Fix type, calculation of FamilyFont PitchAndFamily
This patch fixes problems caused by the cleanup commit
3e7dd04dd8ca1baea4b7918eb7a7080c595c4625 for type and calculation of
FamilyFont and PitchAndFamily enumerations.
FamilyFont enumeration is described in [MS-WMF] v20210625 page 33:
"In a Font Object, when a FamilyFont value is packed into a byte
with a PitchFont Enumeration value, the result is a PitchAndFamily
Object".
Thus, we will use sal_uInt8 as the underlying type for FamilyFont.
The PitchAndFamily is created as shown in [MS-WMF] v20210625 page 96:
[0 1 2 3] 4 5 [6 7]
Family 0 0 Pitch
The values for FamilyFont enumeration are created according to the
[MS-WMF], and the calculations are changed to use '<< 4' and '>> 4'
instead of applying the same shift to the enumeration values.
Change-Id: I4f6df33ed6405589acf89ba2c9223a571cb510b5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132614
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
diff --git a/emfio/inc/mtftools.hxx b/emfio/inc/mtftools.hxx
index cb6e1c7..0290c48 100644
--- a/emfio/inc/mtftools.hxx
+++ b/emfio/inc/mtftools.hxx
@@ -275,7 +275,7 @@ namespace emfio
};
/* [MS-WMF] - v20210625 - pages 33, */
enum FamilyFont : sal_uInt32
enum FamilyFont : sal_uInt8
{
FF_DONTCARE = 0x00,
FF_ROMAN = 0x01,
diff --git a/emfio/qa/cppunit/wmf/wmfimporttest.cxx b/emfio/qa/cppunit/wmf/wmfimporttest.cxx
index 1ae7416..b8c2218 100644
--- a/emfio/qa/cppunit/wmf/wmfimporttest.cxx
+++ b/emfio/qa/cppunit/wmf/wmfimporttest.cxx
@@ -336,7 +336,7 @@ void WmfTest::testTdf99402()
logfontw.lfUnderline = 0;
logfontw.lfStrikeOut = 0;
logfontw.lfCharSet = emfio::CharacterSet::OEM_CHARSET;
logfontw.lfPitchAndFamily = +emfio::FamilyFont::FF_ROMAN | +emfio::PitchFont::DEFAULT_PITCH;
logfontw.lfPitchAndFamily = emfio::FamilyFont::FF_ROMAN << 4 | emfio::PitchFont::DEFAULT_PITCH;
logfontw.alfFaceName = "Symbol";
emfio::WinMtfFontStyle fontStyle(logfontw);
diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx
index b4973f6..f829788 100644
--- a/emfio/source/reader/mtftools.cxx
+++ b/emfio/source/reader/mtftools.cxx
@@ -179,7 +179,7 @@ namespace emfio
aFont.SetCharSet( eCharSet );
aFont.SetFamilyName( rFont.alfFaceName );
FontFamily eFamily;
switch ( rFont.lfPitchAndFamily & 0xf0 )
switch ( rFont.lfPitchAndFamily >> 4 & 0x0f )
{
case FamilyFont::FF_ROMAN:
eFamily = FAMILY_ROMAN;