ReactOS 0.4.15-dev-7942-gd23573b
sfdriver.c File Reference
#include <ft2build.h>
#include "sfdriver.h"
#include "ttload.h"
#include "sfobjs.h"
#include "sfntpic.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   trace_sfdriver
 
#define IS_WIN(n)
 
#define IS_APPLE(n)
 
#define PUT_EMBEDDED_BITMAPS(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_GET, FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &SFNT_SERVICE_PS_NAME_GET, FT_SERVICE_ID_TT_CMAP, &TT_SERVICE_CMAP_INFO_GET) sfnt_get_interface(FT_Module module
 
return ft_service_list_lookup (SFNT_SERVICES_GET, module_interface)
 

Variables

TT_CMap_Info_GetFunc tt_get_cmap_info const charmodule_interface
 

Macro Definition Documentation

◆ FT_COMPONENT

#define FT_COMPONENT   trace_sfdriver

Definition at line 67 of file sfdriver.c.

◆ IS_APPLE

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

Definition at line 468 of file sfdriver.c.

◆ IS_WIN

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

Definition at line 464 of file sfdriver.c.

◆ PUT_EMBEDDED_BITMAPS

#define PUT_EMBEDDED_BITMAPS (   a)    NULL

Definition at line 1198 of file sfdriver.c.

◆ PUT_PS_NAMES

#define PUT_PS_NAMES (   a)    NULL

Definition at line 1204 of file sfdriver.c.

Typedef Documentation

◆ char_type_func

typedef int(* char_type_func) (int c)

Definition at line 460 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_GET,
FT_SERVICE_ID_POSTSCRIPT_FONT_NAME  ,
SFNT_SERVICE_PS_NAME_GET,
FT_SERVICE_ID_TT_CMAP  ,
TT_SERVICE_CMAP_INFO_GET 
)

◆ ft_service_list_lookup()

return ft_service_list_lookup ( SFNT_SERVICES_GET  ,
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 {
556 FT_FREE( result );
557 entry->stringOffset = 0;
558 entry->stringLength = 0;
559 FT_FREE( entry->string );
560
561 return NULL;
562 }
563
564 r = (FT_String*)result;
565 p = (FT_Char*)stream->cursor;
566
567 for ( len = entry->stringLength; len > 0; len--, p++ )
568 {
569 if ( char_type( *p ) )
570 *r++ = *p;
571 else
572 {
573 if ( report_invalid_characters )
574 {
575 FT_TRACE0(( "get_apple_string:"
576 " Character `%c' (0x%X) invalid in PS name string\n",
577 *p, *p ));
578 /* it's not the job of FreeType to correct PS names... */
579 *r++ = *p;
580 }
581 }
582 }
583 *r = '\0';
584
586
587 return result;
588 }
#define NULL
Definition: types.h:112
return FT_Err_Ok
Definition: ftbbox.c:511
#define FT_UNUSED(arg)
Definition: ftconfig.h:101
#define FT_TRACE0(varformat)
Definition: ftdebug.h:157
#define FT_ALLOC(ptr, size)
Definition: ftmemory.h:303
#define FT_FREE(ptr)
Definition: ftmemory.h:329
#define FT_FRAME_ENTER(size)
Definition: ftstream.h:512
#define FT_STREAM_SEEK(position)
Definition: ftstream.h:489
#define FT_FRAME_EXIT()
Definition: ftstream.h:517
signed char FT_Char
Definition: fttypes.h:143
int FT_Error
Definition: fttypes.h:300
char FT_String
Definition: fttypes.h:187
unsigned int FT_UInt
Definition: fttypes.h:231
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLsizei len
Definition: glext.h:6722
GLuint64EXT * result
Definition: glext.h:11304
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 76 of file sfdriver.c.

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

◆ 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 473 of file sfdriver.c.

478 {
480
481 char* result = NULL;
482 FT_String* r;
483 FT_Char* p;
484 FT_UInt len;
485
486 FT_UNUSED( error );
487
488
489 if ( FT_ALLOC( result, entry->stringLength / 2 + 1 ) )
490 return NULL;
491
492 if ( FT_STREAM_SEEK( entry->stringOffset ) ||
493 FT_FRAME_ENTER( entry->stringLength ) )
494 {
495 FT_FREE( result );
496 entry->stringLength = 0;
497 entry->stringOffset = 0;
498 FT_FREE( entry->string );
499
500 return NULL;
501 }
502
503 r = (FT_String*)result;
504 p = (FT_Char*)stream->cursor;
505
506 for ( len = entry->stringLength / 2; len > 0; len--, p += 2 )
507 {
508 if ( p[0] == 0 )
509 {
510 if ( char_type( p[1] ) )
511 *r++ = p[1];
512 else
513 {
514 if ( report_invalid_characters )
515 {
516 FT_TRACE0(( "get_win_string:"
517 " Character `%c' (0x%X) invalid in PS name string\n",
518 p[1], p[1] ));
519 /* it's not the job of FreeType to correct PS names... */
520 *r++ = p[1];
521 }
522 }
523 }
524 }
525 *r = '\0';
526
528
529 return result;
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 592 of file sfdriver.c.

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

1024 {
1025 FT_Int found, win, apple;
1026 const char* result = NULL;
1027
1028
1029 if ( face->postscript_name )
1030 return face->postscript_name;
1031
1032#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
1033 if ( face->blend &&
1035 FT_IS_VARIATION( FT_FACE( face ) ) ) )
1036 {
1037 face->postscript_name = sfnt_get_var_ps_name( face );
1038 return face->postscript_name;
1039 }
1040#endif
1041
1042 /* scan the name table to see whether we have a Postscript name here, */
1043 /* either in Macintosh or Windows platform encodings */
1044 found = sfnt_get_name_id( face, TT_NAME_ID_PS_NAME, &win, &apple );
1045 if ( !found )
1046 return NULL;
1047
1048 /* prefer Windows entries over Apple */
1049 if ( win != -1 )
1050 result = get_win_string( face->root.memory,
1051 face->name_table.stream,
1052 face->name_table.names + win,
1054 1 );
1055 else
1056 result = get_apple_string( face->root.memory,
1057 face->name_table.stream,
1058 face->name_table.names + apple,
1060 1 );
1061
1062 face->postscript_name = result;
1063
1064 return result;
1065 }
#define FT_IS_VARIATION(face)
Definition: freetype.h:1442
#define FT_IS_NAMED_INSTANCE(face)
Definition: freetype.h:1424
#define FT_FACE(x)
Definition: ftobjs.h:630
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:473
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:592
static int sfnt_is_postscript(int c)
Definition: sfdriver.c:245
#define TT_NAME_ID_PS_NAME
Definition: ttnameid.h:799

◆ sfnt_is_postscript()

static int sfnt_is_postscript ( int  c)
static

Definition at line 245 of file sfdriver.c.

246 {
247 unsigned int cc;
248
249
250 if ( c < 0 || c >= 0x80 )
251 return 0;
252
253 cc = (unsigned int)c;
254
255 return sfnt_ps_map[cc >> 3] & ( 1 << ( cc & 0x07 ) );
256 }
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 121 of file sfdriver.c.

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

Variable Documentation

◆ module_interface

Initial value:

Definition at line 1175 of file sfdriver.c.

Referenced by af_get_interface(), and cff_get_interface().