vcl/inc/font/PhysicalFontFace.hxx |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 59286d0b99679aeeffd989380754a3687effbb22
Author:     Stephan Bergmann <[email protected]>
AuthorDate: Wed Sep 21 08:08:34 2022 +0200
Commit:     Stephan Bergmann <[email protected]>
CommitDate: Wed Sep 21 10:13:47 2022 +0200

    NameID must encompass the full OpenType Name ID range
    
    ...to avoid CppunitTest_vcl_fontfeature
    CPPUNIT_TEST_NAME=FontFeatureTest::testGetFontFeaturesOpenType failing with
    
    > vcl/source/font/PhysicalFontFace.cxx:376:48: runtime error: load of value 
259, which is not a valid value for type 'NameID'
    >  #0 in vcl::font::PhysicalFontFace::GetName(vcl::font::NameID, 
LanguageTag const&) const at vcl/source/font/PhysicalFontFace.cxx:376:48
    >  #1 in vcl::font::FeatureCollector::collectForTable(unsigned int) at 
vcl/source/font/FeatureCollector.cxx:124:44
    >  #2 in vcl::font::FeatureCollector::collect() at 
vcl/source/font/FeatureCollector.cxx:198:9
    >  #3 in OutputDevice::GetFontFeatures(std::vector<vcl::font::Feature, 
std::allocator<vcl::font::Feature>>&) const at vcl/source/outdev/font.cxx:169:23
    >  #4 in FontFeatureTest::testGetFontFeaturesOpenType() at 
vcl/qa/cppunit/FontFeatureTest.cxx:143:5
    
    after 06a23b7b4d23a31a4808c68f00e1be42d8218737 "vcl: Add
    PhysicalFontFace::GetName()".
    
    Per <https://harfbuzz.github.io/harfbuzz-hb-ot-name.html#hb-ot-name-id-t>,
    hb_ot_name_id_t is a typedef for unsigned int, and per its referenced
    <https://learn.microsoft.com/en-us/typography/opentype/spec/name> OpenType 
Name
    IDs are apparently uint16 values covering the whole value range (e.g., 
"Name IDs
    256 to 32767, inclusive, are reserved for font-specific names").  We could 
thus
    presumably use something like std::uint16_t as the underlying type for 
NameID,
    but lets play it safe (and avoid potential data loss when casting from
    hb_ot_name_id_t to NameID) and simply use hb_ot_name_id_t as the underlying
    type.
    
    Change-Id: I50768c5ae6174500d959ba63fdbc15fe416f8777
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140301
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <[email protected]>

diff --git a/vcl/inc/font/PhysicalFontFace.hxx 
b/vcl/inc/font/PhysicalFontFace.hxx
index 5cdf88bd3ac9..5c4ab2eea046 100644
--- a/vcl/inc/font/PhysicalFontFace.hxx
+++ b/vcl/inc/font/PhysicalFontFace.hxx
@@ -34,6 +34,7 @@
 #include <fontsubset.hxx>
 
 #include <hb.h>
+#include <hb-ot.h>
 
 class LogicalFontInstance;
 struct FontMatchStatus;
@@ -95,7 +96,7 @@ struct ColorLayer
 typedef std::vector<Color> ColorPalette;
 
 // https://learn.microsoft.com/en-us/typography/opentype/spec/name#name-ids
-typedef enum {
+typedef enum : hb_ot_name_id_t {
     NAME_ID_COPYRIGHT = 0,
     NAME_ID_FONT_FAMILY = 1,
     NAME_ID_FONT_SUBFAMILY = 2,

Reply via email to