I'm revising a QuickDraw-based program to draw aliased text using
DrawThemeTextBox.
With the standard Apple TrueType Symbol font installed, the text is
rendered with something that looks like Times New Roman instead of Symbol.
With an Adobe Postscript font installed, the text is rendered with the
Symbol font.
I'm starting from a QuickDraw font number for the Symbol font, and ASCII
text I want to draw.
My code fragment is:
short familyID;
Rect r= {0,0,200,12};
GetFNum("\pSymbol", &familyID); // or "\pWingdings"
TextFont(familyID);
CFMutableStringRef cfstr= CFStringCreateMutable(NULL,0);
CFStringAppendCString(cfstr, "Hello World!",
GetApplicationTextEncoding());
DrawThemeTextBox(cfstr, kThemeCurrentPortFont, kThemeStateActive,
0, &r, teFlushLeft, NULL);
The problem is showing up on PPC and Intel Macintoshes running 10.4.10 (at
least, probably on other OS versions).
I'm using Xcode 2.4 (10.3.9/10.4 SDKs) if that matters.
The use of GetApplicationTextEncoding() seemed a little shaky, so I tried
replacing GetApplicationTextEncoding() with
GetThemeFontTextEncoding(kThemeCurrentPortFont), a routine based on my
interpretation of some old Carbon list postings by Deborah Smith:
TextEncoding
GetThemeFontTextEncoding(ThemeFontID inFontID)
{
TextEncoding te;
OSStatus status= noErr+1;
if( inFontID == kThemeCurrentPortFont ) {
Str255 pfontName;
ScriptCode textScriptID;
LangCode textLanguageID;
int fontNum = GetPortTextFont(QDCurrentPort());
te= ATSFontFamilyGetEncoding((ATSFontFamilyRef)fontNum);
RevertTextEncodingToScriptInfo(te, &textScriptID,
&textLanguageID, NULL);
GetFontName(fontNum, pfontName);
status= UpgradeScriptInfoToTextEncoding(textScriptID,
textLanguageID, kTextRegionDontCare, pfontName, &te);
}
if( status != noErr )
te= GetApplicationTextEncoding();
return te;
}
UpgradeScriptInfoToTextEncoding sets te to kCFStringEncodingMacSymbol (33)
for Symbol and 131072 or 0x20000 for Wingdings with status == noErr.
Using my GetThemeFontTextEncoding(), I can get Symbol to render properly,
but Wingdings doesn't.
Image of Symbol and Wingdings results when using GetThemeFontTextEncoding()
in my code fragment here:
http://www.wavemetrics.com/junk/DrawThemeTextBoxDingbats.png
Any ideas on how to get Wingdings and other fonts to render correctly?
--
Jim "How does it work?" Prouty
Voice: (503) 620-3001, FAX: (503) 620-6754
Makers of IGOR Pro, scientific data analysis and graphing for Mac and PC
http://www.wavemetrics.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden
This email sent to email@hidden