ReactOS 0.4.16-dev-1067-ge98bba2
cidload.h File Reference
#include <ft2build.h>
#include "cidparse.h"
Include dependency graph for cidload.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  CID_Loader_
 

Typedefs

typedef FT_BEGIN_HEADER struct CID_Loader_ CID_Loader
 

Functions

 cid_get_offset (FT_Byte **start, FT_Byte offsize)
 
 cid_face_open (CID_Face face, FT_Int face_index)
 

Typedef Documentation

◆ CID_Loader

Function Documentation

◆ cid_face_open()

cid_face_open ( CID_Face  face,
FT_Int  face_index 
)

Definition at line 766 of file cidload.c.

768 {
769 CID_Loader loader;
771 FT_Memory memory = face->root.memory;
773 FT_Int n;
774
775 CID_FaceInfo cid = &face->cid;
776
777 FT_ULong binary_length;
778 FT_ULong entry_len;
779
780
781 cid_init_loader( &loader, face );
782
783 parser = &loader.parser;
784 error = cid_parser_new( parser, face->root.stream, face->root.memory,
785 (PSAux_Service)face->psaux );
786 if ( error )
787 goto Exit;
788
789 error = cid_parse_dict( face, &loader,
790 parser->postscript,
791 parser->postscript_len );
792 if ( error )
793 goto Exit;
794
795 if ( face_index < 0 )
796 goto Exit;
797
798 if ( FT_NEW( face->cid_stream ) )
799 goto Exit;
800
801 if ( parser->binary_length )
802 {
803 if ( parser->binary_length >
804 face->root.stream->size - parser->data_offset )
805 {
806 FT_TRACE0(( "cid_face_open: adjusting length of binary data\n"
807 " (from %d to %d bytes)\n",
808 parser->binary_length,
809 face->root.stream->size - parser->data_offset ));
810 parser->binary_length = face->root.stream->size -
811 parser->data_offset;
812 }
813
814 /* we must convert the data section from hexadecimal to binary */
815 if ( FT_ALLOC( face->binary_data, parser->binary_length ) ||
816 FT_SET_ERROR( cid_hex_to_binary( face->binary_data,
817 parser->binary_length,
818 parser->data_offset,
819 face ) ) )
820 goto Exit;
821
822 FT_Stream_OpenMemory( face->cid_stream,
823 face->binary_data, parser->binary_length );
824 cid->data_offset = 0;
825 }
826 else
827 {
828 *face->cid_stream = *face->root.stream;
829 cid->data_offset = loader.parser.data_offset;
830 }
831
832 /* sanity tests */
833
834 if ( cid->fd_bytes < 0 || cid->gd_bytes < 1 )
835 {
836 FT_ERROR(( "cid_face_open:"
837 " Invalid `FDBytes' or `GDBytes' value\n" ));
838 error = FT_THROW( Invalid_File_Format );
839 goto Exit;
840 }
841
842 /* allow at most 32bit offsets */
843 if ( cid->fd_bytes > 4 || cid->gd_bytes > 4 )
844 {
845 FT_ERROR(( "cid_face_open:"
846 " Values of `FDBytes' or `GDBytes' larger than 4\n"
847 " "
848 " are not supported\n" ));
849 error = FT_THROW( Invalid_File_Format );
850 goto Exit;
851 }
852
853 binary_length = face->cid_stream->size - cid->data_offset;
854 entry_len = (FT_ULong)( cid->fd_bytes + cid->gd_bytes );
855
856 for ( n = 0; n < cid->num_dicts; n++ )
857 {
858 CID_FaceDict dict = cid->font_dicts + n;
859
860
861 /* the upper limits are ad-hoc values */
862 if ( dict->private_dict.blue_shift > 1000 ||
863 dict->private_dict.blue_shift < 0 )
864 {
865 FT_TRACE2(( "cid_face_open:"
866 " setting unlikely BlueShift value %d to default (7)\n",
867 dict->private_dict.blue_shift ));
868 dict->private_dict.blue_shift = 7;
869 }
870
871 if ( dict->private_dict.blue_fuzz > 1000 ||
872 dict->private_dict.blue_fuzz < 0 )
873 {
874 FT_TRACE2(( "cid_face_open:"
875 " setting unlikely BlueFuzz value %d to default (1)\n",
876 dict->private_dict.blue_fuzz ));
877 dict->private_dict.blue_fuzz = 1;
878 }
879
880 if ( dict->sd_bytes < 0 ||
881 ( dict->num_subrs && dict->sd_bytes < 1 ) )
882 {
883 FT_ERROR(( "cid_face_open: Invalid `SDBytes' value\n" ));
884 error = FT_THROW( Invalid_File_Format );
885 goto Exit;
886 }
887
888 if ( dict->sd_bytes > 4 )
889 {
890 FT_ERROR(( "cid_face_open:"
891 " Values of `SDBytes' larger than 4"
892 " are not supported\n" ));
893 error = FT_THROW( Invalid_File_Format );
894 goto Exit;
895 }
896
897 if ( dict->subrmap_offset > binary_length )
898 {
899 FT_ERROR(( "cid_face_open: Invalid `SubrMapOffset' value\n" ));
900 error = FT_THROW( Invalid_File_Format );
901 goto Exit;
902 }
903
904 /* `num_subrs' is scanned as a signed integer */
905 if ( (FT_Int)dict->num_subrs < 0 ||
906 ( dict->sd_bytes &&
907 dict->num_subrs > ( binary_length - dict->subrmap_offset ) /
908 (FT_UInt)dict->sd_bytes ) )
909 {
910 FT_ERROR(( "cid_face_open: Invalid `SubrCount' value\n" ));
911 error = FT_THROW( Invalid_File_Format );
912 goto Exit;
913 }
914 }
915
916 if ( cid->cidmap_offset > binary_length )
917 {
918 FT_ERROR(( "cid_face_open: Invalid `CIDMapOffset' value\n" ));
919 error = FT_THROW( Invalid_File_Format );
920 goto Exit;
921 }
922
923 if ( entry_len &&
924 cid->cid_count >
925 ( binary_length - cid->cidmap_offset ) / entry_len )
926 {
927 FT_ERROR(( "cid_face_open: Invalid `CIDCount' value\n" ));
928 error = FT_THROW( Invalid_File_Format );
929 goto Exit;
930 }
931
932 /* we can now safely proceed */
934
935 Exit:
936 cid_done_loader( &loader );
937 return error;
938 }
static FT_Error cid_read_subrs(CID_Face face)
Definition: cidload.c:514
static void cid_init_loader(CID_Loader *loader, CID_Face face)
Definition: cidload.c:647
static void cid_done_loader(CID_Loader *loader)
Definition: cidload.c:657
static FT_Error cid_hex_to_binary(FT_Byte *data, FT_ULong data_len, FT_ULong offset, CID_Face face)
Definition: cidload.c:668
static FT_Error cid_parse_dict(CID_Face face, CID_Loader *loader, FT_Byte *base, FT_ULong size)
Definition: cidload.c:387
FT_BEGIN_HEADER struct CID_Loader_ CID_Loader
cid_parser_new(CID_Parser *parser, FT_Stream stream, FT_Memory memory, PSAux_Service psaux)
Definition: cidparse.c:57
FT_BEGIN_HEADER struct CID_Parser_ CID_Parser
#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_TRACE2(varformat)
Definition: ftdebug.h:187
#define FT_NEW(ptr)
Definition: ftmemory.h:330
#define FT_SET_ERROR(expression)
Definition: ftmemory.h:42
#define FT_ALLOC(ptr, size)
Definition: ftmemory.h:302
FT_Stream_OpenMemory(FT_Stream stream, const FT_Byte *base, FT_ULong size)
Definition: ftstream.c:35
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:65
unsigned long FT_ULong
Definition: fttypes.h:253
int FT_Error
Definition: fttypes.h:299
unsigned int FT_UInt
Definition: fttypes.h:231
signed int FT_Int
Definition: fttypes.h:220
GLdouble n
Definition: glext.h:7729
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
#define error(str)
Definition: mkdosfs.c:1605
static char memory[1024 *256]
Definition: process.c:116
static TfClientId cid
static void Exit(void)
Definition: sock.c:1330
FT_ULong subrmap_offset
Definition: t1tables.h:363
FT_UInt num_subrs
Definition: t1tables.h:362
PS_PrivateRec private_dict
Definition: t1tables.h:350
FT_Int sd_bytes
Definition: t1tables.h:364
FT_Int blue_fuzz
Definition: t1tables.h:155
FT_Int blue_shift
Definition: t1tables.h:154
Definition: import.c:81

Referenced by cid_face_init().

◆ cid_get_offset()

cid_get_offset ( FT_Byte **  start,
FT_Byte  offsize 
)

Definition at line 43 of file cidload.c.

45 {
47 FT_Byte* p = *start;
48
49
50 for ( result = 0; offsize > 0; offsize-- )
51 {
52 result <<= 8;
53 result |= *p++;
54 }
55
56 *start = p;
57 return result;
58 }
unsigned char FT_Byte
Definition: fttypes.h:154
GLuint start
Definition: gl.h:1545
GLuint64EXT * result
Definition: glext.h:11304
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by cid_load_glyph(), and cid_read_subrs().