ReactOS 0.4.16-dev-311-g9382aa2
ttcmap.c File Reference
#include <ft2build.h>
#include "sferrors.h"
#include "ttload.h"
#include "ttcmap.h"
#include "ttpost.h"
#include "sfntpic.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   trace_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   trace_ttcmap

Definition at line 40 of file ttcmap.c.

◆ TT_NEXT_LONG

#define TT_NEXT_LONG   FT_NEXT_LONG

Definition at line 52 of file ttcmap.c.

◆ TT_NEXT_SHORT

#define TT_NEXT_SHORT   FT_NEXT_SHORT

Definition at line 49 of file ttcmap.c.

◆ TT_NEXT_UINT24

#define TT_NEXT_UINT24   FT_NEXT_UOFF3

Definition at line 51 of file ttcmap.c.

◆ TT_NEXT_ULONG

#define TT_NEXT_ULONG   FT_NEXT_ULONG

Definition at line 53 of file ttcmap.c.

◆ TT_NEXT_USHORT

#define TT_NEXT_USHORT   FT_NEXT_USHORT

Definition at line 50 of file ttcmap.c.

◆ TT_PEEK_LONG

#define TT_PEEK_LONG   FT_PEEK_LONG

Definition at line 46 of file ttcmap.c.

◆ TT_PEEK_SHORT

#define TT_PEEK_SHORT   FT_PEEK_SHORT

Definition at line 43 of file ttcmap.c.

◆ TT_PEEK_UINT24

#define TT_PEEK_UINT24   FT_PEEK_UOFF3

Definition at line 45 of file ttcmap.c.

◆ TT_PEEK_ULONG

#define TT_PEEK_ULONG   FT_PEEK_ULONG

Definition at line 47 of file ttcmap.c.

◆ TT_PEEK_USHORT

#define TT_PEEK_USHORT   FT_PEEK_USHORT

Definition at line 44 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 64 of file ttcmap.c.

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

◆ tt_face_build_cmaps()

tt_face_build_cmaps ( TT_Face  face)

Definition at line 3814 of file ttcmap.c.

