8000 Fix #1710. When a font doesn't have glyph names, we should synthesiz… · matplotlib/matplotlib@be1d7dd · GitHub
[go: up one dir, main page]

Skip to content

Commit be1d7dd

Browse files
committed
Fix #1710. When a font doesn't have glyph names, we should synthesize them.
1 parent 7147317 commit be1d7dd

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/ft2font.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1616,15 +1616,17 @@ FT2Font::get_glyph_name(const Py::Tuple & args)
16161616
_VERBOSE("FT2Font::get_glyph_name");
16171617
args.verify_length(1);
16181618

1619-
if (!FT_HAS_GLYPH_NAMES(face))
1620-
{
1621-
throw Py::RuntimeError("Face has no glyph names");
1622-
}
1623-
16241619
char buffer[128];
1625-
if (FT_Get_Glyph_Name(face, (FT_UInt) (unsigned long)Py::Int(args[0]), buffer, 128))
1620+
FT_UInt glyph_number = Py::Int(args[0]);
1621+
1622+
if (!FT_HAS_GLYPH_NAMES(face))
16261623
{
1627-
throw Py::RuntimeError("Could not get glyph names.");
1624+
snprintf(buffer, 128, "uni%04x", glyph_number);
1625+
} else {
1626+
if (FT_Get_Glyph_Name(face, glyph_number, buffer, 128))
1627+
{
1628+
throw Py::RuntimeError("Could not get glyph names.");
1629+
}
16281630
}
16291631
return Py::String(buffer);
16301632
}

0 commit comments

Comments
 (0)
0