pass ARCH down to uClibc
[buildroot.git] / package / xorg / libXfont-1.1.0-noftinternals.patch
blob846410dc741cb90c4069b53b20088a8c7a3d46e2
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
4 @@ -54,10 +54,7 @@
5 #include FT_TYPE1_TABLES_H
6 #include FT_XFREE86_H
7 #include FT_BBOX_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.
15 @@ -123,6 +120,25 @@
19 +/* read 2-byte value from a SFNT table */
20 +static FT_UShort
21 +sfnt_get_ushort( FT_Face face,
22 + FT_ULong table_tag,
23 + FT_ULong table_offset )
25 + FT_Byte buff[2];
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] );
32 + return result;
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;
41 @@ -211,6 +227,10 @@
42 if(maxp && maxp->maxContours == 0)
43 face->bitmap = 1;
46 + face->num_hmetrics = (FT_UInt) sfnt_get_ushort( face->face,
47 + TTAG_hhea, 34 );
49 /* Insert face in hashtable and return it */
50 face->next = faceTable[bucket];
51 faceTable[bucket] = face;
52 @@ -462,6 +482,34 @@
55 if( FT_IS_SFNT( face->face ) ) {
56 +#if 1
57 + FT_F26Dot6 tt_char_width, tt_char_height, tt_dim_x, tt_dim_y;
58 + FT_UInt nn;
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++ )
74 + {
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) )
78 + {
79 + instance->strike_index = nn;
80 + break;
81 + }
82 + }
83 +#else
84 /* See Set_Char_Sizes() in ttdriver.c */
85 FT_Error err;
86 TT_Face tt_face;
87 @@ -486,6 +534,7 @@
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;
91 +#endif
94 /* maintain a linked list of instances */
95 @@ -803,31 +852,61 @@
96 * parse the htmx field in TrueType font.
99 -/* from src/truetype/ttgload.c */
100 static void
101 -tt_get_metrics( TT_HoriHeader* header,
102 +tt_get_metrics( FT_Face face,
103 FT_UInt idx,
104 + FT_UInt num_hmetrics,
105 FT_Short* bearing,
106 FT_UShort* advance )
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
116 + */
117 + FT_UInt count = num_hmetrics;
118 + FT_ULong length = 0;
119 + FT_ULong offset = 0;
120 + FT_Error error;
122 - if ( k == 0 ) {
123 - *bearing = *advance = 0;
124 - return;
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 )
134 + *advance = 0;
135 + *bearing = 0;
137 + else if ( idx < count )
139 + offset = idx * 4L;
140 + if ( offset + 4 > length )
142 + *advance = 0;
143 + *bearing = 0;
145 + else
147 + *advance = sfnt_get_ushort( face, TTAG_hmtx, offset );
148 + *bearing = sfnt_get_short ( face, TTAG_hmtx, offset+2 );
151 + else
153 + offset = 4L * (count - 1);
154 + if ( offset + 4 > length )
156 + *advance = 0;
157 + *bearing = 0;
159 + else
161 + *advance = sfnt_get_ushort ( face, TTAG_hmtx, offset );
162 + offset += 4 + 2 * ( idx - count );
163 + if ( offset + 2 > length)
164 + *bearing = 0;
165 + else
166 + *bearing = sfnt_get_short ( face, TTAG_hmtx, offset );
168 - else {
169 - *bearing = ((TT_ShortMetrics*)header->short_metrics)[idx - k];
170 - *advance = ((TT_LongMetrics )header->long_metrics)[k - 1].advance;
174 @@ -835,6 +914,7 @@
175 ft_get_very_lazy_bbox( FT_UInt index,
176 FT_Face face,
177 FT_Size size,
178 + FT_UInt num_hmetrics,
179 double slant,
180 FT_Matrix *matrix,
181 FT_BBox *bbox,
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;
192 /* horizontal */
193 - tt_get_metrics(&ttface->horizontal, index,
194 - &leftBearing, &advance);
195 + tt_get_metrics( face, index, num_hmetrics,
196 + &leftBearing, &advance );
198 #if 0
199 fprintf(stderr,"x_scale=%f y_scale=%f\n",
200 @@ -910,7 +989,27 @@
201 FT_UShort glyph_index, FT_Glyph_Metrics *metrics_return,
202 int *sbitchk_incomplete_but_exist )
204 -#if (FREETYPE_VERSION >= 2001008)
205 +#if 1
206 + if ( strike_index != 0xFFFFU && ft_face->available_sizes != NULL )
208 + FT_Error error;
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 );
212 + if ( !error )
214 + error = FT_Load_Glyph( ft_face, glyph_index, FT_LOAD_SBITS_ONLY );
215 + if ( !error )
217 + if ( metrics_return != NULL )
218 + *metrics_return = ft_face->glyph->metrics;
220 + return 0;
224 + return -1;
225 +#elif (FREETYPE_VERSION >= 2001008)
226 SFNT_Service sfnt;
227 TT_Face face;
228 FT_Error error;
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 ) {
241 +#ifdef USE_GET_CBOX
242 + FT_Outline_Get_CBox(&face->face->glyph->outline, &bbox);
243 + ftrc = 0;
244 +#else
245 + ftrc = FT_Outline_Get_BBox(&face->face->glyph->outline, &bbox);
246 +#endif
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 )
254 + is_outline = -1;
255 + else
257 ftrc = FT_Render_Glyph(face->face->glyph,FT_RENDER_MODE_MONO);
258 if( ftrc != 0 ) return FTtoXReturnCode(ftrc);
259 is_outline = 1;
262 else{
263 is_outline=0;
265 @@ -1221,6 +1338,7 @@
266 if( is_outline == 1 ){
267 if( correct ){
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
276 @@ -47,6 +47,7 @@
277 char *filename;
278 FT_Face face;
279 int bitmap;
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
287 @@ -35,7 +35,6 @@
288 #endif
289 #include <ft2build.h>
290 #include FT_CONFIG_CONFIG_H
291 -#include FT_INTERNAL_DEBUG_H
292 #include FT_SYSTEM_H
293 #include FT_ERRORS_H
294 #include FT_TYPES_H