summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2020-03-20 10:47:19 +0100
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2020-03-20 10:47:19 +0100
commit10a9a0440ef66ad103d15bcc58ea189b9ccb4a09 (patch)
tree9f0074b36278f932b8014d0059260f3b76c29b97 /src/drivers
parent214f14db8a50fbbf30c99b614a8920436bfe3333 (diff)
Rewrite Fl_Xlib_Graphics_Driver::get_font_name() with less lines of code.
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx22
1 files changed, 6 insertions, 16 deletions
diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx
index 5d5b4afdf..ee36e1cf6 100644
--- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx
+++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx
@@ -977,45 +977,35 @@ float Fl_Xlib_Graphics_Driver::scale_font_for_PostScript(Fl_Font_Descriptor *des
// of the font name array.
#define ENDOFBUFFER 127 // sizeof(Fl_Font.fontname)-1
-#if USE_PANGO
// turn a stored font name in "fltk format" into a pretty name:
const char* Fl_Xlib_Graphics_Driver::get_font_name(Fl_Font fnum, int* ap) {
Fl_Fontdesc *f = fl_fonts + fnum;
if (!f->fontname[0]) {
const char* p = f->name;
int type;
+#if USE_PANGO
type = 0;
if (strstr(p, " Bold")) type = FL_BOLD;
if (strstr(p, " Italic") || strstr(p, " Oblique")) type += FL_ITALIC;
strlcpy(f->fontname, p, ENDOFBUFFER);
- f->fontname[ENDOFBUFFER] = (char)type;
- }
- if (ap) *ap = f->fontname[ENDOFBUFFER];
- return f->fontname;
-}
#else
-const char* Fl_Xlib_Graphics_Driver::get_font_name(Fl_Font fnum, int* ap) {
- Fl_Fontdesc *f = fl_fonts + fnum;
- if (!f->fontname[0]) {
- const char* p = f->name;
- int type;
switch (p[0]) {
- case 'B': type = FL_BOLD; break;
- case 'I': type = FL_ITALIC; break;
- case 'P': type = FL_BOLD | FL_ITALIC; break;
- default: type = 0; break;
+ case 'B': type = FL_BOLD; break;
+ case 'I': type = FL_ITALIC; break;
+ case 'P': type = FL_BOLD | FL_ITALIC; break;
+ default: type = 0; break;
}
// NOTE: This can cause duplications in fonts that already have Bold or Italic in
// their "name". Maybe we need to find a cleverer way?
strlcpy(f->fontname, p+1, ENDOFBUFFER);
if (type & FL_BOLD) strlcat(f->fontname, " bold", ENDOFBUFFER);
if (type & FL_ITALIC) strlcat(f->fontname, " italic", ENDOFBUFFER);
+#endif // USE_PANGO
f->fontname[ENDOFBUFFER] = (char)type;
}
if (ap) *ap = f->fontname[ENDOFBUFFER];
return f->fontname;
}
-#endif // USE_PANGO
float Fl_Xlib_Graphics_Driver::scale_bitmap_for_PostScript() {
return 2;