1 /************************************************************************/ 2 /* */ 3 /* Data structures that describe postscript fonts. */ 4 /* */ 5 /************************************************************************/ 6 7 # ifndef PS_FONT_INFO_H 8 # define PS_FONT_INFO_H 9 10 # include <geo2DInteger.h> 11 # include <utilIndexSet.h> 12 # include <utilIndexMapping.h> 13 # include <utilMemoryBuffer.h> 14 15 # define SCAPS_SIZE( sz ) ( 8*(sz)/10 ) 16 # define SUPERSUB_SIZE( sz ) ( 6*(sz)/10 ) 17 18 # define PSflagDEFER_METRICS 0x01 19 # define PSflagIGNORE_KERNING 0x02 20 21 /************************************************************************/ 22 /* */ 23 /* Information extracted from an AFM file. (Or directly from a font) */ 24 /* */ 25 /* The afm file format suggests that a font is a mapping from glyph */ 26 /* to code point while both type1 fonts and TTF fonts actually work */ 27 /* the other way: They have a collection of glyphs and the encoding */ 28 /* maps a code point to the glyph. */ 29 /* */ 30 /* Bounding boxes are vertically oriented in the numeric orientation */ 31 /* of the numbers. I.E: Bottom:drY0, Top:drY1. */ 32 /* */ 33 /************************************************************************/ 34 35 typedef struct AfmKerningPair 36 { 37 short int akpPosition; 38 short int akpXVec; 39 } AfmKerningPair; 40 41 typedef struct AfmCodeList 42 { 43 unsigned short int * aclCodes; 44 int aclCodeCount; 45 } AfmCodeList; 46 47 typedef struct AfmCharMetric 48 { 49 AfmCodeList acmDefaultCodeList; 50 AfmCodeList acmUnicodeCodeList; 51 /************************************/ 52 /* Potentially empty array of code */ 53 /* points associated to this glyph.*/ 54 /* This is because it is possible */ 55 /* to map more than one code point */ 56 /* in the default encoding to the */ 57 /* same glyph. */ 58 /* Only values < 256 are saved to */ 59 /* the afm file. */ 60 /************************************/ 61 62 short int acmWX; 63 DocumentRectangle acmBBox; 64 char * acmN; 65 short int acmGlyphIndex; 66 /************************************/ 67 /* Index of the glyph in the font. */ 68 /************************************/ 69 AfmKerningPair * acmKernPairs; 70 short int acmKernPairCount; 71 } AfmCharMetric; 72 73 struct AfmFontInfo; 74 75 typedef int (*ResolveFontMetrics)( struct AfmFontInfo * afi ); 76 77 typedef struct AfmFontInfo 78 { 79 /********************************************/ 80 /* Must be unique in the font list. */ 81 /********************************************/ 82 int afiFaceNumber; 83 /********************************************/ 84 /* General font information. At least an */ 85 /* Approximation must be known while the */ 86 /* font catalog is made. */ 87 /********************************************/ 88 char * afiFontName; 89 char * afiFullName; 90 char * afiFamilyName; 91 char * afiFamilyName_Orig; 92 char * afiWeightStr; 93 short int afiWeightInt; 94 char * afiWidthStr; 95 short int afiWidthInt; 96 double afiItalicAngle; 97 double afiTanItalicAngle; 98 unsigned char afiIsFixedPitch; 99 100 char * afiNotice; 101 char * afiVersion; 102 103 /********************************************/ 104 /* Metrics information: Must be known as */ 105 /* soon as text is formatted. */ 106 /********************************************/ 107 int afiUnitsPerEm; 108 DocumentRectangle afiFontBBox; 109 int afiUnderlinePosition; 110 int afiUnderlineThickness; 111 int afiCapHeight; 112 int afiXHeight; 113 int afiAscender; 114 int afiDescender; 115 116 /********************************************/ 117 /* Glyph Metrics information: Must be */ 118 /* known as soon as text is formatted. */ 119 /********************************************/ 120 MemoryBuffer afiAfmFileName; 121 unsigned char afiMetricsDeferred; 122 unsigned char afiIgnoreKerning; 123 int afiMetricCount; 124 AfmCharMetric ** afiMetrics; 125 void * afiNameToMetric; 126 int afiFallbackGlyph; 127 128 /********************************************/ 129 /* Collected screen font information. */ 130 /********************************************/ 131 char ** afiX11Fonts; 132 int afiX11FontCount; 133 134 char * afiEncodingScheme; 135 char * afiCharacterSet; 136 char * afiVendor; 137 138 char * afiResourceName; 139 MemoryBuffer afiFontFileName; 140 int afiFontFileIndex; 141 142 IndexSet afiUnicodesProvided; 143 IndexMapping afiUnicodeToGlyphMapping; 144 /********************************************/ 145 /* Hacked screen related functionality. */ 146 /********************************************/ 147 char * afiStyle; 148 149 ResolveFontMetrics afiResolveMetrics; 150 } AfmFontInfo; 151 152 # define psFontHasUnicode( a, u ) \ 153 utilIndexSetContains( &((a)->afiUnicodesProvided), (u) ) 154 155 /************************************************************************/ 156 /* */ 157 /* Face information. */ 158 /* */ 159 /* Used to map a users idea of fonts to implementation fonts. */ 160 /* Used by the font chooser to select fonts. */ 161 /* */ 162 /* 1) Set width defines. The values math those in fontconfig. */ 163 /* 2) Set weight defines. The values math those in fontconfig. */ 164 /* */ 165 /************************************************************************/ 166 167 /* 1 */ 168 # define FONTwidthULTRACONDENSED 50 169 # define FONTwidthEXTRACONDENSED 63 170 # define FONTwidthCONDENSED 75 171 # define FONTwidthSEMICONDENSED 87 172 # define FONTwidthNORMAL 100 173 # define FONTwidthSEMIEXPANDED 113 174 # define FONTwidthEXPANDED 125 175 # define FONTwidthEXTRAEXPANDED 150 176 # define FONTwidthULTRAEXPANDED 200 177 178 # define FONTwidth_MIN FONTwidthULTRACONDENSED 179 # define FONTwidth_MAX FONTwidthULTRAEXPANDED 180 181 /* 2 */ 182 # define FONTweightTHIN 0 183 # define FONTweightEXTRALIGHT 40 184 # define FONTweightLIGHT 50 185 # define FONTweightBOOK 75 186 # define FONTweightREGULAR 80 187 # define FONTweightMEDIUM 100 188 # define FONTweightDEMIBOLD 180 189 # define FONTweightBOLD 200 190 # define FONTweightEXTRABOLD 205 191 # define FONTweightBLACK 210 192 193 # define FONTweightULTRALIGHT FONTweightEXTRALIGHT 194 # define FONTweightNORMAL FONTweightREGULAR 195 # define FONTweightSEMIBOLD FONTweightDEMIBOLD 196 # define FONTweightULTRABOLD FONTweightEXTRABOLD 197 # define FONTweightHEAVY FONTweightBLACK 198 199 # define FONTweight_MIN FONTweightTHIN 200 # define FONTweight_MAX FONTweightBLACK 201 202 /************************************************************************/ 203 204 # define FONT_IS_BOLD( afi ) ((afi)->afiWeightInt >= FONTweightDEMIBOLD ) 205 # define FONT_IS_SLANTED( afi ) ((afi)->afiItalicAngle < -1.0 ) 206 207 /************************************************************************/ 208 /* */ 209 /* Declarations. */ 210 /* */ 211 /************************************************************************/ 212 213 extern int psGetUnicodesFromGlyphNames( AfmFontInfo * afi ); 214 extern int psGetAlternateGlyphs( AfmFontInfo * afi ); 215 extern int psResolveFallbackGlyph( AfmFontInfo * afi ); 216 217 extern void psInitAfmFontInfo( AfmFontInfo * afi ); 218 extern void psCleanAfmFontInfo( AfmFontInfo * afi ); 219 extern void psFreeAfmFontInfo( AfmFontInfo * afi ); 220 extern void psRemoveMetricsFromInfo( AfmFontInfo * afi ); 221 222 extern int psFindAlternate( const AfmFontInfo * afi, 223 const char * glyphName ); 224 225 extern int psGetDeferredMetrics( AfmFontInfo * afi ); 226 227 extern int psFontInfoAddMetric( AfmFontInfo * afi, 228 int C, 229 int WX, 230 const char * N, 231 const DocumentRectangle * abb ); 232 233 extern int psFontInfoGetGlyphIndex( const AfmFontInfo * afi, 234 const char * glyphName ); 235 236 extern int psFontInfoSetGlyphName( AfmFontInfo * afi, 237 int glyphIndex, 238 const char * glyphName ); 239 240 extern const char * psFontInfoGetGlyphName( 241 const AfmFontInfo * afi, 242 int glyphIndex ); 243 244 extern int psFontInfoSetGlyphCode( AfmFontInfo * afi, 245 int glyphIndex, 246 int c ); 247 248 extern int psFontInfoSetGlyphUnicode( AfmFontInfo * afi, 249 int glyphIndex, 250 int c ); 251 252 extern int psAddX11FontToInfo( AfmFontInfo * afi, 253 const char * x11Font ); 254 255 extern int psMapVisibleNamesToBase35( AfmFontInfo * afi ); 256 257 # endif 258