From 53933f5fea9d07d1ba6304b88439fba257ee8c34 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Wed, 2 Feb 2011 22:24:36 +0100 Subject: update to latest 2geom ! (bzr r10025) --- src/libnrtype/FontInstance.cpp | 2 +- src/libnrtype/Layout-TNG-OutIter.cpp | 4 ++-- src/libnrtype/Layout-TNG-Output.cpp | 28 ++++++++++++++-------------- src/libnrtype/Layout-TNG-Scanline-Makers.cpp | 6 +++--- src/libnrtype/Layout-TNG.h | 12 ++++++------ src/libnrtype/font-instance.h | 2 +- src/libnrtype/font-style.h | 4 ++-- 7 files changed, 29 insertions(+), 29 deletions(-) (limited to 'src/libnrtype') diff --git a/src/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp index bdf700346..6ba6440de 100644 --- a/src/libnrtype/FontInstance.cpp +++ b/src/libnrtype/FontInstance.cpp @@ -794,7 +794,7 @@ double font_instance::Advance(int glyph_id,bool vertical) } -raster_font* font_instance::RasterFont(const Geom::Matrix &trs, double stroke_width, bool vertical, JoinType stroke_join, ButtType stroke_cap, float /*miter_limit*/) +raster_font* font_instance::RasterFont(const Geom::Affine &trs, double stroke_width, bool vertical, JoinType stroke_join, ButtType stroke_cap, float /*miter_limit*/) { font_style nStyle; nStyle.transform=trs; diff --git a/src/libnrtype/Layout-TNG-OutIter.cpp b/src/libnrtype/Layout-TNG-OutIter.cpp index 0682e3570..4d461a486 100644 --- a/src/libnrtype/Layout-TNG-OutIter.cpp +++ b/src/libnrtype/Layout-TNG-OutIter.cpp @@ -343,7 +343,7 @@ Geom::Rect Layout::characterBoundingBox(iterator const &it, double *rotation) co return Geom::Rect(top_left, bottom_right); } -std::vector Layout::createSelectionShape(iterator const &it_start, iterator const &it_end, Geom::Matrix const &transform) const +std::vector Layout::createSelectionShape(iterator const &it_start, iterator const &it_end, Geom::Affine const &transform) const { std::vector quads; unsigned char_index; @@ -398,7 +398,7 @@ std::vector Layout::createSelectionShape(iterator const &it_start, continue; Geom::Point center_of_rotation((top_left[Geom::X] + bottom_right[Geom::X]) * 0.5, top_left[Geom::Y] + _spans[span_index].line_height.ascent); - Geom::Matrix total_transform = Geom::Translate(-center_of_rotation) * Geom::Rotate(char_rotation) * Geom::Translate(center_of_rotation) * transform; + Geom::Affine total_transform = Geom::Translate(-center_of_rotation) * Geom::Rotate(char_rotation) * Geom::Translate(center_of_rotation) * transform; for(int i = 0; i < 4; i ++) quads.push_back(char_box.corner(i) * total_transform); } diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp index 10be0fc51..0d4d19a42 100644 --- a/src/libnrtype/Layout-TNG-Output.cpp +++ b/src/libnrtype/Layout-TNG-Output.cpp @@ -66,7 +66,7 @@ void Layout::LineHeight::max(LineHeight const &other) if (other.leading > leading) leading = other.leading; } -void Layout::_getGlyphTransformMatrix(int glyph_index, Geom::Matrix *matrix) const +void Layout::_getGlyphTransformMatrix(int glyph_index, Geom::Affine *matrix) const { Span const &span = _glyphs[glyph_index].span(this); double sin_rotation = sin(_glyphs[glyph_index].rotation); @@ -97,7 +97,7 @@ void Layout::show(NRArenaGroup *in_arena, NRRect const *paintbox) const nr_arena_glyphs_group_set_style(nr_group, text_source->style); while (glyph_index < (int)_glyphs.size() && _characters[_glyphs[glyph_index].in_character].in_span == span_index) { if (_characters[_glyphs[glyph_index].in_character].in_glyph != -1) { - Geom::Matrix glyph_matrix; + Geom::Affine glyph_matrix; _getGlyphTransformMatrix(glyph_index, &glyph_matrix); nr_arena_glyphs_group_add_component(nr_group, _spans[span_index].font, _glyphs[glyph_index].glyph, glyph_matrix); } @@ -108,7 +108,7 @@ void Layout::show(NRArenaGroup *in_arena, NRRect const *paintbox) const nr_arena_item_request_update(NR_ARENA_ITEM(in_arena), NR_ARENA_ITEM_STATE_ALL, FALSE); } -void Layout::getBoundingBox(NRRect *bounding_box, Geom::Matrix const &transform, int start, int length) const +void Layout::getBoundingBox(NRRect *bounding_box, Geom::Affine const &transform, int start, int length) const { for (unsigned glyph_index = 0 ; glyph_index < _glyphs.size() ; glyph_index++) { if (_characters[_glyphs[glyph_index].in_character].in_glyph == -1) continue; @@ -119,9 +119,9 @@ void Layout::getBoundingBox(NRRect *bounding_box, Geom::Matrix const &transform, if ((int) _glyphs[glyph_index].in_character > start + length) continue; } // this could be faster - Geom::Matrix glyph_matrix; + Geom::Affine glyph_matrix; _getGlyphTransformMatrix(glyph_index, &glyph_matrix); - Geom::Matrix total_transform = glyph_matrix; + Geom::Affine total_transform = glyph_matrix; total_transform *= transform; if(_glyphs[glyph_index].span(this).font) { Geom::OptRect glyph_rect = _glyphs[glyph_index].span(this).font->BBox(_glyphs[glyph_index].glyph); @@ -146,11 +146,11 @@ void Layout::getBoundingBox(NRRect *bounding_box, Geom::Matrix const &transform, void Layout::print(SPPrintContext *ctx, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox, - Geom::Matrix const &ctm) const + Geom::Affine const &ctm) const { if (_input_stream.empty()) return; - Geom::Matrix ctm_2geom(ctm); + Geom::Affine ctm_2geom(ctm); Direction block_progression = _blockProgression(); bool text_to_path = ctx->module->textToPath(); for (unsigned glyph_index = 0 ; glyph_index < _glyphs.size() ; ) { @@ -161,7 +161,7 @@ void Layout::print(SPPrintContext *ctx, glyph_index++; continue; } - Geom::Matrix glyph_matrix; + Geom::Affine glyph_matrix; Span const &span = _spans[_characters[_glyphs[glyph_index].in_character].in_span]; InputStreamTextSource const *text_source = static_cast(_input_stream[span.in_input_stream_item]); if (text_to_path || _path_fitted) { @@ -177,7 +177,7 @@ void Layout::print(SPPrintContext *ctx, glyph_index++; } else { Geom::Point g_pos(0,0); // all strings are output at (0,0) because we do the translation using the matrix - glyph_matrix = Geom::Scale(1.0, -1.0) * (Geom::Matrix)Geom::Rotate(_glyphs[glyph_index].rotation); + glyph_matrix = Geom::Scale(1.0, -1.0) * (Geom::Affine)Geom::Rotate(_glyphs[glyph_index].rotation); if (block_progression == LEFT_TO_RIGHT || block_progression == RIGHT_TO_LEFT) { glyph_matrix[4] = span.line(this).baseline_y + span.baseline_shift; // since we're outputting character codes, not glyphs, we want the character x @@ -237,7 +237,7 @@ void Layout::showGlyphs(CairoRenderContext *ctx) const Span const &span = _spans[_characters[_glyphs[glyph_index].in_character].in_span]; InputStreamTextSource const *text_source = static_cast(_input_stream[span.in_input_stream_item]); - Geom::Matrix glyph_matrix; + Geom::Affine glyph_matrix; _getGlyphTransformMatrix(glyph_index, &glyph_matrix); if (clip_mode) { Geom::PathVector const *pathv = span.font->PathVector(_glyphs[glyph_index].glyph); @@ -250,7 +250,7 @@ void Layout::showGlyphs(CairoRenderContext *ctx) const continue; } - Geom::Matrix font_matrix = glyph_matrix; + Geom::Affine font_matrix = glyph_matrix; font_matrix[4] = 0; font_matrix[5] = 0; @@ -292,7 +292,7 @@ void Layout::showGlyphs(CairoRenderContext *ctx) const && _characters[_glyphs[glyph_index].in_character].in_span == this_span_index); // remove vertical flip - Geom::Matrix flip_matrix; + Geom::Affine flip_matrix; flip_matrix.setIdentity(); flip_matrix[3] = -1.0; font_matrix = flip_matrix * font_matrix; @@ -547,7 +547,7 @@ SPCurve *Layout::convertToCurves(iterator const &from_glyph, iterator const &to_ GSList *cc = NULL; for (int glyph_index = from_glyph._glyph_index ; glyph_index < to_glyph._glyph_index ; glyph_index++) { - Geom::Matrix glyph_matrix; + Geom::Affine glyph_matrix; Span const &span = _glyphs[glyph_index].span(this); _getGlyphTransformMatrix(glyph_index, &glyph_matrix); @@ -576,7 +576,7 @@ SPCurve *Layout::convertToCurves(iterator const &from_glyph, iterator const &to_ return curve; } -void Layout::transform(Geom::Matrix const &transform) +void Layout::transform(Geom::Affine const &transform) { // this is all massively oversimplified // I can't actually think of anybody who'll want to use it at the moment, so it'll stay simple diff --git a/src/libnrtype/Layout-TNG-Scanline-Makers.cpp b/src/libnrtype/Layout-TNG-Scanline-Makers.cpp index 1bfde1f2d..7144f3876 100644 --- a/src/libnrtype/Layout-TNG-Scanline-Makers.cpp +++ b/src/libnrtype/Layout-TNG-Scanline-Makers.cpp @@ -85,9 +85,9 @@ Layout::ShapeScanlineMaker::ShapeScanlineMaker(Shape const *shape, Layout::Direc _shape_needs_freeing = true; temp_rotated_shape->Copy(const_cast(shape)); switch (block_progression) { - case BOTTOM_TO_TOP: temp_rotated_shape->Transform(Geom::Matrix(1.0, 0.0, 0.0, -1.0, 0.0, 0.0)); break; // reflect about x axis - case LEFT_TO_RIGHT: temp_rotated_shape->Transform(Geom::Matrix(0.0, 1.0, 1.0, 0.0, 0.0, 0.0)); break; // reflect about y=x - case RIGHT_TO_LEFT: temp_rotated_shape->Transform(Geom::Matrix(0.0, -1.0, 1.0, 0.0, 0.0, 0.0)); break; // reflect about y=-x + case BOTTOM_TO_TOP: temp_rotated_shape->Transform(Geom::Affine(1.0, 0.0, 0.0, -1.0, 0.0, 0.0)); break; // reflect about x axis + case LEFT_TO_RIGHT: temp_rotated_shape->Transform(Geom::Affine(0.0, 1.0, 1.0, 0.0, 0.0, 0.0)); break; // reflect about y=x + case RIGHT_TO_LEFT: temp_rotated_shape->Transform(Geom::Affine(0.0, -1.0, 1.0, 0.0, 0.0, 0.0)); break; // reflect about y=-x default: break; } _rotated_shape = new Shape; diff --git a/src/libnrtype/Layout-TNG.h b/src/libnrtype/Layout-TNG.h index ae2b9ae9a..5ed922969 100644 --- a/src/libnrtype/Layout-TNG.h +++ b/src/libnrtype/Layout-TNG.h @@ -18,7 +18,7 @@ #include #include #include <2geom/d2.h> -#include <2geom/matrix.h> +#include <2geom/affine.h> #include #include #include @@ -337,7 +337,7 @@ public: \param transform The transform to be applied to the entire object prior to calculating its bounds. */ - void getBoundingBox(NRRect *bounding_box, Geom::Matrix const &transform, int start = -1, int length = -1) const; + void getBoundingBox(NRRect *bounding_box, Geom::Affine const &transform, int start = -1, int length = -1) const; /** Sends all the glyphs to the given print context. \param ctx I have @@ -346,7 +346,7 @@ public: \param bbox parameters \param ctm do yet */ - void print(SPPrintContext *ctx, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox, Geom::Matrix const &ctm) const; + void print(SPPrintContext *ctx, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox, Geom::Affine const &ctm) const; #ifdef HAVE_CAIRO_PDF /** Renders all the glyphs to the given Cairo rendering context. @@ -380,7 +380,7 @@ public: /** Apply the given transform to all the output presently stored in this object. This only transforms the glyph positions, The glyphs themselves will not be transformed. */ - void transform(Geom::Matrix const &transform); + void transform(Geom::Affine const &transform); //@} @@ -501,7 +501,7 @@ public: \a start to \a end and returns the union of these boxes. The return value is a list of zero or more quadrilaterals specified by a group of four points for each, thus size() is always a multiple of four. */ - std::vector createSelectionShape(iterator const &it_start, iterator const &it_end, Geom::Matrix const &transform) const; + std::vector createSelectionShape(iterator const &it_start, iterator const &it_end, Geom::Affine const &transform) const; /** Returns true if \a it points to a character which is a valid cursor position, as defined by Pango. */ @@ -746,7 +746,7 @@ private: /** gets the overall matrix that transforms the given glyph from local space to world space. */ - void _getGlyphTransformMatrix(int glyph_index, Geom::Matrix *matrix) const; + void _getGlyphTransformMatrix(int glyph_index, Geom::Affine *matrix) const; // loads of functions to drill down the object tree, all of them // annoyingly similar and all of them requiring predicate functors. diff --git a/src/libnrtype/font-instance.h b/src/libnrtype/font-instance.h index d52bd723f..33085858b 100644 --- a/src/libnrtype/font-instance.h +++ b/src/libnrtype/font-instance.h @@ -68,7 +68,7 @@ public: Geom::OptRect BBox(int glyph_id); // creates a rasterfont for the given style - raster_font* RasterFont(Geom::Matrix const &trs, double stroke_width, + raster_font* RasterFont(Geom::Affine const &trs, double stroke_width, bool vertical = false, JoinType stroke_join = join_straight, ButtType stroke_cap = butt_straight, float miter_limit = 4.0); // the dashes array in iStyle is copied diff --git a/src/libnrtype/font-style.h b/src/libnrtype/font-style.h index 20f03df86..abfac2737 100644 --- a/src/libnrtype/font-style.h +++ b/src/libnrtype/font-style.h @@ -1,7 +1,7 @@ #ifndef SEEN_LIBNRTYPE_FONT_STYLE_H #define SEEN_LIBNRTYPE_FONT_STYLE_H -#include <2geom/matrix.h> +#include <2geom/affine.h> #include #include @@ -9,7 +9,7 @@ // Different raster styles. struct font_style { - Geom::Matrix transform; // the ctm. contains the font-size + Geom::Affine transform; // the ctm. contains the font-size bool vertical; // should be rendered vertically or not? // good font support would take the glyph alternates for vertical mode, when present double stroke_width; // if 0, the glyph is filled; otherwise stroked -- cgit v1.2.3 From 4e01c64b6094fa1f4bf63ec8a8f77cf21696b711 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sat, 19 Mar 2011 23:42:59 -0700 Subject: Cleaned up memory patch. Fixes bug #737298. Fixed bugs: - https://launchpad.net/bugs/737298 (bzr r10118) --- src/libnrtype/FontFactory.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/libnrtype') diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index 41533e0ab..7fc0a9715 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -371,7 +371,10 @@ Glib::ustring font_factory::ConstructFontSpecification(PangoFontDescription *fon PangoFontDescription *copy = pango_font_description_copy(font); pango_font_description_unset_fields (copy, PANGO_FONT_MASK_SIZE); - pangoString = Glib::ustring(pango_font_description_to_string(copy)); + char * copyAsString = pango_font_description_to_string(copy); + pangoString = copyAsString; + g_free(copyAsString); + copyAsString = 0; pango_font_description_free(copy); @@ -420,8 +423,11 @@ Glib::ustring font_factory::GetUIStyleString(PangoFontDescription const *fontDes pango_font_description_unset_fields(fontDescrCopy, PANGO_FONT_MASK_SIZE); // For now, keep it as style name taken from pango - style = pango_font_description_to_string(fontDescrCopy); + char *fontDescrAsString = pango_font_description_to_string(fontDescrCopy); + style = fontDescrAsString; + g_free(fontDescrAsString); + fontDescrAsString = 0; pango_font_description_free(fontDescrCopy); } @@ -745,7 +751,11 @@ void font_factory::GetUIFamiliesAndStyles(FamilyToStylesMap *map) } } } + g_free(faces); + faces = 0; } + g_free(families); + families = 0; // Sort the style lists for (FamilyToStylesMap::iterator iter = map->begin() ; iter != map->end(); iter++) { -- cgit v1.2.3