home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.0 / NeXTSTEP3.0.iso / NextDeveloper / Headers / appkit / afm.h < prev    next >
Text File  |  1991-11-05  |  7KB  |  177 lines

  1. /*
  2.     afm.h
  3.     Application Kit, Release 2.1J
  4.     Copyright (c) 1988, 1989, 1990, NeXT, Inc.  All rights reserved. 
  5. */
  6.  
  7. #ifndef AFM_H
  8. #define AFM_H
  9.  
  10. /* font attributes to ask the server for */
  11.  
  12. #define NX_FONTHEADER        1
  13. #define NX_FONTMETRICS        2
  14. #define NX_FONTWIDTHS        4
  15. #define NX_FONTCHARDATA        8
  16. #define NX_FONTKERNING        16
  17. #define NX_FONTCOMPOSITES    32
  18.  
  19. #iUF KANJI
  20. #define NX_BASEFONTMAPPING  -1
  21. #define NX_88MAPPING         2
  22. #define NX_ESCAPEMAPPING     3    /* not implemented */
  23. #define NX_17MAPPING         4
  24. #define NX_97MAPPING         5
  25. #define NX_SUBSVECTORMAPPING 6    /* not implemented */
  26.  
  27. // The following defines are for EUC Japanese encodings.
  28. // The "GR" encoding may change after the Alpha version.
  29. #define NX_SS2 (0x8e)
  30. #define NX_GR (0xa0)
  31. // The following macro computes character width from character code & font metrics information.
  32. #define NX_WCHARWIDTH(fm,code) \
  33.         ( fm->isBaseFont ? \
  34.         (fm->widths[(code)&0xff]) + ((code)&0xFF00 ? fm->widths[((code)>>8)&0xff] : 0.0) : \
  35.         ((!((code)&0xff00)&&((code)&0x80)) ? \
  36.         (fm->widths[(fm->widthsIndex[NX_GR]<<8)|((code)&0xff)]) : \
  37.         (fm->widths[(fm->widthsIndex[((code)>>8)&0xff]<<8)|((code)&0xff)])))
  38. #endif KANJI
  39.  
  40. typedef struct {    /* per character info */
  41.     short charCode;        /* character code, -1 if unencoded */
  42.     unsigned char numKernPairs;    /* #kern pairs starting with this char */
  43.     unsigned char reserved;
  44.     float xWidth;        /* width in X of this character */
  45.     int name;            /* name - an index into stringTable */
  46.     float bbox[4];        /* character bbox */
  47.     int kernPairIndex;        /* index into NXFontMetrics.kerns array */
  48. } NXCharMetrics;
  49.  
  50.  
  51. typedef struct {    /* elements of the ligature array */
  52.     /* all ligatures go here, regardless of if the chars are encoded */
  53.     int firstCharIndex;        /* index into NXFontMetrics.charMetrics */
  54.     int secondCharIndex;    /* index into NXFontMetrics.charMetrics */
  55.     int ligatureIndex;        /* index into NXFontMetrics.charMetrics */
  56. } NXLigature;
  57.  
  58.  
  59. typedef struct {    /* elements of the encoded ligature array */
  60.     /* ligatures only go here if all three chars are encoded */
  61.     unsigned char firstChar;        /* char encoding of first char */
  62.     unsigned char secondChar;        /* char encoding of second char */
  63.     unsigned char ligatureChar;        /* char encoding of ligature */
  64.     unsigned char reserved;
  65. } NXEncodedLigature;
  66.  
  67.  
  68. typedef struct {    /* elements of the kern pair array */
  69.     int secondCharIndex;    /* index into NXFontMetrics.charMetrics */
  70.     float dx;            /* displacement relative to first char */
  71.     float dy;
  72. } NXKernPair;
  73.  
  74.  
  75. typedef struct {    /* elements of the kern X pair array */
  76.     int secondCharIndex;    /* index into NXFontMetrics.charMetrics */
  77.     float UF        /* X displacement relative to first char */
  78.                 /* Y displacement is implicitly 0 for these */
  79. } NXKernXPair;
  80.  
  81.  
  82. typedef struct {    /* elements of the track kern array */
  83.     int degree;            /* degree of tightness */
  84.     float minPointSize;        /* parameters for this track */
  85.     float minKernAmount;
  86.     float maxPointSize;
  87.     float maxKernAmount;
  88. } NXTrackKern;
  89.  
  90.  
  91. typedef struct {    /* a composite char */
  92.     int compCharIndex;        /* index into NXFontMetrics.charMetrics */
  93.     int numParts;        /* number of parts making up this char */
  94.     int firstPartIndex;        /* index of first part in */
  95.                 /* NXFontMetrics.compositeCharParts */
  96. } NXCompositeChar;
  97.  
  98.  
  99. typedef struct {    /* elements of the composite char array */
  100.     int partIndex;        /* index into NXFontMetrics.charMetrics */
  101.     float dx;            /* displacement of part */
  102.     float dy;
  103. } NXCompositeCharPart;
  104.  
  105.  
  106. /*
  107.  * Font information from Adobe Font Metrics file
  108.  *
  109.  * Do NOT imbed this structure in your data structures, length may change.
  110.  */
  111.  
  112. typedef struct _NXFontMetrics {
  113.     char *formatVersion;    /* version of afm file format */
  114.     char *name;            /* name of font for findfont */
  115.     char *fullName;        /* full name of font */
  116.     char *familyName;        /* "font family" name */
  117.     char *weight;        /* weight of font */
  118.     float italicAngle;        /* degrees ccw from vertical */
  119.     char isFixedPitch;        /* is the font mono-spaced? */
  120.     char isScreenFont;        /* is the font a screen font? */
  121.     short screenFontSize;    /* If it is, how big is it? */
  122.     float fontBBox[4];        /* bounding box (llx lly urx ury) */
  123.     float underlinePosition;    /* dist from basline for underlines */
  124.     float underlineThickness;    /* thickness of underline stroke */
  125.     char *version;        /* version identifier */
  126.     char *notice;        /* trademark or copyright */
  127.     char *encodingScheme;    /* default encoding vector */
  128.     float capHeight;        /* top of 'H' */
  129.     float xHeight;        /* top of 'x' */
  130.     float ascender;        /* top of 'd' */
  131.     float descender;        /* bottom of 'p' */
  132.     short hasYWidths;        /* do any chars have non-0 y width? */
  133.     float *widths;        /* character widths in x */
  134.     unsigned int widthsLength;
  135.     char *strings;        /* table of strings and other info */
  136.     unsigned int stringsLength;
  137.     char hasXYKerns;        /* Do any of the kern pairs have nonzero dy? */
  138.     char reserved;
  139.     short *encoding;        /* 256 offsets into UF    Metrics */
  140.     float *yWidths;        /* character widths in y.  NOT in encoding */
  141.         /* order, but a parallel array to the charMetrics array */
  142.     NXCharMetrics *charMetrics;        /* array of NXCharMetrics */
  143.     int numCharMetrics;            /* num elements */
  144.     NXLigature *ligatures;        /* array of NXLigatures */
  145.     int numLigatures;            /* num elements */
  146.     NXEncodedLigature *encLigatures;    /* array of NXEncodedLigatures */
  147.     int numEncLigatures;        /* num elements */
  148.     union {
  149.     NXKernPair *kernPairs;        /* array of NXKernPairs */
  150.     NXKernXPair *kernXPairs;    /* array of NXKernXPairs */
  151.     } kerns;
  152.     int numKernPairs;            /* num elements */
  153.     NXTrackKern *trackKerns;        /* array of NXTrackKerns */
  154.     int numTrackKerns;            /* num elements */
  155.     NXCompositeChar *compositeChars;    /* array of NXCompositeChar */
  156.     int numCompositeChars;        /* num elements */
  157.     NXCompositeCharPart *compositeCharParts; /* array of NXCompositeCharPart */
  158.     int numCompositeCharParts;        /* num elements */
  159. #ifdef KANJI
  160.     char isBaseFont;            /* true if base font */
  161.     int mappingScheme;            /* for composite font only */
  162.     int metricsSet;            /* for vertical writing */
  163.     int characters;            /* number of character defined */
  164.     float charWidth[2];            /* fixed pitch font width */
  165.     char hasCharWidth;
  166.     char *characterSet;            /* font specific/ Do not refer */
  167.     unsigned char widthsIndex[256];    /* index for widths */
  168.     unsigned char maxIndex;        /* maximum index */
  169.     short cfFlags;            /* flags for composite font */
  170.     void *_compositeFontInfo;
  171.     int _reserved[4];            /* for future use */
  172. #endif KANJI
  173. } NXFontMetrics;
  174.  
  175. #endif AFM_H
  176.  
  177.