Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit be1d7dd

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

File tree

Expand file treeCollapse file tree

1 file changed

+9
-7
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-7
lines changed

‎src/ft2font.cpp

Copy file name to clipboardExpand all lines: src/ft2font.cpp
+9-7Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.