ReactOS 0.4.16-dev-1067-ge98bba2
ttcmap.c File Reference
#include <ft2build.h>
#include "sferrors.h"
#include "ttload.h"
#include "ttcmap.h"
#include "ttpost.h"
#include "ttcmapc.h"
Include dependency graph for ttcmap.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define FT_COMPONENT   ttcmap
 
#define TT_PEEK_SHORT   FT_PEEK_SHORT
 
#define TT_PEEK_USHORT   FT_PEEK_USHORT
 
#define TT_PEEK_UINT24   FT_PEEK_UOFF3
 
#define TT_PEEK_LONG   FT_PEEK_LONG
 
#define TT_PEEK_ULONG   FT_PEEK_ULONG
 
#define TT_NEXT_SHORT   FT_NEXT_SHORT
 
#define TT_NEXT_USHORT   FT_NEXT_USHORT
 
#define TT_NEXT_UINT24   FT_NEXT_UOFF3
 
#define TT_NEXT_LONG   FT_NEXT_LONG
 
#define TT_NEXT_ULONG   FT_NEXT_ULONG
 
#define TTCMAPCITEM(a)   &a,
 

Functions

 tt_cmap_init (TT_CMap cmap, FT_Byte *table)
 
 tt_face_build_cmaps (TT_Face face)
 
 tt_get_cmap_info (FT_CharMap charmap, TT_CMapInfo *cmap_info)
 

Variables

static const TT_CMap_Class tt_cmap_classes []
 

Macro Definition Documentation

◆ FT_COMPONENT

#define FT_COMPONENT   ttcmap

Definition at line 39 of file ttcmap.c.

◆ TT_NEXT_LONG

#define TT_NEXT_LONG   FT_NEXT_LONG

Definition at line 51 of file ttcmap.c.

◆ TT_NEXT_SHORT

#define TT_NEXT_SHORT   FT_NEXT_SHORT

Definition at line 48 of file ttcmap.c.

◆ TT_NEXT_UINT24

#define TT_NEXT_UINT24   FT_NEXT_UOFF3

Definition at line 50 of file ttcmap.c.

◆ TT_NEXT_ULONG

#define TT_NEXT_ULONG   FT_NEXT_ULONG

Definition at line 52 of file ttcmap.c.

◆ TT_NEXT_USHORT

#define TT_NEXT_USHORT   FT_NEXT_USHORT

Definition at line 49 of file ttcmap.c.

◆ TT_PEEK_LONG

#define TT_PEEK_LONG   FT_PEEK_LONG

Definition at line 45 of file ttcmap.c.

◆ TT_PEEK_SHORT

#define TT_PEEK_SHORT   FT_PEEK_SHORT

Definition at line 42 of file ttcmap.c.

◆ TT_PEEK_UINT24

#define TT_PEEK_UINT24   FT_PEEK_UOFF3

Definition at line 44 of file ttcmap.c.

◆ TT_PEEK_ULONG

#define TT_PEEK_ULONG   FT_PEEK_ULONG

Definition at line 46 of file ttcmap.c.

◆ TT_PEEK_USHORT

#define TT_PEEK_USHORT   FT_PEEK_USHORT

Definition at line 43 of file ttcmap.c.

◆ TTCMAPCITEM

#define TTCMAPCITEM (   a)    &a,

Function Documentation

◆ tt_cmap_init()

tt_cmap_init ( TT_CMap  cmap,
FT_Byte table 
)

Definition at line 63 of file ttcmap.c.

65 {
66 cmap->data = table;
67 return FT_Err_Ok;
68 }
return FT_Err_Ok
Definition: ftbbox.c:527
FT_Byte * data
Definition: ttcmap.h:37

◆ tt_face_build_cmaps()

tt_face_build_cmaps ( TT_Face  face)

Definition at line 3768 of file ttcmap.c.

