Hi, for a text background graphic I need the character box sizes of a given string. I managed to collect the needed info (width, height, depth, kerns), but there is still some flaw in the kerning part. For example: "VATo" is printed out (in the shell) as V 12 11 0 *kerning -85721.088 A 10 11 0 *kerning -64487.424 T 10 11 0 *kerning -64487.424 o 7 7 0 The character stands in the first column, followed by width, height and depth (in pixel). The "*kerning" line shows the kerning value (in sp) of the neighbouring character pair. No problem here. But "A much longer Test graphic VATo" A 12 11 0 5 0 0 m 13 7 0 *kerning -21233.664 u 8 7 0 c 7 7 0 *kerning -21233.664 h 8 11 0 5 0 0 l 4 11 0 o 7 7 0 n 9 7 0 g 8 7 3 e 7 7 0 r 6 7 0 5 0 0 T 11 11 0 e 7 7 0 s 6 7 0 t 6 10 0 5 0 0 g 8 7 3 r 6 7 0 a 8 7 0 p 9 7 3 h 8 11 0 i 4 10 0 c 7 7 0 5 0 0 V 12 11 0 A 12 11 0 T 11 11 0 o 7 7 0 sees no kerning for "VATo" (although the text is printed with the correct kerning). What am I missing? Example code is attached. Peter
On 01/07/2011 02:48 PM, Peter Rolf wrote:
The character stands in the first column, followed by width, height and depth (in pixel). The "*kerning" line shows the kerning value (in sp) of the neighbouring character pair. No problem here.
But "A much longer Test graphic VATo"
sees no kerning for "VATo" (although the text is printed with the correct kerning).
What am I missing? Example code is attached.
Your code only reports a kern if it happens between the first occurrence of a certain glyph and is predecessor. After that first attempt, the if not char[u] then ... condition evaluates to false, so no further reporting is done. In other words, your longer example fails to report anything for the "VA", "AT", and "To" combinations because all the second glyphs in the pairs have already been seen before in a non-kerned combination ("A", "lo", " T"). You have to rethink the loop logic. Best wishes, Taco
Am 07.01.2011 15:13, schrieb Taco Hoekwater:
On 01/07/2011 02:48 PM, Peter Rolf wrote:
The character stands in the first column, followed by width, height and depth (in pixel). The "*kerning" line shows the kerning value (in sp) of the neighbouring character pair. No problem here.
But "A much longer Test graphic VATo"
sees no kerning for "VATo" (although the text is printed with the correct kerning).
What am I missing? Example code is attached.
Your code only reports a kern if it happens between the first occurrence of a certain glyph and is predecessor. After that first attempt, the
if not char[u] then ...
condition evaluates to false, so no further reporting is done.
In other words, your longer example fails to report anything for the "VA", "AT", and "To" combinations because all the second glyphs in the pairs have already been seen before in a non-kerned combination ("A", "lo", " T").
You have to rethink the loop logic.
Ah, I see the problem now. Many thanks Taco!!!!! :-) Best wishes, Peter
participants (2)
-
Peter Rolf
-
Taco Hoekwater