ReactOS 0.4.15-dev-8222-g9164419
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 690 of file cidload.c.

692 {
693 CID_Loader loader;
695 FT_Memory memory = face->root.memory;
697 FT_Int n;
698
699 CID_FaceInfo cid = &face->cid;
700
701 FT_ULong binary_length;
702 FT_ULong entry_len;
703
704
705 cid_init_loader( &loader, face );
706
707 parser = &loader.parser;
708 error = cid_parser_new( parser, face->root.stream, face->root.memory,
709 (PSAux_Service)face->psaux );
710 if ( error )
711 goto Exit;
712
713 error = cid_parse_dict( face, &loader,
714 parser->postscript,
715 parser->postscript_len );
716 if ( error )
717 goto Exit;
718
719 if ( face_index < 0 )
720 goto Exit;
721
722 if ( FT_NEW( face->cid_stream ) )
723 goto Exit;
724
725 if ( parser->binary_length )
726 {
727 if ( parser->binary_length >
728 face->root.stream->size - parser->data_offset )
729 {
730 FT_TRACE0(( "cid_face_open: adjusting length of binary data\n"
731 " (from %d to %d bytes)\n",
732 parser->binary_length,
733 face->root.stream->size - parser->data_offset ));
734 parser->binary_length = face->root.stream->size -
735 parser->data_offset;
736 }
737
738 /* we must convert the data section from hexadecimal to binary */
739 if ( FT_ALLOC( face->binary_data, parser->binary_length ) ||
740 FT_SET_ERROR( cid_hex_to_binary( face->binary_data,
741 parser->binary_length,
742 parser->data_offset,
743 face ) ) )
744 goto Exit;
745
746 FT_Stream_OpenMemory( face->cid_stream,
747 face->binary_data, parser->binary_length );
748 cid->data_offset = 0;
749 }
750 else
751 {
752 *face->cid_stream = *face->root.stream;
753 cid->data_offset = loader.parser.data_offset;
754 }
755
756 /* sanity tests */
757
758 if ( cid->fd_bytes < 0 || cid->gd_bytes < 1 )
759 {
760 FT_ERROR(( "cid_parse_dict:"
761 " Invalid `FDBytes' or `GDBytes' value\n" ));
762 error = FT_THROW( Invalid_File_Format );
763 goto Exit;
764 }
765
766 /* allow at most 32bit offsets */
767 if ( cid->fd_bytes > 4 || cid->gd_bytes > 4 )
768 {
769 FT_ERROR(( "cid_parse_dict:"
770 " Values of `FDBytes' or `GDBytes' larger than 4\n"
771 " "
772 " are not supported\n" ));
773 error = FT_THROW( Invalid_File_Format );
774 goto Exit;
775 }
776
777 binary_length = face->cid_stream->size - cid->data_offset;
778 entry_len = (FT_ULong)( cid->fd_bytes + cid->gd_bytes );
779
780 for ( n = 0; n < cid->num_dicts; n++ )
781 {
782 CID_FaceDict dict = cid->font_dicts + n;
783
784
785 if ( dict->sd_bytes < 0 ||
786 ( dict->num_subrs && dict->sd_bytes < 1 ) )
787 {
788 FT_ERROR(( "cid_parse_dict: Invalid `SDBytes' value\n" ));
789 error = FT_THROW( Invalid_File_Format );
790 goto Exit;
791 }
792
793 if ( dict->sd_bytes > 4 )
794 {
795 FT_ERROR(( "cid_parse_dict:"
796 " Values of `SDBytes' larger than 4"
797 " are not supported\n" ));
798 error = FT_THROW( Invalid_File_Format );
799 goto Exit;
800 }
801
802 if ( dict->subrmap_offset > binary_length )
803 {
804 FT_ERROR(( "cid_parse_dict: Invalid `SubrMapOffset' value\n" ));
805 error = FT_THROW( Invalid_File_Format );
806 goto Exit;
807 }
808
809 /* `num_subrs' is scanned as a signed integer */
810 if ( (FT_Int)dict->num_subrs < 0 ||
811 ( dict->sd_bytes &&
812 dict->num_subrs > ( binary_length - dict->subrmap_offset ) /
813 (FT_UInt)dict->sd_bytes ) )
814 {
815 FT_ERROR(( "cid_parse_dict: Invalid `SubrCount' value\n" ));
816 error = FT_THROW( Invalid_File_Format );
817 goto Exit;
818 }
819 }
820
821 if ( cid->cidmap_offset > binary_length )
822 {
823 FT_ERROR(( "cid_parse_dict: Invalid `CIDMapOffset' value\n" ));
824 error = FT_THROW( Invalid_File_Format );
825 goto Exit;
826 }
827
828 if ( entry_len &&
829 cid->cid_count >
830 ( binary_length - cid->cidmap_offset ) / entry_len )
831 {
832 FT_ERROR(( "cid_parse_dict: Invalid `CIDCount' value\n" ));
833 error = FT_THROW( Invalid_File_Format );
834 goto Exit;
835 }
836
837 /* we can now safely proceed */
839
840 Exit:
841 cid_done_loader( &loader );
842 return error;
843 }
static FT_Error cid_read_subrs(CID_Face face)
Definition: cidload.c:438
static void cid_init_loader(CID_Loader *loader, CID_Face face)
Definition: cidload.c:571
static void cid_done_loader(CID_Loader *loader)
Definition: cidload.c:581
static FT_Error cid_hex_to_binary(FT_Byte *data, FT_ULong data_len, FT_ULong offset, CID_Face face)
Definition: cidload.c:592
static FT_Error cid_parse_dict(CID_Face face, CID_Loader *loader, FT_Byte *base, FT_ULong size)
Definition: cidload.c:320
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:157
#define FT_ERROR(varformat)
Definition: ftdebug.h:181
#define FT_THROW(e)
Definition: ftdebug.h:213
#define FT_NEW(ptr)
Definition: ftmemory.h:331
#define FT_SET_ERROR(expression)
Definition: ftmemory.h:42
#define FT_ALLOC(ptr, size)
Definition: ftmemory.h:303
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:66
unsigned long FT_ULong
Definition: fttypes.h:253
int FT_Error
Definition: fttypes.h:300
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:356
FT_UInt num_subrs
Definition: t1tables.h:355
FT_Int sd_bytes
Definition: t1tables.h:357
Definition: import.c:81

Referenced by cid_face_init().

◆ cid_get_offset()

cid_get_offset ( FT_Byte **  start,
FT_Byte  offsize 
)

Definition at line 42 of file cidload.c.

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

Referenced by cid_load_glyph(), and cid_read_subrs().