diff options
| author | Ted Gould <ted@gould.cx> | 2010-03-26 04:34:25 +0000 |
|---|---|---|
| committer | Ted Gould <ted@gould.cx> | 2010-03-26 04:34:25 +0000 |
| commit | 9e023a3aa964a0d3fa1e31e46d33657367ba68aa (patch) | |
| tree | 33f1392a340737e4eeefca6fd031f96c29befd2b /src/libnrtype | |
| parent | Installing the pkgconfig file (diff) | |
| parent | Adding in shape-record.h (diff) | |
| download | inkscape-9e023a3aa964a0d3fa1e31e46d33657367ba68aa.tar.gz inkscape-9e023a3aa964a0d3fa1e31e46d33657367ba68aa.zip | |
Merge from trunk
(bzr r8254.1.53)
Diffstat (limited to 'src/libnrtype')
| -rw-r--r-- | src/libnrtype/FontFactory.cpp | 30 | ||||
| -rw-r--r-- | src/libnrtype/FontFactory.h | 2 | ||||
| -rw-r--r-- | src/libnrtype/FontInstance.cpp | 40 | ||||
| -rw-r--r-- | src/libnrtype/Layout-TNG-Compute.cpp | 6 | ||||
| -rw-r--r-- | src/libnrtype/Layout-TNG-Input.cpp | 68 | ||||
| -rw-r--r-- | src/libnrtype/Layout-TNG-Output.cpp | 2 | ||||
| -rw-r--r-- | src/libnrtype/Layout-TNG.h | 4 | ||||
| -rw-r--r-- | src/libnrtype/font-instance.h | 4 |
8 files changed, 43 insertions, 113 deletions
diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index 1f85ee5ca..06fb93f2d 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -10,26 +10,19 @@ #define PANGO_ENABLE_ENGINE -#include "FontFactory.h" -#include <libnrtype/font-instance.h> - -#include <glibmm.h> - - #ifdef HAVE_CONFIG_H # include "config.h" #endif +#include <glibmm.h> #include <glib/gmem.h> #include <glibmm/i18n.h> // _() +#include <pango/pangoft2.h> +#include "libnrtype/FontFactory.h" +#include "libnrtype/font-instance.h" +#include "util/unordered-containers.h" -/* Freetype2 */ -# include <pango/pangoft2.h> - -#include <ext/hash_map> - - -typedef __gnu_cxx::hash_map<PangoFontDescription*, font_instance*, font_descr_hash, font_descr_equal> FaceMapType; +typedef INK_UNORDERED_MAP<PangoFontDescription*, font_instance*, font_descr_hash, font_descr_equal> FaceMapType; // need to avoid using the size field size_t font_descr_hash::operator()( PangoFontDescription *const &x) const { @@ -47,7 +40,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); @@ -332,6 +325,7 @@ font_factory::~font_factory(void) { if (loadedPtr) { FaceMapType* tmp = static_cast<FaceMapType*>(loadedPtr); + delete tmp; loadedPtr = 0; } @@ -824,9 +818,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/FontFactory.h b/src/libnrtype/FontFactory.h index 8d85bcf3e..0118c862d 100644 --- a/src/libnrtype/FontFactory.h +++ b/src/libnrtype/FontFactory.h @@ -45,7 +45,7 @@ struct font_descr_hash : public std::unary_function<PangoFontDescription*,size_t size_t operator()(PangoFontDescription *const &x) const; }; struct font_descr_equal : public std::binary_function<PangoFontDescription*, PangoFontDescription*, bool> { - bool operator()(PangoFontDescription *const &a, PangoFontDescription *const &b); + bool operator()(PangoFontDescription *const &a, PangoFontDescription *const &b) const; }; // Comparison functions for style names diff --git a/src/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp index f34a230c1..be5eb86c8 100644 --- a/src/libnrtype/FontInstance.cpp +++ b/src/libnrtype/FontInstance.cpp @@ -11,39 +11,33 @@ #define PANGO_ENABLE_ENGINE #ifdef HAVE_CONFIG_H -# include <config.h> +# include "config.h" #endif -#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" - -/* Freetype 2 */ -# include <ft2build.h> -# include FT_OUTLINE_H -# include FT_BBOX_H -# include FT_TRUETYPE_TAGS_H -# include FT_TRUETYPE_TABLES_H -# include <pango/pangoft2.h> -#include <ext/hash_map> +#include <ft2build.h> +#include FT_OUTLINE_H +#include FT_BBOX_H +#include FT_TRUETYPE_TAGS_H +#include FT_TRUETYPE_TABLES_H +#include <pango/pangoft2.h> +#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" -// 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<font_style, size_t> { size_t operator()(font_style const &x) const; }; struct font_style_equal : public std::binary_function<font_style, font_style, bool> { - bool operator()(font_style const &a, font_style const &b); + bool operator()(font_style const &a, font_style const &b) const; }; - -typedef __gnu_cxx::hash_map<font_style, raster_font*, font_style_hash, font_style_equal> StyleMap; +typedef INK_UNORDERED_MAP<font_style, raster_font*, font_style_hash, font_style_equal> StyleMap; @@ -76,7 +70,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/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. 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; |
