[haiku-commits] Change in haiku[master]: Fix the font fallback for non-matching styles

  • From: Gerrit <review@xxxxxxxxxxxxxxxxxxx>
  • To: waddlesplash <waddlesplash@xxxxxxxxx>, haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 4 Jun 2020 16:31:55 +0000

From Adrien Destugues <pulkomandy@xxxxxxxxx>:

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


Change subject: Fix the font fallback for non-matching styles
......................................................................

Fix the font fallback for non-matching styles

7a8d5a2db3214be378c4450bd94e07db75d5e240 Introduced that the fallback tries to 
find a matching style
instead of using regular, the fallback was broken in a different way untill 
commit
4dcd8c81b12790b0ad7661f3ab8742ae619996be fixed the remaining issue, this commit
makes the fallback first try the matching style and afterwards try the regular 
style
(so as to improve above falling back to regular in everyy case)
---
M src/servers/app/font/GlyphLayoutEngine.h
1 file changed, 31 insertions(+), 0 deletions(-)



  git pull ssh://git.haiku-os.org:22/haiku refs/changes/77/2877/1

diff --git a/src/servers/app/font/GlyphLayoutEngine.h 
b/src/servers/app/font/GlyphLayoutEngine.h
index 5b5af5c..4c445c2 100644
--- a/src/servers/app/font/GlyphLayoutEngine.h
+++ b/src/servers/app/font/GlyphLayoutEngine.h
@@ -371,6 +371,37 @@
                }
        }

+       // Try to get the glyph from the fallback fonts
+       // this time use style regular
+       // TODO: attempt to get rid of e.g italic style by stripping it
+       // as in "bold italic" -> "bold" before falling back to regular
+       if (fallbackEntry == NULL) {
+               for (i = 0; fallbacks[i] != NULL; i++) {
+                       if (gFontManager->Lock()) {
+                               FontStyle* fallbackStyle = 
gFontManager->GetStyleByIndex(fallbacks[i],
+                                       0);
+
+                               if (fallbackStyle == NULL) {
+                                       gFontManager->Unlock();
+                                       continue;
+                               }
+
+                               ServerFont fallbackFont(*fallbackStyle, 
font.Size());
+                               gFontManager->Unlock();
+
+                               FontCacheEntry* candidateFallbackEntry = 
FontCacheEntryFor(
+                                       fallbackFont, forceVector, entry, 
charCode,
+                                       fallbackCacheReference, true);
+
+                               // Stop when we find a font that indeed has the 
glyph we need.
+                               if (candidateFallbackEntry != NULL) {
+                                       fallbackEntry = candidateFallbackEntry;
+                                       break;
+                               }
+                       }
+               }
+       }
+
        // NOTE: We don't care if fallbackEntry is still NULL, fetching
        // alternate glyphs will simply not work.


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

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

Other related posts:

  • » [haiku-commits] Change in haiku[master]: Fix the font fallback for non-matching styles - Gerrit