|
From: | Mickey Gabel |
Subject: | Re: [ft] TrueType ignoring white space |
Date: | Sun, 15 Jun 2008 10:48:19 +0300 |
User-agent: | Thunderbird 2.0.0.14 (Windows/20080421) |
Junior wrote:
Hi All, I'm trying to confirm whether this observation is true or this is a user error. I have a ttf file I use to write text. When I have a string that ha a fixed number of bytes but may be padded with white space (0x20), it appears that the ending while spaces are ignored. Is this a normal behaviour? This seems odd because the other spaces in that string shows up. If I have a ttf file - sat times.ttf - and generated a size 12 font, should ALL character be size 12 (including white spaces)? Thanks, Jr.
This could be an artifact of the way you draw strings, since spaces normally are empty and do not have a bounding box.
For example, suppose you get a bounding box for the string (as described in the tutorial). Since spaces have empty bounding boxes, they are not included in the string. However, spaces DO have an "advance" so supposing you are drawing from left to right, and your string is something like:
" a "The left spaces advance pen positions for the 'a', so when taking into account initial pen position and the bounding box, the leftmost spaces are expressed. However the rightmost spaces do not advance any actual bounding box so they normally don't appear anywhere, and the end result is that the rightmost trailing spaces are "ignored". Especially when you are doing things like right justification.
This is actually not such a bad behavior, it sort of makes sense. Window's DrawText() function seems to have the same behavior, so you are in good company.
What I did to avoid this is to calculate a fake bounding box for empty glyphs, based on metrics (suggested by Werner, so of course it works :)
Mickey
[Prev in Thread] | Current Thread | [Next in Thread] |