| OLD | NEW |
| 1 /***************************************************************************/ | 1 /***************************************************************************/ |
| 2 /* */ | 2 /* */ |
| 3 /* ttkern.c */ | 3 /* ttkern.c */ |
| 4 /* */ | 4 /* */ |
| 5 /* Load the basic TrueType kerning table. This doesn't handle */ | 5 /* Load the basic TrueType kerning table. This doesn't handle */ |
| 6 /* kerning data within the GPOS table at the moment. */ | 6 /* kerning data within the GPOS table at the moment. */ |
| 7 /* */ | 7 /* */ |
| 8 /* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by */ | 8 /* Copyright 1996-2007, 2009, 2010, 2013 by */ |
| 9 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ | 9 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
| 10 /* */ | 10 /* */ |
| 11 /* This file is part of the FreeType project, and may only be used, */ | 11 /* This file is part of the FreeType project, and may only be used, */ |
| 12 /* modified, and distributed under the terms of the FreeType project */ | 12 /* modified, and distributed under the terms of the FreeType project */ |
| 13 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ | 13 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
| 14 /* this file you indicate that you have read the license and */ | 14 /* this file you indicate that you have read the license and */ |
| 15 /* understand and accept it fully. */ | 15 /* understand and accept it fully. */ |
| 16 /* */ | 16 /* */ |
| 17 /***************************************************************************/ | 17 /***************************************************************************/ |
| 18 | 18 |
| 19 | 19 |
| 20 #include "../../include/ft2build.h" | 20 #include <ft2build.h> |
| 21 #include "../../include/freetype/internal/ftdebug.h" | 21 #include FT_INTERNAL_DEBUG_H |
| 22 #include "../../include/freetype/internal/ftstream.h" | 22 #include FT_INTERNAL_STREAM_H |
| 23 #include "../../include/freetype/tttags.h" | 23 #include FT_TRUETYPE_TAGS_H |
| 24 #include "ttkern.h" | 24 #include "ttkern.h" |
| 25 | 25 |
| 26 #include "sferrors.h" | 26 #include "sferrors.h" |
| 27 | 27 |
| 28 | 28 |
| 29 /*************************************************************************/ | 29 /*************************************************************************/ |
| 30 /* */ | 30 /* */ |
| 31 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ | 31 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ |
| 32 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ | 32 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ |
| 33 /* messages during execution. */ | 33 /* messages during execution. */ |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 92 |
| 93 if ( p + 6 > p_limit ) | 93 if ( p + 6 > p_limit ) |
| 94 break; | 94 break; |
| 95 | 95 |
| 96 p_next = p; | 96 p_next = p; |
| 97 | 97 |
| 98 p += 2; /* skip version */ | 98 p += 2; /* skip version */ |
| 99 length = FT_NEXT_USHORT( p ); | 99 length = FT_NEXT_USHORT( p ); |
| 100 coverage = FT_NEXT_USHORT( p ); | 100 coverage = FT_NEXT_USHORT( p ); |
| 101 | 101 |
| 102 if ( length <= 6 ) | 102 if ( length <= 6 + 8 ) |
| 103 break; | 103 break; |
| 104 | 104 |
| 105 p_next += length; | 105 p_next += length; |
| 106 | 106 |
| 107 if ( p_next > p_limit ) /* handle broken table */ | 107 if ( p_next > p_limit ) /* handle broken table */ |
| 108 p_next = p_limit; | 108 p_next = p_limit; |
| 109 | 109 |
| 110 /* only use horizontal kerning tables */ | 110 /* only use horizontal kerning tables */ |
| 111 if ( ( coverage & ~8 ) != 0x0001 || | 111 if ( ( coverage & ~8 ) != 0x0001 || |
| 112 p + 8 > p_limit ) | 112 p + 8 > p_limit ) |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 face->kern_order_bits = 0; | 176 face->kern_order_bits = 0; |
| 177 } | 177 } |
| 178 | 178 |
| 179 | 179 |
| 180 FT_LOCAL_DEF( FT_Int ) | 180 FT_LOCAL_DEF( FT_Int ) |
| 181 tt_face_get_kerning( TT_Face face, | 181 tt_face_get_kerning( TT_Face face, |
| 182 FT_UInt left_glyph, | 182 FT_UInt left_glyph, |
| 183 FT_UInt right_glyph ) | 183 FT_UInt right_glyph ) |
| 184 { | 184 { |
| 185 FT_Int result = 0; | 185 FT_Int result = 0; |
| 186 FT_UInt count, mask = 1; | 186 FT_UInt count, mask; |
| 187 FT_Byte* p = face->kern_table; | 187 FT_Byte* p = face->kern_table; |
| 188 FT_Byte* p_limit = p + face->kern_table_size; | 188 FT_Byte* p_limit = p + face->kern_table_size; |
| 189 | 189 |
| 190 | 190 |
| 191 p += 4; | 191 p += 4; |
| 192 mask = 0x0001; | 192 mask = 0x0001; |
| 193 | 193 |
| 194 for ( count = face->num_kern_tables; | 194 for ( count = face->num_kern_tables; |
| 195 count > 0 && p + 6 <= p_limit; | 195 count > 0 && p + 6 <= p_limit; |
| 196 count--, mask <<= 1 ) | 196 count--, mask <<= 1 ) |
| 197 { | 197 { |
| 198 FT_Byte* base = p; | 198 FT_Byte* base = p; |
| 199 FT_Byte* next = base; | 199 FT_Byte* next; |
| 200 FT_UInt version = FT_NEXT_USHORT( p ); | 200 FT_UInt version = FT_NEXT_USHORT( p ); |
| 201 FT_UInt length = FT_NEXT_USHORT( p ); | 201 FT_UInt length = FT_NEXT_USHORT( p ); |
| 202 FT_UInt coverage = FT_NEXT_USHORT( p ); | 202 FT_UInt coverage = FT_NEXT_USHORT( p ); |
| 203 FT_UInt num_pairs; | 203 FT_UInt num_pairs; |
| 204 FT_Int value = 0; | 204 FT_Int value = 0; |
| 205 | 205 |
| 206 FT_UNUSED( version ); | 206 FT_UNUSED( version ); |
| 207 | 207 |
| 208 | 208 |
| 209 next = base + length; | 209 next = base + length; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 NextTable: | 297 NextTable: |
| 298 p = next; | 298 p = next; |
| 299 } | 299 } |
| 300 | 300 |
| 301 return result; | 301 return result; |
| 302 } | 302 } |
| 303 | 303 |
| 304 #undef TT_KERN_INDEX | 304 #undef TT_KERN_INDEX |
| 305 | 305 |
| 306 /* END */ | 306 /* END */ |
| OLD | NEW |