[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ft] What do kerning values mean in RTL text?
From: |
David Turner |
Subject: |
Re: [ft] What do kerning values mean in RTL text? |
Date: |
Fri, 09 Jun 2006 23:44:48 +0200 |
User-agent: |
Thunderbird 1.5.0.2 (X11/20060522) |
Paul Pedriana a écrit :
> I'm trying to understand how kerning is done in RTL text and can't
> find any documentation (on the Internet nor in Freetype) that
> addresses this.
>
> Questions:
> - Do kerning pairs in RTL refer to two sequential glyphs in logical
> order or visual order?
>
At least for TrueType and Type 1 fonts, it only refers to visual order.
Nelson just wrote
something about TeX which apparently follows the opposite convention,
but I can guarantee
you that it is not followed by other industry-standard formats.
> - If there is a string with the logical order is CAT and a visual
> order of TAC,
> do kerning adjustment pairings apply for CA (logical order) or
> for AC (visual order)?
>
you'll need to apply the kernings for (T,A) then (A,C)
> - Given that the RTL layout alrogithm
> (http://freetype.sourceforge.net/freetype2/docs/glyphs/glyphs-5.html)
> specifies that advance width of C (from our CAT above) is applied
> before the positioning
> and drawing of C, how and when and in what way is a kerning
> adjustment applied?
>
if you write text left-to-right, independent of its logical order, you're
going to do the following:
prev = -1;
xpos = 0;
for ( n=0; n < num_visual_glyphs; n++ )
{
gindex = visual_glyphs[n].index;
if ( prev > 0 )
xpos += kerning( prev, gindex );
drawGlyph( gindex, xpos );
xpos += visual_glyphs[n].advance;
prev = gindex;
}
when writing right-to-left text, you can do the following, which results
in the same glyph positions, justified to the right:
prev = -1;
xpos = width;
for ( n=num_visual_glyphs-1; n >= 0; n-- )
{
gindex = visual_glyphs[n].index;
xpos -= visual_glyphs[n].advance;
if ( prev > 0 )
xpos -= kerning( gindex, prev );
drawGlyph( gindex, xpos );
prev = gindex;
}
to better understand why, here's an example with two glyphs,
named 'L' (for left) and 'R' (for right):
left-to-right text:
L.x = 0
R.x = L.advance + kerning(L,R)
xpos.final = L.advance + R.advance + kerning(L,R)
xpos.final - xpos.start = L.advance + R.advance + kerning(L,R)
right-to-left text:
R.x = width - R.advance
L.x = width - R.advance - L.advance - kerning(L,R)
xpos.final = L.x
xpos.final - xpos.start = -(L.advance + R.advance + kerning(L,R))
L.x - xpos.final = 0
R.x - xpos.final = L.advance + kerning(L,R)
Hope this helps,
- David
> If I can get this answered, I would like to document this and
> contribute the documentation to the Freetype project, as this is
> something that appears to have flummoxed a lot of people. Every
> description of kerning I can find discusses LTR kerning and
> unfortunately seems to leave RTL kerning as an "exercise for the reader".
>
> Thanks.
>
>
>
>
> _______________________________________________
> Freetype mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/freetype