ReactOS 0.4.16-dev-2358-g0df3463
ttcmap.h File Reference
Include dependency graph for ttcmap.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  TT_CMapRec_
 
struct  TT_CMap_ClassRec_
 
struct  TT_ValidatorRec_
 

Macros

#define TT_CMAP_FLAG_UNSORTED   1
 
#define TT_CMAP_FLAG_OVERLAPPING   2
 
#define FT_DEFINE_TT_CMAP(class_, size_, init_, done_, char_index_, char_next_, char_var_index_, char_var_default_, variant_list_, charvariant_list_, variantchar_list_, format_, validate_, get_cmap_info_)
 
#define TTCMAPCITEM(a)   FT_CALLBACK_TABLE const TT_CMap_ClassRec a;
 
#define TT_VALIDATOR(x)   ( (TT_Validator)( x ) )
 
#define TT_VALID_GLYPH_COUNT(x)   TT_VALIDATOR( x )->num_glyphs
 

Typedefs

typedef struct TT_CMapRec_ TT_CMapRec
 
typedef struct TT_CMapRec_TT_CMap
 
typedef const struct TT_CMap_ClassRec_TT_CMap_Class
 
typedef FT_Error(* TT_CMap_ValidateFunc) (FT_Byte *data, FT_Validator valid)
 
typedef struct TT_CMap_ClassRec_ TT_CMap_ClassRec
 
typedef struct TT_ValidatorRec_ TT_ValidatorRec
 
typedef struct TT_ValidatorRec_TT_Validator
 

Functions

 tt_face_build_cmaps (TT_Face face)
 
 tt_get_cmap_info (FT_CharMap charmap, TT_CMapInfo *cmap_info)
 

Variables

FT_CALLBACK_TABLE const TT_CMap_ClassRec tt_cmap_unicode_class_rec
 

Macro Definition Documentation

◆ FT_DEFINE_TT_CMAP

#define FT_DEFINE_TT_CMAP (   class_,
  size_,
  init_,
  done_,
  char_index_,
  char_next_,
  char_var_index_,
  char_var_default_,
  variant_list_,
  charvariant_list_,
  variantchar_list_,
  format_,
  validate_,
  get_cmap_info_ 
)
Value:
FT_CALLBACK_TABLE_DEF \
const TT_CMap_ClassRec class_ = \
{ \
{ size_, \
init_, \
done_, \
char_index_, \
char_next_, \
char_var_index_, \
char_var_default_, \
variant_list_, \
charvariant_list_, \
variantchar_list_ \
}, \
\
format_, \
validate_, \
get_cmap_info_ \
};

Definition at line 58 of file ttcmap.h.

◆ TT_CMAP_FLAG_OVERLAPPING

#define TT_CMAP_FLAG_OVERLAPPING   2

Definition at line 31 of file ttcmap.h.

◆ TT_CMAP_FLAG_UNSORTED

#define TT_CMAP_FLAG_UNSORTED   1

Definition at line 30 of file ttcmap.h.

◆ TT_VALID_GLYPH_COUNT

#define TT_VALID_GLYPH_COUNT (   x)    TT_VALIDATOR( x )->num_glyphs

Definition at line 107 of file ttcmap.h.

◆ TT_VALIDATOR

#define TT_VALIDATOR (   x)    ( (TT_Validator)( x ) )

Definition at line 106 of file ttcmap.h.

◆ TTCMAPCITEM

#define TTCMAPCITEM (   a)    FT_CALLBACK_TABLE const TT_CMap_ClassRec a;

Definition at line 94 of file ttcmap.h.

Typedef Documentation

◆ TT_CMap

◆ TT_CMap_Class

Definition at line 41 of file ttcmap.h.

◆ TT_CMap_ClassRec

◆ TT_CMap_ValidateFunc

typedef FT_Error(* TT_CMap_ValidateFunc) (FT_Byte *data, FT_Validator valid)

