1 /* Copyright (c) 2008 Christopher J. W. Lloyd
3 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
8 #import <Foundation/NSObject.h>
9 #import <Onyx2D/O2Geometry.h>
11 @
class O2Font
, O2Encoding
;
13 typedef O2Font
*O2FontRef
;
15 typedef uint16_t O2Glyph
;
17 #import <Onyx2D/O2Context.h>
18 #import <Onyx2D/O2DataProvider.h>
19 //#import <Onyx2D/O2Image.h>
21 #define O2FONTLOGGINGENABLED 0
23 #if O2FONTLOGGINGENABLED
24 #define O2FontLog(format, args...) NSLog(@"%s line: %d | %@", __PRETTY_FUNCTION__, __LINE__, [NSString stringWithFormat:format, ##args])
26 #define O2FontLog(format, args...)
32 O2FontPlatformTypeGDI
,
33 O2FontPlatformTypeFreeType
,
36 @interface O2Font
: NSObject
{
37 O2FontPlatformType _platformType
;
39 NSCharacterSet
*_coveredCharSet
;
40 O2DataProviderRef _provider
;
52 O2Glyph
*_MacRomanEncoding
;
55 // Font name mapping : platform specific font class may override
56 // these methods in a category O2Font(<platformname>) if some
57 // mapping is needed between the font postscript names and the
58 // native names used by the platform
59 + (NSString
*)nativeFontNameForPostscriptName
:(NSString
*)name
;
60 + (NSString
*)postscriptNameForNativeName
:(NSString
*)name
;
61 + (NSString
*)postscriptNameForDisplayName
:(NSString
*)name
;
62 + (NSString
*)displayNameForPostscriptName
:(NSString
*)name
;
63 + (NSString
*)postscriptNameForFontName
:(NSString
*)name
;
65 + (NSArray
*)preferredFontNames
;
66 + (void)setPreferredFontNames
:(NSArray
*)fontNames
;
68 - initWithFontName
:(NSString
*)name
;
69 - initWithDataProvider
:(O2DataProviderRef
)provider
;
71 - (NSData
*)copyTableForTag
:(uint32_t)tag
;
73 - (O2Glyph
)glyphWithGlyphName
:(NSString
*)name
;
74 - (NSString
*)copyGlyphNameForGlyph
:(O2Glyph
)glyph
;
76 - (NSCharacterSet
*)coveredCharacterSet
;
78 - (float)nativeSizeForSize
:(float)size
;
80 - (void)fetchAdvances
;
82 - (O2Encoding
*)createEncodingForTextEncoding
:(O2TextEncoding
)encoding
;
84 O2FontRef
O2FontCreateWithFontName(NSString
*name
);
85 O2FontRef
O2FontCreateWithDataProvider(O2DataProviderRef provider
);
86 O2FontRef
O2FontRetain(O2FontRef self
);
87 void O2FontRelease(O2FontRef self
);
89 O2FontPlatformType
O2FontGetPlatformType(O2Font
*self
);
90 CFStringRef
O2FontCopyFullName(O2FontRef self
);
91 int O2FontGetUnitsPerEm(O2FontRef self
);
92 int O2FontGetAscent(O2FontRef self
);
93 int O2FontGetDescent(O2FontRef self
);
94 int O2FontGetLeading(O2FontRef self
);
95 int O2FontGetCapHeight(O2FontRef self
);
96 int O2FontGetXHeight(O2FontRef self
);
97 O2Float
O2FontGetItalicAngle(O2FontRef self
);
98 O2Float
O2FontGetStemV(O2FontRef self
);
99 O2Rect
O2FontGetFontBBox(O2FontRef self
);
101 NSCharacterSet
*O2FontGetCoveredCharacterSet(O2FontRef self
);
103 size_t O2FontGetNumberOfGlyphs(O2FontRef self
);
104 BOOL
O2FontGetGlyphAdvances(O2FontRef self
, const O2Glyph
*glyphs
, size_t count
, int *advances
);
106 O2Glyph
O2FontGetGlyphWithGlyphName(O2FontRef self
, CFStringRef name
);
107 NSString
*O2FontCopyGlyphNameForGlyph(O2FontRef self
, O2Glyph glyph
);
109 NSData
*O2FontCopyTableForTag(O2FontRef self
, uint32_t tag
);
111 uint16_t O2FontUnicodeForGlyphName(CFStringRef name
);