3769 {
3770 FT_Byte* table = face->cmap_table;
3771 FT_Byte* limit = table + face->cmap_size;
3772 FT_UInt volatile num_cmaps;
3773 FT_Byte* volatile p = table;
3775
3776 FT_UNUSED( library );
3777
3778
3779 if ( !p || p + 4 > limit )
3780 return FT_THROW( Invalid_Table );
3781
3782 /* only recognize format 0 */
3783 if ( TT_NEXT_USHORT( p ) != 0 )
3784 {
3785 FT_ERROR(( "tt_face_build_cmaps:"
3786 " unsupported `cmap' table format = %d\n",
3787 TT_PEEK_USHORT( p - 2 ) ));
3788 return FT_THROW( Invalid_Table );
3789 }
3790
3791 num_cmaps = TT_NEXT_USHORT( p );
3792
3793 for ( ; num_cmaps > 0 && p + 8 <= limit; num_cmaps-- )
3794 {
3795 FT_CharMapRec charmap;
3796 FT_UInt32 offset;
3797
3798
3799 charmap.platform_id = TT_NEXT_USHORT( p );
3800 charmap.encoding_id = TT_NEXT_USHORT( p );
3801 charmap.face = FT_FACE( face );
3802 charmap.encoding = FT_ENCODING_NONE; /* will be filled later */
3803 offset = TT_NEXT_ULONG( p );
3804
3805 if ( offset && offset <= face->cmap_size - 2 )
3806 {
3807 FT_Byte* volatile cmap = table + offset;
3808 volatile FT_UInt format = TT_PEEK_USHORT( cmap );
3809 const TT_CMap_Class* volatile pclazz = tt_cmap_classes;
3810 TT_CMap_Class volatile clazz;
3811
3812
3813 for ( ; *pclazz; pclazz++ )
3814 {
3815 clazz = *pclazz;
3816 if ( clazz->format == format )
3817 {
3818 volatile TT_ValidatorRec valid;
3819 volatile FT_Error error = FT_Err_Ok;
3820
3821
3824
3825 valid.num_glyphs = (FT_UInt)face->max_profile.numGlyphs;
3826
3827 if ( ft_setjmp( FT_VALIDATOR( &valid )->jump_buffer) == 0 )
3828 {
3829 /* validate this cmap sub-table */
3830 error = clazz->validate( cmap, FT_VALIDATOR( &valid ) );
3831 }
3832
3833 if ( !valid.validator.error )
3834 {
3835 FT_CMap ttcmap;
3836
3837
3838 /* It might make sense to store the single variation */
3839 /* selector cmap somewhere special. But it would have to be */
3840 /* in the public FT_FaceRec, and we can't change that. */
3841
3842 if ( !FT_CMap_New( (FT_CMap_Class)clazz,
3843 cmap, &charmap, &ttcmap ) )
3844 {
3845 /* it is simpler to directly set `flags' than adding */
3846 /* a parameter to FT_CMap_New */
3847 ((TT_CMap)ttcmap)->flags = (FT_Int)error;
3848 }
3849 }
3850 else
3851 {
3852 FT_TRACE0(( "tt_face_build_cmaps:"
3853 " broken cmap sub-table ignored\n" ));
3854 }
3855 break;
3856 }
3857 }
3858
3859 if ( !*pclazz )
3860 {
3861 FT_TRACE0(( "tt_face_build_cmaps:"
3862 " unsupported cmap sub-table ignored\n" ));
3863 }
3864 }
3865 }
3866
3867 return FT_Err_Ok;
3868 }
FT_Library library
Definition: cffdrivr.c:661
#define FT_UNUSED(arg)
Definition: ftconfig.h:100
#define FT_TRACE0(varformat)
Definition: ftdebug.h:185
#define FT_ERROR(varformat)
Definition: ftdebug.h:209
#define FT_THROW(e)
Definition: ftdebug.h:241
#define FT_FACE_LIBRARY(x)
Definition: ftobjs.h:604
#define FT_FACE(x)
Definition: ftobjs.h:599
FT_CMap_New(FT_CMap_Class clazz, FT_Pointer init_data, FT_CharMap charmap, FT_CMap *acmap)
Definition: ftobjs.c:3657
#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:72
#define FT_VALIDATOR(x)
Definition: ftvalid.h:103
ft_validator_init(FT_Validator valid, const FT_Byte *base, const FT_Byte *limit, FT_ValidationLevel level)
Definition: ftobjs.c:134
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
FT_Face face
Definition: freetype.h:835
FT_Encoding encoding
Definition: freetype.h:836
FT_UShort platform_id
Definition: freetype.h:837
FT_UShort encoding_id
Definition: freetype.h:838
FT_UInt format
Definition: ttcmap.h:52
TT_CMap_ValidateFunc validate
Definition: ttcmap.h:53
Definition: format.c:58
#define TT_NEXT_USHORT
Definition: ttcmap.c:49
#define TT_NEXT_ULONG
Definition: ttcmap.c:52
#define TT_PEEK_USHORT
Definition: ttcmap.c:43
static const TT_CMap_Class tt_cmap_classes[]
Definition: ttcmap.c:3756
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 3872 of file ttcmap.c.

3874 {
3875 FT_CMap cmap = (FT_CMap)charmap;
3876 TT_CMap_Class clazz = (TT_CMap_Class)cmap->clazz;
3877
3878 if ( clazz->get_cmap_info )
3879 return clazz->get_cmap_info( charmap, cmap_info );
3880 else
3881 return FT_THROW( Invalid_CharMap_Format );
3882 }
TT_CMapInfo * cmap_info
Definition: cffdrivr.c:656
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:54
const struct TT_CMap_ClassRec_ * TT_CMap_Class
Definition: ttcmap.h:42

Variable Documentation

◆ tt_cmap_classes

const TT_CMap_Class tt_cmap_classes[]
static
Initial value:
=
{
#define TTCMAPCITEM( a )
}
#define NULL
Definition: types.h:112

Definition at line 3756 of file ttcmap.c.

Referenced by tt_face_build_cmaps().