summaryrefslogtreecommitdiff
path: root/emfio
diff options
context:
space:
mode:
authorHossein <hossein@libreoffice.org>2022-04-06 04:41:07 +0200
committerStephan Bergmann <sbergman@redhat.com>2022-04-06 10:52:50 +0200
commit51431559bda9a81293d502328982452caeeba6c6 (patch)
tree34571c0972862cd5dbd2bec5f06edbb8c74d2c62 /emfio
parentcedf0b23542a06cd31440dd1deb450d03191a1b9 (diff)
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>
Diffstat (limited to 'emfio')
-rw-r--r--emfio/inc/mtftools.hxx2
-rw-r--r--emfio/qa/cppunit/wmf/wmfimporttest.cxx2
-rw-r--r--emfio/source/reader/mtftools.cxx2
3 files changed, 3 insertions, 3 deletions
diff --git a/emfio/inc/mtftools.hxx b/emfio/inc/mtftools.hxx
index cb6e1c7ff243..0290c487c574 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 1ae7416521aa..b8c2218fdec2 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 b4973f6e51ab..f829788dbd1b 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;