You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(92) |
Dec
(141) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(126) |
Feb
(72) |
Mar
(31) |
Apr
(200) |
May
(81) |
Jun
(130) |
Jul
(112) |
Aug
(134) |
Sep
(76) |
Oct
(89) |
Nov
(153) |
Dec
(9) |
2007 |
Jan
(59) |
Feb
(82) |
Mar
(50) |
Apr
(20) |
May
(9) |
Jun
(81) |
Jul
(41) |
Aug
(109) |
Sep
(91) |
Oct
(87) |
Nov
(33) |
Dec
(60) |
2008 |
Jan
(21) |
Feb
(15) |
Mar
(38) |
Apr
(75) |
May
(59) |
Jun
(46) |
Jul
(30) |
Aug
(20) |
Sep
(35) |
Oct
(32) |
Nov
(34) |
Dec
(19) |
2009 |
Jan
(29) |
Feb
(71) |
Mar
(54) |
Apr
(17) |
May
(4) |
Jun
|
Jul
(3) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(3) |
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(3) |
Aug
(58) |
Sep
(7) |
Oct
(7) |
Nov
(12) |
Dec
(18) |
2011 |
Jan
(17) |
Feb
(29) |
Mar
(11) |
Apr
(5) |
May
(1) |
Jun
|
Jul
|
Aug
(11) |
Sep
|
Oct
|
Nov
|
Dec
|
2012 |
Jan
(2) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(87) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(44) |
Jun
(79) |
Jul
(16) |
Aug
(31) |
Sep
|
Oct
(51) |
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
From: Ehud S. <esh...@us...> - 2006-04-21 16:31:20
|
Update of /cvsroot/roadmap/roadmap_editor/src/freetype/src/pcf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28321/src/pcf Added Files: Jamfile module.mk pcf.h pcfdrivr.h pcferror.h pcfread.h pcfutil.h rules.mk Log Message: Import freetype sources. --- NEW FILE: rules.mk --- # # FreeType 2 pcf driver configuration rules # # Copyright (C) 2000, 2001, 2003 by # Francesco Zappa Nardelli # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # pcf driver directory # PCF_DIR := $(SRC_DIR)/pcf PCF_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(PCF_DIR)) # pcf driver sources (i.e., C files) # PCF_DRV_SRC := $(PCF_DIR)/pcfread.c \ $(PCF_DIR)/pcfdrivr.c \ $(PCF_DIR)/pcfutil.c # pcf driver headers # PCF_DRV_H := $(PCF_DIR)/pcf.h \ $(PCF_DIR)/pcfdrivr.h \ $(PCF_DIR)/pcfutil.h \ $(PCF_DIR)/pcferror.h # pcf driver object(s) # # PCF_DRV_OBJ_M is used during `multi' builds # PCF_DRV_OBJ_S is used during `single' builds # PCF_DRV_OBJ_M := $(PCF_DRV_SRC:$(PCF_DIR)/%.c=$(OBJ_DIR)/%.$O) PCF_DRV_OBJ_S := $(OBJ_DIR)/pcf.$O # pcf driver source file for single build # PCF_DRV_SRC_S := $(PCF_DIR)/pcf.c # pcf driver - single object # $(PCF_DRV_OBJ_S): $(PCF_DRV_SRC_S) $(PCF_DRV_SRC) $(FREETYPE_H) $(PCF_DRV_H) $(PCF_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(PCF_DRV_SRC_S)) # pcf driver - multiple objects # $(OBJ_DIR)/%.$O: $(PCF_DIR)/%.c $(FREETYPE_H) $(PCF_DRV_H) $(PCF_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<) # update main driver object lists # DRV_OBJS_S += $(PCF_DRV_OBJ_S) DRV_OBJS_M += $(PCF_DRV_OBJ_M) # EOF --- NEW FILE: Jamfile --- # FreeType 2 src/pcf Jamfile # # Copyright 2001, 2003 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, # and distributed under the terms of the FreeType project license, # LICENSE.TXT. By continuing to use, modify, or distribute this file you # indicate that you have read the license and understand and accept it # fully. SubDir FT2_TOP $(FT2_SRC_DIR) pcf ; { local _sources ; if $(FT2_MULTI) { _sources = pcfdrivr pcfread pcfutil ; } else { _sources = pcf ; } Library $(FT2_LIB) : $(_sources).c ; } # end of src/pcf Jamfile --- NEW FILE: pcfread.h --- /* pcfread.h FreeType font driver for pcf fonts Copyright 2003 by Francesco Zappa Nardelli Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef __PCFREAD_H__ #define __PCFREAD_H__ #include <ft2build.h> FT_BEGIN_HEADER FT_LOCAL( PCF_Property ) pcf_find_property( PCF_Face face, const FT_String* prop ); FT_END_HEADER #endif /* __PCFREAD_H__ */ /* END */ --- NEW FILE: pcfutil.h --- /* pcfutil.h FreeType font driver for pcf fonts Copyright 2000, 2001, 2004 by Francesco Zappa Nardelli Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef __PCFUTIL_H__ #define __PCFUTIL_H__ #include <ft2build.h> #include FT_CONFIG_CONFIG_H FT_BEGIN_HEADER FT_LOCAL( void ) BitOrderInvert( unsigned char* buf, int nbytes ); FT_LOCAL( void ) TwoByteSwap( unsigned char* buf, int nbytes ); FT_LOCAL( void ) FourByteSwap( unsigned char* buf, int nbytes ); FT_END_HEADER #endif /* __PCFUTIL_H__ */ /* END */ --- NEW FILE: module.mk --- # # FreeType 2 PCF module definition # # Copyright 2000 by # Francesco Zappa Nardelli # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. make_module_list: add_pcf_driver add_pcf_driver: $(OPEN_DRIVER)pcf_driver_class$(CLOSE_DRIVER) $(ECHO_DRIVER)pcf $(ECHO_DRIVER_DESC)pcf bitmap fonts$(ECHO_DRIVER_DONE) # EOF --- NEW FILE: pcf.h --- /* pcf.h FreeType font driver for pcf fonts Copyright (C) 2000, 2001, 2002, 2003 by Francesco Zappa Nardelli Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef __PCF_H__ #define __PCF_H__ #include <ft2build.h> #include FT_INTERNAL_DRIVER_H #include FT_INTERNAL_STREAM_H FT_BEGIN_HEADER typedef struct PCF_TableRec_ { FT_ULong type; FT_ULong format; FT_ULong size; FT_ULong offset; } PCF_TableRec, *PCF_Table; typedef struct PCF_TocRec_ { FT_ULong version; FT_ULong count; PCF_Table tables; } PCF_TocRec, *PCF_Toc; typedef struct PCF_ParsePropertyRec_ { FT_Long name; FT_Byte isString; FT_Long value; } PCF_ParsePropertyRec, *PCF_ParseProperty; typedef struct PCF_PropertyRec_ { FT_String* name; FT_Byte isString; union { FT_String* atom; FT_Long integer; FT_ULong cardinal; } value; } PCF_PropertyRec, *PCF_Property; typedef struct PCF_Compressed_MetricRec_ { FT_Byte leftSideBearing; FT_Byte rightSideBearing; FT_Byte characterWidth; FT_Byte ascent; FT_Byte descent; } PCF_Compressed_MetricRec, *PCF_Compressed_Metric; typedef struct PCF_MetricRec_ { FT_Short leftSideBearing; FT_Short rightSideBearing; FT_Short characterWidth; FT_Short ascent; FT_Short descent; FT_Short attributes; FT_ULong bits; } PCF_MetricRec, *PCF_Metric; typedef struct PCF_AccelRec_ { FT_Byte noOverlap; FT_Byte constantMetrics; FT_Byte terminalFont; FT_Byte constantWidth; FT_Byte inkInside; FT_Byte inkMetrics; FT_Byte drawDirection; FT_Long fontAscent; FT_Long fontDescent; FT_Long maxOverlap; PCF_MetricRec minbounds; PCF_MetricRec maxbounds; PCF_MetricRec ink_minbounds; PCF_MetricRec ink_maxbounds; } PCF_AccelRec, *PCF_Accel; typedef struct PCF_EncodingRec_ { FT_Long enc; FT_UShort glyph; } PCF_EncodingRec, *PCF_Encoding; typedef struct PCF_FaceRec_ { FT_FaceRec root; FT_StreamRec gzip_stream; FT_Stream gzip_source; char* charset_encoding; char* charset_registry; PCF_TocRec toc; PCF_AccelRec accel; int nprops; PCF_Property properties; FT_Long nmetrics; PCF_Metric metrics; FT_Long nencodings; PCF_Encoding encodings; FT_Short defaultChar; FT_ULong bitmapsFormat; FT_CharMap charmap_handle; FT_CharMapRec charmap; /* a single charmap per face */ } PCF_FaceRec, *PCF_Face; /* macros for pcf font format */ #define LSBFirst 0 #define MSBFirst 1 #define PCF_FILE_VERSION ( ( 'p' << 24 ) | \ ( 'c' << 16 ) | \ ( 'f' << 8 ) | 1 ) #define PCF_FORMAT_MASK 0xFFFFFF00L #define PCF_DEFAULT_FORMAT 0x00000000L #define PCF_INKBOUNDS 0x00000200L #define PCF_ACCEL_W_INKBOUNDS 0x00000100L #define PCF_COMPRESSED_METRICS 0x00000100L #define PCF_FORMAT_MATCH( a, b ) \ ( ( (a) & PCF_FORMAT_MASK ) == ( (b) & PCF_FORMAT_MASK ) ) #define PCF_GLYPH_PAD_MASK ( 3 << 0 ) #define PCF_BYTE_MASK ( 1 << 2 ) #define PCF_BIT_MASK ( 1 << 3 ) #define PCF_SCAN_UNIT_MASK ( 3 << 4 ) #define PCF_BYTE_ORDER( f ) \ ( ( (f) & PCF_BYTE_MASK ) ? MSBFirst : LSBFirst ) #define PCF_BIT_ORDER( f ) \ ( ( (f) & PCF_BIT_MASK ) ? MSBFirst : LSBFirst ) #define PCF_GLYPH_PAD_INDEX( f ) \ ( (f) & PCF_GLYPH_PAD_MASK ) #define PCF_GLYPH_PAD( f ) \ ( 1 << PCF_GLYPH_PAD_INDEX( f ) ) #define PCF_SCAN_UNIT_INDEX( f ) \ ( ( (f) & PCF_SCAN_UNIT_MASK ) >> 4 ) #define PCF_SCAN_UNIT( f ) \ ( 1 << PCF_SCAN_UNIT_INDEX( f ) ) #define PCF_FORMAT_BITS( f ) \ ( (f) & ( PCF_GLYPH_PAD_MASK | \ PCF_BYTE_MASK | \ PCF_BIT_MASK | \ PCF_SCAN_UNIT_MASK ) ) #define PCF_SIZE_TO_INDEX( s ) ( (s) == 4 ? 2 : (s) == 2 ? 1 : 0 ) #define PCF_INDEX_TO_SIZE( b ) ( 1 << b ) #define PCF_FORMAT( bit, byte, glyph, scan ) \ ( ( PCF_SIZE_TO_INDEX( scan ) << 4 ) | \ ( ( (bit) == MSBFirst ? 1 : 0 ) << 3 ) | \ ( ( (byte) == MSBFirst ? 1 : 0 ) << 2 ) | \ ( PCF_SIZE_TO_INDEX( glyph ) << 0 ) ) #define PCF_PROPERTIES ( 1 << 0 ) #define PCF_ACCELERATORS ( 1 << 1 ) #define PCF_METRICS ( 1 << 2 ) #define PCF_BITMAPS ( 1 << 3 ) #define PCF_INK_METRICS ( 1 << 4 ) #define PCF_BDF_ENCODINGS ( 1 << 5 ) #define PCF_SWIDTHS ( 1 << 6 ) #define PCF_GLYPH_NAMES ( 1 << 7 ) #define PCF_BDF_ACCELERATORS ( 1 << 8 ) #define GLYPHPADOPTIONS 4 /* I'm not sure about this */ FT_LOCAL( FT_Error ) pcf_load_font( FT_Stream, PCF_Face ); FT_END_HEADER #endif /* __PCF_H__ */ /* END */ --- NEW FILE: pcferror.h --- /***************************************************************************/ /* */ /* pcferror.h */ /* */ /* PCF error codes (specification only). */ /* */ /* Copyright 2001 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ /*************************************************************************/ /* */ /* This file is used to define the PCF error enumeration constants. */ /* */ /*************************************************************************/ #ifndef __PCFERROR_H__ #define __PCFERROR_H__ #include FT_MODULE_ERRORS_H #undef __FTERRORS_H__ #define FT_ERR_PREFIX PCF_Err_ #define FT_ERR_BASE FT_Mod_Err_PCF #include FT_ERRORS_H #endif /* __PCFERROR_H__ */ /* END */ --- NEW FILE: pcfdrivr.h --- /* pcfdrivr.h FreeType font driver for pcf fonts Copyright 2000-2001, 2002 by Francesco Zappa Nardelli Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef __PCFDRIVR_H__ #define __PCFDRIVR_H__ #include <ft2build.h> #include FT_INTERNAL_DRIVER_H FT_BEGIN_HEADER FT_EXPORT_VAR( const FT_Driver_ClassRec ) pcf_driver_class; FT_END_HEADER #endif /* __PCFDRIVR_H__ */ /* END */ |
From: Ehud S. <esh...@us...> - 2006-04-21 16:31:20
|
Update of /cvsroot/roadmap/roadmap_editor/src/freetype/src/psaux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28321/src/psaux Added Files: Jamfile module.mk psauxerr.h psauxmod.h psobjs.h rules.mk t1cmap.h t1decode.h Log Message: Import freetype sources. --- NEW FILE: rules.mk --- # # FreeType 2 PSaux driver configuration rules # # Copyright 1996-2000, 2002, 2003 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, # and distributed under the terms of the FreeType project license, # LICENSE.TXT. By continuing to use, modify, or distribute this file you # indicate that you have read the license and understand and accept it # fully. # PSAUX driver directory # PSAUX_DIR := $(SRC_DIR)/psaux # compilation flags for the driver # PSAUX_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(PSAUX_DIR)) # PSAUX driver sources (i.e., C files) # PSAUX_DRV_SRC := $(PSAUX_DIR)/psobjs.c \ $(PSAUX_DIR)/t1decode.c \ $(PSAUX_DIR)/t1cmap.c \ $(PSAUX_DIR)/psauxmod.c # PSAUX driver headers # PSAUX_DRV_H := $(PSAUX_DRV_SRC:%c=%h) \ $(PSAUX_DIR)/psauxerr.h # PSAUX driver object(s) # # PSAUX_DRV_OBJ_M is used during `multi' builds. # PSAUX_DRV_OBJ_S is used during `single' builds. # PSAUX_DRV_OBJ_M := $(PSAUX_DRV_SRC:$(PSAUX_DIR)/%.c=$(OBJ_DIR)/%.$O) PSAUX_DRV_OBJ_S := $(OBJ_DIR)/psaux.$O # PSAUX driver source file for single build # PSAUX_DRV_SRC_S := $(PSAUX_DIR)/psaux.c # PSAUX driver - single object # $(PSAUX_DRV_OBJ_S): $(PSAUX_DRV_SRC_S) $(PSAUX_DRV_SRC) \ $(FREETYPE_H) $(PSAUX_DRV_H) $(PSAUX_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(PSAUX_DRV_SRC_S)) # PSAUX driver - multiple objects # $(OBJ_DIR)/%.$O: $(PSAUX_DIR)/%.c $(FREETYPE_H) $(PSAUX_DRV_H) $(PSAUX_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<) # update main driver object lists # DRV_OBJS_S += $(PSAUX_DRV_OBJ_S) DRV_OBJS_M += $(PSAUX_DRV_OBJ_M) # EOF --- NEW FILE: t1cmap.h --- /***************************************************************************/ /* */ /* t1cmap.h */ /* */ /* Type 1 character map support (specification). */ /* */ /* Copyright 2002, 2003 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __T1CMAP_H__ #define __T1CMAP_H__ #include <ft2build.h> #include FT_INTERNAL_OBJECTS_H #include FT_INTERNAL_TYPE1_TYPES_H FT_BEGIN_HEADER /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** TYPE1 STANDARD (AND EXPERT) ENCODING CMAPS *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ /* standard (and expert) encoding cmaps */ typedef struct T1_CMapStdRec_* T1_CMapStd; typedef struct T1_CMapStdRec_ { FT_CMapRec cmap; const FT_UShort* code_to_sid; PS_Adobe_Std_Strings_Func sid_to_string; FT_UInt num_glyphs; const char* const* glyph_names; } T1_CMapStdRec; FT_CALLBACK_TABLE const FT_CMap_ClassRec t1_cmap_standard_class_rec; FT_CALLBACK_TABLE const FT_CMap_ClassRec t1_cmap_expert_class_rec; /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** TYPE1 CUSTOM ENCODING CMAP *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ typedef struct T1_CMapCustomRec_* T1_CMapCustom; typedef struct T1_CMapCustomRec_ { FT_CMapRec cmap; FT_UInt first; FT_UInt count; FT_UShort* indices; } T1_CMapCustomRec; FT_CALLBACK_TABLE const FT_CMap_ClassRec t1_cmap_custom_class_rec; /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** TYPE1 SYNTHETIC UNICODE ENCODING CMAP *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ /* unicode (syntehtic) cmaps */ typedef struct T1_CMapUnicodeRec_* T1_CMapUnicode; typedef struct T1_CMapUniPairRec_ { FT_UInt32 unicode; FT_UInt gindex; } T1_CMapUniPairRec, *T1_CMapUniPair; typedef struct T1_CMapUnicodeRec_ { FT_CMapRec cmap; FT_UInt num_pairs; T1_CMapUniPair pairs; } T1_CMapUnicodeRec; FT_CALLBACK_TABLE const FT_CMap_ClassRec t1_cmap_unicode_class_rec; /* */ FT_END_HEADER #endif /* __T1CMAP_H__ */ /* END */ --- NEW FILE: Jamfile --- # FreeType 2 src/psaux Jamfile # # Copyright 2001, 2002 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, # and distributed under the terms of the FreeType project license, # LICENSE.TXT. By continuing to use, modify, or distribute this file you # indicate that you have read the license and understand and accept it # fully. SubDir FT2_TOP $(FT2_SRC_DIR) psaux ; { local _sources ; if $(FT2_MULTI) { _sources = psauxmod psobjs t1decode t1cmap ; } else { _sources = psaux ; } Library $(FT2_LIB) : $(_sources).c ; } # end of src/psaux Jamfile --- NEW FILE: psobjs.h --- /***************************************************************************/ /* */ /* psobjs.h */ /* */ /* Auxiliary functions for PostScript fonts (specification). */ /* */ /* Copyright 1996-2001, 2002, 2003 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __PSOBJS_H__ #define __PSOBJS_H__ #include <ft2build.h> #include FT_INTERNAL_POSTSCRIPT_AUX_H FT_BEGIN_HEADER /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** T1_TABLE *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ FT_CALLBACK_TABLE const PS_Table_FuncsRec ps_table_funcs; FT_CALLBACK_TABLE const PS_Parser_FuncsRec ps_parser_funcs; FT_CALLBACK_TABLE const T1_Builder_FuncsRec t1_builder_funcs; FT_LOCAL( FT_Error ) ps_table_new( PS_Table table, FT_Int count, FT_Memory memory ); FT_LOCAL( FT_Error ) ps_table_add( PS_Table table, FT_Int idx, void* object, FT_PtrDist length ); FT_LOCAL( void ) ps_table_done( PS_Table table ); FT_LOCAL( void ) ps_table_release( PS_Table table ); /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** T1 PARSER *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ FT_LOCAL( void ) ps_parser_skip_spaces( PS_Parser parser ); FT_LOCAL( void ) ps_parser_skip_PS_token( PS_Parser parser ); FT_LOCAL( void ) ps_parser_to_token( PS_Parser parser, T1_Token token ); FT_LOCAL( void ) ps_parser_to_token_array( PS_Parser parser, T1_Token tokens, FT_UInt max_tokens, FT_Int* pnum_tokens ); FT_LOCAL( FT_Error ) ps_parser_load_field( PS_Parser parser, const T1_Field field, void** objects, FT_UInt max_objects, FT_ULong* pflags ); FT_LOCAL( FT_Error ) ps_parser_load_field_table( PS_Parser parser, const T1_Field field, void** objects, FT_UInt max_objects, FT_ULong* pflags ); FT_LOCAL( FT_Long ) ps_parser_to_int( PS_Parser parser ); FT_LOCAL( FT_Error ) ps_parser_to_bytes( PS_Parser parser, FT_Byte* bytes, FT_Long max_bytes, FT_Long* pnum_bytes, FT_Bool delimiters ); FT_LOCAL( FT_Fixed ) ps_parser_to_fixed( PS_Parser parser, FT_Int power_ten ); FT_LOCAL( FT_Int ) ps_parser_to_coord_array( PS_Parser parser, FT_Int max_coords, FT_Short* coords ); FT_LOCAL( FT_Int ) ps_parser_to_fixed_array( PS_Parser parser, FT_Int max_values, FT_Fixed* values, FT_Int power_ten ); FT_LOCAL( void ) ps_parser_init( PS_Parser parser, FT_Byte* base, FT_Byte* limit, FT_Memory memory ); FT_LOCAL( void ) ps_parser_done( PS_Parser parser ); /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** T1 BUILDER *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ FT_LOCAL( void ) t1_builder_init( T1_Builder builder, FT_Face face, FT_Size size, FT_GlyphSlot glyph, FT_Bool hinting ); FT_LOCAL( void ) t1_builder_done( T1_Builder builder ); FT_LOCAL( FT_Error ) t1_builder_check_points( T1_Builder builder, FT_Int count ); FT_LOCAL( void ) t1_builder_add_point( T1_Builder builder, FT_Pos x, FT_Pos y, FT_Byte flag ); FT_LOCAL( FT_Error ) t1_builder_add_point1( T1_Builder builder, FT_Pos x, FT_Pos y ); FT_LOCAL( FT_Error ) t1_builder_add_contour( T1_Builder builder ); FT_LOCAL( FT_Error ) t1_builder_start_point( T1_Builder builder, FT_Pos x, FT_Pos y ); FT_LOCAL( void ) t1_builder_close_contour( T1_Builder builder ); /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** OTHER *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ FT_LOCAL( void ) t1_decrypt( FT_Byte* buffer, FT_Offset length, FT_UShort seed ); FT_END_HEADER #endif /* __PSOBJS_H__ */ /* END */ --- NEW FILE: psauxerr.h --- /***************************************************************************/ /* */ /* psauxerr.h */ /* */ /* PS auxiliary module error codes (specification only). */ /* */ /* Copyright 2001 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ /*************************************************************************/ /* */ /* This file is used to define the PS auxiliary module error enumeration */ /* constants. */ /* */ /*************************************************************************/ #ifndef __PSAUXERR_H__ #define __PSAUXERR_H__ #include FT_MODULE_ERRORS_H #undef __FTERRORS_H__ #define FT_ERR_PREFIX PSaux_Err_ #define FT_ERR_BASE FT_Mod_Err_PSaux #include FT_ERRORS_H #endif /* __PSAUXERR_H__ */ /* END */ --- NEW FILE: psauxmod.h --- /***************************************************************************/ /* */ /* psauxmod.h */ /* */ /* FreeType auxiliary PostScript module implementation (specification). */ /* */ /* Copyright 2000-2001 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __PSAUXMOD_H__ #define __PSAUXMOD_H__ #include <ft2build.h> #include FT_MODULE_H FT_BEGIN_HEADER FT_EXPORT_VAR( const FT_Module_Class ) psaux_driver_class; FT_END_HEADER #endif /* __PSAUXMOD_H__ */ /* END */ --- NEW FILE: module.mk --- # # FreeType 2 PSaux module definition # # Copyright 1996-2000 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, # and distributed under the terms of the FreeType project license, # LICENSE.TXT. By continuing to use, modify, or distribute this file you # indicate that you have read the license and understand and accept it # fully. make_module_list: add_psaux_module add_psaux_module: $(OPEN_DRIVER)psaux_module_class$(CLOSE_DRIVER) $(ECHO_DRIVER)psaux $(ECHO_DRIVER_DESC)Postscript Type 1 & Type 2 helper module$(ECHO_DRIVER_DONE) # EOF --- NEW FILE: t1decode.h --- /***************************************************************************/ /* */ /* t1decode.h */ /* */ /* PostScript Type 1 decoding routines (specification). */ /* */ /* Copyright 2000-2001, 2002, 2003 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __T1DECODE_H__ #define __T1DECODE_H__ #include <ft2build.h> #include FT_INTERNAL_POSTSCRIPT_AUX_H #include FT_INTERNAL_TYPE1_TYPES_H FT_BEGIN_HEADER FT_CALLBACK_TABLE const T1_Decoder_FuncsRec t1_decoder_funcs; FT_LOCAL( FT_Error ) t1_decoder_parse_glyph( T1_Decoder decoder, FT_UInt glyph_index ); FT_LOCAL( FT_Error ) t1_decoder_parse_charstrings( T1_Decoder decoder, FT_Byte* base, FT_UInt len ); FT_LOCAL( FT_Error ) t1_decoder_init( T1_Decoder decoder, FT_Face face, FT_Size size, FT_GlyphSlot slot, FT_Byte** glyph_names, PS_Blend blend, FT_Bool hinting, FT_Render_Mode hint_mode, T1_Decoder_Callback parse_glyph ); FT_LOCAL( void ) t1_decoder_done( T1_Decoder decoder ); FT_END_HEADER #endif /* __T1DECODE_H__ */ /* END */ |
From: Ehud S. <esh...@us...> - 2006-04-21 16:31:20
|
Update of /cvsroot/roadmap/roadmap_editor/src/freetype/src/cff In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28321/src/cff Added Files: Jamfile cffcmap.h cffdrivr.h cfferrs.h cffgload.h cffload.h cffobjs.h cffparse.h cfftoken.h cfftypes.h module.mk rules.mk Log Message: Import freetype sources. --- NEW FILE: rules.mk --- # # FreeType 2 OpenType/CFF driver configuration rules # # Copyright 1996-2000, 2001, 2003 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, # and distributed under the terms of the FreeType project license, # LICENSE.TXT. By continuing to use, modify, or distribute this file you # indicate that you have read the license and understand and accept it # fully. # OpenType driver directory # CFF_DIR := $(SRC_DIR)/cff CFF_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(CFF_DIR)) # CFF driver sources (i.e., C files) # CFF_DRV_SRC := $(CFF_DIR)/cffobjs.c \ $(CFF_DIR)/cffload.c \ $(CFF_DIR)/cffgload.c \ $(CFF_DIR)/cffparse.c \ $(CFF_DIR)/cffcmap.c \ $(CFF_DIR)/cffdrivr.c # CFF driver headers # CFF_DRV_H := $(CFF_DRV_SRC:%.c=%.h) \ $(CFF_DIR)/cfftoken.h \ $(CFF_DIR)/cfftypes.h \ $(CFF_DIR)/cfferrs.h # CFF driver object(s) # # CFF_DRV_OBJ_M is used during `multi' builds # CFF_DRV_OBJ_S is used during `single' builds # CFF_DRV_OBJ_M := $(CFF_DRV_SRC:$(CFF_DIR)/%.c=$(OBJ_DIR)/%.$O) CFF_DRV_OBJ_S := $(OBJ_DIR)/cff.$O # CFF driver source file for single build # CFF_DRV_SRC_S := $(CFF_DIR)/cff.c # CFF driver - single object # $(CFF_DRV_OBJ_S): $(CFF_DRV_SRC_S) $(CFF_DRV_SRC) $(FREETYPE_H) $(CFF_DRV_H) $(CFF_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(CFF_DRV_SRC_S)) # CFF driver - multiple objects # $(OBJ_DIR)/%.$O: $(CFF_DIR)/%.c $(FREETYPE_H) $(CFF_DRV_H) $(CFF_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<) # update main driver object lists # DRV_OBJS_S += $(CFF_DRV_OBJ_S) DRV_OBJS_M += $(CFF_DRV_OBJ_M) # EOF --- NEW FILE: cfftypes.h --- /***************************************************************************/ /* */ /* cfftypes.h */ /* */ /* Basic OpenType/CFF type definitions and interface (specification */ /* only). */ /* */ /* Copyright 1996-2001, 2002, 2003 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __CFFTYPES_H__ #define __CFFTYPES_H__ #include <ft2build.h> #include FT_FREETYPE_H FT_BEGIN_HEADER /*************************************************************************/ /* */ /* <Struct> */ /* CFF_IndexRec */ /* */ /* <Description> */ /* A structure used to model a CFF Index table. */ /* */ /* <Fields> */ /* stream :: The source input stream. */ /* */ /* count :: The number of elements in the index. */ /* */ /* off_size :: The size in bytes of object offsets in index. */ /* */ /* data_offset :: The position of first data byte in the index's */ /* bytes. */ /* */ /* offsets :: A table of element offsets in the index. */ /* */ /* bytes :: If the index is loaded in memory, its bytes. */ /* */ typedef struct CFF_IndexRec_ { FT_Stream stream; FT_UInt count; FT_Byte off_size; FT_ULong data_offset; FT_ULong* offsets; FT_Byte* bytes; } CFF_IndexRec, *CFF_Index; typedef struct CFF_EncodingRec_ { FT_UInt format; FT_ULong offset; FT_UInt count; FT_UShort sids [256]; /* avoid dynamic allocations */ FT_UShort codes[256]; } CFF_EncodingRec, *CFF_Encoding; typedef struct CFF_CharsetRec_ { FT_UInt format; FT_ULong offset; FT_UShort* sids; FT_UShort* cids; /* the inverse mapping of `sids'; only needed */ /* for CID-keyed fonts */ } CFF_CharsetRec, *CFF_Charset; typedef struct CFF_FontRecDictRec_ { FT_UInt version; FT_UInt notice; FT_UInt copyright; FT_UInt full_name; FT_UInt family_name; FT_UInt weight; FT_Bool is_fixed_pitch; FT_Fixed italic_angle; FT_Fixed underline_position; FT_Fixed underline_thickness; FT_Int paint_type; FT_Int charstring_type; FT_Matrix font_matrix; FT_UShort units_per_em; FT_Vector font_offset; FT_ULong unique_id; FT_BBox font_bbox; FT_Pos stroke_width; FT_ULong charset_offset; FT_ULong encoding_offset; FT_ULong charstrings_offset; FT_ULong private_offset; FT_ULong private_size; FT_Long synthetic_base; FT_UInt embedded_postscript; /* these should only be used for the top-level font dictionary */ FT_UInt cid_registry; FT_UInt cid_ordering; FT_ULong cid_supplement; FT_Long cid_font_version; FT_Long cid_font_revision; FT_Long cid_font_type; FT_ULong cid_count; FT_ULong cid_uid_base; FT_ULong cid_fd_array_offset; FT_ULong cid_fd_select_offset; FT_UInt cid_font_name; } CFF_FontRecDictRec, *CFF_FontRecDict; typedef struct CFF_PrivateRec_ { FT_Byte num_blue_values; FT_Byte num_other_blues; FT_Byte num_family_blues; FT_Byte num_family_other_blues; FT_Pos blue_values[14]; FT_Pos other_blues[10]; FT_Pos family_blues[14]; FT_Pos family_other_blues[10]; FT_Fixed blue_scale; FT_Pos blue_shift; FT_Pos blue_fuzz; FT_Pos standard_width; FT_Pos standard_height; FT_Byte num_snap_widths; FT_Byte num_snap_heights; FT_Pos snap_widths[13]; FT_Pos snap_heights[13]; FT_Bool force_bold; FT_Fixed force_bold_threshold; FT_Int lenIV; FT_Int language_group; FT_Fixed expansion_factor; FT_Long initial_random_seed; FT_ULong local_subrs_offset; FT_Pos default_width; FT_Pos nominal_width; } CFF_PrivateRec, *CFF_Private; typedef struct CFF_FDSelectRec_ { FT_Byte format; FT_UInt range_count; /* that's the table, taken from the file `as is' */ FT_Byte* data; FT_UInt data_size; /* small cache for format 3 only */ FT_UInt cache_first; FT_UInt cache_count; FT_Byte cache_fd; } CFF_FDSelectRec, *CFF_FDSelect; /* A SubFont packs a font dict and a private dict together. They are */ /* needed to support CID-keyed CFF fonts. */ typedef struct CFF_SubFontRec_ { CFF_FontRecDictRec font_dict; CFF_PrivateRec private_dict; CFF_IndexRec local_subrs_index; FT_UInt num_local_subrs; FT_Byte** local_subrs; } CFF_SubFontRec, *CFF_SubFont; /* maximum number of sub-fonts in a CID-keyed file */ #define CFF_MAX_CID_FONTS 32 typedef struct CFF_FontRec_ { FT_Stream stream; FT_Memory memory; FT_UInt num_faces; FT_UInt num_glyphs; FT_Byte version_major; FT_Byte version_minor; FT_Byte header_size; FT_Byte absolute_offsize; CFF_IndexRec name_index; CFF_IndexRec top_dict_index; CFF_IndexRec string_index; CFF_IndexRec global_subrs_index; CFF_EncodingRec encoding; CFF_CharsetRec charset; CFF_IndexRec charstrings_index; CFF_IndexRec font_dict_index; CFF_IndexRec private_index; CFF_IndexRec local_subrs_index; FT_String* font_name; FT_UInt num_global_subrs; FT_Byte** global_subrs; CFF_SubFontRec top_font; FT_UInt num_subfonts; CFF_SubFont subfonts[CFF_MAX_CID_FONTS]; CFF_FDSelectRec fd_select; /* interface to PostScript hinter */ void* pshinter; /* interface to Postscript Names service */ void* psnames; } CFF_FontRec, *CFF_Font; FT_END_HEADER #endif /* __CFFTYPES_H__ */ /* END */ --- NEW FILE: Jamfile --- # FreeType 2 src/cff Jamfile # # Copyright 2001, 2002 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, # and distributed under the terms of the FreeType project license, # LICENSE.TXT. By continuing to use, modify, or distribute this file you # indicate that you have read the license and understand and accept it # fully. SubDir FT2_TOP $(FT2_SRC_DIR) cff ; { local _sources ; if $(FT2_MULTI) { _sources = cffdrivr cffgload cffload cffobjs cffparse cffcmap ; } else { _sources = cff ; } Library $(FT2_LIB) : $(_sources).c ; } # end of src/cff Jamfile --- NEW FILE: cffdrivr.h --- /***************************************************************************/ /* */ /* cffdrivr.h */ /* */ /* High-level OpenType driver interface (specification). */ /* */ /* Copyright 1996-2001, 2002 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __CFFDRIVER_H__ #define __CFFDRIVER_H__ #include <ft2build.h> #include FT_INTERNAL_DRIVER_H FT_BEGIN_HEADER FT_CALLBACK_TABLE const FT_Driver_ClassRec cff_driver_class; FT_END_HEADER #endif /* __CFFDRIVER_H__ */ /* END */ --- NEW FILE: cffload.h --- /***************************************************************************/ /* */ /* cffload.h */ /* */ /* OpenType & CFF data/program tables loader (specification). */ /* */ /* Copyright 1996-2001, 2002, 2003 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __CFFLOAD_H__ #define __CFFLOAD_H__ #include <ft2build.h> #include "cfftypes.h" #include FT_SERVICE_POSTSCRIPT_CMAPS_H FT_BEGIN_HEADER FT_LOCAL( FT_UShort ) cff_get_standard_encoding( FT_UInt charcode ); FT_LOCAL( FT_String* ) cff_index_get_name( CFF_Index idx, FT_UInt element ); FT_LOCAL( FT_String* ) cff_index_get_sid_string( CFF_Index idx, FT_UInt sid, FT_Service_PsCMaps psnames ); FT_LOCAL( FT_Error ) cff_index_access_element( CFF_Index idx, FT_UInt element, FT_Byte** pbytes, FT_ULong* pbyte_len ); FT_LOCAL( void ) cff_index_forget_element( CFF_Index idx, FT_Byte** pbytes ); FT_LOCAL( FT_Error ) cff_font_load( FT_Stream stream, FT_Int face_index, CFF_Font font ); FT_LOCAL( void ) cff_font_done( CFF_Font font ); FT_LOCAL( FT_Byte ) cff_fd_select_get( CFF_FDSelect fdselect, FT_UInt glyph_index ); FT_END_HEADER #endif /* __CFFLOAD_H__ */ /* END */ --- NEW FILE: cfftoken.h --- /***************************************************************************/ /* */ /* cfftoken.h */ /* */ /* CFF token definitions (specification only). */ /* */ /* Copyright 1996-2001, 2002, 2003 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #undef FT_STRUCTURE #define FT_STRUCTURE CFF_FontRecDictRec #undef CFFCODE #define CFFCODE CFFCODE_TOPDICT CFF_FIELD_STRING ( 0, version ) CFF_FIELD_STRING ( 1, notice ) CFF_FIELD_STRING ( 0x100, copyright ) CFF_FIELD_STRING ( 2, full_name ) CFF_FIELD_STRING ( 3, family_name ) CFF_FIELD_STRING ( 4, weight ) CFF_FIELD_BOOL ( 0x101, is_fixed_pitch ) CFF_FIELD_FIXED ( 0x102, italic_angle ) CFF_FIELD_FIXED ( 0x103, underline_position ) CFF_FIELD_FIXED ( 0x104, underline_thickness ) CFF_FIELD_NUM ( 0x105, paint_type ) CFF_FIELD_NUM ( 0x106, charstring_type ) CFF_FIELD_CALLBACK( 0x107, font_matrix ) CFF_FIELD_NUM ( 13, unique_id ) CFF_FIELD_CALLBACK( 5, font_bbox ) CFF_FIELD_NUM ( 0x108, stroke_width ) CFF_FIELD_NUM ( 15, charset_offset ) CFF_FIELD_NUM ( 16, encoding_offset ) CFF_FIELD_NUM ( 17, charstrings_offset ) CFF_FIELD_CALLBACK( 18, private_dict ) CFF_FIELD_NUM ( 0x114, synthetic_base ) CFF_FIELD_STRING ( 0x115, embedded_postscript ) #if 0 CFF_FIELD_STRING ( 0x116, base_font_name ) CFF_FIELD_DELTA ( 0x117, base_font_blend, 16 ) CFF_FIELD_CALLBACK( 0x118, multiple_master ) CFF_FIELD_CALLBACK( 0x119, blend_axis_types ) #endif CFF_FIELD_CALLBACK( 0x11E, cid_ros ) CFF_FIELD_NUM ( 0x11F, cid_font_version ) CFF_FIELD_NUM ( 0x120, cid_font_revision ) CFF_FIELD_NUM ( 0x121, cid_font_type ) CFF_FIELD_NUM ( 0x122, cid_count ) CFF_FIELD_NUM ( 0x123, cid_uid_base ) CFF_FIELD_NUM ( 0x124, cid_fd_array_offset ) CFF_FIELD_NUM ( 0x125, cid_fd_select_offset ) CFF_FIELD_STRING ( 0x126, cid_font_name ) #if 0 CFF_FIELD_NUM ( 0x127, chameleon ) #endif #undef FT_STRUCTURE #define FT_STRUCTURE CFF_PrivateRec #undef CFFCODE #define CFFCODE CFFCODE_PRIVATE CFF_FIELD_DELTA ( 6, blue_values, 14 ) CFF_FIELD_DELTA ( 7, other_blues, 10 ) CFF_FIELD_DELTA ( 8, family_blues, 14 ) CFF_FIELD_DELTA ( 9, family_other_blues, 10 ) CFF_FIELD_FIXED_1000( 0x109, blue_scale ) CFF_FIELD_NUM ( 0x10A, blue_shift ) CFF_FIELD_NUM ( 0x10B, blue_fuzz ) CFF_FIELD_NUM ( 10, standard_width ) CFF_FIELD_NUM ( 11, standard_height ) CFF_FIELD_DELTA ( 0x10C, snap_widths, 13 ) CFF_FIELD_DELTA ( 0x10D, snap_heights, 13 ) CFF_FIELD_BOOL ( 0x10E, force_bold ) CFF_FIELD_FIXED ( 0x10F, force_bold_threshold ) CFF_FIELD_NUM ( 0x110, lenIV ) CFF_FIELD_NUM ( 0x111, language_group ) CFF_FIELD_FIXED ( 0x112, expansion_factor ) CFF_FIELD_NUM ( 0x113, initial_random_seed ) CFF_FIELD_NUM ( 19, local_subrs_offset ) CFF_FIELD_NUM ( 20, default_width ) CFF_FIELD_NUM ( 21, nominal_width ) /* END */ --- NEW FILE: cfferrs.h --- /***************************************************************************/ /* */ /* cfferrs.h */ /* */ /* CFF error codes (specification only). */ /* */ /* Copyright 2001 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ /*************************************************************************/ /* */ /* This file is used to define the CFF error enumeration constants. */ /* */ /*************************************************************************/ #ifndef __CFFERRS_H__ #define __CFFERRS_H__ #include FT_MODULE_ERRORS_H #undef __FTERRORS_H__ #define FT_ERR_PREFIX CFF_Err_ #define FT_ERR_BASE FT_Mod_Err_CFF #include FT_ERRORS_H #endif /* __CFFERRS_H__ */ /* END */ --- NEW FILE: cffobjs.h --- /***************************************************************************/ /* */ /* cffobjs.h */ /* */ /* OpenType objects manager (specification). */ /* */ /* Copyright 1996-2001, 2002, 2003, 2004 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __CFFOBJS_H__ #define __CFFOBJS_H__ #include <ft2build.h> #include FT_INTERNAL_OBJECTS_H #include "cfftypes.h" #include FT_INTERNAL_TRUETYPE_TYPES_H #include FT_SERVICE_POSTSCRIPT_CMAPS_H FT_BEGIN_HEADER /*************************************************************************/ /* */ /* <Type> */ /* CFF_Driver */ /* */ /* <Description> */ /* A handle to an OpenType driver object. */ /* */ typedef struct CFF_DriverRec_* CFF_Driver; typedef TT_Face CFF_Face; /*************************************************************************/ /* */ /* <Type> */ /* CFF_Size */ /* */ /* <Description> */ /* A handle to an OpenType size object. */ /* */ typedef struct CFF_SizeRec_ { FT_SizeRec root; #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS FT_UInt strike_index; /* 0xFFFF to indicate invalid */ FT_Size_Metrics strike_metrics; /* current strike's metrics */ #endif } CFF_SizeRec, *CFF_Size; /*************************************************************************/ /* */ /* <Type> */ /* CFF_GlyphSlot */ /* */ /* <Description> */ /* A handle to an OpenType glyph slot object. */ /* */ typedef struct CFF_GlyphSlotRec_ { FT_GlyphSlotRec root; FT_Bool hint; FT_Bool scaled; FT_Fixed x_scale; FT_Fixed y_scale; } CFF_GlyphSlotRec, *CFF_GlyphSlot; /*************************************************************************/ /* */ /* Subglyph transformation record. */ /* */ typedef struct CFF_Transform_ { FT_Fixed xx, xy; /* transformation matrix coefficients */ FT_Fixed yx, yy; FT_F26Dot6 ox, oy; /* offsets */ } CFF_Transform; /***********************************************************************/ /* */ /* TrueType driver class. */ /* */ typedef struct CFF_DriverRec_ { FT_DriverRec root; void* extension_component; } CFF_DriverRec; FT_LOCAL( FT_Error ) cff_size_init( FT_Size size ); /* CFF_Size */ FT_LOCAL( void ) cff_size_done( FT_Size size ); /* CFF_Size */ FT_LOCAL( FT_Error ) cff_size_reset( FT_Size size, /* CFF_Size */ FT_UInt char_width, FT_UInt char_height ); FT_LOCAL( FT_Error ) cff_point_size_reset( FT_Size cffsize, FT_F26Dot6 char_width, FT_F26Dot6 char_height, FT_UInt horz_resolution, FT_UInt vert_resolution ); FT_LOCAL( void ) cff_slot_done( FT_GlyphSlot slot ); FT_LOCAL( FT_Error ) cff_slot_init( FT_GlyphSlot slot ); /*************************************************************************/ /* */ /* Face functions */ /* */ FT_LOCAL( FT_Error ) cff_face_init( FT_Stream stream, FT_Face face, /* CFF_Face */ FT_Int face_index, FT_Int num_params, FT_Parameter* params ); FT_LOCAL( void ) cff_face_done( FT_Face face ); /* CFF_Face */ /*************************************************************************/ /* */ /* Driver functions */ /* */ FT_LOCAL( FT_Error ) cff_driver_init( FT_Module module ); FT_LOCAL( void ) cff_driver_done( FT_Module module ); FT_END_HEADER #endif /* __CFFOBJS_H__ */ /* END */ --- NEW FILE: module.mk --- # # FreeType 2 CFF module definition # # Copyright 1996-2000 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, # and distributed under the terms of the FreeType project license, # LICENSE.TXT. By continuing to use, modify, or distribute this file you # indicate that you have read the license and understand and accept it # fully. make_module_list: add_cff_driver add_cff_driver: $(OPEN_DRIVER)cff_driver_class$(CLOSE_DRIVER) $(ECHO_DRIVER)cff $(ECHO_DRIVER_DESC)OpenType fonts with extension *.otf$(ECHO_DRIVER_DONE) # EOF --- NEW FILE: cffparse.h --- /***************************************************************************/ /* */ /* cffparse.h */ /* */ /* CFF token stream parser (specification) */ /* */ /* Copyright 1996-2001, 2002, 2003 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __CFF_PARSE_H__ #define __CFF_PARSE_H__ #include <ft2build.h> #include "cfftypes.h" #include FT_INTERNAL_OBJECTS_H FT_BEGIN_HEADER #define CFF_MAX_STACK_DEPTH 96 #define CFF_CODE_TOPDICT 0x1000 #define CFF_CODE_PRIVATE 0x2000 typedef struct CFF_ParserRec_ { FT_Byte* start; FT_Byte* limit; FT_Byte* cursor; FT_Byte* stack[CFF_MAX_STACK_DEPTH + 1]; FT_Byte** top; FT_UInt object_code; void* object; } CFF_ParserRec, *CFF_Parser; FT_LOCAL( void ) cff_parser_init( CFF_Parser parser, FT_UInt code, void* object ); FT_LOCAL( FT_Error ) cff_parser_run( CFF_Parser parser, FT_Byte* start, FT_Byte* limit ); FT_END_HEADER #endif /* __CFF_PARSE_H__ */ /* END */ --- NEW FILE: cffcmap.h --- /***************************************************************************/ /* */ /* cffcmap.h */ /* */ /* CFF character mapping table (cmap) support (specification). */ /* */ /* Copyright 2002, 2003 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __CFFCMAP_H__ #define __CFFCMAP_H__ #include "cffobjs.h" FT_BEGIN_HEADER /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** TYPE1 STANDARD (AND EXPERT) ENCODING CMAPS *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ /* standard (and expert) encoding cmaps */ typedef struct CFF_CMapStdRec_* CFF_CMapStd; typedef struct CFF_CMapStdRec_ { FT_CMapRec cmap; FT_UShort* gids; /* up to 256 elements */ } CFF_CMapStdRec; FT_CALLBACK_TABLE const FT_CMap_ClassRec cff_cmap_encoding_class_rec; /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** CFF SYNTHETIC UNICODE ENCODING CMAP *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ /* unicode (synthetic) cmaps */ typedef struct CFF_CMapUnicodeRec_* CFF_CMapUnicode; typedef struct CFF_CMapUniPairRec_ { FT_UInt32 unicode; FT_UInt gindex; } CFF_CMapUniPairRec, *CFF_CMapUniPair; typedef struct CFF_CMapUnicodeRec_ { FT_CMapRec cmap; FT_UInt num_pairs; CFF_CMapUniPair pairs; } CFF_CMapUnicodeRec; FT_CALLBACK_TABLE const FT_CMap_ClassRec cff_cmap_unicode_class_rec; FT_END_HEADER #endif /* __CFFCMAP_H__ */ /* END */ --- NEW FILE: cffgload.h --- /***************************************************************************/ /* */ /* cffgload.h */ /* */ /* OpenType Glyph Loader (specification). */ /* */ /* Copyright 1996-2001, 2002, 2003, 2004 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __CFFGLOAD_H__ #define __CFFGLOAD_H__ #include <ft2build.h> #include FT_FREETYPE_H #include "cffobjs.h" FT_BEGIN_HEADER #define CFF_MAX_OPERANDS 48 #define CFF_MAX_SUBRS_CALLS 32 /*************************************************************************/ /* */ /* <Structure> */ /* CFF_Builder */ /* */ /* <Description> */ /* A structure used during glyph loading to store its outline. */ /* */ /* <Fields> */ /* memory :: The current memory object. */ /* */ /* face :: The current face object. */ /* */ /* glyph :: The current glyph slot. */ /* */ /* loader :: The current glyph loader. */ /* */ /* base :: The base glyph outline. */ /* */ /* current :: The current glyph outline. */ /* */ /* last :: The last point position. */ /* */ /* scale_x :: The horizontal scale (FUnits to sub-pixels). */ /* */ /* scale_y :: The vertical scale (FUnits to sub-pixels). */ /* */ /* pos_x :: The horizontal translation (if composite glyph). */ /* */ /* pos_y :: The vertical translation (if composite glyph). */ /* */ /* left_bearing :: The left side bearing point. */ /* */ /* advance :: The horizontal advance vector. */ /* */ /* bbox :: Unused. */ /* */ /* path_begun :: A flag which indicates that a new path has begun. */ /* */ /* load_points :: If this flag is not set, no points are loaded. */ /* */ /* no_recurse :: Set but not used. */ /* */ /* metrics_only :: A boolean indicating that we only want to compute */ /* the metrics of a given glyph, not load all of its */ /* points. */ /* */ /* hints_funcs :: Auxiliary pointer for hinting. */ /* */ /* hints_globals :: Auxiliary pointer for hinting. */ /* */ typedef struct CFF_Builder_ { FT_Memory memory; TT_Face face; CFF_GlyphSlot glyph; FT_GlyphLoader loader; FT_Outline* base; FT_Outline* current; FT_Vector last; FT_Fixed scale_x; FT_Fixed scale_y; FT_Pos pos_x; FT_Pos pos_y; FT_Vector left_bearing; FT_Vector advance; FT_BBox bbox; /* bounding box */ FT_Bool path_begun; FT_Bool load_points; FT_Bool no_recurse; FT_Bool metrics_only; void* hints_funcs; /* hinter-specific */ void* hints_globals; /* hinter-specific */ } CFF_Builder; /* execution context charstring zone */ typedef struct CFF_Decoder_Zone_ { FT_Byte* base; FT_Byte* limit; FT_Byte* cursor; } CFF_Decoder_Zone; typedef struct CFF_Decoder_ { CFF_Builder builder; CFF_Font cff; FT_Fixed stack[CFF_MAX_OPERANDS + 1]; FT_Fixed* top; CFF_Decoder_Zone zones[CFF_MAX_SUBRS_CALLS + 1]; CFF_Decoder_Zone* zone; FT_Int flex_state; FT_Int num_flex_vectors; FT_Vector flex_vectors[7]; FT_Pos glyph_width; FT_Pos nominal_width; FT_Bool read_width; FT_Int num_hints; FT_Fixed* buildchar; FT_Int len_buildchar; FT_UInt num_locals; FT_UInt num_globals; FT_Int locals_bias; FT_Int globals_bias; FT_Byte** locals; FT_Byte** globals; FT_Byte** glyph_names; /* for pure CFF fonts only */ FT_UInt num_glyphs; /* number of glyphs in font */ FT_Render_Mode hint_mode; } CFF_Decoder; FT_LOCAL( void ) cff_decoder_init( CFF_Decoder* decoder, TT_Face face, CFF_Size size, CFF_GlyphSlot slot, FT_Bool hinting, FT_Render_Mode hint_mode ); FT_LOCAL( void ) cff_decoder_prepare( CFF_Decoder* decoder, FT_UInt glyph_index ); #if 0 /* unused until we support pure CFF fonts */ /* Compute the maximum advance width of a font through quick parsing */ FT_LOCAL( FT_Error ) cff_compute_max_advance( TT_Face face, FT_Int* max_advance ); #endif /* 0 */ FT_LOCAL( FT_Error ) cff_decoder_parse_charstrings( CFF_Decoder* decoder, FT_Byte* charstring_base, FT_ULong charstring_len ); FT_LOCAL( FT_Error ) cff_slot_load( CFF_GlyphSlot glyph, CFF_Size size, FT_Int glyph_index, FT_Int32 load_flags ); FT_END_HEADER #endif /* __CFFGLOAD_H__ */ /* END */ |
From: Ehud S. <esh...@us...> - 2006-04-21 16:31:20
|
Update of /cvsroot/roadmap/roadmap_editor/src/freetype/src/type1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28321/src/type1 Added Files: Jamfile module.mk rules.mk t1afm.h t1driver.h t1errors.h t1gload.h t1load.h t1objs.h t1parse.h t1tokens.h Log Message: Import freetype sources. --- NEW FILE: rules.mk --- # # FreeType 2 Type1 driver configuration rules # # Copyright 1996-2000, 2001, 2003 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, # and distributed under the terms of the FreeType project license, # LICENSE.TXT. By continuing to use, modify, or distribute this file you # indicate that you have read the license and understand and accept it # fully. # Type1 driver directory # T1_DIR := $(SRC_DIR)/type1 # compilation flags for the driver # T1_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(T1_DIR)) # Type1 driver sources (i.e., C files) # T1_DRV_SRC := $(T1_DIR)/t1parse.c \ $(T1_DIR)/t1load.c \ $(T1_DIR)/t1driver.c \ $(T1_DIR)/t1afm.c \ $(T1_DIR)/t1gload.c \ $(T1_DIR)/t1objs.c # Type1 driver headers # T1_DRV_H := $(T1_DRV_SRC:%.c=%.h) \ $(T1_DIR)/t1tokens.h \ $(T1_DIR)/t1errors.h # Type1 driver object(s) # # T1_DRV_OBJ_M is used during `multi' builds # T1_DRV_OBJ_S is used during `single' builds # T1_DRV_OBJ_M := $(T1_DRV_SRC:$(T1_DIR)/%.c=$(OBJ_DIR)/%.$O) T1_DRV_OBJ_S := $(OBJ_DIR)/type1.$O # Type1 driver source file for single build # T1_DRV_SRC_S := $(T1_DIR)/type1.c # Type1 driver - single object # $(T1_DRV_OBJ_S): $(T1_DRV_SRC_S) $(T1_DRV_SRC) $(FREETYPE_H) $(T1_DRV_H) $(T1_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(T1_DRV_SRC_S)) # Type1 driver - multiple objects # $(OBJ_DIR)/%.$O: $(T1_DIR)/%.c $(FREETYPE_H) $(T1_DRV_H) $(T1_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<) # update main driver object lists # DRV_OBJS_S += $(T1_DRV_OBJ_S) DRV_OBJS_M += $(T1_DRV_OBJ_M) # EOF --- NEW FILE: t1load.h --- /***************************************************************************/ /* */ /* t1load.h */ /* */ /* Type 1 font loader (specification). */ /* */ /* Copyright 1996-2001, 2002, 2004 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __T1LOAD_H__ #define __T1LOAD_H__ #include <ft2build.h> #include FT_INTERNAL_STREAM_H #include FT_INTERNAL_POSTSCRIPT_AUX_H #include FT_MULTIPLE_MASTERS_H #include "t1parse.h" FT_BEGIN_HEADER typedef struct T1_Loader_ { T1_ParserRec parser; /* parser used to read the stream */ FT_Int num_chars; /* number of characters in encoding */ PS_TableRec encoding_table; /* PS_Table used to store the */ /* encoding character names */ FT_Int num_glyphs; PS_TableRec glyph_names; PS_TableRec charstrings; PS_TableRec swap_table; /* For moving .notdef glyph to index 0. */ FT_Int num_subrs; PS_TableRec subrs; FT_Bool fontdata; } T1_LoaderRec, *T1_Loader; FT_LOCAL( FT_Error ) T1_Open_Face( T1_Face face ); #ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT FT_LOCAL( FT_Error ) T1_Get_Multi_Master( T1_Face face, FT_Multi_Master* master ); FT_LOCAL_DEF( FT_Error ) T1_Get_MM_Var( T1_Face face, FT_MM_Var* *master ); FT_LOCAL( FT_Error ) T1_Set_MM_Blend( T1_Face face, FT_UInt num_coords, FT_Fixed* coords ); FT_LOCAL( FT_Error ) T1_Set_MM_Design( T1_Face face, FT_UInt num_coords, FT_Long* coords ); FT_LOCAL_DEF( FT_Error ) T1_Set_Var_Design( T1_Face face, FT_UInt num_coords, FT_Fixed* coords ); FT_LOCAL( void ) T1_Done_Blend( T1_Face face ); #endif /* !T1_CONFIG_OPTION_NO_MM_SUPPORT */ FT_END_HEADER #endif /* __T1LOAD_H__ */ /* END */ --- NEW FILE: t1errors.h --- /***************************************************************************/ /* */ /* t1errors.h */ /* */ /* Type 1 error codes (specification only). */ /* */ /* Copyright 2001 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ /*************************************************************************/ /* */ /* This file is used to define the Type 1 error enumeration constants. */ /* */ /*************************************************************************/ #ifndef __T1ERRORS_H__ #define __T1ERRORS_H__ #include FT_MODULE_ERRORS_H #undef __FTERRORS_H__ #define FT_ERR_PREFIX T1_Err_ #define FT_ERR_BASE FT_Mod_Err_Type1 #include FT_ERRORS_H #endif /* __T1ERRORS_H__ */ /* END */ --- NEW FILE: Jamfile --- # FreeType 2 src/type1 Jamfile # # Copyright 2001 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, # and distributed under the terms of the FreeType project license, # LICENSE.TXT. By continuing to use, modify, or distribute this file you # indicate that you have read the license and understand and accept it # fully. SubDir FT2_TOP $(FT2_SRC_DIR) type1 ; { local _sources ; if $(FT2_MULTI) { _sources = t1afm t1driver t1objs t1load t1gload t1parse ; } else { _sources = type1 ; } Library $(FT2_LIB) : $(_sources).c ; } # end of src/type1 Jamfile --- NEW FILE: t1gload.h --- /***************************************************************************/ /* */ /* t1gload.h */ /* */ /* Type 1 Glyph Loader (specification). */ /* */ /* Copyright 1996-2001, 2002, 2003 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __T1GLOAD_H__ #define __T1GLOAD_H__ #include <ft2build.h> #include "t1objs.h" FT_BEGIN_HEADER FT_LOCAL( FT_Error ) T1_Compute_Max_Advance( T1_Face face, FT_Pos* max_advance ); FT_LOCAL( FT_Error ) T1_Load_Glyph( T1_GlyphSlot glyph, T1_Size size, FT_UInt glyph_index, FT_Int32 load_flags ); FT_END_HEADER #endif /* __T1GLOAD_H__ */ /* END */ --- NEW FILE: t1tokens.h --- /***************************************************************************/ /* */ /* t1tokens.h */ /* */ /* Type 1 tokenizer (specification). */ /* */ /* Copyright 1996-2001, 2002, 2003, 2004 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #undef FT_STRUCTURE #define FT_STRUCTURE PS_FontInfoRec #undef T1CODE #define T1CODE T1_FIELD_LOCATION_FONT_INFO T1_FIELD_STRING( "version", version ) T1_FIELD_STRING( "Notice", notice ) T1_FIELD_STRING( "FullName", full_name ) T1_FIELD_STRING( "FamilyName", family_name ) T1_FIELD_STRING( "Weight", weight ) /* we use pointers to detect modifications made by synthetic fonts */ T1_FIELD_NUM ( "ItalicAngle", italic_angle ) T1_FIELD_BOOL ( "isFixedPitch", is_fixed_pitch ) T1_FIELD_NUM ( "UnderlinePosition", underline_position ) T1_FIELD_NUM ( "UnderlineThickness", underline_thickness ) #undef FT_STRUCTURE #define FT_STRUCTURE PS_PrivateRec #undef T1CODE #define T1CODE T1_FIELD_LOCATION_PRIVATE T1_FIELD_NUM ( "UniqueID", unique_id ) T1_FIELD_NUM ( "lenIV", lenIV ) T1_FIELD_NUM ( "LanguageGroup", language_group ) T1_FIELD_NUM ( "password", password ) T1_FIELD_FIXED_1000( "BlueScale", blue_scale ) T1_FIELD_NUM ( "BlueShift", blue_shift ) T1_FIELD_NUM ( "BlueFuzz", blue_fuzz ) T1_FIELD_NUM_TABLE ( "BlueValues", blue_values, 14 ) T1_FIELD_NUM_TABLE ( "OtherBlues", other_blues, 10 ) T1_FIELD_NUM_TABLE ( "FamilyBlues", family_blues, 14 ) T1_FIELD_NUM_TABLE ( "FamilyOtherBlues", family_other_blues, 10 ) T1_FIELD_NUM_TABLE2( "StdHW", standard_width, 1 ) T1_FIELD_NUM_TABLE2( "StdVW", standard_height, 1 ) T1_FIELD_NUM_TABLE2( "MinFeature", min_feature, 2 ) T1_FIELD_NUM_TABLE ( "StemSnapH", snap_widths, 12 ) T1_FIELD_NUM_TABLE ( "StemSnapV", snap_heights, 12 ) T1_FIELD_FIXED ( "ExpansionFactor", expansion_factor ) #undef FT_STRUCTURE #define FT_STRUCTURE T1_FontRec #undef T1CODE #define T1CODE T1_FIELD_LOCATION_FONT_DICT T1_FIELD_KEY ( "FontName", font_name ) T1_FIELD_NUM ( "PaintType", paint_type ) T1_FIELD_NUM ( "FontType", font_type ) T1_FIELD_FIXED( "StrokeWidth", stroke_width ) #undef FT_STRUCTURE #define FT_STRUCTURE FT_BBox #undef T1CODE #define T1CODE T1_FIELD_LOCATION_BBOX T1_FIELD_BBOX("FontBBox", xMin ) /* END */ --- NEW FILE: module.mk --- # # FreeType 2 Type1 module definition # # Copyright 1996-2000 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, # and distributed under the terms of the FreeType project license, # LICENSE.TXT. By continuing to use, modify, or distribute this file you # indicate that you have read the license and understand and accept it # fully. make_module_list: add_type1_driver add_type1_driver: $(OPEN_DRIVER)t1_driver_class$(CLOSE_DRIVER) $(ECHO_DRIVER)type1 $(ECHO_DRIVER_DESC)Postscript font files with extension *.pfa or *.pfb$(ECHO_DRIVER_DONE) # EOF --- NEW FILE: t1afm.h --- /***************************************************************************/ /* */ /* t1afm.h */ /* */ /* AFM support for Type 1 fonts (specification). */ /* */ /* Copyright 1996-2001, 2002 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __T1AFM_H__ #define __T1AFM_H__ #include <ft2build.h> #include "t1objs.h" FT_BEGIN_HEADER typedef struct T1_Kern_Pair_ { FT_UInt glyph1; FT_UInt glyph2; FT_Vector kerning; } T1_Kern_Pair; typedef struct T1_AFM_ { FT_Int num_pairs; T1_Kern_Pair* kern_pairs; } T1_AFM; FT_LOCAL( FT_Error ) T1_Read_Metrics( FT_Face face, FT_Stream stream ); FT_LOCAL( void ) T1_Done_Metrics( FT_Memory memory, T1_AFM* afm ); FT_LOCAL( void ) T1_Get_Kerning( T1_AFM* afm, FT_UInt glyph1, FT_UInt glyph2, FT_Vector* kerning ); FT_END_HEADER #endif /* __T1AFM_H__ */ /* END */ --- NEW FILE: t1objs.h --- /***************************************************************************/ /* */ /* t1objs.h */ /* */ /* Type 1 objects manager (specification). */ /* */ /* Copyright 1996-2001, 2002 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __T1OBJS_H__ #define __T1OBJS_H__ #include <ft2build.h> #include FT_INTERNAL_OBJECTS_H #include FT_CONFIG_CONFIG_H #include FT_INTERNAL_TYPE1_TYPES_H FT_BEGIN_HEADER /* The following structures must be defined by the hinter */ typedef struct T1_Size_Hints_ T1_Size_Hints; typedef struct T1_Glyph_Hints_ T1_Glyph_Hints; /*************************************************************************/ /* */ /* <Type> */ /* T1_Driver */ /* */ /* <Description> */ /* A handle to a Type 1 driver object. */ /* */ typedef struct T1_DriverRec_ *T1_Driver; /*************************************************************************/ /* */ /* <Type> */ /* T1_Size */ /* */ /* <Description> */ /* A handle to a Type 1 size object. */ /* */ typedef struct T1_SizeRec_* T1_Size; /*************************************************************************/ /* */ /* <Type> */ /* T1_GlyphSlot */ /* */ /* <Description> */ /* A handle to a Type 1 glyph slot object. */ /* */ typedef struct T1_GlyphSlotRec_* T1_GlyphSlot; /*************************************************************************/ /* */ /* <Type> */ /* T1_CharMap */ /* */ /* <Description> */ /* A handle to a Type 1 character mapping object. */ /* */ /* <Note> */ /* The Type 1 format doesn't use a charmap but an encoding table. */ /* The driver is responsible for making up charmap objects */ /* corresponding to these tables. */ /* */ typedef struct T1_CharMapRec_* T1_CharMap; /*************************************************************************/ /* */ /* HERE BEGINS THE TYPE1 SPECIFIC STUFF */ /* */ /*************************************************************************/ /*************************************************************************/ /* */ /* <Type> */ /* T1_SizeRec */ /* */ /* <Description> */ /* Type 1 size record. */ /* */ typedef struct T1_SizeRec_ { FT_SizeRec root; } T1_SizeRec; FT_LOCAL( void ) T1_Size_Done( T1_Size size ); FT_LOCAL( FT_Error ) T1_Size_Reset( T1_Size size ); FT_LOCAL( FT_Error ) T1_Size_Init( T1_Size size ); /*************************************************************************/ /* */ /* <Type> */ /* T1_GlyphSlotRec */ /* */ /* <Description> */ /* Type 1 glyph slot record. */ /* */ typedef struct T1_GlyphSlotRec_ { FT_GlyphSlotRec root; FT_Bool hint; FT_Bool scaled; FT_Int max_points; FT_Int max_contours; FT_Fixed x_scale; FT_Fixed y_scale; } T1_GlyphSlotRec; FT_LOCAL( FT_Error ) T1_Face_Init( FT_Stream stream, T1_Face face, FT_Int face_index, FT_Int num_params, FT_Parameter* params ); FT_LOCAL( void ) T1_Face_Done( T1_Face face ); FT_LOCAL( FT_Error ) T1_GlyphSlot_Init( T1_GlyphSlot slot ); FT_LOCAL( void ) T1_GlyphSlot_Done( T1_GlyphSlot slot ); FT_LOCAL( FT_Error ) T1_Driver_Init( T1_Driver driver ); FT_LOCAL( void ) T1_Driver_Done( T1_Driver driver ); FT_END_HEADER #endif /* __T1OBJS_H__ */ /* END */ --- NEW FILE: t1parse.h --- /***************************************************************************/ /* */ /* t1parse.h */ /* */ /* Type 1 parser (specification). */ /* */ /* Copyright 1996-2001, 2002, 2003 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __T1PARSE_H__ #define __T1PARSE_H__ #include <ft2build.h> #include FT_INTERNAL_TYPE1_TYPES_H #include FT_INTERNAL_STREAM_H FT_BEGIN_HEADER /*************************************************************************/ /* */ /* <Struct> */ /* T1_ParserRec */ /* */ /* <Description> */ /* A PS_ParserRec is an object used to parse a Type 1 fonts very */ /* quickly. */ /* */ /* <Fields> */ /* root :: The root parser. */ /* */ /* stream :: The current input stream. */ /* */ /* base_dict :: A pointer to the top-level dictionary. */ /* */ /* base_len :: The length in bytes of the top dictionary. */ /* */ /* private_dict :: A pointer to the private dictionary. */ /* */ /* private_len :: The length in bytes of the private dictionary. */ /* */ /* in_pfb :: A boolean. Indicates that we are handling a PFB */ /* file. */ /* */ /* in_memory :: A boolean. Indicates a memory-based stream. */ /* */ /* single_block :: A boolean. Indicates that the private dictionary */ /* is stored in lieu of the base dictionary. */ /* */ typedef struct T1_ParserRec_ { PS_ParserRec root; FT_Stream stream; FT_Byte* base_dict; FT_Long base_len; FT_Byte* private_dict; FT_Long private_len; FT_Bool in_pfb; FT_Bool in_memory; FT_Bool single_block; } T1_ParserRec, *T1_Parser; #define T1_Add_Table( p, i, o, l ) (p)->funcs.add( (p), i, o, l ) #define T1_Done_Table( p ) \ do \ { \ if ( (p)->funcs.done ) \ (p)->funcs.done( p ); \ } while ( 0 ) #define T1_Release_Table( p ) \ do \ { \ if ( (p)->funcs.release ) \ (p)->funcs.release( p ); \ } while ( 0 ) #define T1_Skip_Spaces( p ) (p)->root.funcs.skip_spaces( &(p)->root ) #define T1_Skip_PS_Token( p ) (p)->root.funcs.skip_PS_token( &(p)->root ) #define T1_ToInt( p ) (p)->root.funcs.to_int( &(p)->root ) #define T1_ToFixed( p, t ) (p)->root.funcs.to_fixed( &(p)->root, t ) #define T1_ToCoordArray( p, m, c ) \ (p)->root.funcs.to_coord_array( &(p)->root, m, c ) #define T1_ToFixedArray( p, m, f, t ) \ (p)->root.funcs.to_fixed_array( &(p)->root, m, f, t ) #define T1_ToToken( p, t ) \ (p)->root.funcs.to_token( &(p)->root, t ) #define T1_ToTokenArray( p, t, m, c ) \ (p)->root.funcs.to_token_array( &(p)->root, t, m, c ) #define T1_Load_Field( p, f, o, m, pf ) \ (p)->root.funcs.load_field( &(p)->root, f, o, m, pf ) #define T1_Load_Field_Table( p, f, o, m, pf ) \ (p)->root.funcs.load_field_table( &(p)->root, f, o, m, pf ) FT_LOCAL( FT_Error ) T1_New_Parser( T1_Parser parser, FT_Stream stream, FT_Memory memory, PSAux_Service psaux ); FT_LOCAL( FT_Error ) T1_Get_Private_Dict( T1_Parser parser, PSAux_Service psaux ); FT_LOCAL( void ) T1_Finalize_Parser( T1_Parser parser ); FT_END_HEADER #endif /* __T1PARSE_H__ */ /* END */ --- NEW FILE: t1driver.h --- /***************************************************************************/ /* */ /* t1driver.h */ /* */ /* High-level Type 1 driver interface (specification). */ /* */ /* Copyright 1996-2001, 2002 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __T1DRIVER_H__ #define __T1DRIVER_H__ #include <ft2build.h> #include FT_INTERNAL_DRIVER_H FT_BEGIN_HEADER FT_EXPORT_VAR( const FT_Driver_ClassRec ) t1_driver_class; FT_END_HEADER #endif /* __T1DRIVER_H__ */ /* END */ |
From: Ehud S. <esh...@us...> - 2006-04-21 16:31:20
|
Update of /cvsroot/roadmap/roadmap_editor/src/freetype/src/cache In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28321/src/cache Added Files: Jamfile ftccback.h ftcerror.h rules.mk Log Message: Import freetype sources. --- NEW FILE: rules.mk --- # # FreeType 2 Cache configuration rules # # Copyright 2000, 2001, 2003, 2004 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, # and distributed under the terms of the FreeType project license, # LICENSE.TXT. By continuing to use, modify, or distribute this file you # indicate that you have read the license and understand and accept it # fully. # Cache driver directory # CACHE_DIR := $(SRC_DIR)/cache CACHE_H_DIR := $(PUBLIC_DIR)/cache # compilation flags for the driver # CACHE_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(CACHE_DIR)) # Cache driver sources (i.e., C files) # CACHE_DRV_SRC := $(CACHE_DIR)/ftcmru.c \ $(CACHE_DIR)/ftcmanag.c \ $(CACHE_DIR)/ftcbasic.c \ $(CACHE_DIR)/ftccache.c \ $(CACHE_DIR)/ftcglyph.c \ $(CACHE_DIR)/ftcsbits.c \ $(CACHE_DIR)/ftcimage.c \ $(CACHE_DIR)/ftccmap.c # Cache driver headers # CACHE_DRV_H := $(CACHE_H_DIR)/ftcmru.h \ $(CACHE_H_DIR)/ftcmanag.h \ $(CACHE_H_DIR)/ftcglyph.h \ $(CACHE_H_DIR)/ftcimage.h \ $(CACHE_H_DIR)/ftccmap.h \ $(CACHE_DIR)/ftcerror.h \ $(CACHE_DIR)/ftccback.h # Cache driver object(s) # # CACHE_DRV_OBJ_M is used during `multi' builds. # CACHE_DRV_OBJ_S is used during `single' builds. # CACHE_DRV_OBJ_M := $(CACHE_DRV_SRC:$(CACHE_DIR)/%.c=$(OBJ_DIR)/%.$O) CACHE_DRV_OBJ_S := $(OBJ_DIR)/ftcache.$O # Cache driver source file for single build # CACHE_DRV_SRC_S := $(CACHE_DIR)/ftcache.c # Cache driver - single object # $(CACHE_DRV_OBJ_S): $(CACHE_DRV_SRC_S) $(CACHE_DRV_SRC) \ $(FREETYPE_H) $(CACHE_DRV_H) $(CACHE_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(CACHE_DRV_SRC_S)) # Cache driver - multiple objects # $(OBJ_DIR)/%.$O: $(CACHE_DIR)/%.c $(FREETYPE_H) $(CACHE_DRV_H) $(CACHE_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<) # update main driver object lists # DRV_OBJS_S += $(CACHE_DRV_OBJ_S) DRV_OBJS_M += $(CACHE_DRV_OBJ_M) # EOF --- NEW FILE: Jamfile --- # FreeType 2 src/cache Jamfile # # Copyright 2001, 2003, 2004 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, # and distributed under the terms of the FreeType project license, # LICENSE.TXT. By continuing to use, modify, or distribute this file you # indicate that you have read the license and understand and accept it # fully. SubDir FT2_TOP $(FT2_SRC_DIR) cache ; # The file <freetype/ftcache.h> contains some macro definitions that are # later used in #include statements related to the cache sub-system. It # needs to be parsed through a HDRMACRO rule for macro definitions. # HDRMACRO [ FT2_SubDir include ftcache.h ] ; { local _sources ; if $(FT2_MULTI) { _sources = ftcmru ftcmanag ftccache ftcglyph ftcsbits ftcimage ftcbasic ftccmap ; } else { _sources = ftcache ; } Library $(FT2_LIB) : $(_sources).c ; } # end of src/cache Jamfile --- NEW FILE: ftcerror.h --- /***************************************************************************/ /* */ /* ftcerror.h */ /* */ /* Caching sub-system error codes (specification only). */ /* */ /* Copyright 2001 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ /*************************************************************************/ /* */ /* This file is used to define the caching sub-system error enumeration */ /* constants. */ /* */ /*************************************************************************/ #ifndef __FTCERROR_H__ #define __FTCERROR_H__ #include FT_MODULE_ERRORS_H #undef __FTERRORS_H__ #define FT_ERR_PREFIX FTC_Err_ #define FT_ERR_BASE FT_Mod_Err_Cache #include FT_ERRORS_H #endif /* __FTCERROR_H__ */ /* END */ --- NEW FILE: ftccback.h --- /***************************************************************************/ /* */ /* ftccback.h */ /* */ /* Callback functions of the caching sub-system (specification only). */ /* */ /* Copyright 2004 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __FTCCBACK_H__ #define __FTCCBACK_H__ #include <ft2build.h> #include FT_CACHE_H #include FT_CACHE_INTERNAL_MRU_H #include FT_CACHE_INTERNAL_IMAGE_H #include FT_CACHE_INTERNAL_MANAGER_H #include FT_CACHE_INTERNAL_GLYPH_H #include FT_CACHE_INTERNAL_SBITS_H FT_LOCAL( void ) ftc_inode_free( FTC_Node inode, FTC_Cache cache ); FT_LOCAL( FT_Error ) ftc_inode_new( FTC_Node *pinode, FT_Pointer gquery, FTC_Cache cache ); FT_LOCAL( FT_ULong ) ftc_inode_weight( FTC_Node inode, FTC_Cache cache ); FT_LOCAL( void ) ftc_snode_free( FTC_Node snode, FTC_Cache cache ); FT_LOCAL( FT_Error ) ftc_snode_new( FTC_Node *psnode, FT_Pointer gquery, FTC_Cache cache ); FT_LOCAL( FT_ULong ) ftc_snode_weight( FTC_Node snode, FTC_Cache cache ); FT_LOCAL( FT_Bool ) ftc_snode_compare( FTC_Node snode, FT_Pointer gquery, FTC_Cache cache ); FT_LOCAL( FT_Bool ) ftc_gnode_compare( FTC_Node gnode, FT_Pointer gquery, FTC_Cache cache ); FT_LOCAL( FT_Error ) ftc_gcache_init( FTC_Cache cache ); FT_LOCAL( void ) ftc_gcache_done( FTC_Cache cache ); FT_LOCAL( FT_Error ) ftc_cache_init( FTC_Cache cache ); FT_LOCAL( void ) ftc_cache_done( FTC_Cache cache ); #endif /* __FTCCBACK_H__ */ /* END */ |
Update of /cvsroot/roadmap/roadmap_editor/src/freetype/src/pshinter In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28321/src/pshinter Added Files: Jamfile module.mk pshalgo.h pshglob.h pshmod.h pshnterr.h pshrec.h rules.mk Log Message: Import freetype sources. --- NEW FILE: rules.mk --- # # FreeType 2 PSHinter driver configuration rules # # Copyright 2001, 2003 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, # and distributed under the terms of the FreeType project license, # LICENSE.TXT. By continuing to use, modify, or distribute this file you # indicate that you have read the license and understand and accept it # fully. # PSHINTER driver directory # PSHINTER_DIR := $(SRC_DIR)/pshinter # compilation flags for the driver # PSHINTER_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(PSHINTER_DIR)) # PSHINTER driver sources (i.e., C files) # PSHINTER_DRV_SRC := $(PSHINTER_DIR)/pshrec.c \ $(PSHINTER_DIR)/pshglob.c \ $(PSHINTER_DIR)/pshmod.c \ $(PSHINTER_DIR)/pshalgo.c # PSHINTER driver headers # PSHINTER_DRV_H := $(PSHINTER_DRV_SRC:%c=%h) \ $(PSHINTER_DIR)/pshnterr.h # PSHINTER driver object(s) # # PSHINTER_DRV_OBJ_M is used during `multi' builds. # PSHINTER_DRV_OBJ_S is used during `single' builds. # PSHINTER_DRV_OBJ_M := $(PSHINTER_DRV_SRC:$(PSHINTER_DIR)/%.c=$(OBJ_DIR)/%.$O) PSHINTER_DRV_OBJ_S := $(OBJ_DIR)/pshinter.$O # PSHINTER driver source file for single build # PSHINTER_DRV_SRC_S := $(PSHINTER_DIR)/pshinter.c # PSHINTER driver - single object # $(PSHINTER_DRV_OBJ_S): $(PSHINTER_DRV_SRC_S) $(PSHINTER_DRV_SRC) \ $(FREETYPE_H) $(PSHINTER_DRV_H) $(PSHINTER_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(PSHINTER_DRV_SRC_S)) # PSHINTER driver - multiple objects # $(OBJ_DIR)/%.$O: $(PSHINTER_DIR)/%.c $(FREETYPE_H) $(PSHINTER_DRV_H) $(PSHINTER_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<) # update main driver object lists # DRV_OBJS_S += $(PSHINTER_DRV_OBJ_S) DRV_OBJS_M += $(PSHINTER_DRV_OBJ_M) # EOF --- NEW FILE: Jamfile --- # FreeType 2 src/pshinter Jamfile # # Copyright 2001, 2003 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, # and distributed under the terms of the FreeType project license, # LICENSE.TXT. By continuing to use, modify, or distribute this file you # indicate that you have read the license and understand and accept it # fully. SubDir FT2_TOP $(FT2_SRC_DIR) pshinter ; { local _sources ; if $(FT2_MULTI) { _sources = pshrec pshglob pshalgo pshmod ; } else { _sources = pshinter ; } Library $(FT2_LIB) : $(_sources).c ; } # end of src/pshinter Jamfile --- NEW FILE: pshalgo.h --- /***************************************************************************/ /* */ /* pshalgo.h */ /* */ /* PostScript hinting algorithm (specification). */ /* */ /* Copyright 2001, 2002, 2003 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __PSHALGO_H__ #define __PSHALGO_H__ #include "pshrec.h" #include "pshglob.h" #include FT_TRIGONOMETRY_H FT_BEGIN_HEADER /* handle to Hint structure */ typedef struct PSH_HintRec_* PSH_Hint; /* hint bit-flags */ typedef enum { PSH_HINT_GHOST = PS_HINT_FLAG_GHOST, PSH_HINT_BOTTOM = PS_HINT_FLAG_BOTTOM, PSH_HINT_ACTIVE = 4, PSH_HINT_FITTED = 8 } PSH_Hint_Flags; #define psh_hint_is_active( x ) ( ( (x)->flags & PSH_HINT_ACTIVE ) != 0 ) #define psh_hint_is_ghost( x ) ( ( (x)->flags & PSH_HINT_GHOST ) != 0 ) #define psh_hint_is_fitted( x ) ( ( (x)->flags & PSH_HINT_FITTED ) != 0 ) #define psh_hint_activate( x ) (x)->flags |= PSH_HINT_ACTIVE #define psh_hint_deactivate( x ) (x)->flags &= ~PSH_HINT_ACTIVE #define psh_hint_set_fitted( x ) (x)->flags |= PSH_HINT_FITTED /* hint structure */ typedef struct PSH_HintRec_ { FT_Int org_pos; FT_Int org_len; FT_Pos cur_pos; FT_Pos cur_len; FT_UInt flags; PSH_Hint parent; FT_Int order; } PSH_HintRec; /* this is an interpolation zone used for strong points; */ /* weak points are interpolated according to their strong */ /* neighbours */ typedef struct PSH_ZoneRec_ { FT_Fixed scale; FT_Fixed delta; FT_Pos min; FT_Pos max; } PSH_ZoneRec, *PSH_Zone; typedef struct PSH_Hint_TableRec_ { FT_UInt max_hints; FT_UInt num_hints; PSH_Hint hints; PSH_Hint* sort; PSH_Hint* sort_global; FT_UInt num_zones; PSH_ZoneRec* zones; PSH_Zone zone; PS_Mask_Table hint_masks; PS_Mask_Table counter_masks; } PSH_Hint_TableRec, *PSH_Hint_Table; typedef struct PSH_PointRec_* PSH_Point; typedef struct PSH_ContourRec_* PSH_Contour; enum { PSH_DIR_NONE = 4, PSH_DIR_UP = -1, PSH_DIR_DOWN = 1, PSH_DIR_LEFT = -2, PSH_DIR_RIGHT = 2 }; #define PSH_DIR_HORIZONTAL 2 #define PSH_DIR_VERTICAL 1 #define PSH_DIR_COMPARE( d1, d2 ) ( (d1) == (d2) || (d1) == -(d2) ) #define PSH_DIR_IS_HORIZONTAL( d ) PSH_DIR_COMPARE( d, PSH_DIR_HORIZONTAL ) #define PSH_DIR_IS_VERTICAL( d ) PSH_DIR_COMPARE( d, PSH_DIR_VERTICAL ) /* the following bit-flags are computed once by the glyph */ /* analyzer, for both dimensions */ enum { PSH_POINT_OFF = 1, /* point is off the curve */ PSH_POINT_SMOOTH = 2, /* point is smooth */ PSH_POINT_INFLEX = 4 /* point is inflection */ }; #define psh_point_is_smooth( p ) ( (p)->flags & PSH_POINT_SMOOTH ) #define psh_point_is_off( p ) ( (p)->flags & PSH_POINT_OFF ) #define psh_point_is_inflex( p ) ( (p)->flags & PSH_POINT_INFLEX ) #define psh_point_set_smooth( p ) (p)->flags |= PSH_POINT_SMOOTH #define psh_point_set_off( p ) (p)->flags |= PSH_POINT_OFF #define psh_point_set_inflex( p ) (p)->flags |= PSH_POINT_INFLEX /* the following bit-flags are re-computed for each dimension */ enum { PSH_POINT_STRONG = 16, /* point is strong */ PSH_POINT_FITTED = 32, /* point is already fitted */ PSH_POINT_EXTREMUM = 64, /* point is local extremum */ PSH_POINT_POSITIVE = 128, /* extremum has positive contour flow */ PSH_POINT_NEGATIVE = 256, /* extremum has negative contour flow */ PSH_POINT_EDGE_MIN = 512, /* point is aligned to left/bottom stem edge */ PSH_POINT_EDGE_MAX = 1024 /* point is aligned to top/right stem edge */ }; #define psh_point_is_strong( p ) ( (p)->flags2 & PSH_POINT_STRONG ) #define psh_point_is_fitted( p ) ( (p)->flags2 & PSH_POINT_FITTED ) #define psh_point_is_extremum( p ) ( (p)->flags2 & PSH_POINT_EXTREMUM ) #define psh_point_is_positive( p ) ( (p)->flags2 & PSH_POINT_POSITIVE ) #define psh_point_is_negative( p ) ( (p)->flags2 & PSH_POINT_NEGATIVE ) #define psh_point_is_edge_min( p ) ( (p)->flags2 & PSH_POINT_EDGE_MIN ) #define psh_point_is_edge_max( p ) ( (p)->flags2 & PSH_POINT_EDGE_MAX ) #define psh_point_set_strong( p ) (p)->flags2 |= PSH_POINT_STRONG #define psh_point_set_fitted( p ) (p)->flags2 |= PSH_POINT_FITTED #define psh_point_set_extremum( p ) (p)->flags2 |= PSH_POINT_EXTREMUM #define psh_point_set_positive( p ) (p)->flags2 |= PSH_POINT_POSITIVE #define psh_point_set_negative( p ) (p)->flags2 |= PSH_POINT_NEGATIVE #define psh_point_set_edge_min( p ) (p)->flags2 |= PSH_POINT_EDGE_MIN #define psh_point_set_edge_max( p ) (p)->flags2 |= PSH_POINT_EDGE_MAX typedef struct PSH_PointRec_ { PSH_Point prev; PSH_Point next; PSH_Contour contour; FT_UInt flags; FT_UInt flags2; FT_Char dir_in; FT_Char dir_out; FT_Angle angle_in; FT_Angle angle_out; PSH_Hint hint; FT_Pos org_u; FT_Pos org_v; FT_Pos cur_u; #ifdef DEBUG_HINTER FT_Pos org_x; FT_Pos cur_x; FT_Pos org_y; FT_Pos cur_y; FT_UInt flags_x; FT_UInt flags_y; #endif } PSH_PointRec; #define PSH_POINT_EQUAL_ORG( a, b ) ( (a)->org_u == (b)->org_u && \ (a)->org_v == (b)->org_v ) #define PSH_POINT_ANGLE( a, b ) FT_Atan2( (b)->org_u - (a)->org_u, \ (b)->org_v - (a)->org_v ) typedef struct PSH_ContourRec_ { PSH_Point start; FT_UInt count; } PSH_ContourRec; typedef struct PSH_GlyphRec_ { FT_UInt num_points; FT_UInt num_contours; PSH_Point points; PSH_Contour contours; FT_Memory memory; FT_Outline* outline; PSH_Globals globals; PSH_Hint_TableRec hint_tables[2]; FT_Bool vertical; FT_Int major_dir; FT_Int minor_dir; FT_Bool do_horz_hints; FT_Bool do_vert_hints; FT_Bool do_horz_snapping; FT_Bool do_vert_snapping; FT_Bool do_stem_adjust; } PSH_GlyphRec, *PSH_Glyph; #ifdef DEBUG_HINTER extern PSH_Hint_Table ps_debug_hint_table; typedef void (*PSH_HintFunc)( PSH_Hint hint, FT_Bool vertical ); extern PSH_HintFunc ps_debug_hint_func; extern PSH_Glyph ps_debug_glyph; #endif extern FT_Error ps_hints_apply( PS_Hints ps_hints, FT_Outline* outline, PSH_Globals globals, FT_Render_Mode hint_mode ); FT_END_HEADER #endif /* __PSHALGO_H__ */ /* END */ --- NEW FILE: pshnterr.h --- /***************************************************************************/ /* */ /* pshnterr.h */ /* */ /* PS Hinter error codes (specification only). */ /* */ /* Copyright 2003 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ /*************************************************************************/ /* */ /* This file is used to define the PSHinter error enumeration constants. */ /* */ /*************************************************************************/ #ifndef __PSHNTERR_H__ #define __PSHNTERR_H__ #include FT_MODULE_ERRORS_H #undef __FTERRORS_H__ #define FT_ERR_PREFIX PSH_Err_ #define FT_ERR_BASE FT_Mod_Err_PShinter #include FT_ERRORS_H #endif /* __PSHNTERR_H__ */ /* END */ --- NEW FILE: pshrec.h --- /***************************************************************************/ /* */ /* pshrec.h */ /* */ /* Postscript (Type1/Type2) hints recorder (specification). */ /* */ /* Copyright 2001, 2002, 2003 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ /**************************************************************************/ /* */ /* The functions defined here are called from the Type 1, CID and CFF */ /* font drivers to record the hints of a given character/glyph. */ /* */ /* The hints are recorded in a unified format, and are later processed */ /* by the "optimizer" and "fitter" to adjust the outlines to the pixel */ /* grid. */ /* */ /**************************************************************************/ #ifndef __PSHREC_H__ #define __PSHREC_H__ #include <ft2build.h> #include FT_INTERNAL_POSTSCRIPT_HINTS_H #include "pshglob.h" FT_BEGIN_HEADER /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** GLYPH HINTS RECORDER INTERNALS *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ /* handle to hint record */ typedef struct PS_HintRec_* PS_Hint; /* hint types */ typedef enum { PS_HINT_TYPE_1 = 1, PS_HINT_TYPE_2 = 2 } PS_Hint_Type; /* hint flags */ typedef enum { PS_HINT_FLAG_GHOST = 1, PS_HINT_FLAG_BOTTOM = 2 } PS_Hint_Flags; /* hint descriptor */ typedef struct PS_HintRec_ { FT_Int pos; FT_Int len; FT_UInt flags; } PS_HintRec; #define ps_hint_is_active( x ) ( (x)->flags & PS_HINT_FLAG_ACTIVE ) #define ps_hint_is_ghost( x ) ( (x)->flags & PS_HINT_FLAG_GHOST ) #define ps_hint_is_bottom( x ) ( (x)->flags & PS_HINT_FLAG_BOTTOM ) /* hints table descriptor */ typedef struct PS_Hint_TableRec_ { FT_UInt num_hints; FT_UInt max_hints; PS_Hint hints; } PS_Hint_TableRec, *PS_Hint_Table; /* hint and counter mask descriptor */ typedef struct PS_MaskRec_ { FT_UInt num_bits; FT_UInt max_bits; FT_Byte* bytes; FT_UInt end_point; } PS_MaskRec, *PS_Mask; /* masks and counters table descriptor */ typedef struct PS_Mask_TableRec_ { FT_UInt num_masks; FT_UInt max_masks; PS_Mask masks; } PS_Mask_TableRec, *PS_Mask_Table; /* dimension-specific hints descriptor */ typedef struct PS_DimensionRec_ { PS_Hint_TableRec hints; PS_Mask_TableRec masks; PS_Mask_TableRec counters; } PS_DimensionRec, *PS_Dimension; /* glyph hints descriptor */ /* dimension 0 => X coordinates + vertical hints/stems */ /* dimension 1 => Y coordinates + horizontal hints/stems */ typedef struct PS_HintsRec_ { FT_Memory memory; FT_Error error; FT_UInt32 magic; PS_Hint_Type hint_type; PS_DimensionRec dimension[2]; } PS_HintsRec, *PS_Hints; /* */ /* initialize hints recorder */ FT_LOCAL( FT_Error ) ps_hints_init( PS_Hints hints, FT_Memory memory ); /* finalize hints recorder */ FT_LOCAL( void ) ps_hints_done( PS_Hints hints ); /* initialize Type1 hints recorder interface */ FT_LOCAL( void ) t1_hints_funcs_init( T1_Hints_FuncsRec* funcs ); /* initialize Type2 hints recorder interface */ FT_LOCAL( void ) t2_hints_funcs_init( T2_Hints_FuncsRec* funcs ); #ifdef DEBUG_HINTER extern PS_Hints ps_debug_hints; extern int ps_debug_no_horz_hints; extern int ps_debug_no_vert_hints; #endif /* */ FT_END_HEADER #endif /* __PS_HINTER_RECORD_H__ */ /* END */ --- NEW FILE: pshmod.h --- /***************************************************************************/ /* */ /* pshmod.h */ /* */ /* PostScript hinter module interface (specification). */ /* */ /* Copyright 2001 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __PSHMOD_H__ #define __PSHMOD_H__ #include <ft2build.h> #include FT_MODULE_H FT_BEGIN_HEADER FT_EXPORT_VAR( const FT_Module_Class ) pshinter_module_class; FT_END_HEADER #endif /* __PSHMOD_H__ */ /* END */ --- NEW FILE: module.mk --- # # FreeType 2 PSHinter module definition # # Copyright 1996-2001 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, # and distributed under the terms of the FreeType project license, # LICENSE.TXT. By continuing to use, modify, or distribute this file you # indicate that you have read the license and understand and accept it # fully. make_module_list: add_pshinter_module add_pshinter_module: $(OPEN_DRIVER)pshinter_module_class$(CLOSE_DRIVER) $(ECHO_DRIVER)pshinter $(ECHO_DRIVER_DESC)Postscript hinter module$(ECHO_DRIVER_DONE) # EOF --- NEW FILE: pshglob.h --- /***************************************************************************/ /* */ /* pshglob.h */ /* */ /* PostScript hinter global hinting management. */ /* */ /* Copyright 2001, 2002, 2003 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __PSHGLOB_H__ #define __PSHGLOB_H__ #include FT_FREETYPE_H #include FT_INTERNAL_POSTSCRIPT_HINTS_H FT_BEGIN_HEADER /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** GLOBAL HINTS INTERNALS *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ /* */ /* @constant: */ /* PS_GLOBALS_MAX_BLUE_ZONES */ /* */ /* @description: */ /* The maximum number of blue zones in a font global hints structure. */ /* See @PS_Globals_BluesRec. */ /* */ #define PS_GLOBALS_MAX_BLUE_ZONES 16 /*************************************************************************/ /* */ /* @constant: */ /* PS_GLOBALS_MAX_STD_WIDTHS */ /* */ /* @description: */ /* The maximum number of standard and snap widths in either the */ /* horizontal or vertical direction. See @PS_Globals_WidthsRec. */ /* */ #define PS_GLOBALS_MAX_STD_WIDTHS 16 /* standard and snap width */ typedef struct PSH_WidthRec_ { FT_Int org; FT_Pos cur; FT_Pos fit; } PSH_WidthRec, *PSH_Width; /* standard and snap widths table */ typedef struct PSH_WidthsRec_ { FT_UInt count; PSH_WidthRec widths[PS_GLOBALS_MAX_STD_WIDTHS]; } PSH_WidthsRec, *PSH_Widths; typedef struct PSH_DimensionRec_ { PSH_WidthsRec stdw; FT_Fixed scale_mult; FT_Fixed scale_delta; } PSH_DimensionRec, *PSH_Dimension; /* blue zone descriptor */ typedef struct PSH_Blue_ZoneRec_ { FT_Int org_ref; FT_Int org_delta; FT_Int org_top; FT_Int org_bottom; FT_Pos cur_ref; FT_Pos cur_delta; FT_Pos cur_bottom; FT_Pos cur_top; } PSH_Blue_ZoneRec, *PSH_Blue_Zone; typedef struct PSH_Blue_TableRec_ { FT_UInt count; PSH_Blue_ZoneRec zones[PS_GLOBALS_MAX_BLUE_ZONES]; } PSH_Blue_TableRec, *PSH_Blue_Table; /* blue zones table */ typedef struct PSH_BluesRec_ { PSH_Blue_TableRec normal_top; PSH_Blue_TableRec normal_bottom; PSH_Blue_TableRec family_top; PSH_Blue_TableRec family_bottom; FT_Fixed blue_scale; FT_Int blue_shift; FT_Int blue_threshold; FT_Int blue_fuzz; FT_Bool no_overshoots; } PSH_BluesRec, *PSH_Blues; /* font globals. */ /* dimension 0 => X coordinates + vertical hints/stems */ /* dimension 1 => Y coordinates + horizontal hints/stems */ typedef struct PSH_GlobalsRec_ { FT_Memory memory; PSH_DimensionRec dimension[2]; PSH_BluesRec blues; } PSH_GlobalsRec; #define PSH_BLUE_ALIGN_NONE 0 #define PSH_BLUE_ALIGN_TOP 1 #define PSH_BLUE_ALIGN_BOT 2 typedef struct PSH_AlignmentRec_ { int align; FT_Pos align_top; FT_Pos align_bot; } PSH_AlignmentRec, *PSH_Alignment; FT_LOCAL( void ) psh_globals_funcs_init( PSH_Globals_FuncsRec* funcs ); #if 0 /* snap a stem width to fitter coordinates. `org_width' is in font */ /* units. The result is in device pixels (26.6 format). */ FT_LOCAL( FT_Pos ) psh_dimension_snap_width( PSH_Dimension dimension, FT_Int org_width ); #endif FT_LOCAL( FT_Error ) psh_globals_set_scale( PSH_Globals globals, FT_Fixed x_scale, FT_Fixed y_scale, FT_Fixed x_delta, FT_Fixed y_delta ); /* snap a stem to one or two blue zones */ FT_LOCAL( void ) psh_blues_snap_stem( PSH_Blues blues, FT_Int stem_top, FT_Int stem_bot, PSH_Alignment alignment ); /* */ #ifdef DEBUG_HINTER extern PSH_Globals ps_debug_globals; #endif FT_END_HEADER #endif /* __PSHGLOB_H__ */ /* END */ |
From: Ehud S. <esh...@us...> - 2006-04-21 16:31:19
|
Update of /cvsroot/roadmap/roadmap_editor/src/freetype/src/sfnt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28321/src/sfnt Added Files: Jamfile module.mk rules.mk sfdriver.h sferrors.h sfobjs.h ttcmap.h ttkern.h ttload.h ttpost.h ttsbit.h ttsbit0.h Log Message: Import freetype sources. --- NEW FILE: rules.mk --- # # FreeType 2 SFNT driver configuration rules # # Copyright 1996-2000, 2002, 2003, 2004, 2005 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, # and distributed under the terms of the FreeType project license, # LICENSE.TXT. By continuing to use, modify, or distribute this file you # indicate that you have read the license and understand and accept it # fully. # SFNT driver directory # SFNT_DIR := $(SRC_DIR)/sfnt # compilation flags for the driver # SFNT_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(SFNT_DIR)) # SFNT driver sources (i.e., C files) # SFNT_DRV_SRC := $(SFNT_DIR)/ttload.c \ $(SFNT_DIR)/ttcmap.c \ $(SFNT_DIR)/ttsbit.c \ $(SFNT_DIR)/ttpost.c \ $(SFNT_DIR)/ttkern.c \ $(SFNT_DIR)/sfobjs.c \ $(SFNT_DIR)/sfdriver.c # SFNT driver headers # SFNT_DRV_H := $(SFNT_DRV_SRC:%c=%h) \ $(SFNT_DIR)/sferrors.h # SFNT driver object(s) # # SFNT_DRV_OBJ_M is used during `multi' builds. # SFNT_DRV_OBJ_S is used during `single' builds. # SFNT_DRV_OBJ_M := $(SFNT_DRV_SRC:$(SFNT_DIR)/%.c=$(OBJ_DIR)/%.$O) SFNT_DRV_OBJ_S := $(OBJ_DIR)/sfnt.$O # SFNT driver source file for single build # SFNT_DRV_SRC_S := $(SFNT_DIR)/sfnt.c # SFNT driver - single object # $(SFNT_DRV_OBJ_S): $(SFNT_DRV_SRC_S) $(SFNT_DRV_SRC) \ $(FREETYPE_H) $(SFNT_DRV_H) $(SFNT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(SFNT_DRV_SRC_S)) # SFNT driver - multiple objects # $(OBJ_DIR)/%.$O: $(SFNT_DIR)/%.c $(FREETYPE_H) $(SFNT_DRV_H) $(SFNT_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<) # update main driver object lists # DRV_OBJS_S += $(SFNT_DRV_OBJ_S) DRV_OBJS_M += $(SFNT_DRV_OBJ_M) # EOF --- NEW FILE: sferrors.h --- /***************************************************************************/ /* */ /* sferrors.h */ /* */ /* SFNT error codes (specification only). */ /* */ /* Copyright 2001, 2004 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ /*************************************************************************/ /* */ /* This file is used to define the SFNT error enumeration constants. */ /* */ /*************************************************************************/ #ifndef __SFERRORS_H__ #define __SFERRORS_H__ #include FT_MODULE_ERRORS_H #undef __FTERRORS_H__ #define FT_ERR_PREFIX SFNT_Err_ #define FT_ERR_BASE FT_Mod_Err_SFNT #define FT_KEEP_ERR_PREFIX #include FT_ERRORS_H #endif /* __SFERRORS_H__ */ /* END */ --- NEW FILE: ttpost.h --- /***************************************************************************/ /* */ /* ttpost.h */ /* */ /* Postcript name table processing for TrueType and OpenType fonts */ /* (specification). */ /* */ /* Copyright 1996-2001, 2002 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __TTPOST_H__ #define __TTPOST_H__ #include <ft2build.h> #include FT_CONFIG_CONFIG_H #include FT_INTERNAL_TRUETYPE_TYPES_H FT_BEGIN_HEADER FT_LOCAL( FT_Error ) tt_face_get_ps_name( TT_Face face, FT_UInt idx, FT_String** PSname ); FT_LOCAL( void ) tt_face_free_ps_names( TT_Face face ); FT_END_HEADER #endif /* __TTPOST_H__ */ /* END */ --- NEW FILE: Jamfile --- # FreeType 2 src/sfnt Jamfile # # Copyright 2001, 2002, 2004, 2005 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, # and distributed under the terms of the FreeType project license, # LICENSE.TXT. By continuing to use, modify, or distribute this file you # indicate that you have read the license and understand and accept it # fully. SubDir FT2_TOP $(FT2_SRC_DIR) sfnt ; { local _sources ; if $(FT2_MULTI) { _sources = sfobjs sfdriver ttcmap ttpost ttload ttsbit ttkern ; } else { _sources = sfnt ; } Library $(FT2_LIB) : $(_sources).c ; } # end of src/sfnt Jamfile --- NEW FILE: ttcmap.h --- /***************************************************************************/ /* */ /* ttcmap.h */ /* */ /* TrueType character mapping table (cmap) support (specification). */ /* */ /* Copyright 2002, 2003, 2004, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __TTCMAP_H__ #define __TTCMAP_H__ #include <ft2build.h> #include FT_INTERNAL_TRUETYPE_TYPES_H #include FT_INTERNAL_VALIDATE_H #include FT_SERVICE_TT_CMAP_H FT_BEGIN_HEADER typedef struct TT_CMapRec_ { FT_CMapRec cmap; FT_Byte* data; /* pointer to in-memory cmap table */ FT_Bool unsorted; /* for format 4 only */ } TT_CMapRec, *TT_CMap; typedef const struct TT_CMap_ClassRec_* TT_CMap_Class; typedef FT_Error (*TT_CMap_ValidateFunc)( FT_Byte* data, FT_Validator valid ); typedef struct TT_CMap_ClassRec_ { FT_CMap_ClassRec clazz; FT_UInt format; TT_CMap_ValidateFunc validate; TT_CMap_Info_GetFunc get_cmap_info; } TT_CMap_ClassRec; typedef struct TT_ValidatorRec_ { FT_ValidatorRec validator; FT_UInt num_glyphs; } TT_ValidatorRec, *TT_Validator; #define TT_VALIDATOR( x ) ((TT_Validator)( x )) #define TT_VALID_GLYPH_COUNT( x ) TT_VALIDATOR( x )->num_glyphs FT_LOCAL( FT_Error ) tt_face_build_cmaps( TT_Face face ); /* used in tt-cmaps service */ FT_LOCAL( FT_Error ) tt_get_cmap_info( FT_CharMap charmap, TT_CMapInfo *cmap_info ); FT_END_HEADER #endif /* __TTCMAP_H__ */ /* END */ --- NEW FILE: ttkern.h --- /***************************************************************************/ /* */ /* ttkern.h */ /* */ /* Load the basic TrueType kerning table. This doesn't handle */ /* kerning data within the GPOS table at the moment. */ /* */ /* Copyright 1996-2001, 2002, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __TTKERN_H__ #define __TTKERN_H__ #include <ft2build.h> #include FT_INTERNAL_STREAM_H #include FT_INTERNAL_TRUETYPE_TYPES_H FT_BEGIN_HEADER FT_LOCAL( FT_Error ) tt_face_load_kern( TT_Face face, FT_Stream stream ); FT_LOCAL( void ) tt_face_done_kern( TT_Face face ); FT_LOCAL( FT_Int ) tt_face_get_kerning( TT_Face face, FT_UInt left_glyph, FT_UInt right_glyph ); #ifdef FT_OPTIMIZE_MEMORY # define TT_FACE_HAS_KERNING( face ) ( (face)->kern_avail_bits != 0 ) #else # define TT_FACE_HAS_KERNING( face ) ( (face)->kern_pairs != NULL ) #endif FT_END_HEADER #endif /* __TTKERN_H__ */ /* END */ --- NEW FILE: module.mk --- # # FreeType 2 SFNT module definition # # Copyright 1996-2000 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, # and distributed under the terms of the FreeType project license, # LICENSE.TXT. By continuing to use, modify, or distribute this file you # indicate that you have read the license and understand and accept it # fully. make_module_list: add_sfnt_module add_sfnt_module: $(OPEN_DRIVER)sfnt_module_class$(CLOSE_DRIVER) $(ECHO_DRIVER)sfnt $(ECHO_DRIVER_DESC)helper module for TrueType & OpenType formats$(ECHO_DRIVER_DONE) # EOF --- NEW FILE: ttsbit.h --- /***************************************************************************/ /* */ /* ttsbit.h */ /* */ /* TrueType and OpenType embedded bitmap support (specification). */ /* */ /* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __TTSBIT_H__ #define __TTSBIT_H__ #include <ft2build.h> #include "ttload.h" FT_BEGIN_HEADER FT_LOCAL( FT_Error ) tt_face_load_sbit_strikes( TT_Face face, FT_Stream stream ); FT_LOCAL( void ) tt_face_free_sbit_strikes( TT_Face face ); FT_LOCAL( FT_Error ) tt_face_set_sbit_strike( TT_Face face, FT_UInt x_ppem, FT_UInt y_ppem, FT_ULong *astrike_index ); #ifndef FT_OPTIMIZE_MEMORY FT_LOCAL( FT_Error ) tt_find_sbit_image( TT_Face face, FT_UInt glyph_index, FT_ULong strike_index, TT_SBit_Range *arange, TT_SBit_Strike *astrike, FT_ULong *aglyph_offset ); FT_LOCAL( FT_Error ) tt_load_sbit_metrics( FT_Stream stream, TT_SBit_Range range, TT_SBit_Metrics metrics ); #endif /* !FT_OPTIMIZE_MEMORY */ FT_LOCAL( FT_Error ) tt_face_load_sbit_image( TT_Face face, FT_ULong strike_index, FT_UInt glyph_index, FT_UInt load_flags, FT_Stream stream, FT_Bitmap *map, TT_SBit_MetricsRec *metrics ); FT_END_HEADER #endif /* __TTSBIT_H__ */ /* END */ --- NEW FILE: sfobjs.h --- /***************************************************************************/ /* */ /* sfobjs.h */ /* */ /* SFNT object management (specification). */ /* */ /* Copyright 1996-2001, 2002 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __SFOBJS_H__ #define __SFOBJS_H__ #include <ft2build.h> #include FT_INTERNAL_SFNT_H #include FT_INTERNAL_OBJECTS_H FT_BEGIN_HEADER FT_LOCAL( FT_Error ) sfnt_init_face( FT_Stream stream, TT_Face face, FT_Int face_index, FT_Int num_params, FT_Parameter* params ); FT_LOCAL( FT_Error ) sfnt_load_face( FT_Stream stream, TT_Face face, FT_Int face_index, FT_Int num_params, FT_Parameter* params ); FT_LOCAL( void ) sfnt_done_face( TT_Face face ); FT_END_HEADER #endif /* __SFDRIVER_H__ */ /* END */ --- NEW FILE: sfdriver.h --- /***************************************************************************/ /* */ /* sfdriver.h */ /* */ /* High-level SFNT driver interface (specification). */ /* */ /* Copyright 1996-2001 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __SFDRIVER_H__ #define __SFDRIVER_H__ #include <ft2build.h> #include FT_MODULE_H FT_BEGIN_HEADER FT_EXPORT_VAR( const FT_Module_Class ) sfnt_module_class; FT_END_HEADER #endif /* __SFDRIVER_H__ */ /* END */ --- NEW FILE: ttload.h --- /***************************************************************************/ /* */ /* ttload.h */ /* */ /* Load the basic TrueType tables, i.e., tables that can be either in */ /* TTF or OTF fonts (specification). */ /* */ /* Copyright 1996-2001, 2002, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __TTLOAD_H__ #define __TTLOAD_H__ #include <ft2build.h> #include FT_INTERNAL_STREAM_H #include FT_INTERNAL_TRUETYPE_TYPES_H FT_BEGIN_HEADER FT_LOCAL( TT_Table ) tt_face_lookup_table( TT_Face face, FT_ULong tag ); FT_LOCAL( FT_Error ) tt_face_goto_table( TT_Face face, FT_ULong tag, FT_Stream stream, FT_ULong* length ); FT_LOCAL( FT_Error ) tt_face_load_sfnt_header( TT_Face face, FT_Stream stream, FT_Long face_index, SFNT_Header sfnt ); FT_LOCAL( FT_Error ) tt_face_load_directory( TT_Face face, FT_Stream stream, SFNT_Header sfnt ); FT_LOCAL( FT_Error ) tt_face_load_any( TT_Face face, FT_ULong tag, FT_Long offset, FT_Byte* buffer, FT_ULong* length ); FT_LOCAL( FT_Error ) tt_face_load_header( TT_Face face, FT_Stream stream ); FT_LOCAL( FT_Error ) tt_face_load_metrics_header( TT_Face face, FT_Stream stream, FT_Bool vertical ); FT_LOCAL( FT_Error ) tt_face_load_cmap( TT_Face face, FT_Stream stream ); FT_LOCAL( FT_Error ) tt_face_load_max_profile( TT_Face face, FT_Stream stream ); FT_LOCAL( FT_Error ) tt_face_load_names( TT_Face face, FT_Stream stream ); FT_LOCAL( FT_Error ) tt_face_load_os2( TT_Face face, FT_Stream stream ); FT_LOCAL( FT_Error ) tt_face_load_postscript( TT_Face face, FT_Stream stream ); FT_LOCAL( FT_Error ) tt_face_load_hdmx( TT_Face face, FT_Stream stream ); FT_LOCAL( FT_Error ) tt_face_load_pclt( TT_Face face, FT_Stream stream ); FT_LOCAL( void ) tt_face_free_names( TT_Face face ); FT_LOCAL( void ) tt_face_free_hdmx ( TT_Face face ); FT_LOCAL( FT_Error ) tt_face_load_gasp( TT_Face face, FT_Stream stream ); #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS FT_LOCAL( FT_Error ) tt_face_load_bitmap_header( TT_Face face, FT_Stream stream ); #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ FT_END_HEADER #endif /* __TTLOAD_H__ */ /* END */ --- NEW FILE: ttsbit0.h --- /* * ttsbit0.h * * This is a dummy file, used to please the build system. It is never * included by the sfnt sources. * */ |
From: Ehud S. <esh...@us...> - 2006-04-21 16:31:19
|
Update of /cvsroot/roadmap/roadmap_editor/src/freetype/src/bdf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28321/src/bdf Added Files: Jamfile bdf.h bdfdrivr.h bdferror.h module.mk rules.mk Log Message: Import freetype sources. --- NEW FILE: rules.mk --- # # FreeType 2 bdf driver configuration rules # # Copyright (C) 2001, 2002, 2003 by # Francesco Zappa Nardelli # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. # bdf driver directory # BDF_DIR := $(SRC_DIR)/bdf BDF_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(BDF_DIR)) # bdf driver sources (i.e., C files) # BDF_DRV_SRC := $(BDF_DIR)/bdflib.c \ $(BDF_DIR)/bdfdrivr.c # bdf driver headers # BDF_DRV_H := $(BDF_DIR)/bdf.h \ $(BDF_DIR)/bdfdrivr.h # bdf driver object(s) # # BDF_DRV_OBJ_M is used during `multi' builds # BDF_DRV_OBJ_S is used during `single' builds # BDF_DRV_OBJ_M := $(BDF_DRV_SRC:$(BDF_DIR)/%.c=$(OBJ_DIR)/%.$O) BDF_DRV_OBJ_S := $(OBJ_DIR)/bdf.$O # bdf driver source file for single build # BDF_DRV_SRC_S := $(BDF_DIR)/bdf.c # bdf driver - single object # $(BDF_DRV_OBJ_S): $(BDF_DRV_SRC_S) $(BDF_DRV_SRC) $(FREETYPE_H) $(BDF_DRV_H) $(BDF_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(BDF_DRV_SRC_S)) # bdf driver - multiple objects # $(OBJ_DIR)/%.$O: $(BDF_DIR)/%.c $(FREETYPE_H) $(BDF_DRV_H) $(BDF_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<) # update main driver object lists # DRV_OBJS_S += $(BDF_DRV_OBJ_S) DRV_OBJS_M += $(BDF_DRV_OBJ_M) # EOF --- NEW FILE: Jamfile --- # FreeType 2 src/bdf Jamfile # # Copyright 2002 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, # and distributed under the terms of the FreeType project license, # LICENSE.TXT. By continuing to use, modify, or distribute this file you # indicate that you have read the license and understand and accept it # fully. SubDir FT2_TOP $(FT2_SRC_DIR) bdf ; { local _sources ; if $(FT2_MULTI) { _sources = bdfdrivr bdflib ; } else { _sources = bdf ; } Library $(FT2_LIB) : $(_sources).c ; } # end of src/bdf Jamfile --- NEW FILE: bdf.h --- /* * Copyright 2000 Computing Research Labs, New Mexico State University * Copyright 2001, 2002, 2003, 2004 Francesco Zappa Nardelli * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef __BDF_H__ #define __BDF_H__ /* * Based on bdf.h,v 1.16 2000/03/16 20:08:51 mleisher */ #include <ft2build.h> #include FT_INTERNAL_OBJECTS_H #include FT_INTERNAL_STREAM_H FT_BEGIN_HEADER /* Imported from bdfP.h */ #define _bdf_glyph_modified( map, e ) \ ( (map)[(e) >> 5] & ( 1 << ( (e) & 31 ) ) ) #define _bdf_set_glyph_modified( map, e ) \ ( (map)[(e) >> 5] |= ( 1 << ( (e) & 31 ) ) ) #define _bdf_clear_glyph_modified( map, e ) \ ( (map)[(e) >> 5] &= ~( 1 << ( (e) & 31 ) ) ) /* end of bdfP.h */ /*************************************************************************/ /* */ /* BDF font options macros and types. */ /* */ /*************************************************************************/ #define BDF_CORRECT_METRICS 0x01 /* Correct invalid metrics when loading. */ #define BDF_KEEP_COMMENTS 0x02 /* Preserve the font comments. */ #define BDF_KEEP_UNENCODED 0x04 /* Keep the unencoded glyphs. */ #define BDF_PROPORTIONAL 0x08 /* Font has proportional spacing. */ #define BDF_MONOWIDTH 0x10 /* Font has mono width. */ #define BDF_CHARCELL 0x20 /* Font has charcell spacing. */ #define BDF_ALL_SPACING ( BDF_PROPORTIONAL | \ BDF_MONOWIDTH | \ BDF_CHARCELL ) #define BDF_DEFAULT_LOAD_OPTIONS ( BDF_CORRECT_METRICS | \ BDF_KEEP_COMMENTS | \ BDF_KEEP_UNENCODED | \ BDF_PROPORTIONAL ) typedef struct bdf_options_t_ { int correct_metrics; int keep_unencoded; int keep_comments; int font_spacing; } bdf_options_t; /* Callback function type for unknown configuration options. */ typedef int (*bdf_options_callback_t)( bdf_options_t* opts, char** params, unsigned long nparams, void* client_data ); /*************************************************************************/ /* */ /* BDF font property macros and types. */ /* */ /*************************************************************************/ #define BDF_ATOM 1 #define BDF_INTEGER 2 #define BDF_CARDINAL 3 /* This structure represents a particular property of a font. */ /* There are a set of defaults and each font has their own. */ typedef struct bdf_property_t_ { char* name; /* Name of the property. */ int format; /* Format of the property. */ int builtin; /* A builtin property. */ union { char* atom; long int32; unsigned long card32; } value; /* Value of the property. */ } bdf_property_t; /*************************************************************************/ /* */ /* BDF font metric and glyph types. */ /* */ /*************************************************************************/ typedef struct bdf_bbx_t_ { unsigned short width; unsigned short height; short x_offset; short y_offset; short ascent; short descent; } bdf_bbx_t; typedef struct bdf_glyph_t_ { char* name; /* Glyph name. */ long encoding; /* Glyph encoding. */ unsigned short swidth; /* Scalable width. */ unsigned short dwidth; /* Device width. */ bdf_bbx_t bbx; /* Glyph bounding box. */ unsigned char* bitmap; /* Glyph bitmap. */ unsigned long bpr; /* Number of bytes used per row. */ unsigned short bytes; /* Number of bytes used for the bitmap. */ } bdf_glyph_t; typedef struct _hashnode_ { const char* key; void* data; } _hashnode, *hashnode; typedef struct hashtable_ { int limit; int size; int used; hashnode* table; } hashtable; typedef struct bdf_glyphlist_t_ { unsigned short pad; /* Pad to 4-byte boundary. */ unsigned short bpp; /* Bits per pixel. */ long start; /* Beginning encoding value of glyphs. */ long end; /* Ending encoding value of glyphs. */ bdf_glyph_t* glyphs; /* Glyphs themselves. */ unsigned long glyphs_size; /* Glyph structures allocated. */ unsigned long glyphs_used; /* Glyph structures used. */ bdf_bbx_t bbx; /* Overall bounding box of glyphs. */ } bdf_glyphlist_t; typedef struct bdf_font_t_ { char* name; /* Name of the font. */ bdf_bbx_t bbx; /* Font bounding box. */ long point_size; /* Point size of the font. */ unsigned long resolution_x; /* Font horizontal resolution. */ unsigned long resolution_y; /* Font vertical resolution. */ int spacing; /* Font spacing value. */ unsigned short monowidth; /* Logical width for monowidth font. */ long default_char; /* Encoding of the default glyph. */ long font_ascent; /* Font ascent. */ long font_descent; /* Font descent. */ unsigned long glyphs_size; /* Glyph structures allocated. */ unsigned long glyphs_used; /* Glyph structures used. */ bdf_glyph_t* glyphs; /* Glyphs themselves. */ unsigned long unencoded_size; /* Unencoded glyph struct. allocated. */ unsigned long unencoded_used; /* Unencoded glyph struct. used. */ bdf_glyph_t* unencoded; /* Unencoded glyphs themselves. */ unsigned long props_size; /* Font properties allocated. */ unsigned long props_used; /* Font properties used. */ bdf_property_t* props; /* Font properties themselves. */ char* comments; /* Font comments. */ unsigned long comments_len; /* Length of comment string. */ bdf_glyphlist_t overflow; /* Storage used for glyph insertion. */ void* internal; /* Internal data for the font. */ unsigned long nmod[2048]; /* Bitmap indicating modified glyphs. */ unsigned long umod[2048]; /* Bitmap indicating modified */ /* unencoded glyphs. */ unsigned short modified; /* Boolean indicating font modified. */ unsigned short bpp; /* Bits per pixel. */ FT_Memory memory; bdf_property_t* user_props; unsigned long nuser_props; hashtable proptbl; } bdf_font_t; /*************************************************************************/ /* */ /* Types for load/save callbacks. */ /* */ /*************************************************************************/ /* Error codes. */ #define BDF_MISSING_START -1 #define BDF_MISSING_FONTNAME -2 #define BDF_MISSING_SIZE -3 #define BDF_MISSING_CHARS -4 #define BDF_MISSING_STARTCHAR -5 #define BDF_MISSING_ENCODING -6 #define BDF_MISSING_BBX -7 #define BDF_OUT_OF_MEMORY -20 #define BDF_INVALID_LINE -100 /*************************************************************************/ /* */ /* BDF font API. */ /* */ /*************************************************************************/ FT_LOCAL( FT_Error ) bdf_load_font( FT_Stream stream, FT_Memory memory, bdf_options_t* opts, bdf_font_t* *font ); FT_LOCAL( void ) bdf_free_font( bdf_font_t* font ); FT_LOCAL( bdf_property_t * ) bdf_get_property( char* name, bdf_font_t* font ); FT_LOCAL( bdf_property_t * ) bdf_get_font_property( bdf_font_t* font, const char* name ); FT_END_HEADER #endif /* __BDF_H__ */ /* END */ --- NEW FILE: bdferror.h --- /* * Copyright 2001, 2002 Francesco Zappa Nardelli * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ /* */ /* This file is used to define the BDF error enumeration constants. */ /* */ /*************************************************************************/ #ifndef __BDFERROR_H__ #define __BDFERROR_H__ #include FT_MODULE_ERRORS_H #undef __FTERRORS_H__ #define FT_ERR_PREFIX BDF_Err_ #define FT_ERR_BASE FT_Mod_Err_BDF #include FT_ERRORS_H #endif /* __BDFERROR_H__ */ /* END */ --- NEW FILE: module.mk --- # # FreeType 2 BDF module definition # # Copyright 2001, 2002 by # Francesco Zappa Nardelli # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. make_module_list: add_bdf_driver add_bdf_driver: $(OPEN_DRIVER)bdf_driver_class$(CLOSE_DRIVER) $(ECHO_DRIVER)bdf $(ECHO_DRIVER_DESC)bdf bitmap fonts$(ECHO_DRIVER_DONE) --- NEW FILE: bdfdrivr.h --- /* bdfdrivr.h FreeType font driver for bdf fonts Copyright (C) 2001, 2002, 2003, 2004 by Francesco Zappa Nardelli Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef __BDFDRIVR_H__ #define __BDFDRIVR_H__ #include <ft2build.h> #include FT_INTERNAL_DRIVER_H #include "bdf.h" FT_BEGIN_HEADER typedef struct BDF_encoding_el_ { FT_ULong enc; FT_UShort glyph; } BDF_encoding_el; typedef struct BDF_FaceRec_ { FT_FaceRec root; char* charset_encoding; char* charset_registry; bdf_font_t* bdffont; BDF_encoding_el* en_table; FT_CharMap charmap_handle; FT_CharMapRec charmap; /* a single charmap per face */ FT_UInt default_glyph; } BDF_FaceRec, *BDF_Face; FT_EXPORT_VAR( const FT_Driver_ClassRec ) bdf_driver_class; FT_END_HEADER #endif /* __BDFDRIVR_H__ */ /* END */ |
From: Ehud S. <esh...@us...> - 2006-04-21 16:31:18
|
Update of /cvsroot/roadmap/roadmap_editor/src/freetype/src/autofit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28321/src/autofit Added Files: Jamfile afangles.h afdummy.h aferrors.h afglobal.h afhints.h aflatin.h afloader.h afmodule.h aftypes.h module.mk rules.mk Log Message: Import freetype sources. --- NEW FILE: rules.mk --- # # FreeType 2 auto-fitter module configuration rules # # Copyright 2003, 2004, 2005 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, # and distributed under the terms of the FreeType project license, # LICENSE.TXT. By continuing to use, modify, or distribute this file you # indicate that you have read the license and understand and accept it # fully. # AUTOF driver directory # AUTOF_DIR := $(SRC_DIR)/autofit # compilation flags for the driver # AUTOF_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(AUTOF_DIR)) # AUTOF driver sources (i.e., C files) # AUTOF_DRV_SRC := $(AUTOF_DIR)/afangles.c \ $(AUTOF_DIR)/afdummy.c \ $(AUTOF_DIR)/afglobal.c \ $(AUTOF_DIR)/afhints.c \ $(AUTOF_DIR)/aflatin.c \ $(AUTOF_DIR)/afloader.c \ $(AUTOF_DIR)/afmodule.c # AUTOF driver headers # AUTOF_DRV_H := $(AUTOF_DRV_SRC:%c=%h) \ $(AUTOF_DIR)/aftypes.h \ $(AUTOF_DIR)/aferrors.h # AUTOF driver object(s) # # AUTOF_DRV_OBJ_M is used during `multi' builds. # AUTOF_DRV_OBJ_S is used during `single' builds. # AUTOF_DRV_OBJ_M := $(AUTOF_DRV_SRC:$(AUTOF_DIR)/%.c=$(OBJ_DIR)/%.$O) AUTOF_DRV_OBJ_S := $(OBJ_DIR)/autofit.$O # AUTOF driver source file for single build # AUTOF_DRV_SRC_S := $(AUTOF_DIR)/autofit.c # AUTOF driver - single object # $(AUTOF_DRV_OBJ_S): $(AUTOF_DRV_SRC_S) $(AUTOF_DRV_SRC) \ $(FREETYPE_H) $(AUTOF_DRV_H) $(AUTOF_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(AUTOF_DRV_SRC_S)) # AUTOF driver - multiple objects # $(OBJ_DIR)/%.$O: $(AUTOF_DIR)/%.c $(FREETYPE_H) $(AUTOF_DRV_H) $(AUTOF_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<) # update main driver object lists # DRV_OBJS_S += $(AUTOF_DRV_OBJ_S) DRV_OBJS_M += $(AUTOF_DRV_OBJ_M) # EOF --- NEW FILE: afloader.h --- /***************************************************************************/ /* */ /* afloader.h */ /* */ /* Auto-fitter glyph loading routines (specification). */ /* */ /* Copyright 2003, 2004, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __AF_LOADER_H__ #define __AF_LOADER_H__ #include "afhints.h" #include "afglobal.h" FT_BEGIN_HEADER typedef struct AF_LoaderRec_ { FT_Face face; /* current face */ AF_FaceGlobals globals; /* current face globals */ FT_GlyphLoader gloader; /* glyph loader */ AF_GlyphHintsRec hints; AF_ScriptMetrics metrics; FT_Bool transformed; FT_Matrix trans_matrix; FT_Vector trans_delta; FT_Vector pp1; FT_Vector pp2; /* we don't handle vertical phantom points */ } AF_LoaderRec, *AF_Loader; FT_LOCAL( FT_Error ) af_loader_init( AF_Loader loader, FT_Memory memory ); FT_LOCAL( FT_Error ) af_loader_reset( AF_Loader loader, FT_Face face ); FT_LOCAL( void ) af_loader_done( AF_Loader loader ); FT_LOCAL( FT_Error ) af_loader_load_glyph( AF_Loader loader, FT_Face face, FT_UInt gindex, FT_UInt32 load_flags ); /* */ FT_END_HEADER #endif /* __AF_LOADER_H__ */ /* END */ --- NEW FILE: Jamfile --- # FreeType 2 src/autofit Jamfile # # Copyright 2003, 2004, 2005 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, # and distributed under the terms of the FreeType project license, # LICENSE.TXT. By continuing to use, modify, or distribute this file you # indicate that you have read the license and understand and accept it # fully. SubDir FT2_TOP src autofit ; { local _sources ; if $(FT2_MULTI) { _sources = afangles afglobal afhints aflatin afloader afmodule afdummy ; } else { _sources = autofit ; } Library $(FT2_LIB) : $(_sources).c ; } # end of src/autofit Jamfile --- NEW FILE: aftypes.h --- /***************************************************************************/ /* */ /* aftypes.h */ /* */ /* Auto-fitter types (specification only). */ /* */ /* Copyright 2003, 2004, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ /*************************************************************************** * * The auto-fitter is a complete rewrite of the old auto-hinter. * Its main feature is the ability to differentiate between different * scripts in order to apply language-specific rules. * * The code has also been compartimentized into several entities that * should make algorithmic experimentation easier than with the old * code. * * Finally, we get rid of the Catharon license, since this code is * released under the FreeType one. * ***************************************************************************/ #ifndef __AFTYPES_H__ #define __AFTYPES_H__ #include <ft2build.h> #include FT_FREETYPE_H #include FT_OUTLINE_H #include FT_INTERNAL_OBJECTS_H #include FT_INTERNAL_DEBUG_H FT_BEGIN_HEADER /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** D E B U G G I N G *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ #define xxAF_DEBUG #ifdef AF_DEBUG #include <stdio.h> #define AF_LOG( x ) printf x #else #define AF_LOG( x ) do ; while ( 0 ) /* nothing */ #endif /* AF_DEBUG */ /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** U T I L I T Y S T U F F *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ typedef struct AF_WidthRec_ { FT_Pos org; /* original position/width in font units */ FT_Pos cur; /* current/scaled position/width in device sub-pixels */ FT_Pos fit; /* current/fitted position/width in device sub-pixels */ } AF_WidthRec, *AF_Width; FT_LOCAL( void ) af_sort_pos( FT_UInt count, FT_Pos* table ); FT_LOCAL( void ) af_sort_widths( FT_UInt count, AF_Width widths ); /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** A N G L E T Y P E S *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ /* * The auto-fitter doesn't need a very high angular accuracy; * this allows us to speed up some computations considerably with a * light Cordic algorithm (see afangles.c). */ typedef FT_Int AF_Angle; #define AF_ANGLE_PI 256 #define AF_ANGLE_2PI ( AF_ANGLE_PI * 2 ) #define AF_ANGLE_PI2 ( AF_ANGLE_PI / 2 ) #define AF_ANGLE_PI4 ( AF_ANGLE_PI / 4 ) /* * compute the angle of a given 2-D vector */ FT_LOCAL( AF_Angle ) af_angle_atan( FT_Pos dx, FT_Pos dy ); /* * compute `angle2 - angle1'; the result is always within * the range [-AF_ANGLE_PI .. AF_ANGLE_PI - 1] */ FT_LOCAL( AF_Angle ) af_angle_diff( AF_Angle angle1, AF_Angle angle2 ); /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** O U T L I N E S *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ /* opaque handle to glyph-specific hints -- see `afhints.h' for more * details */ typedef struct AF_GlyphHintsRec_* AF_GlyphHints; /* This structure is used to model an input glyph outline to * the auto-hinter. The latter will set the `hints' field * depending on the glyph's script. */ typedef struct AF_OutlineRec_ { FT_Face face; FT_Outline outline; FT_UInt outline_resolution; FT_Int advance; FT_UInt metrics_resolution; AF_GlyphHints hints; } AF_OutlineRec; /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** S C A L E R S *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ /* * A scaler models the target pixel device that will receive the * auto-hinted glyph image. */ typedef enum { AF_SCALER_FLAG_NO_HORIZONTAL = 1, /* disable horizontal hinting */ AF_SCALER_FLAG_NO_VERTICAL = 2, /* disable vertical hinting */ AF_SCALER_FLAG_NO_ADVANCE = 4 /* disable advance hinting */ } AF_ScalerFlags; typedef struct AF_ScalerRec_ { FT_Face face; /* source font face */ FT_Fixed x_scale; /* from font units to 1/64th device pixels */ FT_Fixed y_scale; /* from font units to 1/64th device pixels */ FT_Pos x_delta; /* in 1/64th device pixels */ FT_Pos y_delta; /* in 1/64th device pixels */ FT_Render_Mode render_mode; /* monochrome, anti-aliased, LCD, etc. */ FT_UInt32 flags; /* additional control flags, see above */ } AF_ScalerRec, *AF_Scaler; #define AF_SCALER_EQUAL_SCALES( a, b ) \ ( (a)->x_scale == (b)->x_scale && \ (a)->y_scale == (b)->y_scale && \ (a)->x_delta == (b)->x_delta && \ (a)->y_delta == (b)->y_delta ) /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** S C R I P T S *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ /* * The list of know scripts. Each different script corresponds to the * following information: * * - A set of Unicode ranges to test whether the face supports the * script. * * - A specific global analyzer that will compute global metrics * specific to the script. * * - A specific glyph analyzer that will compute segments and * edges for each glyph covered by the script. * * - A specific grid-fitting algorithm that will distort the * scaled glyph outline according to the results of the glyph * analyzer. * * Note that a given analyzer and/or grid-fitting algorithm can be * used by more than one script. */ typedef enum { AF_SCRIPT_NONE = 0, AF_SCRIPT_LATIN = 1, /* add new scripts here. Don't forget to update the list in */ /* `afglobal.c'. */ AF_SCRIPT_MAX /* do not remove */ } AF_Script; typedef struct AF_ScriptClassRec_ const* AF_ScriptClass; typedef struct AF_ScriptMetricsRec_ { AF_ScriptClass clazz; AF_ScalerRec scaler; } AF_ScriptMetricsRec, *AF_ScriptMetrics; /* This function parses an FT_Face to compute global metrics for * a specific script. */ typedef FT_Error (*AF_Script_InitMetricsFunc)( AF_ScriptMetrics metrics, FT_Face face ); typedef void (*AF_Script_ScaleMetricsFunc)( AF_ScriptMetrics metrics, AF_Scaler scaler ); typedef void (*AF_Script_DoneMetricsFunc)( AF_ScriptMetrics metrics ); typedef FT_Error (*AF_Script_InitHintsFunc)( AF_GlyphHints hints, AF_ScriptMetrics metrics ); typedef void (*AF_Script_ApplyHintsFunc)( AF_GlyphHints hints, FT_Outline* outline, AF_ScriptMetrics metrics ); typedef struct AF_Script_UniRangeRec_ { FT_UInt32 first; FT_UInt32 last; } AF_Script_UniRangeRec; typedef const AF_Script_UniRangeRec *AF_Script_UniRange; typedef struct AF_ScriptClassRec_ { AF_Script script; AF_Script_UniRange script_uni_ranges; /* last must be { 0, 0 } */ FT_UInt script_metrics_size; AF_Script_InitMetricsFunc script_metrics_init; AF_Script_ScaleMetricsFunc script_metrics_scale; AF_Script_DoneMetricsFunc script_metrics_done; AF_Script_InitHintsFunc script_hints_init; AF_Script_ApplyHintsFunc script_hints_apply; } AF_ScriptClassRec; /* */ FT_END_HEADER #endif /* __AFTYPES_H__ */ /* END */ --- NEW FILE: afhints.h --- /***************************************************************************/ /* */ /* afhints.h */ /* */ /* Auto-fitter hinting routines (specification). */ /* */ /* Copyright 2003, 2004, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __AFHINTS_H__ #define __AFHINTS_H__ #include "aftypes.h" FT_BEGIN_HEADER /* * The definition of outline glyph hints. These are shared by all * script analysis routines (until now). */ typedef enum { AF_DIMENSION_HORZ = 0, /* x coordinates, */ /* i.e., vertical segments & edges */ AF_DIMENSION_VERT = 1, /* y coordinates, */ /* i.e., horizontal segments & edges */ AF_DIMENSION_MAX /* do not remove */ } AF_Dimension; /* hint directions -- the values are computed so that two vectors are */ /* in opposite directions iff `dir1 + dir2 == 0' */ typedef enum { AF_DIR_NONE = 4, AF_DIR_RIGHT = 1, AF_DIR_LEFT = -1, AF_DIR_UP = 2, AF_DIR_DOWN = -2 } AF_Direction; /* point hint flags */ typedef enum { AF_FLAG_NONE = 0, /* point type flags */ AF_FLAG_CONIC = 1 << 0, AF_FLAG_CUBIC = 1 << 1, AF_FLAG_CONTROL = AF_FLAG_CONIC | AF_FLAG_CUBIC, /* point extremum flags */ AF_FLAG_EXTREMA_X = 1 << 2, AF_FLAG_EXTREMA_Y = 1 << 3, /* point roundness flags */ AF_FLAG_ROUND_X = 1 << 4, AF_FLAG_ROUND_Y = 1 << 5, /* point touch flags */ AF_FLAG_TOUCH_X = 1 << 6, AF_FLAG_TOUCH_Y = 1 << 7, /* candidates for weak interpolation have this flag set */ AF_FLAG_WEAK_INTERPOLATION = 1 << 8, /* all inflection points in the outline have this flag set */ AF_FLAG_INFLECTION = 1 << 9 } AF_Flags; /* edge hint flags */ typedef enum { AF_EDGE_NORMAL = 0, AF_EDGE_ROUND = 1 << 0, AF_EDGE_SERIF = 1 << 1, AF_EDGE_DONE = 1 << 2 } AF_Edge_Flags; typedef struct AF_PointRec_* AF_Point; typedef struct AF_SegmentRec_* AF_Segment; typedef struct AF_EdgeRec_* AF_Edge; typedef struct AF_PointRec_ { FT_UShort flags; /* point flags used by hinter */ FT_Char in_dir; /* direction of inwards vector */ FT_Char out_dir; /* direction of outwards vector */ FT_Pos ox, oy; /* original, scaled position */ FT_Short fx, fy; /* original, unscaled position (font units) */ FT_Pos x, y; /* current position */ FT_Pos u, v; /* current (x,y) or (y,x) depending on context */ AF_Point next; /* next point in contour */ AF_Point prev; /* previous point in contour */ } AF_PointRec; typedef struct AF_SegmentRec_ { FT_Byte flags; /* edge/segment flags for this segment */ FT_Char dir; /* segment direction */ FT_Short pos; /* position of segment */ FT_Short min_coord; /* minimum coordinate of segment */ FT_Short max_coord; /* maximum coordinate of segment */ AF_Edge edge; /* the segment's parent edge */ AF_Segment edge_next; /* link to next segment in parent edge */ AF_Segment link; /* (stem) link segment */ AF_Segment serif; /* primary segment for serifs */ FT_Pos num_linked; /* number of linked segments */ FT_Pos score; /* used during stem matching */ AF_Point first; /* first point in edge segment */ AF_Point last; /* last point in edge segment */ AF_Point* contour; /* ptr to first point of segment's contour */ } AF_SegmentRec; typedef struct AF_EdgeRec_ { FT_Short fpos; /* original, unscaled position (font units) */ FT_Pos opos; /* original, scaled position */ FT_Pos pos; /* current position */ FT_Byte flags; /* edge flags */ FT_Char dir; /* edge direction */ FT_Fixed scale; /* used to speed up interpolation between edges */ AF_Width blue_edge; /* non-NULL if this is a blue edge */ AF_Edge link; AF_Edge serif; FT_Short num_linked; FT_Int score; AF_Segment first; AF_Segment last; } AF_EdgeRec; typedef struct AF_AxisHintsRec_ { FT_Int num_segments; FT_Int max_segments; AF_Segment segments; FT_Int num_edges; FT_Int max_edges; AF_Edge edges; AF_Direction major_dir; } AF_AxisHintsRec, *AF_AxisHints; typedef struct AF_GlyphHintsRec_ { FT_Memory memory; FT_Fixed x_scale; FT_Pos x_delta; FT_Fixed y_scale; FT_Pos y_delta; FT_Pos edge_distance_threshold; FT_Int max_points; FT_Int num_points; AF_Point points; FT_Int max_contours; FT_Int num_contours; AF_Point* contours; AF_AxisHintsRec axis[AF_DIMENSION_MAX]; FT_UInt32 scaler_flags; /* copy of scaler flags */ FT_UInt32 other_flags; /* free for script-specific */ /* implementations */ AF_ScriptMetrics metrics; } AF_GlyphHintsRec; #define AF_HINTS_TEST_SCALER( h, f ) ( (h)->scaler_flags & (f) ) #define AF_HINTS_TEST_OTHER( h, f ) ( (h)->other_flags & (f) ) #define AF_HINTS_DO_HORIZONTAL( h ) \ !AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_HORIZONTAL ) #define AF_HINTS_DO_VERTICAL( h ) \ !AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_VERTICAL ) #define AF_HINTS_DO_ADVANCE( h ) \ !AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_ADVANCE ) FT_LOCAL( AF_Direction ) af_direction_compute( FT_Pos dx, FT_Pos dy ); FT_LOCAL( FT_Error ) af_axis_hints_new_segment( AF_AxisHints axis, FT_Memory memory, AF_Segment *asegment ); FT_LOCAL( FT_Error) af_axis_hints_new_edge( AF_AxisHints axis, FT_Int fpos, FT_Memory memory, AF_Edge *edge ); FT_LOCAL( void ) af_glyph_hints_init( AF_GlyphHints hints, FT_Memory memory ); /* * recompute all AF_Point in a AF_GlyphHints from the definitions * in a source outline */ FT_LOCAL( void ) af_glyph_hints_rescale( AF_GlyphHints hints, AF_ScriptMetrics metrics ); FT_LOCAL( FT_Error ) af_glyph_hints_reload( AF_GlyphHints hints, FT_Outline* outline ); FT_LOCAL( void ) af_glyph_hints_save( AF_GlyphHints hints, FT_Outline* outline ); FT_LOCAL( void ) af_glyph_hints_align_edge_points( AF_GlyphHints hints, AF_Dimension dim ); FT_LOCAL( void ) af_glyph_hints_align_strong_points( AF_GlyphHints hints, AF_Dimension dim ); FT_LOCAL( void ) af_glyph_hints_align_weak_points( AF_GlyphHints hints, AF_Dimension dim ); FT_LOCAL( void ) af_glyph_hints_done( AF_GlyphHints hints ); /* */ FT_END_HEADER #endif /* __AFHINTS_H__ */ /* END */ --- NEW FILE: afglobal.h --- /***************************************************************************/ /* */ /* afglobal.h */ /* */ /* Auto-fitter routines to compute global hinting values */ /* (specification). */ /* */ /* Copyright 2003, 2004, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __AF_GLOBAL_H__ #define __AF_GLOBAL_H__ #include "aftypes.h" FT_BEGIN_HEADER /************************************************************************/ /************************************************************************/ /***** *****/ /***** F A C E G L O B A L S *****/ /***** *****/ /************************************************************************/ /************************************************************************/ /* * model the global hints data for a given face, decomposed into * script-specific items */ typedef struct AF_FaceGlobalsRec_* AF_FaceGlobals; FT_LOCAL( FT_Error ) af_face_globals_new( FT_Face face, AF_FaceGlobals *aglobals ); FT_LOCAL( FT_Error ) af_face_globals_get_metrics( AF_FaceGlobals globals, FT_UInt gindex, AF_ScriptMetrics *ametrics ); FT_LOCAL( void ) af_face_globals_free( AF_FaceGlobals globals ); /* */ FT_END_HEADER #endif /* __AF_GLOBALS_H__ */ /* END */ --- NEW FILE: afmodule.h --- /***************************************************************************/ /* */ /* afmodule.h */ /* */ /* Auto-fitter module implementation (specification). */ /* */ /* Copyright 2003, 2004, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __AFMODULE_H__ #define __AFMODULE_H__ #include <ft2build.h> #include FT_MODULE_H FT_BEGIN_HEADER FT_CALLBACK_TABLE const FT_Module_Class autofit_module_class; FT_END_HEADER #endif /* __AFMODULE_H__ */ /* END */ --- NEW FILE: module.mk --- # # FreeType 2 auto-fitter module definition # # Copyright 2003, 2004, 2005 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, # and distributed under the terms of the FreeType project license, # LICENSE.TXT. By continuing to use, modify, or distribute this file you # indicate that you have read the license and understand and accept it # fully. make_module_list: add_autofit_module add_autofit_module: $(OPEN_DRIVER)autofit_module_class$(CLOSE_DRIVER) $(ECHO_DRIVER)autofit $(ECHO_DRIVER_DESC)automatic hinting module$(ECHO_DRIVER_DONE) # EOF --- NEW FILE: afangles.h --- /* * afangles.h * * This is a dummy file, used to please the build system. It is never * included by the auto-fitter sources. * */ --- NEW FILE: afdummy.h --- /***************************************************************************/ /* */ /* afdummy.h */ /* */ /* Auto-fitter dummy routines to be used if no hinting should be */ /* performed (specification). */ /* */ /* Copyright 2003, 2004, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __AFDUMMY_H__ #define __AFDUMMY_H__ #include "aftypes.h" FT_BEGIN_HEADER /* A dummy script metrics class used when no hinting should * be performed. This is the default for non-latin glyphs! */ FT_CALLBACK_TABLE const AF_ScriptClassRec af_dummy_script_class; /* */ FT_END_HEADER #endif /* __AFDUMMY_H__ */ /* END */ --- NEW FILE: aferrors.h --- /***************************************************************************/ /* */ /* aferrors.h */ /* */ /* Autofitter error codes (specification only). */ /* */ /* Copyright 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ /*************************************************************************/ /* */ /* This file is used to define the Autofitter error enumeration */ /* constants. */ /* */ /*************************************************************************/ #ifndef __AFERRORS_H__ #define __AFERRORS_H__ #include FT_MODULE_ERRORS_H #undef __FTERRORS_H__ #define FT_ERR_PREFIX AF_Err_ #define FT_ERR_BASE FT_Mod_Err_Autofit #include FT_ERRORS_H #endif /* __AFERRORS_H__ */ /* END */ --- NEW FILE: aflatin.h --- /***************************************************************************/ /* */ /* aflatin.h */ /* */ /* Auto-fitter hinting routines for latin script (specification). */ /* */ /* Copyright 2003, 2004, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __AFLATIN_H__ #define __AFLATIN_H__ #include "afhints.h" FT_BEGIN_HEADER /* the latin-specific script class */ FT_CALLBACK_TABLE const AF_ScriptClassRec af_latin_script_class; /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** L A T I N G L O B A L M E T R I C S *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ /* * The following declarations could be embedded in the file `aflatin.c'; * they have been made semi-public to allow alternate script hinters to * re-use some of them. */ /* Latin (global) metrics management */ enum { AF_LATIN_BLUE_CAPITAL_TOP, AF_LATIN_BLUE_CAPITAL_BOTTOM, AF_LATIN_BLUE_SMALL_F_TOP, AF_LATIN_BLUE_SMALL_TOP, AF_LATIN_BLUE_SMALL_BOTTOM, AF_LATIN_BLUE_SMALL_MINOR, AF_LATIN_BLUE_MAX }; #define AF_LATIN_IS_TOP_BLUE( b ) ( (b) == AF_LATIN_BLUE_CAPITAL_TOP || \ (b) == AF_LATIN_BLUE_SMALL_F_TOP || \ (b) == AF_LATIN_BLUE_SMALL_TOP ) #define AF_LATIN_MAX_WIDTHS 16 #define AF_LATIN_MAX_BLUES AF_LATIN_BLUE_MAX enum { AF_LATIN_BLUE_ACTIVE = 1 << 0, AF_LATIN_BLUE_TOP = 1 << 1, AF_LATIN_BLUE_ADJUSTMENT = 1 << 2, /* used for scale adjustment */ /* optimization */ AF_LATIN_BLUE_FLAG_MAX }; typedef struct AF_LatinBlueRec_ { AF_WidthRec ref; AF_WidthRec shoot; FT_UInt flags; } AF_LatinBlueRec, *AF_LatinBlue; typedef struct AF_LatinAxisRec_ { FT_Fixed scale; FT_Pos delta; FT_UInt width_count; AF_WidthRec widths[AF_LATIN_MAX_WIDTHS]; FT_Pos edge_distance_threshold; /* ignored for horizontal metrics */ FT_Bool control_overshoot; FT_UInt blue_count; AF_LatinBlueRec blues[AF_LATIN_BLUE_MAX]; FT_Fixed org_scale; FT_Pos org_delta; } AF_LatinAxisRec, *AF_LatinAxis; typedef struct AF_LatinMetricsRec_ { AF_ScriptMetricsRec root; FT_UInt units_per_em; AF_LatinAxisRec axis[AF_DIMENSION_MAX]; } AF_LatinMetricsRec, *AF_LatinMetrics; FT_LOCAL( FT_Error ) af_latin_metrics_init( AF_LatinMetrics metrics, FT_Face face ); FT_LOCAL( void ) af_latin_metrics_scale( AF_LatinMetrics metrics, AF_Scaler scaler ); /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** L A T I N G L Y P H A N A L Y S I S *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ enum { AF_LATIN_HINTS_HORZ_SNAP = 1 << 0, /* enable stem width snapping */ AF_LATIN_HINTS_VERT_SNAP = 1 << 1, /* enable stem height snapping */ AF_LATIN_HINTS_STEM_ADJUST = 1 << 2, /* enable stem width/height */ /* adjustment */ AF_LATIN_HINTS_MONO = 1 << 3 /* indicate monochrome */ /* rendering */ }; #define AF_LATIN_HINTS_DO_HORZ_SNAP( h ) \ AF_HINTS_TEST_OTHER( h, AF_LATIN_HINTS_HORZ_SNAP ) #define AF_LATIN_HINTS_DO_VERT_SNAP( h ) \ AF_HINTS_TEST_OTHER( h, AF_LATIN_HINTS_VERT_SNAP ) #define AF_LATIN_HINTS_DO_STEM_ADJUST( h ) \ AF_HINTS_TEST_OTHER( h, AF_LATIN_HINTS_STEM_ADJUST ) #define AF_LATIN_HINTS_DO_MONO( h ) \ AF_HINTS_TEST_OTHER( h, AF_LATIN_HINTS_MONO ) /* * This shouldn't normally be exported. However, other scripts might * like to use this function as-is. */ FT_LOCAL( FT_Error ) af_latin_hints_compute_segments( AF_GlyphHints hints, AF_Dimension dim ); /* * This shouldn't normally be exported. However, other scripts might * want to use this function as-is. */ FT_LOCAL( void ) af_latin_hints_link_segments( AF_GlyphHints hints, AF_Dimension dim ); /* * This shouldn't normally be exported. However, other scripts might * want to use this function as-is. */ FT_LOCAL( FT_Error ) af_latin_hints_compute_edges( AF_GlyphHints hints, AF_Dimension dim ); FT_LOCAL( FT_Error ) af_latin_hints_detect_features( AF_GlyphHints hints, AF_Dimension dim ); /* */ FT_END_HEADER #endif /* __AFLATIN_H__ */ /* END */ |
Update of /cvsroot/roadmap/roadmap_editor/src/freetype/src/gzip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28321/src/gzip Added Files: Jamfile infblock.h infcodes.h inffixed.h inftrees.h infutil.h rules.mk zconf.h zlib.h zutil.h Log Message: Import freetype sources. --- NEW FILE: rules.mk --- # # FreeType 2 GZip support configuration rules # # Copyright 2002, 2003 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, # and distributed under the terms of the FreeType project license, # LICENSE.TXT. By continuing to use, modify, or distribute this file you # indicate that you have read the license and understand and accept it # fully. # gzip driver directory # GZIP_DIR := $(SRC_DIR)/gzip # compilation flags for the driver # ifeq ($(SYSTEM_ZLIB),) GZIP_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(GZIP_DIR)) else GZIP_COMPILE := $(FT_COMPILE) endif # gzip support sources (i.e., C files) # GZIP_DRV_SRC := $(GZIP_DIR)/ftgzip.c # gzip support headers # GZIP_DRV_H := # gzip driver object(s) # # GZIP_DRV_OBJ_M is used during `multi' builds # GZIP_DRV_OBJ_S is used during `single' builds # ifeq ($(SYSTEM_ZLIB),) GZIP_DRV_OBJ_M := $(GZIP_DRV_SRC:$(GZIP_DIR)/%.c=$(OBJ_DIR)/%.$O) else GZIP_DRV_OBJ_M := $(OBJ_DIR)/ftgzip.$O endif GZIP_DRV_OBJ_S := $(OBJ_DIR)/ftgzip.$O # gzip support source file for single build # GZIP_DRV_SRC_S := $(GZIP_DIR)/ftgzip.c # gzip support - single object # $(GZIP_DRV_OBJ_S): $(GZIP_DRV_SRC_S) $(GZIP_DRV_SRC) $(FREETYPE_H) \ $(GZIP_DRV_H) $(GZIP_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(GZIP_DRV_SRC_S)) # gzip support - multiple objects # $(OBJ_DIR)/%.$O: $(GZIP_DIR)/%.c $(FREETYPE_H) $(GZIP_DRV_H) $(GZIP_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<) # update main driver object lists # DRV_OBJS_S += $(GZIP_DRV_OBJ_S) DRV_OBJS_M += $(GZIP_DRV_OBJ_M) # EOF --- NEW FILE: infutil.h --- /* infutil.h -- types and macros common to blocks and codes * Copyright (C) 1995-2002 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* WARNING: this file should *not* be used by applications. It is part of the implementation of the compression library and is subject to change. Applications should only use zlib.h. */ #ifndef _INFUTIL_H #define _INFUTIL_H typedef enum { TYPE, /* get type bits (3, including end bit) */ LENS, /* get lengths for stored */ STORED, /* processing stored block */ TABLE, /* get table lengths */ BTREE, /* get bit lengths tree for a dynamic block */ DTREE, /* get length, distance trees for a dynamic block */ CODES, /* processing fixed or dynamic block */ DRY, /* output remaining window bytes */ DONE, /* finished last block, done */ BAD} /* got a data error--stuck here */ inflate_block_mode; /* inflate blocks semi-private state */ struct inflate_blocks_state { /* mode */ inflate_block_mode mode; /* current inflate_block mode */ /* mode dependent information */ union { uInt left; /* if STORED, bytes left to copy */ struct { uInt table; /* table lengths (14 bits) */ uInt index; /* index into blens (or border) */ uIntf *blens; /* bit lengths of codes */ uInt bb; /* bit length tree depth */ inflate_huft *tb; /* bit length decoding tree */ } trees; /* if DTREE, decoding info for trees */ struct { inflate_codes_statef *codes; } decode; /* if CODES, current state */ } sub; /* submode */ uInt last; /* true if this block is the last block */ /* mode independent information */ uInt bitk; /* bits in bit buffer */ uLong bitb; /* bit buffer */ inflate_huft *hufts; /* single malloc for tree space */ Bytef *window; /* sliding window */ Bytef *end; /* one byte after sliding window */ Bytef *read; /* window read pointer */ Bytef *write; /* window write pointer */ check_func checkfn; /* check function */ uLong check; /* check on output */ }; /* defines for inflate input/output */ /* update pointers and return */ #define UPDBITS {s->bitb=b;s->bitk=k;} #define UPDIN {z->avail_in=n;z->total_in+=p-z->next_in;z->next_in=p;} #define UPDOUT {s->write=q;} #define UPDATE {UPDBITS UPDIN UPDOUT} #define LEAVE {UPDATE return inflate_flush(s,z,r);} /* get bytes and bits */ #define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;} #define NEEDBYTE {if(n)r=Z_OK;else LEAVE} #define NEXTBYTE (n--,*p++) #define NEEDBITS(j) {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<<k;k+=8;}} #define DUMPBITS(j) {b>>=(j);k-=(j);} /* output bytes */ #define WAVAIL (uInt)(q<s->read?s->read-q-1:s->end-q) #define LOADOUT {q=s->write;m=(uInt)WAVAIL;} #define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=(uInt)WAVAIL;}} #define FLUSH {UPDOUT r=inflate_flush(s,z,r); LOADOUT} #define NEEDOUT {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE}}r=Z_OK;} #define OUTBYTE(a) {*q++=(Byte)(a);m--;} /* load local pointers */ #define LOAD {LOADIN LOADOUT} /* masks for lower bits (size given to avoid silly warnings with Visual C++) */ #ifndef NO_INFLATE_MASK local uInt inflate_mask[17]; #endif /* copy as much as possible from the sliding window to the output area */ local int inflate_flush OF(( inflate_blocks_statef *, z_streamp , int)); #endif --- NEW FILE: inftrees.h --- /* inftrees.h -- header to use inftrees.c * Copyright (C) 1995-2002 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* WARNING: this file should *not* be used by applications. It is part of the implementation of the compression library and is subject to change. Applications should only use zlib.h. */ /* Huffman code lookup table entry--this entry is four bytes for machines that have 16-bit pointers (e.g. PC's in the small or medium model). */ #ifndef _INFTREES_H #define _INFTREES_H typedef struct inflate_huft_s FAR inflate_huft; struct inflate_huft_s { union { struct { Byte Exop; /* number of extra bits or operation */ Byte Bits; /* number of bits in this code or subcode */ } what; uInt pad; /* pad structure to a power of 2 (4 bytes for */ } word; /* 16-bit, 8 bytes for 32-bit int's) */ uInt base; /* literal, length base, distance base, or table offset */ }; /* Maximum size of dynamic tree. The maximum found in a long but non- exhaustive search was 1004 huft structures (850 for length/literals and 154 for distances, the latter actually the result of an exhaustive search). The actual maximum is not known, but the value below is more than safe. */ #define MANY 1440 local int inflate_trees_bits OF(( uIntf *, /* 19 code lengths */ uIntf *, /* bits tree desired/actual depth */ inflate_huft * FAR *, /* bits tree result */ inflate_huft *, /* space for trees */ z_streamp)); /* for messages */ local int inflate_trees_dynamic OF(( uInt, /* number of literal/length codes */ uInt, /* number of distance codes */ uIntf *, /* that many (total) code lengths */ uIntf *, /* literal desired/actual bit depth */ uIntf *, /* distance desired/actual bit depth */ inflate_huft * FAR *, /* literal/length tree result */ inflate_huft * FAR *, /* distance tree result */ inflate_huft *, /* space for trees */ z_streamp)); /* for messages */ local int inflate_trees_fixed OF(( uIntf *, /* literal desired/actual bit depth */ uIntf *, /* distance desired/actual bit depth */ const inflate_huft * FAR *, /* literal/length tree result */ const inflate_huft * FAR *, /* distance tree result */ z_streamp)); /* for memory allocation */ #endif /* _INFTREES_H */ --- NEW FILE: infcodes.h --- /* infcodes.h -- header to use infcodes.c * Copyright (C) 1995-2002 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* WARNING: this file should *not* be used by applications. It is part of the implementation of the compression library and is subject to change. Applications should only use zlib.h. */ #ifndef _INFCODES_H #define _INFCODES_H struct inflate_codes_state; typedef struct inflate_codes_state FAR inflate_codes_statef; local inflate_codes_statef *inflate_codes_new OF(( uInt, uInt, inflate_huft *, inflate_huft *, z_streamp )); local int inflate_codes OF(( inflate_blocks_statef *, z_streamp , int)); local void inflate_codes_free OF(( inflate_codes_statef *, z_streamp )); #endif /* _INFCODES_H */ --- NEW FILE: zlib.h --- /* zlib.h -- interface of the 'zlib' general purpose compression library version 1.1.4, March 11th, 2002 Copyright (C) 1995-2002 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. Jean-loup Gailly Mark Adler jl...@gz... ma...@al... The data format used by the zlib library is described by RFCs (Request for Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). */ #ifndef _ZLIB_H #define _ZLIB_H #include "zconf.h" #ifdef __cplusplus extern "C" { #endif #define ZLIB_VERSION "1.1.4" /* The 'zlib' compression library provides in-memory compression and decompression functions, including integrity checks of the uncompressed data. This version of the library supports only one compression method (deflation) but other algorithms will be added later and will have the same stream interface. Compression can be done in a single step if the buffers are large enough (for example if an input file is mmap'ed), or can be done by repeated calls of the compression function. In the latter case, the application must provide more input and/or consume the output (providing more output space) before each call. The library also supports reading and writing files in gzip (.gz) format with an interface similar to that of stdio. The library does not install any signal handler. The decoder checks the consistency of the compressed data, so the library should never crash even in case of corrupted input. */ typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); typedef void (*free_func) OF((voidpf opaque, voidpf address)); struct internal_state; typedef struct z_stream_s { Bytef *next_in; /* next input byte */ uInt avail_in; /* number of bytes available at next_in */ uLong total_in; /* total nb of input bytes read so far */ Bytef *next_out; /* next output byte should be put there */ uInt avail_out; /* remaining free space at next_out */ uLong total_out; /* total nb of bytes output so far */ char *msg; /* last error message, NULL if no error */ struct internal_state FAR *state; /* not visible by applications */ alloc_func zalloc; /* used to allocate the internal state */ free_func zfree; /* used to free the internal state */ voidpf opaque; /* private data object passed to zalloc and zfree */ int data_type; /* best guess about the data type: ascii or binary */ uLong adler; /* adler32 value of the uncompressed data */ uLong reserved; /* reserved for future use */ } z_stream; typedef z_stream FAR *z_streamp; /* The application must update next_in and avail_in when avail_in has dropped to zero. It must update next_out and avail_out when avail_out has dropped to zero. The application must initialize zalloc, zfree and opaque before calling the init function. All other fields are set by the compression library and must not be updated by the application. The opaque value provided by the application will be passed as the first parameter for calls of zalloc and zfree. This can be useful for custom memory management. The compression library attaches no meaning to the opaque value. zalloc must return Z_NULL if there is not enough memory for the object. If zlib is used in a multi-threaded application, zalloc and zfree must be thread safe. On 16-bit systems, the functions zalloc and zfree must be able to allocate exactly 65536 bytes, but will not be required to allocate more than this if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers returned by zalloc for objects of exactly 65536 bytes *must* have their offset normalized to zero. The default allocation function provided by this library ensures this (see zutil.c). To reduce memory requirements and avoid any allocation of 64K objects, at the expense of compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). The fields total_in and total_out can be used for statistics or progress reports. After compression, total_in holds the total size of the uncompressed data and may be saved for use in the decompressor (particularly if the decompressor wants to decompress everything in a single step). */ /* constants */ #define Z_NO_FLUSH 0 #define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ #define Z_SYNC_FLUSH 2 #define Z_FULL_FLUSH 3 #define Z_FINISH 4 /* Allowed flush values; see deflate() below for details */ #define Z_OK 0 #define Z_STREAM_END 1 #define Z_NEED_DICT 2 #define Z_ERRNO (-1) #define Z_STREAM_ERROR (-2) #define Z_DATA_ERROR (-3) #define Z_MEM_ERROR (-4) #define Z_BUF_ERROR (-5) #define Z_VERSION_ERROR (-6) /* Return codes for the compression/decompression functions. Negative * values are errors, positive values are used for special but normal events. */ #define Z_NO_COMPRESSION 0 #define Z_BEST_SPEED 1 #define Z_BEST_COMPRESSION 9 #define Z_DEFAULT_COMPRESSION (-1) /* compression levels */ #define Z_FILTERED 1 #define Z_HUFFMAN_ONLY 2 #define Z_DEFAULT_STRATEGY 0 /* compression strategy; see deflateInit2() below for details */ #define Z_BINARY 0 #define Z_ASCII 1 #define Z_UNKNOWN 2 /* Possible values of the data_type field */ #define Z_DEFLATED 8 /* The deflate compression method (the only one supported in this version) */ #define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ /* basic functions */ /* The application can compare zlibVersion and ZLIB_VERSION for consistency. If the first character differs, the library code actually used is not compatible with the zlib.h header file used by the application. This check is automatically made by deflateInit and inflateInit. */ /* ZEXTERN(int) deflateInit OF((z_streamp strm, int level)); Initializes the internal stream state for compression. The fields zalloc, zfree and opaque must be initialized before by the caller. If zalloc and zfree are set to Z_NULL, deflateInit updates them to use default allocation functions. The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: 1 gives best speed, 9 gives best compression, 0 gives no compression at all (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION requests a default compromise between speed and compression (currently equivalent to level 6). deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if level is not a valid compression level, Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible with the version assumed by the caller (ZLIB_VERSION). msg is set to null if there is no error message. deflateInit does not perform any compression: this will be done by deflate(). */ /* deflate compresses as much data as possible, and stops when the input buffer becomes empty or the output buffer becomes full. It may introduce some output latency (reading input without producing any output) except when forced to flush. The detailed semantics are as follows. deflate performs one or both of the following actions: - Compress more input starting at next_in and update next_in and avail_in accordingly. If not all input can be processed (because there is not enough room in the output buffer), next_in and avail_in are updated and processing will resume at this point for the next call of deflate(). - Provide more output starting at next_out and update next_out and avail_out accordingly. This action is forced if the parameter flush is non zero. Forcing flush frequently degrades the compression ratio, so this parameter should be set only when necessary (in interactive applications). Some output may be provided even if flush is not set. Before the call of deflate(), the application should ensure that at least one of the actions is possible, by providing more input and/or consuming more output, and updating avail_in or avail_out accordingly; avail_out should never be zero before the call. The application can consume the compressed output when it wants, for example when the output buffer is full (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK and with zero avail_out, it must be called again after making room in the output buffer because there might be more output pending. If the parameter flush is set to Z_SYNC_FLUSH, all pending output is flushed to the output buffer and the output is aligned on a byte boundary, so that the decompressor can get all input data available so far. (In particular avail_in is zero after the call if enough output space has been provided before the call.) Flushing may degrade compression for some compression algorithms and so it should be used only when necessary. If flush is set to Z_FULL_FLUSH, all output is flushed as with Z_SYNC_FLUSH, and the compression state is reset so that decompression can restart from this point if previous compressed data has been damaged or if random access is desired. Using Z_FULL_FLUSH too often can seriously degrade the compression. If deflate returns with avail_out == 0, this function must be called again with the same value of the flush parameter and more output space (updated avail_out), until the flush is complete (deflate returns with non-zero avail_out). If the parameter flush is set to Z_FINISH, pending input is processed, pending output is flushed and deflate returns with Z_STREAM_END if there was enough output space; if deflate returns with Z_OK, this function must be called again with Z_FINISH and more output space (updated avail_out) but no more input data, until it returns with Z_STREAM_END or an error. After deflate has returned Z_STREAM_END, the only possible operations on the stream are deflateReset or deflateEnd. Z_FINISH can be used immediately after deflateInit if all the compression is to be done in a single step. In this case, avail_out must be at least 0.1% larger than avail_in plus 12 bytes. If deflate does not return Z_STREAM_END, then it must be called again as described above. deflate() sets strm->adler to the adler32 checksum of all input read so far (that is, total_in bytes). deflate() may update data_type if it can make a good guess about the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered binary. This field is only for information purposes and does not affect the compression algorithm in any manner. deflate() returns Z_OK if some progress has been made (more input processed or more output produced), Z_STREAM_END if all input has been consumed and all output has been produced (only when flush is set to Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible (for example avail_in or avail_out was zero). */ /* All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any pending output. deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state was inconsistent, Z_DATA_ERROR if the stream was freed prematurely (some input or output was discarded). In the error case, msg may be set but then points to a static string (which must not be deallocated). */ /* ZEXTERN(int) inflateInit OF((z_streamp strm)); Initializes the internal stream state for decompression. The fields next_in, avail_in, zalloc, zfree and opaque must be initialized before by the caller. If next_in is not Z_NULL and avail_in is large enough (the exact value depends on the compression method), inflateInit determines the compression method from the zlib header and allocates all data structures accordingly; otherwise the allocation will be deferred to the first call of inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to use default allocation functions. inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_VERSION_ERROR if the zlib library version is incompatible with the version assumed by the caller. msg is set to null if there is no error message. inflateInit does not perform any decompression apart from reading the zlib header if present: this will be done by inflate(). (So next_in and avail_in may be modified, but next_out and avail_out are unchanged.) */ ZEXTERN(int) inflate OF((z_streamp strm, int flush)); /* inflate decompresses as much data as possible, and stops when the input buffer becomes empty or the output buffer becomes full. It may some introduce some output latency (reading input without producing any output) except when forced to flush. The detailed semantics are as follows. inflate performs one or both of the following actions: - Decompress more input starting at next_in and update next_in and avail_in accordingly. If not all input can be processed (because there is not enough room in the output buffer), next_in is updated and processing will resume at this point for the next call of inflate(). - Provide more output starting at next_out and update next_out and avail_out accordingly. inflate() provides as much output as possible, until there is no more input data or no more space in the output buffer (see below about the flush parameter). Before the call of inflate(), the application should ensure that at least one of the actions is possible, by providing more input and/or consuming more output, and updating the next_* and avail_* values accordingly. The application can consume the uncompressed output when it wants, for example when the output buffer is full (avail_out == 0), or after each call of inflate(). If inflate returns Z_OK and with zero avail_out, it must be called again after making room in the output buffer because there might be more output pending. If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much output as possible to the output buffer. The flushing behavior of inflate is not specified for values of the flush parameter other than Z_SYNC_FLUSH and Z_FINISH, but the current implementation actually flushes as much output as possible anyway. inflate() should normally be called until it returns Z_STREAM_END or an error. However if all decompression is to be performed in a single step (a single call of inflate), the parameter flush should be set to Z_FINISH. In this case all pending input is processed and all pending output is flushed; avail_out must be large enough to hold all the uncompressed data. (The size of the uncompressed data may have been saved by the compressor for this purpose.) The next operation on this stream must be inflateEnd to deallocate the decompression state. The use of Z_FINISH is never required, but can be used to inform inflate that a faster routine may be used for the single inflate() call. If a preset dictionary is needed at this point (see inflateSetDictionary below), inflate sets strm-adler to the adler32 checksum of the dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise it sets strm->adler to the adler32 checksum of all output produced so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described below. At the end of the stream, inflate() checks that its computed adler32 checksum is equal to that saved by the compressor and returns Z_STREAM_END only if the checksum is correct. inflate() returns Z_OK if some progress has been made (more input processed or more output produced), Z_STREAM_END if the end of the compressed data has been reached and all uncompressed output has been produced, Z_NEED_DICT if a preset dictionary is needed at this point, Z_DATA_ERROR if the input data was corrupted (input stream not conforming to the zlib format or incorrect adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if no progress is possible or if there was not enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR case, the application may then call inflateSync to look for a good compression block. */ ZEXTERN(int) inflateEnd OF((z_streamp strm)); /* All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any pending output. inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state was inconsistent. In the error case, msg may be set but then points to a static string (which must not be deallocated). */ /* Advanced functions */ /* The following functions are needed only in some special applications. */ /* ZEXTERN(int) deflateInit2 OF((z_streamp strm, int level, int method, int windowBits, int memLevel, int strategy)); This is another version of deflateInit with more compression options. The fields next_in, zalloc, zfree and opaque must be initialized before by the caller. The method parameter is the compression method. It must be Z_DEFLATED in this version of the library. The windowBits parameter is the base two logarithm of the window size (the size of the history buffer). It should be in the range 8..15 for this version of the library. Larger values of this parameter result in better compression at the expense of memory usage. The default value is 15 if deflateInit is used instead. The memLevel parameter specifies how much memory should be allocated for the internal compression state. memLevel=1 uses minimum memory but is slow and reduces compression ratio; memLevel=9 uses maximum memory for optimal speed. The default value is 8. See zconf.h for total memory usage as a function of windowBits and memLevel. The strategy parameter is used to tune the compression algorithm. Use the value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no string match). Filtered data consists mostly of small values with a somewhat random distribution. In this case, the compression algorithm is tuned to compress them better. The effect of Z_FILTERED is to force more Huffman coding and less string matching; it is somewhat intermediate between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects the compression ratio but not the correctness of the compressed output even if it is not set appropriately. deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid method). msg is set to null if there is no error message. deflateInit2 does not perform any compression: this will be done by deflate(). */ /* Initializes the compression dictionary from the given byte sequence without producing any compressed output. This function must be called immediately after deflateInit, deflateInit2 or deflateReset, before any call of deflate. The compressor and decompressor must use exactly the same dictionary (see inflateSetDictionary). The dictionary should consist of strings (byte sequences) that are likely to be encountered later in the data to be compressed, with the most commonly used strings preferably put towards the end of the dictionary. Using a dictionary is most useful when the data to be compressed is short and can be predicted with good accuracy; the data can then be compressed better than with the default empty dictionary. Depending on the size of the compression data structures selected by deflateInit or deflateInit2, a part of the dictionary may in effect be discarded, for example if the dictionary is larger than the window size in deflate or deflate2. Thus the strings most likely to be useful should be put at the end of the dictionary, not at the front. Upon return of this function, strm->adler is set to the Adler32 value of the dictionary; the decompressor may later use this value to determine which dictionary has been used by the compressor. (The Adler32 value applies to the whole dictionary even if only a subset of the dictionary is actually used by the compressor.) deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a parameter is invalid (such as NULL dictionary) or the stream state is inconsistent (for example if deflate has already been called for this stream or if the compression method is bsort). deflateSetDictionary does not perform any compression: this will be done by deflate(). */ /* Sets the destination stream as a complete copy of the source stream. This function can be useful when several compression strategies will be tried, for example when there are several ways of pre-processing the input data with a filter. The streams that will be discarded should then be freed by calling deflateEnd. Note that deflateCopy duplicates the internal compression state which can be quite large, so this strategy is slow and can consume lots of memory. deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc being NULL). msg is left unchanged in both source and destination. */ /* This function is equivalent to deflateEnd followed by deflateInit, but does not free and reallocate all the internal compression state. The stream will keep the same compression level and any other attributes that may have been set by deflateInit2. deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc or state being NULL). */ /* Dynamically update the compression level and compression strategy. The interpretation of level and strategy is as in deflateInit2. This can be used to switch between compression and straight copy of the input data, or to switch to a different kind of input data requiring a different strategy. If the compression level is changed, the input available so far is compressed with the old level (and may be flushed); the new level will take effect only at the next call of deflate(). Before the call of deflateParams, the stream state must be set as for a call of deflate(), since the currently available input may have to be compressed and flushed. In particular, strm->avail_out must be non-zero. deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if strm->avail_out was zero. */ /* ZEXTERN(int) inflateInit2 OF((z_streamp strm, int windowBits)); This is another version of inflateInit with an extra parameter. The fields next_in, avail_in, zalloc, zfree and opaque must be initialized before by the caller. The windowBits parameter is the base two logarithm of the maximum window size (the size of the history buffer). It should be in the range 8..15 for this version of the library. The default value is 15 if inflateInit is used instead. If a compressed stream with a larger window size is given as input, inflate() will return with the error code Z_DATA_ERROR instead of trying to allocate a larger window. inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative memLevel). msg is set to null if there is no error message. inflateInit2 does not perform any decompression apart from reading the zlib header if present: this will be done by inflate(). (So next_in and avail_in may be modified, but next_out and avail_out are unchanged.) */ /* Initializes the decompression dictionary from the given uncompressed byte sequence. This function must be called immediately after a call of inflate if this call returned Z_NEED_DICT. The dictionary chosen by the compressor can be determined from the Adler32 value returned by this call of inflate. The compressor and decompressor must use exactly the same dictionary (see deflateSetDictionary). inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a parameter is invalid (such as NULL dictionary) or the stream state is inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the expected one (incorrect Adler32 value). inflateSetDictionary does not perform any decompression: this will be done by subsequent calls of inflate(). */ /* Skips invalid compressed data until a full flush point (see above the description of deflate with Z_FULL_FLUSH) can be found, or until all available input is skipped. No output is provided. inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point has been found, or Z_STREAM_ERROR if the stream structure was inconsistent. In the success case, the application may save the current current value of total_in which indicates where valid compressed data was found. In the error case, the application may repeatedly call inflateSync, providing more input each time, until success or end of the input data. */ ZEXTERN(int) inflateReset OF((z_streamp strm)); /* This function is equivalent to inflateEnd followed by inflateInit, but does not free and reallocate all the internal decompression state. The stream will keep attributes that may have been set by inflateInit2. inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc or state being NULL). */ /* utility functions */ /* The following utility functions are implemented on top of the basic stream-oriented functions. To simplify the interface, some default options are assumed (compression level and memory usage, standard memory allocation functions). The source code of these utility functions can easily be modified if you need special options. */ /* Compresses the source buffer into the destination buffer. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size of the destination buffer, which must be at least 0.1% larger than sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. This function can be used to compress a whole file at once if the input file is mmap'ed. compress returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output buffer. */ /* Compresses the source buffer into the destination buffer. The level parameter has the same meaning as in deflateInit. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size of the destination buffer, which must be at least 0.1% larger than sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output buffer, Z_STREAM_ERROR if the level parameter is invalid. */ /* Decompresses the source buffer into the destination buffer. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size of the destination buffer, which must be large enough to hold the entire uncompressed data. (The size of the uncompressed data must have been saved previously by the compressor and transmitted to the decompressor by some mechanism outside the scope of this compression library.) Upon exit, destLen is the actual size of the compressed buffer. This function can be used to decompress a whole file at once if the input file is mmap'ed. uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output buffer, or Z_DATA_ERROR if the input data was corrupted. */ /* Opens a gzip (.gz) file for reading or writing. The mode parameter is as in fopen ("rb" or "wb") but can also include a compression level ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman only compression as in "wb1h". (See the description of deflateInit2 for more information about the strategy parameter.) gzopen can be used to read a file which is not in gzip format; in this case gzread will directly read from the file without decompression. gzopen returns NULL if the file could not be opened or if there was insufficient memory to allocate the (de)compression state; errno can be checked to distinguish the two cases (if errno is zero, the zlib error is Z_MEM_ERROR). */ /* gzdopen() associates a gzFile with the file descriptor fd. File descriptors are obtained from calls like open, dup, creat, pipe or fileno (in the file has been previously opened with fopen). The mode parameter is as in gzopen. The next call of gzclose on the returned gzFile will also close the file descriptor fd, just like fclose(fdopen(fd), mode) closes the file descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). gzdopen returns NULL if there was insufficient memory to allocate the (de)compression state. */ /* Dynamically update the compression level or strategy. See the description of deflateInit2 for the meaning of these parameters. gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not opened for writing. */ /* Reads the given number of uncompressed bytes from the compressed file. If the input file was not in gzip format, gzread copies the given number of bytes into the buffer. gzread returns the number of uncompressed bytes actually read (0 for end of file, -1 for error). */ /* Writes the given number of uncompressed bytes into the compressed file. gzwrite returns the number of uncompressed bytes actually written (0 in case of error). */ /* Converts, formats, and writes the args to the compressed file under control of the format string, as in fprintf. gzprintf returns the number of uncompressed bytes actually written (0 in case of error). */ /* Writes the given null-terminated string to the compressed file, excluding the terminating null character. gzputs returns the number of characters written, or -1 in case of error. */ /* Reads bytes from the compressed file until len-1 characters are read, or a newline character is read and transferred to buf, or an end-of-file condition is encountered. The string is then terminated with a null character. gzgets returns buf, or Z_NULL in case of error. */ /* Writes c, converted to an unsigned char, into the compressed file. gzputc returns the value that was written, or -1 in case of error. */ /* Reads one byte from the compressed file. gzgetc returns this byte or -1 in case of end of file or error. */ /* Flushes all pending output into the compressed file. The parameter flush is as in the deflate() function. The return value is the zlib error number (see function gzerror below). gzflush returns Z_OK if the flush parameter is Z_FINISH and all output could be flushed. gzflush should be called only when strictly necessary because it can degrade compression. */ /* Sets the starting position for the next gzread or gzwrite on the given compressed file. The offset represents a number of bytes in the uncompressed data stream. The whence parameter is defined as in lseek(2); the value SEEK_END is not supported. If the file is opened for reading, this function is emulated but can be extremely slow. If the file is opened for writing, only forward seeks are supported; gzseek then compresses a sequence of zeroes up to the new starting position. gzseek returns the resulting offset location as measured in bytes from the beginning of the uncompressed stream, or -1 in case of error, in particular if the file is opened for writing and the new starting position would be before the current position. */ /* Rewinds the given file. This function is supported only for reading. gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) */ /* Returns the starting position for the next gzread or gzwrite on the given compressed file. This position represents a number of bytes in the uncompressed data stream. gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) */ /* Returns 1 when EOF has previously been detected reading the given input stream, otherwise zero. */ /* Flushes all pending output if necessary, closes the compressed file and deallocates all the (de)compression state. The return value is the zlib error number (see function gzerror below). */ /* Returns the error message for the last error which occurred on the given compressed file. errnum is set to zlib error number. If an error occurred in the file system and not in the compression library, errnum is set to Z_ERRNO and the application may consult errno to get the exact error code. */ /* checksum functions */ /* These functions are not related to compression but are exported anyway because they might be useful in applications using the compression library. */ ZEXTERN(uLong) adler32 OF((uLong adler, const Bytef *buf, uInt len)); /* Update a running Adler-32 checksum with the bytes buf[0..len-1] and return the updated checksum. If buf is NULL, this function returns the required initial value for the checksum. An Adler-32 checksum is almost as reliable as a CRC32 but can be computed much faster. Usage example: uLong adler = adler32(0L, Z_NULL, 0); while (read_buffer(buffer, length) != EOF) { adler = adler32(adler, buffer, length); } if (adler != original_adler) error(); */ /* Update a running crc with the bytes buf[0..len-1] and return the updated crc. If buf is NULL, this function returns the required initial value for the crc. Pre- and post-conditioning (one's complement) is performed within this function so it shouldn't be done by the application. Usage example: uLong crc = crc32(0L, Z_NULL, 0); while (read_buffer(buffer, length) != EOF) { crc = crc32(crc, buffer, length); } if (crc != original_crc) error(); */ /* various hacks, don't look :) */ /* deflateInit and inflateInit are macros to allow checking the zlib version * and the compiler's view of z_stream: */ ZEXTERN(int) inflateInit2_ OF((z_streamp strm, int windowBits, const char *version, int stream_size)); #define deflateInit(strm, level) \ deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) #define inflateInit(strm) \ inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) #define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ (strategy), ZLIB_VERSION, sizeof(z_stream)) #define inflateInit2(strm, windowBits) \ inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) #ifdef __cplusplus } #endif #endif /* _ZLIB_H */ --- NEW FILE: zconf.h --- /* zconf.h -- configuration of the zlib compression library * Copyright (C) 1995-2002 Jean-loup Gailly. * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id: zconf.h,v 1.1 2006/04/21 16:31:15 eshabtai Exp $ */ #ifndef _ZCONF_H #define _ZCONF_H /* * If you *really* need a unique prefix for all types and library functions, * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. */ #ifdef Z_PREFIX # define deflateInit_ z_deflateInit_ # define deflate z_deflate # define deflateEnd z_deflateEnd # define inflateInit_ z_inflateInit_ # define inflate z_inflate # define inflateEnd z_inflateEnd # define deflateInit2_ z_deflateInit2_ # define deflateSetDictionary z_deflateSetDictionary # define deflateCopy z_deflateCopy # define deflateReset z_deflateReset # define deflateParams z_deflateParams # define inflateInit2_ z_inflateInit2_ # define inflateSetDictionary z_inflateSetDictionary # define inflateSync z_inflateSync # define inflateSyncPoint z_inflateSyncPoint # define inflateReset z_inflateReset # define compress z_compress # define compress2 z_compress2 # define uncompress z_uncompress # define adler32 z_adler32 # define crc32 z_crc32 # define get_crc_table z_get_crc_table # define Byte z_Byte # define uInt z_uInt # define uLong z_uLong # define Bytef z_Bytef # define charf z_charf # define intf z_intf # define uIntf z_uIntf # define uLongf z_uLongf # define voidpf z_voidpf # define voidp z_voidp #endif #if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) # define WIN32 #endif #if defined(__GNUC__) || defined(WIN32) || defined(__386__) || defined(i386) # ifndef __32BIT__ # define __32BIT__ # endif #endif #if defined(__MSDOS__) && !defined(MSDOS) # define MSDOS #endif /* * Compile with -DMAXSEG_64K if the alloc function cannot allocate more * than 64k bytes at a time (needed on systems with 16-bit int). */ #if defined(MSDOS) && !defined(__32BIT__) # define MAXSEG_64K #endif #ifdef MSDOS # define UNALIGNED_OK #endif #if (defined(MSDOS) || defined(_WINDOWS) || defined(WIN32)) && !defined(STDC) # define STDC #endif #if defined(__STDC__) || defined(__cplusplus) || defined(__OS2__) # ifndef STDC # define STDC # endif #endif #ifndef STDC # ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ # define const # endif #endif /* Some Mac compilers merge all .h files incorrectly: */ #if defined(__MWERKS__) || defined(applec) ||defined(THINK_C) ||defined(__SC__) # define NO_DUMMY_DECL #endif /* Old Borland C and LCC incorrectly complains about missing returns: */ #if defined(__BORLANDC__) && (__BORLANDC__ < 0x500) # define NEED_DUMMY_RETURN #endif #if defined(__LCC__) # define NEED_DUMMY_RETURN #endif /* Maximum value for memLevel in deflateInit2 */ #ifndef MAX_MEM_LEVEL # ifdef MAXSEG_64K # define MAX_MEM_LEVEL 8 # else # define MAX_MEM_LEVEL 9 # endif #endif /* Maximum value for windowBits in deflateInit2 and inflateInit2. * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files * created by gzip. (Files created by minigzip can still be extracted by * gzip.) */ #ifndef MAX_WBITS # define MAX_WBITS 15 /* 32K LZ77 window */ #endif /* The memory requirements for deflate are (in bytes): (1 << (windowBits+2)) + (1 << (memLevel+9)) that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) plus a few kilobytes for small objects. For example, if you want to reduce the default memory requirements from 256K to 128K, compile with make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" Of course this will generally degrade compression (there's no free lunch). The memory requirements for inflate are (in bytes) 1 << windowBits that is, 32K for windowBits=15 (default value) plus a few kilobytes for small objects. */ /* Type declarations */ #ifndef OF /* function prototypes */ # ifdef STDC # define OF(args) args # else # define OF(args) () # endif #endif /* The following definitions for FAR are needed only for MSDOS mixed * model programming (small or medium model with some far allocations). * This was tested only with MSC; for other MSDOS compilers you may have * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, * just define FAR to be empty. */ #if (defined(M_I86SM) || defined(M_I86MM)) && !defined(__32BIT__) /* MSC small or medium model */ # define SMALL_MEDIUM # ifdef _MSC_VER # define FAR _far # else # define FAR far # endif #endif #if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__)) # ifndef __32BIT__ # define SMALL_MEDIUM # define FAR _far # endif #endif /* Compile with -DZLIB_DLL for Windows DLL support */ #if defined(ZLIB_DLL) # if defined(_WINDOWS) || defined(WINDOWS) # ifdef FAR # undef FAR # endif # include <windows.h> # define ZEXPORT(x) x WINAPI # ifdef WIN32 # define ZEXPORTVA(x) x WINAPIV # else # define ZEXPORTVA(x) x FAR _cdecl _export # endif # endif # if defined (__BORLANDC__) # if (__BORLANDC__ >= 0x0500) && defined (WIN32) # include <windows.h> # define ZEXPORT(x) x __declspec(dllexport) WINAPI # define ZEXPORTRVA(x) x __declspec(dllexport) WINAPIV # else # if defined (_Windows) && defined (__DLL__) # define ZEXPORT(x) x _export # define ZEXPORTVA(x) x _export # endif # endif # endif #endif #ifndef ZEXPORT # define ZEXPORT(x) static x #endif #ifndef ZEXPORTVA # define ZEXPORTVA(x) static x #endif #ifndef ZEXTERN # define ZEXTERN(x) static x #endif #ifndef ZEXTERNDEF # define ZEXTERNDEF(x) static x #endif #ifndef FAR # define FAR #endif #if !defined(MACOS) && !defined(TARGET_OS_MAC) typedef unsigned char Byte; /* 8 bits */ #endif typedef unsigned int uInt; /* 16 bits or more */ typedef unsigned long uLong; /* 32 bits or more */ #ifdef SMALL_MEDIUM /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ # define Bytef Byte FAR #else typedef Byte FAR Bytef; #endif typedef char FAR charf; typedef int FAR intf; typedef uInt FAR uIntf; typedef uLong FAR uLongf; #ifdef STDC typedef void FAR *voidpf; typedef void *voidp; #else typedef Byte FAR *voidpf; typedef Byte *voidp; #endif #ifdef HAVE_UNISTD_H # include <sys/types.h> /* for off_t */ # include <unistd.h> /* for SEEK_* and off_t */ # define z_off_t off_t #endif #ifndef SEEK_SET # define SEEK_SET 0 /* Seek from beginning of file. */ # define SEEK_CUR 1 /* Seek from current position. */ # define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ #endif #ifndef z_off_t # define z_off_t long #endif /* MVS linker does not support external names larger than 8 bytes */ #if defined(__MVS__) # pragma map(deflateInit_,"DEIN") # pragma map(deflateInit2_,"DEIN2") # pragma map(deflateEnd,"DEEND") # pragma map(inflateInit_,"ININ") # pragma map(inflateInit2_,"ININ2") # pragma map(inflateEnd,"INEND") # pragma map(inflateSync,"INSY") # pragma map(inflateSetDictionary,"INSEDI") # pragma map(inflate_blocks,"INBL") # pragma map(inflate_blocks_new,"INBLNE") # pragma map(inflate_blocks_free,"INBLFR") # pragma map(inflate_blocks_reset,"INBLRE") # pragma map(inflate_codes_free,"INCOFR") # pragma map(inflate_codes,"INCO") # pragma map(inflate_fast,"INFA") # pragma map(inflate_flush,"INFLU") # pragma map(inflate_mask,"INMA") # pragma map(inflate_set_dictionary,"INSEDI2") # pragma map(inflate_copyright,"INCOPY") # pragma map(inflate_trees_bits,"INTRBI") # pragma map(inflate_trees_dynamic,"INTRDY") # pragma map(inflate_trees_fixed,"INTRFI") # pragma map(inflate_trees_free,"INTRFR") #endif #endif /* _ZCONF_H */ --- NEW FILE: infblock.h --- /* infblock.h -- header to use infblock.c * Copyright (C) 1995-2002 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* WARNING: this file should *not* be used by applications. It is part of the implementation of the compression library and is subject to change. Applications should only use zlib.h. */ #ifndef _INFBLOCK_H #define _INFBLOCK_H struct inflate_blocks_state; typedef struct inflate_blocks_state FAR inflate_blocks_statef; local inflate_blocks_statef * inflate_blocks_new OF(( z_streamp z, check_func c, /* check function */ uInt w)); /* window size */ local int inflate_blocks OF(( inflate_blocks_statef *, z_streamp , int)); /* initial return code */ local void inflate_blocks_reset OF(( inflate_blocks_statef *, z_streamp , uLongf *)); /* check value on output */ local int inflate_blocks_free OF(( inflate_blocks_statef *, z_streamp)); #endif /* _INFBLOCK_H */ --- NEW FILE: zutil.h --- /* zutil.h -- internal interface and configuration of the compression library * Copyright (C) 1995-2002 Jean-loup Gailly. * For conditions of distribution and use, see copyright notice in zlib.h */ /* WARNING: this file should *not* be used by applications. It is part of the implementation of the compression library and is subject to change. Applications should only use zlib.h. */ /* @(#) $Id: zutil.h,v 1.1 2006/04/21 16:31:15 eshabtai Exp $ */ #ifndef _Z_UTIL_H #define _Z_UTIL_H #include "zlib.h" #ifdef STDC # include <stddef.h> # include <string.h> # include <stdlib.h> #endif #ifdef NO_ERRNO_H extern int errno; #else # include <errno.h> #endif #ifndef local # define local static #endif /* compile with -Dlocal if your debugger can't find static symbols */ typedef unsigned char uch; typedef uch FAR uchf; typedef unsigned short ush; typedef ush FAR ushf; typedef unsigned long ulg; #define ERR_RETURN(strm,err) \ return (strm->msg = (char*)ERR_MSG(err), (err)) /* To be used only when the state is known to be valid */ /* common constants */ #ifndef DEF_WBITS # define DEF_WBITS MAX_WBITS #endif /* default windowBits for decompression. MAX_WBITS is for compression only */ #if MAX_MEM_LEVEL >= 8 # define DEF_MEM_LEVEL 8 #else # define DEF_MEM_LEVEL MAX_MEM_LEVEL #endif /* default memLevel */ #define STORED_BLOCK 0 #define STATIC_TREES 1 #define DYN_TREES 2 /* The three kinds of block type */ #define MIN_MATCH 3 #define MAX_MATCH 258 /* The minimum and maximum match lengths */ #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ /* target dependencies */ #ifdef MSDOS # define OS_CODE 0x00 # if defined(__TURBOC__) || defined(__BORLANDC__) # if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) /* Allow compilation with ANSI keywords only enabled */ void _Cdecl farfree( void *block ); void *_Cdecl farmalloc( unsigned long nbytes ); # else # include <alloc.h> # endif # else /* MSC or DJGPP */ # include <malloc.h> # endif #endif #ifdef OS2 # define OS_CODE 0x06 #endif #ifdef WIN32 /* Window 95 & Windows NT */ # define OS_CODE 0x0b #endif #if defined(VAXC) || defined(VMS) # define OS_CODE 0x02 # define F_OPEN(name, mode) \ fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") #endif #ifdef AMIGA # define OS_CODE 0x01 #endif #if defined(ATARI) || defined(atarist) # define OS_CODE 0x05 #endif #if defined(MACOS) || defined(TARGET_OS_MAC) # define OS_CODE 0x07 # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os # include <unix.h> /* for fdopen */ # else # ifndef fdopen # define fdopen(fd,mode) NULL /* No fdopen() */ # endif # endif #endif #ifdef __50SERIES /* Prime/PRIMOS */ # define OS_CODE 0x0F #endif #ifdef TOPS20 # define OS_CODE 0x0a #endif #if defined(_BEOS_) || defined(RISCOS) # define fdopen(fd,mode) NULL /* No fdopen() */ #endif #if (defined(_MSC_VER) && (_MSC_VER > 600)) # define fdopen(fd,type) _fdopen(fd,type) #endif /* Common defaults */ #ifndef OS_CODE # define OS_CODE 0x03 /* assume Unix */ #endif #ifndef F_OPEN # define F_OPEN(name, mode) fopen((name), (mode)) #endif /* functions */ #ifdef HAVE_STRERROR extern char *strerror OF((int)); # define zstrerror(errnum) strerror(errnum) #else # define zstrerror(errnum) "" #endif #if defined(pyr) # define NO_MEMCPY #endif #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) /* Use our own functions for small and medium model with MSC <= 5.0. * You may have to use the same strategy for Borland C (untested). * The __SC__ check is for Symantec. */ # define NO_MEMCPY #endif #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) # define HAVE_MEMCPY #endif #ifdef HAVE_MEMCPY # ifdef SMALL_MEDIUM /* MSDOS small or medium model */ # define zmemcpy _fmemcpy # define zmemcmp _fmemcmp # define zmemzero(dest, len) _fmemset(dest, 0, len) # else # define zmemcpy ft_memcpy # define zmemcmp ft_memcmp # define zmemzero(dest, len) ft_memset(dest, 0, len) # endif #else extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); extern void zmemzero OF((Bytef* dest, uInt len)); #endif /* Diagnostic functions */ #ifdef DEBUG # include <stdio.h> extern int z_verbose; extern void z_error OF((char *m)); # define Assert(cond,msg) {if(!(cond)) z_error(msg);} # define Trace(x) {if (z_verbose>=0) fprintf x ;} # define Tracev(x) {if (z_verbose>0) fprintf x ;} # define Tracevv(x) {if (z_verbose>1) fprintf x ;} # define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} # define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} #else # define Assert(cond,msg) # define Trace(x) # define Tracev(x) # define Tracevv(x) # define Tracec(c,x) # define Tracecv(c,x) #endif typedef uLong (*check_func) OF((uLong check, const Bytef *buf, uInt len)); local voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); local void zcfree OF((voidpf opaque, voidpf ptr)); #defi... [truncated message content] |
From: Ehud S. <esh...@us...> - 2006-04-21 16:31:17
|
Update of /cvsroot/roadmap/roadmap_editor/src/freetype/src/base In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28321/src/base Added Files: Jamfile rules.mk Log Message: Import freetype sources. --- NEW FILE: rules.mk --- # # FreeType 2 base layer configuration rules # # Copyright 1996-2000, 2002, 2003, 2004, 2005 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, # and distributed under the terms of the FreeType project license, # LICENSE.TXT. By continuing to use, modify, or distribute this file you # indicate that you have read the license and understand and accept it # fully. # It sets the following variables which are used by the master Makefile # after the call: # # BASE_OBJ_S: The single-object base layer. # BASE_OBJ_M: A list of all objects for a multiple-objects build. # BASE_EXT_OBJ: A list of base layer extensions, i.e., components found # in `freetype/src/base' which are not compiled within the # base layer proper. # # BASE_H is defined in freetype.mk to simplify the dependency rules. BASE_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(SRC_DIR)/base) # Base layer sources # # ftsystem, ftinit, and ftdebug are handled by freetype.mk # BASE_SRC := $(BASE_DIR)/ftapi.c \ $(BASE_DIR)/ftcalc.c \ $(BASE_DIR)/ftdbgmem.c \ $(BASE_DIR)/ftgloadr.c \ $(BASE_DIR)/ftnames.c \ $(BASE_DIR)/ftobjs.c \ $(BASE_DIR)/ftoutln.c \ $(BASE_DIR)/ftrfork.c \ $(BASE_DIR)/ftstream.c \ $(BASE_DIR)/fttrigon.c \ $(BASE_DIR)/ftutil.c # Base layer `extensions' sources # # An extension is added to the library file (.a or .lib) as a separate # object. It will then be linked to the final executable only if one of its # symbols is used by the application. # BASE_EXT_SRC := $(BASE_DIR)/ftbitmap.c \ $(BASE_DIR)/ftbbox.c \ $(BASE_DIR)/ftbdf.c \ $(BASE_DIR)/ftglyph.c \ $(BASE_DIR)/ftmm.c \ $(BASE_DIR)/ftotval.c \ $(BASE_DIR)/ftpfr.c \ $(BASE_DIR)/ftstroke.c \ $(BASE_DIR)/ftsynth.c \ $(BASE_DIR)/fttype1.c \ $(BASE_DIR)/ftwinfnt.c \ $(BASE_DIR)/ftxf86.c # Default extensions objects # BASE_EXT_OBJ := $(BASE_EXT_SRC:$(BASE_DIR)/%.c=$(OBJ_DIR)/%.$O) # Base layer object(s) # # BASE_OBJ_M is used during `multi' builds (each base source file compiles # to a single object file). # # BASE_OBJ_S is used during `single' builds (the whole base layer is # compiled as a single object file using ftbase.c). # BASE_OBJ_M := $(BASE_SRC:$(BASE_DIR)/%.c=$(OBJ_DIR)/%.$O) BASE_OBJ_S := $(OBJ_DIR)/ftbase.$O # Base layer root source file for single build # BASE_SRC_S := $(BASE_DIR)/ftbase.c # Base layer - single object build # $(BASE_OBJ_S): $(BASE_SRC_S) $(BASE_SRC) $(FREETYPE_H) $(BASE_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $(BASE_SRC_S)) # Multiple objects build + extensions # $(OBJ_DIR)/%.$O: $(BASE_DIR)/%.c $(FREETYPE_H) $(BASE_COMPILE) $T$(subst /,$(COMPILER_SEP),$@ $<) # EOF --- NEW FILE: Jamfile --- # FreeType 2 src/base Jamfile # # Copyright 2001, 2002, 2003, 2004 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, # and distributed under the terms of the FreeType project license, # LICENSE.TXT. By continuing to use, modify, or distribute this file you # indicate that you have read the license and understand and accept it # fully. SubDir FT2_TOP $(FT2_SRC_DIR) base ; { local _sources ; if $(FT2_MULTI) { _sources = ftutil ftdbgmem ftstream ftcalc fttrigon ftgloadr ftoutln ftobjs ftnames ftrfork ; } else { _sources = ftbase ; } Library $(FT2_LIB) : $(_sources).c ; } # Add the optional/replaceable files. # Library $(FT2_LIB) : ftsystem.c ftinit.c ftglyph.c ftmm.c ftbdf.c ftbbox.c ftdebug.c ftxf86.c fttype1.c ftpfr.c ftstroke.c ftwinfnt.c ftotval.c ftbitmap.c ; # Add Macintosh-specific file to the library when necessary. # if $(MAC) { Library $(FT2_LIB) : ftmac.c ; } # end of src/base Jamfile |
From: Ehud S. <esh...@us...> - 2006-04-21 16:22:42
|
Update of /cvsroot/roadmap/roadmap_editor/src/freetype/src/winfonts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22848/src/winfonts Added Files: winfnt.c Log Message: Import freetype sources. --- NEW FILE: winfnt.c --- /***************************************************************************/ /* */ /* winfnt.c */ /* */ /* FreeType font driver for Windows FNT/FON files */ /* */ /* Copyright 1996-2001, 2002, 2003, 2004 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include <ft2build.h> #include FT_WINFONTS_H #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_STREAM_H #include FT_INTERNAL_OBJECTS_H #include "winfnt.h" #include "fnterrs.h" #include FT_SERVICE_WINFNT_H #include FT_SERVICE_XFREE86_NAME_H /*************************************************************************/ /* */ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ /* messages during execution. */ /* */ #undef FT_COMPONENT #define FT_COMPONENT trace_winfnt static const FT_Frame_Field winmz_header_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE WinMZ_HeaderRec FT_FRAME_START( 64 ), FT_FRAME_USHORT_LE ( magic ), FT_FRAME_SKIP_BYTES( 29 * 2 ), FT_FRAME_ULONG_LE ( lfanew ), FT_FRAME_END }; static const FT_Frame_Field winne_header_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE WinNE_HeaderRec FT_FRAME_START( 40 ), FT_FRAME_USHORT_LE ( magic ), FT_FRAME_SKIP_BYTES( 34 ), FT_FRAME_USHORT_LE ( resource_tab_offset ), FT_FRAME_USHORT_LE ( rname_tab_offset ), FT_FRAME_END }; static const FT_Frame_Field winfnt_header_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE FT_WinFNT_HeaderRec FT_FRAME_START( 148 ), FT_FRAME_USHORT_LE( version ), FT_FRAME_ULONG_LE ( file_size ), FT_FRAME_BYTES ( copyright, 60 ), FT_FRAME_USHORT_LE( file_type ), FT_FRAME_USHORT_LE( nominal_point_size ), FT_FRAME_USHORT_LE( vertical_resolution ), FT_FRAME_USHORT_LE( horizontal_resolution ), FT_FRAME_USHORT_LE( ascent ), FT_FRAME_USHORT_LE( internal_leading ), FT_FRAME_USHORT_LE( external_leading ), FT_FRAME_BYTE ( italic ), FT_FRAME_BYTE ( underline ), FT_FRAME_BYTE ( strike_out ), FT_FRAME_USHORT_LE( weight ), FT_FRAME_BYTE ( charset ), FT_FRAME_USHORT_LE( pixel_width ), FT_FRAME_USHORT_LE( pixel_height ), FT_FRAME_BYTE ( pitch_and_family ), FT_FRAME_USHORT_LE( avg_width ), FT_FRAME_USHORT_LE( max_width ), FT_FRAME_BYTE ( first_char ), FT_FRAME_BYTE ( last_char ), FT_FRAME_BYTE ( default_char ), FT_FRAME_BYTE ( break_char ), FT_FRAME_USHORT_LE( bytes_per_row ), FT_FRAME_ULONG_LE ( device_offset ), FT_FRAME_ULONG_LE ( face_name_offset ), FT_FRAME_ULONG_LE ( bits_pointer ), FT_FRAME_ULONG_LE ( bits_offset ), FT_FRAME_BYTE ( reserved ), FT_FRAME_ULONG_LE ( flags ), FT_FRAME_USHORT_LE( A_space ), FT_FRAME_USHORT_LE( B_space ), FT_FRAME_USHORT_LE( C_space ), FT_FRAME_ULONG_LE ( color_table_offset ), FT_FRAME_BYTES ( reserved1, 16 ), FT_FRAME_END }; static void fnt_font_done( FNT_Face face ) { FT_Memory memory = FT_FACE( face )->memory; FT_Stream stream = FT_FACE( face )->stream; FNT_Font font = face->font; if ( !font ) return; if ( font->fnt_frame ) FT_FRAME_RELEASE( font->fnt_frame ); FT_FREE( font->family_name ); FT_FREE( font ); face->font = 0; } static FT_Error fnt_font_load( FNT_Font font, FT_Stream stream ) { FT_Error error; FT_WinFNT_Header header = &font->header; FT_Bool new_format; FT_UInt size; /* first of all, read the FNT header */ if ( FT_STREAM_SEEK( font->offset ) || FT_STREAM_READ_FIELDS( winfnt_header_fields, header ) ) goto Exit; /* check header */ if ( header->version != 0x200 && header->version != 0x300 ) { FT_TRACE2(( "[not a valid FNT file]\n" )); error = FNT_Err_Unknown_File_Format; goto Exit; } new_format = FT_BOOL( font->header.version == 0x300 ); size = new_format ? 148 : 118; if ( header->file_size < size ) { FT_TRACE2(( "[not a valid FNT file]\n" )); error = FNT_Err_Unknown_File_Format; goto Exit; } /* Version 2 doesn't have these fields */ if ( header->version == 0x200 ) { header->flags = 0; header->A_space = 0; header->B_space = 0; header->C_space = 0; header->color_table_offset = 0; } if ( header->file_type & 1 ) { FT_TRACE2(( "[can't handle vector FNT fonts]\n" )); error = FNT_Err_Unknown_File_Format; goto Exit; } /* this is a FNT file/table; extract its frame */ if ( FT_STREAM_SEEK( font->offset ) || FT_FRAME_EXTRACT( header->file_size, font->fnt_frame ) ) goto Exit; Exit: return error; } static FT_Error fnt_face_get_dll_font( FNT_Face face, FT_Int face_index ) { FT_Error error; FT_Stream stream = FT_FACE( face )->stream; FT_Memory memory = FT_FACE( face )->memory; WinMZ_HeaderRec mz_header; face->font = 0; /* does it begin with an MZ header? */ if ( FT_STREAM_SEEK( 0 ) || FT_STREAM_READ_FIELDS( winmz_header_fields, &mz_header ) ) goto Exit; error = FNT_Err_Unknown_File_Format; if ( mz_header.magic == WINFNT_MZ_MAGIC ) { /* yes, now look for an NE header in the file */ WinNE_HeaderRec ne_header; if ( FT_STREAM_SEEK( mz_header.lfanew ) || FT_STREAM_READ_FIELDS( winne_header_fields, &ne_header ) ) goto Exit; error = FNT_Err_Unknown_File_Format; if ( ne_header.magic == WINFNT_NE_MAGIC ) { /* good, now look into the resource table for each FNT resource */ FT_ULong res_offset = mz_header.lfanew + ne_header.resource_tab_offset; FT_UShort size_shift; FT_UShort font_count = 0; FT_ULong font_offset = 0; if ( FT_STREAM_SEEK( res_offset ) || FT_FRAME_ENTER( ne_header.rname_tab_offset - ne_header.resource_tab_offset ) ) goto Exit; size_shift = FT_GET_USHORT_LE(); for (;;) { FT_UShort type_id, count; type_id = FT_GET_USHORT_LE(); if ( !type_id ) break; count = FT_GET_USHORT_LE(); if ( type_id == 0x8008U ) { font_count = count; font_offset = (FT_ULong)( FT_STREAM_POS() + 4 + ( stream->cursor - stream->limit ) ); break; } stream->cursor += 4 + count * 12; } FT_FRAME_EXIT(); if ( !font_count || !font_offset ) { FT_TRACE2(( "this file doesn't contain any FNT resources!\n" )); error = FNT_Err_Unknown_File_Format; goto Exit; } face->root.num_faces = font_count; if ( face_index >= font_count ) { error = FNT_Err_Bad_Argument; goto Exit; } if ( FT_NEW( face->font ) ) goto Exit; if ( FT_STREAM_SEEK( font_offset + face_index * 12 ) || FT_FRAME_ENTER( 12 ) ) goto Fail; face->font->offset = (FT_ULong)FT_GET_USHORT_LE() << size_shift; face->font->fnt_size = (FT_ULong)FT_GET_USHORT_LE() << size_shift; face->font->size_shift = size_shift; stream->cursor += 8; FT_FRAME_EXIT(); error = fnt_font_load( face->font, stream ); } } Fail: if ( error ) fnt_font_done( face ); Exit: return error; } typedef struct FNT_CMapRec_ { FT_CMapRec cmap; FT_UInt32 first; FT_UInt32 count; } FNT_CMapRec, *FNT_CMap; static FT_Error fnt_cmap_init( FNT_CMap cmap ) { FNT_Face face = (FNT_Face)FT_CMAP_FACE( cmap ); FNT_Font font = face->font; cmap->first = (FT_UInt32) font->header.first_char; cmap->count = (FT_UInt32)( font->header.last_char - cmap->first + 1 ); return 0; } static FT_UInt fnt_cmap_char_index( FNT_CMap cmap, FT_UInt32 char_code ) { FT_UInt gindex = 0; char_code -= cmap->first; if ( char_code < cmap->count ) gindex = char_code + 1; /* we artificially increase the glyph index; */ /* FNT_Load_Glyph reverts to the right one */ return gindex; } static FT_UInt fnt_cmap_char_next( FNT_CMap cmap, FT_UInt32 *pchar_code ) { FT_UInt gindex = 0; FT_UInt32 result = 0; FT_UInt32 char_code = *pchar_code + 1; if ( char_code <= cmap->first ) { result = cmap->first; gindex = 1; } else { char_code -= cmap->first; if ( char_code < cmap->count ) { result = cmap->first + char_code; gindex = char_code + 1; } } *pchar_code = result; return gindex; } static const FT_CMap_ClassRec fnt_cmap_class_rec = { sizeof ( FNT_CMapRec ), (FT_CMap_InitFunc) fnt_cmap_init, (FT_CMap_DoneFunc) NULL, (FT_CMap_CharIndexFunc)fnt_cmap_char_index, (FT_CMap_CharNextFunc) fnt_cmap_char_next }; static FT_CMap_Class const fnt_cmap_class = &fnt_cmap_class_rec; static void FNT_Face_Done( FNT_Face face ) { FT_Memory memory = FT_FACE_MEMORY( face ); fnt_font_done( face ); FT_FREE( face->root.available_sizes ); face->root.num_fixed_sizes = 0; } static FT_Error FNT_Face_Init( FT_Stream stream, FNT_Face face, FT_Int face_index, FT_Int num_params, FT_Parameter* params ) { FT_Error error; FT_Memory memory = FT_FACE_MEMORY( face ); FT_UNUSED( num_params ); FT_UNUSED( params ); /* try to load font from a DLL */ error = fnt_face_get_dll_font( face, face_index ); if ( error ) { /* this didn't work; try to load a single FNT font */ FNT_Font font; if ( FT_NEW( face->font ) ) goto Exit; face->root.num_faces = 1; font = face->font; font->offset = 0; font->fnt_size = stream->size; error = fnt_font_load( font, stream ); if ( error ) goto Fail; } /* we now need to fill the root FT_Face fields */ /* with relevant information */ { FT_Face root = FT_FACE( face ); FNT_Font font = face->font; FT_PtrDist family_size; root->face_flags = FT_FACE_FLAG_FIXED_SIZES | FT_FACE_FLAG_HORIZONTAL; if ( font->header.avg_width == font->header.max_width ) root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH; if ( font->header.italic ) root->style_flags |= FT_STYLE_FLAG_ITALIC; if ( font->header.weight >= 800 ) root->style_flags |= FT_STYLE_FLAG_BOLD; /* set up the `fixed_sizes' array */ if ( FT_NEW_ARRAY( root->available_sizes, 1 ) ) goto Fail; root->num_fixed_sizes = 1; { FT_Bitmap_Size* bsize = root->available_sizes; bsize->width = font->header.avg_width; bsize->height = (FT_Short)( font->header.pixel_height + font->header.external_leading ); bsize->size = font->header.nominal_point_size << 6; bsize->x_ppem = font->header.pixel_width << 6; bsize->y_ppem = font->header.pixel_height << 6; } { FT_CharMapRec charmap; charmap.encoding = FT_ENCODING_NONE; charmap.platform_id = 0; charmap.encoding_id = 0; charmap.face = root; if ( font->header.charset == FT_WinFNT_ID_MAC ) { charmap.encoding = FT_ENCODING_APPLE_ROMAN; charmap.platform_id = 1; /* charmap.encoding_id = 0; */ } error = FT_CMap_New( fnt_cmap_class, NULL, &charmap, NULL ); if ( error ) goto Fail; /* Select default charmap */ if ( root->num_charmaps ) root->charmap = root->charmaps[0]; } /* setup remaining flags */ /* reserve one slot for the .notdef glyph at index 0 */ root->num_glyphs = font->header.last_char - font->header.first_char + 1 + 1; /* Some broken fonts don't delimit the face name with a final */ /* NULL byte -- the frame is erroneously one byte too small. */ /* We thus allocate one more byte, setting it explicitly to */ /* zero. */ family_size = font->header.file_size - font->header.face_name_offset; if ( FT_ALLOC( font->family_name, family_size + 1 ) ) goto Fail; FT_MEM_COPY( font->family_name, font->fnt_frame + font->header.face_name_offset, family_size ); font->family_name[family_size] = '\0'; if ( FT_REALLOC( font->family_name, family_size, ft_strlen( font->family_name ) + 1 ) ) goto Fail; root->family_name = font->family_name; root->style_name = (char *)"Regular"; if ( root->style_flags & FT_STYLE_FLAG_BOLD ) { if ( root->style_flags & FT_STYLE_FLAG_ITALIC ) root->style_name = (char *)"Bold Italic"; else root->style_name = (char *)"Bold"; } else if ( root->style_flags & FT_STYLE_FLAG_ITALIC ) root->style_name = (char *)"Italic"; } goto Exit; Fail: FNT_Face_Done( face ); Exit: return error; } static FT_Error FNT_Size_Set_Pixels( FT_Size size ) { FNT_Face face = (FNT_Face)FT_SIZE_FACE( size ); FT_Face root = FT_FACE( face ); if ( size->metrics.y_ppem == root->available_sizes->y_ppem >> 6 ) { FNT_Font font = face->font; size->metrics.ascender = font->header.ascent * 64; size->metrics.descender = -( font->header.pixel_height - font->header.ascent ) * 64; size->metrics.height = font->header.pixel_height * 64; size->metrics.max_advance = font->header.max_width * 64; return FNT_Err_Ok; } else return FNT_Err_Invalid_Pixel_Size; } static FT_Error FNT_Load_Glyph( FT_GlyphSlot slot, FT_Size size, FT_UInt glyph_index, FT_Int32 load_flags ) { FNT_Face face = (FNT_Face)FT_SIZE_FACE( size ); FNT_Font font = face->font; FT_Error error = FNT_Err_Ok; FT_Byte* p; FT_Int len; FT_Bitmap* bitmap = &slot->bitmap; FT_ULong offset; FT_Bool new_format; FT_UNUSED( load_flags ); if ( !face || !font ) { error = FNT_Err_Invalid_Argument; goto Exit; } if ( glyph_index > 0 ) glyph_index--; /* revert to real index */ else glyph_index = font->header.default_char; /* the .notdef glyph */ new_format = FT_BOOL( font->header.version == 0x300 ); len = new_format ? 6 : 4; /* jump to glyph entry */ p = font->fnt_frame + ( new_format ? 148 : 118 ) + len * glyph_index; bitmap->width = FT_NEXT_SHORT_LE( p ); if ( new_format ) offset = FT_NEXT_ULONG_LE( p ); else offset = FT_NEXT_USHORT_LE( p ); if ( offset >= font->header.file_size ) { FT_TRACE2(( "invalid FNT offset!\n" )); error = FNT_Err_Invalid_File_Format; goto Exit; } /* jump to glyph data */ p = font->fnt_frame + /* font->header.bits_offset */ + offset; /* allocate and build bitmap */ { FT_Memory memory = FT_FACE_MEMORY( slot->face ); FT_Int pitch = ( bitmap->width + 7 ) >> 3; FT_Byte* column; FT_Byte* write; bitmap->pitch = pitch; bitmap->rows = font->header.pixel_height; bitmap->pixel_mode = FT_PIXEL_MODE_MONO; /* note: since glyphs are stored in columns and not in rows we */ /* can't use ft_glyphslot_set_bitmap */ if ( FT_ALLOC( bitmap->buffer, pitch * bitmap->rows ) ) goto Exit; column = (FT_Byte*)bitmap->buffer; for ( ; pitch > 0; pitch--, column++ ) { FT_Byte* limit = p + bitmap->rows; for ( write = column; p < limit; p++, write += bitmap->pitch ) *write = *p; } } slot->internal->flags = FT_GLYPH_OWN_BITMAP; slot->bitmap_left = 0; slot->bitmap_top = font->header.ascent; slot->format = FT_GLYPH_FORMAT_BITMAP; /* now set up metrics */ slot->metrics.width = bitmap->width << 6; slot->metrics.height = bitmap->rows << 6; slot->metrics.horiAdvance = bitmap->width << 6; slot->metrics.horiBearingX = 0; slot->metrics.horiBearingY = slot->bitmap_top << 6; slot->linearHoriAdvance = (FT_Fixed)bitmap->width << 16; slot->format = FT_GLYPH_FORMAT_BITMAP; Exit: return error; } static FT_Error winfnt_get_header( FT_Face face, FT_WinFNT_HeaderRec *aheader ) { FNT_Font font = ((FNT_Face)face)->font; *aheader = font->header; return 0; } static const FT_Service_WinFntRec winfnt_service_rec = { winfnt_get_header }; /* * SERVICE LIST * */ static const FT_ServiceDescRec winfnt_services[] = { { FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_WINFNT }, { FT_SERVICE_ID_WINFNT, &winfnt_service_rec }, { NULL, NULL } }; static FT_Module_Interface winfnt_get_service( FT_Driver driver, const FT_String* service_id ) { FT_UNUSED( driver ); return ft_service_list_lookup( winfnt_services, service_id ); } FT_CALLBACK_TABLE_DEF const FT_Driver_ClassRec winfnt_driver_class = { { FT_MODULE_FONT_DRIVER | FT_MODULE_DRIVER_NO_OUTLINES, sizeof ( FT_DriverRec ), "winfonts", 0x10000L, 0x20000L, 0, (FT_Module_Constructor)0, (FT_Module_Destructor) 0, (FT_Module_Requester) winfnt_get_service }, sizeof( FNT_FaceRec ), sizeof( FT_SizeRec ), sizeof( FT_GlyphSlotRec ), (FT_Face_InitFunc) FNT_Face_Init, (FT_Face_DoneFunc) FNT_Face_Done, (FT_Size_InitFunc) 0, (FT_Size_DoneFunc) 0, (FT_Slot_InitFunc) 0, (FT_Slot_DoneFunc) 0, (FT_Size_ResetPointsFunc) FNT_Size_Set_Pixels, (FT_Size_ResetPixelsFunc) FNT_Size_Set_Pixels, (FT_Slot_LoadFunc) FNT_Load_Glyph, (FT_Face_GetKerningFunc) 0, (FT_Face_AttachFunc) 0, (FT_Face_GetAdvancesFunc) 0 }; /* END */ |
From: Ehud S. <esh...@us...> - 2006-04-21 16:22:42
|
Update of /cvsroot/roadmap/roadmap_editor/src/freetype/src/tools In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22848/src/tools Added Files: test_bbox.c test_trig.c Log Message: Import freetype sources. --- NEW FILE: test_bbox.c --- #include <ft2build.h> #include FT_FREETYPE_H #include FT_BBOX_H #include <time.h> /* for clock() */ /* SunOS 4.1.* does not define CLOCKS_PER_SEC, so include <sys/param.h> */ /* to get the HZ macro which is the equivalent. */ #if defined(__sun__) && !defined(SVR4) && !defined(__SVR4) #include <sys/param.h> #define CLOCKS_PER_SEC HZ #endif static long get_time( void ) { return clock() * 10000L / CLOCKS_PER_SEC; } /* test bbox computations */ #define XSCALE 65536 #define XX(x) ((FT_Pos)(x*XSCALE)) #define XVEC(x,y) { XX(x), XX(y) } #define XVAL(x) ((x)/(1.0*XSCALE)) /* dummy outline #1 */ static FT_Vector dummy_vec_1[4] = { #if 1 XVEC( 408.9111, 535.3164 ), XVEC( 455.8887, 634.396 ), XVEC( -37.8765, 786.2207 ), XVEC( 164.6074, 535.3164 ) #else { (FT_Int32)0x0198E93DL , (FT_Int32)0x021750FFL }, /* 408.9111, 535.3164 */ { (FT_Int32)0x01C7E312L , (FT_Int32)0x027A6560L }, /* 455.8887, 634.3960 */ { (FT_Int32)0xFFDA1F9EL , (FT_Int32)0x0312387FL }, /* -37.8765, 786.2207 */ { (FT_Int32)0x00A49B7EL , (FT_Int32)0x021750FFL } /* 164.6074, 535.3164 */ #endif }; static char dummy_tag_1[4] = { FT_CURVE_TAG_ON, FT_CURVE_TAG_CUBIC, FT_CURVE_TAG_CUBIC, FT_CURVE_TAG_ON }; static short dummy_contour_1[1] = { 3 }; static FT_Outline dummy_outline_1 = { 1, 4, dummy_vec_1, dummy_tag_1, dummy_contour_1, 0 }; /* dummy outline #2 */ static FT_Vector dummy_vec_2[4] = { XVEC( 100.0, 100.0 ), XVEC( 100.0, 200.0 ), XVEC( 200.0, 200.0 ), XVEC( 200.0, 133.0 ) }; static FT_Outline dummy_outline_2 = { 1, 4, dummy_vec_2, dummy_tag_1, dummy_contour_1, 0 }; static void dump_outline( FT_Outline* outline ) { FT_BBox bbox; /* compute and display cbox */ FT_Outline_Get_CBox( outline, &bbox ); printf( "cbox = [%.2f %.2f %.2f %.2f]\n", XVAL( bbox.xMin ), XVAL( bbox.yMin ), XVAL( bbox.xMax ), XVAL( bbox.yMax ) ); /* compute and display bbox */ FT_Outline_Get_BBox( outline, &bbox ); printf( "bbox = [%.2f %.2f %.2f %.2f]\n", XVAL( bbox.xMin ), XVAL( bbox.yMin ), XVAL( bbox.xMax ), XVAL( bbox.yMax ) ); } static void profile_outline( FT_Outline* outline, long repeat ) { FT_BBox bbox; long count; long time0; time0 = get_time(); for ( count = repeat; count > 0; count-- ) FT_Outline_Get_CBox( outline, &bbox ); time0 = get_time() - time0; printf( "time = %5.2f cbox = [%.2f %.2f %.2f %.2f]\n", ((double)time0/10000.0), XVAL( bbox.xMin ), XVAL( bbox.yMin ), XVAL( bbox.xMax ), XVAL( bbox.yMax ) ); time0 = get_time(); for ( count = repeat; count > 0; count-- ) FT_Outline_Get_BBox( outline, &bbox ); time0 = get_time() - time0; printf( "time = %5.2f bbox = [%.2f %.2f %.2f %.2f]\n", ((double)time0/10000.0), XVAL( bbox.xMin ), XVAL( bbox.yMin ), XVAL( bbox.xMax ), XVAL( bbox.yMax ) ); } #define REPEAT 100000L int main( int argc, char** argv ) { printf( "outline #1\n" ); profile_outline( &dummy_outline_1, REPEAT ); printf( "outline #2\n" ); profile_outline( &dummy_outline_2, REPEAT ); return 0; } --- NEW FILE: test_trig.c --- #include <ft2build.h> #include FT_FREETYPE_H #include FT_TRIGONOMETRY_H #include <math.h> #include <stdio.h> #define PI 3.14159265358979323846 #define SPI (PI/FT_ANGLE_PI) /* the precision in 16.16 fixed float points of the checks. Expect */ /* between 2 and 5 noise LSB bits during operations, due to */ /* rounding errors.. */ #define THRESHOLD 64 static error = 0; static void test_cos( void ) { FT_Fixed f1, f2; double d1, d2; int i; for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 ) { f1 = FT_Cos(i); d1 = f1/65536.0; d2 = cos( i*SPI ); f2 = (FT_Fixed)(d2*65536.0); if ( abs( f2-f1 ) > THRESHOLD ) { error = 1; printf( "FT_Cos[%3d] = %.7f cos[%3d] = %.7f\n", (i >> 16), f1/65536.0, (i >> 16), d2 ); } } } static void test_sin( void ) { FT_Fixed f1, f2; double d1, d2; int i; for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 ) { f1 = FT_Sin(i); d1 = f1/65536.0; d2 = sin( i*SPI ); f2 = (FT_Fixed)(d2*65536.0); if ( abs( f2-f1 ) > THRESHOLD ) { error = 1; printf( "FT_Sin[%3d] = %.7f sin[%3d] = %.7f\n", (i >> 16), f1/65536.0, (i >> 16), d2 ); } } } static void test_tan( void ) { FT_Fixed f1, f2; double d1, d2; int i; for ( i = 0; i < FT_ANGLE_PI2-0x2000000; i += 0x10000 ) { f1 = FT_Tan(i); d1 = f1/65536.0; d2 = tan( i*SPI ); f2 = (FT_Fixed)(d2*65536.0); if ( abs( f2-f1 ) > THRESHOLD ) { error = 1; printf( "FT_Tan[%3d] = %.7f tan[%3d] = %.7f\n", (i >> 16), f1/65536.0, (i >> 16), d2 ); } } } static void test_atan2( void ) { FT_Fixed c2, s2; double l, a, c1, s1; int i, j; for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 ) { l = 5.0; a = i*SPI; c1 = l * cos(a); s1 = l * sin(a); c2 = (FT_Fixed)(c1*65536.0); s2 = (FT_Fixed)(s1*65536.0); j = FT_Atan2( c2, s2 ); if ( j < 0 ) j += FT_ANGLE_2PI; if ( abs( i - j ) > 1 ) { printf( "FT_Atan2( %.7f, %.7f ) = %.5f, atan = %.5f\n", c2/65536.0, s2/65536.0, j/65536.0, i/65536.0 ); } } } static void test_unit( void ) { FT_Vector v; double a, c1, s1; FT_Fixed c2, s2; int i; for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 ) { FT_Vector_Unit( &v, i ); a = ( i*SPI ); c1 = cos(a); s1 = sin(a); c2 = (FT_Fixed)(c1*65536.0); s2 = (FT_Fixed)(s1*65536.0); if ( abs( v.x-c2 ) > THRESHOLD || abs( v.y-s2 ) > THRESHOLD ) { error = 1; printf( "FT_Vector_Unit[%3d] = ( %.7f, %.7f ) vec = ( %.7f, %.7f )\n", (i >> 16), v.x/65536.0, v.y/65536.0, c1, s1 ); } } } static void test_length( void ) { FT_Vector v; FT_Fixed l, l2; int i; for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 ) { l = (FT_Fixed)(500.0*65536.0); v.x = (FT_Fixed)( l * cos( i*SPI ) ); v.y = (FT_Fixed)( l * sin( i*SPI ) ); l2 = FT_Vector_Length( &v ); if ( abs( l2-l ) > THRESHOLD ) { error = 1; printf( "FT_Length( %.7f, %.7f ) = %.5f, length = %.5f\n", v.x/65536.0, v.y/65536.0, l2/65536.0, l/65536.0 ); } } } static void test_rotate( void ) { FT_Fixed c2, s2, c4, s4; FT_Vector v; double l, ra, a, c1, s1, cra, sra, c3, s3; int i, j, rotate; for ( rotate = 0; rotate < FT_ANGLE_2PI; rotate += 0x10000 ) { ra = rotate*SPI; cra = cos( ra ); sra = sin( ra ); for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 ) { l = 500.0; a = i*SPI; c1 = l * cos(a); s1 = l * sin(a); v.x = c2 = (FT_Fixed)(c1*65536.0); v.y = s2 = (FT_Fixed)(s1*65536.0); FT_Vector_Rotate( &v, rotate ); c3 = c1 * cra - s1 * sra; s3 = c1 * sra + s1 * cra; c4 = (FT_Fixed)(c3*65536.0); s4 = (FT_Fixed)(s3*65536.0); if ( abs( c4 - v.x ) > THRESHOLD || abs( s4 - v.y ) > THRESHOLD ) { error = 1; printf( "FT_Rotate( (%.7f,%.7f), %.5f ) = ( %.7f, %.7f ), rot = ( %.7f, %.7f )\n", c1, s1, ra, c2/65536.0, s2/65536.0, c4/65536.0, s4/65536.0 ); } } } } int main( void ) { test_cos(); test_sin(); test_tan(); test_atan2(); test_unit(); test_length(); test_rotate(); if (!error) printf( "trigonometry test ok !\n" ); return !error; } |
From: Ehud S. <esh...@us...> - 2006-04-21 16:22:42
|
Update of /cvsroot/roadmap/roadmap_editor/src/freetype/src/smooth In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22848/src/smooth Added Files: ftgrays.c ftsmooth.c smooth.c Log Message: Import freetype sources. --- NEW FILE: ftgrays.c --- /***************************************************************************/ /* */ /* ftgrays.c */ /* */ /* A new `perfect' anti-aliasing renderer (body). */ /* */ /* Copyright 2000-2001, 2002, 2003, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ /*************************************************************************/ /* */ [...2120 lines suppressed...] if ( raster && pool_base && pool_size >= 4096 ) gray_init_cells( rast, (char*)pool_base, pool_size ); rast->band_size = (int)( ( pool_size / sizeof ( TCell ) ) / 8 ); } const FT_Raster_Funcs ft_grays_raster = { FT_GLYPH_FORMAT_OUTLINE, (FT_Raster_New_Func) gray_raster_new, (FT_Raster_Reset_Func) gray_raster_reset, (FT_Raster_Set_Mode_Func)0, (FT_Raster_Render_Func) gray_raster_render, (FT_Raster_Done_Func) gray_raster_done }; /* END */ --- NEW FILE: smooth.c --- /***************************************************************************/ /* */ /* smooth.c */ /* */ /* FreeType anti-aliasing rasterer module component (body only). */ /* */ /* Copyright 1996-2001 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #define FT_MAKE_OPTION_SINGLE_OBJECT #include <ft2build.h> #include "ftgrays.c" #include "ftsmooth.c" /* END */ --- NEW FILE: ftsmooth.c --- /***************************************************************************/ /* */ /* ftsmooth.c */ /* */ /* Anti-aliasing renderer interface (body). */ /* */ /* Copyright 2000-2001, 2002, 2003, 2004, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include <ft2build.h> #include FT_INTERNAL_OBJECTS_H #include FT_OUTLINE_H #include "ftsmooth.h" #include "ftgrays.h" #include "ftsmerrs.h" /* initialize renderer -- init its raster */ static FT_Error ft_smooth_init( FT_Renderer render ) { FT_Library library = FT_MODULE_LIBRARY( render ); render->clazz->raster_class->raster_reset( render->raster, library->raster_pool, library->raster_pool_size ); return 0; } /* sets render-specific mode */ static FT_Error ft_smooth_set_mode( FT_Renderer render, FT_ULong mode_tag, FT_Pointer data ) { /* we simply pass it to the raster */ return render->clazz->raster_class->raster_set_mode( render->raster, mode_tag, data ); } /* transform a given glyph image */ static FT_Error ft_smooth_transform( FT_Renderer render, FT_GlyphSlot slot, const FT_Matrix* matrix, const FT_Vector* delta ) { FT_Error error = Smooth_Err_Ok; if ( slot->format != render->glyph_format ) { error = Smooth_Err_Invalid_Argument; goto Exit; } if ( matrix ) FT_Outline_Transform( &slot->outline, matrix ); if ( delta ) FT_Outline_Translate( &slot->outline, delta->x, delta->y ); Exit: return error; } /* return the glyph's control box */ static void ft_smooth_get_cbox( FT_Renderer render, FT_GlyphSlot slot, FT_BBox* cbox ) { FT_MEM_ZERO( cbox, sizeof ( *cbox ) ); if ( slot->format == render->glyph_format ) FT_Outline_Get_CBox( &slot->outline, cbox ); } /* convert a slot's glyph image into a bitmap */ static FT_Error ft_smooth_render_generic( FT_Renderer render, FT_GlyphSlot slot, FT_Render_Mode mode, const FT_Vector* origin, FT_Render_Mode required_mode, FT_Int hmul, FT_Int vmul ) { FT_Error error; FT_Outline* outline = NULL; FT_BBox cbox; FT_UInt width, height, pitch; FT_Bitmap* bitmap; FT_Memory memory; FT_Raster_Params params; /* check glyph image format */ if ( slot->format != render->glyph_format ) { error = Smooth_Err_Invalid_Argument; goto Exit; } /* check mode */ if ( mode != required_mode ) return Smooth_Err_Cannot_Render_Glyph; outline = &slot->outline; /* translate the outline to the new origin if needed */ if ( origin ) FT_Outline_Translate( outline, origin->x, origin->y ); /* compute the control box, and grid fit it */ FT_Outline_Get_CBox( outline, &cbox ); cbox.xMin = FT_PIX_FLOOR( cbox.xMin ); cbox.yMin = FT_PIX_FLOOR( cbox.yMin ); cbox.xMax = FT_PIX_CEIL( cbox.xMax ); cbox.yMax = FT_PIX_CEIL( cbox.yMax ); width = (FT_UInt)( ( cbox.xMax - cbox.xMin ) >> 6 ); height = (FT_UInt)( ( cbox.yMax - cbox.yMin ) >> 6 ); bitmap = &slot->bitmap; memory = render->root.memory; /* release old bitmap buffer */ if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) { FT_FREE( bitmap->buffer ); slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP; } /* allocate new one, depends on pixel format */ pitch = width; if ( hmul ) { width = width * hmul; pitch = FT_PAD_CEIL( width, 4 ); } if ( vmul ) height *= vmul; bitmap->pixel_mode = FT_PIXEL_MODE_GRAY; bitmap->num_grays = 256; bitmap->width = width; bitmap->rows = height; bitmap->pitch = pitch; if ( FT_ALLOC( bitmap->buffer, (FT_ULong)pitch * height ) ) goto Exit; slot->internal->flags |= FT_GLYPH_OWN_BITMAP; /* translate outline to render it into the bitmap */ FT_Outline_Translate( outline, -cbox.xMin, -cbox.yMin ); /* set up parameters */ params.target = bitmap; params.source = outline; params.flags = FT_RASTER_FLAG_AA; /* implode outline if needed */ { FT_Int n; FT_Vector* vec; if ( hmul ) for ( vec = outline->points, n = 0; n < outline->n_points; n++, vec++ ) vec->x *= hmul; if ( vmul ) for ( vec = outline->points, n = 0; n < outline->n_points; n++, vec++ ) vec->y *= vmul; } /* render outline into the bitmap */ error = render->raster_render( render->raster, ¶ms ); /* deflate outline if needed */ { FT_Int n; FT_Vector* vec; if ( hmul ) for ( vec = outline->points, n = 0; n < outline->n_points; n++, vec++ ) vec->x /= hmul; if ( vmul ) for ( vec = outline->points, n = 0; n < outline->n_points; n++, vec++ ) vec->y /= vmul; } FT_Outline_Translate( outline, cbox.xMin, cbox.yMin ); if ( error ) goto Exit; slot->format = FT_GLYPH_FORMAT_BITMAP; slot->bitmap_left = (FT_Int)( cbox.xMin >> 6 ); slot->bitmap_top = (FT_Int)( cbox.yMax >> 6 ); Exit: if ( outline && origin ) FT_Outline_Translate( outline, -origin->x, -origin->y ); return error; } /* convert a slot's glyph image into a bitmap */ static FT_Error ft_smooth_render( FT_Renderer render, FT_GlyphSlot slot, FT_Render_Mode mode, const FT_Vector* origin ) { if ( mode == FT_RENDER_MODE_LIGHT ) mode = FT_RENDER_MODE_NORMAL; return ft_smooth_render_generic( render, slot, mode, origin, FT_RENDER_MODE_NORMAL, 0, 0 ); } /* convert a slot's glyph image into a horizontal LCD bitmap */ static FT_Error ft_smooth_render_lcd( FT_Renderer render, FT_GlyphSlot slot, FT_Render_Mode mode, const FT_Vector* origin ) { FT_Error error; error = ft_smooth_render_generic( render, slot, mode, origin, FT_RENDER_MODE_LCD, 3, 0 ); if ( !error ) slot->bitmap.pixel_mode = FT_PIXEL_MODE_LCD; return error; } /* convert a slot's glyph image into a vertical LCD bitmap */ static FT_Error ft_smooth_render_lcd_v( FT_Renderer render, FT_GlyphSlot slot, FT_Render_Mode mode, const FT_Vector* origin ) { FT_Error error; error = ft_smooth_render_generic( render, slot, mode, origin, FT_RENDER_MODE_LCD_V, 0, 3 ); if ( !error ) slot->bitmap.pixel_mode = FT_PIXEL_MODE_LCD_V; return error; } FT_CALLBACK_TABLE_DEF const FT_Renderer_Class ft_smooth_renderer_class = { { FT_MODULE_RENDERER, sizeof( FT_RendererRec ), "smooth", 0x10000L, 0x20000L, 0, /* module specific interface */ (FT_Module_Constructor)ft_smooth_init, (FT_Module_Destructor) 0, (FT_Module_Requester) 0 }, FT_GLYPH_FORMAT_OUTLINE, (FT_Renderer_RenderFunc) ft_smooth_render, (FT_Renderer_TransformFunc)ft_smooth_transform, (FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox, (FT_Renderer_SetModeFunc) ft_smooth_set_mode, (FT_Raster_Funcs*) &ft_grays_raster }; FT_CALLBACK_TABLE_DEF const FT_Renderer_Class ft_smooth_lcd_renderer_class = { { FT_MODULE_RENDERER, sizeof( FT_RendererRec ), "smooth-lcd", 0x10000L, 0x20000L, 0, /* module specific interface */ (FT_Module_Constructor)ft_smooth_init, (FT_Module_Destructor) 0, (FT_Module_Requester) 0 }, FT_GLYPH_FORMAT_OUTLINE, (FT_Renderer_RenderFunc) ft_smooth_render_lcd, (FT_Renderer_TransformFunc)ft_smooth_transform, (FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox, (FT_Renderer_SetModeFunc) ft_smooth_set_mode, (FT_Raster_Funcs*) &ft_grays_raster }; FT_CALLBACK_TABLE_DEF const FT_Renderer_Class ft_smooth_lcdv_renderer_class = { { FT_MODULE_RENDERER, sizeof( FT_RendererRec ), "smooth-lcdv", 0x10000L, 0x20000L, 0, /* module specific interface */ (FT_Module_Constructor)ft_smooth_init, (FT_Module_Destructor) 0, (FT_Module_Requester) 0 }, FT_GLYPH_FORMAT_OUTLINE, (FT_Renderer_RenderFunc) ft_smooth_render_lcd_v, (FT_Renderer_TransformFunc)ft_smooth_transform, (FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox, (FT_Renderer_SetModeFunc) ft_smooth_set_mode, (FT_Raster_Funcs*) &ft_grays_raster }; /* END */ |
From: Ehud S. <esh...@us...> - 2006-04-21 16:22:42
|
Update of /cvsroot/roadmap/roadmap_editor/src/freetype/src/pshinter In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22848/src/pshinter Added Files: pshalgo.c pshglob.c pshinter.c pshmod.c pshrec.c Log Message: Import freetype sources. --- NEW FILE: pshalgo.c --- /***************************************************************************/ /* */ /* pshalgo.c */ /* */ /* PostScript hinting algorithm (body). */ /* */ /* Copyright 2001, 2002, 2003, 2004, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used */ /* modified and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include <ft2build.h> [...2053 lines suppressed...] psh_glyph_find_blue_points( &globals->blues, glyph ); psh_glyph_interpolate_strong_points( glyph, dimension ); psh_glyph_interpolate_normal_points( glyph, dimension ); psh_glyph_interpolate_other_points( glyph, dimension ); /* save hinted coordinates back to outline */ psh_glyph_save_points( glyph, dimension ); } Exit: #ifndef DEBUG_HINTER psh_glyph_done( glyph ); #endif return error; } /* END */ --- NEW FILE: pshglob.c --- /***************************************************************************/ /* */ /* pshglob.c */ /* */ /* PostScript hinter global hinting management (body). */ /* Inspired by the new auto-hinter module. */ /* */ /* Copyright 2001, 2002, 2003, 2004 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used */ /* modified and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include <ft2build.h> #include FT_FREETYPE_H #include FT_INTERNAL_OBJECTS_H #include "pshglob.h" #ifdef DEBUG_HINTER PSH_Globals ps_debug_globals = 0; #endif /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** STANDARD WIDTHS *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ /* scale the widths/heights table */ static void psh_globals_scale_widths( PSH_Globals globals, FT_UInt direction ) { PSH_Dimension dim = &globals->dimension[direction]; PSH_Widths stdw = &dim->stdw; FT_UInt count = stdw->count; PSH_Width width = stdw->widths; PSH_Width stand = width; /* standard width/height */ FT_Fixed scale = dim->scale_mult; if ( count > 0 ) { width->cur = FT_MulFix( width->org, scale ); width->fit = FT_PIX_ROUND( width->cur ); width++; count--; for ( ; count > 0; count--, width++ ) { FT_Pos w, dist; w = FT_MulFix( width->org, scale ); dist = w - stand->cur; if ( dist < 0 ) dist = -dist; if ( dist < 128 ) w = stand->cur; width->cur = w; width->fit = FT_PIX_ROUND( w ); } } } #if 0 /* org_width is is font units, result in device pixels, 26.6 format */ FT_LOCAL_DEF( FT_Pos ) psh_dimension_snap_width( PSH_Dimension dimension, FT_Int org_width ) { FT_UInt n; FT_Pos width = FT_MulFix( org_width, dimension->scale_mult ); FT_Pos best = 64 + 32 + 2; FT_Pos reference = width; for ( n = 0; n < dimension->stdw.count; n++ ) { FT_Pos w; FT_Pos dist; w = dimension->stdw.widths[n].cur; dist = width - w; if ( dist < 0 ) dist = -dist; if ( dist < best ) { best = dist; reference = w; } } if ( width >= reference ) { width -= 0x21; if ( width < reference ) width = reference; } else { width += 0x21; if ( width > reference ) width = reference; } return width; } #endif /* 0 */ /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** BLUE ZONES *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ static void psh_blues_set_zones_0( PSH_Blues target, FT_Bool is_others, FT_UInt read_count, FT_Short* read, PSH_Blue_Table top_table, PSH_Blue_Table bot_table ) { FT_UInt count_top = top_table->count; FT_UInt count_bot = bot_table->count; FT_Bool first = 1; FT_UNUSED( target ); for ( ; read_count > 0; read_count -= 2 ) { FT_Int reference, delta; FT_UInt count; PSH_Blue_Zone zones, zone; FT_Bool top; /* read blue zone entry, and select target top/bottom zone */ top = 0; if ( first || is_others ) { reference = read[1]; delta = read[0] - reference; zones = bot_table->zones; count = count_bot; first = 0; } else { reference = read[0]; delta = read[1] - reference; zones = top_table->zones; count = count_top; top = 1; } /* insert into sorted table */ zone = zones; for ( ; count > 0; count--, zone++ ) { if ( reference < zone->org_ref ) break; if ( reference == zone->org_ref ) { FT_Int delta0 = zone->org_delta; /* we have two zones on the same reference position -- */ /* only keep the largest one */ if ( delta < 0 ) { if ( delta < delta0 ) zone->org_delta = delta; } else { if ( delta > delta0 ) zone->org_delta = delta; } goto Skip; } } for ( ; count > 0; count-- ) zone[count] = zone[count-1]; zone->org_ref = reference; zone->org_delta = delta; if ( top ) count_top++; else count_bot++; Skip: read += 2; } top_table->count = count_top; bot_table->count = count_bot; } /* Re-read blue zones from the original fonts and store them into out */ /* private structure. This function re-orders, sanitizes and */ /* fuzz-expands the zones as well. */ static void psh_blues_set_zones( PSH_Blues target, FT_UInt count, FT_Short* blues, FT_UInt count_others, FT_Short* other_blues, FT_Int fuzz, FT_Int family ) { PSH_Blue_Table top_table, bot_table; FT_Int count_top, count_bot; if ( family ) { top_table = &target->family_top; bot_table = &target->family_bottom; } else { top_table = &target->normal_top; bot_table = &target->normal_bottom; } /* read the input blue zones, and build two sorted tables */ /* (one for the top zones, the other for the bottom zones) */ top_table->count = 0; bot_table->count = 0; /* first, the blues */ psh_blues_set_zones_0( target, 0, count, blues, top_table, bot_table ); psh_blues_set_zones_0( target, 1, count_others, other_blues, top_table, bot_table ); count_top = top_table->count; count_bot = bot_table->count; /* sanitize top table */ if ( count_top > 0 ) { PSH_Blue_Zone zone = top_table->zones; for ( count = count_top; count > 0; count--, zone++ ) { FT_Int delta; if ( count > 1 ) { delta = zone[1].org_ref - zone[0].org_ref; if ( zone->org_delta > delta ) zone->org_delta = delta; } zone->org_bottom = zone->org_ref; zone->org_top = zone->org_delta + zone->org_ref; } } /* sanitize bottom table */ if ( count_bot > 0 ) { PSH_Blue_Zone zone = bot_table->zones; for ( count = count_bot; count > 0; count--, zone++ ) { FT_Int delta; if ( count > 1 ) { delta = zone[0].org_ref - zone[1].org_ref; if ( zone->org_delta < delta ) zone->org_delta = delta; } zone->org_top = zone->org_ref; zone->org_bottom = zone->org_delta + zone->org_ref; } } /* expand top and bottom tables with blue fuzz */ { FT_Int dim, top, bot, delta; PSH_Blue_Zone zone; zone = top_table->zones; count = count_top; for ( dim = 1; dim >= 0; dim-- ) { if ( count > 0 ) { /* expand the bottom of the lowest zone normally */ zone->org_bottom -= fuzz; /* expand the top and bottom of intermediate zones; */ /* checking that the interval is smaller than the fuzz */ top = zone->org_top; for ( count--; count > 0; count-- ) { bot = zone[1].org_bottom; delta = bot - top; if ( delta < 2 * fuzz ) zone[0].org_top = zone[1].org_bottom = top + delta / 2; else { zone[0].org_top = top + fuzz; zone[1].org_bottom = bot - fuzz; } zone++; top = zone->org_top; } /* expand the top of the highest zone normally */ zone->org_top = top + fuzz; } zone = bot_table->zones; count = count_bot; } } } /* reset the blues table when the device transform changes */ static void psh_blues_scale_zones( PSH_Blues blues, FT_Fixed scale, FT_Pos delta ) { FT_UInt count; FT_UInt num; PSH_Blue_Table table = 0; /* */ /* Determine whether we need to suppress overshoots or */ /* not. We simply need to compare the vertical scale */ /* parameter to the raw bluescale value. Here is why: */ /* */ /* We need to suppress overshoots for all pointsizes. */ /* At 300dpi that satisfies: */ /* */ /* pointsize < 240*bluescale + 0.49 */ /* */ /* This corresponds to: */ /* */ /* pixelsize < 1000*bluescale + 49/24 */ /* */ /* scale*EM_Size < 1000*bluescale + 49/24 */ /* */ /* However, for normal Type 1 fonts, EM_Size is 1000! */ /* We thus only check: */ /* */ /* scale < bluescale + 49/24000 */ /* */ /* which we shorten to */ /* */ /* "scale < bluescale" */ /* */ /* Note that `blue_scale' is stored 1000 times its real */ /* value, and that `scale' converts from font units to */ /* fractional pixels. */ /* */ /* 1000 / 64 = 125 / 8 */ if ( scale >= 0x20C49BAL ) blues->no_overshoots = FT_BOOL( scale < blues->blue_scale * 8 / 125 ); else blues->no_overshoots = FT_BOOL( scale * 125 < blues->blue_scale * 8 ); /* */ /* The blue threshold is the font units distance under */ /* which overshoots are suppressed due to the BlueShift */ /* even if the scale is greater than BlueScale. */ /* */ /* It is the smallest distance such that */ /* */ /* dist <= BlueShift && dist*scale <= 0.5 pixels */ /* */ { FT_Int threshold = blues->blue_shift; while ( threshold > 0 && FT_MulFix( threshold, scale ) > 32 ) threshold--; blues->blue_threshold = threshold; } for ( num = 0; num < 4; num++ ) { PSH_Blue_Zone zone; switch ( num ) { case 0: table = &blues->normal_top; break; case 1: table = &blues->normal_bottom; break; case 2: table = &blues->family_top; break; default: table = &blues->family_bottom; break; } zone = table->zones; count = table->count; for ( ; count > 0; count--, zone++ ) { zone->cur_top = FT_MulFix( zone->org_top, scale ) + delta; zone->cur_bottom = FT_MulFix( zone->org_bottom, scale ) + delta; zone->cur_ref = FT_MulFix( zone->org_ref, scale ) + delta; zone->cur_delta = FT_MulFix( zone->org_delta, scale ); /* round scaled reference position */ zone->cur_ref = FT_PIX_ROUND( zone->cur_ref ); #if 0 if ( zone->cur_ref > zone->cur_top ) zone->cur_ref -= 64; else if ( zone->cur_ref < zone->cur_bottom ) zone->cur_ref += 64; #endif } } /* process the families now */ for ( num = 0; num < 2; num++ ) { PSH_Blue_Zone zone1, zone2; FT_UInt count1, count2; PSH_Blue_Table normal, family; switch ( num ) { case 0: normal = &blues->normal_top; family = &blues->family_top; break; default: normal = &blues->normal_bottom; family = &blues->family_bottom; } zone1 = normal->zones; count1 = normal->count; for ( ; count1 > 0; count1--, zone1++ ) { /* try to find a family zone whose reference position is less */ /* than 1 pixel far from the current zone */ zone2 = family->zones; count2 = family->count; for ( ; count2 > 0; count2--, zone2++ ) { FT_Pos Delta; Delta = zone1->org_ref - zone2->org_ref; if ( Delta < 0 ) Delta = -Delta; if ( FT_MulFix( Delta, scale ) < 64 ) { zone1->cur_top = zone2->cur_top; zone1->cur_bottom = zone2->cur_bottom; zone1->cur_ref = zone2->cur_ref; zone1->cur_delta = zone2->cur_delta; break; } } } } } FT_LOCAL_DEF( void ) psh_blues_snap_stem( PSH_Blues blues, FT_Int stem_top, FT_Int stem_bot, PSH_Alignment alignment ) { PSH_Blue_Table table; FT_UInt count; FT_Pos delta; PSH_Blue_Zone zone; FT_Int no_shoots; alignment->align = PSH_BLUE_ALIGN_NONE; no_shoots = blues->no_overshoots; /* look up stem top in top zones table */ table = &blues->normal_top; count = table->count; zone = table->zones; for ( ; count > 0; count--, zone++ ) { delta = stem_top - zone->org_bottom; if ( delta < -blues->blue_fuzz ) break; if ( stem_top <= zone->org_top + blues->blue_fuzz ) { if ( no_shoots || delta <= blues->blue_threshold ) { alignment->align |= PSH_BLUE_ALIGN_TOP; alignment->align_top = zone->cur_ref; } break; } } /* look up stem bottom in bottom zones table */ table = &blues->normal_bottom; count = table->count; zone = table->zones + count-1; for ( ; count > 0; count--, zone-- ) { delta = zone->org_top - stem_bot; if ( delta < -blues->blue_fuzz ) break; if ( stem_bot >= zone->org_bottom - blues->blue_fuzz ) { if ( no_shoots || delta < blues->blue_threshold ) { alignment->align |= PSH_BLUE_ALIGN_BOT; alignment->align_bot = zone->cur_ref; } break; } } } /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** GLOBAL HINTS *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ static void psh_globals_destroy( PSH_Globals globals ) { if ( globals ) { FT_Memory memory; memory = globals->memory; globals->dimension[0].stdw.count = 0; globals->dimension[1].stdw.count = 0; globals->blues.normal_top.count = 0; globals->blues.normal_bottom.count = 0; globals->blues.family_top.count = 0; globals->blues.family_bottom.count = 0; FT_FREE( globals ); #ifdef DEBUG_HINTER ps_debug_globals = 0; #endif } } static FT_Error psh_globals_new( FT_Memory memory, T1_Private* priv, PSH_Globals *aglobals ) { PSH_Globals globals; FT_Error error; if ( !FT_NEW( globals ) ) { FT_UInt count; FT_Short* read; globals->memory = memory; /* copy standard widths */ { PSH_Dimension dim = &globals->dimension[1]; PSH_Width write = dim->stdw.widths; write->org = priv->standard_width[0]; write++; read = priv->snap_widths; for ( count = priv->num_snap_widths; count > 0; count-- ) { write->org = *read; write++; read++; } dim->stdw.count = priv->num_snap_widths + 1; } /* copy standard heights */ { PSH_Dimension dim = &globals->dimension[0]; PSH_Width write = dim->stdw.widths; write->org = priv->standard_height[0]; write++; read = priv->snap_heights; for ( count = priv->num_snap_heights; count > 0; count-- ) { write->org = *read; write++; read++; } dim->stdw.count = priv->num_snap_heights + 1; } /* copy blue zones */ psh_blues_set_zones( &globals->blues, priv->num_blue_values, priv->blue_values, priv->num_other_blues, priv->other_blues, priv->blue_fuzz, 0 ); psh_blues_set_zones( &globals->blues, priv->num_family_blues, priv->family_blues, priv->num_family_other_blues, priv->family_other_blues, priv->blue_fuzz, 1 ); globals->blues.blue_scale = priv->blue_scale; globals->blues.blue_shift = priv->blue_shift; globals->blues.blue_fuzz = priv->blue_fuzz; globals->dimension[0].scale_mult = 0; globals->dimension[0].scale_delta = 0; globals->dimension[1].scale_mult = 0; globals->dimension[1].scale_delta = 0; #ifdef DEBUG_HINTER ps_debug_globals = globals; #endif } *aglobals = globals; return error; } FT_LOCAL_DEF( FT_Error ) psh_globals_set_scale( PSH_Globals globals, FT_Fixed x_scale, FT_Fixed y_scale, FT_Fixed x_delta, FT_Fixed y_delta ) { PSH_Dimension dim = &globals->dimension[0]; dim = &globals->dimension[0]; if ( x_scale != dim->scale_mult || x_delta != dim->scale_delta ) { dim->scale_mult = x_scale; dim->scale_delta = x_delta; psh_globals_scale_widths( globals, 0 ); } dim = &globals->dimension[1]; if ( y_scale != dim->scale_mult || y_delta != dim->scale_delta ) { dim->scale_mult = y_scale; dim->scale_delta = y_delta; psh_globals_scale_widths( globals, 1 ); psh_blues_scale_zones( &globals->blues, y_scale, y_delta ); } return 0; } FT_LOCAL_DEF( void ) psh_globals_funcs_init( PSH_Globals_FuncsRec* funcs ) { funcs->create = psh_globals_new; funcs->set_scale = psh_globals_set_scale; funcs->destroy = psh_globals_destroy; } /* END */ --- NEW FILE: pshrec.c --- /***************************************************************************/ /* */ /* pshrec.c */ /* */ /* FreeType PostScript hints recorder (body). */ /* */ /* Copyright 2001, 2002, 2003, 2004 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include <ft2build.h> [...1176 lines suppressed...] total -= count; } } FT_LOCAL_DEF( void ) t2_hints_funcs_init( T2_Hints_FuncsRec* funcs ) { FT_MEM_ZERO( funcs, sizeof ( *funcs ) ); funcs->open = (T2_Hints_OpenFunc) t2_hints_open; funcs->close = (T2_Hints_CloseFunc) ps_hints_close; funcs->stems = (T2_Hints_StemsFunc) t2_hints_stems; funcs->hintmask= (T2_Hints_MaskFunc) ps_hints_t2mask; funcs->counter = (T2_Hints_CounterFunc)ps_hints_t2counter; funcs->apply = (T2_Hints_ApplyFunc) ps_hints_apply; } /* END */ --- NEW FILE: pshinter.c --- /***************************************************************************/ /* */ /* pshinter.c */ /* */ /* FreeType PostScript Hinting module */ /* */ /* Copyright 2001, 2003 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #define FT_MAKE_OPTION_SINGLE_OBJECT #include <ft2build.h> #include "pshrec.c" #include "pshglob.c" #include "pshalgo.c" #include "pshmod.c" /* END */ --- NEW FILE: pshmod.c --- /***************************************************************************/ /* */ /* pshmod.c */ /* */ /* FreeType PostScript hinter module implementation (body). */ /* */ /* Copyright 2001, 2002 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include <ft2build.h> #include FT_INTERNAL_OBJECTS_H #include "pshrec.h" #include "pshalgo.h" /* the Postscript Hinter module structure */ typedef struct PS_Hinter_Module_Rec_ { FT_ModuleRec root; PS_HintsRec ps_hints; PSH_Globals_FuncsRec globals_funcs; T1_Hints_FuncsRec t1_funcs; T2_Hints_FuncsRec t2_funcs; } PS_Hinter_ModuleRec, *PS_Hinter_Module; /* finalize module */ FT_CALLBACK_DEF( void ) ps_hinter_done( PS_Hinter_Module module ) { module->t1_funcs.hints = NULL; module->t2_funcs.hints = NULL; ps_hints_done( &module->ps_hints ); } /* initialize module, create hints recorder and the interface */ FT_CALLBACK_DEF( FT_Error ) ps_hinter_init( PS_Hinter_Module module ) { FT_Memory memory = module->root.memory; ps_hints_init( &module->ps_hints, memory ); psh_globals_funcs_init( &module->globals_funcs ); t1_hints_funcs_init( &module->t1_funcs ); module->t1_funcs.hints = (T1_Hints)&module->ps_hints; t2_hints_funcs_init( &module->t2_funcs ); module->t2_funcs.hints = (T2_Hints)&module->ps_hints; return 0; } /* returns global hints interface */ FT_CALLBACK_DEF( PSH_Globals_Funcs ) pshinter_get_globals_funcs( FT_Module module ) { return &((PS_Hinter_Module)module)->globals_funcs; } /* return Type 1 hints interface */ FT_CALLBACK_DEF( T1_Hints_Funcs ) pshinter_get_t1_funcs( FT_Module module ) { return &((PS_Hinter_Module)module)->t1_funcs; } /* return Type 2 hints interface */ FT_CALLBACK_DEF( T2_Hints_Funcs ) pshinter_get_t2_funcs( FT_Module module ) { return &((PS_Hinter_Module)module)->t2_funcs; } static const PSHinter_Interface pshinter_interface = { pshinter_get_globals_funcs, pshinter_get_t1_funcs, pshinter_get_t2_funcs }; FT_CALLBACK_TABLE_DEF const FT_Module_Class pshinter_module_class = { 0, sizeof ( PS_Hinter_ModuleRec ), "pshinter", 0x10000L, 0x20000L, &pshinter_interface, /* module-specific interface */ (FT_Module_Constructor)ps_hinter_init, (FT_Module_Destructor) ps_hinter_done, (FT_Module_Requester) 0 /* no additional interface for now */ }; /* END */ |
Update of /cvsroot/roadmap/roadmap_editor/src/freetype/src/sfnt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22848/src/sfnt Added Files: sfdriver.c sfnt.c sfobjs.c ttcmap.c ttkern.c ttload.c ttpost.c ttsbit.c ttsbit0.c Log Message: Import freetype sources. --- NEW FILE: ttcmap.c --- /***************************************************************************/ /* */ /* ttcmap.c */ /* */ /* TrueType character mapping table (cmap) support (body). */ /* */ /* Copyright 2002, 2003, 2004, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include <ft2build.h> [...2175 lines suppressed...] } } return SFNT_Err_Ok; } FT_LOCAL( FT_Error ) tt_get_cmap_info( FT_CharMap charmap, TT_CMapInfo *cmap_info ) { FT_CMap cmap = (FT_CMap)charmap; TT_CMap_Class clazz = (TT_CMap_Class)cmap->clazz; return clazz->get_cmap_info( charmap, cmap_info ); } /* END */ --- NEW FILE: ttkern.c --- /***************************************************************************/ /* */ /* ttkern.c */ /* */ /* Load the basic TrueType kerning table. This doesn't handle */ /* kerning data within the GPOS table at the moment. */ /* */ /* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include <ft2build.h> #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_STREAM_H #include FT_TRUETYPE_TAGS_H #include "ttkern.h" #include "ttload.h" #include "sferrors.h" /*************************************************************************/ /* */ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ /* messages during execution. */ /* */ #undef FT_COMPONENT #define FT_COMPONENT trace_ttkern #undef TT_KERN_INDEX #define TT_KERN_INDEX( g1, g2 ) ( ( (FT_ULong)(g1) << 16 ) | (g2) ) #ifdef FT_OPTIMIZE_MEMORY FT_LOCAL_DEF( FT_Error ) tt_face_load_kern( TT_Face face, FT_Stream stream ) { FT_Error error; FT_ULong table_size; FT_Byte* p; FT_Byte* p_limit; FT_UInt nn, num_tables; FT_UInt32 avail = 0, ordered = 0; /* the kern table is optional; exit silently if it is missing */ error = face->goto_table( face, TTAG_kern, stream, &table_size ); if ( error ) goto Exit; if ( table_size < 4 ) /* the case of a malformed table */ { FT_ERROR(( "kerning table is too small - ignored\n" )); error = SFNT_Err_Table_Missing; goto Exit; } if ( FT_FRAME_EXTRACT( table_size, face->kern_table ) ) { FT_ERROR(( "could not extract kerning table\n" )); goto Exit; } face->kern_table_size = table_size; p = face->kern_table; p_limit = p + table_size; p += 2; /* skip version */ num_tables = FT_NEXT_USHORT( p ); if ( num_tables > 32 ) /* we only support up to 32 sub-tables */ num_tables = 32; for ( nn = 0; nn < num_tables; nn++ ) { FT_UInt num_pairs, version, length, coverage; FT_Byte* p_next; FT_UInt32 mask = 1UL << nn; if ( p + 6 > p_limit ) break; p_next = p; version = FT_NEXT_USHORT( p ); length = FT_NEXT_USHORT( p ); coverage = FT_NEXT_USHORT( p ); if ( length <= 6 ) break; p_next += length; /* only use horizontal kerning tables */ if ( ( coverage & ~8 ) != 0x0001 || p + 8 > p_limit ) goto NextTable; num_pairs = FT_NEXT_USHORT( p ); p += 6; if ( p + 6 * num_pairs > p_limit ) goto NextTable; avail |= mask; /* * Now check whether the pairs in this table are ordered. * We then can use binary search. */ if ( num_pairs > 0 ) { FT_UInt count; FT_UInt old_pair; old_pair = FT_NEXT_ULONG( p ); p += 2; for ( count = num_pairs - 1; count > 0; count-- ) { FT_UInt32 cur_pair; cur_pair = FT_NEXT_ULONG( p ); if ( cur_pair <= old_pair ) break; p += 2; old_pair = cur_pair; } if ( count == 0 ) ordered |= mask; } NextTable: p = p_next; } face->num_kern_tables = nn; face->kern_avail_bits = avail; face->kern_order_bits = ordered; Exit: return error; } FT_LOCAL_DEF( void ) tt_face_done_kern( TT_Face face ) { FT_Stream stream = face->root.stream; FT_FRAME_RELEASE( face->kern_table ); face->kern_table_size = 0; face->num_kern_tables = 0; face->kern_avail_bits = 0; face->kern_order_bits = 0; } FT_LOCAL_DEF( FT_Int ) tt_face_get_kerning( TT_Face face, FT_UInt left_glyph, FT_UInt right_glyph ) { FT_Int result = 0; FT_UInt count, mask = 1; FT_Byte* p = face->kern_table; p += 4; mask = 0x0001; for ( count = face->num_kern_tables; count > 0; count--, mask <<= 1 ) { FT_Byte* base = p; FT_Byte* next = base; FT_UInt version = FT_NEXT_USHORT( p ); FT_UInt length = FT_NEXT_USHORT( p ); FT_UInt coverage = FT_NEXT_USHORT( p ); FT_Int value = 0; FT_UNUSED( version ); next = base + length; if ( ( face->kern_avail_bits & mask ) == 0 ) goto NextTable; if ( p + 8 > next ) goto NextTable; switch ( coverage >> 8 ) { case 0: { FT_UInt num_pairs = FT_NEXT_USHORT( p ); FT_ULong key0 = TT_KERN_INDEX( left_glyph, right_glyph ); p += 6; if ( face->kern_order_bits & mask ) /* binary search */ { FT_UInt min = 0; FT_UInt max = num_pairs; while ( min < max ) { FT_UInt mid = ( min + max ) >> 1; FT_Byte* q = p + 6 * mid; FT_ULong key; key = FT_NEXT_ULONG( q ); if ( key == key0 ) { value = FT_PEEK_SHORT( q ); goto Found; } if ( key < key0 ) min = mid + 1; else max = mid; } } else /* linear search */ { for ( count = num_pairs; count > 0; count-- ) { FT_ULong key = FT_NEXT_ULONG( p ); if ( key == key0 ) { value = FT_PEEK_SHORT( p ); goto Found; } p += 2; } } } break; /* * We don't support format 2 because we've never seen a single font * using it in real life... */ default: ; } goto NextTable; Found: if ( coverage & 8 ) /* overide or add */ result = value; else result += value; NextTable: p = next; } return result; } #else /* !OPTIMIZE_MEMORY */ FT_CALLBACK_DEF( int ) tt_kern_pair_compare( const void* a, const void* b ); FT_LOCAL_DEF( FT_Error ) tt_face_load_kern( TT_Face face, FT_Stream stream ) { FT_Error error; FT_Memory memory = stream->memory; FT_UInt n, num_tables; /* the kern table is optional; exit silently if it is missing */ error = face->goto_table( face, TTAG_kern, stream, 0 ); if ( error ) return SFNT_Err_Ok; if ( FT_FRAME_ENTER( 4L ) ) goto Exit; (void)FT_GET_USHORT(); /* version */ num_tables = FT_GET_USHORT(); FT_FRAME_EXIT(); for ( n = 0; n < num_tables; n++ ) { FT_UInt coverage; FT_UInt length; if ( FT_FRAME_ENTER( 6L ) ) goto Exit; (void)FT_GET_USHORT(); /* version */ length = FT_GET_USHORT() - 6; /* substract header length */ coverage = FT_GET_USHORT(); FT_FRAME_EXIT(); if ( coverage == 0x0001 ) { FT_UInt num_pairs; TT_Kern0_Pair pair; TT_Kern0_Pair limit; /* found a horizontal format 0 kerning table! */ if ( FT_FRAME_ENTER( 8L ) ) goto Exit; num_pairs = FT_GET_USHORT(); /* skip the rest */ FT_FRAME_EXIT(); /* allocate array of kerning pairs */ if ( FT_QNEW_ARRAY( face->kern_pairs, num_pairs ) || FT_FRAME_ENTER( 6L * num_pairs ) ) goto Exit; pair = face->kern_pairs; limit = pair + num_pairs; for ( ; pair < limit; pair++ ) { pair->left = FT_GET_USHORT(); pair->right = FT_GET_USHORT(); pair->value = FT_GET_USHORT(); } FT_FRAME_EXIT(); face->num_kern_pairs = num_pairs; face->kern_table_index = n; /* ensure that the kerning pair table is sorted (yes, some */ /* fonts have unsorted tables!) */ if ( num_pairs > 0 ) { TT_Kern0_Pair pair0 = face->kern_pairs; FT_ULong prev = TT_KERN_INDEX( pair0->left, pair0->right ); for ( pair0++; pair0 < limit; pair0++ ) { FT_ULong next = TT_KERN_INDEX( pair0->left, pair0->right ); if ( next < prev ) goto SortIt; prev = next; } goto Exit; SortIt: ft_qsort( (void*)face->kern_pairs, (int)num_pairs, sizeof ( TT_Kern0_PairRec ), tt_kern_pair_compare ); } goto Exit; } if ( FT_STREAM_SKIP( length ) ) goto Exit; } /* no kern table found -- doesn't matter */ face->kern_table_index = -1; face->num_kern_pairs = 0; face->kern_pairs = NULL; Exit: return error; } FT_CALLBACK_DEF( int ) tt_kern_pair_compare( const void* a, const void* b ) { TT_Kern0_Pair pair1 = (TT_Kern0_Pair)a; TT_Kern0_Pair pair2 = (TT_Kern0_Pair)b; FT_ULong index1 = TT_KERN_INDEX( pair1->left, pair1->right ); FT_ULong index2 = TT_KERN_INDEX( pair2->left, pair2->right ); return index1 < index2 ? -1 : ( index1 > index2 ? 1 : 0 ); } FT_LOCAL_DEF( void ) tt_face_done_kern( TT_Face face ) { FT_Memory memory = face->root.stream->memory; FT_FREE( face->kern_pairs ); face->num_kern_pairs = 0; } FT_LOCAL_DEF( FT_Int ) tt_face_get_kerning( TT_Face face, FT_UInt left_glyph, FT_UInt right_glyph ) { FT_Int result = 0; TT_Kern0_Pair pair; if ( face && face->kern_pairs ) { /* there are some kerning pairs in this font file! */ FT_ULong search_tag = TT_KERN_INDEX( left_glyph, right_glyph ); FT_Long left, right; left = 0; right = face->num_kern_pairs - 1; while ( left <= right ) { FT_Long middle = left + ( ( right - left ) >> 1 ); FT_ULong cur_pair; pair = face->kern_pairs + middle; cur_pair = TT_KERN_INDEX( pair->left, pair->right ); if ( cur_pair == search_tag ) goto Found; if ( cur_pair < search_tag ) left = middle + 1; else right = middle - 1; } } Exit: return result; Found: result = pair->value; goto Exit; } #endif /* !OPTIMIZE_MEMORY */ #undef TT_KERN_INDEX /* END */ --- NEW FILE: ttpost.c --- /***************************************************************************/ /* */ /* ttpost.c */ /* */ /* Postcript name table processing for TrueType and OpenType fonts */ /* (body). */ /* */ /* Copyright 1996-2001, 2002, 2003 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ /*************************************************************************/ /* */ /* The post table is not completely loaded by the core engine. This */ /* file loads the missing PS glyph names and implements an API to access */ /* them. */ /* */ /*************************************************************************/ #include <ft2build.h> #include FT_INTERNAL_STREAM_H #include FT_TRUETYPE_TAGS_H #include "ttpost.h" #include "ttload.h" #include "sferrors.h" /*************************************************************************/ /* */ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ /* messages during execution. */ /* */ #undef FT_COMPONENT #define FT_COMPONENT trace_ttpost /* If this configuration macro is defined, we rely on the `PSNames' */ /* module to grab the glyph names. */ #ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES #include FT_SERVICE_POSTSCRIPT_CMAPS_H #define MAC_NAME( x ) ( (FT_String*)psnames->macintosh_name( x ) ) #else /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */ /* Otherwise, we ignore the `PSNames' module, and provide our own */ /* table of Mac names. Thus, it is possible to build a version of */ /* FreeType without the Type 1 driver & PSNames module. */ #define MAC_NAME( x ) tt_post_default_names[x] /* the 258 default Mac PS glyph names */ static const FT_String* tt_post_default_names[258] = { /* 0 */ ".notdef", ".null", "CR", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", /* 10 */ "quotesingle", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", /* 20 */ "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", /* 30 */ "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", /* 40 */ "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", /* 50 */ "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", /* 60 */ "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "grave", "a", "b", /* 70 */ "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", /* 80 */ "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", /* 90 */ "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "Adieresis", "Aring", /* 100 */ "Ccedilla", "Eacute", "Ntilde", "Odieresis", "Udieresis", "aacute", "agrave", "acircumflex", "adieresis", "atilde", /* 110 */ "aring", "ccedilla", "eacute", "egrave", "ecircumflex", "edieresis", "iacute", "igrave", "icircumflex", "idieresis", /* 120 */ "ntilde", "oacute", "ograve", "ocircumflex", "odieresis", "otilde", "uacute", "ugrave", "ucircumflex", "udieresis", /* 130 */ "dagger", "degree", "cent", "sterling", "section", "bullet", "paragraph", "germandbls", "registered", "copyright", /* 140 */ "trademark", "acute", "dieresis", "notequal", "AE", "Oslash", "infinity", "plusminus", "lessequal", "greaterequal", /* 150 */ "yen", "mu", "partialdiff", "summation", "product", "pi", "integral", "ordfeminine", "ordmasculine", "Omega", /* 160 */ "ae", "oslash", "questiondown", "exclamdown", "logicalnot", "radical", "florin", "approxequal", "Delta", "guillemotleft", /* 170 */ "guillemotright", "ellipsis", "nbspace", "Agrave", "Atilde", "Otilde", "OE", "oe", "endash", "emdash", /* 180 */ "quotedblleft", "quotedblright", "quoteleft", "quoteright", "divide", "lozenge", "ydieresis", "Ydieresis", "fraction", "currency", /* 190 */ "guilsinglleft", "guilsinglright", "fi", "fl", "daggerdbl", "periodcentered", "quotesinglbase", "quotedblbase", "perthousand", "Acircumflex", /* 200 */ "Ecircumflex", "Aacute", "Edieresis", "Egrave", "Iacute", "Icircumflex", "Idieresis", "Igrave", "Oacute", "Ocircumflex", /* 210 */ "apple", "Ograve", "Uacute", "Ucircumflex", "Ugrave", "dotlessi", "circumflex", "tilde", "macron", "breve", /* 220 */ "dotaccent", "ring", "cedilla", "hungarumlaut", "ogonek", "caron", "Lslash", "lslash", "Scaron", "scaron", /* 230 */ "Zcaron", "zcaron", "brokenbar", "Eth", "eth", "Yacute", "yacute", "Thorn", "thorn", "minus", /* 240 */ "multiply", "onesuperior", "twosuperior", "threesuperior", "onehalf", "onequarter", "threequarters", "franc", "Gbreve", "gbreve", /* 250 */ "Idot", "Scedilla", "scedilla", "Cacute", "cacute", "Ccaron", "ccaron", "dmacron", }; #endif /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */ static FT_Error load_format_20( TT_Face face, FT_Stream stream ) { FT_Memory memory = stream->memory; FT_Error error; FT_Int num_glyphs; FT_UShort num_names; FT_UShort* glyph_indices = 0; FT_Char** name_strings = 0; if ( FT_READ_USHORT( num_glyphs ) ) goto Exit; /* UNDOCUMENTED! The number of glyphs in this table can be smaller */ /* than the value in the maxp table (cf. cyberbit.ttf). */ /* There already exist fonts which have more than 32768 glyph names */ /* in this table, so the test for this threshold has been dropped. */ if ( num_glyphs > face->root.num_glyphs ) { error = SFNT_Err_Invalid_File_Format; goto Exit; } /* load the indices */ { FT_Int n; if ( FT_NEW_ARRAY ( glyph_indices, num_glyphs ) || FT_FRAME_ENTER( num_glyphs * 2L ) ) goto Fail; for ( n = 0; n < num_glyphs; n++ ) glyph_indices[n] = FT_GET_USHORT(); FT_FRAME_EXIT(); } /* compute number of names stored in table */ { FT_Int n; num_names = 0; for ( n = 0; n < num_glyphs; n++ ) { FT_Int idx; idx = glyph_indices[n]; if ( idx >= 258 ) { idx -= 257; if ( idx > num_names ) num_names = (FT_UShort)idx; } } } /* now load the name strings */ { FT_UShort n; if ( FT_NEW_ARRAY( name_strings, num_names ) ) goto Fail; for ( n = 0; n < num_names; n++ ) { FT_UInt len; if ( FT_READ_BYTE ( len ) || FT_NEW_ARRAY( name_strings[n], len + 1 ) || FT_STREAM_READ ( name_strings[n], len ) ) goto Fail1; name_strings[n][len] = '\0'; } } /* all right, set table fields and exit successfuly */ { TT_Post_20 table = &face->postscript_names.names.format_20; table->num_glyphs = (FT_UShort)num_glyphs; table->num_names = (FT_UShort)num_names; table->glyph_indices = glyph_indices; table->glyph_names = name_strings; } return SFNT_Err_Ok; Fail1: { FT_UShort n; for ( n = 0; n < num_names; n++ ) FT_FREE( name_strings[n] ); } Fail: FT_FREE( name_strings ); FT_FREE( glyph_indices ); Exit: return error; } static FT_Error load_format_25( TT_Face face, FT_Stream stream ) { FT_Memory memory = stream->memory; FT_Error error; FT_Int num_glyphs; FT_Char* offset_table = 0; /* UNDOCUMENTED! This value appears only in the Apple TT specs. */ if ( FT_READ_USHORT( num_glyphs ) ) goto Exit; /* check the number of glyphs */ if ( num_glyphs > face->root.num_glyphs || num_glyphs > 258 ) { error = SFNT_Err_Invalid_File_Format; goto Exit; } if ( FT_ALLOC( offset_table, num_glyphs ) || FT_STREAM_READ( offset_table, num_glyphs ) ) goto Fail; /* now check the offset table */ { FT_Int n; for ( n = 0; n < num_glyphs; n++ ) { FT_Long idx = (FT_Long)n + offset_table[n]; if ( idx < 0 || idx > num_glyphs ) { error = SFNT_Err_Invalid_File_Format; goto Fail; } } } /* OK, set table fields and exit successfuly */ { TT_Post_25 table = &face->postscript_names.names.format_25; table->num_glyphs = (FT_UShort)num_glyphs; table->offsets = offset_table; } return SFNT_Err_Ok; Fail: FT_FREE( offset_table ); Exit: return error; } static FT_Error load_post_names( TT_Face face ) { FT_Stream stream; FT_Error error; FT_Fixed format; /* get a stream for the face's resource */ stream = face->root.stream; /* seek to the beginning of the PS names table */ error = face->goto_table( face, TTAG_post, stream, 0 ); if ( error ) goto Exit; format = face->postscript.FormatType; /* go to beginning of subtable */ if ( FT_STREAM_SKIP( 32 ) ) goto Exit; /* now read postscript table */ if ( format == 0x00020000L ) error = load_format_20( face, stream ); else if ( format == 0x00028000L ) error = load_format_25( face, stream ); else error = SFNT_Err_Invalid_File_Format; face->postscript_names.loaded = 1; Exit: return error; } FT_LOCAL_DEF( void ) tt_face_free_ps_names( TT_Face face ) { FT_Memory memory = face->root.memory; TT_Post_Names names = &face->postscript_names; FT_Fixed format; if ( names->loaded ) { format = face->postscript.FormatType; if ( format == 0x00020000L ) { TT_Post_20 table = &names->names.format_20; FT_UShort n; FT_FREE( table->glyph_indices ); table->num_glyphs = 0; for ( n = 0; n < table->num_names; n++ ) FT_FREE( table->glyph_names[n] ); FT_FREE( table->glyph_names ); table->num_names = 0; } else if ( format == 0x00028000L ) { TT_Post_25 table = &names->names.format_25; FT_FREE( table->offsets ); table->num_glyphs = 0; } } names->loaded = 0; } /*************************************************************************/ /* */ /* <Function> */ /* tt_face_get_ps_name */ /* */ /* <Description> */ /* Gets the PostScript glyph name of a glyph. */ /* */ /* <Input> */ /* face :: A handle to the parent face. */ /* */ /* idx :: The glyph index. */ /* */ /* PSname :: The address of a string pointer. Will be NULL in case */ /* of error, otherwise it is a pointer to the glyph name. */ /* */ /* You must not modify the returned string! */ /* */ /* <Output> */ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) tt_face_get_ps_name( TT_Face face, FT_UInt idx, FT_String** PSname ) { FT_Error error; TT_Post_Names names; FT_Fixed format; #ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES FT_Service_PsCMaps psnames; #endif if ( !face ) return SFNT_Err_Invalid_Face_Handle; if ( idx >= (FT_UInt)face->root.num_glyphs ) return SFNT_Err_Invalid_Glyph_Index; #ifdef FT_CONFIG_OPTION_POSTSCRIPT_NAMES psnames = (FT_Service_PsCMaps)face->psnames; if ( !psnames ) return SFNT_Err_Unimplemented_Feature; #endif names = &face->postscript_names; /* `.notdef' by default */ *PSname = MAC_NAME( 0 ); format = face->postscript.FormatType; if ( format == 0x00010000L ) { if ( idx < 258 ) /* paranoid checking */ *PSname = MAC_NAME( idx ); } else if ( format == 0x00020000L ) { TT_Post_20 table = &names->names.format_20; if ( !names->loaded ) { error = load_post_names( face ); if ( error ) goto End; } if ( idx < (FT_UInt)table->num_glyphs ) { FT_UShort name_index = table->glyph_indices[idx]; if ( name_index < 258 ) *PSname = MAC_NAME( name_index ); else *PSname = (FT_String*)table->glyph_names[name_index - 258]; } } else if ( format == 0x00028000L ) { TT_Post_25 table = &names->names.format_25; if ( !names->loaded ) { error = load_post_names( face ); if ( error ) goto End; } if ( idx < (FT_UInt)table->num_glyphs ) /* paranoid checking */ { idx += table->offsets[idx]; *PSname = MAC_NAME( idx ); } } /* nothing to do for format == 0x00030000L */ End: return SFNT_Err_Ok; } /* END */ --- NEW FILE: sfdriver.c --- /***************************************************************************/ /* */ /* sfdriver.c */ /* */ /* High-level SFNT driver interface (body). */ /* */ /* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include <ft2build.h> #include FT_INTERNAL_SFNT_H #include FT_INTERNAL_OBJECTS_H #include "sfdriver.h" #include "ttload.h" #include "sfobjs.h" #include "sferrors.h" #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS #include "ttsbit.h" #endif #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES #include "ttpost.h" #endif #include "ttcmap.h" #include "ttkern.h" #include FT_SERVICE_GLYPH_DICT_H #include FT_SERVICE_POSTSCRIPT_NAME_H #include FT_SERVICE_SFNT_H #include FT_SERVICE_TT_CMAP_H /* * SFNT TABLE SERVICE * */ static void* get_sfnt_table( TT_Face face, FT_Sfnt_Tag tag ) { void* table; switch ( tag ) { case ft_sfnt_head: table = &face->header; break; case ft_sfnt_hhea: table = &face->horizontal; break; case ft_sfnt_vhea: table = face->vertical_info ? &face->vertical : 0; break; case ft_sfnt_os2: table = face->os2.version == 0xFFFFU ? 0 : &face->os2; break; case ft_sfnt_post: table = &face->postscript; break; case ft_sfnt_maxp: table = &face->max_profile; break; case ft_sfnt_pclt: table = face->pclt.Version ? &face->pclt : 0; break; default: table = 0; } return table; } static FT_Error sfnt_table_info( TT_Face face, FT_UInt idx, FT_ULong *tag, FT_ULong *length ) { if ( !tag || !length ) return SFNT_Err_Invalid_Argument; if ( idx >= face->num_tables ) return SFNT_Err_Table_Missing; *tag = face->dir_tables[idx].Tag; *length = face->dir_tables[idx].Length; return SFNT_Err_Ok; } static const FT_Service_SFNT_TableRec sfnt_service_sfnt_table = { (FT_SFNT_TableLoadFunc)tt_face_load_any, (FT_SFNT_TableGetFunc) get_sfnt_table, (FT_SFNT_TableInfoFunc)sfnt_table_info }; #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES /* * GLYPH DICT SERVICE * */ static FT_Error sfnt_get_glyph_name( TT_Face face, FT_UInt glyph_index, FT_Pointer buffer, FT_UInt buffer_max ) { FT_String* gname; FT_Error error; error = tt_face_get_ps_name( face, glyph_index, &gname ); if ( !error && buffer_max > 0 ) { FT_UInt len = (FT_UInt)( ft_strlen( gname ) ); if ( len >= buffer_max ) len = buffer_max - 1; FT_MEM_COPY( buffer, gname, len ); ((FT_Byte*)buffer)[len] = 0; } return error; } static const FT_Service_GlyphDictRec sfnt_service_glyph_dict = { (FT_GlyphDict_GetNameFunc) sfnt_get_glyph_name, (FT_GlyphDict_NameIndexFunc)NULL }; #endif /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */ /* * POSTSCRIPT NAME SERVICE * */ static const char* sfnt_get_ps_name( TT_Face face ) { FT_Int n, found_win, found_apple; const char* result = NULL; /* shouldn't happen, but just in case to avoid memory leaks */ if ( face->postscript_name ) return face->postscript_name; /* scan the name table to see whether we have a Postscript name here, */ /* either in Macintosh or Windows platform encodings */ found_win = -1; found_apple = -1; for ( n = 0; n < face->num_names; n++ ) { TT_NameEntryRec* name = face->name_table.names + n; if ( name->nameID == 6 && name->stringLength > 0 ) { if ( name->platformID == 3 && name->encodingID == 1 && name->languageID == 0x409 ) found_win = n; if ( name->platformID == 1 && name->encodingID == 0 && name->languageID == 0 ) found_apple = n; } } if ( found_win != -1 ) { FT_Memory memory = face->root.memory; TT_NameEntryRec* name = face->name_table.names + found_win; FT_UInt len = name->stringLength / 2; FT_Error error = SFNT_Err_Ok; FT_UNUSED( error ); if ( !FT_ALLOC( result, name->stringLength + 1 ) ) { FT_Stream stream = face->name_table.stream; FT_String* r = (FT_String*)result; FT_Byte* p = (FT_Byte*)name->string; if ( FT_STREAM_SEEK( name->stringOffset ) || FT_FRAME_ENTER( name->stringLength ) ) { FT_FREE( result ); name->stringLength = 0; name->stringOffset = 0; FT_FREE( name->string ); goto Exit; } p = (FT_Byte*)stream->cursor; for ( ; len > 0; len--, p += 2 ) { if ( p[0] == 0 && p[1] >= 32 && p[1] < 128 ) *r++ = p[1]; } *r = '\0'; FT_FRAME_EXIT(); } goto Exit; } if ( found_apple != -1 ) { FT_Memory memory = face->root.memory; TT_NameEntryRec* name = face->name_table.names + found_apple; FT_UInt len = name->stringLength; FT_Error error = SFNT_Err_Ok; FT_UNUSED( error ); if ( !FT_ALLOC( result, len + 1 ) ) { FT_Stream stream = face->name_table.stream; if ( FT_STREAM_SEEK( name->stringOffset ) || FT_STREAM_READ( result, len ) ) { name->stringOffset = 0; name->stringLength = 0; FT_FREE( name->string ); FT_FREE( result ); goto Exit; } ((char*)result)[len] = '\0'; } } Exit: face->postscript_name = result; return result; } static const FT_Service_PsFontNameRec sfnt_service_ps_name = { (FT_PsName_GetFunc)sfnt_get_ps_name }; /* * TT CMAP INFO * */ static const FT_Service_TTCMapsRec tt_service_get_cmap_info = { (TT_CMap_Info_GetFunc)tt_get_cmap_info }; /* * SERVICE LIST * */ static const FT_ServiceDescRec sfnt_services[] = { { FT_SERVICE_ID_SFNT_TABLE, &sfnt_service_sfnt_table }, { FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &sfnt_service_ps_name }, #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES { FT_SERVICE_ID_GLYPH_DICT, &sfnt_service_glyph_dict }, #endif { FT_SERVICE_ID_TT_CMAP, &tt_service_get_cmap_info }, { NULL, NULL } }; FT_CALLBACK_DEF( FT_Module_Interface ) sfnt_get_interface( FT_Module module, const char* module_interface ) { FT_UNUSED( module ); if ( ft_strcmp( module_interface, "get_sfnt" ) == 0 ) return (FT_Module_Interface)get_sfnt_table; if ( ft_strcmp( module_interface, "load_sfnt" ) == 0 ) return (FT_Module_Interface)tt_face_load_any; return ft_service_list_lookup( sfnt_services, module_interface ); } static const SFNT_Interface sfnt_interface = { tt_face_goto_table, sfnt_init_face, sfnt_load_face, sfnt_done_face, sfnt_get_interface, tt_face_load_any, tt_face_load_sfnt_header, tt_face_load_directory, tt_face_load_header, tt_face_load_metrics_header, tt_face_load_cmap, tt_face_load_max_profile, tt_face_load_os2, tt_face_load_postscript, tt_face_load_names, tt_face_free_names, tt_face_load_hdmx, tt_face_free_hdmx, tt_face_load_kern, tt_face_load_gasp, tt_face_load_pclt, #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS /* see `ttload.h' */ tt_face_load_bitmap_header, /* see `ttsbit.h' and `sfnt.h' */ tt_face_set_sbit_strike, tt_face_load_sbit_strikes, 0 /* tt_find_sbit_image */, 0 /* tt_load_sbit_metrics */, tt_face_load_sbit_image, tt_face_free_sbit_strikes, #else /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ 0, 0, 0, 0, 0, 0, 0, #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES /* see `ttkern.h' */ tt_face_get_kerning, /* see `ttpost.h' */ tt_face_get_ps_name, tt_face_free_ps_names, #else /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */ 0, 0, #endif /* TT_CONFIG_OPTION_POSTSCRIPT_NAMES */ }; FT_CALLBACK_TABLE_DEF const FT_Module_Class sfnt_module_class = { 0, /* not a font driver or renderer */ sizeof( FT_ModuleRec ), "sfnt", /* driver name */ 0x10000L, /* driver version 1.0 */ 0x20000L, /* driver requires FreeType 2.0 or higher */ (const void*)&sfnt_interface, /* module specific interface */ (FT_Module_Constructor)0, (FT_Module_Destructor) 0, (FT_Module_Requester) sfnt_get_interface }; /* END */ --- NEW FILE: ttsbit0.c --- /***************************************************************************/ /* */ /* ttsbit0.c */ /* */ /* TrueType and OpenType embedded bitmap support (body). */ /* This is a heap-optimized version. */ /* */ /* Copyright 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include <ft2build.h> #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_STREAM_H #include FT_TRUETYPE_TAGS_H #include "ttsbit.h" #include "sferrors.h" /*************************************************************************/ /* */ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ /* messages during execution. */ /* */ #undef FT_COMPONENT #define FT_COMPONENT trace_ttsbit static const FT_Frame_Field tt_sbit_line_metrics_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE TT_SBit_LineMetricsRec /* no FT_FRAME_START */ FT_FRAME_CHAR( ascender ), FT_FRAME_CHAR( descender ), FT_FRAME_BYTE( max_width ), FT_FRAME_CHAR( caret_slope_numerator ), FT_FRAME_CHAR( caret_slope_denominator ), FT_FRAME_CHAR( caret_offset ), FT_FRAME_CHAR( min_origin_SB ), FT_FRAME_CHAR( min_advance_SB ), FT_FRAME_CHAR( max_before_BL ), FT_FRAME_CHAR( min_after_BL ), FT_FRAME_CHAR( pads[0] ), FT_FRAME_CHAR( pads[1] ), FT_FRAME_END }; static const FT_Frame_Field tt_strike_start_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE TT_SBit_StrikeRec /* no FT_FRAME_START */ FT_FRAME_ULONG( ranges_offset ), FT_FRAME_SKIP_LONG, FT_FRAME_ULONG( num_ranges ), FT_FRAME_ULONG( color_ref ), FT_FRAME_END }; static const FT_Frame_Field tt_strike_end_fields[] = { /* no FT_FRAME_START */ FT_FRAME_USHORT( start_glyph ), FT_FRAME_USHORT( end_glyph ), FT_FRAME_BYTE ( x_ppem ), FT_FRAME_BYTE ( y_ppem ), FT_FRAME_BYTE ( bit_depth ), FT_FRAME_CHAR ( flags ), FT_FRAME_END }; FT_LOCAL_DEF( FT_Error ) tt_face_load_sbit_strikes( TT_Face face, FT_Stream stream ) { FT_Error error = SFNT_Err_Ok; FT_Fixed version; FT_ULong num_strikes, table_size; FT_Byte* p; FT_Byte* p_limit; FT_UInt nn, count; face->sbit_num_strikes = 0; /* this table is optional */ error = face->goto_table( face, TTAG_EBLC, stream, &table_size ); if ( error ) error = face->goto_table( face, TTAG_bloc, stream, &table_size ); if ( error ) goto Exit; if ( table_size < 8 ) { FT_ERROR(( "%s: table too short!\n", "tt_face_load_sbit_strikes" )); error = SFNT_Err_Invalid_File_Format; goto Exit; } if ( FT_FRAME_EXTRACT( table_size, face->sbit_table ) ) goto Exit; face->sbit_table_size = table_size; p = face->sbit_table; p_limit = p + table_size; version = FT_NEXT_ULONG( p ); num_strikes = FT_NEXT_ULONG( p ); if ( version != 0x00020000UL || num_strikes >= 0x10000UL ) { FT_ERROR(( "%s: invalid table version!\n", "tt_face_load_sbit_strikes" )); error = SFNT_Err_Invalid_File_Format; goto Fail; } /* * Count the number of strikes available in the table. We are a bit * paranoid there and don't trust the data. */ count = (FT_UInt)num_strikes; if ( 8 +48UL * count > table_size ) count = (FT_UInt)( ( p_limit - p ) / 48 ); face->sbit_num_strikes = count; /* * Now allocate the root array of FT_Bitmap_Size records and * populate them. Unfortunately, it isn't possible to indicate bit * depths in the FT_Bitmap_Size record. This is a design error. */ { FT_Memory memory = face->root.stream->memory; FT_UInt em_size = (FT_UInt) face->header.Units_Per_EM; FT_Short height = (FT_Short)( face->horizontal.Ascender - face->horizontal.Descender + face->horizontal.Line_Gap ); FT_Short avgwidth = face->os2.xAvgCharWidth; if ( FT_NEW_ARRAY( face->root.available_sizes, count ) ) goto Fail; for ( nn = 0; nn < count; nn++ ) { FT_Bitmap_Size* bsize = face->root.available_sizes + nn; FT_UInt x_ppem, y_ppem; x_ppem = p[44]; y_ppem = p[45]; bsize->x_ppem = (FT_Pos)(x_ppem << 6); bsize->y_ppem = (FT_Pos)(y_ppem << 6); bsize->height = (FT_Short)( height*y_ppem + em_size / 2 ) / em_size; bsize->width = (FT_Short)( avgwidth*y_ppem + em_size / 2 ) / em_size; bsize->size = bsize->y_ppem; p += 48; } face->root.face_flags |= FT_FACE_FLAG_FIXED_SIZES; face->root.num_fixed_sizes = count; } Exit: return error; Fail: FT_FRAME_RELEASE( face->sbit_table ); face->sbit_table_size = 0; goto Exit; } FT_LOCAL_DEF( void ) tt_face_free_sbit_strikes( TT_Face face ) { FT_Stream stream = face->root.stream; FT_FRAME_RELEASE( face->sbit_table ); face->sbit_table_size = 0; face->sbit_num_strikes = 0; } FT_LOCAL_DEF( FT_Error ) tt_face_set_sbit_strike( TT_Face face, FT_UInt x_ppem, FT_UInt y_ppem, FT_ULong *astrike_index ) { FT_UInt nn, count; FT_Byte* p; FT_Byte* p_limit; if ( x_ppem > 255 || y_ppem < 1 || y_ppem > 255 ) return SFNT_Err_Invalid_PPem; p = face->sbit_table + 8; p_limit = p + face->sbit_table_size; count = face->sbit_num_strikes; for ( nn = 0; nn < count; nn++ ) { if ( x_ppem == (FT_UInt)p[44] && y_ppem == (FT_UInt)p[45] ) { *astrike_index = (FT_ULong)nn; return SFNT_Err_Ok; } p += 48; } return SFNT_Err_Invalid_PPem; } typedef struct { TT_Face face; FT_Stream stream; FT_Bitmap* bitmap; TT_SBit_Metrics metrics; FT_Bool metrics_loaded; FT_Bool bitmap_allocated; FT_Byte bit_depth; FT_ULong ebdt_start; FT_ULong ebdt_size; FT_ULong strike_index_array; FT_ULong strike_index_count; FT_Byte* eblc_base; FT_Byte* eblc_limit; } TT_SBitDecoderRec, *TT_SBitDecoder; static FT_Error tt_sbit_decoder_init( TT_SBitDecoder decoder, TT_Face face, FT_ULong strike_index, TT_SBit_MetricsRec* metrics ) { FT_Error error; FT_Stream stream = face->root.stream; FT_ULong ebdt_size; error = face->goto_table( face, TTAG_EBDT, stream, &ebdt_size ); if ( error ) error = face->goto_table( face, TTAG_bdat, stream, &ebdt_size ); if ( error ) goto Exit; decoder->face = face; decoder->stream = stream; decoder->bitmap = &face->root.glyph->bitmap; decoder->metrics = metrics; decoder->metrics_loaded = 0; decoder->bitmap_allocated = 0; decoder->ebdt_start = FT_STREAM_POS(); decoder->ebdt_size = ebdt_size; decoder->eblc_base = face->sbit_table; decoder->eblc_limit = face->sbit_table + face->sbit_table_size; /* now find the strike corresponding to the index */ { FT_Byte* p = decoder->eblc_base + 8 + 48 * strike_index; decoder->strike_index_array = FT_NEXT_ULONG( p ); p += 4; decoder->strike_index_count = FT_NEXT_ULONG( p ); p += 34; decoder->bit_depth = *p; } Exit: return error; } static void tt_sbit_decoder_done( TT_SBitDecoder decoder ) { FT_UNUSED( decoder ); } static FT_Error tt_sbit_decoder_alloc_bitmap( TT_SBitDecoder decoder ) { FT_Error error = SFNT_Err_Ok; FT_UInt width, height; FT_Bitmap* map = decoder->bitmap; FT_Long size; if ( !decoder->metrics_loaded ) { error = SFNT_Err_Invalid_Argument; goto Exit; } width = decoder->metrics->width; height = decoder->metrics->height; map->width = (int)width; map->rows = (int)height; switch ( decoder->bit_depth ) { case 1: map->pixel_mode = FT_PIXEL_MODE_MONO; map->pitch = ( map->width + 7 ) >> 3; break; case 2: map->pixel_mode = FT_PIXEL_MODE_GRAY2; map->pitch = ( map->width + 3 ) >> 2; break; case 4: map->pixel_mode = FT_PIXEL_MODE_GRAY4; map->pitch = ( map->width + 1 ) >> 1; break; case 8: map->pixel_mode = FT_PIXEL_MODE_GRAY; map->pitch = map->width; break; default: error = SFNT_Err_Invalid_File_Format; goto Exit; } size = map->rows * map->pitch; /* check that there is no empty image */ if ( size == 0 ) goto Exit; /* exit successfully! */ error = ft_glyphslot_alloc_bitmap( decoder->face->root.glyph, size ); if ( error ) goto Exit; decoder->bitmap_allocated = 1; Exit: return error; } static FT_Error tt_sbit_decoder_load_metrics( TT_SBitDecoder decoder, FT_Byte* *pp, FT_Byte* limit, FT_Bool big ) { FT_Byte* p = *pp; TT_SBit_Metrics metrics = decoder->metrics; if ( p + 5 > limit ) goto Fail; if ( !decoder->metrics_loaded ) { metrics->height = p[0]; metrics->width = p[1]; metrics->horiBearingX = (FT_Char)p[2]; metrics->horiBearingY = (FT_Char)p[3]; metrics->horiAdvance = p[4]; } p += 5; if ( big ) { if ( p + 3 > limit ) goto Fail; if ( !decoder->metrics_loaded ) { metrics->vertBearingX = (FT_Char)p[0]; metrics->vertBearingY = (FT_Char)p[1]; metrics->vertAdvance = p[2]; } p += 3; } decoder->metrics_loaded = 1; *pp = p; return 0; Fail: return SFNT_Err_Invalid_Argument; } /* forward declaration */ static FT_Error tt_sbit_decoder_load_image( TT_SBitDecoder decoder, FT_UInt glyph_index, FT_Int x_pos, FT_Int y_pos ); typedef FT_Error (*TT_SBitDecoder_LoadFunc)( TT_SBitDecoder decoder, FT_Byte* p, FT_Byte* plimit, FT_Int x_pos, FT_Int y_pos ); static FT_Error tt_sbit_decoder_load_byte_aligned( TT_SBitDecoder decoder, FT_Byte* p, FT_Byte* limit, FT_Int x_pos, FT_Int y_pos ) { FT_Error error = SFNT_Err_Ok; FT_Byte* line; FT_Int bit_height, bit_width, pitch, width, height, h; FT_Bitmap* bitmap; if ( !decoder->bitmap_allocated ) { error = tt_sbit_decoder_alloc_bitmap( decoder ); if ( error ) goto Exit; } /* check that we can write the glyph into the bitmap */ bitmap = decoder->bitmap; bit_width = bitmap->width; bit_height = bitmap->rows; pitch = bitmap->pitch; line = bitmap->buffer; width = decoder->metrics->width; height = decoder->metrics->height; if ( x_pos < 0 || x_pos + width > bit_width || y_pos < 0 || y_pos + height > bit_height ) { error = SFNT_Err_Invalid_File_Format; goto Exit; } if ( p + ( ( width + 7 ) >> 3 ) * height > limit ) { error = SFNT_Err_Invalid_File_Format; goto Exit; } /* now do the blit */ line += y_pos * pitch + ( x_pos >> 3 ); x_pos &= 7; if ( x_pos == 0 ) /* the easy one */ { for ( h = height; h > 0; h--, line += pitch ) { FT_Byte* write = line; FT_Int w; for ( w = width; w >= 8; w -= 8 ) { write[0] = (FT_Byte)( write[0] | *p++ ); write += 1; } if ( w > 0 ) write[0] = (FT_Byte)( write[0] | ( *p++ & ( 0xFF00U >> w ) ) ); } } else /* x_pos > 0 */ { for ( h = height; h > 0; h--, line += pitch ) { FT_Byte* write = line; FT_Int w; FT_UInt wval = 0; for ( w = width; w >= 8; w -= 8 ) { wval = (FT_UInt)( wval | *p++ ); write[0] = (FT_Byte)( write[0] | ( wval >> x_pos ) ); write += 1; wval <<= 8; } if ( w > 0 ) wval = (FT_UInt)(wval | ( *p++ & ( 0xFF00U >> w ) ) ); write[0] = (FT_Byte)( write[0] | ( wval >> x_pos ) ); } } Exit: return error; } static FT_Error tt_sbit_decoder_load_bit_aligned( TT_SBitDecoder decoder, FT_Byte* p, FT_Byte* limit, FT_Int x_pos, FT_Int y_pos ) { FT_Error error = SFNT_Err_Ok; FT_Byte* line; FT_Int bit_height, bit_width, pitch, width, height, h; FT_Bitmap* bitmap; FT_UInt32 rval; if ( !decoder->bitmap_allocated ) { error = tt_sbit_decoder_alloc_bitmap( decoder ); if ( error ) goto Exit; } /* check that we can write the glyph into the bitmap */ bitmap = decoder->bitmap; bit_width = bitmap->width; bit_height = bitmap->rows; pitch = bitmap->pitch; line = bitmap->buffer; width = decoder->metrics->width; height = decoder->metrics->height; if ( x_pos < 0 || x_pos + width > bit_width || y_pos < 0 || y_pos + height > bit_height ) { error = SFNT_Err_Invalid_File_Format; goto Exit; } if ( p + ( ( width + 7 ) >> 3 ) * height > limit ) { error = SFNT_Err_Invalid_File_Format; goto Exit; } /* now do the blit */ line += y_pos * pitch + ( x_pos >> 3 ); x_pos &= 7; rval = 0x10000UL; for ( h = height; h > 0; h--, line += pitch ) { FT_Byte* write = line; FT_UInt32 wval = 0x100 << x_pos; FT_Int w; for ( w = width; w >= 8; w -= 8 ) { if ( rval & 0x10000UL ) rval = 0x100 | *p++; wval |= rval & 0x80; wval <<= 1; rval <<= 1; if ( wval & 0x10000UL ) { write[0] = (FT_Byte)( write[0] | ( wval >> 8 ) ); write += 1; wval = 0x100; } } if ( wval != 0x100 ) { while ( wval > 0x1FF ) wval >>= 1; write[0] = (FT_Byte)( write[0] | wval ); } } Exit: return error; } static FT_Error tt_sbit_decoder_load_compound( TT_SBitDecoder decoder, FT_Byte* p, FT_Byte* limit, FT_Int x_pos, FT_Int y_pos ) { FT_Error error = SFNT_Err_Ok; FT_UInt num_components, nn; if ( p + 2 > limit ) goto Fail; num_components = FT_NEXT_USHORT( p ); if ( p + 4 * num_components > limit ) goto Fail; for ( nn = 0; nn < num_components; nn++ ) { FT_UInt gindex = FT_NEXT_USHORT( p ); FT_Byte dx = FT_NEXT_BYTE( p ); FT_Byte dy = FT_NEXT_BYTE( p ); /* NB: a recursive call */ error = tt_sbit_decoder_load_image( decoder, gindex, x_pos + dx, y_pos + dy ); if ( error ) break; } Exit: return error; Fail: error = SFNT_Err_Invalid_File_Format; goto Exit; } static FT_Error tt_sbit_decoder_load_bitmap( TT_SBitDecoder decoder, FT_UInt glyph_format, FT_ULong glyph_start, FT_ULong glyph_size, FT_Int x_pos, FT_Int y_pos ) { FT_Error error; FT_Stream stream = decoder->stream; FT_Byte* p; FT_Byte* p_limit; FT_Byte* data; /* seek into the EBDT table now */ if ( glyph_start + glyph_size > decoder->ebdt_size ) { error = SFNT_Err_Invalid_Argument; goto Exit; } if ( FT_STREAM_SEEK( decoder->ebdt_start + glyph_start ) || FT_FRAME_EXTRACT( glyph_size, data ) ) goto Exit; p = data; p_limit = p + glyph_size; /* read the data, depending on the glyph format */ switch ( glyph_format ) { case 1: case 2: case 8: error = tt_sbit_decoder_load_metrics( decoder, &p, p_limit, 0 ); break; case 6: case 7: case 9: error = tt_sbit_decoder_load_metrics( decoder, &p, p_limit, 1 ); break; default: error = SFNT_Err_Ok; } if ( error ) goto Fail; { TT_SBitDecoder_LoadFunc loader; switch ( glyph_format ) { case 1: case 6: loader = tt_sbit_decoder_load_byte_aligned; break; case 2: case 5: case 7: loader = tt_sbit_decoder_load_bit_aligned; break; case 8: if ( p + 1 > p_limit ) goto Fail; p += 1; /* skip padding */ /* fall-through */ case 9: loader = tt_sbit_decoder_load_compound; break; default: goto Fail; } error = loader( decoder, p, p_limit, x_pos, y_pos ); } Fail: FT_FRAME_RELEASE( data ); Exit: return error; } static FT_Error tt_sbit_decoder_load_image( TT_SBitDecoder decoder, FT_UInt glyph_index, FT_Int x_pos, FT_Int y_pos ) { /* * First, we find the correct strike range that applies to this * glyph index. */ FT_Byte* p = decoder->eblc_base + decoder->strike_index_array; FT_Byte* p_limit = decoder->eblc_limit; FT_ULong num_ranges = decoder->strike_index_count; FT_UInt start, end, index_format, image_format; FT_ULong image_start = 0, image_end = 0, image_offset; if ( p + 8 * num_ranges > p_limit ) goto NoBitmap; for ( ; num_ranges > 0; num_ranges-- ) { start = FT_NEXT_USHORT( p ); end = FT_NEXT_USHORT( p ); if ( glyph_index >= start && glyph_index <= end ) goto FoundRange; p += 4; /* ignore index offset */ } goto NoBitmap; FoundRange: image_offset = FT_NEXT_ULONG( p ); p = decoder->eblc_base + decoder->strike_index_array + image_offset; if ( p + 8 > p_limit ) goto NoBitmap; /* now find the glyph's location and extend within the ebdt table */ index_format = FT_NEXT_USHORT( p ); image_format = FT_NEXT_USHORT( p ); image_offset = FT_NEXT_ULONG ( p ); switch ( index_format ) { case 1: /* 4-byte offsets relative to `image_offset' */ { p += 4 * ( glyph_index - start ); if ( p + 8 > p_limit ) goto NoBitmap; image_start = FT_NEXT_ULONG( p ); image_end = FT_NEXT_ULONG( p ); if ( image_start == image_end ) /* missing glyph */ goto NoBitmap; } br... [truncated message content] |
From: Ehud S. <esh...@us...> - 2006-04-21 16:22:42
|
Update of /cvsroot/roadmap/roadmap_editor/src/freetype/src/psnames In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22848/src/psnames Added Files: psmodule.c psnames.c Log Message: Import freetype sources. --- NEW FILE: psmodule.c --- /***************************************************************************/ /* */ /* psmodule.c */ /* */ /* PSNames module implementation (body). */ /* */ /* Copyright 1996-2001, 2002, 2003, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include <ft2build.h> #include FT_INTERNAL_OBJECTS_H #include FT_SERVICE_POSTSCRIPT_CMAPS_H #include "psmodule.h" #include "pstables.h" #include "psnamerr.h" #ifndef FT_CONFIG_OPTION_NO_POSTSCRIPT_NAMES #ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST /* Return the Unicode value corresponding to a given glyph. Note that */ /* we do deal with glyph variants by detecting a non-initial dot in */ /* the name, as in `A.swash' or `e.final'. */ /* */ static FT_UInt32 ps_unicode_value( const char* glyph_name ) { /* If the name begins with `uni', then the glyph name may be a */ /* hard-coded unicode character code. */ if ( glyph_name[0] == 'u' && glyph_name[1] == 'n' && glyph_name[2] == 'i' ) { /* determine whether the next four characters following are */ /* hexadecimal. */ /* XXX: Add code to deal with ligatures, i.e. glyph names like */ /* `uniXXXXYYYYZZZZ'... */ FT_Int count; FT_ULong value = 0; const char* p = glyph_name + 3; for ( count = 4; count > 0; count--, p++ ) { char c = *p; unsigned int d; d = (unsigned char)c - '0'; if ( d >= 10 ) { d = (unsigned char)c - 'A'; if ( d >= 6 ) d = 16; else d += 10; } /* exit if a non-uppercase hexadecimal character was found */ if ( d >= 16 ) break; value = ( value << 4 ) + d; } /* there must be exactly four hex digits */ if ( ( *p == '\0' || *p == '.' ) && count == 0 ) return value; } /* If the name begins with `u', followed by four to six uppercase */ /* hexadicimal digits, it is a hard-coded unicode character code. */ if ( glyph_name[0] == 'u' ) { FT_Int count; FT_ULong value = 0; const char* p = glyph_name + 1; for ( count = 6; count > 0; count--, p++ ) { char c = *p; unsigned int d; d = (unsigned char)c - '0'; if ( d >= 10 ) { d = (unsigned char)c - 'A'; if ( d >= 6 ) d = 16; else d += 10; } if ( d >= 16 ) break; value = ( value << 4 ) + d; } if ( ( *p == '\0' || *p == '.' ) && count <= 2 ) return value; } /* look for a non-initial dot in the glyph name in order to */ /* sort-out variants like `A.swash', `e.final', etc. */ { const char* p = glyph_name; const char* dot = NULL; for ( ; *p; p++ ) { if ( *p == '.' && p > glyph_name && !dot ) dot = p; } if ( !dot ) dot = p; /* now, look up the glyph in the Adobe Glyph List */ return ft_get_adobe_glyph_index( glyph_name, dot ); } } /* ft_qsort callback to sort the unicode map */ FT_CALLBACK_DEF( int ) compare_uni_maps( const void* a, const void* b ) { PS_UniMap* map1 = (PS_UniMap*)a; PS_UniMap* map2 = (PS_UniMap*)b; return ( map1->unicode - map2->unicode ); } /* Builds a table that maps Unicode values to glyph indices */ static FT_Error ps_unicodes_init( FT_Memory memory, FT_UInt num_glyphs, const char** glyph_names, PS_Unicodes* table ) { FT_Error error; /* we first allocate the table */ table->num_maps = 0; table->maps = 0; if ( !FT_NEW_ARRAY( table->maps, num_glyphs ) ) { FT_UInt n; FT_UInt count; PS_UniMap* map; FT_UInt32 uni_char; map = table->maps; for ( n = 0; n < num_glyphs; n++ ) { const char* gname = glyph_names[n]; if ( gname ) { uni_char = ps_unicode_value( gname ); if ( uni_char != 0 && uni_char != 0xFFFFL ) { map->unicode = (FT_UInt)uni_char; map->glyph_index = n; map++; } } } /* now, compress the table a bit */ count = (FT_UInt)( map - table->maps ); if ( count > 0 && FT_REALLOC( table->maps, num_glyphs * sizeof ( PS_UniMap ), count * sizeof ( PS_UniMap ) ) ) count = 0; if ( count == 0 ) { FT_FREE( table->maps ); if ( !error ) error = PSnames_Err_Invalid_Argument; /* no unicode chars here! */ } else /* sort the table in increasing order of unicode values */ ft_qsort( table->maps, count, sizeof ( PS_UniMap ), compare_uni_maps ); table->num_maps = count; } return error; } static FT_UInt ps_unicodes_char_index( PS_Unicodes* table, FT_ULong unicode ) { PS_UniMap *min, *max, *mid; /* perform a binary search on the table */ min = table->maps; max = min + table->num_maps - 1; while ( min <= max ) { mid = min + ( max - min ) / 2; if ( mid->unicode == unicode ) return mid->glyph_index; if ( min == max ) break; if ( mid->unicode < unicode ) min = mid + 1; else max = mid - 1; } return 0xFFFFU; } static FT_ULong ps_unicodes_char_next( PS_Unicodes* table, FT_ULong unicode ) { PS_UniMap *min, *max, *mid; unicode++; /* perform a binary search on the table */ min = table->maps; max = min + table->num_maps - 1; while ( min <= max ) { mid = min + ( max - min ) / 2; if ( mid->unicode == unicode ) return unicode; if ( min == max ) break; if ( mid->unicode < unicode ) min = mid + 1; else max = mid - 1; } if ( max < table->maps ) max = table->maps; while ( max < table->maps + table->num_maps ) { if ( unicode < max->unicode ) return max->unicode; max++; } return 0; } #endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */ static const char* ps_get_macintosh_name( FT_UInt name_index ) { if ( name_index >= FT_NUM_MAC_NAMES ) name_index = 0; return ft_standard_glyph_names + ft_mac_names[name_index]; } static const char* ps_get_standard_strings( FT_UInt sid ) { if ( sid >= FT_NUM_SID_NAMES ) return 0; return ft_standard_glyph_names + ft_sid_names[sid]; } static const FT_Service_PsCMapsRec pscmaps_interface = { #ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST (PS_Unicode_ValueFunc) ps_unicode_value, (PS_Unicodes_InitFunc) ps_unicodes_init, (PS_Unicodes_CharIndexFunc)ps_unicodes_char_index, (PS_Unicodes_CharNextFunc) ps_unicodes_char_next, #else 0, 0, 0, 0, #endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */ (PS_Macintosh_Name_Func) ps_get_macintosh_name, (PS_Adobe_Std_Strings_Func)ps_get_standard_strings, t1_standard_encoding, t1_expert_encoding }; static const FT_ServiceDescRec pscmaps_services[] = { { FT_SERVICE_ID_POSTSCRIPT_CMAPS, &pscmaps_interface }, { NULL, NULL } }; static FT_Pointer psnames_get_service( FT_Module module, const char* service_id ) { FT_UNUSED( module ); return ft_service_list_lookup( pscmaps_services, service_id ); } #endif /* !FT_CONFIG_OPTION_NO_POSTSCRIPT_NAMES */ FT_CALLBACK_TABLE_DEF const FT_Module_Class psnames_module_class = { 0, /* this is not a font driver, nor a renderer */ sizeof ( FT_ModuleRec ), "psnames", /* driver name */ 0x10000L, /* driver version */ 0x20000L, /* driver requires FreeType 2 or above */ #ifdef FT_CONFIG_OPTION_NO_POSTSCRIPT_NAMES 0, (FT_Module_Constructor)0, (FT_Module_Destructor) 0, (FT_Module_Requester) 0 #else (void*)&pscmaps_interface, /* module specific interface */ (FT_Module_Constructor)0, (FT_Module_Destructor) 0, (FT_Module_Requester) psnames_get_service #endif }; /* END */ --- NEW FILE: psnames.c --- /***************************************************************************/ /* */ /* psnames.c */ /* */ /* FreeType PSNames module component (body only). */ /* */ /* Copyright 1996-2001 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #define FT_MAKE_OPTION_SINGLE_OBJECT #include <ft2build.h> #include "psmodule.c" /* END */ |
From: Ehud S. <esh...@us...> - 2006-04-21 16:22:41
|
Update of /cvsroot/roadmap/roadmap_editor/src/freetype/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22848/src Added Files: Jamfile Log Message: Import freetype sources. --- NEW FILE: Jamfile --- # FreeType 2 src Jamfile # # Copyright 2001, 2002 by # David Turner, Robert Wilhelm, and Werner Lemberg. # # This file is part of the FreeType project, and may only be used, modified, # and distributed under the terms of the FreeType project license, # LICENSE.TXT. By continuing to use, modify, or distribute this file you # indicate that you have read the license and understand and accept it # fully. SubDir FT2_TOP $(FT2_SRC_DIR) ; # The file <freetype/internal/internal.h> is used to define macros that are # later used in #include statements. It needs to be parsed in order to # record these definitions. # HDRMACRO [ FT2_SubDir $(FT2_INCLUDE_DIR) internal internal.h ] ; for xx in $(FT2_COMPONENTS) { SubInclude FT2_TOP $(FT2_SRC_DIR) $(xx) ; } # end of src Jamfile |
From: Ehud S. <esh...@us...> - 2006-04-21 16:22:41
|
Update of /cvsroot/roadmap/roadmap_editor/src/freetype/src/raster In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22848/src/raster Added Files: ftraster.c ftrend1.c raster.c Log Message: Import freetype sources. --- NEW FILE: raster.c --- /***************************************************************************/ /* */ /* raster.c */ /* */ /* FreeType monochrome rasterer module component (body only). */ /* */ /* Copyright 1996-2001 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #define FT_MAKE_OPTION_SINGLE_OBJECT #include <ft2build.h> #include "ftraster.c" #include "ftrend1.c" /* END */ --- NEW FILE: ftrend1.c --- /***************************************************************************/ /* */ /* ftrend1.c */ /* */ /* The FreeType glyph rasterizer interface (body). */ /* */ /* Copyright 1996-2001, 2002, 2003, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include <ft2build.h> #include FT_INTERNAL_OBJECTS_H #include FT_OUTLINE_H #include "ftrend1.h" #include "ftraster.h" #include "rasterrs.h" /* initialize renderer -- init its raster */ static FT_Error ft_raster1_init( FT_Renderer render ) { FT_Library library = FT_MODULE_LIBRARY( render ); render->clazz->raster_class->raster_reset( render->raster, library->raster_pool, library->raster_pool_size ); return Raster_Err_Ok; } /* set render-specific mode */ static FT_Error ft_raster1_set_mode( FT_Renderer render, FT_ULong mode_tag, FT_Pointer data ) { /* we simply pass it to the raster */ return render->clazz->raster_class->raster_set_mode( render->raster, mode_tag, data ); } /* transform a given glyph image */ static FT_Error ft_raster1_transform( FT_Renderer render, FT_GlyphSlot slot, const FT_Matrix* matrix, const FT_Vector* delta ) { FT_Error error = Raster_Err_Ok; if ( slot->format != render->glyph_format ) { error = Raster_Err_Invalid_Argument; goto Exit; } if ( matrix ) FT_Outline_Transform( &slot->outline, matrix ); if ( delta ) FT_Outline_Translate( &slot->outline, delta->x, delta->y ); Exit: return error; } /* return the glyph's control box */ static void ft_raster1_get_cbox( FT_Renderer render, FT_GlyphSlot slot, FT_BBox* cbox ) { FT_MEM_ZERO( cbox, sizeof ( *cbox ) ); if ( slot->format == render->glyph_format ) FT_Outline_Get_CBox( &slot->outline, cbox ); } /* convert a slot's glyph image into a bitmap */ static FT_Error ft_raster1_render( FT_Renderer render, FT_GlyphSlot slot, FT_Render_Mode mode, const FT_Vector* origin ) { FT_Error error; FT_Outline* outline; FT_BBox cbox; FT_UInt width, height, pitch; FT_Bitmap* bitmap; FT_Memory memory; FT_Raster_Params params; /* check glyph image format */ if ( slot->format != render->glyph_format ) { error = Raster_Err_Invalid_Argument; goto Exit; } /* check rendering mode */ if ( mode != FT_RENDER_MODE_MONO ) { /* raster1 is only capable of producing monochrome bitmaps */ if ( render->clazz == &ft_raster1_renderer_class ) return Raster_Err_Cannot_Render_Glyph; } else { /* raster5 is only capable of producing 5-gray-levels bitmaps */ if ( render->clazz == &ft_raster5_renderer_class ) return Raster_Err_Cannot_Render_Glyph; } outline = &slot->outline; /* translate the outline to the new origin if needed */ if ( origin ) FT_Outline_Translate( outline, origin->x, origin->y ); /* compute the control box, and grid fit it */ FT_Outline_Get_CBox( outline, &cbox ); cbox.xMin = FT_PIX_FLOOR( cbox.xMin ); cbox.yMin = FT_PIX_FLOOR( cbox.yMin ); cbox.xMax = FT_PIX_CEIL( cbox.xMax ); cbox.yMax = FT_PIX_CEIL( cbox.yMax ); width = (FT_UInt)( ( cbox.xMax - cbox.xMin ) >> 6 ); height = (FT_UInt)( ( cbox.yMax - cbox.yMin ) >> 6 ); bitmap = &slot->bitmap; memory = render->root.memory; /* release old bitmap buffer */ if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) { FT_FREE( bitmap->buffer ); slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP; } /* allocate new one, depends on pixel format */ if ( !( mode & FT_RENDER_MODE_MONO ) ) { /* we pad to 32 bits, only for backwards compatibility with FT 1.x */ pitch = FT_PAD_CEIL( width, 4 ); bitmap->pixel_mode = FT_PIXEL_MODE_GRAY; bitmap->num_grays = 256; } else { pitch = ( ( width + 15 ) >> 4 ) << 1; bitmap->pixel_mode = FT_PIXEL_MODE_MONO; } bitmap->width = width; bitmap->rows = height; bitmap->pitch = pitch; if ( FT_ALLOC( bitmap->buffer, (FT_ULong)pitch * height ) ) goto Exit; slot->internal->flags |= FT_GLYPH_OWN_BITMAP; /* translate outline to render it into the bitmap */ FT_Outline_Translate( outline, -cbox.xMin, -cbox.yMin ); /* set up parameters */ params.target = bitmap; params.source = outline; params.flags = 0; if ( bitmap->pixel_mode == FT_PIXEL_MODE_GRAY ) params.flags |= FT_RASTER_FLAG_AA; /* render outline into the bitmap */ error = render->raster_render( render->raster, ¶ms ); FT_Outline_Translate( outline, cbox.xMin, cbox.yMin ); if ( error ) goto Exit; slot->format = FT_GLYPH_FORMAT_BITMAP; slot->bitmap_left = (FT_Int)( cbox.xMin >> 6 ); slot->bitmap_top = (FT_Int)( cbox.yMax >> 6 ); Exit: return error; } FT_CALLBACK_TABLE_DEF const FT_Renderer_Class ft_raster1_renderer_class = { { FT_MODULE_RENDERER, sizeof( FT_RendererRec ), "raster1", 0x10000L, 0x20000L, 0, /* module specific interface */ (FT_Module_Constructor)ft_raster1_init, (FT_Module_Destructor) 0, (FT_Module_Requester) 0 }, FT_GLYPH_FORMAT_OUTLINE, (FT_Renderer_RenderFunc) ft_raster1_render, (FT_Renderer_TransformFunc)ft_raster1_transform, (FT_Renderer_GetCBoxFunc) ft_raster1_get_cbox, (FT_Renderer_SetModeFunc) ft_raster1_set_mode, (FT_Raster_Funcs*) &ft_standard_raster }; /* This renderer is _NOT_ part of the default modules; you will need */ /* to register it by hand in your application. It should only be */ /* used for backwards-compatibility with FT 1.x anyway. */ /* */ FT_CALLBACK_TABLE_DEF const FT_Renderer_Class ft_raster5_renderer_class = { { FT_MODULE_RENDERER, sizeof( FT_RendererRec ), "raster5", 0x10000L, 0x20000L, 0, /* module specific interface */ (FT_Module_Constructor)ft_raster1_init, (FT_Module_Destructor) 0, (FT_Module_Requester) 0 }, FT_GLYPH_FORMAT_OUTLINE, (FT_Renderer_RenderFunc) ft_raster1_render, (FT_Renderer_TransformFunc)ft_raster1_transform, (FT_Renderer_GetCBoxFunc) ft_raster1_get_cbox, (FT_Renderer_SetModeFunc) ft_raster1_set_mode, (FT_Raster_Funcs*) &ft_standard_raster }; /* END */ --- NEW FILE: ftraster.c --- /***************************************************************************/ /* */ /* ftraster.c */ /* */ /* The FreeType glyph rasterizer (body). */ /* */ /* Copyright 1996-2001, 2002, 2003, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ /*************************************************************************/ /* */ [...3302 lines suppressed...] ras.target = *target_map; return ( ( params->flags & FT_RASTER_FLAG_AA ) ? Render_Gray_Glyph( RAS_VAR ) : Render_Glyph( RAS_VAR ) ); } const FT_Raster_Funcs ft_standard_raster = { FT_GLYPH_FORMAT_OUTLINE, (FT_Raster_New_Func) ft_black_new, (FT_Raster_Reset_Func) ft_black_reset, (FT_Raster_Set_Mode_Func)ft_black_set_mode, (FT_Raster_Render_Func) ft_black_render, (FT_Raster_Done_Func) ft_black_done }; /* END */ |
From: Ehud S. <esh...@us...> - 2006-04-21 16:22:41
|
Update of /cvsroot/roadmap/roadmap_editor/src/freetype/src/type42 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22848/src/type42 Added Files: t42drivr.c t42objs.c t42parse.c type42.c Log Message: Import freetype sources. --- NEW FILE: t42objs.c --- /***************************************************************************/ /* */ /* t42objs.c */ /* */ /* Type 42 objects manager (body). */ /* */ /* Copyright 2002, 2003, 2004, 2005 by Roberto Alameda. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include "t42objs.h" #include "t42parse.h" #include "t42error.h" #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_STREAM_H #include FT_LIST_H #undef FT_COMPONENT #define FT_COMPONENT trace_t42 static FT_Error T42_Open_Face( T42_Face face ) { T42_LoaderRec loader; T42_Parser parser; T1_Font type1 = &face->type1; FT_Memory memory = face->root.memory; FT_Error error; PSAux_Service psaux = (PSAux_Service)face->psaux; t42_loader_init( &loader, face ); parser = &loader.parser; if ( FT_ALLOC( face->ttf_data, 12 ) ) goto Exit; error = t42_parser_init( parser, face->root.stream, memory, psaux); if ( error ) goto Exit; error = t42_parse_dict( face, &loader, parser->base_dict, parser->base_len ); if ( type1->font_type != 42 ) { error = T42_Err_Unknown_File_Format; goto Exit; } /* now, propagate the charstrings and glyphnames tables */ /* to the Type1 data */ type1->num_glyphs = loader.num_glyphs; if ( !loader.charstrings.init ) { FT_ERROR(( "T42_Open_Face: no charstrings array in face!\n" )); error = T42_Err_Invalid_File_Format; } loader.charstrings.init = 0; type1->charstrings_block = loader.charstrings.block; type1->charstrings = loader.charstrings.elements; type1->charstrings_len = loader.charstrings.lengths; /* we copy the glyph names `block' and `elements' fields; */ /* the `lengths' field must be released later */ type1->glyph_names_block = loader.glyph_names.block; type1->glyph_names = (FT_String**)loader.glyph_names.elements; loader.glyph_names.block = 0; loader.glyph_names.elements = 0; /* we must now build type1.encoding when we have a custom array */ if ( type1->encoding_type == T1_ENCODING_TYPE_ARRAY ) { FT_Int charcode, idx, min_char, max_char; FT_Byte* char_name; FT_Byte* glyph_name; /* OK, we do the following: for each element in the encoding */ /* table, look up the index of the glyph having the same name */ /* as defined in the CharStrings array. */ /* The index is then stored in type1.encoding.char_index, and */ /* the name in type1.encoding.char_name */ min_char = +32000; max_char = -32000; charcode = 0; for ( ; charcode < loader.encoding_table.max_elems; charcode++ ) { type1->encoding.char_index[charcode] = 0; type1->encoding.char_name [charcode] = (char *)".notdef"; char_name = loader.encoding_table.elements[charcode]; if ( char_name ) for ( idx = 0; idx < type1->num_glyphs; idx++ ) { glyph_name = (FT_Byte*)type1->glyph_names[idx]; if ( ft_strcmp( (const char*)char_name, (const char*)glyph_name ) == 0 ) { type1->encoding.char_index[charcode] = (FT_UShort)idx; type1->encoding.char_name [charcode] = (char*)glyph_name; /* Change min/max encoded char only if glyph name is */ /* not /.notdef */ if ( ft_strcmp( (const char*)".notdef", (const char*)glyph_name ) != 0 ) { if ( charcode < min_char ) min_char = charcode; if ( charcode > max_char ) max_char = charcode; } break; } } } type1->encoding.code_first = min_char; type1->encoding.code_last = max_char; type1->encoding.num_chars = loader.num_chars; } Exit: t42_loader_done( &loader ); return error; } /***************** Driver Functions *************/ FT_LOCAL_DEF( FT_Error ) T42_Face_Init( FT_Stream stream, T42_Face face, FT_Int face_index, FT_Int num_params, FT_Parameter* params ) { FT_Error error; FT_Service_PsCMaps psnames; PSAux_Service psaux; FT_Face root = (FT_Face)&face->root; T1_Font type1 = &face->type1; PS_FontInfo info = &type1->font_info; FT_UNUSED( num_params ); FT_UNUSED( params ); FT_UNUSED( face_index ); FT_UNUSED( stream ); face->ttf_face = NULL; face->root.num_faces = 1; FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS ); face->psnames = psnames; face->psaux = FT_Get_Module_Interface( FT_FACE_LIBRARY( face ), "psaux" ); psaux = (PSAux_Service)face->psaux; /* open the tokenizer, this will also check the font format */ error = T42_Open_Face( face ); if ( error ) goto Exit; /* if we just wanted to check the format, leave successfully now */ if ( face_index < 0 ) goto Exit; /* check the face index */ if ( face_index != 0 ) { FT_ERROR(( "T42_Face_Init: invalid face index\n" )); error = T42_Err_Invalid_Argument; goto Exit; } /* Now load the font program into the face object */ /* Init the face object fields */ /* Now set up root face fields */ root->num_glyphs = type1->num_glyphs; root->num_charmaps = 0; root->face_index = face_index; root->face_flags = FT_FACE_FLAG_SCALABLE; root->face_flags |= FT_FACE_FLAG_HORIZONTAL; root->face_flags |= FT_FACE_FLAG_GLYPH_NAMES; if ( info->is_fixed_pitch ) root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH; /* XXX: TODO -- add kerning with .afm support */ /* get style name -- be careful, some broken fonts only */ /* have a `/FontName' dictionary entry! */ root->family_name = info->family_name; /* assume "Regular" style if we don't know better */ root->style_name = (char *)"Regular"; if ( root->family_name ) { char* full = info->full_name; char* family = root->family_name; if ( full ) { while ( *full ) { if ( *full == *family ) { family++; full++; } else { if ( *full == ' ' || *full == '-' ) full++; else if ( *family == ' ' || *family == '-' ) family++; else { if ( !*family ) root->style_name = full; break; } } } } } else { /* do we have a `/FontName'? */ if ( type1->font_name ) root->family_name = type1->font_name; } /* no embedded bitmap support */ root->num_fixed_sizes = 0; root->available_sizes = 0; /* Load the TTF font embedded in the T42 font */ error = FT_New_Memory_Face( FT_FACE_LIBRARY( face ), face->ttf_data, face->ttf_size, 0, &face->ttf_face ); if ( error ) goto Exit; FT_Done_Size( face->ttf_face->size ); /* Ignore info in FontInfo dictionary and use the info from the */ /* loaded TTF font. The PostScript interpreter also ignores it. */ root->bbox = face->ttf_face->bbox; root->units_per_EM = face->ttf_face->units_per_EM; root->ascender = face->ttf_face->ascender; root->descender = face->ttf_face->descender; root->height = face->ttf_face->height; root->max_advance_width = face->ttf_face->max_advance_width; root->max_advance_height = face->ttf_face->max_advance_height; root->underline_position = (FT_Short)info->underline_position; root->underline_thickness = (FT_Short)info->underline_thickness; root->internal->max_points = 0; root->internal->max_contours = 0; /* compute style flags */ root->style_flags = 0; if ( info->italic_angle ) root->style_flags |= FT_STYLE_FLAG_ITALIC; if ( face->ttf_face->style_flags & FT_STYLE_FLAG_BOLD ) root->style_flags |= FT_STYLE_FLAG_BOLD; if ( face->ttf_face->face_flags & FT_FACE_FLAG_VERTICAL ) root->face_flags |= FT_FACE_FLAG_VERTICAL; { if ( psnames && psaux ) { FT_CharMapRec charmap; T1_CMap_Classes cmap_classes = psaux->t1_cmap_classes; FT_CMap_Class clazz; charmap.face = root; /* first of all, try to synthetize a Unicode charmap */ charmap.platform_id = 3; charmap.encoding_id = 1; charmap.encoding = FT_ENCODING_UNICODE; FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL ); /* now, generate an Adobe Standard encoding when appropriate */ charmap.platform_id = 7; clazz = NULL; switch ( type1->encoding_type ) { case T1_ENCODING_TYPE_STANDARD: charmap.encoding = FT_ENCODING_ADOBE_STANDARD; charmap.encoding_id = 0; clazz = cmap_classes->standard; break; case T1_ENCODING_TYPE_EXPERT: charmap.encoding = FT_ENCODING_ADOBE_EXPERT; charmap.encoding_id = 1; clazz = cmap_classes->expert; break; case T1_ENCODING_TYPE_ARRAY: charmap.encoding = FT_ENCODING_ADOBE_CUSTOM; charmap.encoding_id = 2; clazz = cmap_classes->custom; break; case T1_ENCODING_TYPE_ISOLATIN1: charmap.encoding = FT_ENCODING_ADOBE_LATIN_1; charmap.encoding_id = 3; clazz = cmap_classes->unicode; break; default: ; } if ( clazz ) FT_CMap_New( clazz, NULL, &charmap, NULL ); #if 0 /* Select default charmap */ if ( root->num_charmaps ) root->charmap = root->charmaps[0]; #endif } } Exit: return error; } FT_LOCAL_DEF( void ) T42_Face_Done( T42_Face face ) { T1_Font type1; PS_FontInfo info; FT_Memory memory; if ( face ) { type1 = &face->type1; info = &type1->font_info; memory = face->root.memory; /* delete internal ttf face prior to freeing face->ttf_data */ if ( face->ttf_face ) FT_Done_Face( face->ttf_face ); /* release font info strings */ FT_FREE( info->version ); FT_FREE( info->notice ); FT_FREE( info->full_name ); FT_FREE( info->family_name ); FT_FREE( info->weight ); /* release top dictionary */ FT_FREE( type1->charstrings_len ); FT_FREE( type1->charstrings ); FT_FREE( type1->glyph_names ); FT_FREE( type1->charstrings_block ); FT_FREE( type1->glyph_names_block ); FT_FREE( type1->encoding.char_index ); FT_FREE( type1->encoding.char_name ); FT_FREE( type1->font_name ); FT_FREE( face->ttf_data ); #if 0 /* release afm data if present */ if ( face->afm_data ) T1_Done_AFM( memory, (T1_AFM*)face->afm_data ); #endif /* release unicode map, if any */ FT_FREE( face->unicode_map.maps ); face->unicode_map.num_maps = 0; face->root.family_name = 0; face->root.style_name = 0; } } /*************************************************************************/ /* */ /* <Function> */ /* T42_Driver_Init */ /* */ /* <Description> */ /* Initializes a given Type 42 driver object. */ /* */ /* <Input> */ /* driver :: A handle to the target driver object. */ /* */ /* <Return> */ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) T42_Driver_Init( T42_Driver driver ) { FT_Module ttmodule; ttmodule = FT_Get_Module( FT_MODULE(driver)->library, "truetype" ); driver->ttclazz = (FT_Driver_Class)ttmodule->clazz; return T42_Err_Ok; } FT_LOCAL_DEF( void ) T42_Driver_Done( T42_Driver driver ) { FT_UNUSED( driver ); } FT_LOCAL_DEF( FT_Error ) T42_Size_Init( T42_Size size ) { FT_Face face = size->root.face; T42_Face t42face = (T42_Face)face; FT_Size ttsize; FT_Error error = T42_Err_Ok; error = FT_New_Size( t42face->ttf_face, &ttsize ); size->ttsize = ttsize; FT_Activate_Size( ttsize ); return error; } FT_LOCAL_DEF( void ) T42_Size_Done( T42_Size size ) { FT_Face face = size->root.face; T42_Face t42face = (T42_Face)face; FT_ListNode node; node = FT_List_Find( &t42face->ttf_face->sizes_list, size->ttsize ); if ( node ) { FT_Done_Size( size->ttsize ); size->ttsize = NULL; } } FT_LOCAL_DEF( FT_Error ) T42_GlyphSlot_Init( T42_GlyphSlot slot ) { FT_Face face = slot->root.face; T42_Face t42face = (T42_Face)face; FT_GlyphSlot ttslot; FT_Error error = T42_Err_Ok; if ( face->glyph == NULL ) { /* First glyph slot for this face */ slot->ttslot = t42face->ttf_face->glyph; } else { error = FT_New_GlyphSlot( t42face->ttf_face, &ttslot ); slot->ttslot = ttslot; } return error; } FT_LOCAL_DEF( void ) T42_GlyphSlot_Done( T42_GlyphSlot slot ) { FT_Done_GlyphSlot( slot->ttslot ); } FT_LOCAL_DEF( FT_Error ) T42_Size_SetChars( T42_Size size, FT_F26Dot6 char_width, FT_F26Dot6 char_height, FT_UInt horz_resolution, FT_UInt vert_resolution ) { FT_Face face = size->root.face; T42_Face t42face = (T42_Face)face; FT_Activate_Size( size->ttsize ); return FT_Set_Char_Size( t42face->ttf_face, char_width, char_height, horz_resolution, vert_resolution ); } FT_LOCAL_DEF( FT_Error ) T42_Size_SetPixels( T42_Size size, FT_UInt pixel_width, FT_UInt pixel_height ) { FT_Face face = size->root.face; T42_Face t42face = (T42_Face)face; FT_Activate_Size( size->ttsize ); return FT_Set_Pixel_Sizes( t42face->ttf_face, pixel_width, pixel_height ); } static void t42_glyphslot_clear( FT_GlyphSlot slot ) { /* free bitmap if needed */ ft_glyphslot_free_bitmap( slot ); /* clear all public fields in the glyph slot */ FT_ZERO( &slot->metrics ); FT_ZERO( &slot->outline ); FT_ZERO( &slot->bitmap ); slot->bitmap_left = 0; slot->bitmap_top = 0; slot->num_subglyphs = 0; slot->subglyphs = 0; slot->control_data = 0; slot->control_len = 0; slot->other = 0; slot->format = FT_GLYPH_FORMAT_NONE; slot->linearHoriAdvance = 0; slot->linearVertAdvance = 0; } FT_LOCAL_DEF( FT_Error ) T42_GlyphSlot_Load( FT_GlyphSlot glyph, FT_Size size, FT_UInt glyph_index, FT_Int32 load_flags ) { FT_Error error; T42_GlyphSlot t42slot = (T42_GlyphSlot)glyph; T42_Size t42size = (T42_Size)size; FT_Driver_Class ttclazz = ((T42_Driver)glyph->face->driver)->ttclazz; t42_glyphslot_clear( t42slot->ttslot ); error = ttclazz->load_glyph( t42slot->ttslot, t42size->ttsize, glyph_index, load_flags | FT_LOAD_NO_BITMAP ); if ( !error ) { glyph->metrics = t42slot->ttslot->metrics; glyph->linearHoriAdvance = t42slot->ttslot->linearHoriAdvance; glyph->linearVertAdvance = t42slot->ttslot->linearVertAdvance; glyph->format = t42slot->ttslot->format; glyph->outline = t42slot->ttslot->outline; glyph->bitmap = t42slot->ttslot->bitmap; glyph->bitmap_left = t42slot->ttslot->bitmap_left; glyph->bitmap_top = t42slot->ttslot->bitmap_top; glyph->num_subglyphs = t42slot->ttslot->num_subglyphs; glyph->subglyphs = t42slot->ttslot->subglyphs; glyph->control_data = t42slot->ttslot->control_data; glyph->control_len = t42slot->ttslot->control_len; } return error; } /* END */ --- NEW FILE: t42parse.c --- /***************************************************************************/ /* */ /* t42parse.c */ /* */ /* Type 42 font parser (body). */ /* */ /* Copyright 2002, 2003, 2004, 2005 by Roberto Alameda. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include "t42parse.h" #include "t42error.h" [...1099 lines suppressed...] FT_LOCAL_DEF( void ) t42_loader_done( T42_Loader loader ) { T42_Parser parser = &loader->parser; /* finalize tables */ T1_Release_Table( &loader->encoding_table ); T1_Release_Table( &loader->charstrings ); T1_Release_Table( &loader->glyph_names ); T1_Release_Table( &loader->swap_table ); /* finalize parser */ t42_parser_done( parser ); } /* END */ --- NEW FILE: t42drivr.c --- /***************************************************************************/ /* */ /* t42drivr.c */ /* */ /* High-level Type 42 driver interface (body). */ /* */ /* Copyright 2002, 2003, 2004 by Roberto Alameda. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ /*************************************************************************/ /* */ /* This driver implements Type42 fonts as described in the */ /* Technical Note #5012 from Adobe, with these limitations: */ /* */ /* 1) CID Fonts are not currently supported. */ /* 2) Incremental fonts making use of the GlyphDirectory keyword */ /* will be loaded, but the rendering will be using the TrueType */ /* tables. */ /* 3) As for Type1 fonts, CDevProc is not supported. */ /* 4) The Metrics dictionary is not supported. */ /* 5) AFM metrics are not supported. */ /* */ /* In other words, this driver supports Type42 fonts derived from */ /* TrueType fonts in a non-CID manner, as done by usual conversion */ /* programs. */ /* */ /*************************************************************************/ #include "t42drivr.h" #include "t42objs.h" #include "t42error.h" #include FT_INTERNAL_DEBUG_H #include FT_SERVICE_XFREE86_NAME_H #include FT_SERVICE_GLYPH_DICT_H #include FT_SERVICE_POSTSCRIPT_NAME_H #include FT_SERVICE_POSTSCRIPT_INFO_H #undef FT_COMPONENT #define FT_COMPONENT trace_t42 /* * * GLYPH DICT SERVICE * */ static FT_Error t42_get_glyph_name( T42_Face face, FT_UInt glyph_index, FT_Pointer buffer, FT_UInt buffer_max ) { FT_String* gname; gname = face->type1.glyph_names[glyph_index]; if ( buffer_max > 0 ) { FT_UInt len = (FT_UInt)( ft_strlen( gname ) ); if ( len >= buffer_max ) len = buffer_max - 1; FT_MEM_COPY( buffer, gname, len ); ((FT_Byte*)buffer)[len] = 0; } return T42_Err_Ok; } static FT_UInt t42_get_name_index( T42_Face face, FT_String* glyph_name ) { FT_Int i; FT_String* gname; for ( i = 0; i < face->type1.num_glyphs; i++ ) { gname = face->type1.glyph_names[i]; if ( !ft_strcmp( glyph_name, gname ) ) return (FT_UInt)ft_atol( (const char *)face->type1.charstrings[i] ); } return 0; } static const FT_Service_GlyphDictRec t42_service_glyph_dict = { (FT_GlyphDict_GetNameFunc) t42_get_glyph_name, (FT_GlyphDict_NameIndexFunc)t42_get_name_index }; /* * * POSTSCRIPT NAME SERVICE * */ static const char* t42_get_ps_font_name( T42_Face face ) { return (const char*)face->type1.font_name; } static const FT_Service_PsFontNameRec t42_service_ps_font_name = { (FT_PsName_GetFunc)t42_get_ps_font_name }; /* * * POSTSCRIPT INFO SERVICE * */ static FT_Error t42_ps_get_font_info( FT_Face face, PS_FontInfoRec* afont_info ) { *afont_info = ((T42_Face)face)->type1.font_info; return T42_Err_Ok; } static FT_Int t42_ps_has_glyph_names( FT_Face face ) { FT_UNUSED( face ); return 1; } static FT_Error t42_ps_get_font_private( FT_Face face, PS_PrivateRec* afont_private ) { *afont_private = ((T42_Face)face)->type1.private_dict; return T42_Err_Ok; } static const FT_Service_PsInfoRec t42_service_ps_info = { (PS_GetFontInfoFunc) t42_ps_get_font_info, (PS_HasGlyphNamesFunc) t42_ps_has_glyph_names, (PS_GetFontPrivateFunc)t42_ps_get_font_private }; /* * * SERVICE LIST * */ static const FT_ServiceDescRec t42_services[] = { { FT_SERVICE_ID_GLYPH_DICT, &t42_service_glyph_dict }, { FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &t42_service_ps_font_name }, { FT_SERVICE_ID_POSTSCRIPT_INFO, &t42_service_ps_info }, { FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_TYPE_42 }, { NULL, NULL } }; static FT_Module_Interface T42_Get_Interface( FT_Driver driver, const FT_String* t42_interface ) { FT_UNUSED( driver ); return ft_service_list_lookup( t42_services, t42_interface ); } const FT_Driver_ClassRec t42_driver_class = { { FT_MODULE_FONT_DRIVER | FT_MODULE_DRIVER_SCALABLE | #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER FT_MODULE_DRIVER_HAS_HINTER, #else 0, #endif sizeof ( T42_DriverRec ), "type42", 0x10000L, 0x20000L, 0, /* format interface */ (FT_Module_Constructor)T42_Driver_Init, (FT_Module_Destructor) T42_Driver_Done, (FT_Module_Requester) T42_Get_Interface, }, sizeof ( T42_FaceRec ), sizeof ( T42_SizeRec ), sizeof ( T42_GlyphSlotRec ), (FT_Face_InitFunc) T42_Face_Init, (FT_Face_DoneFunc) T42_Face_Done, (FT_Size_InitFunc) T42_Size_Init, (FT_Size_DoneFunc) T42_Size_Done, (FT_Slot_InitFunc) T42_GlyphSlot_Init, (FT_Slot_DoneFunc) T42_GlyphSlot_Done, (FT_Size_ResetPointsFunc) T42_Size_SetChars, (FT_Size_ResetPixelsFunc) T42_Size_SetPixels, (FT_Slot_LoadFunc) T42_GlyphSlot_Load, (FT_Face_GetKerningFunc) 0, (FT_Face_AttachFunc) 0, (FT_Face_GetAdvancesFunc) 0 }; /* END */ --- NEW FILE: type42.c --- /***************************************************************************/ /* */ /* type42.c */ /* */ /* FreeType Type 42 driver component. */ /* */ /* Copyright 2002 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #define FT_MAKE_OPTION_SINGLE_OBJECT #include <ft2build.h> #include "t42objs.c" #include "t42parse.c" #include "t42drivr.c" /* END */ |
From: Ehud S. <esh...@us...> - 2006-04-21 16:22:40
|
Update of /cvsroot/roadmap/roadmap_editor/src/freetype/src/type1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22848/src/type1 Added Files: t1afm.c t1driver.c t1gload.c t1load.c t1objs.c t1parse.c type1.c Log Message: Import freetype sources. --- NEW FILE: t1driver.c --- /***************************************************************************/ /* */ /* t1driver.c */ /* */ /* Type 1 driver interface (body). */ /* */ /* Copyright 1996-2001, 2002, 2003, 2004 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include <ft2build.h> #include "t1driver.h" #include "t1gload.h" #include "t1load.h" #include "t1errors.h" #ifndef T1_CONFIG_OPTION_NO_AFM #include "t1afm.h" #endif #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_STREAM_H #include FT_SERVICE_MULTIPLE_MASTERS_H #include FT_SERVICE_GLYPH_DICT_H #include FT_SERVICE_XFREE86_NAME_H #include FT_SERVICE_POSTSCRIPT_NAME_H #include FT_SERVICE_POSTSCRIPT_CMAPS_H #include FT_SERVICE_POSTSCRIPT_INFO_H /*************************************************************************/ /* */ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ /* messages during execution. */ /* */ #undef FT_COMPONENT #define FT_COMPONENT trace_t1driver /* * GLYPH DICT SERVICE * */ static FT_Error t1_get_glyph_name( T1_Face face, FT_UInt glyph_index, FT_Pointer buffer, FT_UInt buffer_max ) { FT_String* gname; gname = face->type1.glyph_names[glyph_index]; if ( buffer_max > 0 ) { FT_UInt len = (FT_UInt)( ft_strlen( gname ) ); if (len >= buffer_max) len = buffer_max - 1; FT_MEM_COPY( buffer, gname, len ); ((FT_Byte*)buffer)[len] = 0; } return T1_Err_Ok; } static FT_UInt t1_get_name_index( T1_Face face, FT_String* glyph_name ) { FT_Int i; FT_String* gname; for ( i = 0; i < face->type1.num_glyphs; i++ ) { gname = face->type1.glyph_names[i]; if ( !ft_strcmp( glyph_name, gname ) ) return (FT_UInt)i; } return 0; } static const FT_Service_GlyphDictRec t1_service_glyph_dict = { (FT_GlyphDict_GetNameFunc) t1_get_glyph_name, (FT_GlyphDict_NameIndexFunc)t1_get_name_index }; /* * POSTSCRIPT NAME SERVICE * */ static const char* t1_get_ps_name( T1_Face face ) { return (const char*) face->type1.font_name; } static const FT_Service_PsFontNameRec t1_service_ps_name = { (FT_PsName_GetFunc)t1_get_ps_name }; /* * MULTIPLE MASTERS SERVICE * */ #ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT static const FT_Service_MultiMastersRec t1_service_multi_masters = { (FT_Get_MM_Func) T1_Get_Multi_Master, (FT_Set_MM_Design_Func) T1_Set_MM_Design, (FT_Set_MM_Blend_Func) T1_Set_MM_Blend, (FT_Get_MM_Var_Func) T1_Get_MM_Var, (FT_Set_Var_Design_Func)T1_Set_Var_Design }; #endif /* * POSTSCRIPT INFO SERVICE * */ static FT_Error t1_ps_get_font_info( FT_Face face, PS_FontInfoRec* afont_info ) { *afont_info = ((T1_Face)face)->type1.font_info; return 0; } static FT_Int t1_ps_has_glyph_names( FT_Face face ) { FT_UNUSED( face ); return 1; } static FT_Error t1_ps_get_font_private( FT_Face face, PS_PrivateRec* afont_private ) { *afont_private = ((T1_Face)face)->type1.private_dict; return 0; } static const FT_Service_PsInfoRec t1_service_ps_info = { (PS_GetFontInfoFunc) t1_ps_get_font_info, (PS_HasGlyphNamesFunc) t1_ps_has_glyph_names, (PS_GetFontPrivateFunc)t1_ps_get_font_private, }; /* * SERVICE LIST * */ static const FT_ServiceDescRec t1_services[] = { { FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &t1_service_ps_name }, { FT_SERVICE_ID_GLYPH_DICT, &t1_service_glyph_dict }, { FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_TYPE_1 }, { FT_SERVICE_ID_POSTSCRIPT_INFO, &t1_service_ps_info }, #ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT { FT_SERVICE_ID_MULTI_MASTERS, &t1_service_multi_masters }, #endif { NULL, NULL } }; static FT_Module_Interface Get_Interface( FT_Driver driver, const FT_String* t1_interface ) { FT_UNUSED( driver ); return ft_service_list_lookup( t1_services, t1_interface ); } #ifndef T1_CONFIG_OPTION_NO_AFM /*************************************************************************/ /* */ /* <Function> */ /* Get_Kerning */ /* */ /* <Description> */ /* A driver method used to return the kerning vector between two */ /* glyphs of the same face. */ /* */ /* <Input> */ /* face :: A handle to the source face object. */ /* */ /* left_glyph :: The index of the left glyph in the kern pair. */ /* */ /* right_glyph :: The index of the right glyph in the kern pair. */ /* */ /* <Output> */ /* kerning :: The kerning vector. This is in font units for */ /* scalable formats, and in pixels for fixed-sizes */ /* formats. */ /* */ /* <Return> */ /* FreeType error code. 0 means success. */ /* */ /* <Note> */ /* Only horizontal layouts (left-to-right & right-to-left) are */ /* supported by this function. Other layouts, or more sophisticated */ /* kernings are out of scope of this method (the basic driver */ /* interface is meant to be simple). */ /* */ /* They can be implemented by format-specific interfaces. */ /* */ static FT_Error Get_Kerning( T1_Face face, FT_UInt left_glyph, FT_UInt right_glyph, FT_Vector* kerning ) { T1_AFM* afm; kerning->x = 0; kerning->y = 0; afm = (T1_AFM*)face->afm_data; if ( afm ) T1_Get_Kerning( afm, left_glyph, right_glyph, kerning ); return T1_Err_Ok; } #endif /* T1_CONFIG_OPTION_NO_AFM */ FT_CALLBACK_TABLE_DEF const FT_Driver_ClassRec t1_driver_class = { { FT_MODULE_FONT_DRIVER | FT_MODULE_DRIVER_SCALABLE | FT_MODULE_DRIVER_HAS_HINTER, sizeof( FT_DriverRec ), "type1", 0x10000L, 0x20000L, 0, /* format interface */ (FT_Module_Constructor)T1_Driver_Init, (FT_Module_Destructor) T1_Driver_Done, (FT_Module_Requester) Get_Interface, }, sizeof( T1_FaceRec ), sizeof( T1_SizeRec ), sizeof( T1_GlyphSlotRec ), (FT_Face_InitFunc) T1_Face_Init, (FT_Face_DoneFunc) T1_Face_Done, (FT_Size_InitFunc) T1_Size_Init, (FT_Size_DoneFunc) T1_Size_Done, (FT_Slot_InitFunc) T1_GlyphSlot_Init, (FT_Slot_DoneFunc) T1_GlyphSlot_Done, (FT_Size_ResetPointsFunc) T1_Size_Reset, (FT_Size_ResetPixelsFunc) T1_Size_Reset, (FT_Slot_LoadFunc) T1_Load_Glyph, #ifdef T1_CONFIG_OPTION_NO_AFM (FT_Face_GetKerningFunc) 0, (FT_Face_AttachFunc) 0, #else (FT_Face_GetKerningFunc) Get_Kerning, (FT_Face_AttachFunc) T1_Read_Metrics, #endif (FT_Face_GetAdvancesFunc) 0 }; /* END */ --- NEW FILE: t1load.c --- /***************************************************************************/ /* */ /* t1load.c */ /* */ /* Type 1 font loader (body). */ /* */ /* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ /*************************************************************************/ [...2082 lines suppressed...] */ if ( min_char > max_char ) { min_char = 0; max_char = loader.encoding_table.max_elems; } type1->encoding.code_first = min_char; type1->encoding.code_last = max_char; type1->encoding.num_chars = loader.num_chars; } Exit: t1_done_loader( &loader ); return error; } /* END */ --- NEW FILE: type1.c --- /***************************************************************************/ /* */ /* type1.c */ /* */ /* FreeType Type 1 driver component (body only). */ /* */ /* Copyright 1996-2001 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #define FT_MAKE_OPTION_SINGLE_OBJECT #include <ft2build.h> #include "t1parse.c" #include "t1load.c" #include "t1objs.c" #include "t1driver.c" #include "t1gload.c" #ifndef T1_CONFIG_OPTION_NO_AFM #include "t1afm.c" #endif /* END */ --- NEW FILE: t1gload.c --- /***************************************************************************/ /* */ /* t1gload.c */ /* */ /* Type 1 Glyph Loader (body). */ /* */ /* Copyright 1996-2001, 2002, 2003, 2004 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include <ft2build.h> #include "t1gload.h" #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_STREAM_H #include FT_OUTLINE_H #include FT_INTERNAL_POSTSCRIPT_AUX_H #include "t1errors.h" /*************************************************************************/ /* */ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ /* messages during execution. */ /* */ #undef FT_COMPONENT #define FT_COMPONENT trace_t1gload /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ /********** *********/ /********** COMPUTE THE MAXIMUM ADVANCE WIDTH *********/ /********** *********/ /********** The following code is in charge of computing *********/ /********** the maximum advance width of the font. It *********/ /********** quickly processes each glyph charstring to *********/ /********** extract the value from either a `sbw' or `seac' *********/ /********** operator. *********/ /********** *********/ /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ FT_LOCAL_DEF( FT_Error ) T1_Parse_Glyph_And_Get_Char_String( T1_Decoder decoder, FT_UInt glyph_index, FT_Data* char_string ) { T1_Face face = (T1_Face)decoder->builder.face; T1_Font type1 = &face->type1; FT_Error error = T1_Err_Ok; decoder->font_matrix = type1->font_matrix; decoder->font_offset = type1->font_offset; #ifdef FT_CONFIG_OPTION_INCREMENTAL /* For incremental fonts get the character data using the */ /* callback function. */ if ( face->root.internal->incremental_interface ) error = face->root.internal->incremental_interface->funcs->get_glyph_data( face->root.internal->incremental_interface->object, glyph_index, char_string ); else #endif /* FT_CONFIG_OPTION_INCREMENTAL */ /* For ordinary fonts get the character data stored in the face record. */ { char_string->pointer = type1->charstrings[glyph_index]; char_string->length = (FT_Int)type1->charstrings_len[glyph_index]; } if ( !error ) error = decoder->funcs.parse_charstrings( decoder, (FT_Byte*)char_string->pointer, char_string->length ); #ifdef FT_CONFIG_OPTION_INCREMENTAL /* Incremental fonts can optionally override the metrics. */ if ( !error && face->root.internal->incremental_interface && face->root.internal->incremental_interface->funcs->get_glyph_metrics ) { FT_Incremental_MetricsRec metrics; metrics.bearing_x = decoder->builder.left_bearing.x; metrics.bearing_y = decoder->builder.left_bearing.y; metrics.advance = decoder->builder.advance.x; error = face->root.internal->incremental_interface->funcs->get_glyph_metrics( face->root.internal->incremental_interface->object, glyph_index, FALSE, &metrics ); decoder->builder.left_bearing.x = metrics.bearing_x; decoder->builder.left_bearing.y = metrics.bearing_y; decoder->builder.advance.x = metrics.advance; decoder->builder.advance.y = 0; } #endif /* FT_CONFIG_OPTION_INCREMENTAL */ return error; } FT_CALLBACK_DEF( FT_Error ) T1_Parse_Glyph( T1_Decoder decoder, FT_UInt glyph_index ) { FT_Data glyph_data; FT_Error error = T1_Parse_Glyph_And_Get_Char_String( decoder, glyph_index, &glyph_data ); #ifdef FT_CONFIG_OPTION_INCREMENTAL if ( !error ) { T1_Face face = (T1_Face)decoder->builder.face; if ( face->root.internal->incremental_interface ) face->root.internal->incremental_interface->funcs->free_glyph_data( face->root.internal->incremental_interface->object, &glyph_data ); } #endif /* FT_CONFIG_OPTION_INCREMENTAL */ return error; } FT_LOCAL_DEF( FT_Error ) T1_Compute_Max_Advance( T1_Face face, FT_Pos* max_advance ) { FT_Error error; T1_DecoderRec decoder; FT_Int glyph_index; T1_Font type1 = &face->type1; PSAux_Service psaux = (PSAux_Service)face->psaux; *max_advance = 0; /* initialize load decoder */ error = psaux->t1_decoder_funcs->init( &decoder, (FT_Face)face, 0, /* size */ 0, /* glyph slot */ (FT_Byte**)type1->glyph_names, face->blend, 0, FT_RENDER_MODE_NORMAL, T1_Parse_Glyph ); if ( error ) return error; decoder.builder.metrics_only = 1; decoder.builder.load_points = 0; decoder.num_subrs = type1->num_subrs; decoder.subrs = type1->subrs; decoder.subrs_len = type1->subrs_len; *max_advance = 0; /* for each glyph, parse the glyph charstring and extract */ /* the advance width */ for ( glyph_index = 0; glyph_index < type1->num_glyphs; glyph_index++ ) { /* now get load the unscaled outline */ error = T1_Parse_Glyph( &decoder, glyph_index ); if ( glyph_index == 0 || decoder.builder.advance.x > *max_advance ) *max_advance = decoder.builder.advance.x; /* ignore the error if one occurred - skip to next glyph */ } return T1_Err_Ok; } /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ /********** *********/ /********** UNHINTED GLYPH LOADER *********/ /********** *********/ /********** The following code is in charge of loading a *********/ /********** single outline. It completely ignores hinting *********/ /********** and is used when FT_LOAD_NO_HINTING is set. *********/ /********** *********/ /********** The Type 1 hinter is located in `t1hint.c' *********/ /********** *********/ /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ FT_LOCAL_DEF( FT_Error ) T1_Load_Glyph( T1_GlyphSlot glyph, T1_Size size, FT_UInt glyph_index, FT_Int32 load_flags ) { FT_Error error; T1_DecoderRec decoder; T1_Face face = (T1_Face)glyph->root.face; FT_Bool hinting; T1_Font type1 = &face->type1; PSAux_Service psaux = (PSAux_Service)face->psaux; const T1_Decoder_Funcs decoder_funcs = psaux->t1_decoder_funcs; FT_Matrix font_matrix; FT_Vector font_offset; FT_Data glyph_data; #ifdef FT_CONFIG_OPTION_INCREMENTAL FT_Bool glyph_data_loaded = 0; #endif if ( load_flags & FT_LOAD_NO_RECURSE ) load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING; glyph->x_scale = size->root.metrics.x_scale; glyph->y_scale = size->root.metrics.y_scale; glyph->root.outline.n_points = 0; glyph->root.outline.n_contours = 0; hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 && ( load_flags & FT_LOAD_NO_HINTING ) == 0 ); glyph->root.format = FT_GLYPH_FORMAT_OUTLINE; error = decoder_funcs->init( &decoder, (FT_Face)face, (FT_Size)size, (FT_GlyphSlot)glyph, (FT_Byte**)type1->glyph_names, face->blend, FT_BOOL( hinting ), FT_LOAD_TARGET_MODE( load_flags ), T1_Parse_Glyph ); if ( error ) goto Exit; decoder.builder.no_recurse = FT_BOOL( ( load_flags & FT_LOAD_NO_RECURSE ) != 0 ); decoder.num_subrs = type1->num_subrs; decoder.subrs = type1->subrs; decoder.subrs_len = type1->subrs_len; /* now load the unscaled outline */ error = T1_Parse_Glyph_And_Get_Char_String( &decoder, glyph_index, &glyph_data ); if ( error ) goto Exit; #ifdef FT_CONFIG_OPTION_INCREMENTAL glyph_data_loaded = 1; #endif font_matrix = decoder.font_matrix; font_offset = decoder.font_offset; /* save new glyph tables */ decoder_funcs->done( &decoder ); /* now, set the metrics -- this is rather simple, as */ /* the left side bearing is the xMin, and the top side */ /* bearing the yMax */ if ( !error ) { glyph->root.outline.flags &= FT_OUTLINE_OWNER; glyph->root.outline.flags |= FT_OUTLINE_REVERSE_FILL; /* for composite glyphs, return only left side bearing and */ /* advance width */ if ( load_flags & FT_LOAD_NO_RECURSE ) { FT_Slot_Internal internal = glyph->root.internal; glyph->root.metrics.horiBearingX = decoder.builder.left_bearing.x; glyph->root.metrics.horiAdvance = decoder.builder.advance.x; internal->glyph_matrix = font_matrix; internal->glyph_delta = font_offset; internal->glyph_transformed = 1; } else { FT_BBox cbox; FT_Glyph_Metrics* metrics = &glyph->root.metrics; FT_Vector advance; /* copy the _unscaled_ advance width */ metrics->horiAdvance = decoder.builder.advance.x; glyph->root.linearHoriAdvance = decoder.builder.advance.x; glyph->root.internal->glyph_transformed = 0; /* make up vertical metrics */ metrics->vertBearingX = 0; metrics->vertBearingY = 0; metrics->vertAdvance = 0; glyph->root.linearVertAdvance = 0; glyph->root.format = FT_GLYPH_FORMAT_OUTLINE; if ( size && size->root.metrics.y_ppem < 24 ) glyph->root.outline.flags |= FT_OUTLINE_HIGH_PRECISION; #if 1 /* apply the font matrix, if any */ FT_Outline_Transform( &glyph->root.outline, &font_matrix ); FT_Outline_Translate( &glyph->root.outline, font_offset.x, font_offset.y ); advance.x = metrics->horiAdvance; advance.y = 0; FT_Vector_Transform( &advance, &font_matrix ); metrics->horiAdvance = advance.x + font_offset.x; advance.x = 0; advance.y = metrics->vertAdvance; FT_Vector_Transform( &advance, &font_matrix ); metrics->vertAdvance = advance.y + font_offset.y; #endif if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 ) { /* scale the outline and the metrics */ FT_Int n; FT_Outline* cur = decoder.builder.base; FT_Vector* vec = cur->points; FT_Fixed x_scale = glyph->x_scale; FT_Fixed y_scale = glyph->y_scale; /* First of all, scale the points, if we are not hinting */ if ( !hinting ) for ( n = cur->n_points; n > 0; n--, vec++ ) { vec->x = FT_MulFix( vec->x, x_scale ); vec->y = FT_MulFix( vec->y, y_scale ); } FT_Outline_Get_CBox( &glyph->root.outline, &cbox ); /* Then scale the metrics */ metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, x_scale ); metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, y_scale ); metrics->vertBearingX = FT_MulFix( metrics->vertBearingX, x_scale ); metrics->vertBearingY = FT_MulFix( metrics->vertBearingY, y_scale ); if ( hinting ) { metrics->horiAdvance = FT_PIX_ROUND( metrics->horiAdvance ); metrics->vertAdvance = FT_PIX_ROUND( metrics->vertAdvance ); metrics->vertBearingX = FT_PIX_ROUND( metrics->vertBearingX ); metrics->vertBearingY = FT_PIX_ROUND( metrics->vertBearingY ); } } /* compute the other metrics */ FT_Outline_Get_CBox( &glyph->root.outline, &cbox ); /* grid fit the bounding box if necessary */ if ( hinting ) { cbox.xMin = FT_PIX_FLOOR( cbox.xMin ); cbox.yMin = FT_PIX_FLOOR( cbox.yMin ); cbox.xMax = FT_PIX_CEIL( cbox.xMax ); cbox.yMax = FT_PIX_CEIL( cbox.yMax ); } metrics->width = cbox.xMax - cbox.xMin; metrics->height = cbox.yMax - cbox.yMin; metrics->horiBearingX = cbox.xMin; metrics->horiBearingY = cbox.yMax; } /* Set control data to the glyph charstrings. Note that this is */ /* _not_ zero-terminated. */ glyph->root.control_data = (FT_Byte*)glyph_data.pointer; glyph->root.control_len = glyph_data.length; } Exit: #ifdef FT_CONFIG_OPTION_INCREMENTAL if ( glyph_data_loaded && face->root.internal->incremental_interface ) { face->root.internal->incremental_interface->funcs->free_glyph_data( face->root.internal->incremental_interface->object, &glyph_data ); /* Set the control data to null - it is no longer available if */ /* loaded incrementally. */ glyph->root.control_data = 0; glyph->root.control_len = 0; } #endif return error; } /* END */ --- NEW FILE: t1objs.c --- /***************************************************************************/ /* */ /* t1objs.c */ /* */ /* Type 1 objects manager (body). */ /* */ /* Copyright 1996-2001, 2002, 2003, 2004 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include <ft2build.h> #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_STREAM_H #include FT_TRUETYPE_IDS_H #include "t1gload.h" #include "t1load.h" #include "t1errors.h" #ifndef T1_CONFIG_OPTION_NO_AFM #include "t1afm.h" #endif #include FT_SERVICE_POSTSCRIPT_CMAPS_H #include FT_INTERNAL_POSTSCRIPT_AUX_H /*************************************************************************/ /* */ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ /* messages during execution. */ /* */ #undef FT_COMPONENT #define FT_COMPONENT trace_t1objs /*************************************************************************/ /* */ /* SIZE FUNCTIONS */ /* */ /* note that we store the global hints in the size's "internal" root */ /* field */ /* */ /*************************************************************************/ static PSH_Globals_Funcs T1_Size_Get_Globals_Funcs( T1_Size size ) { T1_Face face = (T1_Face)size->root.face; PSHinter_Service pshinter = (PSHinter_Service)face->pshinter; FT_Module module; module = FT_Get_Module( size->root.face->driver->root.library, "pshinter" ); return ( module && pshinter && pshinter->get_globals_funcs ) ? pshinter->get_globals_funcs( module ) : 0 ; } FT_LOCAL_DEF( void ) T1_Size_Done( T1_Size size ) { if ( size->root.internal ) { PSH_Globals_Funcs funcs; funcs = T1_Size_Get_Globals_Funcs( size ); if ( funcs ) funcs->destroy( (PSH_Globals)size->root.internal ); size->root.internal = 0; } } FT_LOCAL_DEF( FT_Error ) T1_Size_Init( T1_Size size ) { FT_Error error = 0; PSH_Globals_Funcs funcs = T1_Size_Get_Globals_Funcs( size ); if ( funcs ) { PSH_Globals globals; T1_Face face = (T1_Face)size->root.face; error = funcs->create( size->root.face->memory, &face->type1.private_dict, &globals ); if ( !error ) size->root.internal = (FT_Size_Internal)(void*)globals; } return error; } FT_LOCAL_DEF( FT_Error ) T1_Size_Reset( T1_Size size ) { PSH_Globals_Funcs funcs = T1_Size_Get_Globals_Funcs( size ); FT_Error error = 0; if ( funcs ) error = funcs->set_scale( (PSH_Globals)size->root.internal, size->root.metrics.x_scale, size->root.metrics.y_scale, 0, 0 ); return error; } /*************************************************************************/ /* */ /* SLOT FUNCTIONS */ /* */ /*************************************************************************/ FT_LOCAL_DEF( void ) T1_GlyphSlot_Done( T1_GlyphSlot slot ) { slot->root.internal->glyph_hints = 0; } FT_LOCAL_DEF( FT_Error ) T1_GlyphSlot_Init( T1_GlyphSlot slot ) { T1_Face face; PSHinter_Service pshinter; face = (T1_Face)slot->root.face; pshinter = (PSHinter_Service)face->pshinter; if ( pshinter ) { FT_Module module; module = FT_Get_Module( slot->root.face->driver->root.library, "pshinter" ); if (module) { T1_Hints_Funcs funcs; funcs = pshinter->get_t1_funcs( module ); slot->root.internal->glyph_hints = (void*)funcs; } } return 0; } /*************************************************************************/ /* */ /* FACE FUNCTIONS */ /* */ /*************************************************************************/ /*************************************************************************/ /* */ /* <Function> */ /* T1_Face_Done */ /* */ /* <Description> */ /* The face object destructor. */ /* */ /* <Input> */ /* face :: A typeless pointer to the face object to destroy. */ /* */ FT_LOCAL_DEF( void ) T1_Face_Done( T1_Face face ) { FT_Memory memory; T1_Font type1 = &face->type1; if ( face ) { memory = face->root.memory; #ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT /* release multiple masters information */ T1_Done_Blend( face ); face->blend = 0; #endif /* release font info strings */ { PS_FontInfo info = &type1->font_info; FT_FREE( info->version ); FT_FREE( info->notice ); FT_FREE( info->full_name ); FT_FREE( info->family_name ); FT_FREE( info->weight ); } /* release top dictionary */ FT_FREE( type1->charstrings_len ); FT_FREE( type1->charstrings ); FT_FREE( type1->glyph_names ); FT_FREE( type1->subrs ); FT_FREE( type1->subrs_len ); FT_FREE( type1->subrs_block ); FT_FREE( type1->charstrings_block ); FT_FREE( type1->glyph_names_block ); FT_FREE( type1->encoding.char_index ); FT_FREE( type1->encoding.char_name ); FT_FREE( type1->font_name ); #ifndef T1_CONFIG_OPTION_NO_AFM /* release afm data if present */ if ( face->afm_data ) T1_Done_Metrics( memory, (T1_AFM*)face->afm_data ); #endif /* release unicode map, if any */ FT_FREE( face->unicode_map.maps ); face->unicode_map.num_maps = 0; face->root.family_name = 0; face->root.style_name = 0; } } /*************************************************************************/ /* */ /* <Function> */ /* T1_Face_Init */ /* */ /* <Description> */ /* The face object constructor. */ /* */ /* <Input> */ /* stream :: input stream where to load font data. */ /* */ /* face_index :: The index of the font face in the resource. */ /* */ /* num_params :: Number of additional generic parameters. Ignored. */ /* */ /* params :: Additional generic parameters. Ignored. */ /* */ /* <InOut> */ /* face :: The face record to build. */ /* */ /* <Return> */ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) T1_Face_Init( FT_Stream stream, T1_Face face, FT_Int face_index, FT_Int num_params, FT_Parameter* params ) { FT_Error error; FT_Service_PsCMaps psnames; PSAux_Service psaux; T1_Font type1 = &face->type1; PS_FontInfo info = &type1->font_info; FT_UNUSED( num_params ); FT_UNUSED( params ); FT_UNUSED( face_index ); FT_UNUSED( stream ); face->root.num_faces = 1; FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS ); face->psnames = psnames; face->psaux = FT_Get_Module_Interface( FT_FACE_LIBRARY( face ), "psaux" ); psaux = (PSAux_Service)face->psaux; face->pshinter = FT_Get_Module_Interface( FT_FACE_LIBRARY( face ), "pshinter" ); /* open the tokenizer; this will also check the font format */ error = T1_Open_Face( face ); if ( error ) goto Exit; /* if we just wanted to check the format, leave successfully now */ if ( face_index < 0 ) goto Exit; /* check the face index */ if ( face_index != 0 ) { FT_ERROR(( "T1_Face_Init: invalid face index\n" )); error = T1_Err_Invalid_Argument; goto Exit; } /* now load the font program into the face object */ /* initialize the face object fields */ /* set up root face fields */ { FT_Face root = (FT_Face)&face->root; root->num_glyphs = type1->num_glyphs; root->face_index = face_index; root->face_flags = FT_FACE_FLAG_SCALABLE; root->face_flags |= FT_FACE_FLAG_HORIZONTAL; root->face_flags |= FT_FACE_FLAG_GLYPH_NAMES; if ( info->is_fixed_pitch ) root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH; if ( face->blend ) root->face_flags |= FT_FACE_FLAG_MULTIPLE_MASTERS; /* XXX: TODO -- add kerning with .afm support */ /* get style name -- be careful, some broken fonts only */ /* have a `/FontName' dictionary entry! */ root->family_name = info->family_name; /* assume "Regular" style if we don't know better */ root->style_name = (char *)"Regular"; if ( root->family_name ) { char* full = info->full_name; char* family = root->family_name; if ( full ) { while ( *full ) { if ( *full == *family ) { family++; full++; } else { if ( *full == ' ' || *full == '-' ) full++; else if ( *family == ' ' || *family == '-' ) family++; else { if ( !*family ) root->style_name = full; break; } } } } } else { /* do we have a `/FontName'? */ if ( type1->font_name ) root->family_name = type1->font_name; } /* compute style flags */ root->style_flags = 0; if ( info->italic_angle ) root->style_flags |= FT_STYLE_FLAG_ITALIC; if ( info->weight ) { if ( !ft_strcmp( info->weight, "Bold" ) || !ft_strcmp( info->weight, "Black" ) ) root->style_flags |= FT_STYLE_FLAG_BOLD; } /* no embedded bitmap support */ root->num_fixed_sizes = 0; root->available_sizes = 0; root->bbox.xMin = type1->font_bbox.xMin >> 16; root->bbox.yMin = type1->font_bbox.yMin >> 16; root->bbox.xMax = ( type1->font_bbox.xMax + 0xFFFFU ) >> 16; root->bbox.yMax = ( type1->font_bbox.yMax + 0xFFFFU ) >> 16; /* Set units_per_EM if we didn't set it in parse_font_matrix. */ if ( !root->units_per_EM ) root->units_per_EM = 1000; root->ascender = (FT_Short)( root->bbox.yMax ); root->descender = (FT_Short)( root->bbox.yMin ); root->height = (FT_Short)( ( ( root->ascender - root->descender ) * 12 ) / 10 ); /* now compute the maximum advance width */ root->max_advance_width = (FT_Short)( root->bbox.xMax ); { FT_Pos max_advance; error = T1_Compute_Max_Advance( face, &max_advance ); /* in case of error, keep the standard width */ if ( !error ) root->max_advance_width = (FT_Short)max_advance; else error = 0; /* clear error */ } root->max_advance_height = root->height; root->underline_position = (FT_Short)info->underline_position; root->underline_thickness = (FT_Short)info->underline_thickness; root->internal->max_points = 0; root->internal->max_contours = 0; } { FT_Face root = &face->root; if ( psnames && psaux ) { FT_CharMapRec charmap; T1_CMap_Classes cmap_classes = psaux->t1_cmap_classes; FT_CMap_Class clazz; charmap.face = root; /* first of all, try to synthetize a Unicode charmap */ charmap.platform_id = 3; charmap.encoding_id = 1; charmap.encoding = FT_ENCODING_UNICODE; FT_CMap_New( cmap_classes->unicode, NULL, &charmap, NULL ); /* now, generate an Adobe Standard encoding when appropriate */ charmap.platform_id = 7; clazz = NULL; switch ( type1->encoding_type ) { case T1_ENCODING_TYPE_STANDARD: charmap.encoding = FT_ENCODING_ADOBE_STANDARD; charmap.encoding_id = TT_ADOBE_ID_STANDARD; clazz = cmap_classes->standard; break; case T1_ENCODING_TYPE_EXPERT: charmap.encoding = FT_ENCODING_ADOBE_EXPERT; charmap.encoding_id = TT_ADOBE_ID_EXPERT; clazz = cmap_classes->expert; break; case T1_ENCODING_TYPE_ARRAY: charmap.encoding = FT_ENCODING_ADOBE_CUSTOM; charmap.encoding_id = TT_ADOBE_ID_CUSTOM; clazz = cmap_classes->custom; break; case T1_ENCODING_TYPE_ISOLATIN1: charmap.encoding = FT_ENCODING_ADOBE_LATIN_1; charmap.encoding_id = TT_ADOBE_ID_LATIN_1; clazz = cmap_classes->unicode; break; default: ; } if ( clazz ) FT_CMap_New( clazz, NULL, &charmap, NULL ); #if 0 /* Select default charmap */ if (root->num_charmaps) root->charmap = root->charmaps[0]; #endif } } Exit: return error; } /*************************************************************************/ /* */ /* <Function> */ /* T1_Driver_Init */ /* */ /* <Description> */ /* Initializes a given Type 1 driver object. */ /* */ /* <Input> */ /* driver :: A handle to the target driver object. */ /* */ /* <Return> */ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF( FT_Error ) T1_Driver_Init( T1_Driver driver ) { FT_UNUSED( driver ); return T1_Err_Ok; } /*************************************************************************/ /* */ /* <Function> */ /* T1_Driver_Done */ /* */ /* <Description> */ /* Finalizes a given Type 1 driver. */ /* */ /* <Input> */ /* driver :: A handle to the target Type 1 driver. */ /* */ FT_LOCAL_DEF( void ) T1_Driver_Done( T1_Driver driver ) { FT_UNUSED( driver ); } /* END */ --- NEW FILE: t1afm.c --- /***************************************************************************/ /* */ /* t1afm.c */ /* */ /* AFM support for Type 1 fonts (body). */ /* */ /* Copyright 1996-2001, 2002, 2003, 2004 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include <ft2build.h> #include "t1afm.h" #include "t1errors.h" #include FT_INTERNAL_STREAM_H #include FT_INTERNAL_TYPE1_TYPES_H /*************************************************************************/ /* */ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ /* messages during execution. */ /* */ #undef FT_COMPONENT #define FT_COMPONENT trace_t1afm FT_LOCAL_DEF( void ) T1_Done_Metrics( FT_Memory memory, T1_AFM* afm ) { FT_FREE( afm->kern_pairs ); afm->num_pairs = 0; FT_FREE( afm ); } #undef IS_KERN_PAIR #define IS_KERN_PAIR( p ) ( p[0] == 'K' && p[1] == 'P' ) #define IS_ALPHANUM( c ) ( ft_isalnum( c ) || \ c == '_' || \ c == '.' ) /* read a glyph name and return the equivalent glyph index */ static FT_UInt afm_atoindex( FT_Byte** start, FT_Byte* limit, T1_Font type1 ) { FT_Byte* p = *start; FT_PtrDist len; FT_UInt result = 0; char temp[64]; /* skip whitespace */ while ( p < limit && ( *p == ' ' || *p == '\t' || *p == ':' || *p == ';' ) ) p++; *start = p; /* now, read glyph name */ while ( p < limit && IS_ALPHANUM( *p ) ) p++; len = p - *start; if ( len > 0 && len < 64 ) { FT_Int n; /* copy glyph name to intermediate array */ FT_MEM_COPY( temp, *start, len ); temp[len] = 0; /* lookup glyph name in face array */ for ( n = 0; n < type1->num_glyphs; n++ ) { char* gname = (char*)type1->glyph_names[n]; if ( gname && gname[0] == temp[0] && ft_strcmp( gname, temp ) == 0 ) { result = n; break; } } } *start = p; return result; } /* read an integer */ static int afm_atoi( FT_Byte** start, FT_Byte* limit ) { FT_Byte* p = *start; int sum = 0; int sign = 1; /* skip everything that is not a number */ while ( p < limit && !isdigit( *p ) ) { sign = 1; if ( *p == '-' ) sign = -1; p++; } while ( p < limit && isdigit( *p ) ) { sum = sum * 10 + ( *p - '0' ); p++; } *start = p; return sum * sign; } #undef KERN_INDEX #define KERN_INDEX( g1, g2 ) ( ( (FT_ULong)g1 << 16 ) | g2 ) /* compare two kerning pairs */ FT_CALLBACK_DEF( int ) compare_kern_pairs( const void* a, const void* b ) { T1_Kern_Pair* pair1 = (T1_Kern_Pair*)a; T1_Kern_Pair* pair2 = (T1_Kern_Pair*)b; FT_ULong index1 = KERN_INDEX( pair1->glyph1, pair1->glyph2 ); FT_ULong index2 = KERN_INDEX( pair2->glyph1, pair2->glyph2 ); return (int)( index1 - index2 ); } /* parse an AFM file -- for now, only read the kerning pairs */ static FT_Error T1_Read_AFM( FT_Face t1_face, FT_Stream stream ) { FT_Error error = T1_Err_Ok; FT_Memory memory = stream->memory; FT_Byte* start; FT_Byte* limit; FT_Byte* p; FT_Int count = 0; T1_Kern_Pair* pair; T1_Font type1 = &((T1_Face)t1_face)->type1; T1_AFM* afm = 0; start = (FT_Byte*)stream->cursor; limit = (FT_Byte*)stream->limit; p = start; /* we are now going to count the occurences of `KP' or `KPX' in */ /* the AFM file */ count = 0; for ( p = start; p < limit - 3; p++ ) { if ( IS_KERN_PAIR( p ) ) count++; } /* Actually, kerning pairs are simply optional! */ if ( count == 0 ) goto Exit; /* allocate the pairs */ if ( FT_NEW( afm ) || FT_NEW_ARRAY( afm->kern_pairs, count ) ) goto Exit; /* now, read each kern pair */ pair = afm->kern_pairs; afm->num_pairs = count; /* save in face object */ ((T1_Face)t1_face)->afm_data = afm; t1_face->face_flags |= FT_FACE_FLAG_KERNING; for ( p = start; p < limit - 3; p++ ) { if ( IS_KERN_PAIR( p ) ) { FT_Byte* q; /* skip keyword (KP or KPX) */ q = p + 2; if ( *q == 'X' ) q++; pair->glyph1 = afm_atoindex( &q, limit, type1 ); pair->glyph2 = afm_atoindex( &q, limit, type1 ); pair->kerning.x = afm_atoi( &q, limit ); pair->kerning.y = 0; if ( p[2] != 'X' ) pair->kerning.y = afm_atoi( &q, limit ); pair++; } } /* now, sort the kern pairs according to their glyph indices */ ft_qsort( afm->kern_pairs, count, sizeof ( T1_Kern_Pair ), compare_kern_pairs ); Exit: if ( error ) FT_FREE( afm ); return error; } #define LITTLE_ENDIAN_USHORT( p ) (FT_UShort)( ( (p)[0] ) | \ ( (p)[1] << 8 ) ) #define LITTLE_ENDIAN_UINT( p ) (FT_UInt)( ( (p)[0] ) | \ ( (p)[1] << 8 ) | \ ( (p)[2] << 16 ) | \ ( (p)[3] << 24 ) ) /* parse a PFM file -- for now, only read the kerning pairs */ static FT_Error T1_Read_PFM( FT_Face t1_face, FT_Stream stream ) { FT_Error error = T1_Err_Ok; FT_Memory memory = stream->memory; FT_Byte* start; FT_Byte* limit; FT_Byte* p; FT_Int kern_count = 0; T1_Kern_Pair* pair; T1_AFM* afm = 0; FT_Int width_table_length; FT_CharMap oldcharmap; FT_CharMap charmap; FT_Int n; start = (FT_Byte*)stream->cursor; limit = (FT_Byte*)stream->limit; p = start; /* Figure out how long the width table is. */ /* This info is a little-endian short at offset 99. */ p = start + 99; if ( p + 2 > limit ) { error = T1_Err_Unknown_File_Format; goto Exit; } width_table_length = LITTLE_ENDIAN_USHORT( p ); p += 18 + width_table_length; if ( p + 0x12 > limit || LITTLE_ENDIAN_USHORT( p ) < 0x12 ) /* extension table is probably optional */ goto Exit; /* Kerning offset is 14 bytes from start of extensions table. */ p += 14; p = start + LITTLE_ENDIAN_UINT( p ); if ( p + 2 > limit ) { error = T1_Err_Unknown_File_Format; goto Exit; } kern_count = LITTLE_ENDIAN_USHORT( p ); p += 2; if ( p + 4 * kern_count > limit ) { error = T1_Err_Unknown_File_Format; goto Exit; } /* Actually, kerning pairs are simply optional! */ if ( kern_count == 0 ) goto Exit; /* allocate the pairs */ if ( FT_NEW( afm ) || FT_NEW_ARRAY( afm->kern_pairs, kern_count ) ) goto Exit; /* save in face object */ ((T1_Face)t1_face)->afm_data = afm; t1_face->face_flags |= FT_FACE_FLAG_KERNING; /* now, read each kern pair */ pair = afm->kern_pairs; afm->num_pairs = kern_count; limit = p + 4 * kern_count; /* PFM kerning data are stored by encoding rather than glyph index, */ /* so find the PostScript charmap of this font and install it */ /* temporarily. If we find no PostScript charmap, then just use */ /* the default and hope it is the right one. */ oldcharmap = t1_face->charmap; charmap = NULL; for ( n = 0; n < t1_face->num_charmaps; n++ ) { charmap = t1_face->charmaps[n]; /* check against PostScript pseudo platform */ if ( charmap->platform_id == 7 ) { error = FT_Set_Charmap( t1_face, charmap ); if ( error ) goto Exit; break; } } /* Kerning info is stored as: */ /* */ /* encoding of first glyph (1 byte) */ /* encoding of second glyph (1 byte) */ /* offset (little-endian short) */ for ( ; p < limit ; p+=4 ) { pair->glyph1 = FT_Get_Char_Index( t1_face, p[0] ); pair->glyph2 = FT_Get_Char_Index( t1_face, p[1] ); pair->kerning.x = (FT_Short)LITTLE_ENDIAN_USHORT(p + 2); pair->kerning.y = 0; pair++; } if ( oldcharmap != NULL ) error = FT_Set_Charmap( t1_face, oldcharmap ); if ( error ) goto Exit; /* now, sort the kern pairs according to their glyph indices */ ft_qsort( afm->kern_pairs, kern_count, sizeof ( T1_Kern_Pair ), compare_kern_pairs ); Exit: if ( error ) FT_FREE( afm ); return error; } /* parse a metrics file -- either AFM or PFM depending on what */ /* it turns out to be */ FT_LOCAL_DEF( FT_Error ) T1_Read_Metrics( FT_Face t1_face, FT_Stream stream ) { FT_Error error; FT_Byte* start; if ( FT_FRAME_ENTER( stream->size ) ) return error; start = (FT_Byte*)stream->cursor; if ( stream->size >= ft_strlen( "StartFontMetrics" ) && ft_strncmp( (const char*)start, "StartFontMetrics", ft_strlen( "StartFontMetrics" ) ) == 0 ) error = T1_Read_AFM( t1_face, stream ); else if ( stream->size > 6 && start[0] == 0x00 && start[1] == 0x01 && LITTLE_ENDIAN_UINT( start + 2 ) == stream->size ) error = T1_Read_PFM( t1_face, stream ); else error = T1_Err_Unknown_File_Format; FT_FRAME_EXIT(); return error; } /* find the kerning for a given glyph pair */ FT_LOCAL_DEF( void ) T1_Get_Kerning( T1_AFM* afm, FT_UInt glyph1, FT_UInt glyph2, FT_Vector* kerning ) { T1_Kern_Pair *min, *mid, *max; FT_ULong idx = KERN_INDEX( glyph1, glyph2 ); /* simple binary search */ min = afm->kern_pairs; max = min + afm->num_pairs - 1; while ( min <= max ) { FT_ULong midi; mid = min + ( max - min ) / 2; midi = KERN_INDEX( mid->glyph1, mid->glyph2 ); if ( midi == idx ) { *kerning = mid->kerning; return; } if ( midi < idx ) min = mid + 1; else max = mid - 1; } kerning->x = 0; kerning->y = 0; }... [truncated message content] |
Update of /cvsroot/roadmap/roadmap_editor/src/freetype/src/otvalid In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22848/src/otvalid Added Files: otvalid.c otvbase.c otvcommn.c otvgdef.c otvgpos.c otvgsub.c otvjstf.c otvmod.c Log Message: Import freetype sources. --- NEW FILE: otvcommn.c --- /***************************************************************************/ /* */ /* otvcommn.c */ /* */ /* OpenType common tables validation (body). */ /* */ /* Copyright 2004, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include "otvcommn.h" [...1016 lines suppressed...] /* Lookup */ lookup = table + FT_NEXT_USHORT( p ); oldp = p; /* LookupFlag */ p = lookup + 2; if ( FT_NEXT_USHORT( p ) & 0xFF00U ) return 1; p = oldp; } return 0; } /* END */ --- NEW FILE: otvbase.c --- /***************************************************************************/ /* */ /* otvbase.c */ /* */ /* OpenType BASE table validation (body). */ /* */ /* Copyright 2004 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include "otvalid.h" #include "otvcommn.h" /*************************************************************************/ /* */ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ /* messages during execution. */ /* */ #undef FT_COMPONENT #define FT_COMPONENT trace_otvbase static void otv_BaseCoord_validate( FT_Bytes table, OTV_Validator valid ) { FT_Bytes p = table; FT_UInt BaseCoordFormat; OTV_NAME_ENTER( "BaseCoord" ); OTV_LIMIT_CHECK( 4 ); BaseCoordFormat = FT_NEXT_USHORT( p ); p += 2; /* skip Coordinate */ OTV_TRACE(( " (format %d)\n", BaseCoordFormat )); switch ( BaseCoordFormat ) { case 1: /* BaseCoordFormat1 */ break; case 2: /* BaseCoordFormat2 */ OTV_LIMIT_CHECK( 4 ); /* ReferenceGlyph, BaseCoordPoint */ break; case 3: /* BaseCoordFormat3 */ OTV_LIMIT_CHECK( 2 ); /* DeviceTable */ otv_Device_validate( table + FT_NEXT_USHORT( p ), valid ); break; default: FT_INVALID_DATA; } OTV_EXIT; } static void otv_BaseTagList_validate( FT_Bytes table, OTV_Validator valid ) { FT_Bytes p = table; FT_UInt BaseTagCount; OTV_NAME_ENTER( "BaseTagList" ); OTV_LIMIT_CHECK( 2 ); BaseTagCount = FT_NEXT_USHORT( p ); OTV_TRACE(( " (BaseTagCount = %d)\n", BaseTagCount )); OTV_LIMIT_CHECK( BaseTagCount * 4 ); /* BaselineTag */ OTV_EXIT; } static void otv_BaseValues_validate( FT_Bytes table, OTV_Validator valid ) { FT_Bytes p = table; FT_UInt BaseCoordCount; OTV_NAME_ENTER( "BaseValues" ); OTV_LIMIT_CHECK( 4 ); p += 2; /* skip DefaultIndex */ BaseCoordCount = FT_NEXT_USHORT( p ); OTV_TRACE(( " (BaseCoordCount = %d)\n", BaseCoordCount )); OTV_LIMIT_CHECK( BaseCoordCount * 2 ); /* BaseCoord */ for ( ; BaseCoordCount > 0; BaseCoordCount-- ) otv_BaseCoord_validate( table + FT_NEXT_USHORT( p ), valid ); OTV_EXIT; } static void otv_MinMax_validate( FT_Bytes table, OTV_Validator valid ) { FT_Bytes p = table; FT_UInt table_size; FT_UInt FeatMinMaxCount; OTV_OPTIONAL_TABLE( MinCoord ); OTV_OPTIONAL_TABLE( MaxCoord ); OTV_NAME_ENTER( "MinMax" ); OTV_LIMIT_CHECK( 6 ); OTV_OPTIONAL_OFFSET( MinCoord ); OTV_OPTIONAL_OFFSET( MaxCoord ); FeatMinMaxCount = FT_NEXT_USHORT( p ); OTV_TRACE(( " (FeatMinMaxCount = %d)\n", FeatMinMaxCount )); table_size = FeatMinMaxCount * 8 + 6; OTV_SIZE_CHECK( MinCoord ); if ( MinCoord ) otv_BaseCoord_validate( table + MinCoord, valid ); OTV_SIZE_CHECK( MaxCoord ); if ( MaxCoord ) otv_BaseCoord_validate( table + MaxCoord, valid ); OTV_LIMIT_CHECK( FeatMinMaxCount * 8 ); /* FeatMinMaxRecord */ for ( ; FeatMinMaxCount > 0; FeatMinMaxCount-- ) { p += 4; /* skip FeatureTableTag */ OTV_OPTIONAL_OFFSET( MinCoord ); OTV_OPTIONAL_OFFSET( MaxCoord ); OTV_SIZE_CHECK( MinCoord ); if ( MinCoord ) otv_BaseCoord_validate( table + MinCoord, valid ); OTV_SIZE_CHECK( MaxCoord ); if ( MaxCoord ) otv_BaseCoord_validate( table + MaxCoord, valid ); } OTV_EXIT; } static void otv_BaseScript_validate( FT_Bytes table, OTV_Validator valid ) { FT_Bytes p = table; FT_UInt table_size; FT_UInt BaseLangSysCount; OTV_OPTIONAL_TABLE( BaseValues ); OTV_OPTIONAL_TABLE( DefaultMinMax ); OTV_NAME_ENTER( "BaseScript" ); OTV_LIMIT_CHECK( 6 ); OTV_OPTIONAL_OFFSET( BaseValues ); OTV_OPTIONAL_OFFSET( DefaultMinMax ); BaseLangSysCount = FT_NEXT_USHORT( p ); OTV_TRACE(( " (BaseLangSysCount = %d)\n", BaseLangSysCount )); table_size = BaseLangSysCount * 6 + 6; OTV_SIZE_CHECK( BaseValues ); if ( BaseValues ) otv_BaseValues_validate( table + BaseValues, valid ); OTV_SIZE_CHECK( DefaultMinMax ); if ( DefaultMinMax ) otv_MinMax_validate( table + DefaultMinMax, valid ); OTV_LIMIT_CHECK( BaseLangSysCount * 6 ); /* BaseLangSysRecord */ for ( ; BaseLangSysCount > 0; BaseLangSysCount-- ) { p += 4; /* skip BaseLangSysTag */ otv_MinMax_validate( table + FT_NEXT_USHORT( p ), valid ); } OTV_EXIT; } static void otv_BaseScriptList_validate( FT_Bytes table, OTV_Validator valid ) { FT_Bytes p = table; FT_UInt BaseScriptCount; OTV_NAME_ENTER( "BaseScriptList" ); OTV_LIMIT_CHECK( 2 ); BaseScriptCount = FT_NEXT_USHORT( p ); OTV_TRACE(( " (BaseScriptCount = %d)\n", BaseScriptCount )); OTV_LIMIT_CHECK( BaseScriptCount * 6 ); /* BaseScriptRecord */ for ( ; BaseScriptCount > 0; BaseScriptCount-- ) { p += 4; /* skip BaseScriptTag */ /* BaseScript */ otv_BaseScript_validate( table + FT_NEXT_USHORT( p ), valid ); } OTV_EXIT; } static void otv_Axis_validate( FT_Bytes table, OTV_Validator valid ) { FT_Bytes p = table; FT_UInt table_size; OTV_OPTIONAL_TABLE( BaseTagList ); OTV_NAME_ENTER( "Axis" ); OTV_LIMIT_CHECK( 4 ); OTV_OPTIONAL_OFFSET( BaseTagList ); table_size = 4; OTV_SIZE_CHECK( BaseTagList ); if ( BaseTagList ) otv_BaseTagList_validate( table + BaseTagList, valid ); /* BaseScriptList */ otv_BaseScriptList_validate( table + FT_NEXT_USHORT( p ), valid ); OTV_EXIT; } FT_LOCAL_DEF( void ) otv_BASE_validate( FT_Bytes table, FT_Validator ftvalid ) { OTV_ValidatorRec validrec; OTV_Validator valid = &validrec; FT_Bytes p = table; FT_UInt table_size; OTV_OPTIONAL_TABLE( HorizAxis ); OTV_OPTIONAL_TABLE( VertAxis ); valid->root = ftvalid; FT_TRACE3(( "validating BASE table\n" )); OTV_INIT; OTV_LIMIT_CHECK( 6 ); if ( FT_NEXT_ULONG( p ) != 0x10000UL ) /* Version */ FT_INVALID_DATA; table_size = 6; OTV_OPTIONAL_OFFSET( HorizAxis ); OTV_SIZE_CHECK( HorizAxis ); if ( HorizAxis ) otv_Axis_validate( table + HorizAxis, valid ); OTV_OPTIONAL_OFFSET( VertAxis ); OTV_SIZE_CHECK( VertAxis ); if ( VertAxis ) otv_Axis_validate( table + VertAxis, valid ); FT_TRACE4(( "\n" )); } /* END */ --- NEW FILE: otvjstf.c --- /***************************************************************************/ /* */ /* otvjstf.c */ /* */ /* OpenType JSTF table validation (body). */ /* */ /* Copyright 2004 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include "otvalid.h" #include "otvcommn.h" #include "otvgpos.h" /*************************************************************************/ /* */ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ /* messages during execution. */ /* */ #undef FT_COMPONENT #define FT_COMPONENT trace_otvjstf #define JstfPriority otv_JstfPriority_validate, "JstfPriority" #define JstfLookup otv_GPOS_subtable_validate, "" /* uses valid->extra1 (GSUB lookup count) */ /* uses valid->extra2 (GPOS lookup count) */ /* sets valid->extra1 (counter) */ static void otv_JstfPriority_validate( FT_Bytes table, OTV_Validator valid ) { FT_Bytes p = table; FT_UInt table_size; FT_UInt gsub_lookup_count, gpos_lookup_count; OTV_OPTIONAL_TABLE( ShrinkageEnableGSUB ); OTV_OPTIONAL_TABLE( ShrinkageDisableGSUB ); OTV_OPTIONAL_TABLE( ShrinkageEnableGPOS ); OTV_OPTIONAL_TABLE( ShrinkageDisableGPOS ); OTV_OPTIONAL_TABLE( ExtensionEnableGSUB ); OTV_OPTIONAL_TABLE( ExtensionDisableGSUB ); OTV_OPTIONAL_TABLE( ExtensionEnableGPOS ); OTV_OPTIONAL_TABLE( ExtensionDisableGPOS ); OTV_OPTIONAL_TABLE( ShrinkageJstfMax ); OTV_OPTIONAL_TABLE( ExtensionJstfMax ); OTV_ENTER; OTV_TRACE(( "JstfPriority table\n" )); OTV_LIMIT_CHECK( 20 ); gsub_lookup_count = valid->extra1; gpos_lookup_count = valid->extra2; table_size = 20; valid->extra1 = gsub_lookup_count; OTV_OPTIONAL_OFFSET( ShrinkageEnableGSUB ); OTV_SIZE_CHECK( ShrinkageEnableGSUB ); if ( ShrinkageEnableGSUB ) otv_x_ux( table + ShrinkageEnableGSUB, valid ); OTV_OPTIONAL_OFFSET( ShrinkageDisableGSUB ); OTV_SIZE_CHECK( ShrinkageDisableGSUB ); if ( ShrinkageDisableGSUB ) otv_x_ux( table + ShrinkageDisableGSUB, valid ); valid->extra1 = gpos_lookup_count; OTV_OPTIONAL_OFFSET( ShrinkageEnableGPOS ); OTV_SIZE_CHECK( ShrinkageEnableGPOS ); if ( ShrinkageEnableGPOS ) otv_x_ux( table + ShrinkageEnableGPOS, valid ); OTV_OPTIONAL_OFFSET( ShrinkageDisableGPOS ); OTV_SIZE_CHECK( ShrinkageDisableGPOS ); if ( ShrinkageDisableGPOS ) otv_x_ux( table + ShrinkageDisableGPOS, valid ); OTV_OPTIONAL_OFFSET( ShrinkageJstfMax ); OTV_SIZE_CHECK( ShrinkageJstfMax ); if ( ShrinkageJstfMax ) { /* XXX: check lookup types? */ OTV_NEST2( JstfMax, JstfLookup ); OTV_RUN( table + ShrinkageJstfMax, valid ); } valid->extra1 = gsub_lookup_count; OTV_OPTIONAL_OFFSET( ExtensionEnableGSUB ); OTV_SIZE_CHECK( ExtensionEnableGSUB ); if ( ExtensionEnableGSUB ) otv_x_ux( table + ExtensionEnableGSUB, valid ); OTV_OPTIONAL_OFFSET( ExtensionDisableGSUB ); OTV_SIZE_CHECK( ExtensionDisableGSUB ); if ( ExtensionDisableGSUB ) otv_x_ux( table + ExtensionDisableGSUB, valid ); valid->extra1 = gpos_lookup_count; OTV_OPTIONAL_OFFSET( ExtensionEnableGPOS ); OTV_SIZE_CHECK( ExtensionEnableGPOS ); if ( ExtensionEnableGPOS ) otv_x_ux( table + ExtensionEnableGPOS, valid ); OTV_OPTIONAL_OFFSET( ExtensionDisableGPOS ); OTV_SIZE_CHECK( ExtensionDisableGPOS ); if ( ExtensionDisableGPOS ) otv_x_ux( table + ExtensionDisableGPOS, valid ); OTV_OPTIONAL_OFFSET( ExtensionJstfMax ); OTV_SIZE_CHECK( ExtensionJstfMax ); if ( ExtensionJstfMax ) { /* XXX: check lookup types? */ OTV_NEST2( JstfMax, JstfLookup ); OTV_RUN( table + ExtensionJstfMax, valid ); } valid->extra1 = gsub_lookup_count; valid->extra2 = gpos_lookup_count; OTV_EXIT; } /* sets valid->extra (glyph count) */ /* sets valid->func1 (otv_JstfPriority_validate) */ static void otv_JstfScript_validate( FT_Bytes table, OTV_Validator valid ) { FT_Bytes p = table; FT_UInt table_size; FT_UInt JstfLangSysCount; OTV_OPTIONAL_TABLE( ExtGlyph ); OTV_OPTIONAL_TABLE( DefJstfLangSys ); OTV_NAME_ENTER( "JstfScript" ); OTV_LIMIT_CHECK( 6 ); OTV_OPTIONAL_OFFSET( ExtGlyph ); OTV_OPTIONAL_OFFSET( DefJstfLangSys ); JstfLangSysCount = FT_NEXT_USHORT( p ); OTV_TRACE(( " (JstfLangSysCount = %d)\n", JstfLangSysCount )); table_size = JstfLangSysCount * 6 + 6; OTV_SIZE_CHECK( ExtGlyph ); if ( ExtGlyph ) { valid->extra1 = valid->glyph_count; OTV_NEST1( ExtenderGlyph ); OTV_RUN( table + ExtGlyph, valid ); } OTV_SIZE_CHECK( DefJstfLangSys ); if ( DefJstfLangSys ) { OTV_NEST2( JstfLangSys, JstfPriority ); OTV_RUN( table + DefJstfLangSys, valid ); } OTV_LIMIT_CHECK( 6 * JstfLangSysCount ); /* JstfLangSysRecord */ OTV_NEST2( JstfLangSys, JstfPriority ); for ( ; JstfLangSysCount > 0; JstfLangSysCount-- ) { p += 4; /* skip JstfLangSysTag */ OTV_RUN( table + FT_NEXT_USHORT( p ), valid ); } OTV_EXIT; } /* sets valid->extra1 (GSUB lookup count) */ /* sets valid->extra2 (GPOS lookup count) */ /* sets valid->glyph_count */ FT_LOCAL_DEF( void ) otv_JSTF_validate( FT_Bytes table, FT_Bytes gsub, FT_Bytes gpos, FT_UInt glyph_count, FT_Validator ftvalid ) { OTV_ValidatorRec validrec; OTV_Validator valid = &validrec; FT_Bytes p = table; FT_UInt JstfScriptCount; valid->root = ftvalid; FT_TRACE3(( "validating JSTF table\n" )); OTV_INIT; OTV_LIMIT_CHECK( 6 ); if ( FT_NEXT_ULONG( p ) != 0x10000UL ) /* Version */ FT_INVALID_DATA; JstfScriptCount = FT_NEXT_USHORT( p ); FT_TRACE3(( " (JstfScriptCount = %d)\n", JstfScriptCount )); OTV_LIMIT_CHECK( JstfScriptCount * 6 ); if ( gsub ) valid->extra1 = otv_GSUBGPOS_get_Lookup_count( gsub ); else valid->extra1 = 0; if ( gpos ) valid->extra2 = otv_GSUBGPOS_get_Lookup_count( gpos ); else valid->extra2 = 0; valid->glyph_count = glyph_count; /* JstfScriptRecord */ for ( ; JstfScriptCount > 0; JstfScriptCount-- ) { p += 4; /* skip JstfScriptTag */ /* JstfScript */ otv_JstfScript_validate( table + FT_NEXT_USHORT( p ), valid ); } FT_TRACE4(( "\n" )); } /* END */ --- NEW FILE: otvalid.c --- /***************************************************************************/ /* */ /* otvalid.c */ /* */ /* FreeType validator for OpenType tables (body only). */ /* */ /* Copyright 2004 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #define FT_MAKE_OPTION_SINGLE_OBJECT #include <ft2build.h> #include "otvbase.c" #include "otvcommn.c" #include "otvgdef.c" #include "otvgpos.c" #include "otvgsub.c" #include "otvjstf.c" #include "otvmod.c" /* END */ --- NEW FILE: otvgsub.c --- /***************************************************************************/ /* */ /* otvgsub.c */ /* */ /* OpenType GSUB table validation (body). */ /* */ /* Copyright 2004, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include "otvalid.h" #include "otvcommn.h" /*************************************************************************/ /* */ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ /* messages during execution. */ /* */ #undef FT_COMPONENT #define FT_COMPONENT trace_otvgsub /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** GSUB LOOKUP TYPE 1 *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ /* uses valid->glyph_count */ static void otv_SingleSubst_validate( FT_Bytes table, OTV_Validator valid ) { FT_Bytes p = table; FT_UInt SubstFormat; OTV_NAME_ENTER( "SingleSubst" ); OTV_LIMIT_CHECK( 2 ); SubstFormat = FT_NEXT_USHORT( p ); OTV_TRACE(( " (format %d)\n", SubstFormat )); switch ( SubstFormat ) { case 1: /* SingleSubstFormat1 */ { FT_Bytes Coverage; FT_Int DeltaGlyphID; FT_Long idx; OTV_LIMIT_CHECK( 4 ); Coverage = table + FT_NEXT_USHORT( p ); DeltaGlyphID = FT_NEXT_SHORT( p ); otv_Coverage_validate( Coverage, valid ); idx = otv_Coverage_get_first( Coverage ) + DeltaGlyphID; if ( idx < 0 ) FT_INVALID_DATA; idx = otv_Coverage_get_last( Coverage ) + DeltaGlyphID; if ( (FT_UInt)idx >= valid->glyph_count ) FT_INVALID_DATA; } break; case 2: /* SingleSubstFormat2 */ { FT_UInt Coverage, GlyphCount; OTV_LIMIT_CHECK( 4 ); Coverage = FT_NEXT_USHORT( p ); GlyphCount = FT_NEXT_USHORT( p ); OTV_TRACE(( " (GlyphCount = %d)\n", GlyphCount )); otv_Coverage_validate( table + Coverage, valid ); OTV_LIMIT_CHECK( GlyphCount * 2 ); /* Substitute */ for ( ; GlyphCount > 0; GlyphCount-- ) if ( FT_NEXT_USHORT( p ) >= valid->glyph_count ) FT_INVALID_DATA; } break; default: FT_INVALID_DATA; } OTV_EXIT; } /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** GSUB LOOKUP TYPE 2 *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ /* sets valid->extra1 (glyph count) */ static void otv_MultipleSubst_validate( FT_Bytes table, OTV_Validator valid ) { FT_Bytes p = table; FT_UInt SubstFormat; OTV_NAME_ENTER( "MultipleSubst" ); OTV_LIMIT_CHECK( 2 ); SubstFormat = FT_NEXT_USHORT( p ); OTV_TRACE(( " (format %d)\n", SubstFormat )); switch ( SubstFormat ) { case 1: valid->extra1 = valid->glyph_count; OTV_NEST2( MultipleSubstFormat1, Sequence ); OTV_RUN( table, valid ); break; default: FT_INVALID_DATA; } OTV_EXIT; } /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** GSUB LOOKUP TYPE 3 *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ /* sets valid->extra1 (glyph count) */ static void otv_AlternateSubst_validate( FT_Bytes table, OTV_Validator valid ) { FT_Bytes p = table; FT_UInt SubstFormat; OTV_NAME_ENTER( "AlternateSubst" ); OTV_LIMIT_CHECK( 2 ); SubstFormat = FT_NEXT_USHORT( p ); OTV_TRACE(( " (format %d)\n", SubstFormat )); switch ( SubstFormat ) { case 1: valid->extra1 = valid->glyph_count; OTV_NEST2( AlternateSubstFormat1, AlternateSet ); OTV_RUN( table, valid ); break; default: FT_INVALID_DATA; } OTV_EXIT; } /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** GSUB LOOKUP TYPE 4 *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ #define Ligature otv_Ligature_validate, "Ligature" /* uses valid->glyph_count */ static void otv_Ligature_validate( FT_Bytes table, OTV_Validator valid ) { FT_Bytes p = table; FT_UInt LigatureGlyph, CompCount; OTV_ENTER; OTV_LIMIT_CHECK( 4 ); LigatureGlyph = FT_NEXT_USHORT( p ); if ( LigatureGlyph >= valid->glyph_count ) FT_INVALID_DATA; CompCount = FT_NEXT_USHORT( p ); OTV_TRACE(( " (CompCount = %d)\n", CompCount )); if ( CompCount == 0 ) FT_INVALID_DATA; CompCount--; OTV_LIMIT_CHECK( CompCount * 2 ); /* Component */ /* no need to check the Component glyph indices */ OTV_EXIT; } static void otv_LigatureSubst_validate( FT_Bytes table, OTV_Validator valid ) { FT_Bytes p = table; FT_UInt SubstFormat; OTV_NAME_ENTER( "LigatureSubst" ); OTV_LIMIT_CHECK( 2 ); SubstFormat = FT_NEXT_USHORT( p ); OTV_TRACE(( " (format %d)\n", SubstFormat )); switch ( SubstFormat ) { case 1: OTV_NEST3( LigatureSubstFormat1, LigatureSet, Ligature ); OTV_RUN( table, valid ); break; default: FT_INVALID_DATA; } OTV_EXIT; } /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** GSUB LOOKUP TYPE 5 *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ /* sets valid->extra1 (lookup count) */ static void otv_ContextSubst_validate( FT_Bytes table, OTV_Validator valid ) { FT_Bytes p = table; FT_UInt SubstFormat; OTV_NAME_ENTER( "ContextSubst" ); OTV_LIMIT_CHECK( 2 ); SubstFormat = FT_NEXT_USHORT( p ); OTV_TRACE(( " (format %d)\n", SubstFormat )); switch ( SubstFormat ) { case 1: /* no need to check glyph indices/classes used as input for these */ /* context rules since even invalid glyph indices/classes return */ /* meaningful results */ valid->extra1 = valid->lookup_count; OTV_NEST3( ContextSubstFormat1, SubRuleSet, SubRule ); OTV_RUN( table, valid ); break; case 2: /* no need to check glyph indices/classes used as input for these */ /* context rules since even invalid glyph indices/classes return */ /* meaningful results */ OTV_NEST3( ContextSubstFormat2, SubClassSet, SubClassRule ); OTV_RUN( table, valid ); break; case 3: OTV_NEST1( ContextSubstFormat3 ); OTV_RUN( table, valid ); break; default: FT_INVALID_DATA; } OTV_EXIT; } /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** GSUB LOOKUP TYPE 6 *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ /* sets valid->extra1 (lookup count) */ static void otv_ChainContextSubst_validate( FT_Bytes table, OTV_Validator valid ) { FT_Bytes p = table; FT_UInt SubstFormat; OTV_NAME_ENTER( "ChainContextSubst" ); OTV_LIMIT_CHECK( 2 ); SubstFormat = FT_NEXT_USHORT( p ); OTV_TRACE(( " (format %d)\n", SubstFormat )); switch ( SubstFormat ) { case 1: /* no need to check glyph indices/classes used as input for these */ /* context rules since even invalid glyph indices/classes return */ /* meaningful results */ valid->extra1 = valid->lookup_count; OTV_NEST3( ChainContextSubstFormat1, ChainSubRuleSet, ChainSubRule ); OTV_RUN( table, valid ); break; case 2: /* no need to check glyph indices/classes used as input for these */ /* context rules since even invalid glyph indices/classes return */ /* meaningful results */ OTV_NEST3( ChainContextSubstFormat2, ChainSubClassSet, ChainSubClassRule ); OTV_RUN( table, valid ); break; case 3: OTV_NEST1( ChainContextSubstFormat3 ); OTV_RUN( table, valid ); break; default: FT_INVALID_DATA; } OTV_EXIT; } /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** GSUB LOOKUP TYPE 7 *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ /* uses valid->type_funcs */ static void otv_ExtensionSubst_validate( FT_Bytes table, OTV_Validator valid ) { FT_Bytes p = table; FT_UInt SubstFormat; OTV_NAME_ENTER( "ExtensionSubst" ); OTV_LIMIT_CHECK( 2 ); SubstFormat = FT_NEXT_USHORT( p ); OTV_TRACE(( " (format %d)\n", SubstFormat )); switch ( SubstFormat ) { case 1: /* ExtensionSubstFormat1 */ { FT_UInt ExtensionLookupType, ExtensionOffset; OTV_Validate_Func validate; OTV_LIMIT_CHECK( 6 ); ExtensionLookupType = FT_NEXT_USHORT( p ); ExtensionOffset = FT_NEXT_ULONG( p ); if ( ExtensionLookupType == 0 || ExtensionLookupType == 7 || ExtensionLookupType > 8 ) FT_INVALID_DATA; validate = valid->type_funcs[ExtensionLookupType - 1]; validate( table + ExtensionOffset, valid ); } break; default: FT_INVALID_DATA; } OTV_EXIT; } /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** GSUB LOOKUP TYPE 8 *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ /* uses valid->glyph_count */ static void otv_ReverseChainSingleSubst_validate( FT_Bytes table, OTV_Validator valid ) { FT_Bytes p = table, Coverage; FT_UInt SubstFormat; FT_UInt BacktrackGlyphCount, LookaheadGlyphCount, GlyphCount; OTV_NAME_ENTER( "ReverseChainSingleSubst" ); OTV_LIMIT_CHECK( 2 ); SubstFormat = FT_NEXT_USHORT( p ); OTV_TRACE(( " (format %d)\n", SubstFormat )); switch ( SubstFormat ) { case 1: /* ReverseChainSingleSubstFormat1 */ OTV_LIMIT_CHECK( 4 ); Coverage = table + FT_NEXT_USHORT( p ); BacktrackGlyphCount = FT_NEXT_USHORT( p ); OTV_TRACE(( " (BacktrackGlyphCount = %d)\n", BacktrackGlyphCount )); otv_Coverage_validate( Coverage, valid ); OTV_LIMIT_CHECK( BacktrackGlyphCount * 2 + 2 ); for ( ; BacktrackGlyphCount > 0; BacktrackGlyphCount-- ) otv_Coverage_validate( table + FT_NEXT_USHORT( p ), valid ); LookaheadGlyphCount = FT_NEXT_USHORT( p ); OTV_TRACE(( " (LookaheadGlyphCount = %d)\n", LookaheadGlyphCount )); OTV_LIMIT_CHECK( LookaheadGlyphCount * 2 + 2 ); for ( ; LookaheadGlyphCount > 0; LookaheadGlyphCount-- ) otv_Coverage_validate( table + FT_NEXT_USHORT( p ), valid ); GlyphCount = FT_NEXT_USHORT( p ); OTV_TRACE(( " (GlyphCount = %d)\n", GlyphCount )); if ( GlyphCount != otv_Coverage_get_count( Coverage ) ) FT_INVALID_DATA; OTV_LIMIT_CHECK( GlyphCount * 2 ); /* Substitute */ for ( ; GlyphCount > 0; GlyphCount-- ) if ( FT_NEXT_USHORT( p ) >= valid->glyph_count ) FT_INVALID_DATA; break; default: FT_INVALID_DATA; } OTV_EXIT; } static const OTV_Validate_Func otv_gsub_validate_funcs[8] = { otv_SingleSubst_validate, otv_MultipleSubst_validate, otv_AlternateSubst_validate, otv_LigatureSubst_validate, otv_ContextSubst_validate, otv_ChainContextSubst_validate, otv_ExtensionSubst_validate, otv_ReverseChainSingleSubst_validate }; /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** GSUB TABLE *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ /* sets valid->type_count */ /* sets valid->type_funcs */ /* sets valid->glyph_count */ FT_LOCAL_DEF( void ) otv_GSUB_validate( FT_Bytes table, FT_UInt glyph_count, FT_Validator ftvalid ) { OTV_ValidatorRec validrec; OTV_Validator valid = &validrec; FT_Bytes p = table; FT_UInt ScriptList, FeatureList, LookupList; valid->root = ftvalid; FT_TRACE3(( "validating GSUB table\n" )); OTV_INIT; OTV_LIMIT_CHECK( 10 ); if ( FT_NEXT_ULONG( p ) != 0x10000UL ) /* Version */ FT_INVALID_DATA; ScriptList = FT_NEXT_USHORT( p ); FeatureList = FT_NEXT_USHORT( p ); LookupList = FT_NEXT_USHORT( p ); valid->type_count = 8; valid->type_funcs = (OTV_Validate_Func*)otv_gsub_validate_funcs; valid->glyph_count = glyph_count; otv_LookupList_validate( table + LookupList, valid ); otv_FeatureList_validate( table + FeatureList, table + LookupList, valid ); otv_ScriptList_validate( table + ScriptList, table + FeatureList, valid ); FT_TRACE4(( "\n" )); } /* END */ --- NEW FILE: otvgdef.c --- /***************************************************************************/ /* */ /* otvgdef.c */ /* */ /* OpenType GDEF table validation (body). */ /* */ /* Copyright 2004, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include "otvalid.h" #include "otvcommn.h" /*************************************************************************/ /* */ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ /* messages during execution. */ /* */ #undef FT_COMPONENT #define FT_COMPONENT trace_otvgdef /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** UTILITY FUNCTIONS *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ #define AttachList otv_O_x_Ox, "AttachList" #define LigCaretList otv_O_x_Ox, "LigCaretList" /* sets valid->extra1 (0) */ static void otv_O_x_Ox( FT_Bytes table, OTV_Validator valid ) { FT_Bytes p = table; FT_Bytes Coverage; FT_UInt GlyphCount; OTV_Validate_Func func; OTV_ENTER; OTV_LIMIT_CHECK( 4 ); Coverage = table + FT_NEXT_USHORT( p ); GlyphCount = FT_NEXT_USHORT( p ); OTV_TRACE(( " (GlyphCount = %d)\n", GlyphCount )); otv_Coverage_validate( Coverage, valid ); if ( GlyphCount != otv_Coverage_get_count( Coverage ) ) FT_INVALID_DATA; OTV_LIMIT_CHECK( GlyphCount * 2 ); valid->nesting_level++; func = valid->func[valid->nesting_level]; valid->extra1 = 0; for ( ; GlyphCount > 0; GlyphCount-- ) func( table + FT_NEXT_USHORT( p ), valid ); valid->nesting_level--; OTV_EXIT; } /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** LIGATURE CARETS *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ #define CaretValue otv_CaretValue_validate, "CaretValue" static void otv_CaretValue_validate( FT_Bytes table, OTV_Validator valid ) { FT_Bytes p = table; FT_UInt CaretValueFormat; OTV_ENTER; OTV_LIMIT_CHECK( 4 ); CaretValueFormat = FT_NEXT_USHORT( p ); OTV_TRACE(( " (format = %d)\n", CaretValueFormat )); switch ( CaretValueFormat ) { case 1: /* CaretValueFormat1 */ /* skip Coordinate, no test */ break; case 2: /* CaretValueFormat2 */ /* skip CaretValuePoint, no test */ break; case 3: /* CaretValueFormat3 */ p += 2; /* skip Coordinate */ OTV_LIMIT_CHECK( 2 ); /* DeviceTable */ otv_Device_validate( table + FT_NEXT_USHORT( p ), valid ); break; default: FT_INVALID_DATA; } OTV_EXIT; } /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** GDEF TABLE *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ FT_LOCAL_DEF( void ) otv_GDEF_validate( FT_Bytes table, FT_Bytes gsub, FT_Bytes gpos, FT_Validator ftvalid ) { OTV_ValidatorRec validrec; OTV_Validator valid = &validrec; FT_Bytes p = table; FT_UInt table_size; FT_Bool need_MarkAttachClassDef; OTV_OPTIONAL_TABLE( GlyphClassDef ); OTV_OPTIONAL_TABLE( AttachListOffset ); OTV_OPTIONAL_TABLE( LigCaretListOffset ); OTV_OPTIONAL_TABLE( MarkAttachClassDef ); valid->root = ftvalid; FT_TRACE3(( "validating GDEF table\n" )); OTV_INIT; OTV_LIMIT_CHECK( 12 ); if ( FT_NEXT_ULONG( p ) != 0x10000UL ) /* Version */ FT_INVALID_FORMAT; /* MarkAttachClassDef has been added to the OpenType */ /* specification without increasing GDEF's version, */ /* so we use this ugly hack to find out whether the */ /* table is needed actually. */ need_MarkAttachClassDef = FT_BOOL( otv_GSUBGPOS_have_MarkAttachmentType_flag( gsub ) || otv_GSUBGPOS_have_MarkAttachmentType_flag( gpos ) ); if ( need_MarkAttachClassDef ) table_size = 12; /* OpenType >= 1.2 */ else table_size = 10; /* OpenType < 1.2 */ OTV_OPTIONAL_OFFSET( GlyphClassDef ); OTV_SIZE_CHECK( GlyphClassDef ); if ( GlyphClassDef ) otv_ClassDef_validate( table + GlyphClassDef, valid ); OTV_OPTIONAL_OFFSET( AttachListOffset ); OTV_SIZE_CHECK( AttachListOffset ); if ( AttachListOffset ) { OTV_NEST2( AttachList, AttachPoint ); OTV_RUN( table + AttachListOffset, valid ); } OTV_OPTIONAL_OFFSET( LigCaretListOffset ); OTV_SIZE_CHECK( LigCaretListOffset ); if ( LigCaretListOffset ) { OTV_NEST3( LigCaretList, LigGlyph, CaretValue ); OTV_RUN( table + LigCaretListOffset, valid ); } if ( need_MarkAttachClassDef ) { OTV_OPTIONAL_OFFSET( MarkAttachClassDef ); OTV_SIZE_CHECK( MarkAttachClassDef ); if ( MarkAttachClassDef ) otv_ClassDef_validate( table + MarkAttachClassDef, valid ); } FT_TRACE4(( "\n" )); } /* END */ --- NEW FILE: otvgpos.c --- /***************************************************************************/ /* */ /* otvgpos.c */ /* */ /* OpenType GPOS table validation (body). */ /* */ /* Copyright 2002, 2004, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include "otvalid.h" [...974 lines suppressed...] ScriptList = FT_NEXT_USHORT( p ); FeatureList = FT_NEXT_USHORT( p ); LookupList = FT_NEXT_USHORT( p ); valid->type_count = 9; valid->type_funcs = (OTV_Validate_Func*)otv_gpos_validate_funcs; valid->glyph_count = glyph_count; otv_LookupList_validate( table + LookupList, valid ); otv_FeatureList_validate( table + FeatureList, table + LookupList, valid ); otv_ScriptList_validate( table + ScriptList, table + FeatureList, valid ); FT_TRACE4(( "\n" )); } /* END */ --- NEW FILE: otvmod.c --- /***************************************************************************/ /* */ /* otvmod.c */ /* */ /* FreeType's OpenType validation module implementation (body). */ /* */ /* Copyright 2004, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include <ft2build.h> #include FT_TRUETYPE_TABLES_H #include FT_TRUETYPE_TAGS_H #include FT_OPENTYPE_VALIDATE_H #include FT_INTERNAL_OBJECTS_H #include FT_SERVICE_OPENTYPE_VALIDATE_H #include "otvmod.h" #include "otvalid.h" #include "otvcommn.h" /*************************************************************************/ /* */ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ /* messages during execution. */ /* */ #undef FT_COMPONENT #define FT_COMPONENT trace_otvmodule static FT_Error otv_load_table( FT_Face face, FT_Tag tag, FT_Byte* *table, FT_ULong *table_len ) { FT_Error error; FT_Memory memory = FT_FACE_MEMORY( face ); error = FT_Load_Sfnt_Table( face, tag, 0, NULL, table_len ); if ( error == OTV_Err_Table_Missing ) return OTV_Err_Ok; if ( error ) goto Exit; if ( FT_ALLOC( *table, *table_len ) ) goto Exit; error = FT_Load_Sfnt_Table( face, tag, 0, *table, table_len ); Exit: return error; } static FT_Error otv_validate( FT_Face face, FT_UInt ot_flags, FT_Bytes *ot_base, FT_Bytes *ot_gdef, FT_Bytes *ot_gpos, FT_Bytes *ot_gsub, FT_Bytes *ot_jstf ) { FT_Error error = OTV_Err_Ok; FT_Byte *base, *gdef, *gpos, *gsub, *jstf; FT_ULong len_base, len_gdef, len_gpos, len_gsub, len_jstf; FT_ValidatorRec valid; base = gdef = gpos = gsub = jstf = NULL; len_base = len_gdef = len_gpos = len_gsub = len_jstf = 0; /* load tables */ if ( ot_flags & FT_VALIDATE_BASE ) { error = otv_load_table( face, TTAG_BASE, &base, &len_base ); if ( error ) goto Exit; } if ( ot_flags & FT_VALIDATE_GDEF ) { error = otv_load_table( face, TTAG_GDEF, &gdef, &len_gdef ); if ( error ) goto Exit; } if ( ot_flags & FT_VALIDATE_GPOS ) { error = otv_load_table( face, TTAG_GPOS, &gpos, &len_gpos ); if ( error ) goto Exit; } if ( ot_flags & FT_VALIDATE_GSUB ) { error = otv_load_table( face, TTAG_GSUB, &gsub, &len_gsub ); if ( error ) goto Exit; } if ( ot_flags & FT_VALIDATE_JSTF ) { error = otv_load_table( face, TTAG_JSTF, &jstf, &len_jstf ); if ( error ) goto Exit; } /* validate tables */ if ( base ) { ft_validator_init( &valid, base, base + len_base, FT_VALIDATE_DEFAULT ); if ( ft_setjmp( valid.jump_buffer ) == 0 ) otv_BASE_validate( base, &valid ); error = valid.error; if ( error ) goto Exit; } if ( gpos ) { ft_validator_init( &valid, gpos, gpos + len_gpos, FT_VALIDATE_DEFAULT ); if (ft_setjmp( valid.jump_buffer ) == 0 ) otv_GPOS_validate( gpos, face->num_glyphs, &valid ); error = valid.error; if ( error ) goto Exit; } if ( gsub ) { ft_validator_init( &valid, gsub, gsub + len_gsub, FT_VALIDATE_DEFAULT ); if ( ft_setjmp( valid.jump_buffer ) == 0 ) otv_GSUB_validate( gsub, face->num_glyphs, &valid ); error = valid.error; if ( error ) goto Exit; } if ( gdef ) { ft_validator_init( &valid, gdef, gdef + len_gdef, FT_VALIDATE_DEFAULT ); if ( ft_setjmp( valid.jump_buffer ) == 0 ) otv_GDEF_validate( gdef, gsub, gpos, &valid ); error = valid.error; if ( error ) goto Exit; } if ( jstf ) { ft_validator_init( &valid, jstf, jstf + len_jstf, FT_VALIDATE_DEFAULT ); if ( ft_setjmp( valid.jump_buffer ) == 0 ) otv_JSTF_validate( jstf, gsub, gpos, face->num_glyphs, &valid ); error = valid.error; if ( error ) goto Exit; } *ot_base = (FT_Bytes)base; *ot_gdef = (FT_Bytes)gdef; *ot_gpos = (FT_Bytes)gpos; *ot_gsub = (FT_Bytes)gsub; *ot_jstf = (FT_Bytes)jstf; Exit: if ( error ) { FT_Memory memory = FT_FACE_MEMORY( face ); FT_FREE( base ); FT_FREE( gdef ); FT_FREE( gpos ); FT_FREE( gsub ); FT_FREE( jstf ); } return error; } static const FT_Service_OTvalidateRec otvalid_interface = { otv_validate }; static const FT_ServiceDescRec otvalid_services[] = { { FT_SERVICE_ID_OPENTYPE_VALIDATE, &otvalid_interface }, { NULL, NULL } }; static FT_Pointer otvalid_get_service( FT_Module module, const char* service_id ) { FT_UNUSED( module ); return ft_service_list_lookup( otvalid_services, service_id ); } FT_CALLBACK_TABLE_DEF const FT_Module_Class otv_module_class = { 0, sizeof( FT_ModuleRec ), "otvalid", 0x10000L, 0x20000L, 0, /* module-specific interface */ (FT_Module_Constructor)0, (FT_Module_Destructor) 0, (FT_Module_Requester) otvalid_get_service }; /* END */ |
From: Ehud S. <esh...@us...> - 2006-04-21 16:22:40
|
Update of /cvsroot/roadmap/roadmap_editor/src/freetype/src/psaux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22848/src/psaux Added Files: psaux.c psauxmod.c psobjs.c t1cmap.c t1decode.c Log Message: Import freetype sources. --- NEW FILE: psobjs.c --- /***************************************************************************/ /* */ /* psobjs.c */ /* */ /* Auxiliary functions for PostScript fonts (body). */ /* */ /* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include <ft2build.h> [...1754 lines suppressed...] FT_LOCAL_DEF( void ) t1_decrypt( FT_Byte* buffer, FT_Offset length, FT_UShort seed ) { while ( length > 0 ) { FT_Byte plain; plain = (FT_Byte)( *buffer ^ ( seed >> 8 ) ); seed = (FT_UShort)( ( *buffer + seed ) * 52845U + 22719 ); *buffer++ = plain; length--; } } /* END */ --- NEW FILE: t1decode.c --- /***************************************************************************/ /* */ /* t1decode.c */ /* */ /* PostScript Type 1 decoding routines (body). */ /* */ /* Copyright 2000-2001, 2002, 2003, 2004, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include <ft2build.h> [...1127 lines suppressed...] decoder->glyph_names = glyph_names; decoder->hint_mode = hint_mode; decoder->blend = blend; decoder->parse_callback = parse_callback; decoder->funcs = t1_decoder_funcs; return 0; } /* finalize T1 decoder */ FT_LOCAL_DEF( void ) t1_decoder_done( T1_Decoder decoder ) { t1_builder_done( &decoder->builder ); } /* END */ --- NEW FILE: psaux.c --- /***************************************************************************/ /* */ /* psaux.c */ /* */ /* FreeType auxiliary PostScript driver component (body only). */ /* */ /* Copyright 1996-2001, 2002 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #define FT_MAKE_OPTION_SINGLE_OBJECT #include <ft2build.h> #include "psobjs.c" #include "psauxmod.c" #include "t1decode.c" #include "t1cmap.c" /* END */ --- NEW FILE: psauxmod.c --- /***************************************************************************/ /* */ /* psauxmod.c */ /* */ /* FreeType auxiliary PostScript module implementation (body). */ /* */ /* Copyright 2000-2001, 2002, 2003 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include <ft2build.h> #include "psauxmod.h" #include "psobjs.h" #include "t1decode.h" #include "t1cmap.h" FT_CALLBACK_TABLE_DEF const PS_Table_FuncsRec ps_table_funcs = { ps_table_new, ps_table_done, ps_table_add, ps_table_release }; FT_CALLBACK_TABLE_DEF const PS_Parser_FuncsRec ps_parser_funcs = { ps_parser_init, ps_parser_done, ps_parser_skip_spaces, ps_parser_skip_PS_token, ps_parser_to_int, ps_parser_to_fixed, ps_parser_to_bytes, ps_parser_to_coord_array, ps_parser_to_fixed_array, ps_parser_to_token, ps_parser_to_token_array, ps_parser_load_field, ps_parser_load_field_table }; FT_CALLBACK_TABLE_DEF const T1_Builder_FuncsRec t1_builder_funcs = { t1_builder_init, t1_builder_done, t1_builder_check_points, t1_builder_add_point, t1_builder_add_point1, t1_builder_add_contour, t1_builder_start_point, t1_builder_close_contour }; FT_CALLBACK_TABLE_DEF const T1_Decoder_FuncsRec t1_decoder_funcs = { t1_decoder_init, t1_decoder_done, t1_decoder_parse_charstrings }; FT_CALLBACK_TABLE_DEF const T1_CMap_ClassesRec t1_cmap_classes = { &t1_cmap_standard_class_rec, &t1_cmap_expert_class_rec, &t1_cmap_custom_class_rec, &t1_cmap_unicode_class_rec }; static const PSAux_Interface psaux_interface = { &ps_table_funcs, &ps_parser_funcs, &t1_builder_funcs, &t1_decoder_funcs, t1_decrypt, (const T1_CMap_ClassesRec*) &t1_cmap_classes, }; FT_CALLBACK_TABLE_DEF const FT_Module_Class psaux_module_class = { 0, sizeof( FT_ModuleRec ), "psaux", 0x20000L, 0x20000L, &psaux_interface, /* module-specific interface */ (FT_Module_Constructor)0, (FT_Module_Destructor) 0, (FT_Module_Requester) 0 }; /* END */ --- NEW FILE: t1cmap.c --- /***************************************************************************/ /* */ /* t1cmap.c */ /* */ /* Type 1 character map support (body). */ /* */ /* Copyright 2002, 2003 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include "t1cmap.h" #include FT_INTERNAL_DEBUG_H #include "psauxerr.h" /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** TYPE1 STANDARD (AND EXPERT) ENCODING CMAPS *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ static void t1_cmap_std_init( T1_CMapStd cmap, FT_Int is_expert ) { T1_Face face = (T1_Face)FT_CMAP_FACE( cmap ); FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)face->psnames; cmap->num_glyphs = face->type1.num_glyphs; cmap->glyph_names = (const char* const*)face->type1.glyph_names; cmap->sid_to_string = psnames->adobe_std_strings; cmap->code_to_sid = is_expert ? psnames->adobe_expert_encoding : psnames->adobe_std_encoding; FT_ASSERT( cmap->code_to_sid != NULL ); } FT_CALLBACK_DEF( void ) t1_cmap_std_done( T1_CMapStd cmap ) { cmap->num_glyphs = 0; cmap->glyph_names = NULL; cmap->sid_to_string = NULL; cmap->code_to_sid = NULL; } FT_CALLBACK_DEF( FT_UInt ) t1_cmap_std_char_index( T1_CMapStd cmap, FT_UInt32 char_code ) { FT_UInt result = 0; if ( char_code < 256 ) { FT_UInt code, n; const char* glyph_name; /* convert character code to Adobe SID string */ code = cmap->code_to_sid[char_code]; glyph_name = cmap->sid_to_string( code ); /* look for the corresponding glyph name */ for ( n = 0; n < cmap->num_glyphs; n++ ) { const char* gname = cmap->glyph_names[n]; if ( gname && gname[0] == glyph_name[0] && ft_strcmp( gname, glyph_name ) == 0 ) { result = n; break; } } } return result; } FT_CALLBACK_DEF( FT_UInt ) t1_cmap_std_char_next( T1_CMapStd cmap, FT_UInt32 *pchar_code ) { FT_UInt result = 0; FT_UInt32 char_code = *pchar_code + 1; while ( char_code < 256 ) { result = t1_cmap_std_char_index( cmap, char_code ); if ( result != 0 ) goto Exit; char_code++; } char_code = 0; Exit: *pchar_code = char_code; return result; } FT_CALLBACK_DEF( FT_Error ) t1_cmap_standard_init( T1_CMapStd cmap ) { t1_cmap_std_init( cmap, 0 ); return 0; } FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec t1_cmap_standard_class_rec = { sizeof ( T1_CMapStdRec ), (FT_CMap_InitFunc) t1_cmap_standard_init, (FT_CMap_DoneFunc) t1_cmap_std_done, (FT_CMap_CharIndexFunc)t1_cmap_std_char_index, (FT_CMap_CharNextFunc) t1_cmap_std_char_next }; FT_CALLBACK_DEF( FT_Error ) t1_cmap_expert_init( T1_CMapStd cmap ) { t1_cmap_std_init( cmap, 1 ); return 0; } FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec t1_cmap_expert_class_rec = { sizeof ( T1_CMapStdRec ), (FT_CMap_InitFunc) t1_cmap_expert_init, (FT_CMap_DoneFunc) t1_cmap_std_done, (FT_CMap_CharIndexFunc)t1_cmap_std_char_index, (FT_CMap_CharNextFunc) t1_cmap_std_char_next }; /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** TYPE1 CUSTOM ENCODING CMAP *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ FT_CALLBACK_DEF( FT_Error ) t1_cmap_custom_init( T1_CMapCustom cmap ) { T1_Face face = (T1_Face)FT_CMAP_FACE( cmap ); T1_Encoding encoding = &face->type1.encoding; cmap->first = encoding->code_first; cmap->count = (FT_UInt)( encoding->code_last - cmap->first + 1 ); cmap->indices = encoding->char_index; FT_ASSERT( cmap->indices != NULL ); FT_ASSERT( encoding->code_first <= encoding->code_last ); return 0; } FT_CALLBACK_DEF( void ) t1_cmap_custom_done( T1_CMapCustom cmap ) { cmap->indices = NULL; cmap->first = 0; cmap->count = 0; } FT_CALLBACK_DEF( FT_UInt ) t1_cmap_custom_char_index( T1_CMapCustom cmap, FT_UInt32 char_code ) { FT_UInt result = 0; if ( ( char_code >= cmap->first ) && ( char_code < ( cmap->first + cmap->count ) ) ) result = cmap->indices[char_code]; return result; } FT_CALLBACK_DEF( FT_UInt ) t1_cmap_custom_char_next( T1_CMapCustom cmap, FT_UInt32 *pchar_code ) { FT_UInt result = 0; FT_UInt32 char_code = *pchar_code; ++char_code; if ( char_code < cmap->first ) char_code = cmap->first; for ( ; char_code < ( cmap->first + cmap->count ); char_code++ ) { result = cmap->indices[char_code]; if ( result != 0 ) goto Exit; } char_code = 0; Exit: *pchar_code = char_code; return result; } FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec t1_cmap_custom_class_rec = { sizeof ( T1_CMapCustomRec ), (FT_CMap_InitFunc) t1_cmap_custom_init, (FT_CMap_DoneFunc) t1_cmap_custom_done, (FT_CMap_CharIndexFunc)t1_cmap_custom_char_index, (FT_CMap_CharNextFunc) t1_cmap_custom_char_next }; /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** TYPE1 SYNTHETIC UNICODE ENCODING CMAP *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ FT_CALLBACK_DEF( FT_Int ) t1_cmap_uni_pair_compare( const void* pair1, const void* pair2 ) { FT_UInt32 u1 = ((T1_CMapUniPair)pair1)->unicode; FT_UInt32 u2 = ((T1_CMapUniPair)pair2)->unicode; if ( u1 < u2 ) return -1; if ( u1 > u2 ) return +1; return 0; } FT_CALLBACK_DEF( FT_Error ) t1_cmap_unicode_init( T1_CMapUnicode cmap ) { FT_Error error; FT_UInt count; T1_Face face = (T1_Face)FT_CMAP_FACE( cmap ); FT_Memory memory = FT_FACE_MEMORY( face ); FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)face->psnames; cmap->num_pairs = 0; cmap->pairs = NULL; count = face->type1.num_glyphs; if ( !FT_NEW_ARRAY( cmap->pairs, count ) ) { FT_UInt n, new_count; T1_CMapUniPair pair; FT_UInt32 uni_code; pair = cmap->pairs; for ( n = 0; n < count; n++ ) { const char* gname = face->type1.glyph_names[n]; /* build unsorted pair table by matching glyph names */ if ( gname ) { uni_code = psnames->unicode_value( gname ); if ( uni_code != 0 ) { pair->unicode = uni_code; pair->gindex = n; pair++; } } } new_count = (FT_UInt)( pair - cmap->pairs ); if ( new_count == 0 ) { /* there are no unicode characters in here! */ FT_FREE( cmap->pairs ); error = PSaux_Err_Invalid_Argument; } else { /* re-allocate if the new array is much smaller than the original */ /* one */ if ( new_count != count && new_count < count / 2 ) { (void)FT_RENEW_ARRAY( cmap->pairs, count, new_count ); error = 0; } /* sort the pairs table to allow efficient binary searches */ ft_qsort( cmap->pairs, new_count, sizeof ( T1_CMapUniPairRec ), t1_cmap_uni_pair_compare ); cmap->num_pairs = new_count; } } return error; } FT_CALLBACK_DEF( void ) t1_cmap_unicode_done( T1_CMapUnicode cmap ) { FT_Face face = FT_CMAP_FACE(cmap); FT_Memory memory = FT_FACE_MEMORY(face); FT_FREE( cmap->pairs ); cmap->num_pairs = 0; } FT_CALLBACK_DEF( FT_UInt ) t1_cmap_unicode_char_index( T1_CMapUnicode cmap, FT_UInt32 char_code ) { FT_UInt min = 0; FT_UInt max = cmap->num_pairs; FT_UInt mid; T1_CMapUniPair pair; while ( min < max ) { mid = min + ( max - min ) / 2; pair = cmap->pairs + mid; if ( pair->unicode == char_code ) return pair->gindex; if ( pair->unicode < char_code ) min = mid + 1; else max = mid; } return 0; } FT_CALLBACK_DEF( FT_UInt ) t1_cmap_unicode_char_next( T1_CMapUnicode cmap, FT_UInt32 *pchar_code ) { FT_UInt result = 0; FT_UInt32 char_code = *pchar_code + 1; Restart: { FT_UInt min = 0; FT_UInt max = cmap->num_pairs; FT_UInt mid; T1_CMapUniPair pair; while ( min < max ) { mid = min + ( ( max - min ) >> 1 ); pair = cmap->pairs + mid; if ( pair->unicode == char_code ) { result = pair->gindex; if ( result != 0 ) goto Exit; char_code++; goto Restart; } if ( pair->unicode < char_code ) min = mid+1; else max = mid; } /* we didn't find it, but we have a pair just above it */ char_code = 0; if ( min < cmap->num_pairs ) { pair = cmap->pairs + min; result = pair->gindex; if ( result != 0 ) char_code = pair->unicode; } } Exit: *pchar_code = char_code; return result; } FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec t1_cmap_unicode_class_rec = { sizeof ( T1_CMapUnicodeRec ), (FT_CMap_InitFunc) t1_cmap_unicode_init, (FT_CMap_DoneFunc) t1_cmap_unicode_done, (FT_CMap_CharIndexFunc)t1_cmap_unicode_char_index, (FT_CMap_CharNextFunc) t1_cmap_unicode_char_next }; /* END */ |
Update of /cvsroot/roadmap/roadmap_editor/src/freetype/src/base In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22848/src/base Added Files: ftapi.c ftbase.c ftbbox.c ftbdf.c ftbitmap.c ftcalc.c ftdbgmem.c ftdebug.c ftgloadr.c ftglyph.c ftinit.c ftmac.c ftmm.c ftnames.c ftobjs.c ftotval.c ftoutln.c ftpfr.c ftrfork.c ftstream.c ftstroke.c ftsynth.c ftsystem.c fttrigon.c fttype1.c ftutil.c ftwinfnt.c ftxf86.c Log Message: Import freetype sources. --- NEW FILE: ftapi.c --- /***************************************************************************/ /* */ /* ftapi.c */ /* */ /* The FreeType compatibility functions (body). */ /* */ /* Copyright 2002 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include <ft2build.h> #include FT_LIST_H #include FT_OUTLINE_H #include FT_INTERNAL_OBJECTS_H #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_STREAM_H #include FT_TRUETYPE_TABLES_H #include FT_OUTLINE_H /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ /**** ****/ /**** ****/ /**** C O M P A T I B I L I T Y ****/ /**** ****/ /**** ****/ /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ /* backwards compatibility API */ FT_BASE_DEF( void ) FT_New_Memory_Stream( FT_Library library, FT_Byte* base, FT_ULong size, FT_Stream stream ) { FT_UNUSED( library ); FT_Stream_OpenMemory( stream, base, size ); } FT_BASE_DEF( FT_Error ) FT_Seek_Stream( FT_Stream stream, FT_ULong pos ) { return FT_Stream_Seek( stream, pos ); } FT_BASE_DEF( FT_Error ) FT_Skip_Stream( FT_Stream stream, FT_Long distance ) { return FT_Stream_Skip( stream, distance ); } FT_BASE_DEF( FT_Error ) FT_Read_Stream( FT_Stream stream, FT_Byte* buffer, FT_ULong count ) { return FT_Stream_Read( stream, buffer, count ); } FT_BASE_DEF( FT_Error ) FT_Read_Stream_At( FT_Stream stream, FT_ULong pos, FT_Byte* buffer, FT_ULong count ) { return FT_Stream_ReadAt( stream, pos, buffer, count ); } FT_BASE_DEF( FT_Error ) FT_Extract_Frame( FT_Stream stream, FT_ULong count, FT_Byte** pbytes ) { return FT_Stream_ExtractFrame( stream, count, pbytes ); } FT_BASE_DEF( void ) FT_Release_Frame( FT_Stream stream, FT_Byte** pbytes ) { FT_Stream_ReleaseFrame( stream, pbytes ); } FT_BASE_DEF( FT_Error ) FT_Access_Frame( FT_Stream stream, FT_ULong count ) { return FT_Stream_EnterFrame( stream, count ); } FT_BASE_DEF( void ) FT_Forget_Frame( FT_Stream stream ) { FT_Stream_ExitFrame( stream ); } /* END */ --- NEW FILE: ftpfr.c --- /***************************************************************************/ /* */ /* ftpfr.c */ /* */ /* FreeType API for accessing PFR-specific data (body). */ /* */ /* Copyright 2002, 2003, 2004 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include <ft2build.h> #include FT_INTERNAL_OBJECTS_H #include FT_SERVICE_PFR_H /* check the format */ static FT_Service_PfrMetrics ft_pfr_check( FT_Face face ) { FT_Service_PfrMetrics service; FT_FACE_LOOKUP_SERVICE( face, service, PFR_METRICS ); return service; } /* documentation is in ftpfr.h */ FT_EXPORT_DEF( FT_Error ) FT_Get_PFR_Metrics( FT_Face face, FT_UInt *aoutline_resolution, FT_UInt *ametrics_resolution, FT_Fixed *ametrics_x_scale, FT_Fixed *ametrics_y_scale ) { FT_Error error = FT_Err_Ok; FT_Service_PfrMetrics service; service = ft_pfr_check( face ); if ( service ) { error = service->get_metrics( face, aoutline_resolution, ametrics_resolution, ametrics_x_scale, ametrics_y_scale ); } else if ( face ) { FT_Fixed x_scale, y_scale; /* this is not a PFR font */ *aoutline_resolution = face->units_per_EM; *ametrics_resolution = face->units_per_EM; x_scale = y_scale = 0x10000L; if ( face->size ) { x_scale = face->size->metrics.x_scale; y_scale = face->size->metrics.y_scale; } *ametrics_x_scale = x_scale; *ametrics_y_scale = y_scale; } else error = FT_Err_Invalid_Argument; return error; } /* documentation is in ftpfr.h */ FT_EXPORT_DEF( FT_Error ) FT_Get_PFR_Kerning( FT_Face face, FT_UInt left, FT_UInt right, FT_Vector *avector ) { FT_Error error; FT_Service_PfrMetrics service; service = ft_pfr_check( face ); if ( service ) error = service->get_kerning( face, left, right, avector ); else if ( face ) error = FT_Get_Kerning( face, left, right, FT_KERNING_UNSCALED, avector ); else error = FT_Err_Invalid_Argument; return error; } /* documentation is in ftpfr.h */ FT_EXPORT_DEF( FT_Error ) FT_Get_PFR_Advance( FT_Face face, FT_UInt gindex, FT_Pos *aadvance ) { FT_Error error; FT_Service_PfrMetrics service; service = ft_pfr_check( face ); if ( service ) { error = service->get_advance( face, gindex, aadvance ); } else /* XXX: TODO: PROVIDE ADVANCE-LOADING METHOD TO ALL FONT DRIVERS */ error = FT_Err_Invalid_Argument; return error; } /* END */ --- NEW FILE: fttype1.c --- /***************************************************************************/ /* */ /* fttype1.c */ /* */ /* FreeType utility file for PS names support (body). */ /* */ /* Copyright 2002, 2003, 2004 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #include <ft2build.h> #include FT_INTERNAL_OBJECTS_H #include FT_INTERNAL_SERVICE_H #include FT_SERVICE_POSTSCRIPT_INFO_H /* documentation is in t1tables.h */ FT_EXPORT_DEF( FT_Error ) FT_Get_PS_Font_Info( FT_Face face, PS_FontInfoRec* afont_info ) { FT_Error error = FT_Err_Invalid_Argument; if ( face ) { FT_Service_PsInfo service = NULL; FT_FACE_FIND_SERVICE( face, service, POSTSCRIPT_INFO ); if ( service && service->ps_get_font_info ) error = service->ps_get_font_info( face, afont_info ); } return error; } /* documentation is in t1tables.h */ FT_EXPORT_DEF( FT_Int ) FT_Has_PS_Glyph_Names( FT_Face face ) { FT_Int result = 0; FT_Service_PsInfo service = NULL; if ( face ) { FT_FACE_FIND_SERVICE( face, service, POSTSCRIPT_INFO ); if ( service && service->ps_has_glyph_names ) result = service->ps_has_glyph_names( face ); } return result; } /* documentation is in t1tables.h */ FT_EXPORT_DEF( FT_Error ) FT_Get_PS_Font_Private( FT_Face face, PS_PrivateRec* afont_private ) { FT_Error error = FT_Err_Invalid_Argument; if ( face ) { FT_Service_PsInfo service = NULL; FT_FACE_FIND_SERVICE( face, service, POSTSCRIPT_INFO ); if ( service && service->ps_get_font_private ) error = service->ps_get_font_private( face, afont_private ); } return error; } /* END */ --- NEW FILE: ftsystem.c --- /***************************************************************************/ /* */ /* ftsystem.c */ /* */ /* ANSI-specific FreeType low-level system interface (body). */ /* */ /* Copyright 1996-2001, 2002 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ /*************************************************************************/ /* */ /* This file contains the default interface used by FreeType to access */ /* low-level, i.e. memory management, i/o access as well as thread */ /* synchronisation. It can be replaced by user-specific routines if */ /* necessary. */ /* */ /*************************************************************************/ //#define FT_BITMAP_H #include <ft2build.h> #include FT_CONFIG_CONFIG_H #include FT_INTERNAL_DEBUG_H #include FT_SYSTEM_H #include FT_ERRORS_H #include FT_TYPES_H #include <stdio.h> #include <stdlib.h> /*************************************************************************/ /* */ /* MEMORY MANAGEMENT INTERFACE */ /* */ /*************************************************************************/ /*************************************************************************/ /* */ /* It is not necessary to do any error checking for the */ /* allocation-related functions. This will be done by the higher level */ /* routines like FT_Alloc() or FT_Realloc(). */ /* */ /*************************************************************************/ /*************************************************************************/ /* */ /* <Function> */ /* ft_alloc */ /* */ /* <Description> */ /* The memory allocation function. */ /* */ /* <Input> */ /* memory :: A pointer to the memory object. */ /* */ /* size :: The requested size in bytes. */ /* */ /* <Return> */ /* The address of newly allocated block. */ /* */ FT_CALLBACK_DEF( void* ) ft_alloc( FT_Memory memory, long size ) { FT_UNUSED( memory ); return malloc( size ); } /*************************************************************************/ /* */ /* <Function> */ /* ft_realloc */ /* */ /* <Description> */ /* The memory reallocation function. */ /* */ /* <Input> */ /* memory :: A pointer to the memory object. */ /* */ /* cur_size :: The current size of the allocated memory block. */ /* */ /* new_size :: The newly requested size in bytes. */ /* */ /* block :: The current address of the block in memory. */ /* */ /* <Return> */ /* The address of the reallocated memory block. */ /* */ FT_CALLBACK_DEF( void* ) ft_realloc( FT_Memory memory, long cur_size, long new_size, void* block ) { FT_UNUSED( memory ); FT_UNUSED( cur_size ); return realloc( block, new_size ); } /*************************************************************************/ /* */ /* <Function> */ /* ft_free */ /* */ /* <Description> */ /* The memory release function. */ /* */ /* <Input> */ /* memory :: A pointer to the memory object. */ /* */ /* block :: The address of block in memory to be freed. */ /* */ FT_CALLBACK_DEF( void ) ft_free( FT_Memory memory, void* block ) { FT_UNUSED( memory ); free( block ); } /*************************************************************************/ /* */ /* RESOURCE MANAGEMENT INTERFACE */ /* */ /*************************************************************************/ /*************************************************************************/ /* */ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ /* messages during execution. */ /* */ #undef FT_COMPONENT #define FT_COMPONENT trace_io /* We use the macro STREAM_FILE for convenience to extract the */ /* system-specific stream handle from a given FreeType stream object */ #define STREAM_FILE( stream ) ( (FILE*)stream->descriptor.pointer ) /*************************************************************************/ /* */ /* <Function> */ /* ft_ansi_stream_close */ /* */ /* <Description> */ /* The function to close a stream. */ /* */ /* <Input> */ /* stream :: A pointer to the stream object. */ /* */ FT_CALLBACK_DEF( void ) ft_ansi_stream_close( FT_Stream stream ) { fclose( STREAM_FILE( stream ) ); stream->descriptor.pointer = NULL; stream->size = 0; stream->base = 0; } /*************************************************************************/ /* */ /* <Function> */ /* ft_ansi_stream_io */ /* */ /* <Description> */ /* The function to open a stream. */ /* */ /* <Input> */ /* stream :: A pointer to the stream object. */ /* */ /* offset :: The position in the data stream to start reading. */ /* */ /* buffer :: The address of buffer to store the read data. */ /* */ /* count :: The number of bytes to read from the stream. */ /* */ /* <Return> */ /* The number of bytes actually read. */ /* */ FT_CALLBACK_DEF( unsigned long ) ft_ansi_stream_io( FT_Stream stream, unsigned long offset, unsigned char* buffer, unsigned long count ) { FILE* file; file = STREAM_FILE( stream ); fseek( file, offset, SEEK_SET ); return (unsigned long)fread( buffer, 1, count, file ); } /* documentation is in ftobjs.h */ FT_EXPORT_DEF( FT_Error ) FT_Stream_Open( FT_Stream stream, const char* filepathname ) { FILE* file; if ( !stream ) return FT_Err_Invalid_Stream_Handle; file = fopen( filepathname, "rb" ); if ( !file ) { FT_ERROR(( "FT_Stream_Open:" )); FT_ERROR(( " could not open `%s'\n", filepathname )); return FT_Err_Cannot_Open_Resource; } fseek( file, 0, SEEK_END ); stream->size = ftell( file ); fseek( file, 0, SEEK_SET ); stream->descriptor.pointer = file; stream->pathname.pointer = (char*)filepathname; stream->pos = 0; stream->read = ft_ansi_stream_io; stream->close = ft_ansi_stream_close; FT_TRACE1(( "FT_Stream_Open:" )); FT_TRACE1(( " opened `%s' (%d bytes) successfully\n", filepathname, stream->size )); return FT_Err_Ok; } #ifdef FT_DEBUG_MEMORY extern FT_Int ft_mem_debug_init( FT_Memory memory ); extern void ft_mem_debug_done( FT_Memory memory ); #endif /* documentation is in ftobjs.h */ FT_EXPORT_DEF( FT_Memory ) FT_New_Memory( void ) { FT_Memory memory; memory = (FT_Memory)malloc( sizeof ( *memory ) ); if ( memory ) { memory->user = 0; memory->alloc = ft_alloc; memory->realloc = ft_realloc; memory->free = ft_free; #ifdef FT_DEBUG_MEMORY ft_mem_debug_init( memory ); #endif } return memory; } /* documentation is in ftobjs.h */ FT_EXPORT_DEF( void ) FT_Done_Memory( FT_Memory memory ) { #ifdef FT_DEBUG_MEMORY ft_mem_debug_done( memory ); #endif memory->free( memory, memory ); } /* END */ --- NEW FILE: ftglyph.c --- /***************************************************************************/ /* */ /* ftglyph.c */ /* */ /* FreeType convenience functions to handle glyphs (body). */ /* */ /* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ /*************************************************************************/ /* */ /* This file contains the definition of several convenience functions */ /* that can be used by client applications to easily retrieve glyph */ /* bitmaps and outlines from a given face. */ /* */ /* These functions should be optional if you are writing a font server */ /* or text layout engine on top of FreeType. However, they are pretty */ /* handy for many other simple uses of the library. */ /* */ /*************************************************************************/ //#define FT_BITMAP_H #include <ft2build.h> #include FT_GLYPH_H #include FT_OUTLINE_H #include FT_BITMAP_H #include FT_INTERNAL_OBJECTS_H /*************************************************************************/ /* */ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ /* messages during execution. */ /* */ #undef FT_COMPONENT #define FT_COMPONENT trace_glyph /*************************************************************************/ /*************************************************************************/ /**** ****/ /**** Convenience functions ****/ /**** ****/ /*************************************************************************/ /*************************************************************************/ /* documentation is in ftglyph.h */ FT_EXPORT_DEF( void ) FT_Matrix_Multiply( const FT_Matrix* a, FT_Matrix *b ) { FT_Fixed xx, xy, yx, yy; if ( !a || !b ) return; xx = FT_MulFix( a->xx, b->xx ) + FT_MulFix( a->xy, b->yx ); xy = FT_MulFix( a->xx, b->xy ) + FT_MulFix( a->xy, b->yy ); yx = FT_MulFix( a->yx, b->xx ) + FT_MulFix( a->yy, b->yx ); yy = FT_MulFix( a->yx, b->xy ) + FT_MulFix( a->yy, b->yy ); b->xx = xx; b->xy = xy; b->yx = yx; b->yy = yy; } /* documentation is in ftglyph.h */ FT_EXPORT_DEF( FT_Error ) FT_Matrix_Invert( FT_Matrix* matrix ) { FT_Pos delta, xx, yy; if ( !matrix ) return FT_Err_Invalid_Argument; /* compute discriminant */ delta = FT_MulFix( matrix->xx, matrix->yy ) - FT_MulFix( matrix->xy, matrix->yx ); if ( !delta ) return FT_Err_Invalid_Argument; /* matrix can't be inverted */ matrix->xy = - FT_DivFix( matrix->xy, delta ); matrix->yx = - FT_DivFix( matrix->yx, delta ); xx = matrix->xx; yy = matrix->yy; matrix->xx = FT_DivFix( yy, delta ); matrix->yy = FT_DivFix( xx, delta ); return FT_Err_Ok; } /*************************************************************************/ /*************************************************************************/ /**** ****/ /**** FT_BitmapGlyph support ****/ /**** ****/ /*************************************************************************/ /*************************************************************************/ FT_CALLBACK_DEF( FT_Error ) ft_bitmap_glyph_init( FT_Glyph bitmap_glyph, FT_GlyphSlot slot ) { FT_BitmapGlyph glyph = (FT_BitmapGlyph)bitmap_glyph; FT_Error error = FT_Err_Ok; FT_Library library = FT_GLYPH( glyph )->library; if ( slot->format != FT_GLYPH_FORMAT_BITMAP ) { error = FT_Err_Invalid_Glyph_Format; goto Exit; } glyph->left = slot->bitmap_left; glyph->top = slot->bitmap_top; /* do lazy copying whenever possible */ if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) { glyph->bitmap = slot->bitmap; slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP; } else { FT_Bitmap_New( &glyph->bitmap ); error = FT_Bitmap_Copy( library, &slot->bitmap, &glyph->bitmap ); } Exit: return error; } FT_CALLBACK_DEF( FT_Error ) ft_bitmap_glyph_copy( FT_Glyph bitmap_source, FT_Glyph bitmap_target ) { FT_Library library = bitmap_source->library; FT_BitmapGlyph source = (FT_BitmapGlyph)bitmap_source; FT_BitmapGlyph target = (FT_BitmapGlyph)bitmap_target; target->left = source->left; target->top = source->top; return FT_Bitmap_Copy( library, &source->bitmap, &target->bitmap ); } FT_CALLBACK_DEF( void ) ft_bitmap_glyph_done( FT_Glyph bitmap_glyph ) { FT_BitmapGlyph glyph = (FT_BitmapGlyph)bitmap_glyph; FT_Library library = FT_GLYPH( glyph )->library; FT_Bitmap_Done( library, &glyph->bitmap ); } FT_CALLBACK_DEF( void ) ft_bitmap_glyph_bbox( FT_Glyph bitmap_glyph, FT_BBox* cbox ) { FT_BitmapGlyph glyph = (FT_BitmapGlyph)bitmap_glyph; cbox->xMin = glyph->left << 6; cbox->xMax = cbox->xMin + ( glyph->bitmap.width << 6 ); cbox->yMax = glyph->top << 6; cbox->yMin = cbox->yMax - ( glyph->bitmap.rows << 6 ); } FT_CALLBACK_TABLE_DEF const FT_Glyph_Class ft_bitmap_glyph_class = { sizeof ( FT_BitmapGlyphRec ), FT_GLYPH_FORMAT_BITMAP, ft_bitmap_glyph_init, ft_bitmap_glyph_done, ft_bitmap_glyph_copy, 0, /* FT_Glyph_TransformFunc */ ft_bitmap_glyph_bbox, 0 /* FT_Glyph_PrepareFunc */ }; /*************************************************************************/ /*************************************************************************/ /**** ****/ /**** FT_OutlineGlyph support ****/ /**** ****/ /*************************************************************************/ /*************************************************************************/ FT_CALLBACK_DEF( FT_Error ) ft_outline_glyph_init( FT_Glyph outline_glyph, FT_GlyphSlot slot ) { FT_OutlineGlyph glyph = (FT_OutlineGlyph)outline_glyph; FT_Error error = FT_Err_Ok; FT_Library library = FT_GLYPH( glyph )->library; FT_Outline* source = &slot->outline; FT_Outline* target = &glyph->outline; /* check format in glyph slot */ if ( slot->format != FT_GLYPH_FORMAT_OUTLINE ) { error = FT_Err_Invalid_Glyph_Format; goto Exit; } /* allocate new outline */ error = FT_Outline_New( library, source->n_points, source->n_contours, &glyph->outline ); if ( error ) goto Exit; FT_Outline_Copy( source, target ); Exit: return error; } FT_CALLBACK_DEF( void ) ft_outline_glyph_done( FT_Glyph outline_glyph ) { FT_OutlineGlyph glyph = (FT_OutlineGlyph)outline_glyph; FT_Outline_Done( FT_GLYPH( glyph )->library, &glyph->outline ); } FT_CALLBACK_DEF( FT_Error ) ft_outline_glyph_copy( FT_Glyph outline_source, FT_Glyph outline_target ) { FT_OutlineGlyph source = (FT_OutlineGlyph)outline_source; FT_OutlineGlyph target = (FT_OutlineGlyph)outline_target; FT_Error error; FT_Library library = FT_GLYPH( source )->library; error = FT_Outline_New( library, source->outline.n_points, source->outline.n_contours, &target->outline ); if ( !error ) FT_Outline_Copy( &source->outline, &target->outline ); return error; } FT_CALLBACK_DEF( void ) ft_outline_glyph_transform( FT_Glyph outline_glyph, const FT_Matrix* matrix, const FT_Vector* delta ) { FT_OutlineGlyph glyph = (FT_OutlineGlyph)outline_glyph; if ( matrix ) FT_Outline_Transform( &glyph->outline, matrix ); if ( delta ) FT_Outline_Translate( &glyph->outline, delta->x, delta->y ); } FT_CALLBACK_DEF( void ) ft_outline_glyph_bbox( FT_Glyph outline_glyph, FT_BBox* bbox ) { FT_OutlineGlyph glyph = (FT_OutlineGlyph)outline_glyph; FT_Outline_Get_CBox( &glyph->outline, bbox ); } FT_CALLBACK_DEF( FT_Error ) ft_outline_glyph_prepare( FT_Glyph outline_glyph, FT_GlyphSlot slot ) { FT_OutlineGlyph glyph = (FT_OutlineGlyph)outline_glyph; slot->format = FT_GLYPH_FORMAT_OUTLINE; slot->outline = glyph->outline; slot->outline.flags &= ~FT_OUTLINE_OWNER; return FT_Err_Ok; } FT_CALLBACK_TABLE_DEF const FT_Glyph_Class ft_outline_glyph_class = { sizeof ( FT_OutlineGlyphRec ), FT_GLYPH_FORMAT_OUTLINE, ft_outline_glyph_init, ft_outline_glyph_done, ft_outline_glyph_copy, ft_outline_glyph_transform, ft_outline_glyph_bbox, ft_outline_glyph_prepare }; /*************************************************************************/ /*************************************************************************/ /**** ****/ /**** FT_Glyph class and API ****/ /**** ****/ /*************************************************************************/ /*************************************************************************/ static FT_Error ft_new_glyph( FT_Library library, const FT_Glyph_Class* clazz, FT_Glyph* aglyph ) { FT_Memory memory = library->memory; FT_Error error; FT_Glyph glyph; *aglyph = 0; if ( !FT_ALLOC( glyph, clazz->glyph_size ) ) { glyph->library = library; glyph->clazz = clazz; glyph->format = clazz->glyph_format; *aglyph = glyph; } return error; } /* documentation is in ftglyph.h */ FT_EXPORT_DEF( FT_Error ) FT_Glyph_Copy( FT_Glyph source, FT_Glyph *target ) { FT_Glyph copy; FT_Error error; const FT_Glyph_Class* clazz; /* check arguments */ if ( !target || !source || !source->clazz ) { error = FT_Err_Invalid_Argument; goto Exit; } *target = 0; clazz = source->clazz; error = ft_new_glyph( source->library, clazz, © ); if ( error ) goto Exit; copy->advance = source->advance; copy->format = source->format; if ( clazz->glyph_copy ) error = clazz->glyph_copy( source, copy ); if ( error ) FT_Done_Glyph( copy ); else *target = copy; Exit: return error; } /* documentation is in ftglyph.h */ FT_EXPORT_DEF( FT_Error ) FT_Get_Glyph( FT_GlyphSlot slot, FT_Glyph *aglyph ) { FT_Library library; FT_Error error; FT_Glyph glyph; const FT_Glyph_Class* clazz = 0; if ( !slot ) return FT_Err_Invalid_Slot_Handle; library = slot->library; if ( !aglyph ) return FT_Err_Invalid_Argument; /* if it is a bitmap, that's easy :-) */ if ( slot->format == FT_GLYPH_FORMAT_BITMAP ) clazz = &ft_bitmap_glyph_class; /* it it is an outline too */ else if ( slot->format == FT_GLYPH_FORMAT_OUTLINE ) clazz = &ft_outline_glyph_class; else { /* try to find a renderer that supports the glyph image format */ FT_Renderer render = FT_Lookup_Renderer( library, slot->format, 0 ); if ( render ) clazz = &render->glyph_class; } if ( !clazz ) { error = FT_Err_Invalid_Glyph_Format; goto Exit; } /* create FT_Glyph object */ error = ft_new_glyph( library, clazz, &glyph ); if ( error ) goto Exit; /* copy advance while converting it to 16.16 format */ glyph->advance.x = slot->advance.x << 10; glyph->advance.y = slot->advance.y << 10; /* now import the image from the glyph slot */ error = clazz->glyph_init( glyph, slot ); /* if an error occurred, destroy the glyph */ if ( error ) FT_Done_Glyph( glyph ); else *aglyph = glyph; Exit: return error; } /* documentation is in ftglyph.h */ FT_EXPORT_DEF( FT_Error ) FT_Glyph_Transform( FT_Glyph glyph, FT_Matrix* matrix, FT_Vector* delta ) { const FT_Glyph_Class* clazz; FT_Error error = FT_Err_Ok; if ( !glyph || !glyph->clazz ) error = FT_Err_Invalid_Argument; else { clazz = glyph->clazz; if ( clazz->glyph_transform ) { /* transform glyph image */ clazz->glyph_transform( glyph, matrix, delta ); /* transform advance vector */ if ( matrix ) FT_Vector_Transform( &glyph->advance, matrix ); } else error = FT_Err_Invalid_Glyph_Format; } return error; } /* documentation is in ftglyph.h */ FT_EXPORT_DEF( void ) FT_Glyph_Get_CBox( FT_Glyph glyph, FT_UInt bbox_mode, FT_BBox *acbox ) { const FT_Glyph_Class* clazz; if ( !acbox ) return; acbox->xMin = acbox->yMin = acbox->xMax = acbox->yMax = 0; if ( !glyph || !glyph->clazz ) return; else { clazz = glyph->clazz; if ( !clazz->glyph_bbox ) return; else { /* retrieve bbox in 26.6 coordinates */ clazz->glyph_bbox( glyph, acbox ); /* perform grid fitting if needed */ if ( bbox_mode == FT_GLYPH_BBOX_GRIDFIT || bbox_mode == FT_GLYPH_BBOX_PIXELS ) { acbox->xMin = FT_PIX_FLOOR( acbox->xMin ); acbox->yMin = FT_PIX_FLOOR( acbox->yMin ); acbox->xMax = FT_PIX_CEIL( acbox->xMax ); acbox->yMax = FT_PIX_CEIL( acbox->yMax ); } /* convert to integer pixels if needed */ if ( bbox_mode == FT_GLYPH_BBOX_TRUNCATE || bbox_mode == FT_GLYPH_BBOX_PIXELS ) { acbox->xMin >>= 6; acbox->yMin >>= 6; acbox->xMax >>= 6; acbox->yMax >>= 6; } } } return; } /* documentation is in ftglyph.h */ FT_EXPORT_DEF( FT_Error ) FT_Glyph_To_Bitmap( FT_Glyph* the_glyph, FT_Render_Mode render_mode, FT_Vector* origin, FT_Bool destroy ) { FT_GlyphSlotRec dummy; FT_GlyphSlot_InternalRec dummy_internal; FT_Error error = FT_Err_Ok; FT_Glyph glyph; FT_BitmapGlyph bitmap = NULL; const FT_Glyph_Class* clazz; /* check argument */ if ( !the_glyph ) goto Bad; /* we render the glyph into a glyph bitmap using a `dummy' glyph slot */ /* then calling FT_Render_Glyph_Internal() */ glyph = *the_glyph; if ( !glyph ) goto Bad; clazz = glyph->clazz; /* when called with a bitmap glyph, do nothing and return successfully */ if ( clazz == &ft_bitmap_glyph_class ) goto Exit; if ( !clazz || !clazz->glyph_prepare ) goto Bad; FT_MEM_ZERO( &dummy, sizeof ( dummy ) ); FT_MEM_ZERO( &dummy_internal, sizeof ( dummy_internal ) ); dummy.internal = &dummy_internal; dummy.library = glyph->library; dummy.format = clazz->glyph_format; /* create result bitmap glyph */ error = ft_new_glyph( glyph->library, &ft_bitmap_glyph_class, (FT_Glyph*)(void*)&bitmap ); if ( error ) goto Exit; #if 1 /* if `origin' is set, translate the glyph image */ if ( origin ) FT_Glyph_Transform( glyph, 0, origin ); #else FT_UNUSED( origin ); #endif /* prepare dummy slot for rendering */ error = clazz->glyph_prepare( glyph, &dummy ); if ( !error ) error = FT_Render_Glyph_Internal( glyph->library, &dummy, render_mode ); #if 1 if ( !destroy && origin ) { FT_Vector v; v.x = -origin->x; v.y = -origin->y; FT_Glyph_Transform( glyph, 0, &v ); } #endif if ( error ) goto Exit; /* in case of success, copy the bitmap to the glyph bitmap */ error = ft_bitmap_glyph_init( (FT_Glyph)bitmap, &dummy ); if ( error ) goto Exit; /* copy advance */ bitmap->root.advance = glyph->advance; if ( destroy ) FT_Done_Glyph( glyph ); *the_glyph = FT_GLYPH( bitmap ); Exit: if ( error && bitmap ) FT_Done_Glyph( FT_GLYPH( bitmap ) ); return error; Bad: error = FT_Err_Invalid_Argument; goto Exit; } /* documentation is in ftglyph.h */ FT_EXPORT_DEF( void ) FT_Done_Glyph( FT_Glyph glyph ) { if ( glyph ) { FT_Memory memory = glyph->library->memory; const FT_Glyph_Class* clazz = glyph->clazz; if ( clazz->glyph_done ) clazz->glyph_done( glyph ); FT_FREE( glyph ); } } /* END */ --- NEW FILE: ftoutln.c --- /***************************************************************************/ /* */ /* ftoutln.c */ /* */ /* FreeType outline management (body). */ /* */ /* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ /*************************************************************************/ /* */ /* All functions are declared in freetype.h. */ /* */ /*************************************************************************/ #include <ft2build.h> #include FT_OUTLINE_H #include FT_INTERNAL_OBJECTS_H #include FT_TRIGONOMETRY_H /*************************************************************************/ /* */ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ /* messages during execution. */ /* */ #undef FT_COMPONENT #define FT_COMPONENT trace_outline static const FT_Outline null_outline = { 0, 0, 0, 0, 0, 0 }; /* documentation is in ftoutln.h */ FT_EXPORT_DEF( FT_Error ) FT_Outline_Decompose( FT_Outline* outline, const FT_Outline_Funcs* func_interface, void* user ) { #undef SCALED #define SCALED( x ) ( ( (x) << shift ) - delta ) FT_Vector v_last; FT_Vector v_control; FT_Vector v_start; FT_Vector* point; FT_Vector* limit; char* tags; FT_Error error; FT_Int n; /* index of contour in outline */ FT_UInt first; /* index of first point in contour */ FT_Int tag; /* current point's state */ FT_Int shift; FT_Pos delta; if ( !outline || !func_interface ) return FT_Err_Invalid_Argument; shift = func_interface->shift; delta = func_interface->delta; first = 0; for ( n = 0; n < outline->n_contours; n++ ) { FT_Int last; /* index of last point in contour */ last = outline->contours[n]; limit = outline->points + last; v_start = outline->points[first]; v_last = outline->points[last]; v_start.x = SCALED( v_start.x ); v_start.y = SCALED( v_start.y ); v_last.x = SCALED( v_last.x ); v_last.y = SCALED( v_last.y ); v_control = v_start; point = outline->points + first; tags = outline->tags + first; tag = FT_CURVE_TAG( tags[0] ); /* A contour cannot start with a cubic control point! */ if ( tag == FT_CURVE_TAG_CUBIC ) goto Invalid_Outline; /* check first point to determine origin */ if ( tag == FT_CURVE_TAG_CONIC ) { /* first point is conic control. Yes, this happens. */ if ( FT_CURVE_TAG( outline->tags[last] ) == FT_CURVE_TAG_ON ) { /* start at last point if it is on the curve */ v_start = v_last; limit--; } else { /* if both first and last points are conic, */ /* start at their middle and record its position */ /* for closure */ v_start.x = ( v_start.x + v_last.x ) / 2; v_start.y = ( v_start.y + v_last.y ) / 2; v_last = v_start; } point--; tags--; } error = func_interface->move_to( &v_start, user ); if ( error ) goto Exit; while ( point < limit ) { point++; tags++; tag = FT_CURVE_TAG( tags[0] ); switch ( tag ) { case FT_CURVE_TAG_ON: /* emit a single line_to */ { FT_Vector vec; vec.x = SCALED( point->x ); vec.y = SCALED( point->y ); error = func_interface->line_to( &vec, user ); if ( error ) goto Exit; continue; } case FT_CURVE_TAG_CONIC: /* consume conic arcs */ v_control.x = SCALED( point->x ); v_control.y = SCALED( point->y ); Do_Conic: if ( point < limit ) { FT_Vector vec; FT_Vector v_middle; point++; tags++; tag = FT_CURVE_TAG( tags[0] ); vec.x = SCALED( point->x ); vec.y = SCALED( point->y ); if ( tag == FT_CURVE_TAG_ON ) { error = func_interface->conic_to( &v_control, &vec, user ); if ( error ) goto Exit; continue; } if ( tag != FT_CURVE_TAG_CONIC ) goto Invalid_Outline; v_middle.x = ( v_control.x + vec.x ) / 2; v_middle.y = ( v_control.y + vec.y ) / 2; error = func_interface->conic_to( &v_control, &v_middle, user ); if ( error ) goto Exit; v_control = vec; goto Do_Conic; } error = func_interface->conic_to( &v_control, &v_start, user ); goto Close; default: /* FT_CURVE_TAG_CUBIC */ { FT_Vector vec1, vec2; if ( point + 1 > limit || FT_CURVE_TAG( tags[1] ) != FT_CURVE_TAG_CUBIC ) goto Invalid_Outline; point += 2; tags += 2; vec1.x = SCALED( point[-2].x ); vec1.y = SCALED( point[-2].y ); vec2.x = SCALED( point[-1].x ); vec2.y = SCALED( point[-1].y ); if ( point <= limit ) { FT_Vector vec; vec.x = SCALED( point->x ); vec.y = SCALED( point->y ); error = func_interface->cubic_to( &vec1, &vec2, &vec, user ); if ( error ) goto Exit; continue; } error = func_interface->cubic_to( &vec1, &vec2, &v_start, user ); goto Close; } } } /* close the contour with a line segment */ error = func_interface->line_to( &v_start, user ); Close: if ( error ) goto Exit; first = last + 1; } return 0; Exit: return error; Invalid_Outline: return FT_Err_Invalid_Outline; } FT_EXPORT_DEF( FT_Error ) FT_Outline_New_Internal( FT_Memory memory, FT_UInt numPoints, FT_Int numContours, FT_Outline *anoutline ) { FT_Error error; if ( !anoutline || !memory ) return FT_Err_Invalid_Argument; *anoutline = null_outline; if ( FT_NEW_ARRAY( anoutline->points, numPoints * 2L ) || FT_NEW_ARRAY( anoutline->tags, numPoints ) || FT_NEW_ARRAY( anoutline->contours, numContours ) ) goto Fail; anoutline->n_points = (FT_UShort)numPoints; anoutline->n_contours = (FT_Short)numContours; anoutline->flags |= FT_OUTLINE_OWNER; return FT_Err_Ok; Fail: anoutline->flags |= FT_OUTLINE_OWNER; FT_Outline_Done_Internal( memory, anoutline ); return error; } /* documentation is in ftoutln.h */ FT_EXPORT_DEF( FT_Error ) FT_Outline_New( FT_Library library, FT_UInt numPoints, FT_Int numContours, FT_Outline *anoutline ) { if ( !library ) return FT_Err_Invalid_Library_Handle; return FT_Outline_New_Internal( library->memory, numPoints, numContours, anoutline ); } /* documentation is in ftoutln.h */ FT_EXPORT_DEF( FT_Error ) FT_Outline_Check( FT_Outline* outline ) { if ( outline ) { FT_Int n_points = outline->n_points; FT_Int n_contours = outline->n_contours; FT_Int end0, end; FT_Int n; /* empty glyph? */ if ( n_points == 0 && n_contours == 0 ) return 0; /* check point and contour counts */ if ( n_points <= 0 || n_contours <= 0 ) goto Bad; end0 = end = -1; for ( n = 0; n < n_contours; n++ ) { end = outline->contours[n]; /* note that we don't accept empty contours */ if ( end <= end0 || end >= n_points ) goto Bad; end0 = end; } if ( end != n_points - 1 ) goto Bad; /* XXX: check the tags array */ return 0; } Bad: return FT_Err_Invalid_Argument; } /* documentation is in ftoutln.h */ FT_EXPORT_DEF( FT_Error ) FT_Outline_Copy( const FT_Outline* source, FT_Outline *target ) { FT_Int is_owner; if ( !source || !target || source->n_points != target->n_points || source->n_contours != target->n_contours ) return FT_Err_Invalid_Argument; if ( source == target ) return FT_Err_Ok; FT_ARRAY_COPY( target->points, source->points, source->n_points ); FT_ARRAY_COPY( target->tags, source->tags, source->n_points ); FT_ARRAY_COPY( target->contours, source->contours, source->n_contours ); /* copy all flags, except the `FT_OUTLINE_OWNER' one */ is_owner = target->flags & FT_OUTLINE_OWNER; target->flags = source->flags; target->flags &= ~FT_OUTLINE_OWNER; target->flags |= is_owner; return FT_Err_Ok; } FT_EXPORT_DEF( FT_Error ) FT_Outline_Done_Internal( FT_Memory memory, FT_Outline* outline ) { if ( memory && outline ) { if ( outline->flags & FT_OUTLINE_OWNER ) { FT_FREE( outline->points ); FT_FREE( outline->tags ); FT_FREE( outline->contours ); } *outline = null_outline; return FT_Err_Ok; } else return FT_Err_Invalid_Argument; } /* documentation is in ftoutln.h */ FT_EXPORT_DEF( FT_Error ) FT_Outline_Done( FT_Library library, FT_Outline* outline ) { /* check for valid `outline' in FT_Outline_Done_Internal() */ if ( !library ) return FT_Err_Invalid_Library_Handle; return FT_Outline_Done_Internal( library->memory, outline ); } /* documentation is in ftoutln.h */ FT_EXPORT_DEF( void ) FT_Outline_Get_CBox( const FT_Outline* outline, FT_BBox *acbox ) { FT_Pos xMin, yMin, xMax, yMax; if ( outline && acbox ) { if ( outline->n_points == 0 ) { xMin = 0; yMin = 0; xMax = 0; yMax = 0; } else { FT_Vector* vec = outline->points; FT_Vector* limit = vec + outline->n_points; xMin = xMax = vec->x; yMin = yMax = vec->y; vec++; for ( ; vec < limit; vec++ ) { FT_Pos x, y; x = vec->x; if ( x < xMin ) xMin = x; if ( x > xMax ) xMax = x; y = vec->y; if ( y < yMin ) yMin = y; if ( y > yMax ) yMax = y; } } acbox->xMin = xMin; acbox->xMax = xMax; acbox->yMin = yMin; acbox->yMax = yMax; } } /* documentation is in ftoutln.h */ FT_EXPORT_DEF( void ) FT_Outline_Translate( const FT_Outline* outline, FT_Pos xOffset, FT_Pos yOffset ) { FT_UShort n; FT_Vector* vec = outline->points; if ( !outline ) return; for ( n = 0; n < outline->n_points; n++ ) { vec->x += xOffset; vec->y += yOffset; vec++; } } /* documentation is in ftoutln.h */ FT_EXPORT_DEF( void ) FT_Outline_Reverse( FT_Outline* outline ) { FT_UShort n; FT_Int first, last; if ( !outline ) return; first = 0; for ( n = 0; n < outline->n_contours; n++ ) { last = outline->contours[n]; /* reverse point table */ { FT_Vector* p = outline->points + first; FT_Vector* q = outline->points + last; FT_Vector swap; while ( p < q ) { swap = *p; *p = *q; *q = swap; p++; q--; } } /* reverse tags table */ { char* p = outline->tags + first; char* q = outline->tags + last; char swap; while ( p < q ) { swap = *p; *p = *q; *q = swap; p++; q--; } } first = last + 1; } outline->flags ^= FT_OUTLINE_REVERSE_FILL; } /* documentation is in ftoutln.h */ FT_EXPORT_DEF( FT_Error ) FT_Outline_Render( FT_Library library, FT_Outline* outline, FT_Raster_Params* params ) { FT_Error error; FT_Bool update = 0; FT_Renderer renderer; FT_ListNode node; if ( !library ) return FT_Err_Invalid_Library_Handle; if ( !outline || !params ) return FT_Err_Invalid_Argument; renderer = library->cur_renderer; node = library->renderers.head; params->source = (void*)outline; error = FT_Err_Cannot_Render_Glyph; while ( renderer ) { error = renderer->raster_render( renderer->raster, params ); if ( !error || FT_ERROR_BASE( error ) != FT_Err_Cannot_Render_Glyph ) break; /* FT_Err_Cannot_Render_Glyph is returned if the render mode */ /* is unsupported by the current renderer for this glyph image */ /* format */ /* now, look for another renderer that supports the same */ /* format */ renderer = FT_Lookup_Renderer( library, FT_GLYPH_FORMAT_OUTLINE, &node ); update = 1; } /* if we changed the current renderer for the glyph image format */ /* we need to select it as the next current one */ if ( !error && update && renderer ) FT_Set_Renderer( library, renderer, 0, 0 ); return error; } /* documentation is in ftoutln.h */ FT_EXPORT_DEF( FT_Error ) FT_Outline_Get_Bitmap( FT_Library library, FT_Outline* outline, const FT_Bitmap *abitmap ) { FT_Raster_Params params; if ( !abitmap ) return FT_Err_Invalid_Argument; /* other checks are delayed to FT_Outline_Render() */ params.target = abitmap; params.flags = 0; if ( abitmap->pixel_mode == FT_PIXEL_MODE_GRAY || abitmap->pixel_mode == FT_PIXEL_MODE_LCD || abitmap->pixel_mode == FT_PIXEL_MODE_LCD_V ) params.flags |= FT_RASTER_FLAG_AA; return FT_Outline_Render( library, outline, ¶ms ); } /* documentation is in ftoutln.h */ FT_EXPORT_DEF( void ) FT_Vector_Transform( FT_Vector* vector, const FT_Matrix* matrix ) { FT_Pos xz, yz; if ( !vector || !matrix ) return; xz = FT_MulFix( vector->x, matrix->xx ) + FT_MulFix( vector->y, matrix->xy ); yz = FT_MulFix( vector->x, matrix->yx ) + FT_MulFix( vector->y, matrix->yy ); vector->x = xz; vector->y = yz; } /* documentation is in ... [truncated message content] |
From: Ehud S. <esh...@us...> - 2006-04-21 16:22:39
|
Update of /cvsroot/roadmap/roadmap_editor/src/freetype/include/freetype/internal/services In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22848/include/freetype/internal/services Added Files: svbdf.h svgldict.h svmm.h svotval.h svpfr.h svpostnm.h svpscmap.h svpsinfo.h svsfnt.h svttcmap.h svwinfnt.h svxf86nm.h Log Message: Import freetype sources. --- NEW FILE: svsfnt.h --- /***************************************************************************/ /* */ /* svsfnt.h */ /* */ /* The FreeType SFNT table loading service (specification). */ /* */ /* Copyright 2003, 2004 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __SVSFNT_H__ #define __SVSFNT_H__ #include FT_INTERNAL_SERVICE_H #include FT_TRUETYPE_TABLES_H FT_BEGIN_HEADER /* * SFNT table loading service. */ #define FT_SERVICE_ID_SFNT_TABLE "sfnt-table" /* * Used to implement FT_Load_Sfnt_Table(). */ typedef FT_Error (*FT_SFNT_TableLoadFunc)( FT_Face face, FT_ULong tag, FT_Long offset, FT_Byte* buffer, FT_ULong* length ); /* * Used to implement FT_Get_Sfnt_Table(). */ typedef void* (*FT_SFNT_TableGetFunc)( FT_Face face, FT_Sfnt_Tag tag ); /* * Used to implement FT_Sfnt_Table_Info(). */ typedef FT_Error (*FT_SFNT_TableInfoFunc)( FT_Face face, FT_UInt idx, FT_ULong *tag, FT_ULong *length ); FT_DEFINE_SERVICE( SFNT_Table ) { FT_SFNT_TableLoadFunc load_table; FT_SFNT_TableGetFunc get_table; FT_SFNT_TableInfoFunc table_info; }; /* */ FT_END_HEADER #endif /* __SVSFNT_H__ */ /* END */ --- NEW FILE: svxf86nm.h --- /***************************************************************************/ /* */ /* svxf86nm.h */ /* */ /* The FreeType XFree86 services (specification only). */ /* */ /* Copyright 2003 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __SVXF86NM_H__ #define __SVXF86NM_H__ #include FT_INTERNAL_SERVICE_H FT_BEGIN_HEADER /* * A trivial service used to return the name of a face's font driver, * according to the XFree86 nomenclature. Note that the service data * is a simple constant string pointer. */ #define FT_SERVICE_ID_XF86_NAME "xf86-driver-name" #define FT_XF86_FORMAT_TRUETYPE "TrueType" #define FT_XF86_FORMAT_TYPE_1 "Type 1" #define FT_XF86_FORMAT_BDF "BDF" #define FT_XF86_FORMAT_PCF "PCF" #define FT_XF86_FORMAT_TYPE_42 "Type 42" #define FT_XF86_FORMAT_CID "CID Type 1" #define FT_XF86_FORMAT_CFF "CFF" #define FT_XF86_FORMAT_PFR "PFR" #define FT_XF86_FORMAT_WINFNT "Windows FNT" /* */ FT_END_HEADER #endif /* __SVXF86NM_H__ */ /* END */ --- NEW FILE: svpscmap.h --- /***************************************************************************/ /* */ /* svpscmap.h */ /* */ /* The FreeType PostScript charmap service (specification). */ /* */ /* Copyright 2003 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __SVPSCMAP_H__ #define __SVPSCMAP_H__ FT_BEGIN_HEADER #define FT_SERVICE_ID_POSTSCRIPT_CMAPS "postscript-cmaps" /* * Adobe glyph name to unicode value */ typedef FT_UInt32 (*PS_Unicode_ValueFunc)( const char* glyph_name ); /* * Unicode value to Adobe glyph name index. 0xFFFF if not found. */ typedef FT_UInt (*PS_Unicode_Index_Func)( FT_UInt num_glyphs, const char** glyph_names, FT_ULong unicode ); /* * Macintosh name id to glyph name. NULL if invalid index. */ typedef const char* (*PS_Macintosh_Name_Func)( FT_UInt name_index ); /* * Adobe standard string ID to glyph name. NULL if invalid index. */ typedef const char* (*PS_Adobe_Std_Strings_Func)( FT_UInt string_index ); /* * Simple unicode -> glyph index charmap built from font glyph names * table. */ typedef struct PS_UniMap_ { FT_UInt unicode; FT_UInt glyph_index; } PS_UniMap; typedef struct PS_Unicodes_ { FT_UInt num_maps; PS_UniMap* maps; } PS_Unicodes; typedef FT_Error (*PS_Unicodes_InitFunc)( FT_Memory memory, FT_UInt num_glyphs, const char** glyph_names, PS_Unicodes* unicodes ); typedef FT_UInt (*PS_Unicodes_CharIndexFunc)( PS_Unicodes* unicodes, FT_UInt unicode ); typedef FT_ULong (*PS_Unicodes_CharNextFunc)( PS_Unicodes* unicodes, FT_ULong unicode ); FT_DEFINE_SERVICE( PsCMaps ) { PS_Unicode_ValueFunc unicode_value; PS_Unicodes_InitFunc unicodes_init; PS_Unicodes_CharIndexFunc unicodes_char_index; PS_Unicodes_CharNextFunc unicodes_char_next; PS_Macintosh_Name_Func macintosh_name; PS_Adobe_Std_Strings_Func adobe_std_strings; const unsigned short* adobe_std_encoding; const unsigned short* adobe_expert_encoding; }; /* */ FT_END_HEADER #endif /* __SVPSCMAP_H__ */ /* END */ --- NEW FILE: svpsinfo.h --- /***************************************************************************/ /* */ /* svpsinfo.h */ /* */ /* The FreeType PostScript info service (specification). */ /* */ /* Copyright 2003, 2004 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __SVPSINFO_H__ #define __SVPSINFO_H__ #include FT_INTERNAL_SERVICE_H #include FT_INTERNAL_TYPE1_TYPES_H FT_BEGIN_HEADER #define FT_SERVICE_ID_POSTSCRIPT_INFO "postscript-info" typedef FT_Error (*PS_GetFontInfoFunc)( FT_Face face, PS_FontInfoRec* afont_info ); typedef FT_Int (*PS_HasGlyphNamesFunc)( FT_Face face ); typedef FT_Error (*PS_GetFontPrivateFunc)( FT_Face face, PS_PrivateRec* afont_private ); FT_DEFINE_SERVICE( PsInfo ) { PS_GetFontInfoFunc ps_get_font_info; PS_HasGlyphNamesFunc ps_has_glyph_names; PS_GetFontPrivateFunc ps_get_font_private; }; /* */ FT_END_HEADER #endif /* __SVPSINFO_H__ */ /* END */ --- NEW FILE: svttcmap.h --- /***************************************************************************/ /* */ /* svsttcmap.h */ /* */ /* The FreeType TrueType/sfnt cmap extra information service. */ /* */ /* Copyright 2003 by */ /* Masatake YAMATO, Redhat K.K. */ /* */ /* Copyright 2003 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ /* Development of this service is support of Information-technology Promotion Agency, Japan. */ #ifndef __SVTTCMAP_H__ #define __SVTTCMAP_H__ #include FT_INTERNAL_SERVICE_H #include FT_TRUETYPE_TABLES_H FT_BEGIN_HEADER #define FT_SERVICE_ID_TT_CMAP "tt-cmaps" /*************************************************************************/ /* */ /* <Struct> */ /* TT_CMapInfo */ /* */ /* <Description> */ /* A structure used to store TrueType/sfnt specific cmap information */ /* which is not covered by the generic @FT_CharMap structure. This */ /* structure can be accessed with the @FT_Get_TT_CMap_Info function. */ /* */ /* <Fields> */ /* language :: */ /* The language ID used in Mac fonts. Definitions of values are in */ /* freetype/ttnameid.h. */ /* */ typedef struct TT_CMapInfo_ { FT_ULong language; } TT_CMapInfo; typedef FT_Error (*TT_CMap_Info_GetFunc)( FT_CharMap charmap, TT_CMapInfo *cmap_info ); FT_DEFINE_SERVICE( TTCMaps ) { TT_CMap_Info_GetFunc get_cmap_info; }; /* */ FT_END_HEADER #endif /* __SVTTCMAP_H__ */ /* END */ --- NEW FILE: svpostnm.h --- /***************************************************************************/ /* */ /* svpostnm.h */ /* */ /* The FreeType PostScript name services (specification). */ /* */ /* Copyright 2003 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __SVPOSTNM_H__ #define __SVPOSTNM_H__ #include FT_INTERNAL_SERVICE_H FT_BEGIN_HEADER /* * A trivial service used to retrieve the PostScript name of a given * font when available. The `get_name' field should never be NULL. * * The correponding function can return NULL to indicate that the * PostScript name is not available. * * The name is owned by the face and will be destroyed with it. */ #define FT_SERVICE_ID_POSTSCRIPT_FONT_NAME "postscript-font-name" typedef const char* (*FT_PsName_GetFunc)( FT_Face face ); FT_DEFINE_SERVICE( PsFontName ) { FT_PsName_GetFunc get_ps_font_name; }; /* */ FT_END_HEADER #endif /* __SVPOSTNM_H__ */ /* END */ --- NEW FILE: svwinfnt.h --- /***************************************************************************/ /* */ /* svwinfnt.h */ /* */ /* The FreeType Windows FNT/FONT service (specification). */ /* */ /* Copyright 2003 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __SVWINFNT_H__ #define __SVWINFNT_H__ #include FT_INTERNAL_SERVICE_H #include FT_WINFONTS_H FT_BEGIN_HEADER #define FT_SERVICE_ID_WINFNT "winfonts" typedef FT_Error (*FT_WinFnt_GetHeaderFunc)( FT_Face face, FT_WinFNT_HeaderRec *aheader ); FT_DEFINE_SERVICE( WinFnt ) { FT_WinFnt_GetHeaderFunc get_header; }; /* */ FT_END_HEADER #endif /* __SVWINFNT_H__ */ /* END */ --- NEW FILE: svbdf.h --- /***************************************************************************/ /* */ /* svbdf.h */ /* */ /* The FreeType BDF services (specification). */ /* */ /* Copyright 2003 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __SVBDF_H__ #define __SVBDF_H__ #include FT_BDF_H #include FT_INTERNAL_SERVICE_H FT_BEGIN_HEADER #define FT_SERVICE_ID_BDF "bdf" typedef FT_Error (*FT_BDF_GetCharsetIdFunc)( FT_Face face, const char* *acharset_encoding, const char* *acharset_registry ); typedef FT_Error (*FT_BDF_GetPropertyFunc)( FT_Face face, const char* prop_name, BDF_PropertyRec *aproperty ); FT_DEFINE_SERVICE( BDF ) { FT_BDF_GetCharsetIdFunc get_charset_id; FT_BDF_GetPropertyFunc get_property; }; /* */ FT_END_HEADER #endif /* __SVBDF_H__ */ /* END */ --- NEW FILE: svmm.h --- /***************************************************************************/ /* */ /* svmm.h */ /* */ /* The FreeType Multiple Masters and GX var services (specification). */ /* */ /* Copyright 2003, 2004 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __SVMM_H__ #define __SVMM_H__ #include FT_INTERNAL_SERVICE_H FT_BEGIN_HEADER /* * A service used to manage multiple-masters data in a given face. * * See the related APIs in `ftmm.h' (FT_MULTIPLE_MASTERS_H). * */ #define FT_SERVICE_ID_MULTI_MASTERS "multi-masters" typedef FT_Error (*FT_Get_MM_Func)( FT_Face face, FT_Multi_Master* master ); typedef FT_Error (*FT_Get_MM_Var_Func)( FT_Face face, FT_MM_Var* *master ); typedef FT_Error (*FT_Set_MM_Design_Func)( FT_Face face, FT_UInt num_coords, FT_Long* coords ); typedef FT_Error (*FT_Set_Var_Design_Func)( FT_Face face, FT_UInt num_coords, FT_Fixed* coords ); typedef FT_Error (*FT_Set_MM_Blend_Func)( FT_Face face, FT_UInt num_coords, FT_Long* coords ); FT_DEFINE_SERVICE( MultiMasters ) { FT_Get_MM_Func get_mm; FT_Set_MM_Design_Func set_mm_design; FT_Set_MM_Blend_Func set_mm_blend; FT_Get_MM_Var_Func get_mm_var; FT_Set_Var_Design_Func set_var_design; }; /* */ FT_END_HEADER #endif /* __SVMM_H__ */ /* END */ --- NEW FILE: svotval.h --- /***************************************************************************/ /* */ /* svotval.h */ /* */ /* The FreeType OpenType validation service (specification). */ /* */ /* Copyright 2004 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __SVOTVAL_H__ #define __SVOTVAL_H__ FT_BEGIN_HEADER #define FT_SERVICE_ID_OPENTYPE_VALIDATE "opentype-validate" typedef FT_Error (*otv_validate_func)( FT_Face face, FT_UInt ot_flags, FT_Bytes *base, FT_Bytes *gdef, FT_Bytes *gpos, FT_Bytes *gsub, FT_Bytes *jstf ); FT_DEFINE_SERVICE( OTvalidate ) { otv_validate_func validate; }; /* */ FT_END_HEADER #endif /* __SVOTVAL_H__ */ /* END */ --- NEW FILE: svpfr.h --- /***************************************************************************/ /* */ /* svpfr.h */ /* */ /* Internal PFR service functions (specification). */ /* */ /* Copyright 2003 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __SVPFR_H__ #define __SVPFR_H__ #include FT_INTERNAL_SERVICE_H FT_BEGIN_HEADER #define FT_SERVICE_ID_PFR_METRICS "pfr-metrics" typedef FT_Error (*FT_PFR_GetMetricsFunc)( FT_Face face, FT_UInt *aoutline, FT_UInt *ametrics, FT_Fixed *ax_scale, FT_Fixed *ay_scale ); typedef FT_Error (*FT_PFR_GetKerningFunc)( FT_Face face, FT_UInt left, FT_UInt right, FT_Vector *avector ); typedef FT_Error (*FT_PFR_GetAdvanceFunc)( FT_Face face, FT_UInt gindex, FT_Pos *aadvance ); FT_DEFINE_SERVICE( PfrMetrics ) { FT_PFR_GetMetricsFunc get_metrics; FT_PFR_GetKerningFunc get_kerning; FT_PFR_GetAdvanceFunc get_advance; }; /* */ FT_END_HEADER #endif /* __SVPFR_H__ */ /* END */ --- NEW FILE: svgldict.h --- /***************************************************************************/ /* */ /* svgldict.h */ /* */ /* The FreeType glyph dictionary services (specification). */ /* */ /* Copyright 2003 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ /* modified, and distributed under the terms of the FreeType project */ /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ /* this file you indicate that you have read the license and */ /* understand and accept it fully. */ /* */ /***************************************************************************/ #ifndef __SVGLDICT_H__ #define __SVGLDICT_H__ #include FT_INTERNAL_SERVICE_H FT_BEGIN_HEADER /* * A service used to retrieve glyph names, as well as to find the * index of a given glyph name in a font. * */ #define FT_SERVICE_ID_GLYPH_DICT "glyph-dict" typedef FT_Error (*FT_GlyphDict_GetNameFunc)( FT_Face face, FT_UInt glyph_index, FT_Pointer buffer, FT_UInt buffer_max ); typedef FT_UInt (*FT_GlyphDict_NameIndexFunc)( FT_Face face, FT_String* glyph_name ); FT_DEFINE_SERVICE( GlyphDict ) { FT_GlyphDict_GetNameFunc get_name; FT_GlyphDict_NameIndexFunc name_index; /* optional */ }; /* */ FT_END_HEADER #endif /* __SVGLDICT_H__ */ |