Re: [Pyobjc-dev] CoreText CTFontCreatePathForGlyph :: not defined?
Brought to you by:
ronaldoussoren
|
From: Ronald O. <ron...@ma...> - 2009-04-22 20:29:55
|
On 22 Apr, 2009, at 14:38, James Trankelson wrote:
> Bah. Thanks. Still not quite out of the woods, though.
>
> Now it's not having trouble finding the function
> (CTFontCreatePathForGlyph), but I get a new error:
>
> depythonifying 'short', got 'unicode' of 1
I should have mentioned that, the version of pyobjc that's included
with Leopard cannot do what you want it to do. You must pass
unichar(u'a')) instead of u'a'. The reason for that is that "unichar"
is an alias for "short int" in (Objective-)C, both result in the same
metadata.
The version of PyObjC that's in the subversion repository does know
the difference between "unichar" and "unsigned short" using hacks in
the metadata file.
>
> My usage is nearly identical to an example in cttests.py for obtaining
> a font and getting the Glyph from it:
>
> v, gl = CTFontGetGlyphsForCharacters(font, u'x', None, 1)
> v = CTFontCreatePathForGlyph(font, gl[0], None)
>
> This leads me to wonder if the signature mentioned previously for
> CTFontCreatePathForGlyph was incorrect:
>
> '@@sn^{CGAffineTransform=ffffff}'
>
> Unfortunately, I can't find any documentation on how to map the
> signatures. For someone that knows, is this signature correct?
The signature is correct. "s" is the encoding for both "short int" and
"unichar".
Ronald
>
> Thanks
>
> -jt
>
>
> On Wed, Apr 22, 2009 at 10:19 AM, Petr Mifek
> <pet...@an...> wrote:
>> Hi,
>>
>> James, import CoreText is missing there.
>>
>> Cheers, Petr
>>
>> James Trankelson wrote:
>>>
>>> It seems like some names can't be found. CoreText is one of them.
>>>
>>> from CoreText import *
>>> objc.loadBundleFunctions(CoreText.__bundle__, globals(), [
>>> ('CTFontCreatePathForGlyph',
>>> '@@sn^{CGAffineTransform=ffffff}')
>>> ], False)
>>>
>>> Produces: NameError: name 'CoreText' is not defined
>>>
>>> I tried manually loading the bundle as follows:
>>>
>>> objc.loadBundle("CoreText", globals(),
>>>
>>> bundle_path=objc.pathForFramework(u'/Developer/SDKs/MacOSX10.5.sdk/
>>> System/Library/Frameworks/ApplicationServices.framework/Versions/A/
>>> Frameworks/CoreText.framework'))
>>>
>>> Which also fails.
>>>
>>> -jt
>>>
>>> On Wed, Apr 22, 2009 at 7:22 AM, Ronald Oussoren <ron...@ma...
>>> >
>>> wrote:
>>>>
>>>> On 21 Apr, 2009, at 20:59, James Trankelson wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I'm trying to do some CoreText suff (10.5). Most of the calls are
>>>>> fine, but one fails:
>>>>>
>>>>> global name 'CTFontCreatePathForGlyph' is not defined
>>>>>
>>>>> Is there any way around this?
>>>>
>>>> Which version of PyObjC do you use? I guess it's the one included
>>>> in
>>>> Leopard, that seems to mis the symbol while PyObjC 2.2 does have
>>>> it.
>>>>
>>>> Adding a new function can be done using objc.loadBundleFunctions:
>>>>
>>>> import objc
>>>> import CoreText
>>>> objc.loadBundleFunctions(CoreText.__bundle__, globals(), [
>>>> ('CTFontCreatePathForGlyph',
>>>> '@@sn^{CGAffineTransform=ffffff}')
>>>> ], False)
>>>>
>>>> The code above (untested) should add 'CTFontCreatePathForGlyph'
>>>> to the
>>>> globals dictionary.
>>>>
>>>> Ronald
>>>>>
>>>>> Thanks
>>>>>
>>>>> -jt
>>>>>
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> Stay on top of everything new and different, both inside and
>>>>> around Java (TM) technology - register by April 22, and save
>>>>> $200 on the JavaOne (SM) conference, June 2-5, 2009, San
>>>>> Francisco.
>>>>> 300 plus technical and hands-on sessions. Register today.
>>>>> Use priority code J9JMT32. http://p.sf.net/sfu/p
>>>>> _______________________________________________
>>>>> Pyobjc-dev mailing list
>>>>> Pyo...@li...
>>>>> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev
>>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Stay on top of everything new and different, both inside and
>>> around Java
>>> (TM) technology - register by April 22, and save
>>> $200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
>>> 300 plus technical and hands-on sessions. Register today. Use
>>> priority
>>> code J9JMT32. http://p.sf.net/sfu/p
>>> _______________________________________________
>>> Pyobjc-dev mailing list
>>> Pyo...@li...
>>> https://lists.sourceforge.net/lists/listinfo/pyobjc-dev
>>
|