My code to reassemble text from pieces written to EMF files is working great now except for one nagging problem, which only shows up in a few special cases involving manually kerned text. Consider these three sequences:
1. <period><space><A>(hkern + 3.75)<vertical bar> 2. <period><A>(hkern + 3.75)<vertical bar> 3. <period><space><A><vertical bar>
The individual pieces written to the EMF (not reassembled) map exactly onto the originals, so there is no problem in the output coordinates. However, when reassembled into a single <text><tspan> complex (2) and (3) are still OK, but (1) is off, with the vertical bar offset leftwards towards the "A", yet the ". A" is exactly where it should be. I have tracked the problem down to the extent that I know Inkscape's display code is calculating the width of ". A" differently, when manual kerning is present, than just the sum of the advances of those characters. (Logic: the complex looks like <text><tspan></tspan><tspan</tspan><text> and the second tspan pair has a dx value calculated by subtracting from the start position of the fragment [which is correct] the start position of the previous fragment [which is also correct] plus the width of the previous fragment [which must therefore not be correct]. Changing dx to match the original kerning fixes the problem - also consistent with the calculated width not matching that from Freetype2.) Inkscape seems not to be using Freetype Kerning corrections of this type:
FT_Get_Kerning( fsp->face, prev_glyph_index, glyph_index, kern_mode, &akerning )
I tried adding that, and while there was a correction for " A", it only half fixed the problem. Besides, I could not find a call to FT_Get_Kerning anywhere in the source. (It might be called indirectly by some other library.)
This was all done on one machine, so it isn't a case of mismatched fonts between machines.
Anybody have a thought on what Inkscape might be doing to come up with a different string width in this particular instance?
Thanks,
David Mathog mathog@...1176... Manager, Sequence Analysis Facility, Biology Division, Caltech
On 27-Nov-2012 13:07, mathog wrote: I should add that there is a discontinuous change between
<period><space><A><vertical bar>
and
<period><space><A>(hkern + 0.01)<vertical bar>
The size of the error is independent of the amount of horizontal kerning, any horizontal kerning at all triggers the same amount of error.
Thanks,
David Mathog mathog@...1176... Manager, Sequence Analysis Facility, Biology Division, Caltech
participants (1)
-
mathog