Fix a handle leak in TtfFontList::PlotString.

This commit is contained in:
whitequark 2016-10-10 21:16:22 +00:00
parent 476860acbb
commit 66ed417d45

View File

@ -88,7 +88,9 @@ void TtfFontList::PlotString(const std::string &font, const std::string &str,
[&](const TtfFont &tf) { return tf.FontFileBaseName() == font; });
if(!str.empty() && tf != &l.elem[l.n]) {
if(tf->fontFace == NULL) {
tf->LoadFromFile(fontLibrary, /*nameOnly=*/false);
}
tf->PlotString(str, sbl, origin, u, v);
} else {
// No text or no font; so draw a big X for an error marker.
@ -135,6 +137,7 @@ bool TtfFont::LoadFromFile(FT_Library fontLibrary, bool nameOnly) {
dbp("freetype: loading unicode CMap for file '%s' failed: %s",
fontFile.c_str(), ft_error_string(fterr));
FT_Done_Face(fontFace);
fontFace = NULL;
return false;
}