69 |
/*************************************************************************/ |
/*************************************************************************/ |
70 |
/* */ |
/* */ |
71 |
/* <Function> */ |
/* <Function> */ |
72 |
/* Get_Kerning */ |
/* tt_get_kerning */ |
73 |
/* */ |
/* */ |
74 |
/* <Description> */ |
/* <Description> */ |
75 |
/* A driver method used to return the kerning vector between two */ |
/* A driver method used to return the kerning vector between two */ |
99 |
/* They can be implemented by format-specific interfaces. */ |
/* They can be implemented by format-specific interfaces. */ |
100 |
/* */ |
/* */ |
101 |
static FT_Error |
static FT_Error |
102 |
Get_Kerning( FT_Face ttface, /* TT_Face */ |
tt_get_kerning( FT_Face ttface, /* TT_Face */ |
103 |
FT_UInt left_glyph, |
FT_UInt left_glyph, |
104 |
FT_UInt right_glyph, |
FT_UInt right_glyph, |
105 |
FT_Vector* kerning ) |
FT_Vector* kerning ) |
106 |
{ |
{ |
107 |
TT_Face face = (TT_Face)ttface; |
TT_Face face = (TT_Face)ttface; |
108 |
TT_Kern0_Pair pair; |
SFNT_Service sfnt = (SFNT_Service) face->sfnt; |
|
|
|
|
|
|
|
if ( !face ) |
|
|
return TT_Err_Invalid_Face_Handle; |
|
109 |
|
|
110 |
kerning->x = 0; |
kerning->x = 0; |
111 |
kerning->y = 0; |
kerning->y = 0; |
112 |
|
|
113 |
if ( face->kern_pairs ) |
if ( sfnt ) |
114 |
{ |
kerning->x = sfnt->get_kerning( face, left_glyph, right_glyph ); |
115 |
/* there are some kerning pairs in this font file! */ |
|
116 |
FT_ULong search_tag = PAIR_TAG( left_glyph, right_glyph ); |
return 0; |
|
FT_Long left, right; |
|
|
|
|
|
|
|
|
left = 0; |
|
|
right = face->num_kern_pairs - 1; |
|
|
|
|
|
while ( left <= right ) |
|
|
{ |
|
|
FT_Long middle = left + ( ( right - left ) >> 1 ); |
|
|
FT_ULong cur_pair; |
|
|
|
|
|
|
|
|
pair = face->kern_pairs + middle; |
|
|
cur_pair = PAIR_TAG( pair->left, pair->right ); |
|
|
|
|
|
if ( cur_pair == search_tag ) |
|
|
goto Found; |
|
|
|
|
|
if ( cur_pair < search_tag ) |
|
|
left = middle + 1; |
|
|
else |
|
|
right = middle - 1; |
|
|
} |
|
|
} |
|
|
|
|
|
Exit: |
|
|
return TT_Err_Ok; |
|
|
|
|
|
Found: |
|
|
kerning->x = pair->value; |
|
|
goto Exit; |
|
117 |
} |
} |
118 |
|
|
119 |
|
|
421 |
Set_Pixel_Sizes, |
Set_Pixel_Sizes, |
422 |
Load_Glyph, |
Load_Glyph, |
423 |
|
|
424 |
Get_Kerning, |
tt_get_kerning, |
425 |
0, /* FT_Face_AttachFunc */ |
0, /* FT_Face_AttachFunc */ |
426 |
0 /* FT_Face_GetAdvancesFunc */ |
0 /* FT_Face_GetAdvancesFunc */ |
427 |
}; |
}; |