app_server: font style 0 may not exist

In which case failure to find it in the styles hash table does not tell
us anything about the existence of its family.

Change-Id: I77c8960a96e7283547650daae67ea71fd022567e
Reviewed-on: https://review.haiku-os.org/c/haiku/+/7631
Haiku-Format: Haiku-format Bot <[email protected]>
Reviewed-by: Fredrik Holmqvist <[email protected]>
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
Máximo Castañeda
2024-05-02 18:05:38 +00:00
committed by waddlesplash
parent d2ac1f5ab2
commit f657c49d1c
3 changed files with 30 additions and 8 deletions
+17 -1
View File
@@ -166,7 +166,8 @@ FontManager::GetFamily(uint16 familyID) const
if (style != NULL)
return style->Family();
return NULL;
// Try the slow route in case style 0 was removed
return _FindFamily(familyID);
}
@@ -374,6 +375,21 @@ FontManager::_FindFamily(const char* name) const
}
FontFamily*
FontManager::_FindFamily(uint16 familyID) const
{
int32 count = fFamilies.CountItems();
for (int32 i = 0; i < count; i++) {
FontFamily* family = fFamilies.ItemAt(i);
if (family->ID() == familyID)
return family;
}
return NULL;
}
uint16
FontManager::_NextID()
{
+1
View File
@@ -67,6 +67,7 @@ protected:
FT_CharMap _GetSupportedCharmap(const FT_Face& face);
FontFamily* _FindFamily(const char* family) const;
FontFamily* _FindFamily(uint16 familyID) const;
status_t _AddFont(FT_Face face, node_ref nodeRef,
const char* path,
+12 -7
View File
@@ -429,20 +429,27 @@ GlyphLayoutEngine::PopulateFallbacks(
return;
static const int nFallbacks = B_COUNT_OF(fallbacks);
static const int acceptAnyStyle = 2;
for (int c = 0; c < 3; c++) {
for (int degradeLevel = 0; degradeLevel <= acceptAnyStyle; degradeLevel++) {
const char* fontStyle;
if (c == 0)
if (degradeLevel == 0)
fontStyle = font.Style();
else if (c == 1)
else if (degradeLevel == 1)
fontStyle = "Regular";
else
fontStyle = NULL;
for (int i = 0; i < nFallbacks; i++) {
FontStyle* fallbackStyle = gFontManager->GetStyle(fallbacks[i],
fontStyle, 0xffff, 0);
FontStyle* fallbackStyle;
if (degradeLevel != acceptAnyStyle) {
fallbackStyle = gFontManager->GetStyle(fallbacks[i], fontStyle);
} else {
// At this point we'll just take whatever we are given
fallbackStyle = gFontManager->GetStyleByIndex(fallbacks[i], 0);
}
if (fallbackStyle == NULL)
continue;
@@ -458,9 +465,7 @@ GlyphLayoutEngine::PopulateFallbacks(
fallbacksList.AddItem(cacheReference);
} else
FontCache::Default()->Recycle(entry);
}
}
gFontManager->Unlock();