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

Simplify filename tracking in FT2Font. #21379

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

Merged
merged 1 commit into from
Oct 21, 2021
Merged
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
16 changes: 5 additions & 11 deletions 16 src/ft2font_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ typedef struct
{
PyObject_HEAD
FT2Font *x;
PyObject *fname;
PyObject *py_file;
FT_StreamRec stream;
Py_ssize_t shape[2];
Expand Down Expand Up @@ -317,7 +316,6 @@ static PyObject *PyFT2Font_new(PyTypeObject *type, PyObject *args, PyObject *kwd
PyFT2Font *self;
self = (PyFT2Font *)type->tp_alloc(type, 0);
self->x = NULL;
self->fname = NULL;
self->py_file = NULL;
memset(&self->stream, 0, sizeof(FT_StreamRec));
return (PyObject *)self;
Expand Down Expand Up @@ -408,9 +406,6 @@ static int PyFT2Font_init(PyFT2Font *self, PyObject *args, PyObject *kwds)

CALL_CPP_INIT("FT2Font->set_kerning_factor", (self->x->set_kerning_factor(kerning_factor)));

Py_INCREF(filename);
self->fname = filename;

exit:
return PyErr_Occurred() ? -1 : 0;
}
Expand All @@ -419,7 +414,6 @@ static void PyFT2Font_dealloc(PyFT2Font *self)
{
delete self->x;
Py_XDECREF(self->py_file);
Py_XDECREF(self->fname);
Py_TYPE(self)->tp_free((PyObject *)self);
}

Expand Down Expand Up @@ -1420,12 +1414,12 @@ static PyObject *PyFT2Font_underline_thickness(PyFT2Font *self, void *closure)

static PyObject *PyFT2Font_fname(PyFT2Font *self, void *closure)
{
if (self->fname) {
Py_INCREF(self->fname);
return self->fname;
if (self->stream.close) { // Called passed a filename to the constructor.
return PyObject_GetAttrString(self->py_file, "name");
} else {
Py_INCREF(self->py_file);
return self->py_file;
}

Py_RETURN_NONE;
}

static int PyFT2Font_get_buffer(PyFT2Font *self, Py_buffer *buf, int flags)
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.