Dont call the font change machinery when the actual size has not changed
This commit is contained in:
parent
dc7d705c87
commit
3ec64a17f8
@ -262,9 +262,9 @@ harfbuzz_font_for_face(PyObject *self) { return ((Face*)self)->harfbuzz_font; }
|
||||
|
||||
bool
|
||||
set_size_for_face(PyObject *s, float pt_sz, float xdpi, float ydpi) {
|
||||
return true;
|
||||
Face *self = (Face*)s;
|
||||
float dpi = (xdpi + ydpi) / 2.f;
|
||||
if (self->dpi == dpi && self->point_sz == pt_sz) return true;
|
||||
CTFontRef f = CTFontCreateCopyWithAttributes(self->font, self->scaled_point_sz, NULL, NULL);
|
||||
if (f == NULL) { PyErr_SetString(PyExc_ValueError, "Failed to create font copy with different size"); return false; }
|
||||
CFRelease(self->font); self->font = NULL;
|
||||
|
||||
@ -88,10 +88,12 @@ set_font_size(Face *self, FT_F26Dot6 char_width, FT_F26Dot6 char_height, FT_UInt
|
||||
}
|
||||
|
||||
bool
|
||||
set_size_for_face(PyObject *self, float pt_sz, float xdpi, float ydpi) {
|
||||
set_size_for_face(PyObject *s, float pt_sz, float xdpi, float ydpi) {
|
||||
Face *self = (Face*)s;
|
||||
FT_UInt w = (FT_UInt)(ceilf(pt_sz * 64));
|
||||
if (self->char_width == w && self->char_height == w && self->xdpi == (FT_UInt)xdpi && self->ydpi == (FT_UInt)ydpi) return true;
|
||||
((Face*)self)->size_in_pts = pt_sz;
|
||||
return set_font_size((Face*)self, w, w, (FT_UInt)xdpi, (FT_UInt) ydpi);
|
||||
return set_font_size(self, w, w, (FT_UInt)xdpi, (FT_UInt) ydpi);
|
||||
}
|
||||
|
||||
static inline int
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user