Missing Fonts with PangoCairo win32 backed

I thought how will Pango render Wingdings font and tried using it directly but it wasn’t loaded directly in the pangocairo’s win32 font backend. So, I started some kind of checking to find why Pango can’t access it. First I wrote a C program to find the list of fonts, I got this idea some from the mailing list https://mail.gnome.org/archives/gtk-i18n-list/2017-May/msg00000.html

I wrote a C program using that,

#include <pango/pangocairo.h>

int main()
{
    PangoFontMap *fontmap = pango_cairo_font_map_new();
    int n_families=0;
    PangoFontFamily** families=NULL;
    pango_font_map_list_families(
        fontmap,
        &families,
        &n_families
    );
    int i;
    for( i = 0;  i< n_families; i = i + 1 ){
        printf("%s\n", pango_font_family_get_name(families[i]));
    }
    g_free(families);
    g_object_unref(fontmap);
    return 0;
}

That can be compiled using gcc test.c $(pkg-config --cflags --libs pangocairo)

I redirected the output it displayed to win32.txt Next, I rest set PANGOCAIRO_BACKEND env var and run the same program again

export PANGOCAIRO_BACKEND=fc
./a > fc.txt

this time redirected to fc.txt

For comparing the two file I wrote a small python program.

with open('win32.txt') as f:
    win32=[i.strip() for i in f.readlines()]
with open('fc.txt') as f:
    fc=[i.strip() for i in f.readlines()]
print("Fonts in win32 backend but not in Fontconfig Backend")
for i in list(set(win32)-set(fc)):
    print(i)
print('\n\n')
print("Fonts in Fontconfig backend but not in win32 Backend")
for i in list(set(fc)-set(win32)):
    print(i)

The output the python program displayed was

Fonts in win32 backend but not in Fontconfig Backend
Lato Black
Arial Narrow
Segoe UI Semilight
Calibri Light
Segoe UI Light
Fira Code Medium
Bodoni MT Poster Compressed
Fantasy
Poppins SemiBold
Segoe UI Semibold
Texturina Medium
Bodoni MT Condensed
Source Code Pro Black
Roboto Thin
Source Sans Pro Semibold
Bodoni MT Black
Arial Black
Fira Code Retina
Source Sans Pro Black



Fonts in Fontconfig backend but not in win32 Backend
Marlett
Fira Code
Wingdings 2
MS Outlook
MT Extra
Webdings
Symbol
Wingdings
Poppins
Wingdings 3
MS Reference Specialty
Bookshelf Symbol 7
Texturina

which made me wonder, why Webdings font isn’t accessible via win32 backend but is accessible via fontconfig backend? Am I missing something or is it a bug?

1 Like

You can also use pango-list to list the fonts that pango sees. It provides some more details.

1 Like

Each font backend provides pango with a list of fonts. That the fontconfig and win32 backends don’t have the same lists does not really tell you much more than that they are different backends, consulting different sources for their configuration, and thus providing different results.

I have seen it. It provides very much similar result.

I think the wind32 backend is missing the fonts included by default in Windows. See List of typefaces included with Microsoft Windows - Wikipedia for a list.
I could see 9/13 in the list under Fonts in Fontconfig backend but not in win32 Backend in Wikipedia known as the default fonts included in Windows, but Pango couldn’t find it.

What should I other than changing backend using the PANGOCAIRO_BACKEND environment variable, to access those fonts missing in default win32 backend?

I don’t know much about Windows apis.
The win32 backend uses EnumFontFamiliesExW to get its list of families.
There might well be other apis that we could or should use.

Oh! Pango deliberately ignores those fonts.
I get this comment in in pangowin32-fontmap.c

  /* Ignore Symbol fonts (which don't have any Unicode mapping
   * table). We could also be fancy and use the PostScript glyph name
   * table for such if present, and build a Unicode map by mapping
   * each PostScript glyph name to Unicode character. Oh well.
   */

Now I understand what it actually happening, EnumFontFamiliesEx returns fonts, where it returns those missing fonts also, but it is deliberately ignored as in this comment.

Any chances, to add support for that?

EDIT: Adding a print statement there they gets me these names

Symbol Font=Marlett 
Symbol Font=Symbol 
Symbol Font=Wingdings 
Symbol Font=Webdings 
Symbol Font=Wingdings 2 
Symbol Font=Wingdings 3 
Symbol Font=MS Outlook 
Symbol Font=Bookshelf Symbol 7 
Symbol Font=MS Reference Specialty 
Symbol Font=MT Extra 

which matches the previous one.

The comment roughly describes what needs to be done to add support.

Is it worth making an issue on Gitlab?

You can open an issue, for sure, but that does not guarantee that anybody will actually fix it.

It would be best if somebody with experience of handling fonts on Windows fixed the issue and opened a merge request instead.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.