* 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
This commit is contained in:
Adrien Destugues 2010-07-07 18:25:19 +00:00
parent 0f66fdc1b3
commit 7215b9e2ed
2 changed files with 37 additions and 30 deletions

View File

@ -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) {

View File

@ -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) {