1 diff -urbN libXfont-1.1.0/src/FreeType/ftfuncs.c libXfont-1.1.0.new/src/FreeType/ftfuncs.c
2 --- xc/lib/font/FreeType/ftfuncs.c 2005-10-24 02:32:05.000000000 +0800
3 +++ xc/lib/font/FreeType/ftfuncs.c 2006-06-25 10:56:24.221147322 +0800
5 #include FT_TYPE1_TABLES_H
8 -#include FT_INTERNAL_TRUETYPE_TYPES_H
9 #include FT_TRUETYPE_TAGS_H
10 -#include FT_INTERNAL_SFNT_H
11 -#include FT_INTERNAL_STREAM_H
13 * If you want to use FT_Outline_Get_CBox instead of
14 * FT_Outline_Get_BBox, define here.
19 +/* read 2-byte value from a SFNT table */
21 +sfnt_get_ushort( FT_Face face,
23 + FT_ULong table_offset )
26 + FT_ULong len = sizeof(buff);
27 + FT_UShort result = 0;
29 + if ( !FT_Load_Sfnt_Table( face, table_tag, table_offset, buff, &len ) );
30 + result = (FT_UShort)( (buff[0] << 8) | buff[1] );
35 +#define sfnt_get_short(f,t,o) ((FT_Short)sfnt_get_ushort((f),(t),(o)))
38 static int ftypeInitP = 0; /* is the engine initialised? */
39 FT_Library ftypeLibrary;
42 if(maxp && maxp->maxContours == 0)
46 + face->num_hmetrics = (FT_UInt) sfnt_get_ushort( face->face,
49 /* Insert face in hashtable and return it */
50 face->next = faceTable[bucket];
51 faceTable[bucket] = face;
55 if( FT_IS_SFNT( face->face ) ) {
57 + FT_F26Dot6 tt_char_width, tt_char_height, tt_dim_x, tt_dim_y;
60 + instance->strike_index=0xFFFFU;
62 + tt_char_width = (FT_F26Dot6)(trans->scale*(1<<6) + 0.5);
63 + tt_char_height = (FT_F26Dot6)(trans->scale*(1<<6) + 0.5);
65 + tt_dim_x = FLOOR64( ( tt_char_width * trans->xres + 36 ) / 72 + 32 );
66 + tt_dim_y = FLOOR64( ( tt_char_height * trans->yres + 36 ) / 72 + 32 );
68 + if ( tt_dim_x && !tt_dim_y )
69 + tt_dim_y = tt_dim_x;
70 + else if ( !tt_dim_x && tt_dim_y )
71 + tt_dim_x = tt_dim_y;
73 + for ( nn = 0; nn < face->face->num_fixed_sizes; nn++ )
75 + FT_Bitmap_Size* sz = &face->face->available_sizes[nn];
77 + if ( tt_dim_x == FLOOR64(sz->x_ppem + 32) && tt_dim_y == FLOOR64(sz->y_ppem + 32) )
79 + instance->strike_index = nn;
84 /* See Set_Char_Sizes() in ttdriver.c */
88 sfnt = (SFNT_Service)tt_face->sfnt;
89 err = sfnt->set_sbit_strike(tt_face,tt_x_ppem,tt_y_ppem,&instance->strike_index);
90 if ( err ) instance->strike_index=0xFFFFU;
94 /* maintain a linked list of instances */
96 * parse the htmx field in TrueType font.
99 -/* from src/truetype/ttgload.c */
101 -tt_get_metrics( TT_HoriHeader* header,
102 +tt_get_metrics( FT_Face face,
104 + FT_UInt num_hmetrics,
107 -/* Copyright 1996-2001, 2002 by */
108 -/* David Turner, Robert Wilhelm, and Werner Lemberg. */
110 - TT_LongMetrics longs_m;
111 - FT_UShort k = header->number_Of_HMetrics;
112 + /* read the metrics directly from the horizontal header, we
113 + * parse the SFNT table directly through the standard FreeType API.
114 + * this works with any version of the library and doesn't need to
115 + * peek at its internals. Maybe a bit less
117 + FT_UInt count = num_hmetrics;
118 + FT_ULong length = 0;
119 + FT_ULong offset = 0;
123 - *bearing = *advance = 0;
126 + error = FT_Load_Sfnt_Table( face, TTAG_hmtx, 0, NULL, &length );
128 - if ( idx < (FT_UInt)k ) {
129 - longs_m = (TT_LongMetrics )header->long_metrics + idx;
130 - *bearing = longs_m->bearing;
131 - *advance = longs_m->advance;
132 + if ( count == 0 || error )
137 + else if ( idx < count )
140 + if ( offset + 4 > length )
147 + *advance = sfnt_get_ushort( face, TTAG_hmtx, offset );
148 + *bearing = sfnt_get_short ( face, TTAG_hmtx, offset+2 );
153 + offset = 4L * (count - 1);
154 + if ( offset + 4 > length )
161 + *advance = sfnt_get_ushort ( face, TTAG_hmtx, offset );
162 + offset += 4 + 2 * ( idx - count );
163 + if ( offset + 2 > length)
166 + *bearing = sfnt_get_short ( face, TTAG_hmtx, offset );
169 - *bearing = ((TT_ShortMetrics*)header->short_metrics)[idx - k];
170 - *advance = ((TT_LongMetrics )header->long_metrics)[k - 1].advance;
175 ft_get_very_lazy_bbox( FT_UInt index,
178 + FT_UInt num_hmetrics,
182 @@ -842,15 +922,14 @@
183 FT_Long *vertAdvance)
185 if ( FT_IS_SFNT( face ) ) {
186 - TT_Face ttface = (TT_Face)face;
187 FT_Size_Metrics *smetrics = &size->metrics;
188 FT_Short leftBearing = 0;
189 FT_UShort advance = 0;
190 FT_Vector p0, p1, p2, p3;
193 - tt_get_metrics(&ttface->horizontal, index,
194 - &leftBearing, &advance);
195 + tt_get_metrics( face, index, num_hmetrics,
196 + &leftBearing, &advance );
199 fprintf(stderr,"x_scale=%f y_scale=%f\n",
201 FT_UShort glyph_index, FT_Glyph_Metrics *metrics_return,
202 int *sbitchk_incomplete_but_exist )
204 -#if (FREETYPE_VERSION >= 2001008)
206 + if ( strike_index != 0xFFFFU && ft_face->available_sizes != NULL )
209 + FT_Bitmap_Size* sz = &ft_face->available_sizes[strike_index];
211 + error = FT_Set_Pixel_Sizes( ft_face, sz->x_ppem/64, sz->y_ppem/64 );
214 + error = FT_Load_Glyph( ft_face, glyph_index, FT_LOAD_SBITS_ONLY );
217 + if ( metrics_return != NULL )
218 + *metrics_return = ft_face->glyph->metrics;
225 +#elif (FREETYPE_VERSION >= 2001008)
229 @@ -1043,6 +1142,7 @@
230 if( bitmap_metrics == NULL ) {
231 if ( sbitchk_incomplete_but_exist==0 && (instance->ttcap.flags & TTCAP_IS_VERY_LAZY) ) {
232 if( ft_get_very_lazy_bbox( idx, face->face, instance->size,
233 + face->num_hmetrics,
234 instance->ttcap.vl_slant,
235 &instance->transformation.matrix,
236 &bbox, &outline_hori_advance,
237 @@ -1207,10 +1307,27 @@
240 if( face->face->glyph->format != FT_GLYPH_FORMAT_BITMAP ) {
242 + FT_Outline_Get_CBox(&face->face->glyph->outline, &bbox);
245 + ftrc = FT_Outline_Get_BBox(&face->face->glyph->outline, &bbox);
247 + if( ftrc != 0 ) return FTtoXReturnCode(ftrc);
248 + bbox.yMin = FLOOR64( bbox.yMin );
249 + bbox.yMax = CEIL64 ( bbox.yMax );
250 + ht_actual = ( bbox.yMax - bbox.yMin ) >> 6;
251 + /* FreeType think a glyph with 0 height control box is invalid.
252 + * So just let X to create a empty bitmap instead. */
253 + if ( ht_actual == 0 )
257 ftrc = FT_Render_Glyph(face->face->glyph,FT_RENDER_MODE_MONO);
258 if( ftrc != 0 ) return FTtoXReturnCode(ftrc);
265 @@ -1221,6 +1338,7 @@
266 if( is_outline == 1 ){
268 if( ft_get_very_lazy_bbox( idx, face->face, instance->size,
269 + face->num_hmetrics,
270 instance->ttcap.vl_slant,
271 &instance->transformation.matrix,
272 &bbox, &outline_hori_advance,
273 diff -urbN libXfont-1.1.0/src/FreeType/ftfuncs.h libXfont-1.1.0.new/src/FreeType/ftfuncs.h
274 --- xc/lib/font/FreeType/ftfuncs.h 2005-07-07 22:59:47.000000000 +0800
275 +++ xc/lib/font/FreeType/ftfuncs.h 2006-06-21 21:05:28.533849804 +0800
280 + FT_UInt num_hmetrics;
281 struct _FTInstance *instances;
282 struct _FTInstance *active_instance;
283 struct _FTFace *next; /* link to next face in bucket */
284 diff -urbN libXfont-1.1.0/src/FreeType/ftsystem.c libXfont-1.1.0.new/src/FreeType/ftsystem.c
285 --- xc/lib/font/FreeType/ftsystem.c 2005-07-09 14:36:10.000000000 +0800
286 +++ xc/lib/font/FreeType/ftsystem.c 2006-06-21 21:05:28.534849622 +0800
289 #include <ft2build.h>
290 #include FT_CONFIG_CONFIG_H
291 -#include FT_INTERNAL_DEBUG_H