vcl/inc/sft.hxx | 2 +- vcl/source/fontsubset/sft.cxx | 9 ++++----- vcl/source/gdi/embeddedfontsmanager.cxx | 2 +- vcl/unx/generic/fontmanager/fontmanager.cxx | 15 +-------------- 4 files changed, 7 insertions(+), 21 deletions(-)
New commits: commit 9dd549e6acc82a295c2b49ea7af4cec8b9d26633 Author: Caolán McNamara <[email protected]> AuthorDate: Tue Oct 14 12:45:29 2025 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Wed Oct 15 17:08:18 2025 +0200 use AnalyzeTTFWeight to get weight to deal with missing OS/2 tables after renaming AnalyzeTTF to AnalyzeTTFWeight. This avoid a Bold font missing its OS/2 getting used as the Regular font Change-Id: Ia34cf686a14a9354ca07889f102942811f5b86a6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192383 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx index 50705e6eb1a7..588583260530 100644 --- a/vcl/inc/sft.hxx +++ b/vcl/inc/sft.hxx @@ -611,7 +611,7 @@ bool GetTTGlobalFontHeadInfo(const AbstractTrueTypeFont *ttf, int& xMin, int& yM OUString analyzeSfntName(const TrueTypeFont* pTTFont, sal_uInt16 nameId, const LanguageTag& rPrefLang); -void AnalyzeTTF(const TrueTypeFont* pTTFont, FontWeight& weight); +FontWeight AnalyzeTTFWeight(const TrueTypeFont* pTTFont); /*- private definitions */ diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx index 2721d93f2ade..5d5d389c131e 100644 --- a/vcl/source/fontsubset/sft.cxx +++ b/vcl/source/fontsubset/sft.cxx @@ -2011,15 +2011,14 @@ OUString analyzeSfntName(const TrueTypeFont* pTTFont, sal_uInt16 nameId, const L return aResult; } -void AnalyzeTTF(const TrueTypeFont* ttf, FontWeight& weight) +FontWeight AnalyzeTTFWeight(const TrueTypeFont* ttf) { sal_uInt32 table_size; const sal_uInt8* table = ttf->table(O_OS2, table_size); if (table_size >= 42) { sal_uInt16 weightOS2 = GetUInt16(table, OS2_usWeightClass_offset); - weight = ImplWeightToSal(weightOS2); - return; + return ImplWeightToSal(weightOS2); } // Fallback to inferring from the style name (name ID 2). @@ -2047,10 +2046,10 @@ void AnalyzeTTF(const TrueTypeFont* ttf, FontWeight& weight) SAL_WARN("vcl.fonts", "Unhandled font style: " << sStyle); } - if (bBold) - weight = WEIGHT_BOLD; (void)bItalic; // we might need to use this in a similar scenario where // italic cannot be found + + return bBold ? WEIGHT_BOLD : WEIGHT_NORMAL; } } // namespace vcl diff --git a/vcl/source/gdi/embeddedfontsmanager.cxx b/vcl/source/gdi/embeddedfontsmanager.cxx index 69760e1d3899..57c950ea4833 100644 --- a/vcl/source/gdi/embeddedfontsmanager.cxx +++ b/vcl/source/gdi/embeddedfontsmanager.cxx @@ -570,7 +570,7 @@ bool EmbeddedFontsManager::analyzeTTF(const void* data, tools::Long size, FontWe if (OpenTTFontBuffer( data, size, 0 /*TODO*/, &font ) != SFErrCodes::Ok) return false; - AnalyzeTTF(font, weight); + weight = AnalyzeTTFWeight(font); CloseTTFont(font); return true; diff --git a/vcl/unx/generic/fontmanager/fontmanager.cxx b/vcl/unx/generic/fontmanager/fontmanager.cxx index f0c40c7cecbd..28ebe7abaf6f 100644 --- a/vcl/unx/generic/fontmanager/fontmanager.cxx +++ b/vcl/unx/generic/fontmanager/fontmanager.cxx @@ -343,20 +343,7 @@ bool PrintFontManager::analyzeSfntFile( PrintFont& rFont ) const rDFA.SetFamilyType(matchFamilyName(rDFA.GetFamilyName())); - switch( aInfo.weight ) - { - case FW_THIN: rDFA.SetWeight(WEIGHT_THIN); break; - case FW_EXTRALIGHT: rDFA.SetWeight(WEIGHT_ULTRALIGHT); break; - case FW_LIGHT: rDFA.SetWeight(WEIGHT_LIGHT); break; - case FW_MEDIUM: rDFA.SetWeight(WEIGHT_MEDIUM); break; - case FW_SEMIBOLD: rDFA.SetWeight(WEIGHT_SEMIBOLD); break; - case FW_BOLD: rDFA.SetWeight(WEIGHT_BOLD); break; - case FW_EXTRABOLD: rDFA.SetWeight(WEIGHT_ULTRABOLD); break; - case FW_BLACK: rDFA.SetWeight(WEIGHT_BLACK); break; - - case FW_NORMAL: - default: rDFA.SetWeight(WEIGHT_NORMAL); break; - } + rDFA.SetWeight(AnalyzeTTFWeight(pTTFont)); switch( aInfo.width ) {
