ReactOS 0.4.16-dev-2354-g16de117
ttcmap.c File Reference
#include <freetype/internal/ftdebug.h>
#include "sferrors.h"
#include <freetype/internal/ftvalid.h>
#include <freetype/internal/ftstream.h>
#include <freetype/internal/services/svpscmap.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 38 of file ttcmap.c.

◆ TT_NEXT_LONG

#define TT_NEXT_LONG   FT_NEXT_LONG

Definition at line 50 of file ttcmap.c.

◆ TT_NEXT_SHORT

#define TT_NEXT_SHORT   FT_NEXT_SHORT

Definition at line 47 of file ttcmap.c.

◆ TT_NEXT_UINT24

#define TT_NEXT_UINT24   FT_NEXT_UOFF3

Definition at line 49 of file ttcmap.c.

◆ TT_NEXT_ULONG

#define TT_NEXT_ULONG   FT_NEXT_ULONG

Definition at line 51 of file ttcmap.c.

◆ TT_NEXT_USHORT

#define TT_NEXT_USHORT   FT_NEXT_USHORT

Definition at line 48 of file ttcmap.c.

◆ TT_PEEK_LONG

#define TT_PEEK_LONG   FT_PEEK_LONG

Definition at line 44 of file ttcmap.c.

◆ TT_PEEK_SHORT

#define TT_PEEK_SHORT   FT_PEEK_SHORT

Definition at line 41 of file ttcmap.c.

◆ TT_PEEK_UINT24

#define TT_PEEK_UINT24   FT_PEEK_UOFF3

Definition at line 43 of file ttcmap.c.

◆ TT_PEEK_ULONG

#define TT_PEEK_ULONG   FT_PEEK_ULONG

Definition at line 45 of file ttcmap.c.

◆ TT_PEEK_USHORT

#define TT_PEEK_USHORT   FT_PEEK_USHORT

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

64 {
65 cmap->data = table;
66 return FT_Err_Ok;
67 }
return FT_Err_Ok
Definition: ftbbox.c:526
FT_Byte * data
Definition: ttcmap.h:36

◆ 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
#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_classes

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

Definition at line 3767 of file ttcmap.c.

Referenced by tt_face_build_cmaps().