OLD | NEW |
1 /***************************************************************************/ | 1 /***************************************************************************/ |
2 /* */ | 2 /* */ |
3 /* ttpload.c */ | 3 /* ttpload.c */ |
4 /* */ | 4 /* */ |
5 /* TrueType-specific tables loader (body). */ | 5 /* TrueType-specific tables loader (body). */ |
6 /* */ | 6 /* */ |
7 /* Copyright 1996-2002, 2004-2013 by */ | 7 /* Copyright 1996-2015 by */ |
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ | 8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
9 /* */ | 9 /* */ |
10 /* This file is part of the FreeType project, and may only be used, */ | 10 /* This file is part of the FreeType project, and may only be used, */ |
11 /* modified, and distributed under the terms of the FreeType project */ | 11 /* modified, and distributed under the terms of the FreeType project */ |
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ | 12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
13 /* this file you indicate that you have read the license and */ | 13 /* this file you indicate that you have read the license and */ |
14 /* understand and accept it fully. */ | 14 /* understand and accept it fully. */ |
15 /* */ | 15 /* */ |
16 /***************************************************************************/ | 16 /***************************************************************************/ |
17 | 17 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 } | 111 } |
112 | 112 |
113 if ( face->num_locations != (FT_ULong)face->root.num_glyphs + 1 ) | 113 if ( face->num_locations != (FT_ULong)face->root.num_glyphs + 1 ) |
114 { | 114 { |
115 FT_TRACE2(( "glyph count mismatch! loca: %d, maxp: %d\n", | 115 FT_TRACE2(( "glyph count mismatch! loca: %d, maxp: %d\n", |
116 face->num_locations - 1, face->root.num_glyphs )); | 116 face->num_locations - 1, face->root.num_glyphs )); |
117 | 117 |
118 /* we only handle the case where `maxp' gives a larger value */ | 118 /* we only handle the case where `maxp' gives a larger value */ |
119 if ( face->num_locations <= (FT_ULong)face->root.num_glyphs ) | 119 if ( face->num_locations <= (FT_ULong)face->root.num_glyphs ) |
120 { | 120 { |
121 FT_Long new_loca_len = | 121 FT_ULong new_loca_len = |
122 ( (FT_Long)( face->root.num_glyphs ) + 1 ) << shift; | 122 ( (FT_ULong)face->root.num_glyphs + 1 ) << shift; |
123 | 123 |
124 TT_Table entry = face->dir_tables; | 124 TT_Table entry = face->dir_tables; |
125 TT_Table limit = entry + face->num_tables; | 125 TT_Table limit = entry + face->num_tables; |
126 | 126 |
127 FT_Long pos = FT_Stream_Pos( stream ); | 127 FT_Long pos = (FT_Long)FT_STREAM_POS(); |
128 FT_Long dist = 0x7FFFFFFFL; | 128 FT_Long dist = 0x7FFFFFFFL; |
129 | 129 |
130 | 130 |
131 /* compute the distance to next table in font file */ | 131 /* compute the distance to next table in font file */ |
132 for ( ; entry < limit; entry++ ) | 132 for ( ; entry < limit; entry++ ) |
133 { | 133 { |
134 FT_Long diff = entry->Offset - pos; | 134 FT_Long diff = (FT_Long)entry->Offset - pos; |
135 | 135 |
136 | 136 |
137 if ( diff > 0 && diff < dist ) | 137 if ( diff > 0 && diff < dist ) |
138 dist = diff; | 138 dist = diff; |
139 } | 139 } |
140 | 140 |
141 if ( entry == limit ) | 141 if ( entry == limit ) |
142 { | 142 { |
143 /* `loca' is the last table */ | 143 /* `loca' is the last table */ |
144 dist = stream->size - pos; | 144 dist = (FT_Long)stream->size - pos; |
145 } | 145 } |
146 | 146 |
147 if ( new_loca_len <= dist ) | 147 if ( new_loca_len <= (FT_ULong)dist ) |
148 { | 148 { |
149 face->num_locations = face->root.num_glyphs + 1; | 149 face->num_locations = (FT_ULong)face->root.num_glyphs + 1; |
150 table_len = new_loca_len; | 150 table_len = new_loca_len; |
151 | 151 |
152 FT_TRACE2(( "adjusting num_locations to %d\n", | 152 FT_TRACE2(( "adjusting num_locations to %d\n", |
153 face->num_locations )); | 153 face->num_locations )); |
154 } | 154 } |
| 155 else |
| 156 { |
| 157 face->root.num_glyphs = face->num_locations |
| 158 ? (FT_Long)face->num_locations - 1 : 0; |
| 159 |
| 160 FT_TRACE2(( "adjusting num_glyphs to %d\n", |
| 161 face->root.num_glyphs )); |
| 162 } |
155 } | 163 } |
156 } | 164 } |
157 | 165 |
158 /* | 166 /* |
159 * Extract the frame. We don't need to decompress it since | 167 * Extract the frame. We don't need to decompress it since |
160 * we are able to parse it directly. | 168 * we are able to parse it directly. |
161 */ | 169 */ |
162 if ( FT_FRAME_EXTRACT( table_len, face->glyph_locations ) ) | 170 if ( FT_FRAME_EXTRACT( table_len, face->glyph_locations ) ) |
163 goto Exit; | 171 goto Exit; |
164 | 172 |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 if ( gindex < record_size ) | 600 if ( gindex < record_size ) |
593 result = record + nn * record_size + gindex; | 601 result = record + nn * record_size + gindex; |
594 break; | 602 break; |
595 } | 603 } |
596 | 604 |
597 return result; | 605 return result; |
598 } | 606 } |
599 | 607 |
600 | 608 |
601 /* END */ | 609 /* END */ |
OLD | NEW |