index ad108e0a0f520dbc7bbbdf12494c3a94c1e629ea..9295beccdf63ae539666dd91a278f7cade6ddaf3 100644 (file)
#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"
void nr_pixblock_render_shape_mask_or(NRPixBlock &m, Shape *theS);
#endif
+#ifdef ENABLE_SVG_FONTS
+#include "nr-svgfonts.h"
+#endif //#ifdef ENABLE_SVG_FONTS
+
static void nr_arena_glyphs_class_init(NRArenaGlyphsClass *klass);
static void nr_arena_glyphs_init(NRArenaGlyphs *glyphs);
static void nr_arena_glyphs_finalize(NRObject *object);
nr_arena_glyphs_init(NRArenaGlyphs *glyphs)
{
glyphs->style = NULL;
- nr_matrix_set_identity(&glyphs->g_transform);
+ glyphs->g_transform.set_identity();
glyphs->font = NULL;
glyphs->glyph = 0;
@@ -138,15 +144,15 @@ nr_arena_glyphs_update(NRArenaItem *item, NRRectL */*area*/, NRGC *gc, guint /*s
bbox.x0 = bbox.y0 = NR_HUGE;
bbox.x1 = bbox.y1 = -NR_HUGE;
- float const scale = NR_MATRIX_DF_EXPANSION(&gc->transform);
+ float const scale = NR::expansion(gc->transform);
if (!glyphs->style->fill.isNone()) {
- NRMatrix t;
- nr_matrix_multiply(&t, &glyphs->g_transform, &gc->transform);
- glyphs->x = t.c[4];
- glyphs->y = t.c[5];
- t.c[4]=0;
- t.c[5]=0;
+ NR::Matrix t;
+ t = glyphs->g_transform * gc->transform;
+ glyphs->x = t[4];
+ glyphs->y = t[5];
+ t[4]=0;
+ t[5]=0;
rfont = glyphs->font->RasterFont(t, 0);
if (glyphs->rfont) glyphs->rfont->Unref();
glyphs->rfont = rfont;
@@ -163,12 +169,12 @@ nr_arena_glyphs_update(NRArenaItem *item, NRRectL */*area*/, NRGC *gc, guint /*s
if (!glyphs->style->stroke.isNone()) {
/* Build state data */
- NRMatrix t;
- nr_matrix_multiply(&t, &glyphs->g_transform, &gc->transform);
- glyphs->x = t.c[4];
- glyphs->y = t.c[5];
- t.c[4]=0;
- t.c[5]=0;
+ NR::Matrix t;
+ t = glyphs->g_transform * gc->transform;
+ glyphs->x = t[4];
+ glyphs->y = t[5];
+ t[4]=0;
+ t[5]=0;
if ( fabs(glyphs->style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord
font_style nstyl;
@@ -185,6 +191,7 @@ nr_arena_glyphs_update(NRArenaItem *item, NRRectL */*area*/, NRGC *gc, guint /*s
nstyl.dash_offset = 0;
nstyl.dashes=NULL;
if ( glyphs->style->stroke_dash.n_dash > 0 ) {
+ nstyl.dash_offset = glyphs->style->stroke_dash.offset * scale;
nstyl.nbDash=glyphs->style->stroke_dash.n_dash;
nstyl.dashes=(double*)malloc(nstyl.nbDash*sizeof(double));
for (int i = 0; i < nstyl.nbDash; i++) nstyl.dashes[i]= glyphs->style->stroke_dash.dash[i] * scale;
@@ -250,7 +257,7 @@ nr_arena_glyphs_pick(NRArenaItem *item, NR::Point p, gdouble /*delta*/, unsigned
}
void
-nr_arena_glyphs_set_path(NRArenaGlyphs *glyphs, SPCurve */*curve*/, unsigned int /*lieutenant*/, font_instance *font, gint glyph, NRMatrix const *transform)
+nr_arena_glyphs_set_path(NRArenaGlyphs *glyphs, SPCurve */*curve*/, unsigned int /*lieutenant*/, font_instance *font, gint glyph, NR::Matrix const *transform)
{
nr_return_if_fail(glyphs != NULL);
nr_return_if_fail(NR_IS_ARENA_GLYPHS(glyphs));
@@ -260,7 +267,7 @@ nr_arena_glyphs_set_path(NRArenaGlyphs *glyphs, SPCurve */*curve*/, unsigned int
if (transform) {
glyphs->g_transform = *transform;
} else {
- nr_matrix_set_identity(&glyphs->g_transform);
+ glyphs->g_transform.set_identity();
}
if (font) font->Ref();
@@ -409,14 +416,14 @@ nr_arena_glyphs_group_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint s
item->render_opacity = TRUE;
if (group->style->fill.isPaintserver()) {
group->fill_painter = sp_paint_server_painter_new(SP_STYLE_FILL_SERVER(group->style),
- NR::Matrix(&gc->transform), NR::Matrix(&gc->parent->transform),
+ gc->transform, gc->parent->transform,
&group->paintbox);
item->render_opacity = FALSE;
}
if (group->style->stroke.isPaintserver()) {
group->stroke_painter = sp_paint_server_painter_new(SP_STYLE_STROKE_SERVER(group->style),
- NR::Matrix(&gc->transform), NR::Matrix(&gc->parent->transform),
+ gc->transform, gc->parent->transform,
&group->paintbox);
item->render_opacity = FALSE;
}
@@ -443,7 +450,7 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi
guint ret = item->state;
- if (item->arena->rendermode == RENDERMODE_OUTLINE) {
+ if (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE) {
if (!ct)
return item->state;
@@ -457,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;
}
@@ -472,7 +479,7 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi
/* Fill */
- if (!style->fill.isNone() || item->arena->rendermode == RENDERMODE_OUTLINE) {
+ if (!style->fill.isNone() || item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE) {
NRPixBlock m;
nr_pixblock_setup_fast(&m, NR_PIXBLOCK_MODE_A8, area->x0, area->y0, area->x1, area->y1, TRUE);
@@ -498,9 +505,9 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi
if (ggroup->fill_painter) {
nr_arena_render_paintserver_fill(pb, area, ggroup->fill_painter, SP_SCALE24_TO_FLOAT(style->fill_opacity.value), &m);
}
- } else if (style->fill.isColor() || item->arena->rendermode == RENDERMODE_OUTLINE) {
+ } else if (style->fill.isColor() || item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE) {
guint32 rgba;
- if (item->arena->rendermode == RENDERMODE_OUTLINE) {
+ if (item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE) {
// In outline mode, render fill only, using outlinecolor
rgba = item->arena->outlinecolor;
} else if ( item->render_opacity ) {
@@ -517,7 +524,7 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi
}
/* Stroke */
- if (!style->stroke.isNone() && !(item->arena->rendermode == RENDERMODE_OUTLINE)) {
+ if (!style->stroke.isNone() && !(item->arena->rendermode == Inkscape::RENDERMODE_OUTLINE)) {
NRPixBlock m;
guint32 rgba;
nr_pixblock_setup_fast(&m, NR_PIXBLOCK_MODE_A8, area->x0, area->y0, area->x1, area->y1, TRUE);
}
void
-nr_arena_glyphs_group_add_component(NRArenaGlyphsGroup *sg, font_instance *font, int glyph, NRMatrix const *transform)
+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);