|
Lines 54-63
Link Here
|
| 54 |
#include FT_TYPE1_TABLES_H |
54 |
#include FT_TYPE1_TABLES_H |
| 55 |
#include FT_XFREE86_H |
55 |
#include FT_XFREE86_H |
| 56 |
#include FT_BBOX_H |
56 |
#include FT_BBOX_H |
| 57 |
#include FT_INTERNAL_TRUETYPE_TYPES_H |
|
|
| 58 |
#include FT_TRUETYPE_TAGS_H |
57 |
#include FT_TRUETYPE_TAGS_H |
| 59 |
#include FT_INTERNAL_SFNT_H |
|
|
| 60 |
#include FT_INTERNAL_STREAM_H |
| 61 |
/* |
58 |
/* |
| 62 |
* If you want to use FT_Outline_Get_CBox instead of |
59 |
* If you want to use FT_Outline_Get_CBox instead of |
| 63 |
* FT_Outline_Get_BBox, define here. |
60 |
* FT_Outline_Get_BBox, define here. |
|
Lines 123-128
Link Here
|
| 123 |
}; |
120 |
}; |
| 124 |
|
121 |
|
| 125 |
|
122 |
|
|
|
123 |
/* read 2-byte value from a SFNT table */ |
| 124 |
static FT_UShort |
| 125 |
sfnt_get_ushort( FT_Face face, |
| 126 |
FT_ULong table_tag, |
| 127 |
FT_ULong table_offset ) |
| 128 |
{ |
| 129 |
FT_Byte buff[2]; |
| 130 |
FT_ULong len = sizeof(buff); |
| 131 |
FT_UShort result = 0; |
| 132 |
|
| 133 |
if ( !FT_Load_Sfnt_Table( face, table_tag, table_offset, buff, &len ) ); |
| 134 |
result = (FT_UShort)( (buff[0] << 8) | buff[1] ); |
| 135 |
|
| 136 |
return result; |
| 137 |
} |
| 138 |
|
| 139 |
#define sfnt_get_short(f,t,o) ((FT_Short)sfnt_get_ushort((f),(t),(o))) |
| 140 |
|
| 141 |
|
| 142 |
#if 0 |
| 143 |
static FT_ULong |
| 144 |
sfnt_get_ulong( FT_Face face, |
| 145 |
FT_ULong table_tag, |
| 146 |
FT_ULong table_offset ) |
| 147 |
{ |
| 148 |
FT_Byte buff[4]; |
| 149 |
FT_ULong len = sizeof(buff); |
| 150 |
FT_UShort result = 0; |
| 151 |
|
| 152 |
if ( !FT_Load_Sfnt_Table( face, table_tag, table_offset, buff, &len ); |
| 153 |
result = ((FT_ULong)buff[0] << 24) | ((FT_ULong)buff[1] << 16) | |
| 154 |
((FT_ULong)buff[2] << 8) | (FT_ULong)buff[3]; |
| 155 |
|
| 156 |
return result; |
| 157 |
} |
| 158 |
#endif |
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 126 |
static int ftypeInitP = 0; /* is the engine initialised? */ |
163 |
static int ftypeInitP = 0; /* is the engine initialised? */ |
| 127 |
FT_Library ftypeLibrary; |
164 |
FT_Library ftypeLibrary; |
| 128 |
|
165 |
|
|
Lines 211-216
Link Here
|
| 211 |
if(maxp && maxp->maxContours == 0) |
248 |
if(maxp && maxp->maxContours == 0) |
| 212 |
face->bitmap = 1; |
249 |
face->bitmap = 1; |
| 213 |
} |
250 |
} |
|
|
251 |
|
| 252 |
face->num_hmetrics = (FT_UInt) sfnt_get_ushort( face->face, |
| 253 |
TTAG_hhea, 34 ); |
| 254 |
|
| 214 |
/* Insert face in hashtable and return it */ |
255 |
/* Insert face in hashtable and return it */ |
| 215 |
face->next = faceTable[bucket]; |
256 |
face->next = faceTable[bucket]; |
| 216 |
faceTable[bucket] = face; |
257 |
faceTable[bucket] = face; |
|
Lines 462-467
Link Here
|
| 462 |
} |
503 |
} |
| 463 |
|
504 |
|
| 464 |
if( FT_IS_SFNT( face->face ) ) { |
505 |
if( FT_IS_SFNT( face->face ) ) { |
|
|
506 |
#if 1 |
| 507 |
FT_F26Dot6 tt_char_width, tt_char_height, tt_dim_x, tt_dim_y; |
| 508 |
FT_UInt nn; |
| 509 |
|
| 510 |
instance->strike_index=0xFFFFU; |
| 511 |
|
| 512 |
tt_char_width = (int)(trans->scale*(1<<6) + 0.5); |
| 513 |
tt_char_height = (int)(trans->scale*(1<<6) + 0.5); |
| 514 |
|
| 515 |
tt_dim_x = ( ( tt_char_width * trans->xres + (36+32*72) ) / 72 ) & -64; |
| 516 |
tt_dim_y = ( ( tt_char_height * trans->yres + (36+32*72) ) / 72 ) & -64; |
| 517 |
|
| 518 |
for ( nn = 0; nn < face->face->num_fixed_sizes; nn++ ) |
| 519 |
{ |
| 520 |
FT_Bitmap_Size* sz = &face->face->available_sizes[nn]; |
| 521 |
|
| 522 |
if ( tt_dim_x == sz->x_ppem && tt_dim_y == sz->y_ppem ) |
| 523 |
{ |
| 524 |
instance->strike_index = nn; |
| 525 |
break; |
| 526 |
} |
| 527 |
} |
| 528 |
#else |
| 465 |
/* See Set_Char_Sizes() in ttdriver.c */ |
529 |
/* See Set_Char_Sizes() in ttdriver.c */ |
| 466 |
FT_Error err; |
530 |
FT_Error err; |
| 467 |
TT_Face tt_face; |
531 |
TT_Face tt_face; |
|
Lines 486-491
Link Here
|
| 486 |
sfnt = (SFNT_Service)tt_face->sfnt; |
550 |
sfnt = (SFNT_Service)tt_face->sfnt; |
| 487 |
err = sfnt->set_sbit_strike(tt_face,tt_x_ppem,tt_y_ppem,&instance->strike_index); |
551 |
err = sfnt->set_sbit_strike(tt_face,tt_x_ppem,tt_y_ppem,&instance->strike_index); |
| 488 |
if ( err ) instance->strike_index=0xFFFFU; |
552 |
if ( err ) instance->strike_index=0xFFFFU; |
|
|
553 |
#endif |
| 489 |
} |
554 |
} |
| 490 |
|
555 |
|
| 491 |
/* maintain a linked list of instances */ |
556 |
/* maintain a linked list of instances */ |
|
Lines 803-833
Link Here
|
| 803 |
* parse the htmx field in TrueType font. |
868 |
* parse the htmx field in TrueType font. |
| 804 |
*/ |
869 |
*/ |
| 805 |
|
870 |
|
| 806 |
/* from src/truetype/ttgload.c */ |
|
|
| 807 |
static void |
871 |
static void |
| 808 |
tt_get_metrics( TT_HoriHeader* header, |
872 |
tt_get_metrics( FT_Face face, |
| 809 |
FT_UInt idx, |
873 |
FT_UInt idx, |
|
|
874 |
FT_UInt num_hmetrics, |
| 810 |
FT_Short* bearing, |
875 |
FT_Short* bearing, |
| 811 |
FT_UShort* advance ) |
876 |
FT_UShort* advance ) |
| 812 |
/* Copyright 1996-2001, 2002 by */ |
|
|
| 813 |
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
| 814 |
{ |
877 |
{ |
| 815 |
TT_LongMetrics longs_m; |
878 |
/* read the metrics directly from the horizontal header, we |
| 816 |
FT_UShort k = header->number_Of_HMetrics; |
879 |
* parse the SFNT table directly through the standard FreeType API. |
|
|
880 |
* this works with any version of the library and doesn't need to |
| 881 |
* peek at its internals. Maybe a bit less |
| 882 |
*/ |
| 883 |
FT_UInt count = num_hmetrics; |
| 817 |
|
884 |
|
| 818 |
if ( k == 0 ) { |
885 |
if ( count == 0 ) |
| 819 |
*bearing = *advance = 0; |
886 |
{ |
| 820 |
return; |
887 |
*advance = 0; |
|
|
888 |
*bearing = 0; |
| 821 |
} |
889 |
} |
|
|
890 |
else if ( idx < count ) |
| 891 |
{ |
| 892 |
FT_ULong offset = idx*4; |
| 822 |
|
893 |
|
| 823 |
if ( idx < (FT_UInt)k ) { |
894 |
*advance = sfnt_get_ushort( face, TTAG_hmtx, offset ); |
| 824 |
longs_m = (TT_LongMetrics )header->long_metrics + idx; |
895 |
*bearing = sfnt_get_short ( face, TTAG_hmtx, offset+2 ); |
| 825 |
*bearing = longs_m->bearing; |
|
|
| 826 |
*advance = longs_m->advance; |
| 827 |
} |
896 |
} |
| 828 |
else { |
897 |
else |
| 829 |
*bearing = ((TT_ShortMetrics*)header->short_metrics)[idx - k]; |
898 |
{ |
| 830 |
*advance = ((TT_LongMetrics )header->long_metrics)[k - 1].advance; |
899 |
*advance = sfnt_get_ushort( face, TTAG_hmtx, (count-1)*4 ); |
|
|
900 |
*bearing = sfnt_get_short ( face, TTAG_hmtx, (count+idx)*2 ); |
| 831 |
} |
901 |
} |
| 832 |
} |
902 |
} |
| 833 |
|
903 |
|
|
Lines 835-840
Link Here
|
| 835 |
ft_get_very_lazy_bbox( FT_UInt index, |
905 |
ft_get_very_lazy_bbox( FT_UInt index, |
| 836 |
FT_Face face, |
906 |
FT_Face face, |
| 837 |
FT_Size size, |
907 |
FT_Size size, |
|
|
908 |
FT_UInt num_hmetrics, |
| 838 |
double slant, |
909 |
double slant, |
| 839 |
FT_Matrix *matrix, |
910 |
FT_Matrix *matrix, |
| 840 |
FT_BBox *bbox, |
911 |
FT_BBox *bbox, |
|
Lines 842-855
Link Here
|
| 842 |
FT_Long *vertAdvance) |
913 |
FT_Long *vertAdvance) |
| 843 |
{ |
914 |
{ |
| 844 |
if ( FT_IS_SFNT( face ) ) { |
915 |
if ( FT_IS_SFNT( face ) ) { |
| 845 |
TT_Face ttface = (TT_Face)face; |
|
|
| 846 |
FT_Size_Metrics *smetrics = &size->metrics; |
916 |
FT_Size_Metrics *smetrics = &size->metrics; |
| 847 |
FT_Short leftBearing = 0; |
917 |
FT_Short leftBearing = 0; |
| 848 |
FT_UShort advance = 0; |
918 |
FT_UShort advance = 0; |
| 849 |
FT_Vector p0, p1, p2, p3; |
919 |
FT_Vector p0, p1, p2, p3; |
| 850 |
|
920 |
|
| 851 |
/* horizontal */ |
921 |
/* horizontal */ |
| 852 |
tt_get_metrics(&ttface->horizontal, index, |
922 |
tt_get_metrics( face, num_hmetrics, index, |
| 853 |
&leftBearing, &advance); |
923 |
&leftBearing, &advance); |
| 854 |
|
924 |
|
| 855 |
#if 0 |
925 |
#if 0 |
|
Lines 910-916
Link Here
|
| 910 |
FT_UShort glyph_index, FT_Glyph_Metrics *metrics_return, |
980 |
FT_UShort glyph_index, FT_Glyph_Metrics *metrics_return, |
| 911 |
int *sbitchk_incomplete_but_exist ) |
981 |
int *sbitchk_incomplete_but_exist ) |
| 912 |
{ |
982 |
{ |
| 913 |
#if (FREETYPE_VERSION >= 2001008) |
983 |
#if 1 |
|
|
984 |
if ( strike_index != 0xFFFFU && ft_face->available_sizes != 0) |
| 985 |
{ |
| 986 |
FT_Error error; |
| 987 |
FT_Bitmap_Size* sz = &ft_face->available_sizes[strike_index]; |
| 988 |
|
| 989 |
error = FT_Set_Pixel_Sizes( ft_face, sz->x_ppem/64, sz->y_ppem/64 ); |
| 990 |
if ( !error ) |
| 991 |
{ |
| 992 |
error = FT_Load_Glyph( ft_face, glyph_index, FT_LOAD_SBITS_ONLY ); |
| 993 |
if ( !error ) |
| 994 |
{ |
| 995 |
if ( metrics_return != NULL ) |
| 996 |
*metrics_return = ft_face->glyph->metrics; |
| 997 |
|
| 998 |
return 0; |
| 999 |
} |
| 1000 |
} |
| 1001 |
} |
| 1002 |
return -1; |
| 1003 |
#elif (FREETYPE_VERSION >= 2001008) |
| 914 |
SFNT_Service sfnt; |
1004 |
SFNT_Service sfnt; |
| 915 |
TT_Face face; |
1005 |
TT_Face face; |
| 916 |
FT_Error error; |
1006 |
FT_Error error; |
|
Lines 1043-1048
Link Here
|
| 1043 |
if( bitmap_metrics == NULL ) { |
1133 |
if( bitmap_metrics == NULL ) { |
| 1044 |
if ( sbitchk_incomplete_but_exist==0 && (instance->ttcap.flags & TTCAP_IS_VERY_LAZY) ) { |
1134 |
if ( sbitchk_incomplete_but_exist==0 && (instance->ttcap.flags & TTCAP_IS_VERY_LAZY) ) { |
| 1045 |
if( ft_get_very_lazy_bbox( idx, face->face, instance->size, |
1135 |
if( ft_get_very_lazy_bbox( idx, face->face, instance->size, |
|
|
1136 |
face->num_hmetrics, |
| 1046 |
instance->ttcap.vl_slant, |
1137 |
instance->ttcap.vl_slant, |
| 1047 |
&instance->transformation.matrix, |
1138 |
&instance->transformation.matrix, |
| 1048 |
&bbox, &outline_hori_advance, |
1139 |
&bbox, &outline_hori_advance, |
|
Lines 1221-1226
Link Here
|
| 1221 |
if( is_outline == 1 ){ |
1312 |
if( is_outline == 1 ){ |
| 1222 |
if( correct ){ |
1313 |
if( correct ){ |
| 1223 |
if( ft_get_very_lazy_bbox( idx, face->face, instance->size, |
1314 |
if( ft_get_very_lazy_bbox( idx, face->face, instance->size, |
|
|
1315 |
face->num_hmetrics, |
| 1224 |
instance->ttcap.vl_slant, |
1316 |
instance->ttcap.vl_slant, |
| 1225 |
&instance->transformation.matrix, |
1317 |
&instance->transformation.matrix, |
| 1226 |
&bbox, &outline_hori_advance, |
1318 |
&bbox, &outline_hori_advance, |