Show only fonts which support a certain codepage

I’m writing greek, german and english texts. Trying to find a font for the greek part is difficult, because not every font installed supports the greek unicode codepoint. It’s difficult to find the one with greek codepoint due to the fact that the font manager has an implicit fallback to a default font whem a character isn’t found in the selected font.
Is it possible to show (as an option) only those fonts that supprt this codepoint (e.g. selectable in the language combobox)?
Thank you

related : 169180 – Ability to filter-out some typefaces from the list

1 Like

As a workaround, you can type the list of greek characters, then choose menu Format - Character - Font tab, and browse down the font list. You can see in the preview.

It might be better to choose some fonts that support the language beforehand, a quick internet search suggested Gentium or New Athena Unicode for Greek, the latter having more specialist symbols.

Also this page, Fonts - The Document Foundation Wiki has a list

1 Like

It’s not quite easy to distinguish e.g. a sans-serif font with greek codepage and the fallback font Arial

We’re using Python under the hood. :slight_smile:
Here’s a simplified way to check for Greek language support. A return value of 1 indicates the presence of Greek letters in the font.
Using this function, we can output a list of fonts and a Greek language support flag to a new Calc document. Unfortunately, I don’t know of a cross-platform way to get the full path to the file containing the font description. I’m afraid the macros may differ for Windows and Linux.

import struct

def has_greek_chars(font_path):
    with open(font_path, 'rb') as f:
        data = f.read()
        cmap_pos = data.find(b'cmap')
        if cmap_pos == -1:
            return -1
            
        for code in range(0x0391, 0x03CA):
            code_bytes = struct.pack('>H', code)
            if not (code_bytes in data):
                return 0
            
        return 1

We can try the macros in the attached file (macros written in cooperation with Google Gemini).
To run the macro, open the attached file and then
Menu / Tools / Macros / Run Macro / GreekFonts4.ods / Module, Macro Name: create_formatted_font_catalog, Run
A new Calc document will be populated with a list of fonts installed on the system. Fonts that support Greek are highlighted in green.
This macro is only for Windows and Linux.
My Windows instance has 558 fonts installed (249 support Greek).
My Linux Ubuntu clone has 2740 fonts installed (929 support Greek).
Comments and suggestions are welcome.

GreekFonts4.ods (10.2 KB)