Code

NR::Maybe => boost::optional
[inkscape.git] / src / libnrtype / FontInstance.cpp
index 840cff4a1ea90ac9d7790b190710a53ef3dc7ba5..4f745c0f946d85859d2829555e86e30f16c80a48 100644 (file)
@@ -14,7 +14,7 @@
 #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"
@@ -178,7 +178,7 @@ font_instance::~font_instance(void)
 
        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;
@@ -429,7 +429,7 @@ void font_instance::LoadGlyph(int glyph_id)
                }
                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;
 
@@ -556,7 +556,7 @@ void font_instance::LoadGlyph(int glyph_id)
                if ( doAdd ) {
                        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;
@@ -613,7 +613,7 @@ bool font_instance::FontSlope(double &run, double &rise)
        return true;
 }
 
-NR::Maybe<NR::Rect> font_instance::BBox(int glyph_id)
+boost::optional<NR::Rect> font_instance::BBox(int glyph_id)
 {
        int no=-1;
        if ( id_to_no.find(glyph_id) == id_to_no.end() ) {
@@ -627,7 +627,7 @@ NR::Maybe<NR::Rect> font_instance::BBox(int glyph_id)
                no=id_to_no[glyph_id];
        }
        if ( no < 0 ) {
-            return NR::Nothing();
+            return boost::optional<NR::Rect>();
         } else {
            NR::Point rmin(glyphs[no].bbox[0],glyphs[no].bbox[1]);
            NR::Point rmax(glyphs[no].bbox[2],glyphs[no].bbox[3]);
@@ -658,21 +658,21 @@ Path* font_instance::Outline(int glyph_id,Path* copyInto)
        return src_o;
 }
 
-void* font_instance::ArtBPath(int glyph_id)
+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].artbpath;
+    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)