From 8635db5fa8eea32dccc0ce084ac61dbbc99f0b14 Mon Sep 17 00:00:00 2001 From: johanengelen Date: Tue, 8 Jul 2008 20:15:56 +0000 Subject: [PATCH] add 2geom pathvector to glyph font-glyph --- src/libnrtype/FontInstance.cpp | 22 +++++++++++++++++++++- src/libnrtype/font-glyph.h | 2 ++ src/libnrtype/font-instance.h | 5 +++-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp index 840cff4a1..9504a9713 100644 --- a/src/libnrtype/FontInstance.cpp +++ b/src/libnrtype/FontInstance.cpp @@ -14,7 +14,7 @@ #include #include #include - +#include <2geom/pathvector.h> #include #include "RasterFont.h" @@ -179,6 +179,7 @@ font_instance::~font_instance(void) for (int i=0;iFastBBox(n_g.bbox[0],n_g.bbox[1],n_g.bbox[2],n_g.bbox[3]); n_g.artbpath=n_g.outline->MakeArtBPath(); + n_g.pathvector=n_g.outline->MakePathVector(); } glyphs[nbGlyph]=n_g; id_to_no[glyph_id]=nbGlyph; @@ -675,6 +678,23 @@ void* font_instance::ArtBPath(int glyph_id) return glyphs[no].artbpath; } +Geom::PathVector* font_instance::PathVector(int glyph_id) +{ + int no = -1; + if ( id_to_no.find(glyph_id) == id_to_no.end() ) { + LoadGlyph(glyph_id); + if ( id_to_no.find(glyph_id) == id_to_no.end() ) { + // didn't load + } else { + no = id_to_no[glyph_id]; + } + } else { + no = id_to_no[glyph_id]; + } + if ( no < 0 ) return NULL; + return glyphs[no].pathvector; +} + double font_instance::Advance(int glyph_id,bool vertical) { int no=-1; diff --git a/src/libnrtype/font-glyph.h b/src/libnrtype/font-glyph.h index c79888c12..11e0206b5 100644 --- a/src/libnrtype/font-glyph.h +++ b/src/libnrtype/font-glyph.h @@ -3,6 +3,7 @@ #include #include +#include <2geom/forward.h> // the info for a glyph in a font. it's totally resolution- and fontsize-independent struct font_glyph { @@ -12,6 +13,7 @@ struct font_glyph { // as the fonts sometimes contain Path* outline; // outline as a livarot Path void* artbpath; // outline as a artbpath, for text->curve stuff (should be unified with livarot) + Geom::PathVector* pathvector; // outline as 2geom pathvector, for text->curve stuff (should be unified with livarot) }; diff --git a/src/libnrtype/font-instance.h b/src/libnrtype/font-instance.h index 22dd829ae..9fb33e470 100644 --- a/src/libnrtype/font-instance.h +++ b/src/libnrtype/font-instance.h @@ -71,8 +71,9 @@ public: // queries the outline of the glyph (in livarot Path form), and copies it into copyInto instead // of allocating a new Path if copyInto != NULL void* ArtBPath(int glyph_id); - // returns the artbpath for this glyph. no refcounting needed, it's deallocated when the - // font_instance dies + // returns the artbpath for this glyph. no refcounting needed, it's deallocated when the font_instance dies + Geom::PathVector* PathVector(int glyph_id); + // returns the 2geom-type pathvector for this glyph. no refcounting needed, it's deallocated when the font_instance dies double Advance(int glyph_id, bool vertical); // nominal advance of the font. bool FontMetrics(double &ascent, double &descent, double &leading); -- 2.30.2