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:
@@ -446,7 +446,8 @@ class HasGlyphsConsumer {
|
|||||||
fHasArray[index] = false;
|
fHasArray[index] = false;
|
||||||
}
|
}
|
||||||
bool ConsumeGlyph(int32 index, uint32 charCode, const GlyphCache* glyph,
|
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;
|
fHasArray[index] = glyph->glyph_index != 0;
|
||||||
return true;
|
return true;
|
||||||
@@ -491,7 +492,8 @@ class EdgesConsumer {
|
|||||||
fEdges[index].right = 0.0;
|
fEdges[index].right = 0.0;
|
||||||
}
|
}
|
||||||
bool ConsumeGlyph(int32 index, uint32 charCode, const GlyphCache* glyph,
|
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].left = glyph->inset_left / fSize;
|
||||||
fEdges[index].right = glyph->inset_right / fSize;
|
fEdges[index].right = glyph->inset_right / fSize;
|
||||||
@@ -560,9 +562,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ConsumeGlyph(int32 index, uint32 charCode, const GlyphCache* glyph,
|
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:
|
private:
|
||||||
@@ -631,12 +634,13 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ConsumeGlyph(int32 index, uint32 charCode, const GlyphCache* glyph,
|
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)
|
if (index >= fNumChars)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
fWidths[index] = glyph->advance_x / fSize;
|
fWidths[index] = advanceX / fSize;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -685,7 +689,8 @@ class BoundingBoxConsumer {
|
|||||||
void Finish(double x, double y) {}
|
void Finish(double x, double y) {}
|
||||||
void ConsumeEmptyGlyph(int32 index, uint32 charCode, double x, double y) {}
|
void ConsumeEmptyGlyph(int32 index, uint32 charCode, double x, double y) {}
|
||||||
bool ConsumeGlyph(int32 index, uint32 charCode, const GlyphCache* glyph,
|
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) {
|
if (glyph->data_type != glyph_data_outline) {
|
||||||
const agg::rect_i& r = glyph->bounds;
|
const agg::rect_i& r = glyph->bounds;
|
||||||
@@ -812,7 +817,8 @@ class StringWidthConsumer {
|
|||||||
void Finish(double x, double y) { width = x; }
|
void Finish(double x, double y) { width = x; }
|
||||||
void ConsumeEmptyGlyph(int32 index, uint32 charCode, double x, double y) {}
|
void ConsumeEmptyGlyph(int32 index, uint32 charCode, double x, double y) {}
|
||||||
bool ConsumeGlyph(int32 index, uint32 charCode, const GlyphCache* glyph,
|
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; }
|
{ return true; }
|
||||||
|
|
||||||
float width;
|
float width;
|
||||||
|
|||||||
@@ -184,7 +184,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ConsumeGlyph(int32 index, uint32 charCode, const GlyphCache* glyph,
|
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
|
// "glyphBounds" is the bounds of the glyph transformed
|
||||||
// by the x y location of the glyph along the base line,
|
// by the x y location of the glyph along the base line,
|
||||||
|
|||||||
@@ -232,9 +232,6 @@ GlyphLayoutEngine::LayoutGlyphs(GlyphConsumer& consumer,
|
|||||||
|
|
||||||
x += advanceX;
|
x += advanceX;
|
||||||
y += advanceY;
|
y += advanceY;
|
||||||
|
|
||||||
if (delta != NULL && index > 0)
|
|
||||||
x += IsWhiteSpace(charCode) ? delta->space : delta->nonspace;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const GlyphCache* glyph = entry->CachedGlyph(charCode);
|
const GlyphCache* glyph = entry->CachedGlyph(charCode);
|
||||||
@@ -258,15 +255,22 @@ GlyphLayoutEngine::LayoutGlyphs(GlyphConsumer& consumer,
|
|||||||
advanceX = 0;
|
advanceX = 0;
|
||||||
advanceY = 0;
|
advanceY = 0;
|
||||||
} else {
|
} else {
|
||||||
if (!consumer.ConsumeGlyph(index++, charCode, glyph, entry, x, y)) {
|
|
||||||
advanceX = 0;
|
|
||||||
advanceY = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get next increment for pen position
|
// get next increment for pen position
|
||||||
advanceX = glyph->advance_x;
|
advanceX = glyph->advance_x;
|
||||||
advanceY = glyph->advance_y;
|
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;
|
// lastCharCode = charCode;
|
||||||
|
|||||||
Reference in New Issue
Block a user