Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e05c2fa

Browse files
stefanvNeil
authored and
Neil
committed
ft2font: Use mask-and-shift to fix GCC complaint about dereferencing of type-punned pointer.
1 parent cb609d5 commit e05c2fa

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/ft2font.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44

55
#include "numpy/arrayobject.h"
66

7-
#define FIXED_MAJOR(val) (*((short *) &val+1))
8-
#define FIXED_MINOR(val) (*((short *) &val+0))
7+
/*
8+
By definition, FT_FIXED as 2 16bit values stored in a single long.
9+
We cast to long to ensure the correct Py::Int convertor is called
10+
*/
11+
#define FIXED_MAJOR(val) (long) ((val & 0xffff000) >> 16)
12+
#define FIXED_MINOR(val) (long) (val & 0xffff)
913

1014
/**
1115
To improve the hinting of the fonts, this code uses a hack

0 commit comments

Comments
 (0)