Skip to content

Commit

Permalink
app_server: do not return a glyph when nothing is found in the font.
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
pulkomandy committed Feb 14, 2016
1 parent 884412d commit 1532540
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/servers/app/font/FontCacheEntry.cpp
Expand Up @@ -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;
}
}

Expand Down
16 changes: 12 additions & 4 deletions src/servers/app/font/GlyphLayoutEngine.h
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 1532540

Please sign in to comment.