From 49339e07240a3a0af4d8ae3912be39bf2242b816 Mon Sep 17 00:00:00 2001 From: JucaBlues Date: Sat, 31 May 2008 17:20:02 +0000 Subject: [PATCH] * started implementing rendering of SVGFonts horizontal kerning --- src/display/nr-svgfonts.cpp | 16 +++++++++++++--- src/display/nr-svgfonts.h | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/display/nr-svgfonts.cpp b/src/display/nr-svgfonts.cpp index 6550daaf0..b444ce368 100644 --- a/src/display/nr-svgfonts.cpp +++ b/src/display/nr-svgfonts.cpp @@ -141,15 +141,25 @@ SvgFont::scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font, *glyphs = (cairo_glyph_t*) malloc(count*sizeof(cairo_glyph_t)); - + char* previous_unicode = NULL; count=0; + double x=0; _utf8 = (char*) utf8; while(_utf8[0] != '\0'){ len = 0; for (i=0; i < (unsigned long) this->glyphs.size(); i++){ if ( len = compare_them(this->glyphs[i]->unicode, _utf8) ){ + for(SPObject* node = this->font->children;previous_unicode && node;node=node->next){ + if (SP_IS_HKERN(node)){ + if ( (((SPHkern*)node)->u1[0] == previous_unicode[0]) && (((SPHkern*)node)->u2[0] == this->glyphs[i]->unicode[0]))//TODO: strings + x -= (((SPHkern*)node)->k / this->font->horiz_adv_x); + //g_warning("k=%f, adv_x=%f, hkerning=%f", (SPHkern*)node)->k, this->font->horiz_adv_x, hkerning); + g_warning("x=%f",x); + } + } + previous_unicode = this->glyphs[i]->unicode; (*glyphs)[count].index = i; - (*glyphs)[count].x = count; //TODO + (*glyphs)[count].x = x++; //TODO (*glyphs)[count++].y = 0; //TODO _utf8+=len; continue; @@ -157,7 +167,7 @@ SvgFont::scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font, } if (!len){ (*glyphs)[count].index = i; - (*glyphs)[count].x = count; //TODO + (*glyphs)[count].x = x++; //TODO (*glyphs)[count++].y = 0; //TODO _utf8++; } diff --git a/src/display/nr-svgfonts.h b/src/display/nr-svgfonts.h index a0cc56ccd..fc4a2b94e 100644 --- a/src/display/nr-svgfonts.h +++ b/src/display/nr-svgfonts.h @@ -26,6 +26,7 @@ #include "../sp-glyph.h" #include "../sp-missing-glyph.h" #include "../sp-font.h" +#include "../sp-glyph-kerning.h" class SvgFont; -- 2.30.2