* The Glyph() method takes an optional FontCacheEntry* parameter

which can do an alternative lookup of the glyphCode to glyphIndex
  and who's FontEngine is used to retrieve the GlyphCache object.
  The glyph however is inserted into the Cache of the original entry.
* GlyphCache objects are no longer looked up by index, but by charCode,
  which should not be a functional change, but allows to lookup glyphs
  from the cache for which the underlying FontEngine does not have
  a code to index mapping.
* Fixed an operator precedence bug in the signature generation.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38153 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2010-08-16 19:17:11 +00:00
parent a9f371c057
commit e404b4ed2a
2 changed files with 37 additions and 24 deletions

View File

@ -175,11 +175,10 @@ FontCacheEntry::Init(const ServerFont& font)
bool bool
FontCacheEntry::HasGlyphs(const char* utf8String, ssize_t length) const FontCacheEntry::HasGlyphs(const char* utf8String, ssize_t length) const
{ {
uint32 charCode; uint32 glyphCode;
const char* start = utf8String; const char* start = utf8String;
while ((charCode = UTF8ToCharCode(&utf8String))) { while ((glyphCode = UTF8ToCharCode(&utf8String))) {
uint32 glyphIndex = fEngine.GlyphIndexForGlyphCode(charCode); if (fGlyphCache->FindGlyph(glyphCode) == NULL)
if (!fGlyphCache->FindGlyph(glyphIndex))
return false; return false;
if (utf8String - start + 1 > length) if (utf8String - start + 1 > length)
break; break;
@ -189,29 +188,42 @@ FontCacheEntry::HasGlyphs(const char* utf8String, ssize_t length) const
const GlyphCache* const GlyphCache*
FontCacheEntry::Glyph(uint32 glyphCode) FontCacheEntry::Glyph(uint32 glyphCode, FontCacheEntry* fallbackEntry)
{ {
uint32 glyphIndex = fEngine.GlyphIndexForGlyphCode(glyphCode); // We cache the glyph by the requested glyphCode. The FontEngine of this
if (glyphIndex == 0) // FontCacheEntry may not contain a glyph for the given code, in which case
return NULL; // we ask the fallbackEntry for the code to index translation and let it
const GlyphCache* glyph = fGlyphCache->FindGlyph(glyphIndex); // generate the glyph data. We will still use our own cache for storing the
if (glyph) { // glyph. The next time it will be found (by glyphCode).
// NOTE: Both this and the fallback FontCacheEntry are expected to be
// write-locked!
const GlyphCache* glyph = fGlyphCache->FindGlyph(glyphCode);
if (glyph != NULL)
return glyph; return glyph;
} else {
if (fEngine.PrepareGlyph(glyphIndex)) { FontEngine* engine = &fEngine;
glyph = fGlyphCache->CacheGlyph(glyphIndex, uint32 glyphIndex = engine->GlyphIndexForGlyphCode(glyphCode);
fEngine.DataSize(), fEngine.DataType(), fEngine.Bounds(), if (glyphIndex == 0 && fallbackEntry != NULL) {
fEngine.AdvanceX(), fEngine.AdvanceY(), // Our FontEngine does not contain this glyph, but we can retry with
fEngine.InsetLeft(), fEngine.InsetRight()); // the fallbackEntry.
engine = &fallbackEntry->fEngine;
glyphIndex = engine->GlyphIndexForGlyphCode(glyphCode);
}
if (glyphIndex != 0 && engine->PrepareGlyph(glyphIndex)) {
glyph = fGlyphCache->CacheGlyph(glyphCode,
engine->DataSize(), engine->DataType(), engine->Bounds(),
engine->AdvanceX(), engine->AdvanceY(),
engine->InsetLeft(), engine->InsetRight());
if (glyph != NULL) if (glyph != NULL)
fEngine.WriteGlyphTo(glyph->data); engine->WriteGlyphTo(glyph->data);
}
return glyph; return glyph;
} }
}
return NULL;
}
void void
@ -294,7 +306,7 @@ FontCacheEntry::_RenderTypeFor(const ServerFont& font)
if (font.Rotation() != 0.0 || font.Shear() != 90.0 if (font.Rotation() != 0.0 || font.Shear() != 90.0
|| font.FalseBoldWidth() != 0.0 || font.FalseBoldWidth() != 0.0
|| font.Flags() & B_DISABLE_ANTIALIASING || (font.Flags() & B_DISABLE_ANTIALIASING) != 0
|| font.Size() > 30 || font.Size() > 30
|| !font.Hinting()) { || !font.Hinting()) {
renderingType = glyph_ren_outline; renderingType = glyph_ren_outline;

View File

@ -103,7 +103,8 @@ class FontCacheEntry : public MultiLocker, public BReferenceable {
bool HasGlyphs(const char* utf8String, bool HasGlyphs(const char* utf8String,
ssize_t glyphCount) const; ssize_t glyphCount) const;
const GlyphCache* Glyph(uint32 glyphCode); const GlyphCache* Glyph(uint32 glyphCode,
FontCacheEntry* fallbackEntry = NULL);
void InitAdaptors(const GlyphCache* glyph, void InitAdaptors(const GlyphCache* glyph,
double x, double y, double x, double y,