realbasic-nug
[Top] [All Lists]

Stringwidth in 1-bit pictures

To: RbNUG Users Group <realbasic-nug at lists dot realsoftware dot com>
Subject: Stringwidth in 1-bit pictures
From: Peter Truskier <peter at premediasystems dot com>
Date: Tue, 11 May 2004 20:39:04 -0700
Delivered-to: realbasic-nug at lists dot realsoftware dot com
List-help: <mailto:realbasic-nug-request@lists.realsoftware.com?subject=help>
List-id: REALbasic NUG <realbasic-nug.lists.realsoftware.com>
List-post: <mailto:realbasic-nug@lists.realsoftware.com>
I wonder if this makes sense to anyone ...

I am writing some routines to align multiple stringshapes into a group2D to represent a "paragraph." In order to calculate left-, center- and right- alignment, I need to get the width of each line. I create a temporary picture to have access to its graphics property so I can use its stringwidth function.

Because the stringwidth method of the graphics class returns an integer, and I'd like more precision, I set the graphics textsize to 10 times that of my stringshape, and then divide the stringwidth by 10 after I get it from the graphics.

I have noticed that the string widths calculated from the graphics class are not terribly accurate if I get them from a 1-bit picture, causing quite noticeable mis-alignment. However, they are much more accurate if I create an 8-bit temporary picture instead.

Can someone explain this? It's not a big deal now that I've found a way around it, but I'd be interested to know nonetheless.

Thanks,
--
Peter Truskier
Premedia Systems, Inc.
Berkeley, CA USA

_______________________________________________
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>