freetype
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ft] Fw: FreeType positionning questions


From: Werner LEMBERG
Subject: [ft] Fw: FreeType positionning questions
Date: Tue, 20 Nov 2018 13:20:07 +0100 (CET)

Forwarding this e-mail to the right address :-)


    Werner
--- Begin Message --- Subject: FreeType positionning questions Date: Tue, 20 Nov 2018 12:57:49 +0100
Hello,
I'd like to ask you a question about positionning because, when trying to
improve some code, I am not sure anymore with all informations I found.
I want to make sure my code (and the code I will ask to be updated) is
correct and better : especially about position of letters.

I use freetype to render glyph and text and save it as an image or render
to screen in a basic way.
I just: render all glyphs. Then write them to a memory at some
(pen_x/pen_y) positions.
(I stick to horizontal writing, LTR, no use of FT_Outline_Translate(), load
glyph with FT_LOAD_DEFAULT)

I've seen, among others:
https://www.freetype.org/freetype2/docs/tutorial/step2.html
http://git.savannah.gnu.org/cgit/freetype/freetype2-demos.git/tree/src/ftdiff.c
https://cgit.freedesktop.org/cairo/tree/src/cairo-ft-font.c
https://cgit.freedesktop.org/cairo/tree/test/ft-show-glyphs-positioning.c

in a short, I undertand ftdiff.c would position like this:

foreach glyph {
        x_origin += kerning.x       // 26.6
        x_origin += rsb/lsb_detlas    // 26.6
        pen_x = floor(x_origin) + slot->bitmap_left
        dispay/memcopy bitmap at integer position pen_x
        x_origin += slot->advance.x   // 26.6
}

Other (tutorial 2, but this is a simplified)

foreach glyph {
    x_origin += floor(kerning)        // int
        pen_x = x_origin + slot->bitmap_left
        dispay/memcopy bitmap at integer position pen_x
        x_origin += floor(slot->advance.x) // int
}

Mix Cairo / Me ?
foreach glyph {
        x_origin += kerning        // 26.6
        x_origin += rsb/lsb_detlas
        pen_x = floor( x_origin + glyph->horiBearingX )
        dispay/memcopy bitmap at integer position pen_x
        x_origin += glyph->horiAdvance
}

I believe ftdiff.c is the correct way.
But what about the use of horiBearingX wich has a higher precision ? Cairo
seems to use it ?
Also slot->advance.x VS horiAdvance ?
Is the rounding floor() the correct one. (some use ceil(), some round(),
...)

Thanks for  your help,
Sylvain

--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]