Skip to content

Font and text overhaul #30161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions lib/matplotlib/backends/backend_agg.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,20 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
xo, yo = font.get_bitmap_offset()
xo /= 64.0
yo /= 64.0
xd = d * sin(radians(angle))
yd = d * cos(radians(angle))
x = round(x + xo + xd)
y = round(y + yo + yd)

rad = radians(angle)
xd = d * sin(rad)
yd = d * cos(rad)
# Rotating the offset vector ensures text rotates around the anchor point.
# Without this, rotated text offsets incorrectly, causing a horizontal shift.
# Applying the 2D rotation matrix.
rotated_xo = xo * cos(rad) - yo * sin(rad)
rotated_yo = xo * sin(rad) + yo * cos(rad)
# Subtract rotated_yo to account for the inverted y-axis in computer graphics,
# compared to the mathematical convention.
x = round(x + rotated_xo + xd)
y = round(y - rotated_yo + yd)

self._renderer.draw_text_image(font, x, y + 1, angle, gc)

def get_text_width_height_descent(self, s, prop, ismath):
Expand Down
38 changes: 8 additions & 30 deletions lib/matplotlib/backends/backend_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,40 +617,18 @@ def _get_pdf_charprocs(font_path, glyph_ids):
procs = {}
for glyph_id in glyph_ids:
g = font.load_glyph(glyph_id, LoadFlags.NO_SCALE)
# NOTE: We should be using round(), but instead use
# "(x+.5).astype(int)" to keep backcompat with the old ttconv code
# (this is different for negative x's).
d1 = (np.array([g.horiAdvance, 0, *g.bbox]) * conv + .5).astype(int)
d1 = [
round(g.horiAdvance * conv), 0,
# Round bbox corners *outwards*, so that they indeed bound the glyph.
math.floor(g.bbox[0] * conv), math.floor(g.bbox[1] * conv),
math.ceil(g.bbox[2] * conv), math.ceil(g.bbox[3] * conv),
]
v, c = font.get_path()
v = (v * 64).astype(int) # Back to TrueType's internal units (1/64's).
# Backcompat with old ttconv code: control points between two quads are
# omitted if they are exactly at the midpoint between the control of
# the quad before and the quad after, but ttconv used to interpolate
# *after* conversion to PS units, causing floating point errors. Here
# we reproduce ttconv's logic, detecting these "implicit" points and
# re-interpolating them. Note that occasionally (e.g. with DejaVu Sans
# glyph "0") a point detected as "implicit" is actually explicit, and
# will thus be shifted by 1.
quads, = np.nonzero(c == 3)
quads_on = quads[1::2]
quads_mid_on = np.array(
sorted({*quads_on} & {*(quads - 1)} & {*(quads + 1)}), int)
implicit = quads_mid_on[
(v[quads_mid_on] # As above, use astype(int), not // division
== ((v[quads_mid_on - 1] + v[quads_mid_on + 1]) / 2).astype(int))
.all(axis=1)]
if (font.postscript_name, glyph_id) in [
("DejaVuSerif-Italic", 77), # j
("DejaVuSerif-Italic", 135), # \AA
]:
v[:, 0] -= 1 # Hard-coded backcompat (FreeType shifts glyph by 1).
v = (v * conv + .5).astype(int) # As above re: truncation vs rounding.
v[implicit] = (( # Fix implicit points; again, truncate.
(v[implicit - 1] + v[implicit + 1]) / 2).astype(int))
v = (v * 64 * conv).round() # Back to TrueType's internal units (1/64's).
procs[font.get_glyph_name(glyph_id)] = (
" ".join(map(str, d1)).encode("ascii") + b" d1\n"
+ _path.convert_to_string(
Path(v, c), None, None, False, None, -1,
Path(v, c), None, None, False, None, 0,
# no code for quad Beziers triggers auto-conversion to cubics.
[b"m", b"l", b"", b"c", b"h"], True)
+ b"f")
Expand Down
Binary file not shown.
Binary file modified lib/matplotlib/tests/baseline_images/test_axes/fill_units.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified lib/matplotlib/tests/baseline_images/test_axes/imshow_clip.pdf
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified lib/matplotlib/tests/baseline_images/test_ft2font/last_resort.pdf
Binary file not shown.
Binary file modified lib/matplotlib/tests/baseline_images/test_legend/framealpha.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified lib/matplotlib/tests/baseline_images/test_text/multiline.pdf
Binary file not shown.
Binary file modified lib/matplotlib/tests/baseline_images/test_text/multiline2.pdf
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file modified lib/matplotlib/tests/baseline_images/test_text/text_bboxclip.pdf
Binary file not shown.
Binary file not shown.
Binary file modified lib/matplotlib/tests/baseline_images/test_text/titles.pdf
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified lib/matplotlib/tests/baseline_images/test_units/plot_pint.png
16 changes: 16 additions & 0 deletions lib/matplotlib/tests/test_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,22 @@ def test_alignment():
ax.set_yticks([])


