Re: [Pyobjc-dev] CoreText CTFontCreatePathForGlyph :: not defined?
Brought to you by:
ronaldoussoren
|
From: James T. <tra...@gm...> - 2009-04-26 09:01:48
|
Gauging from the fact that this thread has gone stale, Is it safe to assume that this just isn't possible with pyobjc? -jt On Thu, Apr 23, 2009 at 9:17 AM, James Trankelson <tra...@gm...> wrote: > Ok, now using ord: > > v, gl = CTFontGetGlyphsForCharacters(font, ord(u'x'), None, 1) > > Produces: > > TypeError: Expecting UniChar > > -jt > > On Thu, Apr 23, 2009 at 7:43 AM, Ronald Oussoren <ron...@ma...> wrote: >> >> On 23 Apr, 2009, at 0:55, James Trankelson wrote: >> >>> Ok, so in order to do this, I need to install the version in the trunk. >> >> You don't have to install the version in the trunk, if you manually convert >> unicode characters to integers (using "ord", rather than the unichar >> function I mentioned yesterday) >>> >>> I hate to say it, but that's causing me trouble as well... >> >> Phew, I'm glad that didn't work. Please don't install PyObjC 2.2 in the >> system install of Python. There are differences between the current edition >> of PyObjC and the version included in Leoopard and I don't know if those >> changes are backward compatible. That means that installing an updated >> version of PyObjC could break system components (especially on Leopard >> Server). >> >> Sadly enough the version in the trunk isn't ready to be installed by new >> users yet, I need to do some work on packaging (makeing sure that it can be >> installed from source with the Python.org distribution, provide binary >> packages, ...). >> >> Ronald >> >>> >>> $ sudo easy_install pyobjc==2.2b1 >>> >>> Searching for pyobjc==2.2b1 >>> ... >>> Running pyobjc-2.2b1/setup.py -q bdist_egg --dist-dir >>> /tmp/easy_install-_86MCZ/pyobjc-2.2b1/egg-dist-tmp-Q8jX-H >>> The required version of setuptools (>=0.6c9) is not available, and >>> can't be installed while this script is running. Please install >>> a more recent version first, using 'easy_install -U setuptools'. >>> >>> (Currently using setuptools 0.6c7 >>> >>> (/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python)) >>> error: Setup script exited with 2 >>> >>> $ sudo easy_install -U setuptools >>> Searching for setuptools >>> Reading http://pypi.python.org/simple/setuptools/ >>> Best match: setuptools 0.6c9 >>> Processing setuptools-0.6c9-py2.5.egg >>> setuptools 0.6c9 is already the active version in easy-install.pth >>> Installing easy_install script to /usr/local/bin >>> Installing easy_install-2.5 script to /usr/local/bin >>> >>> Using /Library/Python/2.5/site-packages/setuptools-0.6c9-py2.5.egg >>> Processing dependencies for setuptools >>> Finished processing dependencies for setuptools >>> >>> $ sudo easy_install pyobjc==2.2b1 >>> >>> (Same as first try) >>> >>> Is there some config file that will allow me to get this to point to >>> the right setuptools? >>> >>> Thanks again. >>> >>> -jt >>> >>> On Wed, Apr 22, 2009 at 10:29 PM, Ronald Oussoren >>> <ron...@ma...> wrote: >>>> >>>> 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 >>>>>> >>>> >>>> >> >> > |