Code

Patch by Adib for 248721. Thanks Adib!
authorscislac <scislac@users.sourceforge.net>
Fri, 25 Sep 2009 21:48:48 +0000 (21:48 +0000)
committerscislac <scislac@users.sourceforge.net>
Fri, 25 Sep 2009 21:48:48 +0000 (21:48 +0000)
src/libnrtype/Layout-TNG-Output.cpp

index 2003ca26bbc89bd1a3635049de7635c64dd22cc3..2b4b80e7c4cfc01f5f30b0d72997c956a7100016 100644 (file)
@@ -215,7 +215,7 @@ void Layout::print(SPPrintContext *ctx,
 void Layout::showGlyphs(CairoRenderContext *ctx) const
 {
     if (_input_stream.empty()) return;
-    
+
     bool clip_mode = false;//(ctx->getRenderMode() == CairoRenderContext::RENDER_MODE_CLIP);
     std::vector<CairoGlyphInfo> glyphtext;
 
@@ -243,14 +243,9 @@ void Layout::showGlyphs(CairoRenderContext *ctx) const
             continue;
         }
 
-        Geom::Matrix font_matrix;
-        if (_path_fitted == NULL) {
-            font_matrix = glyph_matrix;
-            font_matrix[4] = 0;
-            font_matrix[5] = 0;
-        } else {
-            font_matrix.setIdentity();
-        }
+        Geom::Matrix font_matrix = glyph_matrix;
+        font_matrix[4] = 0;
+        font_matrix[5] = 0;
 
         Glib::ustring::const_iterator span_iter = span.input_stream_first_character;
         unsigned char_index = _glyphs[glyph_index].in_character;
@@ -276,13 +271,10 @@ void Layout::showGlyphs(CairoRenderContext *ctx) const
 
                 CairoGlyphInfo info;
                 info.index = _glyphs[glyph_index].glyph;
-                if (_path_fitted == NULL) {
-                   info.x = glyph_matrix[4];
-                    info.y = glyph_matrix[5];
-                } else {
-                    info.x = 0;
-                    info.y = 0;                    
-                }
+                // this is the translation for x,y-offset
+                info.x = glyph_matrix[4];
+                info.y = glyph_matrix[5];
+
                 glyphtext.push_back(info);
 
                 glyph_index++;
@@ -291,26 +283,24 @@ void Layout::showGlyphs(CairoRenderContext *ctx) const
                  && _path_fitted == NULL
                  && NR::transform_equalp(font_matrix, glyph_matrix, NR_EPSILON)
                  && _characters[_glyphs[glyph_index].in_character].in_span == this_span_index);
-         
+
         // remove vertical flip
-        font_matrix[3] *= -1.0;
+        Geom::Matrix flip_matrix;
+        flip_matrix.setIdentity();
+        flip_matrix[3] = -1.0;
+        font_matrix = flip_matrix * font_matrix;
 
         SPStyle const *style = text_source->style;
         float opacity = SP_SCALE24_TO_FLOAT(style->opacity.value);
-        
-        if (_path_fitted) {
-            ctx->pushState();
-            ctx->transform(&glyph_matrix);
-        } else if (opacity != 1.0) {
+
+        if (opacity != 1.0) {
             ctx->pushState();
             ctx->setStateForStyle(style);
             ctx->pushLayer();
         }
         if (glyph_index - first_index > 0)
             ctx->renderGlyphtext(span.font->pFont, &font_matrix, glyphtext, style);
-        if (_path_fitted)
-            ctx->popState();
-        else if (opacity != 1.0) {
+        if (opacity != 1.0) {
             ctx->popLayer();
             ctx->popState();
         }