Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: DrawThemeTextBox mis-renders Symbol, Wingding fonts



Sorry, I haven't had time recently to read carbon-dev. I have 571 messages waiting to catch up on... :-/

Symbol is a Unicode font, and does not have any ASCII characters in it. Wingdings is a dingbat (or "pi") font and does not have any ASCII characters in it either.

Some pi fonts map characters in the ASCII range, but based on my copy of Wingdings, it's not one of them. It has a MacRoman cmap and a Microsoft symbol cmap. HIDrawThemeTextBox will use the Microsoft symbol cmap, which maps characters into the Unicode private use area (PUA) starting at U+F020. QuickDraw uses the MacRoman cmap, which does map characters into the MacRoman range (naturally).

Character Palette is your friend. Open Character Palette, switch to the glyph view, and choose any font. Then select (click on) the glyph of interest and hover over it to see what Unicode character code is used (if any) to draw it.

Deborah Goldsmith
Internationalization, Unicode Liaison
Apple Inc.
email@hidden

On Aug 30, 2007, at 11:22 AM, Jim Prouty wrote:

Laurence Harris <email@hidden> replied:

I'm confused. Your example uses ASCII text, but you say the problem
is with drawing Symbol and Wingdings. It sounds like you're trying to
do a direct conversion of the old technique you were using in your
QuickDraw code. The best thing to do in Mac OS X is to use Unicode
for your text and let DrawThemeTextBox use whatever font it needs for
each character.

Larry

Yes, it's a "direct conversion" attempt. Sorry :-)

A complete rewrite is in the works, but in the short term I'm pressing
DrawThemeTextBox(cfstr, kThemeCurrentPortFont, etc) into service to render
antialiased text (simple strings) in a user-selected (QD) font.


(I'm no Unicode expert, but I'm pretty sure Unicode doesn't specify the
exact font to render Unicode text, otherwise we'd be re-encoding the text
every time a user chose Times New Roman instead of another Roman font like
Bodoni or Futura. I do know that Symbol, etc contain glyphs that Unicode
uses to render standard "unusual" characters such as the mathematical
summation symbol "sigma", etc. But I'll bet there's no Unicode character
defined for most of the glyphs in a Wingdings font.)


However, it's clear from experimentation that changing the string
formulation from:

	CFStringAppendCString(cfstr, "Hello World!",
GetApplicationTextEncoding());

to

	CFStringAppendCString(cfstr, "Hello World!",
GetThemeFontTextEncoding ());

produces different results when that cfstr is passed to DrawThemeTextBox(),
a successful change in the case of Apple's Trutype Symbol font, but not in
the case of any in the Wingding family.


DrawThemeTextBox works well for nearly every other QuickDraw font I set for
the current port.


So I'm hoping there's something obvious to a font/theme expert that's wrong
in my use of DrawThemeTextBox or the CFStringAppendCString encoding (thus
my CC to Deborah Goldsmith).


--Jim

-------- Code repost intended for the reader's convenience:
------------------------

	short familyID;

	Rect r= {0,0,200,12};

	GetFNum("\pSymbol", &familyID);	// or "\pWingdings"

	TextFont(familyID);

	CFMutableStringRef cfstr= CFStringCreateMutable(NULL,0);

	CFStringAppendCString(cfstr, "Hello World!",
GetThemeFontTextEncoding (kThemeCurrentPortFont));

	DrawThemeTextBox(cfstr, kThemeCurrentPortFont, kThemeStateActive,
0, &r, teFlushLeft, NULL);

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?

(Mac OS X 10.4.10, Xcode 2.4).
--

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
References: 
 >DrawThemeTextBox mis-renders Symbol, Wingding fonts (From: Jim Prouty <email@hidden>)
 >Re: DrawThemeTextBox mis-renders Symbol, Wingding fonts (From: Laurence Harris <email@hidden>)
 >Re: DrawThemeTextBox mis-renders Symbol, Wingding fonts (From: Jim Prouty <email@hidden>)



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

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.