starmath: Improve glyph positioning

Using twips everywhere and not rounding to pixels seems to improve
positioning (at least on hipdi displays). Hopefully the issue that
required rounding is no longer relevant.

Change-Id: I0ee4a4453b2a3d8e06be56d586761f7960a2d4d0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157044
Tested-by: Jenkins
Reviewed-by: خالد حسني <khaled@libreoffice.org>
This commit is contained in:
Khaled Hosny
2023-09-19 14:22:32 +02:00
committed by خالد حسني
parent 37f91706e6
commit 9e92a17cb6
3 changed files with 6 additions and 23 deletions
+4 -4
View File
@@ -22,7 +22,6 @@
#include <sal/config.h>
#include "smdllapi.hxx"
#include <comphelper/lok.hxx>
#include <o3tl/unit_conversion.hxx>
#include <sal/log.hxx>
#include <vcl/font.hxx>
@@ -117,14 +116,15 @@ public:
virtual void Insert(const vcl::Font &rFont) override;
};
// Math uses 100ths of MM by default, but lok needs twips everywhere
// Math used to use 100ths of MM by default, but now uses twips
// which seems to improve (subpixel) positioning.
inline MapUnit SmMapUnit()
{
return comphelper::LibreOfficeKit::isActive() ? MapUnit::MapTwip : MapUnit::Map100thMM;
return MapUnit::MapTwip;
}
inline o3tl::Length SmO3tlLengthUnit()
{
return comphelper::LibreOfficeKit::isActive() ? o3tl::Length::twip : o3tl::Length::mm100;
return o3tl::Length::twip;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+2 -2
View File
@@ -168,9 +168,9 @@ void Test::testTdf151842()
SmFormat aFormat = pDocShell->GetFormat();
// Without the fix in place, this test would have failed with
// - Expected: 4233
// - Expected: 2400
// - Actual : 423
CPPUNIT_ASSERT_EQUAL(tools::Long(4233), aFormat.GetBaseSize().Height());
CPPUNIT_ASSERT_EQUAL(tools::Long(2400), aFormat.GetBaseSize().Height());
}
void Test::testMathmlEntities()
-17
View File
@@ -441,13 +441,6 @@ void SmDrawingVisitor::Visit( SmRootSymbolNode* pNode )
if (mrFormat.IsRightToLeft() && mrDev.GetOutDevType() != OUTDEV_WINDOW)
mrDev.ReMirror(aBar);
//! avoid GROWING AND SHRINKING of drawn rectangle when constantly
//! increasing zoomfactor.
// This is done by shifting its output-position to a point that
// corresponds exactly to a pixel on the output device.
Point aDrawPos( mrDev.PixelToLogic( mrDev.LogicToPixel( aBar.TopLeft( ) ) ) );
aBar.SetPos( aDrawPos );
mrDev.DrawRect( aBar );
}
@@ -500,13 +493,6 @@ void SmDrawingVisitor::Visit( SmRectangleNode* pNode )
if (mrFormat.IsRightToLeft() && mrDev.GetOutDevType() != OUTDEV_WINDOW)
mrDev.ReMirror(aTmp);
//! avoid GROWING AND SHRINKING of drawn rectangle when constantly
//! increasing zoomfactor.
// This is done by shifting its output-position to a point that
// corresponds exactly to a pixel on the output device.
Point aPos ( mrDev.PixelToLogic( mrDev.LogicToPixel( aTmp.TopLeft( ) ) ) );
aTmp.SetPos( aPos );
mrDev.DrawRect( aTmp );
}
@@ -524,9 +510,6 @@ void SmDrawingVisitor::DrawTextNode( SmTextNode* pNode )
if (mrFormat.IsRightToLeft() && mrDev.GetOutDevType() != OUTDEV_WINDOW)
mrDev.ReMirror(aPos);
// round to pixel coordinate
aPos = mrDev.PixelToLogic( mrDev.LogicToPixel( aPos ) );
mrDev.DrawStretchText( aPos, pNode->GetWidth( ), pNode->GetText( ) );
}