OLD | NEW |
1 #include <stdint.h> | 1 #include <stdint.h> |
2 | 2 |
3 #include <ft2build.h> | 3 #include <ft2build.h> |
4 #include FT_FREETYPE_H | 4 #include FT_FREETYPE_H |
5 #include FT_TRUETYPE_TABLES_H | 5 #include FT_TRUETYPE_TABLES_H |
6 | 6 |
7 #if 0 | 7 #if 0 |
8 #include <freetype/freetype.h> | 8 #include <freetype/freetype.h> |
9 #include <freetype/tttables.h> | 9 #include <freetype/tttables.h> |
10 #endif | 10 #endif |
11 | 11 |
12 #include <harfbuzz-shaper.h> | 12 #include <harfbuzz-shaper.h> |
13 #include "harfbuzz-unicode.h" | 13 #include "harfbuzz-unicode.h" |
14 | 14 |
15 static HB_Bool | 15 static HB_Bool |
16 hb_freetype_string_to_glyphs(HB_Font font, | 16 hb_freetype_string_to_glyphs(HB_Font font, |
17 const HB_UChar16 *chars, hb_uint32 len, | 17 const HB_UChar16 *chars, hb_uint32 len, |
18 HB_Glyph *glyphs, hb_uint32 *numGlyphs, | 18 HB_Glyph *glyphs, hb_uint32 *numGlyphs, |
19 HB_Bool is_rtl) { | 19 HB_Bool is_rtl) { |
20 FT_Face face = (FT_Face) font->userData; | 20 FT_Face face = (FT_Face) font->userData; |
21 if (len > *numGlyphs) | 21 if (len > *numGlyphs) |
22 return 0; | 22 return 0; |
23 | 23 |
24 size_t i = 0, j = 0; | 24 ssize_t i = 0; |
| 25 hb_uint32 j = 0; |
25 while (i < len) { | 26 while (i < len) { |
26 const uint32_t cp = utf16_to_code_point(chars, len, &i); | 27 const uint32_t cp = utf16_to_code_point(chars, len, &i); |
27 glyphs[j++] = FT_Get_Char_Index(face, cp); | 28 glyphs[j++] = FT_Get_Char_Index(face, cp); |
28 } | 29 } |
29 | 30 |
30 *numGlyphs = j; | 31 *numGlyphs = j; |
31 | 32 |
32 return 1; | 33 return 1; |
33 } | 34 } |
34 | 35 |
(...skipping 11 matching lines...) Expand all Loading... |
46 } | 47 } |
47 | 48 |
48 advances[i] = face->glyph->advance.x; | 49 advances[i] = face->glyph->advance.x; |
49 } | 50 } |
50 } | 51 } |
51 | 52 |
52 static HB_Bool | 53 static HB_Bool |
53 hb_freetype_can_render(HB_Font font, const HB_UChar16 *chars, hb_uint32 len) { | 54 hb_freetype_can_render(HB_Font font, const HB_UChar16 *chars, hb_uint32 len) { |
54 FT_Face face = (FT_Face)font->userData; | 55 FT_Face face = (FT_Face)font->userData; |
55 | 56 |
56 size_t i = 0; | 57 ssize_t i = 0; |
57 while (i < len) { | 58 while (i < len) { |
58 const uint32_t cp = utf16_to_code_point(chars, len, &i); | 59 const uint32_t cp = utf16_to_code_point(chars, len, &i); |
59 if (FT_Get_Char_Index(face, cp) == 0) | 60 if (FT_Get_Char_Index(face, cp) == 0) |
60 return 0; | 61 return 0; |
61 } | 62 } |
62 | 63 |
63 return 1; | 64 return 1; |
64 } | 65 } |
65 | 66 |
66 static HB_Error | 67 static HB_Error |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 FT_Face face = (FT_Face) voidface; | 141 FT_Face face = (FT_Face) voidface; |
141 FT_ULong ftlen = *len; | 142 FT_ULong ftlen = *len; |
142 | 143 |
143 if (!FT_IS_SFNT(face)) | 144 if (!FT_IS_SFNT(face)) |
144 return HB_Err_Invalid_Argument; | 145 return HB_Err_Invalid_Argument; |
145 | 146 |
146 const FT_Error error = FT_Load_Sfnt_Table(face, tag, 0, buffer, &ftlen); | 147 const FT_Error error = FT_Load_Sfnt_Table(face, tag, 0, buffer, &ftlen); |
147 *len = ftlen; | 148 *len = ftlen; |
148 return (HB_Error) error; | 149 return (HB_Error) error; |
149 } | 150 } |
OLD | NEW |