diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2024-04-18 13:18:37 +0500 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2024-04-29 10:02:52 +0500 |
commit | c92e08d54033ffeb010c7460f1c25b31cb4c0f37 (patch) | |
tree | 9c55519b695801cf54479048779f9cda20bd9cf6 | |
parent | 9059240ea11f8c16c3fb9d40a85650d187ad19db (diff) |
Return double from OutputDevice::GetTextArray
And introduce GetTextWidth / GetTextHeight variants returning double.
It allows to avoid premature rounding.
At least in one case - testTdf145111_anchor_in_Fontwork - it allowed
to make the test DPI-independent (at least in my testing on Windows,
using 125, 150, and 175% UI scaling).
Change-Id: I973d2c729ec6bb7114b4f99b9027f1ead7c1d061
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166237
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r-- | drawinglayer/source/processor2d/vclprocessor2d.cxx | 4 | ||||
-rw-r--r-- | editeng/source/items/svxfont.cxx | 2 | ||||
-rw-r--r-- | emfio/qa/cppunit/emf/EmfImportTest.cxx | 2 | ||||
-rw-r--r-- | filter/source/svg/svgwriter.cxx | 2 | ||||
-rw-r--r-- | include/vcl/outdev.hxx | 9 | ||||
-rw-r--r-- | sc/qa/uitest/chart/chartLegend.py | 4 | ||||
-rw-r--r-- | sd/qa/unit/layout-tests.cxx | 4 | ||||
-rw-r--r-- | sd/qa/unit/tiledrendering/LOKitSearchTest.cxx | 6 | ||||
-rw-r--r-- | svx/qa/unit/customshapes.cxx | 10 | ||||
-rw-r--r-- | sw/qa/extras/layout/layout.cxx | 6 | ||||
-rw-r--r-- | toolkit/source/awt/vclxfont.cxx | 2 | ||||
-rw-r--r-- | vcl/qa/cppunit/complextext.cxx | 2 | ||||
-rw-r--r-- | vcl/source/filter/wmf/emfwr.cxx | 2 | ||||
-rw-r--r-- | vcl/source/filter/wmf/wmfwr.cxx | 2 | ||||
-rw-r--r-- | vcl/source/gdi/textlayout.cxx | 2 | ||||
-rw-r--r-- | vcl/source/outdev/map.cxx | 29 | ||||
-rw-r--r-- | vcl/source/outdev/text.cxx | 31 |
17 files changed, 79 insertions, 40 deletions
diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx index 13025b27d8a2..6a1073fa9d5b 100644 --- a/drawinglayer/source/processor2d/vclprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx @@ -340,8 +340,8 @@ void VclProcessor2D::RenderTextSimpleOrDecoratedPortionPrimitive2D( { tools::Long nWidthToFill = rTextCandidate.getWidthToFill(); - tools::Long nWidth - = mpOutputDevice->GetTextArray(rTextCandidate.getText(), &aDXArray, 0, 1); + tools::Long nWidth = basegfx::fround<tools::Long>( + mpOutputDevice->GetTextArray(rTextCandidate.getText(), &aDXArray, 0, 1)); sal_Int32 nChars = 2; if (nWidth) nChars = nWidthToFill / nWidth; diff --git a/editeng/source/items/svxfont.cxx b/editeng/source/items/svxfont.cxx index b484a645a7f6..306b378fc133 100644 --- a/editeng/source/items/svxfont.cxx +++ b/editeng/source/items/svxfont.cxx @@ -37,7 +37,7 @@ static tools::Long GetTextArray( const OutputDevice* pOut, const OUString& rStr, { const SalLayoutGlyphs* layoutGlyphs = SalLayoutGlyphsCache::self()->GetLayoutGlyphs(pOut, rStr, nIndex, nLen); - return pOut->GetTextArray( rStr, pDXAry, nIndex, nLen, true, nullptr, layoutGlyphs); + return basegfx::fround<tools::Long>(pOut->GetTextArray( rStr, pDXAry, nIndex, nLen, true, nullptr, layoutGlyphs)); } SvxFont::SvxFont() diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx index 1e03cc15dc20..627423117b37 100644 --- a/emfio/qa/cppunit/emf/EmfImportTest.cxx +++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx @@ -1343,7 +1343,7 @@ void Test::TestExtTextOutOpaqueAndClipWMF() assertXPath(pDocument, aXPathPrefix + "mask/group[3]/mask/group/polypolygoncolor", "color", "#ff8000"); assertXPath(pDocument, aXPathPrefix + "mask/group[3]/mask/group/polypolygoncolor/polypolygon", - "path", "m1067 1067h1270v473h-1270z"); + "path", "m1067 1067h1317v473h-1317z"); assertXPath(pDocument, aXPathPrefix + "mask/group[3]/mask/group/textsimpleportion", "text", "OOOO"); assertXPath(pDocument, aXPathPrefix + "mask/group[3]/mask/group/textsimpleportion", "fontcolor", diff --git a/filter/source/svg/svgwriter.cxx b/filter/source/svg/svgwriter.cxx index ff444a6ce284..aa83250f53b6 100644 --- a/filter/source/svg/svgwriter.cxx +++ b/filter/source/svg/svgwriter.cxx @@ -2690,7 +2690,7 @@ void SVGActionWriter::ImplWriteText( const Point& rPos, const OUString& rText, } else { - aNormSize = Size( mpVDev->GetTextArray( rText, &aTmpArray ), 0 ); + aNormSize = Size(basegfx::fround<tools::Long>(mpVDev->GetTextArray(rText, &aTmpArray)), 0); } // if text is rotated, set transform matrix at new g element diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index 8bcf883c8fc9..098a5ccc5ef0 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -1033,12 +1033,16 @@ public: tools::Long GetTextWidth( const OUString& rStr, sal_Int32 nIndex = 0, sal_Int32 nLen = -1, vcl::text::TextLayoutCache const* = nullptr, SalLayoutGlyphs const*const pLayoutCache = nullptr) const; + double GetTextWidthDouble(const OUString& rStr, sal_Int32 nIndex = 0, sal_Int32 nLen = -1, + vcl::text::TextLayoutCache const* = nullptr, + SalLayoutGlyphs const* const pLayoutCache = nullptr) const; /** Height where any character of the current font fits; in logic coordinates. See also GetTextBoundRect() for more explanation + code examples. */ tools::Long GetTextHeight() const; + double GetTextHeightDouble() const; float approximate_digit_width() const; void DrawTextArray( const Point& rStartPt, const OUString& rStr, @@ -1048,7 +1052,7 @@ public: sal_Int32 nLen, SalLayoutFlags flags = SalLayoutFlags::NONE, const SalLayoutGlyphs* pLayoutCache = nullptr); - tools::Long GetTextArray( const OUString& rStr, KernArray* pDXAry, + double GetTextArray( const OUString& rStr, KernArray* pDXAry, sal_Int32 nIndex = 0, sal_Int32 nLen = -1, bool bCaret = false, vcl::text::TextLayoutCache const* = nullptr, SalLayoutGlyphs const*const pLayoutCache = nullptr) const; @@ -1841,6 +1845,9 @@ private: */ SAL_DLLPRIVATE tools::Long ImplLogicYToDevicePixel( tools::Long nY ) const; + SAL_DLLPRIVATE double ImplDevicePixelToLogicWidthDouble(double nWidth) const; + SAL_DLLPRIVATE double ImplDevicePixelToLogicHeightDouble(double nHeight) const; + /** @name Native Widget Rendering functions These all just call through to the private mpGraphics functions of the same name. diff --git a/sc/qa/uitest/chart/chartLegend.py b/sc/qa/uitest/chart/chartLegend.py index 45938e23017d..fe0525a0746d 100644 --- a/sc/qa/uitest/chart/chartLegend.py +++ b/sc/qa/uitest/chart/chartLegend.py @@ -88,7 +88,7 @@ class chartLegend(UITestCase): xLegends.executeAction("SELECT", tuple()) with self.ui_test.execute_dialog_through_action(xLegends, "COMMAND", mkPropertyValues({"COMMAND": "TransformDialog"})) as xDialog: - self.assertEqual("4.61", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_X"))['Value']) + self.assertEqual("4.59", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_X"))['Value']) self.assertEqual("1.54", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_Y"))['Value']) xChartMain.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) @@ -96,7 +96,7 @@ class chartLegend(UITestCase): # Check the position has changed after moving the label using the arrows keys with self.ui_test.execute_dialog_through_action(xLegends, "COMMAND", mkPropertyValues({"COMMAND": "TransformDialog"})) as xDialog: - self.assertEqual("4.51", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_X"))['Value']) + self.assertEqual("4.49", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_X"))['Value']) self.assertEqual("1.44", get_state_as_dict(xDialog.getChild("MTR_FLD_POS_Y"))['Value']) def test_Tdf147394(self): diff --git a/sd/qa/unit/layout-tests.cxx b/sd/qa/unit/layout-tests.cxx index 1c4429f62aec..681f137f4dbb 100644 --- a/sd/qa/unit/layout-tests.cxx +++ b/sd/qa/unit/layout-tests.cxx @@ -103,7 +103,7 @@ CPPUNIT_TEST_FIXTURE(SdLayoutTest, testTdf128212) xmlDocUniquePtr pXmlDoc = load("pptx/tdf128212.pptx"); // Without the fix in place, this test would have failed with - // - Expected: 7793 + // - Expected: 7795 // - Actual : 12068 assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray", "x", "4525"); assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray", "y", "7797"); @@ -310,7 +310,7 @@ CPPUNIT_TEST_FIXTURE(SdLayoutTest, testFitToFrameTextFitting) assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray[1]", "y", "406"); assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray[1]/dxarray", "first", "114"); #ifndef _WIN32 // Windows seems to differ in text layouting, so ignore for now - assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray[1]/dxarray", "last", "7010"); + assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray[1]/dxarray", "last", "6984"); #endif } diff --git a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx index f3beb12b3ce1..1468f130cf11 100644 --- a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx +++ b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx @@ -655,8 +655,7 @@ void LOKitSearchTest::testSearchIn2MixedObjects() CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size()); CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size()); - CPPUNIT_ASSERT_EQUAL(OString("3546, 3174, 738, 402"), - mpCallbackRecorder->m_aSearchResultSelection[0]); + CPPUNIT_ASSERT_EQUAL("3545, 3174, 740, 402", mpCallbackRecorder->m_aSearchResultSelection[0]); // Search next @@ -681,8 +680,7 @@ void LOKitSearchTest::testSearchIn2MixedObjects() CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size()); CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size()); - CPPUNIT_ASSERT_EQUAL(OString("3546, 3174, 738, 402"), - mpCallbackRecorder->m_aSearchResultSelection[0]); + CPPUNIT_ASSERT_EQUAL("3545, 3174, 740, 402", mpCallbackRecorder->m_aSearchResultSelection[0]); } // Test searching in document with mixed objects. We have 6 objects. diff --git a/svx/qa/unit/customshapes.cxx b/svx/qa/unit/customshapes.cxx index efe322d54e76..86bae7d50447 100644 --- a/svx/qa/unit/customshapes.cxx +++ b/svx/qa/unit/customshapes.cxx @@ -406,10 +406,6 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf145111_Fontwork_rendering_font_siz CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf145111_anchor_in_Fontwork) { - // The tested positions depend on dpi. - if (!IsDefaultDPI()) - return; - // tdf#145004 In case ScaleX is true in property TextPath, SDRTEXTVERTADJUST is // evaluated and should shift the Fontwork text. That did not work for // 'Top-Left' and 'Bottom-Left'. @@ -423,8 +419,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf145111_anchor_in_Fontwork) SdrObjCustomShape& rSdrCustomShape( static_cast<SdrObjCustomShape&>(*SdrObject::getSdrObjectFromXShape(xShape))); - // Without the fix in place top was 2295, but should be 2916 for 96dpi. - // Was 2184, should be 2886 for 120dpi. + // Without the fix in place top was 2295, but should be 2900. tools::Rectangle aBoundRect(rSdrCustomShape.GetCurrentBoundRect()); CPPUNIT_ASSERT_DOUBLES_EQUAL(tools::Long(2916), aBoundRect.Top(), 5); } @@ -434,8 +429,7 @@ CPPUNIT_TEST_FIXTURE(CustomshapesTest, testTdf145111_anchor_in_Fontwork) SdrObjCustomShape& rSdrCustomShape( static_cast<SdrObjCustomShape&>(*SdrObject::getSdrObjectFromXShape(xShape))); - // Without the fix in place top was 10294, but should be 9519 for 96dpi. - // Was 10184, should be 9481 for 120dpi. + // Without the fix in place top was 10294, but should be 9500. tools::Rectangle aBoundRect(rSdrCustomShape.GetCurrentBoundRect()); CPPUNIT_ASSERT_DOUBLES_EQUAL(tools::Long(9519), aBoundRect.Top(), 5); } diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index 0ffdb543fbd9..65b31c5909c6 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -3673,7 +3673,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf106234) "type", "PortionType::Margin"); // This was a justified line, without width assertXPath(pXmlDoc, "/root/page/body/txt[2]/SwParaPortion/SwLineLayout[1]/SwGluePortion", - "width", "7881"); + "width", "7882"); } CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf120287b) @@ -3686,7 +3686,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf120287b) assertXPath( pXmlDoc, "/root/page/body/txt[1]/SwParaPortion/SwLineLayout/child::*[@type='PortionType::TabRight']", - "width", "17"); + "width", "19"); } CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf120287c) @@ -3819,7 +3819,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf122607) assertXPath(pXmlDoc, "/root/page[1]/anchored/fly/txt[1]/anchored/fly/tab/row[2]/cell/txt[7]/anchored/" "fly/txt/SwParaPortion/SwLineLayout/child::*[1]", - "width", "428"); + "width", "427"); assertXPath(pXmlDoc, "/root/page[1]/anchored/fly/txt[1]/anchored/fly/tab/row[2]/cell/txt[7]/anchored/" "fly/txt/SwParaPortion/SwLineLayout/child::*[1]", diff --git a/toolkit/source/awt/vclxfont.cxx b/toolkit/source/awt/vclxfont.cxx index 866a362e710f..f7338e79cfd0 100644 --- a/toolkit/source/awt/vclxfont.cxx +++ b/toolkit/source/awt/vclxfont.cxx @@ -156,7 +156,7 @@ sal_Int32 VCLXFont::getStringWidthArray( const OUString& str, css::uno::Sequence vcl::Font aOldFont = pOutDev->GetFont(); pOutDev->SetFont( maFont ); KernArray aDXA; - nRet = pOutDev->GetTextArray( str, &aDXA ); + nRet = basegfx::fround(pOutDev->GetTextArray(str, &aDXA)); rDXArray.realloc(aDXA.size()); sal_Int32* pArray = rDXArray.getArray(); for (size_t i = 0, nLen = aDXA.size(); i < nLen; ++i) diff --git a/vcl/qa/cppunit/complextext.cxx b/vcl/qa/cppunit/complextext.cxx index daf70a1c589d..cfe5d2213d7d 100644 --- a/vcl/qa/cppunit/complextext.cxx +++ b/vcl/qa/cppunit/complextext.cxx @@ -79,7 +79,7 @@ void VclComplexTextTest::testArabic() std::vector<sal_Int32> aRefCharWidths {6, 9, 16, 16, 22, 22, 26, 29, 32, 32, 36, 40, 49, 53, 56, 63, 63, 66, 72, 72}; KernArray aCharWidths; - tools::Long nTextWidth = pOutDev->GetTextArray(aOneTwoThree, &aCharWidths); + tools::Long nTextWidth = basegfx::fround<tools::Long>(pOutDev->GetTextArray(aOneTwoThree, &aCharWidths)); CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths.get_subunit_array()); // this sporadically returns 75 or 74 on some of the windows tinderboxes eg. tb73 diff --git a/vcl/source/filter/wmf/emfwr.cxx b/vcl/source/filter/wmf/emfwr.cxx index 45a1a7ce4e27..dfdc3156f838 100644 --- a/vcl/source/filter/wmf/emfwr.cxx +++ b/vcl/source/filter/wmf/emfwr.cxx @@ -880,7 +880,7 @@ void EMFWriter::ImplWriteTextRecord( const Point& rPos, const OUString& rText, K } else { - nNormWidth = maVDev->GetTextArray( rText, &aOwnArray ); + nNormWidth = basegfx::fround<sal_uInt32>(maVDev->GetTextArray(rText, &aOwnArray)); pDX = aOwnArray; } diff --git a/vcl/source/filter/wmf/wmfwr.cxx b/vcl/source/filter/wmf/wmfwr.cxx index 335773728b60..c35d7236c9d9 100644 --- a/vcl/source/filter/wmf/wmfwr.cxx +++ b/vcl/source/filter/wmf/wmfwr.cxx @@ -1198,7 +1198,7 @@ void WMFWriter::WriteRecords( const GDIMetaFile & rMTF ) pVirDev->SetFont( aSrcFont ); const sal_Int32 nLen = aTemp.getLength(); KernArray aDXAry; - const sal_Int32 nNormSize = pVirDev->GetTextArray( aTemp, nLen ? &aDXAry : nullptr ); + const sal_Int32 nNormSize = basegfx::fround(pVirDev->GetTextArray( aTemp, nLen ? &aDXAry : nullptr )); if (nLen && nNormSize == 0) { OSL_FAIL("Impossible div by 0 action: MetaStretchTextAction!"); diff --git a/vcl/source/gdi/textlayout.cxx b/vcl/source/gdi/textlayout.cxx index 0ee1c9ba5faf..ce681a2e9eea 100644 --- a/vcl/source/gdi/textlayout.cxx +++ b/vcl/source/gdi/textlayout.cxx @@ -166,7 +166,7 @@ namespace vcl return 0; // retrieve the character widths from the reference device - tools::Long nTextWidth = m_rReferenceDevice.GetTextArray( _rText, _pDXAry, _nStartIndex, _nLength ); + tools::Long nTextWidth = basegfx::fround<tools::Long>(m_rReferenceDevice.GetTextArray( _rText, _pDXAry, _nStartIndex, _nLength )); #if OSL_DEBUG_LEVEL > 1 if ( _pDXAry ) { diff --git a/vcl/source/outdev/map.cxx b/vcl/source/outdev/map.cxx index d7ddaf3ccd86..3359cc70c210 100644 --- a/vcl/source/outdev/map.cxx +++ b/vcl/source/outdev/map.cxx @@ -272,6 +272,19 @@ static tools::Long ImplPixelToLogic(tools::Long n, tools::Long nDPI, tools::Long return n; } +static double ImplPixelToLogicDouble(double n, tools::Long nDPI, tools::Long nMapNum, + tools::Long nMapDenom) +{ + assert(nDPI > 0); + if (nMapNum == 0) + return 0; + + n *= nMapDenom; + n /= nDPI; + n /= nMapNum; + return n; +} + tools::Long OutputDevice::ImplLogicXToDevicePixel( tools::Long nX ) const { if ( !mbMap ) @@ -314,6 +327,14 @@ tools::Long OutputDevice::ImplDevicePixelToLogicWidth( tools::Long nWidth ) cons return ImplPixelToLogic(nWidth, mnDPIX, maMapRes.mnMapScNumX, maMapRes.mnMapScDenomX); } +SAL_DLLPRIVATE double OutputDevice::ImplDevicePixelToLogicWidthDouble(double nWidth) const +{ + if (!mbMap) + return nWidth; + + return ImplPixelToLogicDouble(nWidth, mnDPIX, maMapRes.mnMapScNumX, maMapRes.mnMapScDenomX); +} + tools::Long OutputDevice::ImplDevicePixelToLogicHeight( tools::Long nHeight ) const { if ( !mbMap ) @@ -322,6 +343,14 @@ tools::Long OutputDevice::ImplDevicePixelToLogicHeight( tools::Long nHeight ) co return ImplPixelToLogic(nHeight, mnDPIY, maMapRes.mnMapScNumY, maMapRes.mnMapScDenomY); } +double OutputDevice::ImplDevicePixelToLogicHeightDouble(double nHeight) const +{ + if (!mbMap) + return nHeight; + + return ImplPixelToLogicDouble(nHeight, mnDPIY, maMapRes.mnMapScNumY, maMapRes.mnMapScDenomY); +} + Point OutputDevice::ImplLogicToDevicePixel( const Point& rLogicPt ) const { if ( !mbMap ) diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx index bbbb63f2326d..0ff3ac91f177 100644 --- a/vcl/source/outdev/text.cxx +++ b/vcl/source/outdev/text.cxx @@ -892,11 +892,15 @@ tools::Long OutputDevice::GetTextWidth( const OUString& rStr, sal_Int32 nIndex, vcl::text::TextLayoutCache const*const pLayoutCache, SalLayoutGlyphs const*const pSalLayoutCache) const { + double nWidth = GetTextWidthDouble(rStr, nIndex, nLen, pLayoutCache, pSalLayoutCache); + return basegfx::fround<tools::Long>(nWidth); +} - tools::Long nWidth = GetTextArray( rStr, nullptr, nIndex, - nLen, false, pLayoutCache, pSalLayoutCache ); - - return nWidth; +double OutputDevice::GetTextWidthDouble(const OUString& rStr, sal_Int32 nIndex, sal_Int32 nLen, + vcl::text::TextLayoutCache const* const pLayoutCache, + SalLayoutGlyphs const* const pSalLayoutCache) const +{ + return GetTextArray(rStr, nullptr, nIndex, nLen, false, pLayoutCache, pSalLayoutCache); } tools::Long OutputDevice::GetTextHeight() const @@ -912,6 +916,16 @@ tools::Long OutputDevice::GetTextHeight() const return nHeight; } +double OutputDevice::GetTextHeightDouble() const +{ + if (!InitFont()) + return 0; + + tools::Long nHeight = mpFontInstance->mnLineHeight + mnEmphasisAscent + mnEmphasisDescent; + + return ImplDevicePixelToLogicHeightDouble(nHeight); +} + float OutputDevice::approximate_char_width() const { //note pango uses "The quick brown fox jumps over the lazy dog." for english @@ -960,7 +974,7 @@ void OutputDevice::DrawTextArray( const Point& rStartPt, const OUString& rStr, mpAlphaVDev->DrawTextArray( rStartPt, rStr, pDXAry, pKashidaAry, nIndex, nLen, flags ); } -tools::Long OutputDevice::GetTextArray( const OUString& rStr, KernArray* pKernArray, +double OutputDevice::GetTextArray( const OUString& rStr, KernArray* pKernArray, sal_Int32 nIndex, sal_Int32 nLen, bool bCaret, vcl::text::TextLayoutCache const*const pLayoutCache, SalLayoutGlyphs const*const pSalLayoutCache) const @@ -1048,7 +1062,7 @@ tools::Long OutputDevice::GetTextArray( const OUString& rStr, KernArray* pKernAr if (mbMap) { for (int i = 0; i < nLen; ++i) - (*pDXAry)[i] = ImplDevicePixelToLogicWidth( (*pDXAry)[i] * nSubPixelFactor ); + (*pDXAry)[i] = ImplDevicePixelToLogicWidthDouble((*pDXAry)[i] * nSubPixelFactor); } else if (nSubPixelFactor) { @@ -1057,10 +1071,7 @@ tools::Long OutputDevice::GetTextArray( const OUString& rStr, KernArray* pKernAr } } - if (mbMap) - nWidth = ImplDevicePixelToLogicWidth( nWidth ); - - return basegfx::fround<tools::Long>(nWidth); + return ImplDevicePixelToLogicWidthDouble(nWidth); #endif /* VCL_FLOAT_DEVICE_PIXEL */ } |