-
-
Notifications
You must be signed in to change notification settings - Fork 689
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1399 from freakboy3742/cocoa-fonts
Initial implementation of Cocoa and iOS font loading.
- Loading branch information
Showing
17 changed files
with
198 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
Support for custom font loading was added to the GTK backend. | ||
Support for custom font loading was added to the GTK, Cocoa and iOS backends. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,106 +1,23 @@ | ||
########################################################################## | ||
# System/Library/Frameworks/CoreText.framework | ||
########################################################################## | ||
from ctypes import POINTER, c_bool, c_double, c_uint32, c_void_p, cdll, util | ||
|
||
from rubicon.objc import CFIndex, CGFloat, CGGlyph, CGRect, CGSize, UniChar | ||
from ctypes import c_bool, c_uint32, c_void_p, cdll, util | ||
|
||
###################################################################### | ||
core_text = cdll.LoadLibrary(util.find_library("CoreText")) | ||
###################################################################### | ||
|
||
###################################################################### | ||
# CTFontDescriptor.h | ||
|
||
CTFontOrientation = c_uint32 | ||
|
||
###################################################################### | ||
# CTFontTraits.h | ||
|
||
CTFontSymbolicTraits = c_uint32 | ||
|
||
###################################################################### | ||
# CTFont.h | ||
core_text.CTFontGetBoundingRectsForGlyphs.restype = CGRect | ||
core_text.CTFontGetBoundingRectsForGlyphs.argtypes = [ | ||
c_void_p, | ||
CTFontOrientation, | ||
POINTER(CGGlyph), | ||
POINTER(CGRect), | ||
CFIndex, | ||
] | ||
|
||
core_text.CTFontGetAdvancesForGlyphs.restype = c_double | ||
core_text.CTFontGetAdvancesForGlyphs.argtypes = [ | ||
c_void_p, | ||
CTFontOrientation, | ||
POINTER(CGGlyph), | ||
POINTER(CGSize), | ||
CFIndex, | ||
] | ||
|
||
core_text.CTFontGetAscent.restype = CGFloat | ||
core_text.CTFontGetAscent.argtypes = [c_void_p] | ||
|
||
core_text.CTFontGetDescent.restype = CGFloat | ||
core_text.CTFontGetDescent.argtypes = [c_void_p] | ||
|
||
core_text.CTFontGetSymbolicTraits.restype = CTFontSymbolicTraits | ||
core_text.CTFontGetSymbolicTraits.argtypes = [c_void_p] | ||
|
||
core_text.CTFontGetGlyphsForCharacters.restype = c_bool | ||
core_text.CTFontGetGlyphsForCharacters.argtypes = [ | ||
c_void_p, | ||
POINTER(UniChar), | ||
POINTER(CGGlyph), | ||
CFIndex, | ||
] | ||
|
||
core_text.CTFontCreateWithGraphicsFont.restype = c_void_p | ||
core_text.CTFontCreateWithGraphicsFont.argtypes = [ | ||
c_void_p, | ||
CGFloat, | ||
c_void_p, | ||
c_void_p, | ||
] | ||
|
||
core_text.CTFontCopyFamilyName.restype = c_void_p | ||
core_text.CTFontCopyFamilyName.argtypes = [c_void_p] | ||
|
||
core_text.CTFontCopyFullName.restype = c_void_p | ||
core_text.CTFontCopyFullName.argtypes = [c_void_p] | ||
|
||
core_text.CTFontCreateWithFontDescriptor.restype = c_void_p | ||
core_text.CTFontCreateWithFontDescriptor.argtypes = [c_void_p, CGFloat, c_void_p] | ||
|
||
core_text.CTFontDescriptorCreateWithAttributes.restype = c_void_p | ||
core_text.CTFontDescriptorCreateWithAttributes.argtypes = [c_void_p] | ||
|
||
###################################################################### | ||
# CTFontDescriptor.h | ||
|
||
kCTFontFamilyNameAttribute = c_void_p.in_dll(core_text, "kCTFontFamilyNameAttribute") | ||
kCTFontTraitsAttribute = c_void_p.in_dll(core_text, "kCTFontTraitsAttribute") | ||
|
||
###################################################################### | ||
# CTFontTraits.h | ||
|
||
kCTFontSymbolicTrait = c_void_p.in_dll(core_text, "kCTFontSymbolicTrait") | ||
kCTFontWeightTrait = c_void_p.in_dll(core_text, "kCTFontWeightTrait") | ||
|
||
kCTFontItalicTrait = 1 << 0 | ||
kCTFontBoldTrait = 1 << 1 | ||
|
||
###################################################################### | ||
# CTLine.h | ||
|
||
core_text.CTLineCreateWithAttributedString.restype = c_void_p | ||
core_text.CTLineCreateWithAttributedString.argtypes = [c_void_p] | ||
|
||
core_text.CTLineDraw.restype = None | ||
core_text.CTLineDraw.argtypes = [c_void_p, c_void_p] | ||
core_text.CTFontManagerRegisterFontsForURL.restype = c_bool | ||
core_text.CTFontManagerRegisterFontsForURL.argtypes = [c_void_p, c_uint32, c_void_p] | ||
|
||
###################################################################### | ||
# CTStringAttributes.h | ||
# CTFontManagerScope.h | ||
|
||
kCTFontAttributeName = c_void_p.in_dll(core_text, "kCTFontAttributeName") | ||
kCTFontManagerScopeNone = 0 | ||
kCTFontManagerScopeProcess = 1 | ||
kCTFontManagerScopePersistent = 2 | ||
kCTFontManagerScopeSession = 3 | ||
kCTFontManagerScopeUser = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.