home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2 / Openstep-4.2-Intel-Developer.iso / NextLibrary / Frameworks / AppKit.framework / Versions / B / Headers / NSFont.h < prev    next >
Text File  |  1996-10-17  |  8KB  |  176 lines

  1. /*
  2.     NSFont.h
  3.     Application Kit
  4.     Copyright (c) 1994-1996, NeXT Software, Inc.
  5.     All rights reserved.
  6. */
  7.  
  8. #import <Foundation/Foundation.h>
  9. #import <AppKit/NSFontManager.h>
  10. #import <AppKit/AppKitDefines.h>
  11.  
  12. typedef unsigned int NSGlyph;
  13.  
  14. enum {
  15.     NSControlGlyph = 0x00FFFFFF,
  16.     NSNullGlyph = 0x0
  17. };
  18.  
  19. typedef enum _NSGlyphRelation {
  20.     NSGlyphBelow = 1,
  21.     NSGlyphAbove = 2,
  22. } NSGlyphRelation;
  23.  
  24. APPKIT_EXTERN const float *NSFontIdentityMatrix;
  25.  
  26. @interface NSFont : NSObject <NSCopying, NSCoding> {
  27. @private
  28.     NSString *_name;
  29.     float _size;
  30.     int _reservedFont1;
  31.     float *_matrix;
  32.     int _fontNum;
  33.     struct _NSFaceInfo *_faceInfo;
  34.     id _otherFont;
  35.     struct __fFlags {
  36.       /* the following instance variables are no longer part of the API */
  37.     unsigned int usedByWS:1;
  38.     unsigned int usedByPrinter:1;
  39.     unsigned int isScreenFont:1;
  40.     unsigned int _systemFontType:4;
  41.     unsigned int _flippedUsedByWS:1;
  42.     unsigned int _flippedUsedByPrinter:1;
  43.     unsigned int _RESERVED:4;
  44.     unsigned int _matrixIsIdentity:1;
  45.     unsigned int _matrixIsFlipped:1;
  46.     unsigned int _hasStyle:1;
  47.     } _fFlags;
  48.     unsigned short _reservedFont2;
  49.     int _flippedFontNum;
  50. }
  51.  
  52. + (NSFont *)fontWithName:(NSString *)fontName size:(float)fontSize;
  53. + (NSFont *)fontWithName:(NSString *)fontName matrix:(const float *)fontMatrix;
  54. + (void)useFont:(NSString *)fontName;
  55.  
  56. + (NSFont *)userFontOfSize:(float)fontSize;
  57. + (NSFont *)userFixedPitchFontOfSize:(float)fontSize;
  58. + (NSFont *)systemFontOfSize:(float)fontSize;
  59. + (NSFont *)boldSystemFontOfSize:(float)fontSize;
  60. + (void)setUserFont:(NSFont *)aFont;
  61. + (void)setUserFixedPitchFont:(NSFont *)aFont;
  62.  
  63. #ifndef STRICT_OPENSTEP
  64.  
  65. + (NSFont *)titleBarFontOfSize:(float)fontSize;
  66. + (NSFont *)menuFontOfSize:(float)fontSize;
  67. + (NSFont *)messageFontOfSize:(float)fontSize;
  68. + (NSFont *)paletteFontOfSize:(float)fontSize;
  69. + (NSFont *)toolTipsFontOfSize:(float)fontSize;
  70.  
  71. #endif
  72.  
  73. - (float)pointSize;
  74. - (NSString *)fontName;
  75. - (NSString *)familyName;
  76. - (NSString *)displayName;
  77.  
  78. - (const float *)matrix;
  79. - (void)set;
  80. - (float)widthOfString:(NSString *)string;
  81. - (NSFont *)screenFont;
  82. - (NSFont *)printerFont;
  83.  
  84. - (BOOL)isBaseFont;
  85.  
  86. /* The "widths" method returns a pointer to an array of 256 widths.  They are unscaled but are pre-divided by 1000.  All other methods return scaled numbers.  If the font was created with a matrix, the matrix is applied automatically; otherwise the coordinates are multiplied by size.
  87. */
  88.  
  89. - (float *)widths;
  90. - (NSRect)boundingRectForFont;
  91. - (NSRect)boundingRectForGlyph:(NSGlyph)aGlyph;
  92. - (NSSize)advancementForGlyph:(NSGlyph)ag;
  93. - (NSDictionary *)afmDictionary;
  94. - (NSString *)afmFileContents;
  95. - (BOOL)glyphIsEncoded:(NSGlyph)aGlyph;
  96.  
  97. #ifndef STRICT_OPENSTEP
  98. + (NSArray *)preferredFontNames;
  99. + (void)setPreferredFontNames:(NSArray *)fontNameArray;
  100.  
  101. - (NSSize) maximumAdvancement; /* returns widest advancement, or constant advancement if the font is fixed-pitch. */
  102. - (NSStringEncoding) mostCompatibleStringEncoding;
  103. #endif
  104.  
  105. - (float) underlinePosition;    /* was fontUnderlinePosition */
  106. - (float) underlineThickness;    /* was fontUnderlineThickness */
  107. - (float) italicAngle;    /* was fontItalicAngle */
  108. - (float) capHeight;    /* used for translating vertical baselines */
  109. - (float) xHeight;
  110. - (float) ascender;
  111. - (float) descender;
  112. - (BOOL) isFixedPitch;
  113. - (NSString *) encodingScheme;
  114. - (NSGlyph) glyphWithName:(NSString *)aName;
  115.  
  116. /* Glyph related methods.
  117.  
  118. The position of a glyph is where you need to be to show the glyph. The position is relative to the position of the other glyph supplied as argument. If other glyph is 0 (no glyph), then this reduces to being relative to the origin.
  119.  
  120. The optional isNominal argument indicates whether the returned position is the standard advancement specified for the previous glyph (ie, width from the AFM file). It could be NO if the two glyphs are kerned, for instance.
  121.  
  122. The optional metricsExist argument specifies whether the metrics for the combination were found; if not, the returned point will be computed using the bounding boxes of the glyphs and may not be very pretty.
  123.  
  124. */
  125.  
  126. /* Position two base glyphs next to each other.  In this method, 0 (i.e., no glyph) may be specified for either glyph.
  127. */
  128. - (NSPoint)positionOfGlyph:(NSGlyph)curGlyph precededByGlyph:(NSGlyph)prevGlyph isNominal:(BOOL *)nominal;
  129.  
  130. #ifndef STRICT_OPENSTEP
  131. /* Given a base glyph followed by a bunch of "overstruck" glyphs, see if there's a corresponding set of metrics in the font.  If so, return the NUMBER of matching glyphs from the group and fill in "points" with the positions, relative to (0,0) for the base glyph.  Partial sequences may be returned.  If the return value is less than numGlyphs, then the leftover glyphs can be rendered via positionOfGlyph:forCharacter:struckOverRect:, using the union-rect of the glyphs for which the font had metrics.
  132. */
  133. - (int) positionsForCompositeSequence:(NSGlyph *)someGlyphs numberOfGlyphs:(int)numGlyphs pointArray:(NSPoint *)points;
  134.  
  135. /* Basic base/accent positioning.  Try to position the glyphs, using metric information if it exists.  If metrics do not exist, this method may defer to "positionOfGlyph:struckOverRect:metricsExist:" for the answer.  In any case, if metrics do not exist, the answer may be invalid.
  136. */
  137. - (NSPoint)positionOfGlyph:(NSGlyph)curGlyph struckOverGlyph:(NSGlyph)prevGlyph metricsExist:(BOOL *)exist;
  138.  
  139. /* Base/accent positioning when a previous glyph (i.e., aRect) may not be in the same font or has no metrics -- use its rectangle.  Try to position the glyphs, using generalized metric information if it exists.  If metrics do not exist, the result may not be valid.
  140. */
  141. - (NSPoint)positionOfGlyph:(NSGlyph)aGlyph struckOverRect:(NSRect)aRect metricsExist:(BOOL *)exist;
  142.  
  143. /* As a last resort, this attempts to do positioning of base/accent based on semantic knowledge of various "accent" characters.  It is NOT guaranteed to be pretty, but works in the absence of proper metrics for "many" diacritical marks in the Latin, Greek, and Cyrillic scripts.  The caller asserts that "aGlyph" is a rendering in the font for the Unicode character "aChar".  The rectangle is presumed to be the rectangle of some other glyph, whether known in this font or not.  The returned position tells where to put "aGlyph" in relation to "aRect"; i.e., presuming aRect is shown at {0,0} one may "moveto" the returned position and show "aGlyph".
  144. */
  145. - (NSPoint)positionOfGlyph:(NSGlyph)aGlyph forCharacter:(unichar)aChar struckOverRect:(NSRect)aRect;
  146.  
  147. /* This is for specific types of positioning above/below (mainly for Indic support).  Metric support is usually required for the result to be pretty.  The default is to join glyphs without gaps and return the advancement of baseGlyph.
  148. */
  149. - (NSPoint)positionOfGlyph:(NSGlyph)thisGlyph withRelation:(NSGlyphRelation)rel toBaseGlyph:(NSGlyph)baseGlyph totalAdvancement:(NSSize *)adv metricsExist:(BOOL *)exist;
  150.  
  151. #endif
  152.  
  153. @end
  154.  
  155. /* These are the strings that are available in the "afmDictionary".  For other things, use "afmFileContents".  The floating point values (e.g., ascender, cap height) can be converted to floating point via NSString's "floatValue" method.
  156. */
  157. APPKIT_EXTERN NSString *NSAFMFamilyName;
  158. APPKIT_EXTERN NSString *NSAFMFontName;
  159. APPKIT_EXTERN NSString *NSAFMFormatVersion;
  160. APPKIT_EXTERN NSString *NSAFMFullName;
  161. APPKIT_EXTERN NSString *NSAFMNotice;
  162. APPKIT_EXTERN NSString *NSAFMVersion;
  163. APPKIT_EXTERN NSString *NSAFMWeight;
  164. APPKIT_EXTERN NSString *NSAFMEncodingScheme;
  165. APPKIT_EXTERN NSString *NSAFMCharacterSet;
  166.  
  167. APPKIT_EXTERN NSString *NSAFMCapHeight;
  168. APPKIT_EXTERN NSString *NSAFMXHeight;
  169. APPKIT_EXTERN NSString *NSAFMAscender;
  170. APPKIT_EXTERN NSString *NSAFMDescender;
  171. APPKIT_EXTERN NSString *NSAFMUnderlinePosition;
  172. APPKIT_EXTERN NSString *NSAFMUnderlineThickness;
  173. APPKIT_EXTERN NSString *NSAFMItalicAngle;
  174. APPKIT_EXTERN NSString *NSAFMMappingScheme;
  175.  
  176.