1 /*-------------------------------------------------------------------------- 2 ----- File: t1types.h 3 ----- Author: Rainer Menzner (Rainer.Menzner@web.de) 4 ----- Date: 2001-06-04 5 ----- Description: This file is part of the t1-library. It contains 6 type definitions used by the t1-library. 7 ----- Copyright: t1lib is copyrighted (c) Rainer Menzner, 1996-2001. 8 As of version 0.5, t1lib is distributed under the 9 GNU General Public Library Lincense. The 10 conditions can be found in the files LICENSE and 11 LGPL, which should reside in the toplevel 12 directory of the distribution. Please note that 13 there are parts of t1lib that are subject to 14 other licenses: 15 The parseAFM-package is copyrighted by Adobe Systems 16 Inc. 17 The type1 rasterizer is copyrighted by IBM and the 18 X11-consortium. 19 ----- Warranties: Of course, there's NO WARRANTY OF ANY KIND :-) 20 ----- Credits: I want to thank IBM and the X11-consortium for making 21 their rasterizer freely available. 22 Also thanks to Piet Tutelaers for his ps2pk, from 23 which I took the rasterizer sources in a format 24 independent from X11. 25 Thanks to all people who make free software living! 26 --------------------------------------------------------------------------*/ 27 28 29 #define T1TYPES_H 30 31 32 typedef struct 33 { 34 int flags; 35 int chars; 36 int hkern; 37 } METRICS_ENTRY; 38 39 40 typedef struct 41 { 42 char *pFontFileName; /* Pointer to the font's filename */ 43 char *pAfmFileName; /* Pointer to the afm filename, IFF set explicitly */ 44 FontInfo *pAFMData; /* A pointer to a struct which gives access to all 45 the data contained in the .afm-file. If this 46 pointer is NULL, no .afm-file had been found. 47 => There's no advanced info on the font available. 48 */ 49 psfont *pType1Data; /* A pointer to a struct giving access to all 50 information contained in the .pfa/.pfb-file. This 51 is needed! */ 52 int *pEncMap; /* For fast mapping from charnames to encoding 53 indices */ 54 METRICS_ENTRY *pKernMap; /* dito */ 55 int KernMapSize; 56 char **pFontEnc; /* This is the pointer to the encoding array 57 associated with that particular font. If 58 FontEnc=NULL, it means the internal 59 (fontspecific) encoding is to be used. */ 60 char *vm_base; /* The base address of the virtual memory area for this 61 font. It must be stored in order to be able to realloc 62 and free those memory areas later. */ 63 void *pFontSizeDeps; /* This one points to a linked list of structures 64 which store all font size dependent data. */ 65 double FontMatrix[4]; /* Two matrices which store the font matrix and special 66 Transformation to be applied, such as slant and 67 extend or probably some rotation. */ 68 double FontTransform[4]; 69 float slant; /* A slant factor for the font */ 70 float extend; /* A extension factor for the font */ 71 float UndrLnPos; /* Parameters for ~lining rules */ 72 float UndrLnThick; 73 float OvrLnPos; 74 float OvrLnThick; 75 float OvrStrkPos; 76 float OvrStrkThick; 77 unsigned short physical; /* This entry is used to decide, whether a 78 font is associated with an own physical 79 fontfile, or whether it has been created 80 as a "logical" font by copying another 81 "physical" font. */ 82 unsigned short refcount; /* At load time this counter is set to 1. Every 83 time, a T1_CopyFont() is executed on this font, 84 this counter is incremented by 1. This gives 85 the possibility to decide whether a physical 86 font is used by some logical font. */ 87 short space_position; /* The position where "space" is encoded, is saved 88 in this entry. The space character needs special 89 treatment. Saving its position here yields faster 90 execution during rastering of strings with a 91 user-supplied space-offset! */ 92 short info_flags; /* Here some info may be stored */ 93 } FONTPRIVATE; 94 95 96 /* A structure representing a matrix */ 97 typedef struct 98 { 99 double cxx; 100 double cyx; 101 double cxy; 102 double cyy; 103 } T1_TMATRIX; 104 105 106 /* Following struct is used for storing all information for a particular 107 rendered character glyph */ 108 typedef struct 109 { 110 char *bits; /* A pointer to the characters local bitmap */ 111 struct /* A struct containing diverse metric information */ 112 { 113 int ascent; 114 int descent; 115 int leftSideBearing; 116 int rightSideBearing; 117 int advanceX; 118 int advanceY; 119 } metrics; 120 void *pFontCacheInfo; 121 unsigned long bpp; /* The number of bits that represent 1 pixel */ 122 } GLYPH; 123 124 125 126 /* Next comes the struct declaration for FontSizeDeps, which stores size 127 specific data of a font */ 128 typedef struct 129 { 130 GLYPH *pFontCache; /* Pointer to the cache area of this 131 font at this size */ 132 void *pNextFontSizeDeps; /* A pointer to the next size's 133 FontSizeDeps-structure. */ 134 void *pPrevFontSizeDeps; /* A pointer to the previous size's 135 FontSizeDeps-structure or NULL if 136 the current is the first. */ 137 struct XYspace *pCharSpaceLocal; /* This is a scaled version of the 138 global version for this font. */ 139 float size; /* The desired size, to be specified 140 in bp's. */ 141 int antialias; /* Switch for marking the current size 142 antialiased */ 143 } FONTSIZEDEPS; 144 145 146 147 /* A data that makes most important information available to user. */ 148 typedef struct 149 { 150 int width; /* The glyph's width */ 151 BBox bbox; /* The glyph's bounding box */ 152 int numchars; /* The number of characters in the glyph (string) */ 153 int *charpos; /* A pointer to an integer array were the horizontal 154 positions in (afm units) of the individual 155 characters in the string are stored */ 156 } METRICSINFO; 157 158 159 /* Handling of outlines: These definitions decouple from the type 1 rasterizers 160 def's and make the necessary stuff available to end users */ 161 162 #define FRACTBITS 16 /* number of fractional bits in 'fractpel' */ 163 /* From/to conversion of pels/fractpels */ 164 #define T1_TOPATHPOINT(p) (((long)p)<<FRACTBITS) 165 #define PPHALF (1<<(FRACTBITS-1)) 166 #define T1_NEARESTPOINT(fp) (((fp)+PPHALF)>>FRACTBITS) 167 168 /* A fractional point */ 169 typedef struct { 170 long x; 171 long y; 172 } T1_PATHPOINT; 173 174 175 /* A straight outline segment, stroked or not stroked */ 176 typedef struct pathsegment { 177 char type; /* type of segment (line or move) */ 178 unsigned char flag; /* type1 rasterizer internal stuff */ 179 short references; /* type1 rasterizer internal stuff */ 180 unsigned char size; /* size of the structure */ 181 unsigned char context; /* index to device context */ 182 struct pathsegment *link; /* pointer to next structure in linked list */ 183 struct pathsegment *last; /* pointer to last structure in list */ 184 T1_PATHPOINT dest; /* relative ending location of path segment */ 185 } T1_PATHSEGMENT; 186 187 /* A third order bezier segment */ 188 typedef struct bezierpathsegment { 189 char type; /* type of segment (bezier) */ 190 unsigned char flag; /* type1 rasterizer internal stuff */ 191 short references; /* type1 rasterizer internal stuff */ 192 unsigned char size; /* as with any 'segment' type */ 193 unsigned char context; /* as with any 'segment' type */ 194 T1_PATHSEGMENT *link; /* as with any 'segment' type */ 195 T1_PATHSEGMENT *last; /* as with any 'segment' type */ 196 T1_PATHPOINT dest; /* ending point (D) */ 197 T1_PATHPOINT B; /* control point B */ 198 T1_PATHPOINT C; /* control point C */ 199 } T1_BEZIERSEGMENT; 200 201 typedef T1_PATHSEGMENT T1_OUTLINE; 202 203 204 /* Two structures for handling composite character data */ 205 /* One structure for each symbol of the composite character */ 206 typedef struct 207 { 208 int piece; /* the index of the current symbol */ 209 int deltax; /* horizontal displacement of current symbol in CS */ 210 int deltay; /* vertical displacement of current symbol in CS */ 211 } T1_COMP_PIECE; 212 213 /* This one defines the composite character, the number of pieces and how to 214 access their data. */ 215 typedef struct 216 { 217 int compchar; /* the base character in the current encoding */ 218 int numPieces; /* the number of defined pieces including the base char */ 219 T1_COMP_PIECE *pieces; /* a pointer to the pieces' information */ 220 } T1_COMP_CHAR_INFO; 221 222