sudipshil9862 / fonts-compare

fonts rendering and comparing
GNU General Public License v2.0
6 stars 2 forks source link

The label of Font button still says "None" #33

Closed tagoh closed 1 year ago

tagoh commented 1 year ago

When fonts-compare grabs a font "Biwidth" which is available from efont-unicode-bdf package on Fedora, the label of the font button displays "None".

The debugging logs are attached:

2023-03-03 18:33:08,937 fonts_compare.py line 869 _on_language_menu_popover_listbox_row_selected INFO: language selected from menu = ja
2023-03-03 18:33:08,938 fonts_compare.py line 876 _on_language_menu_popover_listbox_row_selected INFO: no set_preview function for font_dialog
2023-03-03 18:33:08,938 fonts_compare.py line 1053 get_default_font_family_for_language INFO: language: ja
2023-03-03 18:33:08,982 fonts_compare.py line 1070 get_default_font_family_for_language INFO: default font families=['Noto Sans CJK JP']
2023-03-03 18:33:08,983 fonts_compare.py line 1071 get_default_font_family_for_language INFO: default familylang=['en']
2023-03-03 18:33:08,983 fonts_compare.py line 1085 get_default_font_family_for_language INFO: selected default font = Noto Sans CJK JP
2023-03-03 18:33:08,983 fonts_compare.py line 693 set_font INFO: label1 text now: 日本語
2023-03-03 18:33:08,983 fonts_compare.py line 695 set_font INFO: self.font_dialog_button1.set_font(Noto Sans CJK JP 40)
2023-03-03 18:33:08,983 fonts_compare.py line 698 set_font INFO: self.font_dialog_button1.get_font(Noto Sans CJK JP 40)
2023-03-03 18:33:09,022 fonts_compare.py line 1124 get_random_font_family_for_language INFO: selected random list from fc-list = Biwidth:familylang=en:style=Regular
2023-03-03 18:33:09,022 fonts_compare.py line 1155 get_random_font_family_for_language INFO: Random font families=['Biwidth']
2023-03-03 18:33:09,022 fonts_compare.py line 1156 get_random_font_family_for_language INFO: Random font familylang=['en']
2023-03-03 18:33:09,022 fonts_compare.py line 1170 get_random_font_family_for_language INFO: selected default font = Biwidth
2023-03-03 18:33:09,022 fonts_compare.py line 703 set_font INFO: label2 text now: 日本語
2023-03-03 18:33:09,022 fonts_compare.py line 704 set_font INFO: self.font_dialog_button2.set_font(Biwidth 40)

(python3:265670): GLib-GIO-CRITICAL **: 18:33:09.023: g_list_model_get_n_items: assertion 'G_IS_LIST_MODEL (list)' failed
2023-03-03 18:33:09,023 fonts_compare.py line 708 set_font INFO: self.font_dialog_button2.get_font(Biwidth 40)
2023-03-03 18:33:09,023 fonts_compare.py line 1034 detect_language INFO: Trying to detect language of: 日本語
2023-03-03 18:33:09,024 fonts_compare.py line 890 _on_language_menu_popover_listbox_row_selected DEBUG: label_lang_full_form=標準中国語 (繁体字) (台湾)
tagoh commented 1 year ago

Well, I guess this is a sort of the logic bug. Pango explicitly ignores the non-scalable fonts because it isn't useful. So you couldn't get the name from the list of fonts on the font chooser. that may be why I saw this.

You should also drop a font from the result when they have "PCF" in "fontformat".

tagoh commented 1 year ago

Sorry, the above fix has ineffective and redundant code. As I mentioned on Chat, "PCF" nor "fontformat" isn't a font family name. "fontformat" is a prioerty name available in fontconfig cache which contains a font format such as PCF, CFF, TrueType and so on. If a font has "PCF" as "fontformat" property, that would means they are a PCF font. In most cases, Pango doesn't care. So I suggested you should simply drop such fonts from the list. And what I also suggested on Chat is, you can get scalable fonts only by fc-list :scalable=true. In this case, you don't need to go through the list and check if they are PCF or not because fc-list will filter it out.

What you need was to change this line:

                   [fc_list_binary, f':lang={lang}', 'family', 'style', 'familylang'],

To

                   [fc_list_binary, f':lang={lang}:scalable=true', 'family', 'style', 'familylang'],

That's it.

sudipshil9862 commented 1 year ago

same way I did it indirectly like from output of fc-list :lang={lang} family style familylang, I removed the fonts that are the output of fc-list :scalable=false family style familylang

Thanks for the information changing with fc-list :lang={lang}:scalable=true family

sudipshil9862 commented 1 year ago

Here is the login: firstly, it checks for output of fc-list :lang=en:scalable=true family, which are scalable. Secondly, it checks for fc-list :fontformat=PCF family, which fonts have "PCF" as "fontformat" property removing second output from the first output.

tagoh commented 1 year ago

Secondly, it checks for fc-list :fontformat=PCF family, which fonts have "PCF" as "fontformat" property removing second output from the first output.

No. you don't need it! PCF is a bitmap font format and it is non-scalable font. As I said at https://github.com/sudipshil9862/fonts-compare/issues/33#issuecomment-1453925112, "you don't need to go through the list and check if they are PCF or not because fc-list will filter it out." that works enough.

sudipshil9862 commented 1 year ago

fc-list :lang=en:scalable=true family style will remove non-scalable fonts and PCF is non-scalable fonts. So, no need to check for "PCF" as "fontformat" property. Thanks for the info @tagoh .. means a lot