[haiku-commits] haiku: hrev46897 - in src/servers/app: . font drawing/Painter

  • From: superstippi@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 20 Feb 2014 22:53:46 +0100 (CET)

hrev46897 adds 1 changeset to branch 'master'
old head: a073305c9669e9a76db294148e6eef1e5ceb2d5e
new head: 4ccc40a15c5c250fbd5ddbefcfff5b651b102825
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=4ccc40a+%5Ea073305

----------------------------------------------------------------------------

4ccc40a: app_server: Fixed BFont::GetEscapements()
  
  Both versions effectively ignored the provided escapement_delta.
  Also when layouting glyphs, the space/non-space delta were applied
  off-by-one. It should affect the advance for the current glyph,
  not the offset.

                                      [ Stephan Aßmus <superstippi@xxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev46897
Commit:      4ccc40a15c5c250fbd5ddbefcfff5b651b102825
URL:         http://cgit.haiku-os.org/haiku/commit/?id=4ccc40a
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Thu Feb 20 21:31:44 2014 UTC

----------------------------------------------------------------------------

3 files changed, 29 insertions(+), 18 deletions(-)
src/servers/app/ServerFont.cpp                   | 22 +++++++++++++-------
.../app/drawing/Painter/AGGTextRenderer.cpp      |  3 ++-
src/servers/app/font/GlyphLayoutEngine.h         | 22 ++++++++++++--------

----------------------------------------------------------------------------

diff --git a/src/servers/app/ServerFont.cpp b/src/servers/app/ServerFont.cpp
index 5655b02..3e25553 100644
--- a/src/servers/app/ServerFont.cpp
+++ b/src/servers/app/ServerFont.cpp
@@ -446,7 +446,8 @@ class HasGlyphsConsumer {
                fHasArray[index] = false;
        }
        bool ConsumeGlyph(int32 index, uint32 charCode, const GlyphCache* glyph,
-               FontCacheEntry* entry, double x, double y)
+               FontCacheEntry* entry, double x, double y, double advanceX,
+                       double advanceY)
        {
                fHasArray[index] = glyph->glyph_index != 0;
                return true;
@@ -491,7 +492,8 @@ class EdgesConsumer {
                fEdges[index].right = 0.0;
        }
        bool ConsumeGlyph(int32 index, uint32 charCode, const GlyphCache* glyph,
-               FontCacheEntry* entry, double x, double y)
+               FontCacheEntry* entry, double x, double y, double advanceX,
+                       double advanceY)
        {
                fEdges[index].left = glyph->inset_left / fSize;
                fEdges[index].right = glyph->inset_right / fSize;
@@ -560,9 +562,10 @@ public:
        }
 
        bool ConsumeGlyph(int32 index, uint32 charCode, const GlyphCache* glyph,
-               FontCacheEntry* entry, double x, double y)
+               FontCacheEntry* entry, double x, double y, double advanceX,
+                       double advanceY)
        {
-               return _Set(index, glyph->advance_x, glyph->advance_y);
+               return _Set(index, advanceX, advanceY);
        }
 
 private:
@@ -631,12 +634,13 @@ public:
        }
 
        bool ConsumeGlyph(int32 index, uint32 charCode, const GlyphCache* glyph,
-               FontCacheEntry* entry, double x, double y)
+               FontCacheEntry* entry, double x, double y, double advanceX,
+                       double advanceY)
        {
                if (index >= fNumChars)
                        return false;
 
-               fWidths[index] = glyph->advance_x / fSize;
+               fWidths[index] = advanceX / fSize;
                return true;
        }
 
@@ -685,7 +689,8 @@ class BoundingBoxConsumer {
        void Finish(double x, double y) {}
        void ConsumeEmptyGlyph(int32 index, uint32 charCode, double x, double 
y) {}
        bool ConsumeGlyph(int32 index, uint32 charCode, const GlyphCache* glyph,
-               FontCacheEntry* entry, double x, double y)
+               FontCacheEntry* entry, double x, double y, double advanceX,
+                       double advanceY)
        {
                if (glyph->data_type != glyph_data_outline) {
                        const agg::rect_i& r = glyph->bounds;
@@ -812,7 +817,8 @@ class StringWidthConsumer {
        void Finish(double x, double y) { width = x; }
        void ConsumeEmptyGlyph(int32 index, uint32 charCode, double x, double 
y) {}
        bool ConsumeGlyph(int32 index, uint32 charCode, const GlyphCache* glyph,
-               FontCacheEntry* entry, double x, double y)
+               FontCacheEntry* entry, double x, double y, double advanceX,
+                       double advanceY)
        { return true; }
 
        float width;
diff --git a/src/servers/app/drawing/Painter/AGGTextRenderer.cpp 
b/src/servers/app/drawing/Painter/AGGTextRenderer.cpp
index 64876d5..ad4598a 100644
--- a/src/servers/app/drawing/Painter/AGGTextRenderer.cpp
+++ b/src/servers/app/drawing/Painter/AGGTextRenderer.cpp
@@ -184,7 +184,8 @@ public:
        }
 
        bool ConsumeGlyph(int32 index, uint32 charCode, const GlyphCache* glyph,
-               FontCacheEntry* entry, double x, double y)
+               FontCacheEntry* entry, double x, double y, double advanceX,
+                       double advanceY)
        {
                // "glyphBounds" is the bounds of the glyph transformed
                // by the x y location of the glyph along the base line,
diff --git a/src/servers/app/font/GlyphLayoutEngine.h 
b/src/servers/app/font/GlyphLayoutEngine.h
index d03619c..481cfb1 100644
--- a/src/servers/app/font/GlyphLayoutEngine.h
+++ b/src/servers/app/font/GlyphLayoutEngine.h
@@ -232,9 +232,6 @@ GlyphLayoutEngine::LayoutGlyphs(GlyphConsumer& consumer,
 
                        x += advanceX;
                        y += advanceY;
-
-                       if (delta != NULL && index > 0)
-                               x += IsWhiteSpace(charCode) ? delta->space : 
delta->nonspace;
                }
 
                const GlyphCache* glyph = entry->CachedGlyph(charCode);
@@ -258,15 +255,22 @@ GlyphLayoutEngine::LayoutGlyphs(GlyphConsumer& consumer,
                        advanceX = 0;
                        advanceY = 0;
                } else {
-                       if (!consumer.ConsumeGlyph(index++, charCode, glyph, 
entry, x, y)) {
-                               advanceX = 0;
-                               advanceY = 0;
-                               break;
-                       }
-
                        // get next increment for pen position
                        advanceX = glyph->advance_x;
                        advanceY = glyph->advance_y;
+
+                       // adjust for custom spacing
+                       if (delta != NULL) {
+                               advanceX += IsWhiteSpace(charCode)
+                                       ? delta->space : delta->nonspace;
+                       }
+
+                       if (!consumer.ConsumeGlyph(index++, charCode, glyph, 
entry, x, y,
+                                       advanceX, advanceY)) {
+                               advanceX = 0.0;
+                               advanceY = 0.0;
+                               break;
+                       }
                }
 
 //             lastCharCode = charCode;


Other related posts:

  • » [haiku-commits] haiku: hrev46897 - in src/servers/app: . font drawing/Painter - superstippi