Display all fonts of a single character

Post general font related questions (e.g. how to install, convert and use fonts) and requests (looking for fonts, designers etc.) here.
Post Reply
Marcel
Posts: 26
Joined: Mon Sep 28, 2015 3:54 pm

Display all fonts of a single character

Post by Marcel » Sun Mar 10, 2019 10:09 pm

Bhikkhu Pesala wrote:
Tue Feb 26, 2019 5:47 am
Type a "y" in the Font Name field, and display the Font Name Column.
That works fantastically. Many thanks too.

If we wish to filter the fonts on the criterium whether they support a given character or not, and output the list in a text file, we may get this list directly and then check the fonts back in Main Type.

We may do that by running this Python script, that we may store in a file called "f.py". It is based on this forum post: https://askubuntu.com/questions/27598/l ... -character, that links to this other forum post: https://apple.stackexchange.com/questio ... -character.

The script is reported to run on macOS, but I ran it on Linux so to use it on a Windows computer we need to install e.g. Ubuntu on a small partition alongside.

Of course the routine called by the script does check only the fonts that it finds on the system that it is running on, so the font files to check must be put at reach. The Windows EULA forbids to use Windows system files outside the licensed installation, but I copied the Windows fonts to Linux only to check them, not to use them. And I’ve already disabled (by renaming it) the .fonts folder in my /home directory (keeping it for further checks) that the Windows font files go into for that purpose.

Code: Select all

#!/usr/bin/env python3

# Finds fonts containing a single Unicode character passed as a command line argument.
# Supports continuous logging of searched characters, font lists and counts in "out.txt".

# Based on the script posted on the following fora:
# <https://askubuntu.com/questions/27598/list-of-fonts-containing-selected-character>
# <https://apple.stackexchange.com/questions/287707/get-list-of-all-fonts-containing-a-specific-character>

# Requirement: python3-fontconfig package.

# Syntax: $ python3 <script file name>.py <literal goes here>

import sys

def find_fonts(c):
    import fontconfig
    fonts = fontconfig.query()
    for path in sorted(fonts):
        font = fontconfig.FcFont(path)
        if font.has_char(c):
            yield path

with open('out.txt', 'a') as f:
    print("\n\nThe Unicode character <", sys.argv[1], ">",\
                hex(ord(sys.argv[1])), "is supported by these installed fonts:\n", file=f)
    print("\n\nThe Unicode character <", sys.argv[1], ">",\
                hex(ord(sys.argv[1])), "is supported by these installed fonts:\n")
    count = 0

    if __name__ == '__main__':
        import sys
        search = sys.argv[1]
        char = search.decode('utf-8') if isinstance(search, bytes) else search
        for path in find_fonts(char):
            count += 1
            print(count, path, file=f)
            print(count, path)
     
with open('out.txt', 'a') as f:
    print("\nThere are", count, "fonts supporting <", sys.argv[1], ">", hex(ord(sys.argv[1])), "at reach on this OS.\n", file=f)
    print("\nThere are", count, "fonts supporting <", sys.argv[1], ">", hex(ord(sys.argv[1])), "at reach on this OS.\n")
When checking the Unicode character U+2060 WORD JOINER, we need to type a word joiner from the keyboard into the command line, or paste it into the terminal from the clipboard.

Among all the fonts shipped with version 1607 of Windows 10, only these few do support the WORD JOINER (that joined the Unicode Standard back in 2002):

javatext.ttf
micross.ttf
mmrtext.ttf
mmrtextb.ttf
seguisym.ttf
times.ttf
timesbd.ttf
timesbi.ttf
timesi.ttf

I.e. Javanese Text, Microsoft Sans Serif, Myanmar Text, Segoe UI Symbols, and Times New Roman.

Well, that’s it. This weak font support is the more annoying as the word joiner is recommended by Unicode — over the legacy (and now deprecated for this semantics) U+FEFF ZERO WIDTH NO-BREAK SPACE — to prevent undesired line breaks, so that we should use it to make non-breaking spaces out of the many spaces that were encoded in the range U+2002..U+200A and that should be non-breaking but are not, except U+2007 FIGURE SPACE, and except in Donald Knuth’s TeX (that has consistently U+2000 and U+2001 as breaking spaces so that we have both sorts to choose from, rather than two useless duplicates).

OK the last paragraph is a bit off-topic here but exemplifies how we may need to get the fonts listed in a hard-coded way to make sure we didn’t overlook any.
Last edited by Marcel on Wed Mar 13, 2019 6:47 pm, edited 4 times in total.

Bhikkhu Pesala
Top Typographer
Top Typographer
Posts: 8344
Joined: Tue Oct 29, 2002 5:28 am
Location: Seven Kings, London UK
Contact:

Re: Display all fonts of a single character

Post by Bhikkhu Pesala » Mon Mar 11, 2019 5:28 am

I thought your post was a bit too far off-topic in the MainType thread where it was originally posted, so I moved it to where it may be discussed if anyone is interested.

If I don't want a word to break, I disable hyphenation for that word by inserting a soft hyphen before the word.

If the word joiner is deprecated, it is unlikely to be added to many fonts. It is also difficult to type.

Serif PagePlus includes an item on the menu to insert a non-breaking space.
Non-breaking Space.png
Non-breaking Space.png (4.7 KiB) Viewed 870 times
My FontsReviews: MainTypeFont CreatorHelpFC12 Pro + MT9.0 @ Win10 1903 build 18362.356

Marcel
Posts: 26
Joined: Mon Sep 28, 2015 3:54 pm

Re: Display all fonts of a single character

Post by Marcel » Mon Mar 11, 2019 8:05 pm

Bhikkhu Pesala wrote:
Mon Mar 11, 2019 5:28 am
I thought your post was a bit too far off-topic in the MainType thread where it was originally posted, so I moved it to where it may be discussed if anyone is interested.
Thank you, I see that this is a good idea, as the etiquette about keeping topics together and avoiding duplicate threads may finally not apply here when looking harder it appears that the new turn takes us somewhat away from the OP’s request. Would it be good to post a link there?
If I don't want a word to break, I disable hyphenation for that word by inserting a soft hyphen before the word.
Thank you for this advice. I’ve got U+00AD SOFT HYPHEN on keyboard at Shift+E01 ["1" key].
If the word joiner is deprecated, it is unlikely to be added to many fonts. It is also difficult to type.
In fact it’s the opposite; sorry for not being clear. The word joining semantics of U+FEFF ZERO WIDTH NO-BREAK SPACE is deprecated. (I’ve got both on keyboard at Shift+SPM+SPI+C05 or C04, respectively.)
Serif PagePlus includes an item on the menu to insert a non-breaking space.
If this inserts U+00A0 NO-BREAK SPACE, the resulting behavior if untailored is justifying. If the Thin Space menu item inserts U+2009 THIN SPACE, the resulting behavior if untailored is breaking.

I’m afraid I need to open a new thread about these characters.

Also I need to check Windows fonts again, as the collection I’ve checked actually includes additional software-bundled fonts that I was unaware of, and I need to know what comes with Windows. This too is off-topic here. I’m likely to correct my previous post a bit later, and launch the spun-off threads a bit later again, as I’m actually striving to meet some deadlines related to keyboarding.

Thank you for looking into this.

Post Reply