1 --- XFree86-4.6.0/xc/lib/font/FreeType/ftfuncs.c.orig 2005-10-14 17:16:01.000000000 +0200
2 +++ XFree86-4.6.0/xc/lib/font/FreeType/ftfuncs.c 2006-07-19 08:16:57.502772250 +0200
4 #include FT_TYPE1_TABLES_H
7 -#include FT_INTERNAL_TRUETYPE_TYPES_H
8 #include FT_TRUETYPE_TAGS_H
9 -#include FT_INTERNAL_SFNT_H
10 -#include FT_INTERNAL_STREAM_H
12 * If you want to use FT_Outline_Get_CBox instead of
13 * FT_Outline_Get_BBox, define here.
18 +/* read 2-byte value from a SFNT table */
20 +sfnt_get_ushort( FT_Face face,
22 + FT_ULong table_offset )
25 + FT_ULong len = sizeof(buff);
26 + FT_UShort result = 0;
28 + if ( !FT_Load_Sfnt_Table( face, table_tag, table_offset, buff, &len ) );
29 + result = (FT_UShort)( (buff[0] << 8) | buff[1] );
34 +#define sfnt_get_short(f,t,o) ((FT_Short)sfnt_get_ushort((f),(t),(o)))
37 static int ftypeInitP = 0; /* is the engine initialised? */
38 static FT_Library ftypeLibrary;
41 if(maxp && maxp->maxContours == 0)
45 + face->num_hmetrics = (FT_UInt) sfnt_get_ushort( face->face,
48 /* Insert face in hashtable and return it */
49 face->next = faceTable[bucket];
50 faceTable[bucket] = face;
54 if( FT_IS_SFNT( face->face ) ) {
56 + FT_F26Dot6 tt_char_width, tt_char_height, tt_dim_x, tt_dim_y;
59 + instance->strike_index=0xFFFFU;
61 + tt_char_width = (FT_F26Dot6)(trans->scale*(1<<6) + 0.5);
62 + tt_char_height = (FT_F26Dot6)(trans->scale*(1<<6) + 0.5);
64 + tt_dim_x = FLOOR64( ( tt_char_width * trans->xres + 36 ) / 72 + 32 );
65 + tt_dim_y = FLOOR64( ( tt_char_height * trans->yres + 36 ) / 72 + 32 );
67 + if ( tt_dim_x && !tt_dim_y )
68 + tt_dim_y = tt_dim_x;
69 + else if ( !tt_dim_x && tt_dim_y )
70 + tt_dim_x = tt_dim_y;
72 + for ( nn = 0; nn < face->face->num_fixed_sizes; nn++ )
74 + FT_Bitmap_Size* sz = &face->face->available_sizes[nn];
76 + if ( tt_dim_x == FLOOR64(sz->x_ppem + 32) && tt_dim_y == FLOOR64(sz->y_ppem + 32) )
78 + instance->strike_index = nn;
83 /* See Set_Char_Sizes() in ttdriver.c */
87 sfnt = (SFNT_Service)tt_face->sfnt;
88 err = sfnt->set_sbit_strike(tt_face,tt_x_ppem,tt_y_ppem,&instance->strike_index);
89 if ( err ) instance->strike_index=0xFFFFU;
93 /* maintain a linked list of instances */
95 * parse the htmx field in TrueType font.
98 -/* from src/truetype/ttgload.c */
100 -tt_get_metrics( TT_HoriHeader* header,
101 +tt_get_metrics( FT_Face face,
103 + FT_UInt num_hmetrics,
106 -/* Copyright 1996-2001, 2002 by */
107 -/* David Turner, Robert Wilhelm, and Werner Lemberg. */
109 - TT_LongMetrics longs_m;
110 - FT_UShort k = header->number_Of_HMetrics;
111 + /* read the metrics directly from the horizontal header, we
112 + * parse the SFNT table directly through the standard FreeType API.
113 + * this works with any version of the library and doesn't need to
114 + * peek at its internals. Maybe a bit less
116 + FT_UInt count = num_hmetrics;
117 + FT_ULong length = 0;
118 + FT_ULong offset = 0;
122 - *bearing = *advance = 0;
125 + error = FT_Load_Sfnt_Table( face, TTAG_hmtx, 0, NULL, &length );
127 - if ( idx < (FT_UInt)k ) {
128 - longs_m = (TT_LongMetrics )header->long_metrics + idx;
129 - *bearing = longs_m->bearing;
130 - *advance = longs_m->advance;
131 + if ( count == 0 || error )
136 + else if ( idx < count )
139 + if ( offset + 4 > length )
146 + *advance = sfnt_get_ushort( face, TTAG_hmtx, offset );
147 + *bearing = sfnt_get_short ( face, TTAG_hmtx, offset+2 );
152 + offset = 4L * (count - 1);
153 + if ( offset + 4 > length )
160 + *advance = sfnt_get_ushort ( face, TTAG_hmtx, offset );
161 + offset += 4 + 2 * ( idx - count );
162 + if ( offset + 2 > length)
165 + *bearing = sfnt_get_short ( face, TTAG_hmtx, offset );
168 - *bearing = ((TT_ShortMetrics*)header->short_metrics)[idx - k];
169 - *advance = ((TT_LongMetrics )header->long_metrics)[k - 1].advance;
174 ft_get_very_lazy_bbox( FT_UInt index,
177 + FT_UInt num_hmetrics,
181 @@ -838,15 +918,14 @@
182 FT_Long *vertAdvance)
184 if ( FT_IS_SFNT( face ) ) {
185 - TT_Face ttface = (TT_Face)face;
186 FT_Size_Metrics *smetrics = &size->metrics;
187 FT_Short leftBearing = 0;
188 FT_UShort advance = 0;
189 FT_Vector p0, p1, p2, p3;
192 - tt_get_metrics(&ttface->horizontal, index,
193 - &leftBearing, &advance);
194 + tt_get_metrics( face, index, num_hmetrics,
195 + &leftBearing, &advance );
198 fprintf(stderr,"x_scale=%f y_scale=%f\n",
202 FT_Do_SBit_Metrics( FT_Face ft_face, FT_Size ft_size, FT_ULong strike_index,
203 - FT_UShort glyph_index, FT_Glyph_Metrics *metrics_return )
204 + FT_UShort glyph_index, FT_Glyph_Metrics *metrics_return,
205 + int *sbitchk_incomplete_but_exist )
208 + if ( strike_index != 0xFFFFU && ft_face->available_sizes != NULL )
211 + FT_Bitmap_Size* sz = &ft_face->available_sizes[strike_index];
213 + error = FT_Set_Pixel_Sizes( ft_face, sz->x_ppem/64, sz->y_ppem/64 );
216 + error = FT_Load_Glyph( ft_face, glyph_index, FT_LOAD_SBITS_ONLY );
219 + if ( metrics_return != NULL )
220 + *metrics_return = ft_face->glyph->metrics;
227 +#elif (FREETYPE_VERSION >= 2001008)
232 face = (TT_Face)ft_face;
233 sfnt = (SFNT_Service)face->sfnt;
235 - if ( strike_index != 0xFFFFU && sfnt->load_sbits ) {
236 + if (strike_index != 0xFFFFU && sfnt && sfnt->find_sbit_image &&
237 + sfnt->load_sbits) {
238 /* Check whether there is a glyph sbit for the current index */
239 error = sfnt->find_sbit_image( face, glyph_index, strike_index,
240 &range, &strike, &glyph_offset );
241 @@ -968,6 +1070,17 @@
245 +#else /* if (FREETYPE_VERSION < 2001008) */
248 + if ( ! FT_IS_SFNT( ft_face ) ) return -1;
249 + face = (TT_Face)ft_face;
250 + sfnt = (SFNT_Service)face->sfnt;
251 + if ( strike_index != 0xFFFFU && sfnt->load_sbits ) {
252 + if ( sbitchk_incomplete_but_exist ) *sbitchk_incomplete_but_exist=1;
261 int leftSideBearing, rightSideBearing, characterWidth, rawCharacterWidth,
263 + int sbitchk_incomplete_but_exist;
264 double bbox_center_raw;
266 face = instance->face;
267 @@ -1014,15 +1128,17 @@
271 + sbitchk_incomplete_but_exist=0;
272 if( ! (instance->load_flags & FT_LOAD_NO_BITMAP) ) {
273 if( FT_Do_SBit_Metrics(face->face,instance->size,instance->strike_index,
274 - idx,&sbit_metrics)==0 ) {
275 + idx,&sbit_metrics,&sbitchk_incomplete_but_exist)==0 ) {
276 bitmap_metrics = &sbit_metrics;
279 if( bitmap_metrics == NULL ) {
280 - if ( instance->ttcap.flags & TTCAP_IS_VERY_LAZY ) {
281 + if ( sbitchk_incomplete_but_exist==0 && (instance->ttcap.flags & TTCAP_IS_VERY_LAZY) ) {
282 if( ft_get_very_lazy_bbox( idx, face->face, instance->size,
283 + face->num_hmetrics,
284 instance->ttcap.vl_slant,
285 &instance->transformation.matrix,
286 &bbox, &outline_hori_advance,
287 @@ -1040,6 +1156,8 @@
290 if( bitmap_metrics ) {
293 leftSideBearing = bitmap_metrics->horiBearingX / 64;
294 rightSideBearing = (bitmap_metrics->width + bitmap_metrics->horiBearingX) / 64;
295 bbox_center_raw = (2.0 * bitmap_metrics->horiBearingX + bitmap_metrics->width)/2.0/64.0;
296 @@ -1062,8 +1180,8 @@
297 rightSideBearing += instance->ttcap.rsbShiftOfBitmapAutoItalic;
298 leftSideBearing += instance->ttcap.lsbShiftOfBitmapAutoItalic;
300 - rawCharacterWidth =
301 - (unsigned short)(short)(floor(1000 * bitmap_metrics->horiAdvance
302 + factor = bitmap_metrics->horiAdvance;
303 + rawCharacterWidth = (unsigned short)(short)(floor(1000 * factor
304 * instance->ttcap.scaleBBoxWidth * ratio / 64.
305 / instance->pixel_size));
307 @@ -1155,14 +1273,16 @@
308 else if( flags & FT_FORCE_CONSTANT_SPACING ) correct=1;
310 int sbit_available=0;
311 + sbitchk_incomplete_but_exist=0;
312 if( !(instance->load_flags & FT_LOAD_NO_BITMAP) ) {
313 if( FT_Do_SBit_Metrics(face->face,instance->size,
314 - instance->strike_index,idx,NULL)==0 ) {
315 + instance->strike_index,idx,NULL,
316 + &sbitchk_incomplete_but_exist)==0 ) {
320 if( sbit_available == 0 ) {
321 - if ( instance->ttcap.flags & TTCAP_IS_VERY_LAZY ) {
322 + if ( sbitchk_incomplete_but_exist==0 && (instance->ttcap.flags & TTCAP_IS_VERY_LAZY) ) {
323 if( FT_IS_SFNT(face->face) ) correct=1;
326 @@ -1183,10 +1303,27 @@
329 if( face->face->glyph->format != FT_GLYPH_FORMAT_BITMAP ) {
331 + FT_Outline_Get_CBox(&face->face->glyph->outline, &bbox);
334 + ftrc = FT_Outline_Get_BBox(&face->face->glyph->outline, &bbox);
336 + if( ftrc != 0 ) return FTtoXReturnCode(ftrc);
337 + bbox.yMin = FLOOR64( bbox.yMin );
338 + bbox.yMax = CEIL64 ( bbox.yMax );
339 + ht_actual = ( bbox.yMax - bbox.yMin ) >> 6;
340 + /* FreeType think a glyph with 0 height control box is invalid.
341 + * So just let X to create a empty bitmap instead. */
342 + if ( ht_actual == 0 )
346 ftrc = FT_Render_Glyph(face->face->glyph,FT_RENDER_MODE_MONO);
347 if( ftrc != 0 ) return FTtoXReturnCode(ftrc);
354 @@ -1197,6 +1334,7 @@
355 if( is_outline == 1 ){
357 if( ft_get_very_lazy_bbox( idx, face->face, instance->size,
358 + face->num_hmetrics,
359 instance->ttcap.vl_slant,
360 &instance->transformation.matrix,
361 &bbox, &outline_hori_advance,
362 --- XFree86-4.6.0/xc/lib/font/FreeType/ftfuncs.h.orig 2004-04-14 17:32:43.000000000 +0200
363 +++ XFree86-4.6.0/xc/lib/font/FreeType/ftfuncs.h 2006-07-19 08:17:53.774289000 +0200
368 + FT_UInt num_hmetrics;
369 struct _FTInstance *instances;
370 struct _FTInstance *active_instance;
371 struct _FTFace *next; /* link to next face in bucket */
372 --- XFree86-4.6.0/xc/programs/fonttosfnt/util.c.orig 2005-02-07 02:01:16.000000000 +0100
373 +++ XFree86-4.6.0/xc/programs/fonttosfnt/util.c 2006-07-19 17:46:00.392569500 +0200
376 #include <ft2build.h>
377 #include FT_FREETYPE_H
378 -#include FT_INTERNAL_OBJECTS_H
381 #include "fonttosfnt.h"