[haiku-commits] Change in haiku[master]: app_server: fix font fallback

  • From: Gerrit <review@xxxxxxxxxxxxxxxxxxx>
  • To: waddlesplash <waddlesplash@xxxxxxxxx>, haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 21 May 2020 17:58:02 +0000

From Adrien Destugues <pulkomandy@xxxxxxxxx>:

Adrien Destugues has uploaded this change for review. ( 
https://review.haiku-os.org/c/haiku/+/2767 ;)


Change subject: app_server: fix font fallback
......................................................................

app_server: fix font fallback

Actually check that the replacement font contains the needed glyph.
---
M src/servers/app/font/FontCacheEntry.cpp
M src/servers/app/font/FontCacheEntry.h
M src/servers/app/font/GlyphLayoutEngine.h
3 files changed, 17 insertions(+), 0 deletions(-)



  git pull ssh://git.haiku-os.org:22/haiku refs/changes/67/2767/1

diff --git a/src/servers/app/font/FontCacheEntry.cpp 
b/src/servers/app/font/FontCacheEntry.cpp
index fd2428d..edc18d5 100644
--- a/src/servers/app/font/FontCacheEntry.cpp
+++ b/src/servers/app/font/FontCacheEntry.cpp
@@ -266,6 +266,16 @@
 }


+bool
+FontCacheEntry::CanCreateGlyph(uint32 glyphCode)
+{
+       // Note that this bypass any fallback or caching because it is used in
+       // the fallback code itself.
+       uint32 glyphIndex = fEngine.GlyphIndexForGlyphCode(glyphCode);
+       return glyphIndex != 0;
+}
+
+
 const GlyphCache*
 FontCacheEntry::CreateGlyph(uint32 glyphCode, FontCacheEntry* fallbackEntry)
 {
diff --git a/src/servers/app/font/FontCacheEntry.h 
b/src/servers/app/font/FontCacheEntry.h
index abe085a..233c510 100644
--- a/src/servers/app/font/FontCacheEntry.h
+++ b/src/servers/app/font/FontCacheEntry.h
@@ -112,6 +112,7 @@
                        const GlyphCache*       CachedGlyph(uint32 glyphCode);
                        const GlyphCache*       CreateGlyph(uint32 glyphCode,
                                                                        
FontCacheEntry* fallbackEntry = NULL);
+                       bool                            CanCreateGlyph(uint32 
glyphCode);

                        void                            InitAdaptors(const 
GlyphCache* glyph,
                                                                        double 
x, double y,
diff --git a/src/servers/app/font/GlyphLayoutEngine.h 
b/src/servers/app/font/GlyphLayoutEngine.h
index 7bd51d4..910b88e 100644
--- a/src/servers/app/font/GlyphLayoutEngine.h
+++ b/src/servers/app/font/GlyphLayoutEngine.h
@@ -147,6 +147,11 @@
                return NULL;
        }

+       if (glyphCode != 0 && !entry->CanCreateGlyph(glyphCode)) {
+               cache->Recycle(entry);
+               return NULL;
+       }
+
        if (needsWriteLock) {
                if (!entry->WriteLock()) {
                        cache->Recycle(entry);
@@ -163,6 +168,7 @@
        // proper mode. We can setup the FontCacheReference so it takes care of
        // the locking and recycling from now and return the entry.
        cacheReference.SetTo(entry, needsWriteLock);
+
        return entry;
 }


--
To view, visit https://review.haiku-os.org/c/haiku/+/2767
To unsubscribe, or for help writing mail filters, visit 
https://review.haiku-os.org/settings

Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: I6d774361fcf16a36dc3d05ce8b0fe1cb407fabff
Gerrit-Change-Number: 2767
Gerrit-PatchSet: 1
Gerrit-Owner: Adrien Destugues <pulkomandy@xxxxxxxxx>
Gerrit-MessageType: newchange

Other related posts:

  • » [haiku-commits] Change in haiku[master]: app_server: fix font fallback - Gerrit