Definition at line 44 of file ttcmap.h.

◆ TT_CMapRec

◆ TT_Validator

◆ TT_ValidatorRec

Function Documentation

◆ tt_face_build_cmaps()

tt_face_build_cmaps ( TT_Face  face)

Definition at line 3780 of file ttcmap.c.

3781 {
3782 FT_Byte* const table = face->cmap_table;
3783 FT_Byte* limit;
3784 FT_UInt volatile num_cmaps;
3785 FT_Byte* volatile p = table;
3787
3788 FT_UNUSED( library );
3789
3790
3791 if ( !p || face->cmap_size < 4 )
3792 return FT_THROW( Invalid_Table );
3793
3794 /* Version 1.8.3 of the OpenType specification contains the following */
3795 /* (https://docs.microsoft.com/en-us/typography/opentype/spec/cmap): */
3796 /* */
3797 /* The 'cmap' table version number remains at 0x0000 for fonts that */
3798 /* make use of the newer subtable formats. */
3799 /* */
3800 /* This essentially means that a version format test is useless. */
3801
3802 /* ignore format */
3803 p += 2;
3804
3805 num_cmaps = TT_NEXT_USHORT( p );
3806 FT_TRACE4(( "tt_face_build_cmaps: %d cmaps\n", num_cmaps ));
3807
3808 limit = table + face->cmap_size;
3809 for ( ; num_cmaps > 0 && p + 8 <= limit; num_cmaps-- )
3810 {
3811 FT_CharMapRec charmap;
3812 FT_UInt32 offset;
3813
3814
3815 charmap.platform_id = TT_NEXT_USHORT( p );
3816 charmap.encoding_id = TT_NEXT_USHORT( p );
3817 charmap.face = FT_FACE( face );
3818 charmap.encoding = FT_ENCODING_NONE; /* will be filled later */
3819 offset = TT_NEXT_ULONG( p );
3820
3821 if ( offset && offset <= face->cmap_size - 2 )
3822 {
3823 FT_Byte* volatile cmap = table + offset;
3824 volatile FT_UInt format = TT_PEEK_USHORT( cmap );
3825 const TT_CMap_Class* volatile pclazz = tt_cmap_classes;
3826 TT_CMap_Class volatile clazz;
3827
3828
3829 for ( ; *pclazz; pclazz++ )
3830 {
3831 clazz = *pclazz;
3832 if ( clazz->format == format )
3833 {
3834 volatile TT_ValidatorRec valid;
3835 volatile FT_Error error = FT_Err_Ok;
3836
3837
3840
3841 valid.num_glyphs = (FT_UInt)face->max_profile.numGlyphs;
3842
3843 if ( ft_setjmp( FT_VALIDATOR( &valid )->jump_buffer) == 0 )
3844 {
3845 /* validate this cmap sub-table */
3846 error = clazz->validate( cmap, FT_VALIDATOR( &valid ) );
3847 }
3848
3849 if ( !valid.validator.error )
3850 {
3851 FT_CMap ttcmap;
3852
3853
3854 /* It might make sense to store the single variation */
3855 /* selector cmap somewhere special. But it would have to be */
3856 /* in the public FT_FaceRec, and we can't change that. */
3857
3858 if ( !FT_CMap_New( (FT_CMap_Class)clazz,
3859 cmap, &charmap, &ttcmap ) )
3860 {
3861 /* it is simpler to directly set `flags' than adding */
3862 /* a parameter to FT_CMap_New */
3863 ((TT_CMap)ttcmap)->flags = (FT_Int)error;
3864 }
3865 }
3866 else
3867 {
3868 FT_TRACE0(( "tt_face_build_cmaps:"
3869 " broken cmap sub-table ignored\n" ));
3870 }
3871 break;
3872 }
3873 }
3874
3875 if ( !*pclazz )
3876 {
3877 FT_TRACE0(( "tt_face_build_cmaps:"
3878 " unsupported cmap sub-table ignored\n" ));
3879 }
3880 }
3881 }
3882
3883 return FT_Err_Ok;
3884 }
FT_Library library
Definition: cffdrivr.c:660
return FT_Err_Ok
Definition: ftbbox.c:526
#define FT_TRACE0(varformat)
Definition: ftdebug.h:187
#define FT_THROW(e)
Definition: ftdebug.h:243
#define FT_TRACE4(varformat)
Definition: ftdebug.h:191
#define FT_FACE_LIBRARY(x)
Definition: ftobjs.h:602
#define FT_FACE(x)
Definition: ftobjs.h:597
FT_CMap_New(FT_CMap_Class clazz, FT_Pointer init_data, FT_CharMap charmap, FT_CMap *acmap)
Definition: ftobjs.c:3677
#define ft_setjmp(b)
Definition: ftstdlib.h:163
unsigned char FT_Byte
Definition: fttypes.h:154
int FT_Error
Definition: fttypes.h:299
unsigned int FT_UInt
Definition: fttypes.h:231
signed int FT_Int
Definition: fttypes.h:220
@ FT_VALIDATE_DEFAULT
Definition: ftvalid.h:73
#define FT_VALIDATOR(x)
Definition: ftvalid.h:104
ft_validator_init(FT_Validator valid, const FT_Byte *base, const FT_Byte *limit, FT_ValidationLevel level)
Definition: ftobjs.c:133
BOOLEAN valid
GLintptr offset
Definition: glext.h:5920
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
GLint limit
Definition: glext.h:10326
GLfloat GLfloat p
Definition: glext.h:8902
if(dx< 0)
Definition: linetemp.h:194
#define error(str)
Definition: mkdosfs.c:1605
#define FT_UNUSED(arg)
FT_Face face
Definition: freetype.h:819
FT_Encoding encoding
Definition: freetype.h:820
FT_UShort platform_id
Definition: freetype.h:821
FT_UShort encoding_id
Definition: freetype.h:822
FT_UInt format
Definition: ttcmap.h:51
TT_CMap_ValidateFunc validate
Definition: ttcmap.h:52
Definition: format.c:58
#define TT_NEXT_USHORT
Definition: ttcmap.c:48
#define TT_NEXT_ULONG
Definition: ttcmap.c:51
#define TT_PEEK_USHORT
Definition: ttcmap.c:42
static const TT_CMap_Class tt_cmap_classes[]
Definition: ttcmap.c:3767
struct TT_CMapRec_ * TT_CMap

