From 4c5079ef143d4b23db0827421eb80f0d98f3ce44 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sun, 18 Aug 2019 18:50:15 +0200 Subject: [PATCH] Clarify docstring of FT2Font.get_glyph_name. Sometimes the glyph_name returned is completely made up. We can't fix that for now (this requires changes in ttfont), but at least we can warn about it. --- src/ft2font_wrapper.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/ft2font_wrapper.cpp b/src/ft2font_wrapper.cpp index e1fc5741f214..ef2ac5fc87f8 100644 --- a/src/ft2font_wrapper.cpp +++ b/src/ft2font_wrapper.cpp @@ -945,19 +945,20 @@ static PyObject *PyFT2Font_draw_glyph_to_bitmap(PyFT2Font *self, PyObject *args, const char *PyFT2Font_get_glyph_name__doc__ = "get_glyph_name(index)\n" "\n" - "Retrieves the ASCII name of a given glyph in a face.\n"; + "Retrieves the ASCII name of a given glyph in a face.\n" + "\n" + "Due to Matplotlib's internal design, for fonts that do not contain glyph \n" + "names (per FT_FACE_FLAG_GLYPH_NAMES), this returns a made-up name which \n" + "does *not* roundtrip through `.get_name_index`.\n"; static PyObject *PyFT2Font_get_glyph_name(PyFT2Font *self, PyObject *args, PyObject *kwds) { unsigned int glyph_number; char buffer[128]; - if (!PyArg_ParseTuple(args, "I:get_glyph_name", &glyph_number)) { return NULL; } - CALL_CPP("get_glyph_name", (self->x->get_glyph_name(glyph_number, buffer))); - return PyUnicode_FromString(buffer); }