Skip to content

Fix some more integer type inconsistencies in Freetype code #7782

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
Jan 11, 2017
Merged
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
8 changes: 4 additions & 4 deletions src/ft2font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ void FT2Font::select_charmap(unsigned long i)
}
}

int FT2Font::get_kerning(int left, int right, int mode)
int FT2Font::get_kerning(FT_UInt left, FT_UInt right, FT_UInt mode)
{
if (!FT_HAS_KERNING(face)) {
return 0;
Expand All @@ -589,7 +589,7 @@ int FT2Font::get_kerning(int left, int right, int mode)
}

void FT2Font::set_text(
size_t N, uint32_t *codepoints, double angle, FT_UInt32 flags, std::vector<double> &xys)
size_t N, uint32_t *codepoints, double angle, FT_Int32 flags, std::vector<double> &xys)
{
angle = angle / 360.0 * 2 * M_PI;

Expand Down Expand Up @@ -666,7 +666,7 @@ void FT2Font::set_text(
}
}

void FT2Font::load_char(long charcode, FT_UInt32 flags)
void FT2Font::load_char(long charcode, FT_Int32 flags)
{
int error = FT_Load_Char(face, (unsigned long)charcode, flags);

Expand All @@ -684,7 +684,7 @@ void FT2Font::load_char(long charcode, FT_UInt32 flags)
glyphs.push_back(thisGlyph);
}

void FT2Font::load_glyph(FT_UInt glyph_index, FT_UInt32 flags)
void FT2Font::load_glyph(FT_UInt glyph_index, FT_Int32 flags)
{
int error = FT_Load_Glyph(face, glyph_index, flags);

Expand Down
8 changes: 4 additions & 4 deletions src/ft2font.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ class FT2Font
void set_charmap(int i);
void select_charmap(unsigned long i);
void set_text(
size_t N, uint32_t *codepoints, double angle, FT_UInt32 flags, std::vector<double> &xys);
int get_kerning(int left, int right, int mode);
void load_char(long charcode, FT_UInt32 flags);
void load_glyph(FT_UInt glyph_index, FT_UInt32 flags);
size_t N, uint32_t *codepoints, double angle, FT_Int32 flags, std::vector<double> &xys);
int get_kerning(FT_UInt left, FT_UInt right, FT_UInt mode);
void load_char(long charcode, FT_Int32 flags);
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);
long get_descent();
Expand Down
28 changes: 19 additions & 9 deletions src/ft2font_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,9 +621,10 @@ const char *PyFT2Font_get_kerning__doc__ =

static PyObject *PyFT2Font_get_kerning(PyFT2Font *self, PyObject *args, PyObject *kwds)
{
int left, right, mode, result;
FT_UInt left, right, mode;
int result;

if (!PyArg_ParseTuple(args, "iii:get_kerning", &left, &right, &mode)) {
if (!PyArg_ParseTuple(args, "III:get_kerning", &left, &right, &mode)) {
return NULL;
}

Expand All @@ -643,12 +644,15 @@ static PyObject *PyFT2Font_set_text(PyFT2Font *self, PyObject *args, PyObject *k
{
PyObject *textobj;
double angle = 0.0;
FT_UInt32 flags = FT_LOAD_FORCE_AUTOHINT;
FT_Int32 flags = FT_LOAD_FORCE_AUTOHINT;
std::vector<double> xys;
const char *names[] = { "string", "angle", "flags", NULL };

/* This makes a technically incorrect assumption that FT_Int32 is
int. In theory it can also be long, if the size of int is less
than 32 bits. This is very unlikely on modern platforms. */
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "O|dI:set_text", (char **)names, &textobj, &angle, &flags)) {
args, kwds, "O|di:set_text", (char **)names, &textobj, &angle, &flags)) {
return NULL;
}

Expand Down Expand Up @@ -712,11 +716,14 @@ const char *PyFT2Font_load_char__doc__ =
static PyObject *PyFT2Font_load_char(PyFT2Font *self, PyObject *args, PyObject *kwds)
{
long charcode;
FT_UInt32 flags = FT_LOAD_FORCE_AUTOHINT;
FT_Int32 flags = FT_LOAD_FORCE_AUTOHINT;
const char *names[] = { "charcode", "flags", NULL };

/* This makes a technically incorrect assumption that FT_Int32 is
int. In theory it can also be long, if the size of int is less
than 32 bits. This is very unlikely on modern platforms. */
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "k|I:load_char", (char **)names, &charcode, &flags)) {
args, kwds, "l|i:load_char", (char **)names, &charcode, &flags)) {
return NULL;
}

Expand Down Expand Up @@ -747,11 +754,14 @@ const char *PyFT2Font_load_glyph__doc__ =
static PyObject *PyFT2Font_load_glyph(PyFT2Font *self, PyObject *args, PyObject *kwds)
{
FT_UInt glyph_index;
FT_UInt32 flags = FT_LOAD_FORCE_AUTOHINT;
FT_Int32 flags = FT_LOAD_FORCE_AUTOHINT;
const char *names[] = { "glyph_index", "flags", NULL };

/* This makes a technically incorrect assumption that FT_Int32 is
int. In theory it can also be long, if the size of int is less
than 32 bits. This is very unlikely on modern platforms. */
if (!PyArg_ParseTupleAndKeywords(
args, kwds, "I|I:load_glyph", (char **)names, &glyph_index, &flags)) {
args, kwds, "I|i:load_glyph", (char **)names, &glyph_index, &flags)) {
return NULL;
}

Expand Down Expand Up @@ -901,7 +911,7 @@ static PyObject *PyFT2Font_get_glyph_name(PyFT2Font *self, PyObject *args, PyObj
unsigned int glyph_number;
char buffer[128];

if (!PyArg_ParseTuple(args, "i:get_glyph_name", &glyph_number)) {
if (!PyArg_ParseTuple(args, "I:get_glyph_name", &glyph_number)) {
return NULL;
}

Expand Down