Re: [fltk/fltk] Fl::get_font_name() with Pango is inconsistent (Issue #732)
wcout
Jun 05, 2023
Yes that fixes it, but only partially.
The fix is only for the Cairo+Pango version, not for the Xft+Pango case.
What about the 'Regular' problem mentioned in the issue description (under "Expected behaviour")?
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 '
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: <fltk/fltk/issues/732/1576973376@github.com>
Comments are owned by the poster. All other content is copyright 1998-2025 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.