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
Fl::get_font_name() with Pango is inconsistent #732
Comments
The commit mentionned above should fix the issue. @wcout Please, close issue if you confirm it's fixed. |
Yes that fixes it, but only partially.
I tried (for Cairo+Pango) the following change to remove the "Regular" from the name, and I can see no side effects. This would make the Pango version behave like the non-Pango (Xft only) version: diff --git a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx
index fcc83dc5b..1720b569d 100644
--- a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx
+++ b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx
@@ -1089,10 +1089,15 @@ Fl_Font Fl_Cairo_Graphics_Driver::set_fonts(const char* /*pattern_name*/)
pango_font_family_list_faces(families[fam], &faces, &n_faces);
for (int j = 0; j < n_faces; j++) {
const char *p = pango_font_face_get_face_name(faces[j]);
+ if (!strcasecmp(p, "regular"))
+ p = "";
// build the font's FLTK name
int lfont = lfam + strlen(p) + 2;
char *q = new char[lfont];
- snprintf(q, lfont, "%s %s", fam_name, p);
+ if (*p)
+ snprintf(q, lfont, "%s %s", fam_name, p);
+ else
+ snprintf(q, lfont, "%s", fam_name);
Fl::set_font((Fl_Font)(count++ + FL_FREE_FONT), q);
}
/*g_*/free(faces); // glib source code shows that g_free is equivalent to free
Note: This also fixes the name of fonts that don't have a 'Regular' string in it, these are currently created with a space at the end, like here (excerpt from a debug output of fonts list): Font 346: 'Mitra Mono '
Font 347: 'Mitra Mono Bold'
Font 348: 'Mitra Mono Italic'
Font 349: 'Mitra Mono Bold Italic'
Font 350: 'Monospace '
|
The Xft+Pango case should be fixed now. I'm not keen to remove the Regular suffix from Pango font names because Pango can put many suffixes besides Regular, Bold and Italic: Normal, Oblique, Medium, Roman, Light, Demi, Sans, SemiCondensed, SuperBold, Book, etc... Thus, I see Regular as part of the font names rather than as an annoying suffix. |
I see only this problem for an application: |
There are many differences in font names between the Xft and the Pango setups, besides presence or absence of the " Regular" suffix. I would believe it's not correct to expect a config file containing font names prepared under Xft to work in a Pango setup. |
The fix for Xft does not work. But there is something wrong fundamentally here: fl_getenv() is returning just the language string e.g. "de_DE.UTF-8", but is then compared with "LANG=C" and afterwards set with fl_putenv() e.g. |
JFYI: I see now, why the Xft-version does not produce font names containing "Regular": It is effectively filtered out by FLTK here:
|
Oops. The fixes should work after the last 2 commits mentionned above. |
Ok - checked both - working! I assume the argument about the Xft case actively suppressing the "Regular" string didn't make you rethink :( So will close though this leaves some inconsistency in the behaviour... |
OK. The last commit removes all " Regular" suffixes from font names for the sake of compatibility with Xft before Pango, even if I believe it's not as clean a way to present font names as with the suffix. |
Great, thanks! |
Describe the bug
When building FLTK with Pango (either Xft+Pango or Wayland/Cairo+Pango) some fonts are not with correct style information.
I am observing this in special with the
msttcorefonts
.To Reproduce
msttcorefont
package installed with your system. You will get the additional true type fonts Arial, Courier New, Verdana, ...test/fonts
and look at e.g. the Ariel fontExpected behavior
The name should be consistent/independent from LANG and/or the style information should be correct.
Fl::get_font_name(name, &attr)
should fill theattr
information correctly.An additional minor difference to the Xft version is (even when LANG is changed to an english one), that the name of the normal font is given as e.g. "Arial Regular" (Xft version gives just "Arial"). This makes it difficult to use
Fl::set_font(Fl_Font, const char *name)
consistently across platforms (though this could be worked around at application level, ifattr
would be correct fromFl::get_font()
).Screenshots
This is e.g. when LANG is set to 'fr':
FLTK Version
Git current.
FLTK Configure / Build Options
Operating System / Platform:
Linux: Ubuntu 20.04
Linux/Unix Runtime, if applicable:
The text was updated successfully, but these errors were encountered: