File: CoreText.pxi

package info (click to toggle)
python-enable 4.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 7,280 kB
  • ctags: 13,899
  • sloc: cpp: 48,447; python: 28,502; ansic: 9,004; makefile: 315; sh: 44
file content (355 lines) | stat: -rw-r--r-- 15,808 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
# :Author:    John Wiggins
# :Copyright: 2011, Enthought, Inc.
# :License:   BSD Style

include "CoreFoundation.pxi"
include "CoreGraphics.pxi"

cdef extern from "ApplicationServices/ApplicationServices.h":

    ctypedef CFTypeRef CTFontRef
    ctypedef CFTypeRef CTFontCollectionRef
    ctypedef CFTypeRef CTFontDescriptorRef
    ctypedef CFTypeRef CTLineRef

    # Constants that are used throughout CoreText
    cdef CFStringRef kCTFontAttributeName
    cdef CFStringRef kCTKernAttributeName
    cdef CFStringRef kCTLigatureAttributeName
    cdef CFStringRef kCTForegroundColorAttributeName
    cdef CFStringRef kCTParagraphStyleAttributeName
    cdef CFStringRef kCTUnderlineStyleAttributeName
    cdef CFStringRef kCTVerticalFormsAttributeName
    cdef CFStringRef kCTGlyphInfoAttributeName
    
    ctypedef enum CTUnderlineStyle:
        kCTUnderlineStyleNone   = 0x00
        kCTUnderlineStyleSingle = 0x01
        kCTUnderlineStyleThick  = 0x02
        kCTUnderlineStyleDouble = 0x09

    ctypedef enum CTUnderlineStyleModifiers:
        kCTUnderlinePatternSolid        = 0x0000
        kCTUnderlinePatternDot          = 0x0100
        kCTUnderlinePatternDash         = 0x0200
        kCTUnderlinePatternDashDot      = 0x0300
        kCTUnderlinePatternDashDotDot   = 0x0400

    cdef CFStringRef kCTFontSymbolicTrait
    cdef CFStringRef kCTFontWeightTrait
    cdef CFStringRef kCTFontWidthTrait
    cdef CFStringRef kCTFontSlantTrait

    ctypedef enum:
        kCTFontClassMaskShift = 28

    ctypedef enum CTFontSymbolicTraits:
        kCTFontItalicTrait      = (1 << 0)
        kCTFontBoldTrait        = (1 << 1)
        kCTFontExpandedTrait    = (1 << 5)
        kCTFontCondensedTrait   = (1 << 6)
        kCTFontMonoSpaceTrait   = (1 << 10)
        kCTFontVerticalTrait    = (1 << 11)
        kCTFontUIOptimizedTrait = (1 << 12)
        kCTFontClassMaskTrait   = (15 << kCTFontClassMaskShift)

    ctypedef enum CTFontStylisticClass:
        kCTFontUnknownClass             = (0 << kCTFontClassMaskShift)
        kCTFontOldStyleSerifsClass      = (1 << kCTFontClassMaskShift)
        kCTFontTransitionalSerifsClass  = (2 << kCTFontClassMaskShift)
        kCTFontModernSerifsClass        = (3 << kCTFontClassMaskShift)
        kCTFontClarendonSerifsClass     = (4 << kCTFontClassMaskShift)
        kCTFontSlabSerifsClass          = (5 << kCTFontClassMaskShift)
        kCTFontFreeformSerifsClass      = (7 << kCTFontClassMaskShift)
        kCTFontSansSerifClass           = (8 << kCTFontClassMaskShift)
        kCTFontOrnamentalsClass         = (9 << kCTFontClassMaskShift)
        kCTFontScriptsClass             = (10 << kCTFontClassMaskShift)
        kCTFontSymbolicClass            = (12 << kCTFontClassMaskShift)

    cdef CFStringRef kCTFontNameAttribute
    cdef CFStringRef kCTFontDisplayNameAttribute
    cdef CFStringRef kCTFontFamilyNameAttribute
    cdef CFStringRef kCTFontStyleNameAttribute
    cdef CFStringRef kCTFontTraitsAttribute
    cdef CFStringRef kCTFontVariationAttribute
    cdef CFStringRef kCTFontSizeAttribute
    cdef CFStringRef kCTFontMatrixAttribute
    cdef CFStringRef kCTFontCascadeListAttribute
    cdef CFStringRef kCTFontCharacterSetAttribute
    cdef CFStringRef kCTFontLanguagesAttribute
    cdef CFStringRef kCTFontBaselineAdjustAttribute
    cdef CFStringRef kCTFontMacintoshEncodingsAttribute
    cdef CFStringRef kCTFontFeaturesAttribute
    cdef CFStringRef kCTFontFeatureSettingsAttribute
    cdef CFStringRef kCTFontFixedAdvanceAttribute
    cdef CFStringRef kCTFontOrientationAttribute
    
    ctypedef enum CTFontOrientation:
        kCTFontDefaultOrientation       = 0
        kCTFontHorizontalOrientation    = 1
        kCTFontVerticalOrientation      = 2

    cdef CFStringRef kCTFontCopyrightNameKey
    cdef CFStringRef kCTFontFamilyNameKey
    cdef CFStringRef kCTFontSubFamilyNameKey
    cdef CFStringRef kCTFontStyleNameKey
    cdef CFStringRef kCTFontUniqueNameKey
    cdef CFStringRef kCTFontFullNameKey
    cdef CFStringRef kCTFontVersionNameKey
    cdef CFStringRef kCTFontPostScriptNameKey
    cdef CFStringRef kCTFontTrademarkNameKey
    cdef CFStringRef kCTFontManufacturerNameKey
    cdef CFStringRef kCTFontDesignerNameKey
    cdef CFStringRef kCTFontDescriptionNameKey
    cdef CFStringRef kCTFontVendorURLNameKey
    cdef CFStringRef kCTFontDesignerURLNameKey
    cdef CFStringRef kCTFontLicenseNameKey
    cdef CFStringRef kCTFontLicenseURLNameKey
    cdef CFStringRef kCTFontSampleTextNameKey
    cdef CFStringRef kCTFontPostScriptCIDNameKey

    ctypedef enum CTFontUIFontType:
        kCTFontNoFontType                           = -1
        kCTFontUserFontType                         =  0
        kCTFontUserFixedPitchFontType               =  1
        kCTFontSystemFontType                       =  2
        kCTFontEmphasizedSystemFontType             =  3
        kCTFontSmallSystemFontType                  =  4
        kCTFontSmallEmphasizedSystemFontType        =  5
        kCTFontMiniSystemFontType                   =  6
        kCTFontMiniEmphasizedSystemFontType         =  7
        kCTFontViewsFontType                        =  8
        kCTFontApplicationFontType                  =  9
        kCTFontLabelFontType                        = 10
        kCTFontMenuTitleFontType                    = 11
        kCTFontMenuItemFontType                     = 12
        kCTFontMenuItemMarkFontType                 = 13
        kCTFontMenuItemCmdKeyFontType               = 14
        kCTFontWindowTitleFontType                  = 15
        kCTFontPushButtonFontType                   = 16
        kCTFontUtilityWindowTitleFontType           = 17
        kCTFontAlertHeaderFontType                  = 18
        kCTFontSystemDetailFontType                 = 19
        kCTFontEmphasizedSystemDetailFontType       = 20
        kCTFontToolbarFontType                      = 21
        kCTFontSmallToolbarFontType                 = 22
        kCTFontMessageFontType                      = 23
        kCTFontPaletteFontType                      = 24
        kCTFontToolTipFontType                      = 25
        kCTFontControlContentFontType               = 26

    cdef CFStringRef kCTFontVariationAxisIdentifierKey
    cdef CFStringRef kCTFontVariationAxisMinimumValueKey
    cdef CFStringRef kCTFontVariationAxisMaximumValueKey
    cdef CFStringRef kCTFontVariationAxisDefaultValueKey
    cdef CFStringRef kCTFontVariationAxisNameKey

    cdef CFStringRef kCTFontFeatureTypeIdentifierKey
    cdef CFStringRef kCTFontFeatureTypeNameKey
    cdef CFStringRef kCTFontFeatureTypeExclusiveKey
    cdef CFStringRef kCTFontFeatureTypeSelectorsKey
    cdef CFStringRef kCTFontFeatureSelectorIdentifierKey
    cdef CFStringRef kCTFontFeatureSelectorNameKey
    cdef CFStringRef kCTFontFeatureSelectorDefaultKey
    cdef CFStringRef kCTFontFeatureSelectorSettingKey

    #ctypedef enum CTFontTableTag:
    #    kCTFontTableBASE
    #    kCTFontTableCFF
    #    kCTFontTableDSIG
    #    kCTFontTableEBDT
    #    kCTFontTableEBLC
    #    kCTFontTableEBSC
    #    kCTFontTableGDEF
    #    kCTFontTableGPOS
    #    kCTFontTableGSUB
    #    kCTFontTableJSTF
    #    kCTFontTableLTSH
    #    kCTFontTableOS2
    #    kCTFontTablePCLT
    #    kCTFontTableVDMX
    #    kCTFontTableVORG
    #    kCTFontTableZapf
    #    kCTFontTableAcnt
    #    kCTFontTableAvar
    #    kCTFontTableBdat
    #    kCTFontTableBhed
    #    kCTFontTableBloc
    #    kCTFontTableBsln
    #    kCTFontTableCmap
    #    kCTFontTableCvar
    #    kCTFontTableCvt
    #    kCTFontTableFdsc
    #    kCTFontTableFeat
    #    kCTFontTableFmtx
    #    kCTFontTableFpgm
    #    kCTFontTableFvar
    #    kCTFontTableGasp
    #    kCTFontTableGlyf
    #    kCTFontTableGvar
    #    kCTFontTableHdmx
    #    kCTFontTableHead
    #    kCTFontTableHhea
    #    kCTFontTableHmtx
    #    kCTFontTableHsty
    #    kCTFontTableJust
    #    kCTFontTableKern
    #    kCTFontTableLcar
    #    kCTFontTableLoca
    #    kCTFontTableMaxp
    #    kCTFontTableMort
    #    kCTFontTableMorx
    #    kCTFontTableName
    #    kCTFontTableOpbd
    #    kCTFontTablePost
    #    kCTFontTablePrep
    #    kCTFontTableProp
    #    kCTFontTableTrak
    #    kCTFontTableVhea
    #    kCTFontTableVmtx
    #
    #ctypedef enum CTFontTableOptions:
    #    kCTFontTableOptionNoOptions = 0
    #    kCTFontTableOptionExcludeSynthetic = (1 << 0)
    #

    cdef CFStringRef kCTFontCollectionRemoveDuplicatesOption

    ctypedef enum CTLineTruncationType:
        kCTLineTruncationStart  = 0
        kCTLineTruncationEnd    = 1
        kCTLineTruncationMiddle = 2

    # Fonts
    CTFontRef CTFontCreateWithName(CFStringRef name, CGFloat size,
        void *matrix)
    CTFontRef CTFontCreateWithFontDescriptor(CTFontDescriptorRef descriptor,
        CGFloat size, void *matrix)
    
    #CTFontRef CTFontCreateUIFontForLanguage(CTFontUIFontType uiType,
    #    CGFloat size, CFStringRef language)
    #CTFontRef CTFontCreateCopyWithAttributes(CTFontRef font, CGFloat size,
    #    void *matrix, CTFontDescriptorRef attributes)
    CTFontRef CTFontCreateCopyWithSymbolicTraits(CTFontRef font, CGFloat size,
        void *matrix, CTFontSymbolicTraits symTraitValue, 
        CTFontSymbolicTraits symTraitMask)
    #CTFontRef CTFontCreateCopyWithFamily(CTFontRef font, CGFloat size,
    #    void *matrix, CFStringRef family)
    #CTFontRef CTFontCreateForString(CTFontRef currentFont, CFStringRef string,
    #    CFRange range)
    CTFontDescriptorRef CTFontCopyFontDescriptor(CTFontRef font)
    CFTypeRef CTFontCopyAttribute(CTFontRef font, CFStringRef attribute)
    CGFloat CTFontGetSize(CTFontRef font)
    void CTFontGetMatrix(CTFontRef font)
    CTFontSymbolicTraits CTFontGetSymbolicTraits(CTFontRef font)
    CFDictionaryRef CTFontCopyTraits(CTFontRef font)
    CFStringRef CTFontCopyPostScriptName(CTFontRef font)
    CFStringRef CTFontCopyFamilyName(CTFontRef font)
    CFStringRef CTFontCopyFullName(CTFontRef font)
    CFStringRef CTFontCopyDisplayName(CTFontRef font)
    CFStringRef CTFontCopyName(CTFontRef font, CFStringRef nameKey)
    CFStringRef CTFontCopyLocalizedName(CTFontRef font, CFStringRef nameKey,
        CFStringRef *language)
    #CFCharacterSetRef CTFontCopyCharacterSet(CTFontRef font)
    CFStringEncoding CTFontGetStringEncoding(CTFontRef font)
    CFArrayRef CTFontCopySupportedLanguages(CTFontRef font)
    Boolean CTFontGetGlyphsForCharacters(CTFontRef font,
        UniChar characters[], CGGlyph glyphs[], CFIndex count)
    CGFloat CTFontGetAscent(CTFontRef font)
    CGFloat CTFontGetDescent(CTFontRef font)
    CGFloat CTFontGetLeading(CTFontRef font)
    unsigned CTFontGetUnitsPerEm(CTFontRef font)
    CFIndex CTFontGetGlyphCount(CTFontRef font)
    CGRect CTFontGetBoundingBox(CTFontRef font)
    CGFloat CTFontGetUnderlinePosition(CTFontRef font)
    CGFloat CTFontGetUnderlineThickness(CTFontRef font)
    CGFloat CTFontGetSlantAngle(CTFontRef font)
    CGFloat CTFontGetCapHeight(CTFontRef font)
    CGFloat CTFontGetXHeight(CTFontRef font)
    CGGlyph CTFontGetGlyphWithName(CTFontRef font, CFStringRef glyphName)
    CGRect CTFontGetBoundingRectsForGlyphs(CTFontRef font,
        CTFontOrientation orientation, CGGlyph glyphs[],
        CGRect boundingRects[],CFIndex count)
    double CTFontGetAdvancesForGlyphs(CTFontRef font, CTFontOrientation orientation,
        CGGlyph glyphs[], CGSize advances[], CFIndex count)
    void CTFontGetVerticalTranslationsForGlyphs(CTFontRef font,
        CGGlyph glyphs[], CGSize translations[], CFIndex count)
    CGPathRef CTFontCreatePathForGlyph(CTFontRef font, CGGlyph glyph,
        void * transform)
    
    CFArrayRef CTFontCopyVariationAxes(CTFontRef font)
    CFDictionaryRef CTFontCopyVariation(CTFontRef font)
    
    CFArrayRef CTFontCopyFeatures(CTFontRef font)
    CFArrayRef CTFontCopyFeatureSettings(CTFontRef font)
    CGFontRef CTFontCopyGraphicsFont(CTFontRef font, CTFontDescriptorRef *attributes)
    CTFontRef CTFontCreateWithGraphicsFont(CGFontRef graphicsFont, CGFloat size,
        void *matrix, CTFontDescriptorRef attributes)
    #ATSFontRef CTFontGetPlatformFont(CTFontRef font, CTFontDescriptorRef *attributes)
    #CTFontRef CTFontCreateWithPlatformFont(ATSFontRef platformFont, CGFloat size,
    #    void *matrix, CTFontDescriptorRef attributes)
    #CTFontRef CTFontCreateWithQuickdrawInstance(ConstStr255Param name,
    #    int16_t identifier, uint8_t style, CGFloat size)
    
    #CFArrayRef CTFontCopyAvailableTables(CTFontRef font,
    #    CTFontTableOptions options)
    #CFDataRef CTFontCopyTable(CTFontRef font, CTFontTableTag table,
    #    CTFontTableOptions options)

    # Font Collections
    CTFontCollectionRef CTFontCollectionCreateFromAvailableFonts(CFDictionaryRef options)
    CTFontCollectionRef CTFontCollectionCreateWithFontDescriptors(CFArrayRef descriptors,
        CFDictionaryRef options)
    #CTFontCollectionRef CTFontCollectionCreateCopyWithFontDescriptors(
    #    CTFontCollectionRef original, CFArrayRef descriptors,
    #    CFDictionaryRef options)
    CFArrayRef CTFontCollectionCreateMatchingFontDescriptors(CTFontCollectionRef collection)
    #CFArrayRef CTFontCollectionCreateMatchingFontDescriptorsSortedWithCallback(
    #    CTFontCollectionRef collection,
    #    CTFontCollectionSortDescriptorsCallback sortCallback,
    #    void* refCon)

    # Font Descriptors
    CTFontDescriptorRef CTFontDescriptorCreateWithNameAndSize(CFStringRef name,
        CGFloat size)
    CTFontDescriptorRef CTFontDescriptorCreateWithAttributes(
        CFDictionaryRef attributes)
    CTFontDescriptorRef CTFontDescriptorCreateCopyWithAttributes(
        CTFontDescriptorRef original, CFDictionaryRef attributes)
    
    #CTFontDescriptorRef CTFontDescriptorCreateCopyWithVariation(
    #    CTFontDescriptorRef original, CFNumberRef variationIdentifier,
    #    CGFloat variationValue)
    #CTFontDescriptorRef CTFontDescriptorCreateCopyWithFeature(
    #    CTFontDescriptorRef original, CFNumberRef featureTypeIdentifier,
    #    CFNumberRef featureSelectorIdentifier)
    #CFArrayRef CTFontDescriptorCreateMatchingFontDescriptors(
    #    CTFontDescriptorRef descriptor, CFSetRef mandatoryAttributes)
    #CTFontDescriptorRef CTFontDescriptorCreateMatchingFontDescriptor(
    #    CTFontDescriptorRef descriptor, CFSetRef mandatoryAttributes)
    #CFDictionaryRef CTFontDescriptorCopyAttributes(CTFontDescriptorRef descriptor)
    CFTypeRef CTFontDescriptorCopyAttribute( CTFontDescriptorRef descriptor,
        CFStringRef attribute)
    #CFTypeRef CTFontDescriptorCopyLocalizedAttribute(
    #    CTFontDescriptorRef descriptor, CFStringRef attribute,
    #    CFStringRef *language)

    # Lines
    CTLineRef CTLineCreateWithAttributedString(CFAttributedStringRef string)
    CTLineRef CTLineCreateTruncatedLine(CTLineRef line, double width,
        CTLineTruncationType truncationType, CTLineRef truncationToken)
    CTLineRef CTLineCreateJustifiedLine(CTLineRef line, CGFloat justificationFactor,
        double justificationWidth)
    CFIndex CTLineGetGlyphCount(CTLineRef line)
    CFArrayRef CTLineGetGlyphRuns(CTLineRef line)
    CFRange CTLineGetStringRange(CTLineRef line)
    double CTLineGetPenOffsetForFlush(CTLineRef line, CGFloat flushFactor,
        double flushWidth)
    void CTLineDraw(CTLineRef line, CGContextRef context)
    CGRect CTLineGetImageBounds(CTLineRef line, CGContextRef context)
    double CTLineGetTypographicBounds(CTLineRef line, CGFloat* ascent,
        CGFloat* descent, CGFloat* leading)
    double CTLineGetTrailingWhitespaceWidth(CTLineRef line)
    CFIndex CTLineGetStringIndexForPosition(CTLineRef line, CGPoint position)
    CGFloat CTLineGetOffsetForStringIndex(CTLineRef line, CFIndex charIndex,
        CGFloat* secondaryOffset)