| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | #ifndef FONTSTR_H |
| 25 | #define FONTSTR_H |
| 26 | |
| 27 | #include <X11/Xproto.h> |
| 28 | #include "font.h" |
| 29 | #include <X11/Xfuncproto.h> |
| 30 | #include <X11/Xdefs.h> |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | #define GLYPHPADOPTIONS 4 |
| 40 | |
| 41 | typedef struct _FontProp { |
| 42 | long name; |
| 43 | long value; |
| 44 | } FontPropRec; |
| 45 | |
| 46 | typedef struct _FontResolution { |
| 47 | unsigned short x_resolution; |
| 48 | unsigned short y_resolution; |
| 49 | unsigned short point_size; |
| 50 | } FontResolutionRec; |
| 51 | |
| 52 | typedef struct _ExtentInfo { |
| 53 | DrawDirection drawDirection; |
| 54 | int fontAscent; |
| 55 | int fontDescent; |
| 56 | int overallAscent; |
| 57 | int overallDescent; |
| 58 | int overallWidth; |
| 59 | int overallLeft; |
| 60 | int overallRight; |
| 61 | } ExtentInfoRec; |
| 62 | |
| 63 | typedef struct _CharInfo { |
| 64 | xCharInfo metrics; |
| 65 | char *bits; |
| 66 | } CharInfoRec; |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | typedef struct _FontInfo { |
| 74 | unsigned short firstCol; |
| 75 | unsigned short lastCol; |
| 76 | unsigned short firstRow; |
| 77 | unsigned short lastRow; |
| 78 | unsigned short defaultCh; |
| 79 | unsigned int noOverlap:1; |
| 80 | unsigned int terminalFont:1; |
| 81 | unsigned int constantMetrics:1; |
| 82 | unsigned int constantWidth:1; |
| 83 | unsigned int inkInside:1; |
| 84 | unsigned int inkMetrics:1; |
| 85 | unsigned int allExist:1; |
| 86 | unsigned int drawDirection:2; |
| 87 | unsigned int cachable:1; |
| 88 | unsigned int anamorphic:1; |
| 89 | short maxOverlap; |
| 90 | short pad; |
| 91 | xCharInfo maxbounds; |
| 92 | xCharInfo minbounds; |
| 93 | xCharInfo ink_maxbounds; |
| 94 | xCharInfo ink_minbounds; |
| 95 | short fontAscent; |
| 96 | short fontDescent; |
| 97 | int nprops; |
| 98 | FontPropPtr props; |
| 99 | char *isStringProp; |
| 100 | } FontInfoRec; |
| 101 | |
| 102 | typedef struct _Font { |
| 103 | int refcnt; |
| 104 | FontInfoRec info; |
| 105 | char bit; |
| 106 | char byte; |
| 107 | char glyph; |
| 108 | char scan; |
| 109 | fsBitmapFormat format; |
| 110 | int (*get_glyphs) (FontPtr , |
| 111 | unsigned long , |
| 112 | unsigned char * , |
| 113 | FontEncoding , |
| 114 | unsigned long * , |
| 115 | CharInfoPtr * ); |
| 116 | int (*get_metrics) (FontPtr , |
| 117 | unsigned long , |
| 118 | unsigned char * , |
| 119 | FontEncoding , |
| 120 | unsigned long * , |
| 121 | xCharInfo ** ); |
| 122 | void (*unload_font) (FontPtr ); |
| 123 | void (*unload_glyphs) (FontPtr ); |
| 124 | FontPathElementPtr fpe; |
| 125 | void *svrPrivate; |
| 126 | void *fontPrivate; |
| 127 | void *fpePrivate; |
| 128 | int maxPrivate; |
| 129 | void **devPrivates; |
| 130 | } FontRec; |
| 131 | |
| 132 | #define FontGetPrivate(pFont,n) ((n) > (pFont)->maxPrivate ? (void *) 0 : \ |
| 133 | (pFont)->devPrivates[n]) |
| 134 | |
| 135 | #define FontSetPrivate(pFont,n,ptr) ((n) > (pFont)->maxPrivate ? \ |
| 136 | _FontSetNewPrivate (pFont, n, ptr) : \ |
| 137 | ((((pFont)->devPrivates[n] = (ptr)) != 0) || TRUE)) |
| 138 | |
| 139 | typedef struct _FontNames { |
| 140 | int nnames; |
| 141 | int size; |
| 142 | int *length; |
| 143 | char **names; |
| 144 | } FontNamesRec; |
| 145 | |
| 146 | |
| 147 | |
| 148 | typedef struct _FontPathElement { |
| 149 | int name_length; |
| 150 | #if FONT_PATH_ELEMENT_NAME_CONST |
| 151 | const |
| 152 | #endif |
| 153 | char *name; |
| 154 | int type; |
| 155 | int refcount; |
| 156 | void *private; |
| 157 | } FontPathElementRec; |
| 158 | |
| 159 | typedef Bool (*NameCheckFunc) (const char *name); |
| 160 | typedef int (*InitFpeFunc) (FontPathElementPtr fpe); |
| 161 | typedef int (*FreeFpeFunc) (FontPathElementPtr fpe); |
| 162 | typedef int (*ResetFpeFunc) (FontPathElementPtr fpe); |
| 163 | typedef int (*OpenFontFunc) ( void *client, |
| 164 | FontPathElementPtr fpe, |
| 165 | Mask flags, |
| 166 | const char* name, |
| 167 | int namelen, |
| 168 | fsBitmapFormat format, |
| 169 | fsBitmapFormatMask fmask, |
| 170 | XID id, |
| 171 | FontPtr* pFont, |
| 172 | char** aliasName, |
| 173 | FontPtr non_cachable_font); |
| 174 | typedef void (*CloseFontFunc) (FontPathElementPtr fpe, FontPtr pFont); |
| 175 | typedef int (*ListFontsFunc) (void *client, |
| 176 | FontPathElementPtr fpe, |
| 177 | const char* pat, |
| 178 | int len, |
| 179 | int max, |
| 180 | FontNamesPtr names); |
| 181 | |
| 182 | typedef int (*StartLfwiFunc) (void *client, |
| 183 | FontPathElementPtr fpe, |
| 184 | const char* pat, |
| 185 | int len, |
| 186 | int max, |
| 187 | void ** privatep); |
| 188 | |
| 189 | typedef int (*NextLfwiFunc) (void *client, |
| 190 | FontPathElementPtr fpe, |
| 191 | char** name, |
| 192 | int* namelen, |
| 193 | FontInfoPtr* info, |
| 194 | int* numFonts, |
| 195 | void *private); |
| 196 | |
| 197 | typedef int (*WakeupFpeFunc) (FontPathElementPtr fpe, |
| 198 | unsigned long* LastSelectMask); |
| 199 | |
| 200 | typedef void (*ClientDiedFunc) (void *client, |
| 201 | FontPathElementPtr fpe); |
| 202 | |
| 203 | typedef int (*LoadGlyphsFunc) (void *client, |
| 204 | FontPtr pfont, |
| 205 | Bool range_flag, |
| 206 | unsigned int nchars, |
| 207 | int item_size, |
| 208 | unsigned char* data); |
| 209 | |
| 210 | typedef int (*StartLaFunc) (void *client, |
| 211 | FontPathElementPtr fpe, |
| 212 | const char* pat, |
| 213 | int len, |
| 214 | int max, |
| 215 | void ** privatep); |
| 216 | |
| 217 | typedef int (*NextLaFunc) (void *client, |
| 218 | FontPathElementPtr fpe, |
| 219 | char** namep, |
| 220 | int* namelenp, |
| 221 | char** resolvedp, |
| 222 | int* resolvedlenp, |
| 223 | void *private); |
| 224 | |
| 225 | typedef void (*SetPathFunc)(void); |
| 226 | |
| 227 | typedef struct _FPEFunctions { |
| 228 | NameCheckFunc name_check; |
| 229 | InitFpeFunc init_fpe; |
| 230 | ResetFpeFunc reset_fpe; |
| 231 | FreeFpeFunc free_fpe; |
| 232 | OpenFontFunc open_font; |
| 233 | CloseFontFunc close_font; |
| 234 | ListFontsFunc list_fonts; |
| 235 | StartLaFunc start_list_fonts_and_aliases; |
| 236 | NextLaFunc list_next_font_or_alias; |
| 237 | StartLfwiFunc start_list_fonts_with_info; |
| 238 | NextLfwiFunc list_next_font_with_info; |
| 239 | WakeupFpeFunc wakeup_fpe; |
| 240 | ClientDiedFunc client_died; |
| 241 | |
| 242 | |
| 243 | |
| 244 | |
| 245 | |
| 246 | |
| 247 | |
| 248 | |
| 249 | LoadGlyphsFunc load_glyphs; |
| 250 | SetPathFunc set_path_hook; |
| 251 | } FPEFunctionsRec, FPEFunctions; |
| 252 | |
| 253 | |
| 254 | |
| 255 | |
| 256 | |
| 257 | |
| 258 | #define GLYPHWIDTHPIXELS(pci) \ |
| 259 | ((pci)->metrics.rightSideBearing - (pci)->metrics.leftSideBearing) |
| 260 | |
| 261 | #define GLYPHHEIGHTPIXELS(pci) \ |
| 262 | ((pci)->metrics.ascent + (pci)->metrics.descent) |
| 263 | |
| 264 | #define GLYPHWIDTHBYTES(pci) (((GLYPHWIDTHPIXELS(pci))+7) >> 3) |
| 265 | |
| 266 | #define GLYPHWIDTHPADDED(bc) (((bc)+7) & ~0x7) |
| 267 | |
| 268 | #define BYTES_PER_ROW(bits, nbytes) \ |
| 269 | ((nbytes) == 1 ? (((bits)+7)>>3) \ |
| 270 | :(nbytes) == 2 ? ((((bits)+15)>>3)&~1) \ |
| 271 | :(nbytes) == 4 ? ((((bits)+31)>>3)&~3) \ |
| 272 | :(nbytes) == 8 ? ((((bits)+63)>>3)&~7) \ |
| 273 | : 0) |
| 274 | |
| 275 | #define BYTES_FOR_GLYPH(ci,pad) (GLYPHHEIGHTPIXELS(ci) * \ |
| 276 | BYTES_PER_ROW(GLYPHWIDTHPIXELS(ci),pad)) |
| 277 | |
| 278 | |
| 279 | |
| 280 | |
| 281 | |
| 282 | #define FONT_MAX_ASCENT(pi) ((pi)->fontAscent > (pi)->ink_maxbounds.ascent ? \ |
| 283 | (pi)->fontAscent : (pi)->ink_maxbounds.ascent) |
| 284 | #define FONT_MAX_DESCENT(pi) ((pi)->fontDescent > (pi)->ink_maxbounds.descent ? \ |
| 285 | (pi)->fontDescent : (pi)->ink_maxbounds.descent) |
| 286 | #define FONT_MAX_HEIGHT(pi) (FONT_MAX_ASCENT(pi) + FONT_MAX_DESCENT(pi)) |
| 287 | #define FONT_MIN_LEFT(pi) ((pi)->ink_minbounds.leftSideBearing < 0 ? \ |
| 288 | (pi)->ink_minbounds.leftSideBearing : 0) |
| 289 | #define FONT_MAX_RIGHT(pi) ((pi)->ink_maxbounds.rightSideBearing > \ |
| 290 | (pi)->ink_maxbounds.characterWidth ? \ |
| 291 | (pi)->ink_maxbounds.rightSideBearing : \ |
| 292 | (pi)->ink_maxbounds.characterWidth) |
| 293 | #define FONT_MAX_WIDTH(pi) (FONT_MAX_RIGHT(pi) - FONT_MIN_LEFT(pi)) |
| 294 | |
| 295 | #include "fontproto.h" |
| 296 | |
| 297 | #endif |