From 7215b9e2eda5131f04d8ba24175b69ada16fe770 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Wed, 7 Jul 2010 18:25:19 +0000 Subject: [PATCH] * Avoid falling back to VL Gothic if the font with a missing glyph is VL Gothic itself. * Some cleanup and style fixes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37419 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/FontCacheEntry.cpp | 2 +- src/servers/app/GlyphLayoutEngine.h | 65 ++++++++++++++++------------- 2 files changed, 37 insertions(+), 30 deletions(-) diff --git a/src/servers/app/FontCacheEntry.cpp b/src/servers/app/FontCacheEntry.cpp index 76733636de..707a01f9a9 100644 --- a/src/servers/app/FontCacheEntry.cpp +++ b/src/servers/app/FontCacheEntry.cpp @@ -192,7 +192,7 @@ const GlyphCache* FontCacheEntry::Glyph(uint32 glyphCode) { uint32 glyphIndex = fEngine.GlyphIndexForGlyphCode(glyphCode); - if (glyphIndex==0) + if (glyphIndex == 0) return NULL; const GlyphCache* glyph = fGlyphCache->FindGlyph(glyphIndex); if (glyph) { diff --git a/src/servers/app/GlyphLayoutEngine.h b/src/servers/app/GlyphLayoutEngine.h index 00e23b6e75..a2e54edc42 100644 --- a/src/servers/app/GlyphLayoutEngine.h +++ b/src/servers/app/GlyphLayoutEngine.h @@ -177,39 +177,46 @@ GlyphLayoutEngine::LayoutGlyphs(GlyphConsumer& consumer, // Try to find a suitable glyph in another font FontCache* cache = FontCache::Default(); bool needsWriteLock = false; - ServerFont f(*(gFontManager->GetStyleByIndex("VL Gothic",0))); - // We always try to get the glyph from VL Gothic, so we can display - // japanese character. Other scripts (indian, ...) should be handled - // too, perhaps with a charcode > font mapping. - fallbackEntry = cache->FontCacheEntryFor(f); - if (!fallbackEntry || !fallbackEntry->ReadLock()) { - cache->Recycle(fallbackEntry); - continue; - } - - needsWriteLock = !fallbackEntry->HasGlyphs(utf8String, length); - - if (needsWriteLock) { - fallbackEntry->ReadUnlock(); - if (!fallbackEntry->WriteLock()) { + ServerFont fallbackFont(*(gFontManager->GetStyleByIndex("VL Gothic", + 0))); + // We always try to get the glyph from VL Gothic, so we can + // display japanese characters. Other scripts (indian, ...) + // should be handled too, perhaps with a charcode > font + // mapping. + // TODO : the font should not be hardcoded, but somehow derived + // from the one that missed a glyph. + bool consumed = true; + fallbackEntry = cache->FontCacheEntryFor(fallbackFont); + if (fallbackEntry != entry) + { + if (!fallbackEntry || !fallbackEntry->ReadLock()) { cache->Recycle(fallbackEntry); continue; } + + needsWriteLock = !fallbackEntry->HasGlyphs(utf8String, length); + + if (needsWriteLock) { + fallbackEntry->ReadUnlock(); + if (!fallbackEntry->WriteLock()) { + cache->Recycle(fallbackEntry); + continue; + } + } + + glyph = fallbackEntry->Glyph(charCode); + if (glyph != NULL && !consumer.ConsumeGlyph(index, charCode, + glyph, fallbackEntry, x, y)) { + advanceX = 0; + advanceY = 0; + consumed = false; + } + + if (needsWriteLock) + fallbackEntry->WriteUnlock(); + else + fallbackEntry->ReadUnlock(); } - - bool consumed = true; - glyph = fallbackEntry->Glyph(charCode); - if (glyph != NULL && !consumer.ConsumeGlyph(index, charCode, glyph, fallbackEntry, x, y)) { - advanceX = 0; - advanceY = 0; - consumed = false; - } - - if (needsWriteLock) - fallbackEntry->WriteUnlock(); - else - fallbackEntry->ReadUnlock(); - FontCache::Default()->Recycle(fallbackEntry); if (glyph == NULL) {