[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ft-devel] How to get the position of a glyph without rendering it
From: |
Albert Astals Cid |
Subject: |
[ft-devel] How to get the position of a glyph without rendering it |
Date: |
Wed, 20 Oct 2010 01:29:29 +0100 |
User-agent: |
KMail/1.13.5 (Linux/2.6.35-22-generic; KDE/4.5.1; x86_64; ; ) |
Hi, at the moment i am doing
FT_Load_Glyph(face, ...)
FT_Render_Glyph(slot, ...)
int x = -slot->bitmap_left;
int y = slot->bitmap_top;
int w = slot->bitmap.width;
int h = slot->bitmap.rows;
I would like to get a rough idea of x, y, w, h before calling FT_Render_Glyph
so that if certain conditions are met i don't need to render the glyph
What i have been doing is
FT_Load_Glyph(face, ...)
FT_Glyph_Metrics *glyphMetrics = &(face->glyph->metrics);
int x = round(-glyphMetrics->horiBearingX / 64.0);
int y = round(glyphMetrics->horiBearingY / 64.0);
int w = round(glyphMetrics->width / 64.0);
int h = round(glyphMetrics->height / 64.0);
That code works fine for most of the fonts i tried but now i have encountered
a case in which
round(-glyphMetrics->horiBearingX / 64.0);
is -2 and
-slot->bitmap_left;
is 26
So my question is, is my code totally wrong in the sense that what I am trying
to calculate is not possible without actually rendering the glyph?
Or is it possible and i'm just missing something in my "guessing" code?
Thanks for the help,
Albert
- [ft-devel] How to get the position of a glyph without rendering it,
Albert Astals Cid <=