Code

render glyphs using 2geom pathvector instead of artbpath of font-glyph
authorjohanengelen <johanengelen@users.sourceforge.net>
Tue, 8 Jul 2008 20:19:51 +0000 (20:19 +0000)
committerjohanengelen <johanengelen@users.sourceforge.net>
Tue, 8 Jul 2008 20:19:51 +0000 (20:19 +0000)
src/display/nr-arena-glyphs.cpp
src/libnrtype/Layout-TNG-Output.cpp

index 7ca6d9aa157fb2a42ca33aa6c41b04dff9705df9..9295beccdf63ae539666dd91a278f7cade6ddaf3 100644 (file)
@@ -21,6 +21,8 @@
 #include <libnr/n-art-bpath.h>
 #include <libnr/nr-matrix-ops.h>
 #include <libnr/nr-matrix-fns.h>
+#include <libnr/nr-convert2geom.h>
+#include <2geom/matrix.h>
 #include "../style.h"
 #include "nr-arena.h"
 #include "nr-arena-glyphs.h"
@@ -462,11 +464,11 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi
         for (child = group->children; child != NULL; child = child->next) {
             NRArenaGlyphs *g = NR_ARENA_GLYPHS(child);
 
-            NArtBpath *bpath = (NArtBpath *) g->font->ArtBPath(g->glyph);
+            Geom::PathVector const * pathv = g->font->PathVector(g->glyph);
 
             cairo_new_path(ct);
-            NR::Matrix g_t(g->g_transform);
-            feed_curve_to_cairo (ct, bpath, g_t * group->ctm, (pb->area).upgrade(), false, 0);
+            Geom::Matrix transform = to_2geom(g->g_transform * group->ctm);
+            feed_pathvector_to_cairo (ct, *pathv, transform, (pb->area).upgrade(), false, 0);
             cairo_fill(ct);
             pb->empty = FALSE;
         }
@@ -610,15 +612,13 @@ void
 nr_arena_glyphs_group_add_component(NRArenaGlyphsGroup *sg, font_instance *font, int glyph, NR::Matrix const *transform)
 {
     NRArenaGroup *group;
-    NRBPath bpath;
 
     group = NR_ARENA_GROUP(sg);
 
-    bpath.path = ( font
-                   ? (NArtBpath *) font->ArtBPath(glyph)
-                   : NULL );
-    if ( bpath.path ) {
-
+    Geom::PathVector const * pathv = ( font
+                                       ? font->PathVector(glyph)
+                                       : NULL );
+    if ( pathv ) {
         nr_arena_item_request_render(NR_ARENA_ITEM(group));
 
         NRArenaItem *new_arena = NRArenaGlyphs::create(group->arena);
index 499a8f7a5e83506f1068ec8e0b1ccfa61829becc..eb6514b34462ac422e1c671b902b702fc72d374d 100644 (file)
 #include "livarot/Path.h"
 #include "libnr/nr-matrix-fns.h"
 #include "libnr/nr-scale-matrix-ops.h"
+#include "libnr/nr-convert2geom.h"
 #include "font-instance.h"
 #include "svg/svg-length.h"
 #include "extension/internal/cairo-render-context.h"
 #include "display/curve.h"
+#include <2geom/pathvector.h>
 
 namespace Inkscape {
     namespace Extension {
@@ -232,14 +234,11 @@ void Layout::showGlyphs(CairoRenderContext *ctx) const
         NR::Matrix glyph_matrix;
         _getGlyphTransformMatrix(glyph_index, &glyph_matrix);
         if (clip_mode) {
-            NArtBpath *bpath = (NArtBpath*)span.font->ArtBPath(_glyphs[glyph_index].glyph);
-            if (bpath) {
-                NArtBpath *abp = nr_artpath_affine(bpath, glyph_matrix);
-                const_NRBPath bpath;
-                bpath.path = abp;
+            Geom::PathVector const *pathv = span.font->PathVector(_glyphs[glyph_index].glyph);
+            if (pathv) {
+                Geom::PathVector pathv_trans = (*pathv) * to_2geom(glyph_matrix);
                 SPStyle const *style = text_source->style;
-                ctx->renderPath(&bpath, style, NULL);
-                g_free(abp);
+                ctx->renderPathVector(pathv_trans, style, NULL);
             }
             glyph_index++;
             continue;
@@ -550,11 +549,10 @@ SPCurve *Layout::convertToCurves(iterator const &from_glyph, iterator const &to_
         Span const &span = _glyphs[glyph_index].span(this);
         _getGlyphTransformMatrix(glyph_index, &glyph_matrix);
 
-        NRBPath bpath;
-        bpath.path = (NArtBpath*)span.font->ArtBPath(_glyphs[glyph_index].glyph);
-        if (bpath.path) {
-            NArtBpath *abp = nr_artpath_affine(bpath.path, glyph_matrix);
-            SPCurve *c = SPCurve::new_from_bpath(abp);
+        Geom::PathVector const * pathv = span.font->PathVector(_glyphs[glyph_index].glyph);
+        if (pathv) {
+            Geom::PathVector pathv_trans = (*pathv) * to_2geom(glyph_matrix);
+            SPCurve *c = new SPCurve(pathv_trans);
             if (c) cc = g_slist_prepend(cc, c);
         }
     }