if (!(font->spacing == FC_PROPORTIONAL)) {
g->width = font->max_advance_width;
} else {
- g->width = font->face->glyph->advance.x;
- g->width = TRUNC(ROUND(font->face->glyph->metrics.width));/* >> 6;*/
+ g->width = font->face->glyph->advance.x >> 6;
}
+ g->x = font->face->glyph->metrics.horiBearingX >> 6;
+ g->y = font->face->glyph->metrics.horiBearingY >> 6;
g->height = TRUNC(ROUND(font->face->glyph->metrics.height));/* >> 6;*/
- g_message("%c = Width: %d Height: %d", *c, g->width, g->height);
+ g_message("%c = X %d Y %d Width: %d Height: %d", *c, g->x, g->y, g->width, g->height);
g_hash_table_insert(font->glyph_map, &g->w, g);
}
struct GlftGlyph *right)
{
FT_Vector v;
- int k = left->width;
+ int k = 0;
-/* font->kerning = 0;*/
- g_message("HAS KERNING: %d", font->kerning);
+ if (left) k+= left->width;
- if (font->kerning && right) {
- FT_Get_Kerning(font->face, left->glyph, right->glyph,
- FT_KERNING_UNFITTED, &v);
-/*x_scale = pixel_size_x / EM_size*/
- k += v.x >> 6;
+ g_message("HAS KERNING: %d", font->kerning);
+ if (right) {
+ k -= right->x;
+ if (font->kerning) {
+ FT_Get_Kerning(font->face, left->glyph, right->glyph,
+ FT_KERNING_UNFITTED, &v);
+ k += v.x >> 6;
+ }
}
+
return k;
}
int x, int y)
{
const char *c;
- struct GlftGlyph *g;
+ struct GlftGlyph *g, *p = NULL;
if (!g_utf8_validate(str, bytes, NULL)) {
GlftDebug("Invalid UTF-8 in string\n");
while (c - str < bytes) {
g = GlftFontGlyph(font, c);
if (g) {
+ glTranslatef(GlftFontAdvance(font, p, g), 0.0, 0.0);
glCallList(g->dlist);
- glTranslatef(g->width, 0.0, 0.0);
} else
glTranslatef(font->max_advance_width, 0.0, 0.0);
+ p = g;
c = g_utf8_next_char(c);
}
int *h)
{
const char *c;
- struct GlftGlyph *g;
+ struct GlftGlyph *g, *p = NULL;
if (!g_utf8_validate(str, bytes, NULL)) {
GlftDebug("Invalid UTF-8 in string\n");
while (c - str < bytes) {
g = GlftFontGlyph(font, c);
if (g) {
- *w += g->width;
+ *w += GlftFontAdvance(font, p, g);
*h = MAX(g->height, *h);
- } else {
+ } else
*w += font->max_advance_width;
- }
+ p = g;
c = g_utf8_next_char(c);
}
}