diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2023-04-14 08:15:50 +0200 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2023-04-14 08:15:50 +0200 |
| commit | 0fe118aa946a6c195d53b929a37be6c1cb3c1bd3 (patch) | |
| tree | 6f6574c9996cf40b804e2e317831243f8ef78a27 | |
| parent | 4769e0085d7e259d68de1f4d22b6a83509fcad05 (diff) | |
Remove duplication of Pango standard font names
And move each array of standard font names to appropriate font-related source file
| -rw-r--r-- | src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx | 28 | ||||
| -rw-r--r-- | src/drivers/Wayland/fl_wayland_platform_init.cxx | 23 | ||||
| -rw-r--r-- | src/drivers/X11/fl_X11_platform_init.cxx | 96 | ||||
| -rw-r--r-- | src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx | 26 | ||||
| -rw-r--r-- | src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx | 46 |
5 files changed, 96 insertions, 123 deletions
diff --git a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx index d07baaf51..0084f8cdf 100644 --- a/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx +++ b/src/drivers/Cairo/Fl_Cairo_Graphics_Driver.cxx @@ -37,6 +37,30 @@ extern unsigned fl_cmap[256]; // defined in fl_color.cxx +// The predefined fonts that FLTK has with Pango: +static Fl_Fontdesc built_in_table[] = { + {"Sans"}, + {"Sans Bold"}, + {"Sans Italic"}, + {"Sans Bold Italic"}, + {"Monospace"}, + {"Monospace Bold"}, + {"Monospace Italic"}, + {"Monospace Bold Italic"}, + {"Serif"}, + {"Serif Bold"}, + {"Serif Italic"}, + {"Serif Bold Italic"}, + {"Standard Symbols PS"}, // FL_SYMBOL + {"Monospace"}, + {"Monospace Bold"}, + {"D050000L"}, // FL_ZAPF_DINGBATS +}; + + +FL_EXPORT Fl_Fontdesc *fl_fonts = built_in_table; + + // duplicated from Fl_PostScript.cxx struct callback_data { const uchar *data; @@ -70,6 +94,7 @@ static void draw_image_cb(void *data, int x, int y, int w, uchar *buf) { curdata += cb_data->D; } } +// end of duplicated part Fl_Cairo_Graphics_Driver::Fl_Cairo_Graphics_Driver() : Fl_Graphics_Driver() { @@ -1001,9 +1026,6 @@ int Fl_Cairo_Graphics_Driver::descent() { } -extern Fl_Fontdesc *fl_fonts; - - void Fl_Cairo_Graphics_Driver::init_built_in_fonts() { static int i = 0; if (!i) { diff --git a/src/drivers/Wayland/fl_wayland_platform_init.cxx b/src/drivers/Wayland/fl_wayland_platform_init.cxx index 880d12310..765a0a1f6 100644 --- a/src/drivers/Wayland/fl_wayland_platform_init.cxx +++ b/src/drivers/Wayland/fl_wayland_platform_init.cxx @@ -33,29 +33,6 @@ #include <stdio.h> -static Fl_Fontdesc built_in_table[] = { // Pango font names - {"Sans"}, - {"Sans Bold"}, - {"Sans Italic"}, - {"Sans Bold Italic"}, - {"Monospace"}, - {"Monospace Bold"}, - {"Monospace Italic"}, - {"Monospace Bold Italic"}, - {"Serif"}, - {"Serif Bold"}, - {"Serif Italic"}, - {"Serif Bold Italic"}, - {"Standard Symbols PS"}, // FL_SYMBOL - {"Monospace"}, // FL_SCREEN - {"Monospace Bold"}, // FL_SCREEN_BOLD - {"D050000L"}, // FL_ZAPF_DINGBATS -}; - - -FL_EXPORT Fl_Fontdesc *fl_fonts = built_in_table; - - #ifdef FLTK_USE_X11 static bool attempt_wayland() { diff --git a/src/drivers/X11/fl_X11_platform_init.cxx b/src/drivers/X11/fl_X11_platform_init.cxx index 477978b97..33ea43bee 100644 --- a/src/drivers/X11/fl_X11_platform_init.cxx +++ b/src/drivers/X11/fl_X11_platform_init.cxx @@ -26,7 +26,6 @@ #include "../Unix/Fl_Unix_System_Driver.H" #include "Fl_X11_Window_Driver.H" #include "../Xlib/Fl_Xlib_Image_Surface_Driver.H" -#include "../Xlib/Fl_Font.H" Fl_Copy_Surface_Driver *Fl_Copy_Surface_Driver::newCopySurfaceDriver(int w, int h) @@ -35,101 +34,6 @@ Fl_Copy_Surface_Driver *Fl_Copy_Surface_Driver::newCopySurfaceDriver(int w, int } -#if !USE_XFT - -// WARNING: if you add to this table, you must redefine FL_FREE_FONT -// in Enumerations.H & recompile!! -static Fl_Xlib_Fontdesc built_in_table[] = { -{"-*-helvetica-medium-r-normal--*"}, -{"-*-helvetica-bold-r-normal--*"}, -{"-*-helvetica-medium-o-normal--*"}, -{"-*-helvetica-bold-o-normal--*"}, -{"-*-courier-medium-r-normal--*"}, -{"-*-courier-bold-r-normal--*"}, -{"-*-courier-medium-o-normal--*"}, -{"-*-courier-bold-o-normal--*"}, -{"-*-times-medium-r-normal--*"}, -{"-*-times-bold-r-normal--*"}, -{"-*-times-medium-i-normal--*"}, -{"-*-times-bold-i-normal--*"}, -{"-*-symbol-*"}, -{"-*-lucidatypewriter-medium-r-normal-sans-*"}, -{"-*-lucidatypewriter-bold-r-normal-sans-*"}, -{"-*-*zapf dingbats-*"} -}; - -#else // USE_XFT - -#if ! USE_PANGO - -// The predefined fonts that FLTK has: -static Fl_Fontdesc built_in_table[] = { -#if 1 - {" sans"}, - {"Bsans"}, - {"Isans"}, - {"Psans"}, - {" mono"}, - {"Bmono"}, - {"Imono"}, - {"Pmono"}, - {" serif"}, - {"Bserif"}, - {"Iserif"}, - {"Pserif"}, - {" symbol"}, - {" screen"}, - {"Bscreen"}, - {" zapf dingbats"}, -#else - {" helvetica"}, - {"Bhelvetica"}, - {"Ihelvetica"}, - {"Phelvetica"}, - {" courier"}, - {"Bcourier"}, - {"Icourier"}, - {"Pcourier"}, - {" times"}, - {"Btimes"}, - {"Itimes"}, - {"Ptimes"}, - {" symbol"}, - {" lucidatypewriter"}, - {"Blucidatypewriter"}, - {" zapf dingbats"}, -#endif -}; - -#else - -// The predefined fonts that FLTK has with Pango: -static Fl_Fontdesc built_in_table[] = { - {"Sans"}, - {"Sans Bold"}, - {"Sans Italic"}, - {"Sans Bold Italic"}, - {"Monospace"}, - {"Monospace Bold"}, - {"Monospace Italic"}, - {"Monospace Bold Italic"}, - {"Serif"}, - {"Serif Bold"}, - {"Serif Italic"}, - {"Serif Bold Italic"}, - {"Sans"}, - {"Monospace"}, - {"Monospace Bold"}, - {"Sans"}, -}; - -#endif // USE_PANGO - -#endif // USE_XFT - -FL_EXPORT Fl_Fontdesc* fl_fonts = (Fl_Fontdesc*)built_in_table; - - Fl_Graphics_Driver *Fl_Graphics_Driver::newMainGraphicsDriver() { #if FLTK_USE_CAIRO diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx index 8a7daf567..94d013b3f 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx @@ -1,7 +1,7 @@ // // X11 font utilities for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2022 by Bill Spitzak and others. +// Copyright 1998-2023 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -29,6 +29,30 @@ static char* fl_find_fontsize(char* name); static const char* fl_font_word(const char* p, int n); +// WARNING: if you add to this table, you must redefine FL_FREE_FONT +// in Enumerations.H & recompile!! +static Fl_Xlib_Fontdesc built_in_table[] = { +{"-*-helvetica-medium-r-normal--*"}, +{"-*-helvetica-bold-r-normal--*"}, +{"-*-helvetica-medium-o-normal--*"}, +{"-*-helvetica-bold-o-normal--*"}, +{"-*-courier-medium-r-normal--*"}, +{"-*-courier-bold-r-normal--*"}, +{"-*-courier-medium-o-normal--*"}, +{"-*-courier-bold-o-normal--*"}, +{"-*-times-medium-r-normal--*"}, +{"-*-times-bold-r-normal--*"}, +{"-*-times-medium-i-normal--*"}, +{"-*-times-bold-i-normal--*"}, +{"-*-symbol-*"}, +{"-*-lucidatypewriter-medium-r-normal-sans-*"}, +{"-*-lucidatypewriter-bold-r-normal-sans-*"}, +{"-*-*zapf dingbats-*"} +}; + +FL_EXPORT Fl_Fontdesc* fl_fonts = (Fl_Fontdesc*)built_in_table; + + // This function fills in the fltk font table with all the fonts that // are found on the X server. It tries to place the fonts into families // and to sort them so the first 4 in a family are normal, bold, italic, 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 9fc98f0dd..8fe677939 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx @@ -34,6 +34,52 @@ Fl_XFont_On_Demand fl_xfont = 0; + +#if ! USE_PANGO + +// The predefined fonts that FLTK has with Xft but without Pango: +static Fl_Fontdesc built_in_table[] = { +#if 1 + {" sans"}, + {"Bsans"}, + {"Isans"}, + {"Psans"}, + {" mono"}, + {"Bmono"}, + {"Imono"}, + {"Pmono"}, + {" serif"}, + {"Bserif"}, + {"Iserif"}, + {"Pserif"}, + {" symbol"}, + {" screen"}, + {"Bscreen"}, + {" zapf dingbats"}, +#else + {" helvetica"}, + {"Bhelvetica"}, + {"Ihelvetica"}, + {"Phelvetica"}, + {" courier"}, + {"Bcourier"}, + {"Icourier"}, + {"Pcourier"}, + {" times"}, + {"Btimes"}, + {"Itimes"}, + {"Ptimes"}, + {" symbol"}, + {" lucidatypewriter"}, + {"Blucidatypewriter"}, + {" zapf dingbats"}, +#endif +}; + +FL_EXPORT Fl_Fontdesc* fl_fonts = (Fl_Fontdesc*)built_in_table; + +#endif // ! USE_PANGO + static void fl_xft_font(Fl_Xlib_Graphics_Driver *driver, Fl_Font fnum, Fl_Fontsize size, int angle); // For some reason Xft produces errors if you destroy a window whose id |
