Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Questions regarding SystemEncoding used for controls
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Questions regarding SystemEncoding used for controls



I am working with Metrowerks PowerPlant 6.0 under OS X. One thing we have
noticed is that LStaticText does not draw Aqua theme-compliant text. This
is because it uses the ::DrawText() method to draw the text directly, which
bypasses the Quartz drawing layer and results in text that is not properly
anti-aliased and does not use the appropriate theme fonts. We have a large
legacy PowerPlant codebase and so are not prepared currently to switch to a
different framework; hence, it would be helpful to be able to continue to
use LStaticText in our PPobs.
I have been working on making a revised version of
UDrawingUtils.cp::DrawWithJustification, which is the function used by
LStaticText to draw the text. The new version uses the function
DrawThemeTextBox to draw the text instead. It works well but I have run
into some issues.

The most important issue I have found involves international text, most
obviously Japanese.
DrawThemeTextBox requires that I translate the Pascal string used by
LStaticText into a CFString, which requires that an encoding be specified.
I am using the function CFStringGetSystemEncoding() to get the current
encoding used by the System. However, this appears to have limitations.
If the OS is set to use Japanese, then Japanese text drawn using
DrawThemeTextBox will appear correctly. However, if the OS is not in
Japanese, then CFStringGetSystemEncoding() returns MacRoman as the
encoding, and then my Japanese text appears as decomposed Roman characters.

This problem occurs even when I set the localization code in the 'vers'
resource to Japan. I notice that other controls, such as LCheckBox and
LRadioButton (which PowerPlant implements by calling the toolbox function
::NewControl, which apparently resolves to an Aqua control creator in
Carbon) draw Japanese text correctly even when the OS is not Japanese, if
the 'vers' resource specifies a Japanese localization. Apparently, then,
these controls are getting encoding information from something other than
just the System Encoding. I have not been able to find an API for this.

Another problem I notice is that if I have English text, set to use the
System font, and I run the application under the Japanese OS, then the
English text drawn by DrawThemeTextBox is drawn using the Japanese System
font and not Lucida Grande, so it does not match the text labels on other
controls.

My goal is to have the text drawn by LStaticText match the text drawn by
other controls in all cases (unless a different font, size, or style is
chosen for the LStaticText, of course).

Questions:
(1) does anyone know how I can get a SystemEncoding that will take into
account the localization in the 'vers' resource?
(2) does anyone know how controls set to use "System Font" manage to use
Lucida Grande as their font under the Japanese OS, and is there a way I can
get DrawThemetextBox to do the same?
(3) has anyone implemented an alternative, perhaps more successful, and
sharable solution to use LStaticText and the PowerPlant framework
successfully in a Carbon application under OS X?

I won't be able to use recommendations such as "Don't use PowerPlant for
Carbon development," so I'm hoping to get useful answers to some of the
above.

Please respond directly to my email address.

Thanks,

Blake Hodgetts
Sr. SQA Engineer
Symantec Corp.




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.