zenilib: zenilib/jni/external/freetype2/src/bdf/bdfdrivr.c Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
bdfdrivr.c
Go to the documentation of this file.
1 /* bdfdrivr.c
2
3 FreeType font driver for bdf files
4
5 Copyright (C) 2001-2008, 2011 by
6 Francesco Zappa Nardelli
7
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
14
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 THE SOFTWARE.
25 */
26
27 #include <ft2build.h>
28
29 #include FT_INTERNAL_DEBUG_H
30 #include FT_INTERNAL_STREAM_H
31 #include FT_INTERNAL_OBJECTS_H
32 #include FT_BDF_H
33 #include FT_TRUETYPE_IDS_H
34
35 #include FT_SERVICE_BDF_H
36 #include FT_SERVICE_XFREE86_NAME_H
37
38 #include "bdf.h"
39 #include "bdfdrivr.h"
40
41 #include "bdferror.h"
42
43
44 /*************************************************************************/
45 /* */
46 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
47 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
48 /* messages during execution. */
49 /* */
50 #undef FT_COMPONENT
51 #define FT_COMPONENT trace_bdfdriver
52
53
54 typedef struct BDF_CMapRec_
55 {
56 FT_CMapRec cmap;
57 FT_ULong num_encodings; /* ftobjs.h: FT_CMap->clazz->size */
58 BDF_encoding_el* encodings;
59
60 } BDF_CMapRec, *BDF_CMap;
61
62
63 FT_CALLBACK_DEF( FT_Error )
64 bdf_cmap_init( FT_CMap bdfcmap,
65 FT_Pointer init_data )
66 {
67 BDF_CMap cmap = (BDF_CMap)bdfcmap;
68 BDF_Face face = (BDF_Face)FT_CMAP_FACE( cmap );
69 FT_UNUSED( init_data );
70
71
72 cmap->num_encodings = face->bdffont->glyphs_used;
73 cmap->encodings = face->en_table;
74
75 return BDF_Err_Ok;
76 }
77
78
79 FT_CALLBACK_DEF( void )
80 bdf_cmap_done( FT_CMap bdfcmap )
81 {
82 BDF_CMap cmap = (BDF_CMap)bdfcmap;
83
84
85 cmap->encodings = NULL;
86 cmap->num_encodings = 0;
87 }
88
89
90 FT_CALLBACK_DEF( FT_UInt )
91 bdf_cmap_char_index( FT_CMap bdfcmap,
92 FT_UInt32 charcode )
93 {
94 BDF_CMap cmap = (BDF_CMap)bdfcmap;
95 BDF_encoding_el* encodings = cmap->encodings;
96 FT_ULong min, max, mid; /* num_encodings */
97 FT_UShort result = 0; /* encodings->glyph */
98
99
100 min = 0;
101 max = cmap->num_encodings;
102
103 while ( min < max )
104 {
105 FT_ULong code;
106
107
108 mid = ( min + max ) >> 1;
109 code = encodings[mid].enc;
110
111 if ( charcode == code )
112 {
113 /* increase glyph index by 1 -- */
114 /* we reserve slot 0 for the undefined glyph */
115 result = encodings[mid].glyph + 1;
116 break;
117 }
118
119 if ( charcode < code )
120 max = mid;
121 else
122 min = mid + 1;
123 }
124
125 return result;
126 }
127
128
129 FT_CALLBACK_DEF( FT_UInt )
130 bdf_cmap_char_next( FT_CMap bdfcmap,
131 FT_UInt32 *acharcode )
132 {
133 BDF_CMap cmap = (BDF_CMap)bdfcmap;
134 BDF_encoding_el* encodings = cmap->encodings;
135 FT_ULong min, max, mid; /* num_encodings */
136 FT_UShort result = 0; /* encodings->glyph */
137 FT_ULong charcode = *acharcode + 1;
138
139
140 min = 0;
141 max = cmap->num_encodings;
142
143 while ( min < max )
144 {
145 FT_ULong code; /* same as BDF_encoding_el.enc */
146
147
148 mid = ( min + max ) >> 1;
149 code = encodings[mid].enc;
150
151 if ( charcode == code )
152 {
153 /* increase glyph index by 1 -- */
154 /* we reserve slot 0 for the undefined glyph */
155 result = encodings[mid].glyph + 1;
156 goto Exit;
157 }
158
159 if ( charcode < code )
160 max = mid;
161 else
162 min = mid + 1;
163 }
164
165 charcode = 0;
166 if ( min < cmap->num_encodings )
167 {
168 charcode = encodings[min].enc;
169 result = encodings[min].glyph + 1;
170 }
171
172 Exit:
173 if ( charcode > 0xFFFFFFFFUL )
174 {
175 FT_TRACE1(( "bdf_cmap_char_next: charcode 0x%x > 32bit API" ));
176 *acharcode = 0;
177 /* XXX: result should be changed to indicate an overflow error */
178 }
179 else
180 *acharcode = (FT_UInt32)charcode;
181 return result;
182 }
183
184
185 FT_CALLBACK_TABLE_DEF
186 const FT_CMap_ClassRec bdf_cmap_class =
187 {
188 sizeof ( BDF_CMapRec ),
189 bdf_cmap_init,
190 bdf_cmap_done,
191 bdf_cmap_char_index,
192 bdf_cmap_char_next,
193
194 NULL, NULL, NULL, NULL, NULL
195 };
196
197
198 static FT_Error
199 bdf_interpret_style( BDF_Face bdf )
200 {
201 FT_Error error = BDF_Err_Ok;
202 FT_Face face = FT_FACE( bdf );
203 FT_Memory memory = face->memory;
204 bdf_font_t* font = bdf->bdffont;
205 bdf_property_t* prop;
206
207 char* strings[4] = { NULL, NULL, NULL, NULL };
208 size_t nn, len, lengths[4];
209
210
211 face->style_flags = 0;
212
213 prop = bdf_get_font_property( font, (char *)"SLANT" );
214 if ( prop && prop->format == BDF_ATOM &&
215 prop->value.atom &&
216 ( *(prop->value.atom) == 'O' || *(prop->value.atom) == 'o' ||
217 *(prop->value.atom) == 'I' || *(prop->value.atom) == 'i' ) )
218 {
219 face->style_flags |= FT_STYLE_FLAG_ITALIC;
220 strings[2] = ( *(prop->value.atom) == 'O' || *(prop->value.atom) == 'o' )
221 ? (char *)"Oblique"
222 : (char *)"Italic";
223 }
224
225 prop = bdf_get_font_property( font, (char *)"WEIGHT_NAME" );
226 if ( prop && prop->format == BDF_ATOM &&
227 prop->value.atom &&
228 ( *(prop->value.atom) == 'B' || *(prop->value.atom) == 'b' ) )
229 {
230 face->style_flags |= FT_STYLE_FLAG_BOLD;
231 strings[1] = (char *)"Bold";
232 }
233
234 prop = bdf_get_font_property( font, (char *)"SETWIDTH_NAME" );
235 if ( prop && prop->format == BDF_ATOM &&
236 prop->value.atom && *(prop->value.atom) &&
237 !( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) )
238 strings[3] = (char *)(prop->value.atom);
239
240 prop = bdf_get_font_property( font, (char *)"ADD_STYLE_NAME" );
241 if ( prop && prop->format == BDF_ATOM &&
242 prop->value.atom && *(prop->value.atom) &&
243 !( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) )
244 strings[0] = (char *)(prop->value.atom);
245
246 len = 0;
247
248 for ( len = 0, nn = 0; nn < 4; nn++ )
249 {
250 lengths[nn] = 0;
251 if ( strings[nn] )
252 {
253 lengths[nn] = ft_strlen( strings[nn] );
254 len += lengths[nn] + 1;
255 }
256 }
257
258 if ( len == 0 )
259 {
260 strings[0] = (char *)"Regular";
261 lengths[0] = ft_strlen( strings[0] );
262 len = lengths[0] + 1;
263 }
264
265 {
266 char* s;
267
268
269 if ( FT_ALLOC( face->style_name, len ) )
270 return error;
271
272 s = face->style_name;
273
274 for ( nn = 0; nn < 4; nn++ )
275 {
276 char* src = strings[nn];
277
278
279 len = lengths[nn];
280
281 if ( src == NULL )
282 continue;
283
284 /* separate elements with a space */
285 if ( s != face->style_name )
286 *s++ = ' ';
287
288 ft_memcpy( s, src, len );
289
290 /* need to convert spaces to dashes for */
291 /* add_style_name and setwidth_name */
292 if ( nn == 0 || nn == 3 )
293 {
294 size_t mm;
295
296
297 for ( mm = 0; mm < len; mm++ )
298 if ( s[mm] == ' ' )
299 s[mm] = '-';
300 }
301
302 s += len;
303 }
304 *s = 0;
305 }
306
307 return error;
308 }
309
310
311 FT_CALLBACK_DEF( void )
312 BDF_Face_Done( FT_Face bdfface ) /* BDF_Face */
313 {
314 BDF_Face face = (BDF_Face)bdfface;
315 FT_Memory memory;
316
317
318 if ( !face )
319 return;
320
321 memory = FT_FACE_MEMORY( face );
322
323 bdf_free_font( face->bdffont );
324
325 FT_FREE( face->en_table );
326
327 FT_FREE( face->charset_encoding );
328 FT_FREE( face->charset_registry );
329 FT_FREE( bdfface->family_name );
330 FT_FREE( bdfface->style_name );
331
332 FT_FREE( bdfface->available_sizes );
333
334 FT_FREE( face->bdffont );
335 }
336
337
338 FT_CALLBACK_DEF( FT_Error )
339 BDF_Face_Init( FT_Stream stream,
340 FT_Face bdfface, /* BDF_Face */
341 FT_Int face_index,
342 FT_Int num_params,
343 FT_Parameter* params )
344 {
345 FT_Error error = BDF_Err_Ok;
346 BDF_Face face = (BDF_Face)bdfface;
347 FT_Memory memory = FT_FACE_MEMORY( face );
348
349 bdf_font_t* font = NULL;
350 bdf_options_t options;
351
352 FT_UNUSED( num_params );
353 FT_UNUSED( params );
354 FT_UNUSED( face_index );
355
356
357 FT_TRACE2(( "BDF driver\n" ));
358
359 if ( FT_STREAM_SEEK( 0 ) )
360 goto Exit;
361
362 options.correct_metrics = 1; /* FZ XXX: options semantics */
363 options.keep_unencoded = 1;
364 options.keep_comments = 0;
365 options.font_spacing = BDF_PROPORTIONAL;
366
367 error = bdf_load_font( stream, memory, &options, &font );
368 if ( error == BDF_Err_Missing_Startfont_Field )
369 {
370 FT_TRACE2(( " not a BDF file\n" ));
371 goto Fail;
372 }
373 else if ( error )
374 goto Exit;
375
376 /* we have a bdf font: let's construct the face object */
377 face->bdffont = font;
378 {
379 bdf_property_t* prop = NULL;
380
381
382 FT_TRACE4(( " number of glyphs: allocated %d (used %d)\n",
383 font->glyphs_size,
384 font->glyphs_used ));
385 FT_TRACE4(( " number of unencoded glyphs: allocated %d (used %d)\n",
386 font->unencoded_size,
387 font->unencoded_used ));
388
389 bdfface->num_faces = 1;
390 bdfface->face_index = 0;
391 bdfface->face_flags = FT_FACE_FLAG_FIXED_SIZES |
392 FT_FACE_FLAG_HORIZONTAL |
393 FT_FACE_FLAG_FAST_GLYPHS;
394
395 prop = bdf_get_font_property( font, "SPACING" );
396 if ( prop && prop->format == BDF_ATOM &&
397 prop->value.atom &&
398 ( *(prop->value.atom) == 'M' || *(prop->value.atom) == 'm' ||
399 *(prop->value.atom) == 'C' || *(prop->value.atom) == 'c' ) )
400 bdfface->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
401
402 /* FZ XXX: TO DO: FT_FACE_FLAGS_VERTICAL */
403 /* FZ XXX: I need a font to implement this */
404
405 prop = bdf_get_font_property( font, "FAMILY_NAME" );
406 if ( prop && prop->value.atom )
407 {
408 if ( FT_STRDUP( bdfface->family_name, prop->value.atom ) )
409 goto Exit;
410 }
411 else
412 bdfface->family_name = 0;
413
414 if ( ( error = bdf_interpret_style( face ) ) != 0 )
415 goto Exit;
416
417 /* the number of glyphs (with one slot for the undefined glyph */
418 /* at position 0 and all unencoded glyphs) */
419 bdfface->num_glyphs = font->glyphs_size + 1;
420
421 bdfface->num_fixed_sizes = 1;
422 if ( FT_NEW_ARRAY( bdfface->available_sizes, 1 ) )
423 goto Exit;
424
425 {
426 FT_Bitmap_Size* bsize = bdfface->available_sizes;
427 FT_Short resolution_x = 0, resolution_y = 0;
428
429
430 FT_MEM_ZERO( bsize, sizeof ( FT_Bitmap_Size ) );
431
432 bsize->height = (FT_Short)( font->font_ascent + font->font_descent );
433
434 prop = bdf_get_font_property( font, "AVERAGE_WIDTH" );
435 if ( prop )
436 bsize->width = (FT_Short)( ( prop->value.l + 5 ) / 10 );
437 else
438 bsize->width = (FT_Short)( bsize->height * 2/3 );
439
440 prop = bdf_get_font_property( font, "POINT_SIZE" );
441 if ( prop )
442 /* convert from 722.7 decipoints to 72 points per inch */
443 bsize->size =
444 (FT_Pos)( ( prop->value.l * 64 * 7200 + 36135L ) / 72270L );
445 else
446 bsize->size = bsize->width << 6;
447
448 prop = bdf_get_font_property( font, "PIXEL_SIZE" );
449 if ( prop )
450 bsize->y_ppem = (FT_Short)prop->value.l << 6;
451
452 prop = bdf_get_font_property( font, "RESOLUTION_X" );
453 if ( prop )
454 resolution_x = (FT_Short)prop->value.l;
455
456 prop = bdf_get_font_property( font, "RESOLUTION_Y" );
457 if ( prop )
458 resolution_y = (FT_Short)prop->value.l;
459
460 if ( bsize->y_ppem == 0 )
461 {
462 bsize->y_ppem = bsize->size;
463 if ( resolution_y )
464 bsize->y_ppem = bsize->y_ppem * resolution_y / 72;
465 }
466 if ( resolution_x && resolution_y )
467 bsize->x_ppem = bsize->y_ppem * resolution_x / resolution_y;
468 else
469 bsize->x_ppem = bsize->y_ppem;
470 }
471
472 /* encoding table */
473 {
474 bdf_glyph_t* cur = font->glyphs;
475 unsigned long n;
476
477
478 if ( FT_NEW_ARRAY( face->en_table, font->glyphs_size ) )
479 goto Exit;
480
481 face->default_glyph = 0;
482 for ( n = 0; n < font->glyphs_size; n++ )
483 {
484 (face->en_table[n]).enc = cur[n].encoding;
485 FT_TRACE4(( " idx %d, val 0x%lX\n", n, cur[n].encoding ));
486 (face->en_table[n]).glyph = (FT_Short)n;
487
488 if ( cur[n].encoding == font->default_char )
489 {
490 if ( n < FT_UINT_MAX )
491 face->default_glyph = (FT_UInt)n;
492 else
493 FT_TRACE1(( "BDF_Face_Init:"
494 " idx %d is too large for this system\n", n ));
495 }
496 }
497 }
498
499 /* charmaps */
500 {
501 bdf_property_t *charset_registry = 0, *charset_encoding = 0;
502 FT_Bool unicode_charmap = 0;
503
504
505 charset_registry =
506 bdf_get_font_property( font, "CHARSET_REGISTRY" );
507 charset_encoding =
508 bdf_get_font_property( font, "CHARSET_ENCODING" );
509 if ( charset_registry && charset_encoding )
510 {
511 if ( charset_registry->format == BDF_ATOM &&
512 charset_encoding->format == BDF_ATOM &&
513 charset_registry->value.atom &&
514 charset_encoding->value.atom )
515 {
516 const char* s;
517
518
519 if ( FT_STRDUP( face->charset_encoding,
520 charset_encoding->value.atom ) ||
521 FT_STRDUP( face->charset_registry,
522 charset_registry->value.atom ) )
523 goto Exit;
524
525 /* Uh, oh, compare first letters manually to avoid dependency */
526 /* on locales. */
527 s = face->charset_registry;
528 if ( ( s[0] == 'i' || s[0] == 'I' ) &&
529 ( s[1] == 's' || s[1] == 'S' ) &&
530 ( s[2] == 'o' || s[2] == 'O' ) )
531 {
532 s += 3;
533 if ( !ft_strcmp( s, "10646" ) ||
534 ( !ft_strcmp( s, "8859" ) &&
535 !ft_strcmp( face->charset_encoding, "1" ) ) )
536 unicode_charmap = 1;
537 }
538
539 {
540 FT_CharMapRec charmap;
541
542
543 charmap.face = FT_FACE( face );
544 charmap.encoding = FT_ENCODING_NONE;
545 /* initial platform/encoding should indicate unset status? */
546 charmap.platform_id = TT_PLATFORM_APPLE_UNICODE;
547 charmap.encoding_id = TT_APPLE_ID_DEFAULT;
548
549 if ( unicode_charmap )
550 {
551 charmap.encoding = FT_ENCODING_UNICODE;
552 charmap.platform_id = TT_PLATFORM_MICROSOFT;
553 charmap.encoding_id = TT_MS_ID_UNICODE_CS;
554 }
555
556 error = FT_CMap_New( &bdf_cmap_class, NULL, &charmap, NULL );
557
558 #if 0
559 /* Select default charmap */
560 if ( bdfface->num_charmaps )
561 bdfface->charmap = bdfface->charmaps[0];
562 #endif
563 }
564
565 goto Exit;
566 }
567 }
568
569 /* otherwise assume Adobe standard encoding */
570
571 {
572 FT_CharMapRec charmap;
573
574
575 charmap.face = FT_FACE( face );
576 charmap.encoding = FT_ENCODING_ADOBE_STANDARD;
577 charmap.platform_id = TT_PLATFORM_ADOBE;
578 charmap.encoding_id = TT_ADOBE_ID_STANDARD;
579
580 error = FT_CMap_New( &bdf_cmap_class, NULL, &charmap, NULL );
581
582 /* Select default charmap */
583 if ( bdfface->num_charmaps )
584 bdfface->charmap = bdfface->charmaps[0];
585 }
586 }
587 }
588
589 Exit:
590 return error;
591
592 Fail:
593 BDF_Face_Done( bdfface );
594 return BDF_Err_Unknown_File_Format;
595 }
596
597
598 FT_CALLBACK_DEF( FT_Error )
599 BDF_Size_Select( FT_Size size,
600 FT_ULong strike_index )
601 {
602 bdf_font_t* bdffont = ( (BDF_Face)size->face )->bdffont;
603
604
605 FT_Select_Metrics( size->face, strike_index );
606
607 size->metrics.ascender = bdffont->font_ascent << 6;
608 size->metrics.descender = -bdffont->font_descent << 6;
609 size->metrics.max_advance = bdffont->bbx.width << 6;
610
611 return BDF_Err_Ok;
612 }
613
614
615 FT_CALLBACK_DEF( FT_Error )
616 BDF_Size_Request( FT_Size size,
617 FT_Size_Request req )
618 {
619 FT_Face face = size->face;
620 FT_Bitmap_Size* bsize = face->available_sizes;
621 bdf_font_t* bdffont = ( (BDF_Face)face )->bdffont;
622 FT_Error error = BDF_Err_Invalid_Pixel_Size;
623 FT_Long height;
624
625
626 height = FT_REQUEST_HEIGHT( req );
627 height = ( height + 32 ) >> 6;
628
629 switch ( req->type )
630 {
631 case FT_SIZE_REQUEST_TYPE_NOMINAL:
632 if ( height == ( ( bsize->y_ppem + 32 ) >> 6 ) )
633 error = BDF_Err_Ok;
634 break;
635
636 case FT_SIZE_REQUEST_TYPE_REAL_DIM:
637 if ( height == ( bdffont->font_ascent +
638 bdffont->font_descent ) )
639 error = BDF_Err_Ok;
640 break;
641
642 default:
643 error = BDF_Err_Unimplemented_Feature;
644 break;
645 }
646
647 if ( error )
648 return error;
649 else
650 return BDF_Size_Select( size, 0 );
651 }
652
653
654
655 FT_CALLBACK_DEF( FT_Error )
656 BDF_Glyph_Load( FT_GlyphSlot slot,
657 FT_Size size,
658 FT_UInt glyph_index,
659 FT_Int32 load_flags )
660 {
661 BDF_Face bdf = (BDF_Face)FT_SIZE_FACE( size );
662 FT_Face face = FT_FACE( bdf );
663 FT_Error error = BDF_Err_Ok;
664 FT_Bitmap* bitmap = &slot->bitmap;
665 bdf_glyph_t glyph;
666 int bpp = bdf->bdffont->bpp;
667
668 FT_UNUSED( load_flags );
669
670
671 if ( !face || glyph_index >= (FT_UInt)face->num_glyphs )
672 {
673 error = BDF_Err_Invalid_Argument;
674 goto Exit;
675 }
676
677 /* index 0 is the undefined glyph */
678 if ( glyph_index == 0 )
679 glyph_index = bdf->default_glyph;
680 else
681 glyph_index--;
682
683 /* slot, bitmap => freetype, glyph => bdflib */
684 glyph = bdf->bdffont->glyphs[glyph_index];
685
686 bitmap->rows = glyph.bbx.height;
687 bitmap->width = glyph.bbx.width;
688 if ( glyph.bpr > INT_MAX )
689 FT_TRACE1(( "BDF_Glyph_Load: too large pitch %d is truncated\n",
690 glyph.bpr ));
691 bitmap->pitch = (int)glyph.bpr; /* same as FT_Bitmap.pitch */
692
693 /* note: we don't allocate a new array to hold the bitmap; */
694 /* we can simply point to it */
695 ft_glyphslot_set_bitmap( slot, glyph.bitmap );
696
697 switch ( bpp )
698 {
699 case 1:
700 bitmap->pixel_mode = FT_PIXEL_MODE_MONO;
701 break;
702 case 2:
703 bitmap->pixel_mode = FT_PIXEL_MODE_GRAY2;
704 break;
705 case 4:
706 bitmap->pixel_mode = FT_PIXEL_MODE_GRAY4;
707 break;
708 case 8:
709 bitmap->pixel_mode = FT_PIXEL_MODE_GRAY;
710 bitmap->num_grays = 256;
711 break;
712 }
713
714 slot->format = FT_GLYPH_FORMAT_BITMAP;
715 slot->bitmap_left = glyph.bbx.x_offset;
716 slot->bitmap_top = glyph.bbx.ascent;
717
718 slot->metrics.horiAdvance = glyph.dwidth << 6;
719 slot->metrics.horiBearingX = glyph.bbx.x_offset << 6;
720 slot->metrics.horiBearingY = glyph.bbx.ascent << 6;
721 slot->metrics.width = bitmap->width << 6;
722 slot->metrics.height = bitmap->rows << 6;
723
724 /*
725 * XXX DWIDTH1 and VVECTOR should be parsed and
726 * used here, provided such fonts do exist.
727 */
728 ft_synthesize_vertical_metrics( &slot->metrics,
729 bdf->bdffont->bbx.height << 6 );
730
731 Exit:
732 return error;
733 }
734
735
736 /*
737 *
738 * BDF SERVICE
739 *
740 */
741
742 static FT_Error
743 bdf_get_bdf_property( BDF_Face face,
744 const char* prop_name,
745 BDF_PropertyRec *aproperty )
746 {
747 bdf_property_t* prop;
748
749
750 FT_ASSERT( face && face->bdffont );
751
752 prop = bdf_get_font_property( face->bdffont, prop_name );
753 if ( prop )
754 {
755 switch ( prop->format )
756 {
757 case BDF_ATOM:
758 aproperty->type = BDF_PROPERTY_TYPE_ATOM;
759 aproperty->u.atom = prop->value.atom;
760 break;
761
762 case BDF_INTEGER:
763 if ( prop->value.l > 0x7FFFFFFFL || prop->value.l < ( -1 - 0x7FFFFFFFL ) )
764 {
765 FT_TRACE1(( "bdf_get_bdf_property:"
766 " too large integer 0x%x is truncated\n" ));
767 }
768 aproperty->type = BDF_PROPERTY_TYPE_INTEGER;
769 aproperty->u.integer = (FT_Int32)prop->value.l;
770 break;
771
772 case BDF_CARDINAL:
773 if ( prop->value.ul > 0xFFFFFFFFUL )
774 {
775 FT_TRACE1(( "bdf_get_bdf_property:"
776 " too large cardinal 0x%x is truncated\n" ));
777 }
778 aproperty->type = BDF_PROPERTY_TYPE_CARDINAL;
779 aproperty->u.cardinal = (FT_UInt32)prop->value.ul;
780 break;
781
782 default:
783 goto Fail;
784 }
785 return 0;
786 }
787
788 Fail:
789 return BDF_Err_Invalid_Argument;
790 }
791
792
793 static FT_Error
794 bdf_get_charset_id( BDF_Face face,
795 const char* *acharset_encoding,
796 const char* *acharset_registry )
797 {
798 *acharset_encoding = face->charset_encoding;
799 *acharset_registry = face->charset_registry;
800
801 return 0;
802 }
803
804
805 static const FT_Service_BDFRec bdf_service_bdf =
806 {
807 (FT_BDF_GetCharsetIdFunc)bdf_get_charset_id,
808 (FT_BDF_GetPropertyFunc) bdf_get_bdf_property
809 };
810
811
812 /*
813 *
814 * SERVICES LIST
815 *
816 */
817
818 static const FT_ServiceDescRec bdf_services[] =
819 {
820 { FT_SERVICE_ID_BDF, &bdf_service_bdf },
821 { FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_BDF },
822 { NULL, NULL }
823 };
824
825
826 FT_CALLBACK_DEF( FT_Module_Interface )
827 bdf_driver_requester( FT_Module module,
828 const char* name )
829 {
830 FT_UNUSED( module );
831
832 return ft_service_list_lookup( bdf_services, name );
833 }
834
835
836
837 FT_CALLBACK_TABLE_DEF
838 const FT_Driver_ClassRec bdf_driver_class =
839 {
840 {
841 FT_MODULE_FONT_DRIVER |
842 FT_MODULE_DRIVER_NO_OUTLINES,
843 sizeof ( FT_DriverRec ),
844
845 "bdf",
846 0x10000L,
847 0x20000L,
848
849 0,
850
851 0, /* FT_Module_Constructor */
852 0, /* FT_Module_Destructor */
853 bdf_driver_requester
854 },
855
856 sizeof ( BDF_FaceRec ),
857 sizeof ( FT_SizeRec ),
858 sizeof ( FT_GlyphSlotRec ),
859
860 BDF_Face_Init,
861 BDF_Face_Done,
862 0, /* FT_Size_InitFunc */
863 0, /* FT_Size_DoneFunc */
864 0, /* FT_Slot_InitFunc */
865 0, /* FT_Slot_DoneFunc */
866
867 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
868 ft_stub_set_char_sizes,
869 ft_stub_set_pixel_sizes,
870 #endif
871 BDF_Glyph_Load,
872
873 0, /* FT_Face_GetKerningFunc */
874 0, /* FT_Face_AttachFunc */
875 0, /* FT_Face_GetAdvancesFunc */
876
877 BDF_Size_Request,
878 BDF_Size_Select
879 };
880
881
882 /* END */
FT_ALLOC
#define FT_ALLOC(ptr, size)
Definition: ftmemory.h:260
FT_UINT_MAX
#define FT_UINT_MAX
Definition: ftstdlib.h:66
ft_glyphslot_set_bitmap
ft_glyphslot_set_bitmap(FT_GlyphSlot slot, FT_Byte *buffer)
Definition: ftobjs.c:283
ft_service_list_lookup
ft_service_list_lookup(FT_ServiceDesc service_descriptors, const char *service_id)
Definition: ftobjs.c:47
FT_SizeRec_
Definition: freetype.h:1395
FT_Error
int FT_Error
Definition: fttypes.h:296
bdf_font_t_::unencoded_size
unsigned long unencoded_size
Definition: bdf.h:214
FT_Long
signed long FT_Long
Definition: fttypes.h:238
FT_Bitmap_Size_::x_ppem
FT_Pos x_ppem
Definition: freetype.h:301
s
GLdouble s
Definition: glew.h:1376
BDF_FaceRec_::charset_encoding
char * charset_encoding
Definition: bdfdrivr.h:56
BDF_encoding_el
FT_BEGIN_HEADER struct BDF_encoding_el_ BDF_encoding_el
FT_ULong
unsigned long FT_ULong
Definition: fttypes.h:249
FT_Bitmap_Size_::width
FT_Short width
Definition: freetype.h:297
bdferror.h
FT_Pos
FT_BEGIN_HEADER typedef signed long FT_Pos
Definition: ftimage.h:59
BDF_PROPERTY_TYPE_CARDINAL
Definition: ftbdf.h:79
FT_GlyphSlotRec_
Definition: freetype.h:1605
bdf_property_t_::value
union bdf_property_t_::@25 value
bdf_get_charset_id
static FT_Error bdf_get_charset_id(BDF_Face face, const char **acharset_encoding, const char **acharset_registry)
Definition: bdfdrivr.c:794
ft_synthesize_vertical_metrics
ft_synthesize_vertical_metrics(FT_Glyph_Metrics *metrics, FT_Pos advance)
Definition: ftobjs.c:2530
BDF_Glyph_Load
BDF_Glyph_Load(FT_GlyphSlot slot, FT_Size size, FT_UInt glyph_index, FT_Int32 load_flags)
Definition: bdfdrivr.c:656
FT_CMAP_FACE
#define FT_CMAP_FACE(x)
Definition: ftobjs.h:145
bdf_driver_class
FT_CALLBACK_TABLE_DEF const FT_Driver_ClassRec bdf_driver_class
Definition: bdfdrivr.c:838
FT_Select_Metrics
FT_Select_Metrics(FT_Face face, FT_ULong strike_index)
Definition: ftobjs.c:2590
TT_ADOBE_ID_STANDARD
#define TT_ADOBE_ID_STANDARD
Definition: ttnameid.h:309
FT_MEM_ZERO
#define FT_MEM_ZERO(dest, count)
Definition: ftmemory.h:208
FT_ModuleRec_
Definition: ftobjs.h:439
BDF_FaceRec_::default_glyph
FT_UInt default_glyph
Definition: bdfdrivr.h:66
FT_FACE_FLAG_FAST_GLYPHS
#define FT_FACE_FLAG_FAST_GLYPHS
Definition: freetype.h:1076
NULL
#define NULL
Definition: ftobjs.h:61
FT_Int
signed int FT_Int
Definition: fttypes.h:216
BDF_FaceRec_
Definition: bdfdrivr.h:52
FT_Bitmap_::rows
int rows
Definition: ftimage.h:312
FT_REQUEST_HEIGHT
#define FT_REQUEST_HEIGHT(req)
Definition: ftobjs.h:587
BDF_Size_Request
BDF_Size_Request(FT_Size size, FT_Size_Request req)
Definition: bdfdrivr.c:616
stream
GLuint GLuint stream
Definition: glew.h:6573
n
GLclampd n
Definition: glew.h:7287
bdf_font_t_
Definition: bdf.h:192
FT_Bitmap_Size_::height
FT_Short height
Definition: freetype.h:296
bdf_property_t_::format
int format
Definition: bdf.h:112
bdf_service_bdf
static const FT_Service_BDFRec bdf_service_bdf
Definition: bdfdrivr.c:805
bdf_font_t_::font_ascent
long font_ascent
Definition: bdf.h:207
BDF_CARDINAL
#define BDF_CARDINAL
Definition: bdf.h:104
BDF_INTEGER
#define BDF_INTEGER
Definition: bdf.h:103
BDF_PropertyRec_::u
union BDF_PropertyRec_::@18 u
FT_FaceRec_::style_name
FT_String * style_name
Definition: freetype.h:923
FT_CharMapRec_::platform_id
FT_UShort platform_id
Definition: freetype.h:740
FT_FaceRec_::available_sizes
FT_Bitmap_Size * available_sizes
Definition: freetype.h:926
FT_Driver_ClassRec_
Definition: ftdriver.h:182
height
EGLSurface EGLint EGLint EGLint EGLint height
Definition: eglext.h:293
FT_FACE_FLAG_FIXED_SIZES
#define FT_FACE_FLAG_FIXED_SIZES
Definition: freetype.h:1070
FT_SizeRec
struct FT_SizeRec_ FT_SizeRec
bdf_free_font
bdf_free_font(bdf_font_t *font)
Definition: bdflib.c:2517
FT_Bitmap_::pitch
int pitch
Definition: ftimage.h:314
name
EGLImageKHR EGLint * name
Definition: eglext.h:284
bdf_driver_requester
bdf_driver_requester(FT_Module module, const char *name)
Definition: bdfdrivr.c:827
BDF_PropertyRec_
Definition: ftbdf.h:117
FT_XF86_FORMAT_BDF
#define FT_XF86_FORMAT_BDF
Definition: svxf86nm.h:38
BDF_Face_Done
BDF_Face_Done(FT_Face bdfface)
Definition: bdfdrivr.c:312
FT_SERVICE_ID_BDF
#define FT_SERVICE_ID_BDF
Definition: svbdf.h:29
FT_PIXEL_MODE_GRAY
Definition: ftimage.h:176
TT_PLATFORM_MICROSOFT
#define TT_PLATFORM_MICROSOFT
Definition: ttnameid.h:89
len
GLenum GLsizei len
Definition: glew.h:7035
lengths
GLsizei const GLchar const GLint * lengths
Definition: glew.h:1830
bdf_get_font_property
bdf_get_font_property(bdf_font_t *font, const char *name)
Definition: bdflib.c:2598
BDF_Size_Select
BDF_Size_Select(FT_Size size, FT_ULong strike_index)
Definition: bdfdrivr.c:599
BDF_ATOM
#define BDF_ATOM
Definition: bdf.h:102
bdf_cmap_init
bdf_cmap_init(FT_CMap bdfcmap, FT_Pointer init_data)
Definition: bdfdrivr.c:64
bdf_glyph_t_::bbx
bdf_bbx_t bbx
Definition: bdf.h:152
if
if(!yyg->yy_init)
Definition: glslang_lex.cpp:1037
FT_CharMapRec_::encoding_id
FT_UShort encoding_id
Definition: freetype.h:741
FT_Bool
FT_BEGIN_HEADER typedef unsigned char FT_Bool
Definition: fttypes.h:104
FT_CharMapRec_::face
FT_Face face
Definition: freetype.h:738
FT_TRACE1
#define FT_TRACE1(varformat)
Definition: ftdebug.h:158
bdf_property_t_
Definition: bdf.h:109
FT_ASSERT
#define FT_ASSERT(condition)
Definition: ftdebug.h:204
FT_STYLE_FLAG_BOLD
#define FT_STYLE_FLAG_BOLD
Definition: freetype.h:1290
bdf_services
static const FT_ServiceDescRec bdf_services[]
Definition: bdfdrivr.c:818
FT_Bitmap_Size_::size
FT_Pos size
Definition: freetype.h:299
params
GLenum GLvoid ** params
Definition: gl2ext.h:806
bdf_cmap_char_index
bdf_cmap_char_index(FT_CMap bdfcmap, FT_UInt32 charcode)
Definition: bdfdrivr.c:91
FT_TRACE4
#define FT_TRACE4(varformat)
Definition: ftdebug.h:161
BDF_CMap
struct BDF_CMapRec_ * BDF_CMap
BDF_PropertyRec_::integer
FT_Int32 integer
Definition: ftbdf.h:122
bdf_options_t_::correct_metrics
int correct_metrics
Definition: bdf.h:79
encodings
static struct @83 encodings[]
bdf_get_bdf_property
static FT_Error bdf_get_bdf_property(BDF_Face face, const char *prop_name, BDF_PropertyRec *aproperty)
Definition: bdfdrivr.c:743
bdf_glyph_t_::dwidth
unsigned short dwidth
Definition: bdf.h:151
bdf_glyph_t_
Definition: bdf.h:146
bdf_property_t_::ul
unsigned long ul
Definition: bdf.h:118
BDF_Face
struct BDF_FaceRec_ * BDF_Face
bdf_font_t_::bpp
unsigned short bpp
Definition: bdf.h:235
FT_FREE
#define FT_FREE(ptr)
Definition: ftmemory.h:286
result
GLuint64EXT * result
Definition: glew.h:12708
FT_FACE_FLAG_FIXED_WIDTH
#define FT_FACE_FLAG_FIXED_WIDTH
Definition: freetype.h:1071
bdf.h
bdf_font_t_::default_char
long default_char
Definition: bdf.h:205
bdf_font_t_::glyphs_size
unsigned long glyphs_size
Definition: bdf.h:210
FT_FaceRec_
Definition: freetype.h:912
int
int
Definition: SDL_systhread.c:37
FT_PIXEL_MODE_GRAY2
Definition: ftimage.h:177
error
FT_Error error
Definition: cffdrivr.c:407
cmap
Colormap cmap
Definition: glewinfo_tail.c:225
FT_SERVICE_ID_XF86_NAME
#define FT_SERVICE_ID_XF86_NAME
Definition: svxf86nm.h:34
FT_Bitmap_
Definition: ftimage.h:310
FT_Pointer
void * FT_Pointer
Definition: fttypes.h:307
bdf_bbx_t_::x_offset
short x_offset
Definition: bdf.h:137
FT_CMapRec_
Definition: ftobjs.h:131
face
GLenum face
Definition: gl2ext.h:1490
FT_FACE_FLAG_HORIZONTAL
#define FT_FACE_FLAG_HORIZONTAL
Definition: freetype.h:1073
FT_Size_RequestRec_
Definition: freetype.h:2185
bdf_font_t_::font_descent
long font_descent
Definition: bdf.h:208
bdf_property_t_::l
long l
Definition: bdf.h:117
bdf_glyph_t_::bpr
unsigned long bpr
Definition: bdf.h:154
bdf_options_t_::keep_unencoded
int keep_unencoded
Definition: bdf.h:80
BDF_PropertyRec_::atom
const char * atom
Definition: ftbdf.h:121
FT_Module_Interface
FT_Pointer FT_Module_Interface
Definition: ftmodapi.h:79
bdf_property_t_::atom
char * atom
Definition: bdf.h:116
FT_TRACE2
#define FT_TRACE2(varformat)
Definition: ftdebug.h:159
bdfdrivr.h
strings
GLsizei const GLchar ** strings
Definition: gl2ext.h:1205
FT_Bitmap_::num_grays
short num_grays
Definition: ftimage.h:316
TT_PLATFORM_ADOBE
#define TT_PLATFORM_ADOBE
Definition: ttnameid.h:91
FT_PIXEL_MODE_GRAY4
Definition: ftimage.h:178
FT_BDF_GetPropertyFunc
FT_Error(* FT_BDF_GetPropertyFunc)(FT_Face face, const char *prop_name, BDF_PropertyRec *aproperty)
Definition: svbdf.h:37
bdf_cmap_done
bdf_cmap_done(FT_CMap bdfcmap)
Definition: bdfdrivr.c:80
FT_CharMapRec_::encoding
FT_Encoding encoding
Definition: freetype.h:739
bdf_font_t_::unencoded_used
unsigned long unencoded_used
Definition: bdf.h:215
FT_CALLBACK_DEF
#define FT_CALLBACK_DEF(x)
Definition: ftconfig.h:554
bdf_interpret_style
static FT_Error bdf_interpret_style(BDF_Face bdf)
Definition: bdfdrivr.c:199
FT_Bitmap_Size_
Definition: freetype.h:294
FT_MODULE_FONT_DRIVER
#define FT_MODULE_FONT_DRIVER
Definition: ftmodapi.h:55
BDF_PROPERTY_TYPE_INTEGER
Definition: ftbdf.h:78
BDF_PropertyRec_::type
BDF_PropertyType type
Definition: ftbdf.h:119
FT_Short
signed short FT_Short
Definition: fttypes.h:194
FT_Memory
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
FT_Bitmap_::width
int width
Definition: ftimage.h:313
BDF_FaceRec_::charset_registry
char * charset_registry
Definition: bdfdrivr.h:57
bdf_cmap_class
FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec bdf_cmap_class
Definition: bdfdrivr.c:186
BDF_FaceRec_::bdffont
bdf_font_t * bdffont
Definition: bdfdrivr.h:59
code
Definition: inftrees.h:24
FT_ServiceDescRec_
Definition: ftserv.h:157
FT_NEW_ARRAY
#define FT_NEW_ARRAY(ptr, count)
Definition: ftmemory.h:290
FT_STREAM_SEEK
#define FT_STREAM_SEEK(position)
Definition: ftstream.h:496
FT_FACE_MEMORY
#define FT_FACE_MEMORY(x)
Definition: ftobjs.h:529
FT_CMap_New
FT_CMap_New(FT_CMap_Class clazz, FT_Pointer init_data, FT_CharMap charmap, FT_CMap *acmap)
Definition: ftobjs.c:3236
bdf_load_font
bdf_load_font(FT_Stream stream, FT_Memory memory, bdf_options_t *opts, bdf_font_t **font)
Definition: bdflib.c:2359
const
#define const
Definition: zconf.h:91
ft2build.h
BDF_PROPORTIONAL
#define BDF_PROPORTIONAL
Definition: bdf.h:63
FT_CharMapRec_
Definition: freetype.h:736
FT_FACE
#define FT_FACE(x)
Definition: ftobjs.h:523
FT_FaceRec_::num_glyphs
FT_Long num_glyphs
Definition: freetype.h:920
bdf_options_t_
Definition: bdf.h:77
FT_SIZE_REQUEST_TYPE_REAL_DIM
Definition: freetype.h:2148
FT_UInt
unsigned int FT_UInt
Definition: fttypes.h:227
bdf_bbx_t_::height
unsigned short height
Definition: bdf.h:135
FT_SIZE_FACE
#define FT_SIZE_FACE(x)
Definition: ftobjs.h:532
bdf_bbx_t_::ascent
short ascent
Definition: bdf.h:140
FT_Bitmap_::pixel_mode
char pixel_mode
Definition: ftimage.h:317
FT_FaceRec_::style_flags
FT_Long style_flags
Definition: freetype.h:918
bdf_font_t_::glyphs
bdf_glyph_t * glyphs
Definition: bdf.h:212
TT_PLATFORM_APPLE_UNICODE
#define TT_PLATFORM_APPLE_UNICODE
Definition: ttnameid.h:86
bitmap
GLsizei GLfixed GLfixed GLfixed GLfixed const GLubyte * bitmap
Definition: glext.h:4510
BDF_CMapRec
struct BDF_CMapRec_ BDF_CMapRec
bdf_bbx_t_::width
unsigned short width
Definition: bdf.h:134
FT_Bitmap_Size_::y_ppem
FT_Pos y_ppem
Definition: freetype.h:302
BDF_Face_Init
BDF_Face_Init(FT_Stream stream, FT_Face bdfface, FT_Int face_index, FT_Int num_params, FT_Parameter *params)
Definition: bdfdrivr.c:339
TT_MS_ID_UNICODE_CS
#define TT_MS_ID_UNICODE_CS
Definition: ttnameid.h:280
FT_MODULE_DRIVER_NO_OUTLINES
#define FT_MODULE_DRIVER_NO_OUTLINES
Definition: ftmodapi.h:62
min
#define min(x, y)
Definition: os.h:75
FT_SIZE_REQUEST_TYPE_NOMINAL
Definition: freetype.h:2147
src
GLenum src
Definition: glew.h:2396
FT_STRDUP
#define FT_STRDUP(dst, str)
Definition: ftmemory.h:351
BDF_PROPERTY_TYPE_ATOM
Definition: ftbdf.h:77
bdf_font_t_::glyphs_used
unsigned long glyphs_used
Definition: bdf.h:211
FT_DriverRec
struct FT_DriverRec_ FT_DriverRec
bdf_options_t_::font_spacing
int font_spacing
Definition: bdf.h:82
FT_CMap_ClassRec_
Definition: ftobjs.h:190
max
#define max(x, y)
Definition: os.h:79
FT_STYLE_FLAG_ITALIC
#define FT_STYLE_FLAG_ITALIC
Definition: freetype.h:1289
FT_UShort
unsigned short FT_UShort
Definition: fttypes.h:205
FT_StreamRec_
Definition: ftsystem.h:321
ft_memcpy
#define ft_memcpy
Definition: ftstdlib.h:81
FT_UNUSED
#define FT_UNUSED(arg)
Definition: ftconfig.h:101
bdf_cmap_char_next
bdf_cmap_char_next(FT_CMap bdfcmap, FT_UInt32 *acharcode)
Definition: bdfdrivr.c:130
FT_BDF_GetCharsetIdFunc
FT_Error(* FT_BDF_GetCharsetIdFunc)(FT_Face face, const char **acharset_encoding, const char **acharset_registry)
Definition: svbdf.h:32
bdf_glyph_t_::bitmap
unsigned char * bitmap
Definition: bdf.h:153
ft_strlen
#define ft_strlen
Definition: ftstdlib.h:87
TT_APPLE_ID_DEFAULT
#define TT_APPLE_ID_DEFAULT
Definition: ttnameid.h:124
FT_CALLBACK_TABLE_DEF
#define FT_CALLBACK_TABLE_DEF
Definition: ftconfig.h:564
FT_FaceRec_::memory
FT_Memory memory
Definition: freetype.h:956
FT_Parameter_
Definition: freetype.h:1763
BDF_FaceRec_::en_table
BDF_encoding_el * en_table
Definition: bdfdrivr.h:61
ft_strcmp
#define ft_strcmp
Definition: ftstdlib.h:85
bdf_font_t_::bbx
bdf_bbx_t bbx
Definition: bdf.h:195
bdf_options_t_::keep_comments
int keep_comments
Definition: bdf.h:81
BDF_PropertyRec_::cardinal
FT_UInt32 cardinal
Definition: ftbdf.h:123
size
GLsizei size
Definition: gl2ext.h:1467
FT_PIXEL_MODE_MONO
Definition: ftimage.h:175