ReactOS 0.4.16-dev-981-g80eb313
sfdriver.c File Reference
#include <ft2build.h>
#include "sfdriver.h"
#include "ttload.h"
#include "sfobjs.h"
#include "sferrors.h"
#include "ttcmap.h"
#include "ttkern.h"
#include "ttmtx.h"
Include dependency graph for sfdriver.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define FT_COMPONENT   sfdriver
 
#define IS_WIN(n)
 
#define IS_APPLE(n)
 
#define PUT_EMBEDDED_BITMAPS(a)   NULL
 
#define PUT_COLOR_LAYERS(a)   NULL
 
#define PUT_PS_NAMES(a)   NULL
 

Typedefs

typedef int(* char_type_func) (int c)
 

Functions

static voidget_sfnt_table (TT_Face face, FT_Sfnt_Tag tag)
 
static FT_Error sfnt_table_info (TT_Face face, FT_UInt idx, FT_ULong *tag, FT_ULong *offset, FT_ULong *length)
 
 FT_DEFINE_SERVICE_SFNT_TABLEREC (sfnt_service_sfnt_table,(FT_SFNT_TableLoadFunc) tt_face_load_any,(FT_SFNT_TableGetFunc) get_sfnt_table,(FT_SFNT_TableInfoFunc) sfnt_table_info) static const unsigned char sfnt_ps_map[16]
 
static int sfnt_is_postscript (int c)
 
static charget_win_string (FT_Memory memory, FT_Stream stream, TT_Name entry, char_type_func char_type, FT_Bool report_invalid_characters)
 
static charget_apple_string (FT_Memory memory, FT_Stream stream, TT_Name entry, char_type_func char_type, FT_Bool report_invalid_characters)
 
static FT_Bool sfnt_get_name_id (TT_Face face, FT_UShort id, FT_Int *win, FT_Int *apple)
 
