Fix for STR#3374: Crash with pango enabled when changing default font

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12218 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2017-04-12 12:41:47 +00:00
parent cd10796251
commit ed807788ff
2 changed files with 12 additions and 5 deletions

View File

@ -187,6 +187,9 @@ const char *Fl_Xlib_Graphics_Driver::font_name(int num) {
}
void Fl_Xlib_Graphics_Driver::font_name(int num, const char *name) {
#if USE_PANGO
init_built_in_fonts();
#endif
Fl_Fontdesc *s = fl_fonts + num;
if (s->name) {
if (!strcmp(s->name, name)) {s->name = name; return;}

View File

@ -1272,7 +1272,8 @@ void Fl_Xlib_Graphics_Driver::text_extents(const char *str, int n, int &dx, int
}
int Fl_Xlib_Graphics_Driver::height() {
return font_descriptor()->height_;
if (font_descriptor()) return font_descriptor()->height_;
else return -1;
}
double Fl_Xlib_Graphics_Driver::width(unsigned int c) {
@ -1282,7 +1283,8 @@ double Fl_Xlib_Graphics_Driver::width(unsigned int c) {
}
int Fl_Xlib_Graphics_Driver::descent() {
return font_descriptor()->descent_;
if (font_descriptor()) return font_descriptor()->descent_;
else return -1;
}
typedef int (*sort_f_type)(const void *aa, const void *bb);
@ -1327,9 +1329,11 @@ Fl_Font Fl_Xlib_Graphics_Driver::set_fonts(const char* pattern_name)
void Fl_Xlib_Graphics_Driver::init_built_in_fonts() {
static int i = 0;
while (i < FL_FREE_FONT) {
Fl::set_font((Fl_Font)i, built_in_table[i].name);
i++;
if (!i) {
while (i < FL_FREE_FONT) {
i++;
Fl::set_font((Fl_Font)i-1, built_in_table[i-1].name);
}
}
}