Referenced by sfnt_load_face().

◆ tt_get_cmap_info()

tt_get_cmap_info ( FT_CharMap  charmap,
TT_CMapInfo cmap_info 
)

Definition at line 3888 of file ttcmap.c.

3890 {
3891 FT_CMap cmap = (FT_CMap)charmap;
3892 TT_CMap_Class clazz = (TT_CMap_Class)cmap->clazz;
3893
3894 if ( clazz->get_cmap_info )
3895 return clazz->get_cmap_info( charmap, cmap_info );
3896 else
3897 return FT_THROW( Invalid_CharMap_Format );
3898 }
TT_CMapInfo * cmap_info
Definition: cffdrivr.c:655
struct FT_CMapRec_ * FT_CMap
Definition: ftobjs.h:143
FT_CMap_Class clazz
Definition: ftobjs.h:152
TT_CMap_Info_GetFunc get_cmap_info
Definition: ttcmap.h:53
const struct TT_CMap_ClassRec_ * TT_CMap_Class
Definition: ttcmap.h:41

Variable Documentation

◆ tt_cmap_unicode_class_rec

FT_CALLBACK_TABLE const TT_CMap_ClassRec tt_cmap_unicode_class_rec

Definition at line 110 of file ttcmap.h.

Referenced by sfnt_load_face().