3815 {
3816 FT_Byte* table = face->cmap_table;
3817 FT_Byte* limit = table + face->cmap_size;
3818 FT_UInt volatile num_cmaps;
3819 FT_Byte* volatile p = table;
3821
3822 FT_UNUSED( library );
3823
3824
3825 if ( !p || p + 4 > limit )
3826 return FT_THROW( Invalid_Table );
3827
3828 /* only recognize format 0 */
3829 if ( TT_NEXT_USHORT( p ) != 0 )
3830 {
3831 FT_ERROR(( "tt_face_build_cmaps:"
3832 " unsupported `cmap' table format = %d\n",
3833 TT_PEEK_USHORT( p - 2 ) ));
3834 return FT_THROW( Invalid_Table );
3835 }
3836
3837 num_cmaps = TT_NEXT_USHORT( p );
3838
3839 for ( ; num_cmaps > 0 && p + 8 <= limit; num_cmaps-- )
3840 {
3841 FT_CharMapRec charmap;
3842 FT_UInt32 offset;
3843
3844
3845 charmap.platform_id = TT_NEXT_USHORT( p );
3846 charmap.encoding_id = TT_NEXT_USHORT( p );
3847 charmap.face = FT_FACE( face );
3848 charmap.encoding = FT_ENCODING_NONE; /* will be filled later */
3849 offset = TT_NEXT_ULONG( p );
3850
3851 if ( offset && offset <= face->cmap_size - 2 )
3852 {
3853 FT_Byte* volatile cmap = table + offset;
3854 volatile FT_UInt format = TT_PEEK_USHORT( cmap );
3855 const TT_CMap_Class* volatile pclazz = TT_CMAP_CLASSES_GET;
3856 TT_CMap_Class volatile clazz;
3857
3858
3859 for ( ; *pclazz; pclazz++ )
3860 {
3861 clazz = *pclazz;
3862 if ( clazz->format == format )
3863 {
3864 volatile TT_ValidatorRec valid;
3865 volatile FT_Error error = FT_Err_Ok;
3866
3867
3870
3871 valid.num_glyphs = (FT_UInt)face->max_profile.numGlyphs;
3872
3873 if ( ft_setjmp( FT_VALIDATOR( &valid )->jump_buffer) == 0 )
3874 {
3875 /* validate this cmap sub-table */
3876 error = clazz->validate( cmap, FT_VALIDATOR( &valid ) );
3877 }
3878
3879 if ( !valid.validator.error )
3880 {
3881 FT_CMap ttcmap;
3882
3883
3884 /* It might make sense to store the single variation */
3885 /* selector cmap somewhere special. But it would have to be */
3886 /* in the public FT_FaceRec, and we can't change that. */
3887
3888 if ( !FT_CMap_New( (FT_CMap_Class)clazz,
3889 cmap, &charmap, &ttcmap ) )
3890 {
3891 /* it is simpler to directly set `flags' than adding */
3892 /* a parameter to FT_CMap_New */
3893 ((TT_CMap)ttcmap)->flags = (FT_Int)error;
3894 }
3895 }
3896 else
3897 {
3898 FT_TRACE0(( "tt_face_build_cmaps:"
3899 " broken cmap sub-table ignored\n" ));
3900 }
3901 break;
3902 }
3903 }
3904
3905 if ( !*pclazz )
3906 {
3907 FT_TRACE0(( "tt_face_build_cmaps:"
3908 " unsupported cmap sub-table ignored\n" ));
3909 }
3910 }
3911 }
3912
3913 return FT_Err_Ok;
3914 }
FT_Library library
Definition: cffdrivr.c:654
#define FT_UNUSED(arg)
Definition: ftconfig.h:101
#define FT_TRACE0(varformat)
Definition: ftdebug.h:157
#define FT_ERROR(varformat)
Definition: ftdebug.h:181
#define FT_THROW(e)
Definition: ftdebug.h:213
#define FT_FACE_LIBRARY(x)
Definition: ftobjs.h:635
#define FT_FACE(x)
Definition: ftobjs.h:630
FT_CMap_New(FT_CMap_Class clazz, FT_Pointer init_data, FT_CharMap charmap, FT_CMap *acmap)
Definition: ftobjs.c:3614
#define ft_setjmp(b)
Definition: ftstdlib.h:163
unsigned char FT_Byte
Definition: fttypes.h:154
int FT_Error
Definition: fttypes.h:300
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:122
BOOLEAN valid
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
GLint limit
Definition: glext.h:10326
GLfloat GLfloat p
Definition: glext.h:8902
GLintptr offset
Definition: glext.h:5920
if(dx< 0)
Definition: linetemp.h:194
#define error(str)
Definition: mkdosfs.c:1605
#define TT_CMAP_CLASSES_GET
Definition: sfntpic.h:32
FT_Face face
Definition: freetype.h:842
FT_Encoding encoding
Definition: freetype.h:843
FT_UShort platform_id
Definition: freetype.h:844
FT_UShort encoding_id
Definition: freetype.h:845
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:50
#define TT_NEXT_ULONG
Definition: ttcmap.c:53
#define TT_PEEK_USHORT
Definition: ttcmap.c:44
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 3918 of file ttcmap.c.

3920 {
3921 FT_CMap cmap = (FT_CMap)charmap;
3922 TT_CMap_Class clazz = (TT_CMap_Class)cmap->clazz;
3923
3924 if ( clazz->get_cmap_info )
3925 return clazz->get_cmap_info( charmap, cmap_info );
3926 else
3927 return FT_THROW( Invalid_CharMap_Format );
3928 }
TT_CMapInfo * cmap_info
Definition: cffdrivr.c:649
struct FT_CMapRec_ * FT_CMap
Definition: ftobjs.h:145
FT_CMap_Class clazz
Definition: ftobjs.h:154
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 3747 of file ttcmap.c.