From 31bb8269c26a781036448ed8f8cd93cc84fb2118 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 29 Nov 2009 16:33:18 +0100 Subject: First GSoC node tool commit to Bazaar (bzr r8846.1.1) --- src/libnrtype/FontFactory.cpp | 2 +- src/libnrtype/FontFactory.h | 6 +++--- src/libnrtype/FontInstance.cpp | 2 +- src/libnrtype/font-instance.h | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/libnrtype') diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index fec9316b9..db7cd9747 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -43,7 +43,7 @@ size_t font_descr_hash::operator()( PangoFontDescription *const &x) const { h += (int)pango_font_description_get_stretch(x); return h; } -bool font_descr_equal::operator()( PangoFontDescription *const&a, PangoFontDescription *const &b) { +bool font_descr_equal::operator()( PangoFontDescription *const&a, PangoFontDescription *const &b) const { //if ( pango_font_description_equal(a,b) ) return true; char const *fa = pango_font_description_get_family(a); char const *fb = pango_font_description_get_family(b); diff --git a/src/libnrtype/FontFactory.h b/src/libnrtype/FontFactory.h index 9f4b31a2e..5253f6bbd 100644 --- a/src/libnrtype/FontFactory.h +++ b/src/libnrtype/FontFactory.h @@ -11,7 +11,7 @@ #include #include -#include +#include #ifdef HAVE_CONFIG_H # include @@ -46,7 +46,7 @@ struct font_descr_hash : public std::unary_function { - bool operator()(PangoFontDescription *const &a, PangoFontDescription *const &b); + bool operator()(PangoFontDescription *const &a, PangoFontDescription *const &b) const; }; // Comparison functions for style names @@ -84,7 +84,7 @@ public: double fontSize; /**< The huge fontsize used as workaround for hinting. * Different between freetype and win32. */ - __gnu_cxx::hash_map loadedFaces; + std::tr1::unordered_map loadedFaces; font_factory(); virtual ~font_factory(); diff --git a/src/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp index e1413b46e..d9a0c43e6 100644 --- a/src/libnrtype/FontInstance.cpp +++ b/src/libnrtype/FontInstance.cpp @@ -60,7 +60,7 @@ size_t font_style_hash::operator()(const font_style &x) const { return h; } -bool font_style_equal::operator()(const font_style &a,const font_style &b) { +bool font_style_equal::operator()(const font_style &a,const font_style &b) const { for (int i=0;i<6;i++) { if ( (int)(100*a.transform[i]) != (int)(100*b.transform[i]) ) return false; } diff --git a/src/libnrtype/font-instance.h b/src/libnrtype/font-instance.h index 4209a20af..ce3f6cf1b 100644 --- a/src/libnrtype/font-instance.h +++ b/src/libnrtype/font-instance.h @@ -1,7 +1,7 @@ #ifndef SEEN_LIBNRTYPE_FONT_INSTANCE_H #define SEEN_LIBNRTYPE_FONT_INSTANCE_H -#include +#include #include #include #include @@ -26,13 +26,13 @@ struct font_style_hash : public std::unary_function { }; struct font_style_equal : public std::binary_function { - bool operator()(font_style const &a, font_style const &b); + bool operator()(font_style const &a, font_style const &b) const; }; class font_instance { public: // hashmap to get the raster_font for a given style - __gnu_cxx::hash_map loadedStyles; + std::tr1::unordered_map loadedStyles; // the real source of the font PangoFont* pFont; // depending on the rendering backend, different temporary data -- cgit v1.2.3 From ed4ddd304ffed5f3206ee1cf5fd9c74a78c108a6 Mon Sep 17 00:00:00 2001 From: buliabyak <> Date: Wed, 6 Jan 2010 20:24:25 -0400 Subject: a better truncation detection, suggested by Richard Hughes (bzr r8950) --- src/libnrtype/Layout-TNG-Compute.cpp | 6 +++- src/libnrtype/Layout-TNG-Input.cpp | 68 ------------------------------------ src/libnrtype/Layout-TNG-Output.cpp | 2 ++ src/libnrtype/Layout-TNG.h | 4 ++- 4 files changed, 10 insertions(+), 70 deletions(-) (limited to 'src/libnrtype') diff --git a/src/libnrtype/Layout-TNG-Compute.cpp b/src/libnrtype/Layout-TNG-Compute.cpp index 7a2924d98..f6b9688bb 100644 --- a/src/libnrtype/Layout-TNG-Compute.cpp +++ b/src/libnrtype/Layout-TNG-Compute.cpp @@ -1467,8 +1467,12 @@ bool Layout::Calculator::calculate() } para.free(); - if (_scanline_maker) + if (_scanline_maker) { delete _scanline_maker; + _flow._input_truncated = false; + } else { + _flow._input_truncated = true; + } return true; } diff --git a/src/libnrtype/Layout-TNG-Input.cpp b/src/libnrtype/Layout-TNG-Input.cpp index 33371ab10..fb2769edc 100644 --- a/src/libnrtype/Layout-TNG-Input.cpp +++ b/src/libnrtype/Layout-TNG-Input.cpp @@ -19,8 +19,6 @@ #include "sp-string.h" #include "FontFactory.h" -#include "text-editing.h" // for inputTruncated() - namespace Inkscape { namespace Text { @@ -324,71 +322,5 @@ Layout::InputStreamTextSource::~InputStreamTextSource() sp_style_unref(style); } -bool -Layout::inputTruncated() const -{ - if (!inputExists()) - return false; - - // Find out the SPObject to which the last visible character corresponds: - Layout::iterator last = end(); - if (last == begin()) { - // FIXME: this returns a wrong "not truncated" when a flowtext is entirely - // truncated, so there are no visible characters. But how can I find out the - // originator SPObject without having anything to do getSourceOfCharacter - // from? - return false; - } - last.prevCharacter(); - void *source; - Glib::ustring::iterator offset; - getSourceOfCharacter(last, &source, &offset); - SPObject *obj = SP_OBJECT(source); - - // if that is SPString, see if it has further characters beyond the last visible - if (obj && SP_IS_STRING(obj)) { - Glib::ustring::iterator offset_next = offset; - offset_next ++; - if (offset_next != SP_STRING(obj)->string.end()) { - // truncated: source SPString has next char - return true; - } - } - - // otherwise, see if the SPObject at end() or any of its text-tree ancestors - // (excluding top-level SPText or SPFlowText) have a text-tree next sibling with - // visible text - if (obj) { - for (SPObject *ascend = obj; - ascend && (is_part_of_text_subtree (ascend) && !is_top_level_text_object(ascend)); - ascend = SP_OBJECT_PARENT(ascend)) { - if (SP_OBJECT_NEXT(ascend)) { - SPObject *next = SP_OBJECT_NEXT(ascend); - if (next && is_part_of_text_subtree(next) && has_visible_text(next)) { - // truncated: source text object has next text sibling - return true; - } - } - } - } - - // the above works for flowed text, but not for text on path. - // so now, we also check if the last of the _characters, if coming from a TEXT_SOURCE, - // has in_glyph different from -1 - unsigned last_char = _characters.size() - 1; - unsigned span_index = _characters[last_char].in_span; - Glib::ustring::const_iterator iter_char = _spans[span_index].input_stream_first_character; - - if (_input_stream[_spans[span_index].in_input_stream_item]->Type() == TEXT_SOURCE) { - if (_characters[last_char].in_glyph == -1) { - //truncated: last char has no glyph - return true; - } - } - - // not truncated - return false; -} - }//namespace Text }//namespace Inkscape diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp index 2b4b80e7c..d6b68ab40 100644 --- a/src/libnrtype/Layout-TNG-Output.cpp +++ b/src/libnrtype/Layout-TNG-Output.cpp @@ -513,8 +513,10 @@ void Layout::fitToPathAlign(SVGLength const &startOffset, Path const &path) _glyphs[glyph_index].y = midpoint[1] - _lines.front().baseline_y + tangent[1] * tangent_shift + tangent[0] * normal_shift; _glyphs[glyph_index].rotation += rotation; } + _input_truncated = false; } else { // outside the bounds of the path: hide the glyphs _characters[char_index].in_glyph = -1; + _input_truncated = true; } g_free(midpoint_otp); diff --git a/src/libnrtype/Layout-TNG.h b/src/libnrtype/Layout-TNG.h index 05b5103fc..0a2463a56 100644 --- a/src/libnrtype/Layout-TNG.h +++ b/src/libnrtype/Layout-TNG.h @@ -212,7 +212,9 @@ public: bool inputExists() const {return !_input_stream.empty();} - bool inputTruncated() const; + bool _input_truncated; + bool inputTruncated() const + {return _input_truncated;} /** adds a new piece of text to the end of the current list of text to be processed. This method can only add text of a consistent style. -- cgit v1.2.3 From 4756aa99f5756a6cac199c1aae6c37514cf1c562 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 14 Jan 2010 23:38:54 +0100 Subject: Replace std::tr1::unordered_(map|set) with __gnu_cxx::hash_(map|set), to work around broken headers in some GCC versions. (bzr r8980) --- src/libnrtype/FontFactory.cpp | 5 +++-- src/libnrtype/FontInstance.cpp | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src/libnrtype') diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index a63f70d75..afce4d849 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -26,10 +26,11 @@ /* Freetype2 */ # include -#include +//#include +#include -typedef std::tr1::unordered_map FaceMapType; +typedef __gnu_cxx::hash_map FaceMapType; // need to avoid using the size field size_t font_descr_hash::operator()( PangoFontDescription *const &x) const { diff --git a/src/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp index 6b0725b34..8b8eb8bbe 100644 --- a/src/libnrtype/FontInstance.cpp +++ b/src/libnrtype/FontInstance.cpp @@ -29,7 +29,8 @@ # include FT_TRUETYPE_TABLES_H # include -#include +//#include +#include // the various raster_font in use at a given time are held in a hash_map whose indices are the @@ -43,7 +44,7 @@ struct font_style_equal : public std::binary_function StyleMap; +typedef __gnu_cxx::hash_map StyleMap; -- cgit v1.2.3 From 5986b668c966deece6bba2cce1068d60cc6b4882 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Thu, 14 Jan 2010 17:16:07 -0800 Subject: Fixed object leak. (bzr r8982) --- src/libnrtype/FontFactory.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/libnrtype') diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index afce4d849..761da7756 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -333,6 +333,7 @@ font_factory::~font_factory(void) { if (loadedPtr) { FaceMapType* tmp = static_cast(loadedPtr); + delete tmp; loadedPtr = 0; } -- cgit v1.2.3 From 906f78949458732f138e4e2b79843c75e9d52f87 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 20 Jan 2010 20:31:57 +0100 Subject: Go back to using TR1 unordered containers to fix warnings. Add configure code to detect the broken header and display Wiki page URL. (bzr r9006) --- src/libnrtype/FontFactory.cpp | 14 +++++++------- src/libnrtype/FontInstance.cpp | 8 ++------ src/libnrtype/font-instance.h | 4 ++-- 3 files changed, 11 insertions(+), 15 deletions(-) (limited to 'src/libnrtype') diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index 761da7756..09d9e2c4f 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -26,11 +26,9 @@ /* Freetype2 */ # include -//#include -#include +#include - -typedef __gnu_cxx::hash_map FaceMapType; +typedef std::tr1::unordered_map FaceMapType; // need to avoid using the size field size_t font_descr_hash::operator()( PangoFontDescription *const &x) const { @@ -826,9 +824,11 @@ font_instance *font_factory::Face(PangoFontDescription *descr, bool canFail) if ( nFace ) { // duplicate FcPattern, the hard way res = new font_instance(); - // store the descr of the font we asked for, since this is the key where we intend to put the font_instance at - // in the hash_map. the descr of the returned pangofont may differ from what was asked, so we don't know (at this - // point) whether loadedFaces[that_descr] is free or not (and overwriting an entry will bring deallocation problems) + // store the descr of the font we asked for, since this is the key where we intend + // to put the font_instance at in the unordered_map. the descr of the returned + // pangofont may differ from what was asked, so we don't know (at this + // point) whether loadedFaces[that_descr] is free or not (and overwriting + // an entry will bring deallocation problems) res->descr = pango_font_description_copy(descr); res->daddy = this; res->InstallFace(nFace); diff --git a/src/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp index 8b8eb8bbe..628e3cba0 100644 --- a/src/libnrtype/FontInstance.cpp +++ b/src/libnrtype/FontInstance.cpp @@ -29,12 +29,9 @@ # include FT_TRUETYPE_TABLES_H # include -//#include -#include +#include -// the various raster_font in use at a given time are held in a hash_map whose indices are the -// styles, hence the 2 following 'classes' struct font_style_hash : public std::unary_function { size_t operator()(font_style const &x) const; }; @@ -43,8 +40,7 @@ struct font_style_equal : public std::binary_function StyleMap; +typedef std::tr1::unordered_map StyleMap; diff --git a/src/libnrtype/font-instance.h b/src/libnrtype/font-instance.h index 521c9a424..d52bd723f 100644 --- a/src/libnrtype/font-instance.h +++ b/src/libnrtype/font-instance.h @@ -25,7 +25,7 @@ public: // depending on the rendering backend, different temporary data // that's the font's fingerprint; this particular PangoFontDescription gives the entry at which this font_instance - // resides in the font_factory loadedFaces hash_map + // resides in the font_factory loadedFaces unordered_map PangoFontDescription* descr; // refcount int refCount; @@ -86,7 +86,7 @@ private: void FreeTheFace(); // hashmap to get the raster_font for a given style - void* loadedPtr; // Pointer to a hash_map. Moved into .cpp to not expose use of __gnu_cxx extension. + void* loadedPtr; #ifdef USE_PANGO_WIN32 HFONT theFace; -- cgit v1.2.3 From 84fc09c9c921a31ac826c53e419d4ea61584f8a9 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Tue, 2 Mar 2010 23:52:32 +0100 Subject: Use Boost unordeed containers instead of TR1 to minimize pain when using Apple compilers. (bzr r9129) --- src/libnrtype/FontFactory.cpp | 4 ++-- src/libnrtype/FontInstance.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/libnrtype') diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index 09d9e2c4f..d6fc207b0 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -26,9 +26,9 @@ /* Freetype2 */ # include -#include +#include -typedef std::tr1::unordered_map FaceMapType; +typedef boost::unordered_map FaceMapType; // need to avoid using the size field size_t font_descr_hash::operator()( PangoFontDescription *const &x) const { diff --git a/src/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp index 628e3cba0..557e9106e 100644 --- a/src/libnrtype/FontInstance.cpp +++ b/src/libnrtype/FontInstance.cpp @@ -29,7 +29,7 @@ # include FT_TRUETYPE_TABLES_H # include -#include +#include struct font_style_hash : public std::unary_function { @@ -40,7 +40,7 @@ struct font_style_equal : public std::binary_function StyleMap; +typedef boost::unordered_map StyleMap; -- cgit v1.2.3 From 46fd0e8c49da44226151096546905589819bbdf5 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Thu, 4 Mar 2010 00:44:53 -0800 Subject: Fixing build breakage with more proper autoconf usage. (bzr r9138) --- src/libnrtype/FontFactory.cpp | 4 ++-- src/libnrtype/FontInstance.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/libnrtype') diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index d6fc207b0..8ab2ee696 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -26,9 +26,9 @@ /* Freetype2 */ # include -#include +#include "util/set-types.h" -typedef boost::unordered_map FaceMapType; +typedef optim_map FaceMapType; // need to avoid using the size field size_t font_descr_hash::operator()( PangoFontDescription *const &x) const { diff --git a/src/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp index 557e9106e..61cd28190 100644 --- a/src/libnrtype/FontInstance.cpp +++ b/src/libnrtype/FontInstance.cpp @@ -29,7 +29,7 @@ # include FT_TRUETYPE_TABLES_H # include -#include +#include "util/set-types.h" struct font_style_hash : public std::unary_function { @@ -40,7 +40,7 @@ struct font_style_equal : public std::binary_function StyleMap; +typedef optim_map StyleMap; -- cgit v1.2.3 From 91b1b6cec4776d8c2e48b54e16d698abcea6bbfe Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 4 Mar 2010 22:54:38 +0100 Subject: Clean up the unordered containers fix. (bzr r9142) --- src/libnrtype/FontFactory.cpp | 18 ++++++------------ src/libnrtype/FontInstance.cpp | 33 +++++++++++++++------------------ 2 files changed, 21 insertions(+), 30 deletions(-) (limited to 'src/libnrtype') diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index 8ab2ee696..06fb93f2d 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -10,25 +10,19 @@ #define PANGO_ENABLE_ENGINE -#include "FontFactory.h" -#include - -#include - - #ifdef HAVE_CONFIG_H # include "config.h" #endif +#include #include #include // _() +#include +#include "libnrtype/FontFactory.h" +#include "libnrtype/font-instance.h" +#include "util/unordered-containers.h" -/* Freetype2 */ -# include - -#include "util/set-types.h" - -typedef optim_map FaceMapType; +typedef INK_UNORDERED_MAP FaceMapType; // need to avoid using the size field size_t font_descr_hash::operator()( PangoFontDescription *const &x) const { diff --git a/src/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp index 61cd28190..be5eb86c8 100644 --- a/src/libnrtype/FontInstance.cpp +++ b/src/libnrtype/FontInstance.cpp @@ -11,25 +11,22 @@ #define PANGO_ENABLE_ENGINE #ifdef HAVE_CONFIG_H -# include +# include "config.h" #endif -#include -#include -#include -#include <2geom/pathvector.h> -#include - -#include "RasterFont.h" -/* Freetype 2 */ -# include -# include FT_OUTLINE_H -# include FT_BBOX_H -# include FT_TRUETYPE_TAGS_H -# include FT_TRUETYPE_TABLES_H -# include - -#include "util/set-types.h" +#include +#include FT_OUTLINE_H +#include FT_BBOX_H +#include FT_TRUETYPE_TAGS_H +#include FT_TRUETYPE_TABLES_H +#include +#include <2geom/pathvector.h> +#include "libnr/nr-rect.h" +#include "libnrtype/font-glyph.h" +#include "libnrtype/font-instance.h" +#include "libnrtype/RasterFont.h" +#include "livarot/Path.h" +#include "util/unordered-containers.h" struct font_style_hash : public std::unary_function { @@ -40,7 +37,7 @@ struct font_style_equal : public std::binary_function StyleMap; +typedef INK_UNORDERED_MAP StyleMap; -- cgit v1.2.3