summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 134f822)
raw | patch | inline | side by side (parent: 134f822)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Tue, 8 Jul 2008 20:15:56 +0000 (20:15 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Tue, 8 Jul 2008 20:15:56 +0000 (20:15 +0000) |
src/libnrtype/FontInstance.cpp | patch | blob | history | |
src/libnrtype/font-glyph.h | patch | blob | history | |
src/libnrtype/font-instance.h | patch | blob | history |
index 840cff4a1ea90ac9d7790b190710a53ef3dc7ba5..9504a97136177757f78c15a38fb12e9cff4efe15 100644 (file)
#include <libnr/nr-rect.h>
#include <libnrtype/font-glyph.h>
#include <libnrtype/font-instance.h>
-
+#include <2geom/pathvector.h>
#include <livarot/Path.h>
#include "RasterFont.h"
for (int i=0;i<nbGlyph;i++) {
if ( glyphs[i].outline ) delete glyphs[i].outline;
if ( glyphs[i].artbpath ) free(glyphs[i].artbpath);
+ if ( glyphs[i].pathvector ) delete glyphs[i].pathvector;
}
if ( glyphs ) free(glyphs);
nbGlyph=maxGlyph=0;
font_glyph n_g;
n_g.outline=NULL;
n_g.artbpath=NULL;
+ n_g.pathvector=NULL;
n_g.bbox[0]=n_g.bbox[1]=n_g.bbox[2]=n_g.bbox[3]=0;
bool doAdd=false;
if ( n_g.outline ) {
n_g.outline->FastBBox(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;
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;
index c79888c12be1e53e7342fb8e559bf19151d671d0..11e0206b5d437b543a7d54e823ab530afc9d9790 100644 (file)
#include <libnrtype/nrtype-forward.h>
#include <livarot/livarot-forward.h>
+#include <2geom/forward.h>
// the info for a glyph in a font. it's totally resolution- and fontsize-independent
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)
};
index 22dd829ae30c3e04cb0390a44966a54211ce7dbd..9fb33e47084d1134bcb5986a76d693a2106fffe8 100644 (file)
// 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);