@image_comparison(baseline_images=['rotation_anchor.png'], style='mpl20',
remove_text=True)
def test_rotation_mode_anchor():
fig, ax = plt.subplots()

ax.plot([0, 1], lw=0)
ax.axvline(.5, linewidth=.5, color='.5')
ax.axhline(.5, linewidth=.5, color='.5')

N = 4
for r in range(N):
ax.text(.5, .5, 'pP', color=f'C{r}', size=100,
rotation=r/N*360, rotation_mode='anchor',
verticalalignment='center_baseline')


@image_comparison(['axes_titles.png'])
def test_axes_titles():
# Related to issue #3327
Expand Down
47 changes: 17 additions & 30 deletions src/_path.h
Original file line number Diff line number Diff line change
Expand Up @@ -1066,38 +1066,25 @@
void __add_number(double val, char format_code, int precision,
std::string& buffer)
{
if (precision == -1) {
// Special-case for compat with old ttconv code, which *truncated*
// values with a cast to int instead of rounding them as printf
// would do. The only point where non-integer values arise is from
// quad2cubic conversion (as we already perform a first truncation
// on Python's side), which can introduce additional floating point
// error (by adding 2/3 delta-x and then 1/3 delta-x), so compensate by
// first rounding to the closest 1/3 and then truncating.
char str[255];
PyOS_snprintf(str, 255, "%d", (int)(round(val * 3)) / 3);
buffer += str;
} else {
char *str = PyOS_double_to_string(
val, format_code, precision, Py_DTSF_ADD_DOT_0, nullptr);
// Delete trailing zeros and decimal point
char *c = str + strlen(str) - 1; // Start at last character.
// Rewind through all the zeros and, if present, the trailing decimal
// point. Py_DTSF_ADD_DOT_0 ensures we won't go past the start of str.
while (*c == '0') {
--c;
}
if (*c == '.') {
--c;
}
try {
buffer.append(str, c + 1);
} catch (std::bad_alloc& e) {
PyMem_Free(str);
throw e;
}
char *str = PyOS_double_to_string(
val, format_code, precision, Py_DTSF_ADD_DOT_0, nullptr);
// Delete trailing zeros and decimal point
char *c = str + strlen(str) - 1; // Start at last character.
// Rewind through all the zeros and, if present, the trailing decimal
// point. Py_DTSF_ADD_DOT_0 ensures we won't go past the start of str.
while (*c == '0') {
--c;
}
if (*c == '.') {
--c;
}
try {
buffer.append(str, c + 1);
} catch (std::bad_alloc& e) {
PyMem_Free(str);
throw e;

Check warning on line 1085 in src/_path.h

View check run for this annotation

Codecov / codecov/patch

src/_path.h#L1085

Added line #L1085 was not covered by tests
}
PyMem_Free(str);
}


Expand Down
65 changes: 8 additions & 57 deletions src/ft2font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ void FT2Font::clear()
}

