From 15325401ceeffbac7348f8b7ac518d0d47a2efc2 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sun, 14 Feb 2016 20:59:16 +0100 Subject: [PATCH] app_server: do not return a glyph when nothing is found in the font. - Fixes BFont::GetHasGlyphs, the "empty square" which was returned led it to think the font had glyphs for everything - This means the "no character" empty square will not be drawn anymore, if we want it back, we will need to rework the implementation a bit more (either request it explicitly when there is a missing glyph, or return it as it was before but including an info that it is the "missing glyph") - Maybe GetHasGlyphs should also bypass the font fallback system, and return what's actually in the requested font only. This also fixes a locking problem in the GlyphLayoutEngine, the code didn't handle the read/write lock properly and tried to ReadUnlock from a place where only the write lock was held. --- src/servers/app/font/FontCacheEntry.cpp | 3 ++- src/servers/app/font/GlyphLayoutEngine.h | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/servers/app/font/FontCacheEntry.cpp b/src/servers/app/font/FontCacheEntry.cpp index 39b64d295e4..fd2428d891f 100644 --- a/src/servers/app/font/FontCacheEntry.cpp +++ b/src/servers/app/font/FontCacheEntry.cpp @@ -304,7 +304,8 @@ FontCacheEntry::CreateGlyph(uint32 glyphCode, FontCacheEntry* fallbackEntry) // get the normal space glyph glyphIndex = engine->GlyphIndexForGlyphCode(0x20 /* space */); } else { - // render the "missing glyph box" (by simply keeping glyphIndex 0) + // The glyph was not found anywhere. + return NULL; } } diff --git a/src/servers/app/font/GlyphLayoutEngine.h b/src/servers/app/font/GlyphLayoutEngine.h index 8ed8d198a2b..963c0ca6e46 100644 --- a/src/servers/app/font/GlyphLayoutEngine.h +++ b/src/servers/app/font/GlyphLayoutEngine.h @@ -309,9 +309,15 @@ GlyphLayoutEngine::_WriteLockAndAcquireFallbackEntry( // glyphs from it. We need to obtain the fallback font while we have not // locked anything, since locking the FontManager with the write-lock held // can obvisouly lead to a deadlock. + + bool writeLocked = entry->IsWriteLocked(); - cacheReference.SetTo(NULL, false); - entry->ReadUnlock(); + if (writeLocked) { + entry->WriteUnlock(); + } else { + cacheReference.SetTo(NULL, false); + entry->ReadUnlock(); + } if (gFontManager->Lock()) { // TODO: We always get the fallback glyphs from VL Gothic at the @@ -342,8 +348,10 @@ GlyphLayoutEngine::_WriteLockAndAcquireFallbackEntry( return false; } - // Update the FontCacheReference, since the locking kind changed. - cacheReference.SetTo(entry, true); + if (!writeLocked) { + // Update the FontCacheReference, since the locking kind changed. + cacheReference.SetTo(entry, true); + } return true; }