Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
tagoh opened this issue Mar 3, 2023 · 6 comments
Closed

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

tagoh opened this issue Mar 3, 2023 · 6 comments

Comments

@tagoh
Copy link

tagoh commented Mar 3, 2023

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
Copy link
Author

tagoh commented Mar 3, 2023

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
Copy link
Author

tagoh commented Mar 3, 2023

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 sudipshil9862 reopened this Mar 6, 2023
@sudipshil9862
Copy link
Owner

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
Copy link
Owner

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
Copy link
Author

tagoh commented Mar 7, 2023

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 #33 (comment), "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
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants