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.
This commit is contained in:
Stephan Aßmus 2014-02-20 22:31:44 +01:00
parent a073305c96
commit 4ccc40a15c
3 changed files with 29 additions and 18 deletions

View File

@ -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;

View File

@ -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,

View File

@ -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;