Local ownership for font name.
This commit is contained in:
@ -146,19 +146,19 @@ void FltkFont::initSystemFonts ()
|
|||||||
int k = Fl::set_fonts ("-*-iso10646-1");
|
int k = Fl::set_fonts ("-*-iso10646-1");
|
||||||
for (int i = 0; i < k; i++) {
|
for (int i = 0; i < k; i++) {
|
||||||
int t;
|
int t;
|
||||||
char *name = dStrdup (Fl::get_font_name ((Fl_Font) i, &t));
|
std::string name = Fl::get_font_name ((Fl_Font) i, &t);
|
||||||
|
|
||||||
// normalize font family names (strip off "bold", "italic")
|
// normalize font family names (strip off "bold", "italic")
|
||||||
if (t & FL_ITALIC)
|
if (t & FL_ITALIC)
|
||||||
strstrip(name, " italic");
|
strstrip(name.data(), " italic");
|
||||||
if (t & FL_BOLD)
|
if (t & FL_BOLD)
|
||||||
strstrip(name, " bold");
|
strstrip(name.data(), " bold");
|
||||||
|
|
||||||
_MSG("Found font: %s%s%s\n", name, t & FL_BOLD ? " bold" : "",
|
_MSG("Found font: %s%s%s\n", name, t & FL_BOLD ? " bold" : "",
|
||||||
t & FL_ITALIC ? " italic" : "");
|
t & FL_ITALIC ? " italic" : "");
|
||||||
|
|
||||||
|
|
||||||
auto &family = (*systemFonts)[ name ];
|
auto &family = (*systemFonts)[ name.c_str() ];
|
||||||
if( family ) {
|
if( family ) {
|
||||||
family->set ((Fl_Font) i, t);
|
family->set ((Fl_Font) i, t);
|
||||||
} else {
|
} else {
|
||||||
@ -167,8 +167,6 @@ void FltkFont::initSystemFonts ()
|
|||||||
family = std::make_unique< FontFamily >( (Fl_Font) i, -1, -1, -1 );
|
family = std::make_unique< FontFamily >( (Fl_Font) i, -1, -1, -1 );
|
||||||
family->set( (Fl_Font) i, t );
|
family->set( (Fl_Font) i, t );
|
||||||
}
|
}
|
||||||
|
|
||||||
free (name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user