| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d02024e commit b19fa70
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -161,9 +161,19 @@ FT2Image::draw_rect_filled(unsigned long x0, unsigned long y0, unsigned long x1, | |||
| 161 | 161 | ||
| 162 | 162 | inline double conv(long v) | |
| 163 | 163 | { | |
| 164 | - return double(v) / 64.0; | ||
| 164 | + return v / 64.; | ||
| 165 | 165 | } | |
| 166 | 166 | ||
| 167 | + FT_UInt ft_get_char_index_or_warn(FT_Face face, FT_ULong charcode) | ||
| 168 | + { | ||
| 169 | + FT_UInt glyph_index = FT_Get_Char_Index(face, charcode); | ||
| 170 | + if (!glyph_index) { | ||
| 171 | + PyErr_WarnEx(NULL, "Required glyph missing from current font.", 1); | ||
| 172 | + } | ||
| 173 | + return glyph_index; | ||
| 174 | + } | ||
| 175 | + | ||
| 176 | + | ||
| 167 | 177 | int FT2Font::get_path_count() | |
| 168 | 178 | { | |
| 169 | 179 | // get the glyph as a path, a list of (COMMAND, *args) as desribed in matplotlib.path | |
@@ -614,7 +624,7 @@ void FT2Font::set_text( | |||
| 614 | 624 | FT_BBox glyph_bbox; | |
| 615 | 625 | FT_Pos last_advance; | |
| 616 | 626 | ||
| 617 | - glyph_index = FT_Get_Char_Index(face, codepoints[n]); | ||
| 627 | + glyph_index = ft_get_char_index_or_warn(face, codepoints[n]); | ||
| 618 | 628 | ||
| 619 | 629 | // retrieve kerning distance and move pen position | |
| 620 | 630 | if (use_kerning && previous && glyph_index) { | |
@@ -667,7 +677,8 @@ void FT2Font::set_text( | |||
| 667 | 677 | ||
| 668 | 678 | void FT2Font::load_char(long charcode, FT_Int32 flags) | |
| 669 | 679 | { | |
| 670 | - int error = FT_Load_Char(face, (unsigned long)charcode, flags); | ||
| 680 | + FT_UInt glyph_index = ft_get_char_index_or_warn(face, (FT_ULong)charcode); | ||
| 681 | + int error = FT_Load_Glyph(face, glyph_index, flags); | ||
| 671 | 682 | ||
| 672 | 683 | if (error) { | |
| 673 | 684 | throw "Could not load charcode"; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -995,8 +995,8 @@ static PyObject *PyFT2Font_get_char_index(PyFT2Font *self, PyObject *args, PyObj | |||
| 995 | 995 | const char *PyFT2Font_get_sfnt__doc__ = | |
| 996 | 996 | "get_sfnt(name)\n" | |
| 997 | 997 | "\n" | |
| 998 | - "Get all values from the SFNT names table. Result is a dictionary whose" | ||
| 999 | - "key is the platform-ID, ISO-encoding-scheme, language-code, and" | ||
| 998 | + "Get all values from the SFNT names table. Result is a dictionary whose " | ||
| 999 | + "key is the platform-ID, ISO-encoding-scheme, language-code, and " | ||
| 1000 | 1000 | "description.\n"; | |
| 1001 | 1001 | ||
| 1002 | 1002 | static PyObject *PyFT2Font_get_sfnt(PyFT2Font *self, PyObject *args, PyObject *kwds) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments