summaryrefslogtreecommitdiffstats
path: root/src/libnrtype
diff options
context:
space:
mode:
authorKrzysztof Kosi??ski <tweenk.pl@gmail.com>2011-04-07 23:42:04 +0000
committerKrzysztof KosiƄski <tweenk.pl@gmail.com>2011-04-07 23:42:04 +0000
commit945ce419c806c73d70203dec33ececafbe108a92 (patch)
treecfcdb59bf47e9db7f9e01f7eebb59924bdeaea94 /src/libnrtype
parentMerge from trunk (again) (diff)
parentExtensions. SVG+media fix (see Bug #400356). (diff)
downloadinkscape-945ce419c806c73d70203dec33ececafbe108a92.tar.gz
inkscape-945ce419c806c73d70203dec33ececafbe108a92.zip
Merge from trunk
(bzr r9508.1.73)
Diffstat (limited to 'src/libnrtype')
-rw-r--r--src/libnrtype/FontFactory.cpp14
-rw-r--r--src/libnrtype/Layout-TNG-OutIter.cpp4
-rw-r--r--src/libnrtype/Layout-TNG-Output.cpp28
-rw-r--r--src/libnrtype/Layout-TNG-Scanline-Makers.cpp6
-rw-r--r--src/libnrtype/Layout-TNG.h12
-rw-r--r--src/libnrtype/font-style.h4
6 files changed, 39 insertions, 29 deletions
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++) {
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<Geom::Point> Layout::createSelectionShape(iterator const &it_start, iterator const &it_end, Geom::Matrix const &transform) const
+std::vector<Geom::Point> Layout::createSelectionShape(iterator const &it_start, iterator const &it_end, Geom::Affine const &transform) const
{
std::vector<Geom::Point> quads;
unsigned char_index;
@@ -398,7 +398,7 @@ std::vector<Geom::Point> 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 7c941522d..610f92582 100644
--- a/src/libnrtype/Layout-TNG-Output.cpp
+++ b/src/libnrtype/Layout-TNG-Output.cpp
@@ -63,7 +63,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);
@@ -94,7 +94,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);
}
@@ -105,7 +105,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;
@@ -116,9 +116,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);
@@ -143,11 +143,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() ; ) {
@@ -158,7 +158,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<InputStreamTextSource const *>(_input_stream[span.in_input_stream_item]);
if (text_to_path || _path_fitted) {
@@ -174,7 +174,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
@@ -234,7 +234,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<InputStreamTextSource const *>(_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);
@@ -247,7 +247,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;
@@ -289,7 +289,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;
@@ -544,7 +544,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);
@@ -573,7 +573,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*>(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 833ddc6fd..7d0c58c3e 100644
--- a/src/libnrtype/Layout-TNG.h
+++ b/src/libnrtype/Layout-TNG.h
@@ -16,7 +16,7 @@
#endif
#include <libnr/nr-rect.h>
#include <2geom/d2.h>
-#include <2geom/matrix.h>
+#include <2geom/affine.h>
#include <glibmm/ustring.h>
#include <pango/pango-break.h>
#include <algorithm>
@@ -335,7 +335,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
@@ -344,7 +344,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.
@@ -378,7 +378,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);
//@}
@@ -499,7 +499,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<Geom::Point> createSelectionShape(iterator const &it_start, iterator const &it_end, Geom::Matrix const &transform) const;
+ std::vector<Geom::Point> 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. */
@@ -744,7 +744,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-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 <livarot/LivarotDefs.h>
#include <livarot/livarot-forward.h>
@@ -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