diff --git a/model/ModelTextObject.cpp b/model/ModelTextObject.cpp index 9a6779b..29d0a0d 100644 --- a/model/ModelTextObject.cpp +++ b/model/ModelTextObject.cpp @@ -42,13 +42,16 @@ namespace /// /// Calculate pixel size /// - /// Assume a virtual DPI of 96 pixels/inch for all QPainter contexts. + /// Assume a virtual DPI of 72 pixels/inch for all QPainter contexts. /// Ideally, we should use pointSizes for device independence, but as - /// Qt-6.4 on X11, Wayland, and MacOS this approach has better results. + /// of Qt-6.4, the xcb (X11) and Wayland backends will render the same + /// font differently. Currently this function is basically the unity + /// function (i.e. 1 pt = 1 pixel) with rounding, but is a placeholder + /// that may need to be tweaked for different backends. /// int pixelSize( double pointSize ) { - const double virtual_dpi = 96; + const double virtual_dpi = 72; return qMax( 1, qRound( pointSize * virtual_dpi/72.0 ) ); } } diff --git a/model/XmlLabelParser_3.cpp b/model/XmlLabelParser_3.cpp index 4a70218..b1fb325 100644 --- a/model/XmlLabelParser_3.cpp +++ b/model/XmlLabelParser_3.cpp @@ -53,8 +53,6 @@ namespace using namespace glabels::model; const uint32_t GDK_PIXBUF_MAGIC_NUMBER {0x47646b50}; - - const double FONT_SCALE_FACTOR {0.75}; // In glabels-3, fonts were rendered at 75% of specified fontsize const Distance MARGIN_OFFSET { Distance::pt(3) }; // In glabels-3, margin was not accounted for in text baseline calculations typedef enum @@ -557,7 +555,7 @@ namespace glabels::model /* font attrs */ fontFamily = XmlUtil::getStringAttr( element, "font_family", "Sans" ); - fontSize = XmlUtil::getDoubleAttr( element, "font_size", 10 ) * FONT_SCALE_FACTOR; + fontSize = XmlUtil::getDoubleAttr( element, "font_size", 10 ); fontWeight = getWeightAttr( element, "font_weight", QFont::Normal ); fontItalicFlag = XmlUtil::getBoolAttr( element, "font_italic", false ); diff --git a/model/unit_tests/TestXmlLabel.cpp b/model/unit_tests/TestXmlLabel.cpp index e60a162..c925151 100644 --- a/model/unit_tests/TestXmlLabel.cpp +++ b/model/unit_tests/TestXmlLabel.cpp @@ -60,12 +60,6 @@ using namespace glabels::barcode; using namespace glabels::merge; -namespace -{ - const double FONT_SCALE_FACTOR {0.75}; -} - - void TestXmlLabel::initTestCase() { QCoreApplication::setOrganizationName( glabels::model::Version::ORGANIZATION_NAME ); @@ -548,7 +542,7 @@ void TestXmlLabel::parser_3ReadFile() QCOMPARE( modelTextObject0->shadow(), false ); QCOMPARE( modelTextObject0->text(), QString( "Hello, my name is" ) ); QCOMPARE( modelTextObject0->fontFamily(), QString( "Sans" ) ); - QCOMPARE( modelTextObject0->fontSize(), 16 * FONT_SCALE_FACTOR ); + QCOMPARE( modelTextObject0->fontSize(), 16 ); QCOMPARE( modelTextObject0->fontWeight(), QFont::Bold ); QCOMPARE( modelTextObject0->fontItalicFlag(), false ); QCOMPARE( modelTextObject0->textLineSpacing(), 1.0 ); @@ -566,7 +560,7 @@ void TestXmlLabel::parser_3ReadFile() QCOMPARE( modelTextObject1->shadow(), false ); QCOMPARE( modelTextObject1->text(), QString( "${Name}" ) ); QCOMPARE( modelTextObject1->fontFamily(), QString( "Sans" ) ); - QCOMPARE( modelTextObject1->fontSize(), 20 * FONT_SCALE_FACTOR ); + QCOMPARE( modelTextObject1->fontSize(), 20 ); QCOMPARE( modelTextObject1->fontWeight(), QFont::Normal ); QCOMPARE( modelTextObject1->fontItalicFlag(), false ); QCOMPARE( modelTextObject1->textLineSpacing(), 1.0 ); @@ -584,7 +578,7 @@ void TestXmlLabel::parser_3ReadFile() QCOMPARE( modelTextObject2->shadow(), false ); QCOMPARE( modelTextObject2->text(), QString( "Department: ${Department}" ) ); QCOMPARE( modelTextObject2->fontFamily(), QString( "Sans" ) ); - QCOMPARE( modelTextObject2->fontSize(), 11 * FONT_SCALE_FACTOR ); + QCOMPARE( modelTextObject2->fontSize(), 11 ); QCOMPARE( modelTextObject2->fontWeight(), QFont::Normal ); QCOMPARE( modelTextObject2->fontItalicFlag(), false ); QCOMPARE( modelTextObject2->textLineSpacing(), 1.0 ); diff --git a/test-data/simple-text-liberation-sans.pdf b/test-data/simple-text-liberation-sans.pdf index c99461f..3e3f06c 100644 Binary files a/test-data/simple-text-liberation-sans.pdf and b/test-data/simple-text-liberation-sans.pdf differ diff --git a/test-data/simple-text-liberation-serif.pdf b/test-data/simple-text-liberation-serif.pdf index 40ac2ad..08a5df7 100644 Binary files a/test-data/simple-text-liberation-serif.pdf and b/test-data/simple-text-liberation-serif.pdf differ