CGFont.pas 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. { CoreGraphics - CGFont.h
  2. * Copyright (c) 1999-2003 Apple Computer, Inc.
  3. * All rights reserved.
  4. }
  5. { Pascal Translation Updated: Peter N Lewis, <[email protected]>, August 2005 }
  6. {
  7. Modified for use with Free Pascal
  8. Version 200
  9. Please report any bugs to <[email protected]>
  10. }
  11. {$mode macpas}
  12. {$packenum 1}
  13. {$macro on}
  14. {$inline on}
  15. {$CALLING MWPASCAL}
  16. unit CGFont;
  17. interface
  18. {$setc UNIVERSAL_INTERFACES_VERSION := $0342}
  19. {$setc GAP_INTERFACES_VERSION := $0200}
  20. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  21. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  22. {$endc}
  23. {$ifc defined CPUPOWERPC and defined CPUI386}
  24. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  25. {$endc}
  26. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  27. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  28. {$endc}
  29. {$ifc not defined __ppc__ and defined CPUPOWERPC}
  30. {$setc __ppc__ := 1}
  31. {$elsec}
  32. {$setc __ppc__ := 0}
  33. {$endc}
  34. {$ifc not defined __i386__ and defined CPUI386}
  35. {$setc __i386__ := 1}
  36. {$elsec}
  37. {$setc __i386__ := 0}
  38. {$endc}
  39. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  40. {$error Conflicting definitions for __ppc__ and __i386__}
  41. {$endc}
  42. {$ifc defined __ppc__ and __ppc__}
  43. {$setc TARGET_CPU_PPC := TRUE}
  44. {$setc TARGET_CPU_X86 := FALSE}
  45. {$elifc defined __i386__ and __i386__}
  46. {$setc TARGET_CPU_PPC := FALSE}
  47. {$setc TARGET_CPU_X86 := TRUE}
  48. {$elsec}
  49. {$error Neither __ppc__ nor __i386__ is defined.}
  50. {$endc}
  51. {$setc TARGET_CPU_PPC_64 := FALSE}
  52. {$ifc defined FPC_BIG_ENDIAN}
  53. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  54. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  55. {$elifc defined FPC_LITTLE_ENDIAN}
  56. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  57. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  58. {$elsec}
  59. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  60. {$endc}
  61. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  62. {$setc CALL_NOT_IN_CARBON := FALSE}
  63. {$setc OLDROUTINENAMES := FALSE}
  64. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  65. {$setc OPAQUE_UPP_TYPES := TRUE}
  66. {$setc OTCARBONAPPLICATION := TRUE}
  67. {$setc OTKERNEL := FALSE}
  68. {$setc PM_USE_SESSION_APIS := TRUE}
  69. {$setc TARGET_API_MAC_CARBON := TRUE}
  70. {$setc TARGET_API_MAC_OS8 := FALSE}
  71. {$setc TARGET_API_MAC_OSX := TRUE}
  72. {$setc TARGET_CARBON := TRUE}
  73. {$setc TARGET_CPU_68K := FALSE}
  74. {$setc TARGET_CPU_MIPS := FALSE}
  75. {$setc TARGET_CPU_SPARC := FALSE}
  76. {$setc TARGET_OS_MAC := TRUE}
  77. {$setc TARGET_OS_UNIX := FALSE}
  78. {$setc TARGET_OS_WIN32 := FALSE}
  79. {$setc TARGET_RT_MAC_68881 := FALSE}
  80. {$setc TARGET_RT_MAC_CFM := FALSE}
  81. {$setc TARGET_RT_MAC_MACHO := TRUE}
  82. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  83. {$setc TYPE_BOOL := FALSE}
  84. {$setc TYPE_EXTENDED := FALSE}
  85. {$setc TYPE_LONGLONG := TRUE}
  86. uses MacTypes,CFBase,CFData,CFDictionary,CFArray,CGBase;
  87. {$ALIGN POWER}
  88. { The type used to represent a CoreGraphics font. }
  89. type
  90. CGFontRef = ^SInt32; { an opaque 32-bit type }
  91. { A type to represent indexes in a CGFontRef. }
  92. type
  93. CGFontIndex = UInt16;
  94. { A type to represent glyph identifiers in a CGFontRef. }
  95. type
  96. CGGlyph = CGFontIndex;
  97. CGGlyphPtr = ^CGGlyph;
  98. { The format of a PostScript font subset. Type1 is documented in the
  99. * "Adobe Type 1 Font Format"; Type3 in the "PostScript Language Reference,
  100. * 3rd ed." and Type42 in "Adobe Technical Note 5012, The Type 42 Font
  101. * Format Specification". }
  102. type
  103. CGFontPostScriptFormat = SInt32;
  104. const
  105. kCGFontPostScriptFormatType1 = 1;
  106. kCGFontPostScriptFormatType3 = 3;
  107. kCGFontPostScriptFormatType42 = 42;
  108. const
  109. { The maximum allowed value of a CGFontIndex. Always <= USHRT_MAX - 1. }
  110. kCGFontIndexMax = (1 shl 16) - 2;
  111. { A value representing an invalid CGFontIndex. Always <= USHRT_MAX. }
  112. kCGFontIndexInvalid = (1 shl 16) - 1;
  113. { The maximum allowed value of a CGGlyph. }
  114. kCGGlyphMax = kCGFontIndexMax;
  115. { Return the CFTypeID for CGFontRefs. }
  116. function CGFontGetTypeID: CFTypeID; external name '_CGFontGetTypeID'; (* AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER *)
  117. { Create a CGFontRef using `platformFontReference', a pointer to a
  118. * platform-specific font reference. For MacOS X, `platformFontReference'
  119. * should be a pointer to an ATSFontRef. }
  120. function CGFontCreateWithPlatformFont( platformFontReference: UnivPtr ): CGFontRef; external name '_CGFontCreateWithPlatformFont';
  121. { Return a font based on `font' with the variation specification
  122. * dictionary `variations' applied to `font'. A variation specification
  123. * dictionary contains keys corresponding the variation axis names of the
  124. * font. Each key is a variation axis name; the value for each key is the
  125. * value specified for that particular variation axis represented as a
  126. * CFNumberRef. If a variation axis name is not specified in `variations',
  127. * then the current value from `font' is used. }
  128. function CGFontCreateCopyWithVariations( font: CGFontRef; variations: CFDictionaryRef ): CGFontRef; external name '_CGFontCreateCopyWithVariations'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  129. { Equivalent to `CFRetain(font)', except it doesn't crash (as CFRetain
  130. * does) if `font' is NULL. }
  131. function CGFontRetain( font: CGFontRef ): CGFontRef; external name '_CGFontRetain';
  132. { Equivalent to `CFRelease(font)', except it doesn't crash (as CFRelease
  133. * does) if `font' is NULL. }
  134. procedure CGFontRelease( font: CGFontRef ); external name '_CGFontRelease';
  135. { Return the PostScript name of `font'. }
  136. function CGFontCopyPostScriptName( font: CGFontRef ): CFStringRef; external name '_CGFontCopyPostScriptName'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  137. { Return an array of the variation axis dictionaries for `font'. Each
  138. * variation axis dictionary contains values for the variation axis keys
  139. * listed below. This function returns NULL if `font' doesn't support
  140. * variations. }
  141. function CGFontCopyVariationAxes( font: CGFontRef ): CFArrayRef; external name '_CGFontCopyVariationAxes'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  142. { Return the variation specification dictionary from `font'. This
  143. * dictionary contains keys corresponding the variation axis names of the
  144. * font. Each key is a variation axis name; the value for each key is the
  145. * value specified for that particular variation axis represented as a
  146. * CFNumberRef. This function returns NULL if `font' doesn't support
  147. * variations. }
  148. function CGFontCopyVariations( font: CGFontRef ): CFDictionaryRef; external name '_CGFontCopyVariations'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  149. { Return true if a subset in the PostScript format `format' can be created
  150. * for `font'; false otherwise. }
  151. function CGFontCanCreatePostScriptSubset( font: CGFontRef; format: CGFontPostScriptFormat ): CBool; external name '_CGFontCanCreatePostScriptSubset'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  152. { Create a subset of `font' named `subsetName' in the PostScript format
  153. * `format'. The subset will contain the glyphs specified by `glyphs', an
  154. * array of `count' CGGlyphs. If non-NULL, `encoding' specifies the
  155. * default encoding for the subset. }
  156. type
  157. CGGlyph256Array = array[0..255] of CGGlyph;
  158. function CGFontCreatePostScriptSubset( font: CGFontRef; subsetName: CFStringRef; format: CGFontPostScriptFormat; {const} glyphs: {variable-size-array} CGGlyphPtr; count: size_t; const (*var*) encoding: CGGlyph256Array ): CFDataRef; external name '_CGFontCreatePostScriptSubset'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  159. { Return a PostScript encoding of `font' containing glyphs in `encoding'. }
  160. function CGFontCreatePostScriptEncoding( font: CGFontRef; const (*var*) encoding: CGGlyph256Array ): CFDataRef; external name '_CGFontCreatePostScriptEncoding'; (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  161. {** Keys for the font variation axis dictionary. **}
  162. { The key used to obtain the variation axis name from a variation axis
  163. * dictionary. The value obtained with this key is a CFStringRef specifying
  164. * the name of the variation axis. }
  165. var kCGFontVariationAxisName: CFStringRef; external name '_kCGFontVariationAxisName'; (* attribute const *) (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  166. { The key used to obtain the minimum variation axis value from a variation
  167. * axis dictionary. The value obtained with this key is a CFNumberRef
  168. * specifying the minimum value of the variation axis. }
  169. var kCGFontVariationAxisMinValue: CFStringRef; external name '_kCGFontVariationAxisMinValue'; (* attribute const *) (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  170. { The key used to obtain the maximum variation axis value from a variation
  171. * axis dictionary. The value obtained with this key is a CFNumberRef
  172. * specifying the maximum value of the variation axis. }
  173. var kCGFontVariationAxisMaxValue: CFStringRef; external name '_kCGFontVariationAxisMaxValue'; (* attribute const *) (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  174. { The key used to obtain the default variation axis value from a variation
  175. * axis dictionary. The value obtained with this key is a CFNumberRef
  176. * specifying the default value of the variation axis. }
  177. var kCGFontVariationAxisDefaultValue: CFStringRef; external name '_kCGFontVariationAxisDefaultValue'; (* attribute const *) (* AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER *)
  178. { Obsolete; don't use these. }
  179. const
  180. CGGlyphMin = 0;
  181. CGGlyphMax = kCGGlyphMax;
  182. end.