static const charsfnt_get_ps_name (TT_Face face)
 
 FT_DEFINE_SERVICE_PSFONTNAMEREC (sfnt_service_ps_name,(FT_PsName_GetFunc) sfnt_get_ps_name) FT_DEFINE_SERVICE_TTCMAPSREC(tt_service_get_cmap_info
 
TT_CMap_Info_GetFunc tt_get_cmap_info FT_DEFINE_SERVICEDESCREC3 (sfnt_services, FT_SERVICE_ID_SFNT_TABLE, &sfnt_service_sfnt_table, FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &sfnt_service_ps_name, FT_SERVICE_ID_TT_CMAP, &tt_service_get_cmap_info) sfnt_get_interface(FT_Module module
 
return ft_service_list_lookup (sfnt_services, module_interface)
 

Variables

TT_CMap_Info_GetFunc tt_get_cmap_info const charmodule_interface
 

Macro Definition Documentation

◆ FT_COMPONENT

#define FT_COMPONENT   sfdriver

Definition at line 71 of file sfdriver.c.

◆ IS_APPLE

#define IS_APPLE (   n)
Value:
( (n)->platformID == 1 && \
(n)->encodingID == 0 )
GLdouble n
Definition: glext.h:7729

Definition at line 471 of file sfdriver.c.

◆ IS_WIN

#define IS_WIN (   n)
Value:
( (n)->platformID == 3 && \
( (n)->encodingID == 1 || (n)->encodingID == 0 ) )

Definition at line 468 of file sfdriver.c.

◆ PUT_COLOR_LAYERS

#define PUT_COLOR_LAYERS (   a)    NULL

Definition at line 1200 of file sfdriver.c.

◆ PUT_EMBEDDED_BITMAPS

#define PUT_EMBEDDED_BITMAPS (   a)    NULL

Definition at line 1194 of file sfdriver.c.

◆ PUT_PS_NAMES

#define PUT_PS_NAMES (   a)    NULL

Definition at line 1206 of file sfdriver.c.

Typedef Documentation

◆ char_type_func

typedef int(* char_type_func) (int c)

Definition at line 464 of file sfdriver.c.

Function Documentation

◆ FT_DEFINE_SERVICE_PSFONTNAMEREC()

FT_DEFINE_SERVICE_PSFONTNAMEREC ( sfnt_service_ps_name  ,
(FT_PsName_GetFunc sfnt_get_ps_name 
)

◆ FT_DEFINE_SERVICE_SFNT_TABLEREC()

FT_DEFINE_SERVICE_SFNT_TABLEREC ( sfnt_service_sfnt_table  ,
(FT_SFNT_TableLoadFunc tt_face_load_any,
(FT_SFNT_TableGetFunc get_sfnt_table,
(FT_SFNT_TableInfoFunc sfnt_table_info 
) const

◆ FT_DEFINE_SERVICEDESCREC3()

TT_CMap_Info_GetFunc tt_get_cmap_info FT_DEFINE_SERVICEDESCREC3 ( sfnt_services  ,
FT_SERVICE_ID_SFNT_TABLE  ,
sfnt_service_sfnt_table,
FT_SERVICE_ID_POSTSCRIPT_FONT_NAME  ,
sfnt_service_ps_name,
FT_SERVICE_ID_TT_CMAP  ,
tt_service_get_cmap_info 
)

◆ ft_service_list_lookup()

return ft_service_list_lookup ( sfnt_services  ,
module_interface   
)

◆ get_apple_string()

static char * get_apple_string ( FT_Memory  memory,
FT_Stream  stream,
TT_Name  entry,
char_type_func  char_type,
FT_Bool  report_invalid_characters 
)
static

Definition at line 534 of file sfdriver.c.

539 {
541
542 char* result = NULL;
543 FT_String* r;
544 FT_Char* p;
545 FT_UInt len;
546
547 FT_UNUSED( error );
548
549
550 if ( FT_ALLOC( result, entry->stringLength + 1 ) )
551 return NULL;
552
553 if ( FT_STREAM_SEEK( entry->stringOffset ) ||
554 FT_FRAME_ENTER( entry->stringLength ) )
555 goto get_apple_string_error;
556
557 r = (FT_String*)result;
558 p = (FT_Char*)stream->cursor;
559
560 for ( len = entry->stringLength; len > 0; len--, p++ )
561 {
562 if ( char_type( *p ) )
563 *r++ = *p;
564 else
565 {
566 if ( report_invalid_characters )
567 FT_TRACE0(( "get_apple_string:"
568 " Character `%c' (0x%X) invalid in PS name string\n",
569 *p, *p ));
570 break;
571 }
572 }
573 if ( !len )
574 *r = '\0';
575
577
578 if ( !len )
579 return result;
580
581 get_apple_string_error:
582 FT_FREE( result );
583
584 entry->stringOffset = 0;
585 entry->stringLength = 0;
586 FT_FREE( entry->string );
587
588 return NULL;
589 }
#define NULL
Definition: types.h:112
return FT_Err_Ok
Definition: ftbbox.c:527
#define FT_UNUSED(arg)
Definition: ftconfig.h:100
#define FT_TRACE0(varformat)
Definition: ftdebug.h:185
#define FT_ALLOC(ptr, size)
Definition: ftmemory.h:302
#define FT_FREE(ptr)
Definition: ftmemory.h:328
#define FT_FRAME_ENTER(size)
Definition: ftstream.h:537
#define FT_STREAM_SEEK(position)
Definition: ftstream.h:514
#define FT_FRAME_EXIT()
Definition: ftstream.h:542
signed char FT_Char
Definition: fttypes.h:143
int FT_Error
Definition: fttypes.h:299
char FT_String
Definition: fttypes.h:187
unsigned int FT_UInt
Definition: fttypes.h:231
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLuint64EXT * result
Definition: glext.h:11304
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLsizei len
Definition: glext.h:6722
uint32_t entry
Definition: isohybrid.c:63
#define error(str)
Definition: mkdosfs.c:1605
#define for
Definition: utility.h:88
Definition: parse.h:23

Referenced by sfnt_get_ps_name().

◆ get_sfnt_table()

static void * get_sfnt_table ( TT_Face  face,
FT_Sfnt_Tag  tag 
)
static

Definition at line 80 of file sfdriver.c.

82 {
83 void* table;
84
85
86 switch ( tag )
87 {
88 case FT_SFNT_HEAD:
89 table = &face->header;
90 break;
91
92 case FT_SFNT_HHEA:
93 table = &face->horizontal;
94 break;
95
96 case FT_SFNT_VHEA:
97 table = face->vertical_info ? &face->vertical : NULL;
98 break;
99
100 case FT_SFNT_OS2:
101 table = ( face->os2.version == 0xFFFFU ) ? NULL : &face->os2;
102 break;
103
104 case FT_SFNT_POST:
105 table = &face->postscript;
106 break;
107
108 case FT_SFNT_MAXP:
109 table = &face->max_profile;
110 break;
111
112 case FT_SFNT_PCLT:
113 table = face->pclt.Version ? &face->pclt : NULL;
114 break;
115
116 default:
117 table = NULL;
118 }
119
120 return table;
121 }
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
Definition: ecma_167.h:138
@ FT_SFNT_HHEA
Definition: tttables.h:626
@ FT_SFNT_MAXP
Definition: tttables.h:624
@ FT_SFNT_HEAD
Definition: tttables.h:623
@ FT_SFNT_PCLT
Definition: tttables.h:629
@ FT_SFNT_POST
Definition: tttables.h:628
@ FT_SFNT_VHEA
Definition: tttables.h:627
@ FT_SFNT_OS2
Definition: tttables.h:625

◆ get_win_string()

static char * get_win_string ( FT_Memory  memory,
FT_Stream  stream,
TT_Name  entry,
char_type_func  char_type,
FT_Bool  report_invalid_characters 
)
static

Definition at line 475 of file sfdriver.c.

480 {
482
483 char* result = NULL;
484 FT_String* r;
485 FT_Char* p;
486 FT_UInt len;
487
488 FT_UNUSED( error );
489
490
491 if ( FT_ALLOC( result, entry->stringLength / 2 + 1 ) )
492 return NULL;
493
494 if ( FT_STREAM_SEEK( entry->stringOffset ) ||
495 FT_FRAME_ENTER( entry->stringLength ) )
496 goto get_win_string_error;
497
498 r = (FT_String*)result;
499 p = (FT_Char*)stream->cursor;
500
501 for ( len = entry->stringLength / 2; len > 0; len--, p += 2 )
502 {
503 if ( p[0] == 0 && char_type( p[1] ) )
504 *r++ = p[1];
505 else
506 {
507 if ( report_invalid_characters )
508 FT_TRACE0(( "get_win_string:"
509 " Character 0x%X invalid in PS name string\n",
510 ((unsigned)p[0])*256 + (unsigned)p[1] ));
511 break;
512 }
513 }
514 if ( !len )
515 *r = '\0';
516
518
519 if ( !len )
520 return result;
521
522 get_win_string_error:
523 FT_FREE( result );
524
525 entry->stringLength = 0;
526 entry->stringOffset = 0;
527 FT_FREE( entry->string );
528
529 return NULL;
530 }

Referenced by sfnt_get_ps_name().

◆ sfnt_get_name_id()

static FT_Bool sfnt_get_name_id ( TT_Face  face,
FT_UShort  id,
FT_Int win,
FT_Int apple 
)
static

Definition at line 593 of file sfdriver.c.

597 {
598 FT_Int n;
599
600
601 *win = -1;
602 *apple = -1;
603
604 for ( n = 0; n < face->num_names; n++ )
605 {
606 TT_Name name = face->name_table.names + n;
607
608
609 if ( name->nameID == id && name->stringLength > 0 )
610 {
611 if ( IS_WIN( name ) && ( name->languageID == 0x409 || *win == -1 ) )
612 *win = n;
613
614 if ( IS_APPLE( name ) && ( name->languageID == 0 || *apple == -1 ) )
615 *apple = n;
616 }
617 }
618
619 return ( *win >= 0 ) || ( *apple >= 0 );
620 }
signed int FT_Int
Definition: fttypes.h:220
static real win[4][36]
#define IS_WIN(n)
Definition: sfdriver.c:468
#define IS_APPLE(n)
Definition: sfdriver.c:471
Definition: name.c:39

Referenced by sfnt_get_ps_name().

◆ sfnt_get_ps_name()

static const char * sfnt_get_ps_name ( TT_Face  face)
static

Definition at line 1031 of file sfdriver.c.

1032 {
1033 FT_Int found, win, apple;
1034 const char* result = NULL;
1035
1036
1037 if ( face->postscript_name )
1038 return face->postscript_name;
1039
1040#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
1041 if ( face->blend &&
1043 FT_IS_VARIATION( FT_FACE( face ) ) ) )
1044 {
1045 face->postscript_name = sfnt_get_var_ps_name( face );
1046 return face->postscript_name;
1047 }
1048#endif
1049
1050 /* scan the name table to see whether we have a Postscript name here, */
1051 /* either in Macintosh or Windows platform encodings */
1052 found = sfnt_get_name_id( face, TT_NAME_ID_PS_NAME, &win, &apple );
1053 if ( !found )
1054 return NULL;
1055
1056 /* prefer Windows entries over Apple */
1057 if ( win != -1 )
1058 result = get_win_string( face->root.memory,
1059 face->name_table.stream,
1060 face->name_table.names + win,
1062 1 );
1063 if ( !result && apple != -1 )
1064 result = get_apple_string( face->root.memory,
1065 face->name_table.stream,
1066 face->name_table.names + apple,
1068 1 );
1069
1070 face->postscript_name = result;
1071
1072 return result;
1073 }
#define FT_IS_VARIATION(face)
Definition: freetype.h:1414
#define FT_IS_NAMED_INSTANCE(face)
Definition: freetype.h:1396
#define FT_FACE(x)
Definition: ftobjs.h:599
static char * get_win_string(FT_Memory memory, FT_Stream stream, TT_Name entry, char_type_func char_type, FT_Bool report_invalid_characters)
Definition: sfdriver.c:475
static char * get_apple_string(FT_Memory memory, FT_Stream stream, TT_Name entry, char_type_func char_type, FT_Bool report_invalid_characters)
Definition: sfdriver.c:534
static FT_Bool sfnt_get_name_id(TT_Face face, FT_UShort id, FT_Int *win, FT_Int *apple)
Definition: sfdriver.c:593
static int sfnt_is_postscript(int c)
Definition: sfdriver.c:249
#define TT_NAME_ID_PS_NAME
Definition: ttnameid.h:799

◆ sfnt_is_postscript()

static int sfnt_is_postscript ( int  c)
static

Definition at line 249 of file sfdriver.c.

250 {
251 unsigned int cc;
252
253
254 if ( c < 0 || c >= 0x80 )
255 return 0;
256
257 cc = (unsigned int)c;
258
259 return sfnt_ps_map[cc >> 3] & ( 1 << ( cc & 0x07 ) );
260 }
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
const GLubyte * c
Definition: glext.h:8905
uint32_t cc
Definition: isohybrid.c:75

Referenced by sfnt_get_ps_name().

◆ sfnt_table_info()

static FT_Error sfnt_table_info ( TT_Face  face,
FT_UInt  idx,
FT_ULong tag,
FT_ULong offset,
FT_ULong length 
)
static

Definition at line 125 of file sfdriver.c.

130 {
131 if ( !offset || !length )
132 return FT_THROW( Invalid_Argument );
133
134 if ( !tag )
135 *length = face->num_tables;
136 else
137 {
138 if ( idx >= face->num_tables )
139 return FT_THROW( Table_Missing );
140
141 *tag = face->dir_tables[idx].Tag;
142 *offset = face->dir_tables[idx].Offset;
143 *length = face->dir_tables[idx].Length;
144 }
145
146 return FT_Err_Ok;
147 }
unsigned int idx
Definition: utils.c:41
#define FT_THROW(e)
Definition: ftdebug.h:241
GLintptr offset
Definition: glext.h:5920
GLuint GLsizei GLsizei * length
Definition: glext.h:6040

Variable Documentation

◆ module_interface

Initial value:

Definition at line 1183 of file sfdriver.c.

Referenced by af_get_interface(), and cff_get_interface().