glyphs.clear();
glyph_to_font.clear();
char_to_font.clear();

for (auto & fallback : fallbacks) {
Expand Down Expand Up @@ -287,35 +286,13 @@ void FT2Font::select_charmap(unsigned long i)
FT_CHECK(FT_Select_Charmap, face, (FT_Encoding)i);
}

int FT2Font::get_kerning(FT_UInt left, FT_UInt right, FT_Kerning_Mode mode,
bool fallback = false)
{
if (fallback && glyph_to_font.find(left) != glyph_to_font.end() &&
glyph_to_font.find(right) != glyph_to_font.end()) {
FT2Font *left_ft_object = glyph_to_font[left];
FT2Font *right_ft_object = glyph_to_font[right];
if (left_ft_object != right_ft_object) {
// we do not know how to do kerning between different fonts
return 0;
}
// if left_ft_object is the same as right_ft_object,
// do the exact same thing which set_text does.
return right_ft_object->get_kerning(left, right, mode, false);
}
else
{
FT_Vector delta;
return get_kerning(left, right, mode, delta);
}
}

int FT2Font::get_kerning(FT_UInt left, FT_UInt right, FT_Kerning_Mode mode,
FT_Vector &delta)
int FT2Font::get_kerning(FT_UInt left, FT_UInt right, FT_Kerning_Mode mode)
{
if (!FT_HAS_KERNING(face)) {
return 0;
}

FT_Vector delta;
if (!FT_Get_Kerning(face, left, right, mode, &delta)) {
return (int)(delta.x) / (hinting_factor << kerning_factor);
} else {
Expand Down Expand Up @@ -364,16 +341,15 @@ void FT2Font::set_text(
std::set<FT_String*> glyph_seen_fonts;
FT2Font *ft_object_with_glyph = this;
bool was_found = load_char_with_fallback(ft_object_with_glyph, glyph_index, glyphs,
char_to_font, glyph_to_font, codepoint, flags,
char_to_font, codepoint, flags,
charcode_error, glyph_error, glyph_seen_fonts, false);
if (!was_found) {
ft_glyph_warn((FT_ULong)codepoint, glyph_seen_fonts);
// render missing glyph tofu
// come back to top-most font
ft_object_with_glyph = this;
char_to_font[codepoint] = ft_object_with_glyph;
glyph_to_font[glyph_index] = ft_object_with_glyph;
ft_object_with_glyph->load_glyph(glyph_index, flags, ft_object_with_glyph, false);
ft_object_with_glyph->load_glyph(glyph_index, flags);
} else if (ft_object_with_glyph->warn_if_used) {
ft_glyph_warn((FT_ULong)codepoint, glyph_seen_fonts);
}
Expand All @@ -383,8 +359,7 @@ void FT2Font::set_text(
ft_object_with_glyph->has_kerning() && // if the font knows how to kern
previous && glyph_index // and we really have 2 glyphs
) {
FT_Vector delta;
pen.x += ft_object_with_glyph->get_kerning(previous, glyph_index, FT_KERNING_DEFAULT, delta);
pen.x += ft_object_with_glyph->get_kerning(previous, glyph_index, FT_KERNING_DEFAULT);
}

// extract glyph image and store it in our table
Expand Down Expand Up @@ -434,7 +409,7 @@ void FT2Font::load_char(long charcode, FT_Int32 flags, FT2Font *&ft_object, bool
FT_Error charcode_error, glyph_error;
FT2Font *ft_object_with_glyph = this;
bool was_found = load_char_with_fallback(ft_object_with_glyph, final_glyph_index,
glyphs, char_to_font, glyph_to_font,
glyphs, char_to_font,
charcode, flags, charcode_error, glyph_error,
glyph_seen_fonts, true);
if (!was_found) {
Expand Down Expand Up @@ -493,7 +468,6 @@ bool FT2Font::load_char_with_fallback(FT2Font *&ft_object_with_glyph,
FT_UInt &final_glyph_index,
std::vector<FT_Glyph> &parent_glyphs,
std::unordered_map<long, FT2Font *> &parent_char_to_font,
std::unordered_map<FT_UInt, FT2Font *> &parent_glyph_to_font,
long charcode,
FT_Int32 flags,
FT_Error &charcode_error,
Expand Down Expand Up @@ -523,7 +497,6 @@ bool FT2Font::load_char_with_fallback(FT2Font *&ft_object_with_glyph,
// need to store this for anytime a character is loaded from a parent
// FT2Font object or to generate a mapping of individual characters to fonts
ft_object_with_glyph = this;
parent_glyph_to_font[final_glyph_index] = this;
parent_char_to_font[charcode] = this;
parent_glyphs.push_back(thisGlyph);
return true;
Expand All @@ -532,7 +505,7 @@ bool FT2Font::load_char_with_fallback(FT2Font *&ft_object_with_glyph,
for (auto & fallback : fallbacks) {
bool was_found = fallback->load_char_with_fallback(
ft_object_with_glyph, final_glyph_index, parent_glyphs,
parent_char_to_font, parent_glyph_to_font, charcode, flags,
parent_char_to_font, charcode, flags,
charcode_error, glyph_error, glyph_seen_fonts, override);
if (was_found) {
return true;
Expand All @@ -542,21 +515,6 @@ bool FT2Font::load_char_with_fallback(FT2Font *&ft_object_with_glyph,
}
}

void FT2Font::load_glyph(FT_UInt glyph_index,
FT_Int32 flags,
FT2Font *&ft_object,
bool fallback = false)
{
// cache is only for parent FT2Font
if (fallback && glyph_to_font.find(glyph_index) != glyph_to_font.end()) {
ft_object = glyph_to_font[glyph_index];
} else {
ft_object = this;
}

ft_object->load_glyph(glyph_index, flags);
}

void FT2Font::load_glyph(FT_UInt glyph_index, FT_Int32 flags)
{
FT_CHECK(FT_Load_Glyph, face, glyph_index, flags);
Expand Down Expand Up @@ -644,15 +602,8 @@ void FT2Font::draw_glyph_to_bitmap(
draw_bitmap(im, &bitmap->bitmap, x + bitmap->left, y);
}

void FT2Font::get_glyph_name(unsigned int glyph_number, std::string &buffer,
bool fallback = false)
void FT2Font::get_glyph_name(unsigned int glyph_number, std::string &buffer)
{
if (fallback && glyph_to_font.find(glyph_number) != glyph_to_font.end()) {
// cache is only for parent FT2Font
FT2Font *ft_object = glyph_to_font[glyph_number];
ft_object->get_glyph_name(glyph_number, buffer, false);
return;
}
if (!FT_HAS_GLYPH_NAMES(face)) {
/* Note that this generated name must match the name that
is generated by ttconv in ttfont_CharStrings_getname. */
Expand Down
8 changes: 2 additions & 6 deletions src/ft2font.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,19 @@ class FT2Font
void select_charmap(unsigned long i);
void set_text(std::u32string_view codepoints, double angle, FT_Int32 flags,
std::vector<double> &xys);
int get_kerning(FT_UInt left, FT_UInt right, FT_Kerning_Mode mode, bool fallback);
int get_kerning(FT_UInt left, FT_UInt right, FT_Kerning_Mode mode, FT_Vector &delta);
int get_kerning(FT_UInt left, FT_UInt right, FT_Kerning_Mode mode);
void set_kerning_factor(int factor);
void load_char(long charcode, FT_Int32 flags, FT2Font *&ft_object, bool fallback);
bool load_char_with_fallback(FT2Font *&ft_object_with_glyph,
FT_UInt &final_glyph_index,
std::vector<FT_Glyph> &parent_glyphs,
std::unordered_map<long, FT2Font *> &parent_char_to_font,
std::unordered_map<FT_UInt, FT2Font *> &parent_glyph_to_font,
long charcode,
FT_Int32 flags,
FT_Error &charcode_error,
FT_Error &glyph_error,
std::set<FT_String*> &glyph_seen_fonts,
bool override);
void load_glyph(FT_UInt glyph_index, FT_Int32 flags, FT2Font *&ft_object, bool fallback);
void load_glyph(FT_UInt glyph_index, FT_Int32 flags);
void get_width_height(long *width, long *height);
void get_bitmap_offset(long *x, long *y);
Expand All @@ -132,7 +129,7 @@ class FT2Font
void draw_glyph_to_bitmap(
py::array_t<uint8_t, py::array::c_style> im,
int x, int y, size_t glyphInd, bool antialiased);
void get_glyph_name(unsigned int glyph_number, std::string &buffer, bool fallback);
void get_glyph_name(unsigned int glyph_number, std::string &buffer);
long get_name_index(char *name);
FT_UInt get_char_index(FT_ULong charcode, bool fallback);
void get_path(std::vector<double> &vertices, std::vector<unsigned char> &codes);
Expand Down Expand Up @@ -176,7 +173,6 @@ class FT2Font
FT_Vector pen; /* untransformed origin */
std::vector<FT_Glyph> glyphs;
std::vector<FT2Font *> fallbacks;
std::unordered_map<FT_UInt, FT2Font *> glyph_to_font;
std::unordered_map<long, FT2Font *> char_to_font;
FT_BBox bbox;
FT_Pos advance;
Expand Down
12 changes: 4 additions & 8 deletions src/ft2font_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,6 @@ static int
PyFT2Font_get_kerning(PyFT2Font *self, FT_UInt left, FT_UInt right,
std::variant<FT_Kerning_Mode, FT_UInt> mode_or_int)
{
bool fallback = true;
FT_Kerning_Mode mode;

if (auto value = std::get_if<FT_UInt>(&mode_or_int)) {
Expand All @@ -636,7 +635,7 @@ PyFT2Font_get_kerning(PyFT2Font *self, FT_UInt left, FT_UInt right,
throw py::type_error("mode must be Kerning or int");
}

return self->x->get_kerning(left, right, mode, fallback);
return self->x->get_kerning(left, right, mode);
}

const char *PyFT2Font_get_fontmap__doc__ = R"""(
Expand Down Expand Up @@ -834,8 +833,6 @@ static PyGlyph *
PyFT2Font_load_glyph(PyFT2Font *self, FT_UInt glyph_index,
std::variant<LoadFlags, FT_Int32> flags_or_int = LoadFlags::FORCE_AUTOHINT)
{
bool fallback = true;
FT2Font *ft_object = nullptr;
LoadFlags flags;

if (auto value = std::get_if<FT_Int32>(&flags_or_int)) {
Expand All @@ -853,9 +850,9 @@ PyFT2Font_load_glyph(PyFT2Font *self, FT_UInt glyph_index,
throw py::type_error("flags must be LoadFlags or int");
}

self->x->load_glyph(glyph_index, static_cast<FT_Int32>(flags), ft_object, fallback);
self->x->load_glyph(glyph_index, static_cast<FT_Int32>(flags));

return PyGlyph_from_FT2Font(ft_object);
return PyGlyph_from_FT2Font(self->x);
}

const char *PyFT2Font_get_width_height__doc__ = R"""(
Expand Down Expand Up @@ -1022,10 +1019,9 @@ static py::str
PyFT2Font_get_glyph_name(PyFT2Font *self, unsigned int glyph_number)
{
std::string buffer;
bool fallback = true;

buffer.resize(128);
self->x->get_glyph_name(glyph_number, buffer, fallback);
self->x->get_glyph_name(glyph_number, buffer);
return buffer;
}

Expand Down
Loading