diff --git a/src/TTFdecoder.cpp b/src/TTFdecoder.cpp index e1411d8..02c592f 100644 --- a/src/TTFdecoder.cpp +++ b/src/TTFdecoder.cpp @@ -32,7 +32,7 @@ QList ImageDecoder::ttf_verbose(const QString &ttffilenam std::string ImageDecoder::ttf_glyph_out(void *glyph, bool verbose) { font2svg::glyph *g = static_cast(glyph); - if(verbose) + if(verbose) return g->svgheader() + g->svgborder() + g->svgtransform() + @@ -43,7 +43,7 @@ std::string ImageDecoder::ttf_glyph_out(void *glyph, bool verbose) { g->outline() + g->labelpts() + g->svgfooter(); - else + else return g->svgheader() + g->svgtransform() + g->outline() + @@ -56,7 +56,7 @@ QList ImageDecoder::ttf_decode(QString ttffilename,int W, if(codepoint == -1) { font2svg::ttf_file tfile(ttffilename.toStdString()); for(int index = 0;index<=0x10FFFF;index++) { - font2svg::glyph g(tfile, index); + font2svg::glyph g(tfile, index, false); if(g.glyph_index != 0) { SvgInfo info; info.src = new QString(QString::fromStdString(ttf_glyph_out(&g,verbose))); @@ -68,7 +68,7 @@ QList ImageDecoder::ttf_decode(QString ttffilename,int W, } tfile.free(); } else { - font2svg::glyph g(ttffilename.toStdString(), codepoint ); + font2svg::glyph g(ttffilename.toStdString(), codepoint, true ); SvgInfo info; info.src = new QString(QString::fromStdString(ttf_glyph_out(&g,verbose))); info.H = H; diff --git a/src/font_to_svg.hpp b/src/font_to_svg.hpp index ed5ae3e..60b60d7 100644 --- a/src/font_to_svg.hpp +++ b/src/font_to_svg.hpp @@ -52,8 +52,6 @@ endorsement. namespace font2svg { -std::stringstream debug; - #if 0 #define DEBUG_OUT std::cout #else @@ -84,6 +82,7 @@ class ttf_file ttf_file( std::string fname ) { + std::stringstream debug; filename = fname; error = FT_Init_FreeType( &library ); debug << "Init error code: " << error; @@ -93,6 +92,7 @@ class ttf_file debug << "\nFace load error code: " << error; debug << "\nfont filename: " << filename; if (error) { + DEBUG_OUT << debug.str(); std::cerr << "problem loading file " << filename << "\n"; exit(1); } @@ -100,16 +100,19 @@ class ttf_file debug << "\nStyle Name: " << face->style_name; debug << "\nNumber of faces: " << face->num_faces; debug << "\nNumber of glyphs: " << face->num_glyphs; + DEBUG_OUT << debug.str(); } void free() { + std::stringstream debug; debug << "\n\n"; + DEBUG_OUT << debug.str(); } }; @@ -240,40 +243,40 @@ class glyph std::stringstream debug, tmp; int bbwidth, bbheight; - glyph( ttf_file &f, std::string unicode_str ) + glyph( ttf_file &f, std::string unicode_str, bool force ) { file = f; - init( unicode_str ); + init( unicode_str, force ); } - glyph( const char * filename, std::string unicode_str ) + glyph( const char * filename, std::string unicode_str, bool force ) { this->file = ttf_file( std::string(filename) ); - init( unicode_str ); + init( unicode_str, force ); } - glyph( const char * filename, const char * unicode_c_str ) + glyph( const char * filename, const char * unicode_c_str, bool force ) { this->file = ttf_file( std::string(filename) ); - init( std::string(unicode_c_str) ); + init( std::string(unicode_c_str), force ); } - glyph( ttf_file &f, int unicode ) + glyph( ttf_file &f, int unicode, bool force ) { file = f; - init( unicode ); + init( unicode, force ); } - glyph( const char * filename, int unicode ) + glyph( const char * filename, int unicode, bool force ) { this->file = ttf_file( std::string(filename) ); - init( unicode ); + init( unicode, force ); } - glyph( std::string fname, int unicode ) + glyph( std::string fname, int unicode, bool force ) { this->file = ttf_file( fname ); - init( unicode ); + init( unicode, force ); } void free() @@ -281,19 +284,20 @@ class glyph file.free(); } - void init( std::string unicode_s ) + void init( std::string unicode_s, bool force ) { int unicode = strtol( unicode_s.c_str() , NULL, 0 ); debug << "