[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ft] Can't get offset of glyphs right.
From: |
Christian Demmer |
Subject: |
Re: [ft] Can't get offset of glyphs right. |
Date: |
Sun, 7 Jun 2015 18:53:44 +0200 |
On Sun, 7 Jun 2015 11:41:30 +0200, Erlend Langseth wrote:
> I first render all glyphs, storing necessary metrics, then use the results
> to render text.
> Given an unsigned char c, this is how I render glyphs, and need to obtain
> the correct offsets (C++):
>
> FT_Face face;
>
> if (!FT_Load_Char(face, c, 0)) {
> if (!FT_Render_Glyph(face->glyph, FT_RENDER_MODE_NORMAL)) {
> if (!FT_Get_Char_Index( face, c )) continue;
> // Set offset of glyphs accessing face->glyph here.
>
> I have tried to use face->glyph->bitmap_left (and bitmap_top), and also
> face->glyph->metrics.horiBearingX / 64.0f (and Y), but the results always
> look arbitrary:
I am no expert on this, but I have done this before and I think
bitmap_left and bitmap_top are the needed values to add to the pen
location to render at. I don't understand where you get g.xoffset /
g.yoffset from in your code.
Probably you applied some shift at the time you store the bitmap in the
texture, but you did not show that code (or I didn't saw it)
Greetings, Chris