On Aug 10, 2012, at 10:55 AM, Sixten Otto <hims...@sfko.com> wrote:

> I could, as you say, measure the drawn sizes of the localized strings.
> I guess my resistance to that idea is really that I'd have to do it a
> couple of times (the width of the whole string, and the position of
> the decimal separator), and that it seems likely to be really slow.

No slower than the kind of layout the text system is already doing in most 
apps. :)

I think all you need to do is measure each number once. Find the offset in the 
string of the decimal point, measure the width of the substring before it, then 
move that far to the left of your desired decimal guideline before drawing the 
entire string.

If you want to find the maximum width, then you'll also need to measure the 
width of the entire string. (Don't just measure the width of the substring 
starting at the decimal point and add that to the first width; due to factors 
like kerning, you can't add substring widths that way.)

—Jens
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to