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 49d7efd

Browse filesBrowse files
committed
Rename/change signature of PyGlyph_new.
Unlike all other ExtensionType_new functions, PyGlyph_new is not a tp_new (https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_new) but simply a plain C function used to construct a struct from the fields of a FT2Font. Rename it to avoid confusion, and make it take a single FT2Font as argument, too (with some additional fixes for const-correctness).
1 parent 3eadeac commit 49d7efd
Copy full SHA for 49d7efd

File tree

Expand file treeCollapse file tree

2 files changed

+13
-14
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+13
-14
lines changed

‎src/ft2font.h

Copy file name to clipboardExpand all lines: src/ft2font.h
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,27 +93,27 @@ class FT2Font
9393
long get_name_index(char *name);
9494
PyObject* get_path();
9595

96-
FT_Face &get_face()
96+
FT_Face const &get_face() const
9797
{
9898
return face;
9999
}
100100
FT2Image &get_image()
101101
{
102102
return image;
103103
}
104-
FT_Glyph &get_last_glyph()
104+
FT_Glyph const &get_last_glyph() const
105105
{
106106
return glyphs.back();
107107
}
108-
size_t get_last_glyph_index()
108+
size_t get_last_glyph_index() const
109109
{
110110
return glyphs.size() - 1;
111111
}
112-
size_t get_num_glyphs()
112+
size_t get_num_glyphs() const
113113
{
114114
return glyphs.size();
115115
}
116-
long get_hinting_factor()
116+
long get_hinting_factor() const
117117
{
118118
return hinting_factor;
119119
}

‎src/ft2font_wrapper.cpp

Copy file name to clipboardExpand all lines: src/ft2font_wrapper.cpp
+8-9Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,13 @@ typedef struct
179179
static PyTypeObject PyGlyphType;
180180

181181
static PyObject *
182-
PyGlyph_new(const FT_Face &face, const FT_Glyph &glyph, size_t ind, long hinting_factor)
182+
PyGlyph_from_FT2Font(const FT2Font *font)
183183
{
184+
const FT_Face &face = font->get_face();
185+
const FT_Glyph &glyph = font->get_last_glyph();
186+
size_t ind = font->get_last_glyph_index();
187+
long hinting_factor = font->get_hinting_factor();
188+
184189
PyGlyph *self;
185190
self = (PyGlyph *)PyGlyphType.tp_alloc(&PyGlyphType, 0);
186191

@@ -625,10 +630,7 @@ static PyObject *PyFT2Font_load_char(PyFT2Font *self, PyObject *args, PyObject *
625630

626631
CALL_CPP("load_char", (self->x->load_char(charcode, flags)));
627632

628-
return PyGlyph_new(self->x->get_face(),
629-
self->x->get_last_glyph(),
630-
self->x->get_last_glyph_index(),
631-
self->x->get_hinting_factor());
633+
return PyGlyph_from_FT2Font(self->x);
632634
}
633635

634636
const char *PyFT2Font_load_glyph__doc__ =
@@ -664,10 +666,7 @@ static PyObject *PyFT2Font_load_glyph(PyFT2Font *self, PyObject *args, PyObject
664666

665667
CALL_CPP("load_glyph", (self->x->load_glyph(glyph_index, flags)));
666668

667-
return PyGlyph_new(self->x->get_face(),
668-
self->x->get_last_glyph(),
669-
self->x->get_last_glyph_index(),
670-
self->x->get_hinting_factor());
669+
return PyGlyph_from_FT2Font(self->x);
671670
}
672671

673672
const char *PyFT2Font_get_width_height__doc__ =

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.