summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorKhaled Hosny <khaled@libreoffice.org>2023-07-16 21:11:40 +0300
committerخالد حسني <khaled@libreoffice.org>2023-07-23 06:01:23 +0200
commit172b500ccbc8dac0496cc2936a9bcca793c0b594 (patch)
tree10efe535c08c6575b3a6d17c365d6be1b0d8a6d2 /vcl/source
parent507a8745870e9a755be3a72f59c6e9a9d811fdcf (diff)
vcl: Use more doubles for text measurements
Change-Id: I5695d9ab51eb09929b4c290ceaf7ae2be46f5989 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154504 Tested-by: Jenkins Reviewed-by: خالد حسني <khaled@libreoffice.org>
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/gdi/sallayout.cxx30
-rw-r--r--vcl/source/outdev/text.cxx10
-rw-r--r--vcl/source/text/ImplLayoutArgs.cxx2
3 files changed, 21 insertions, 21 deletions
diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index da70859f4c53..ba2f1e050dca 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -276,9 +276,9 @@ double GenericSalLayout::GetTextWidth() const
return nWidth;
}
-void GenericSalLayout::Justify( DeviceCoordinate nNewWidth )
+void GenericSalLayout::Justify(double nNewWidth)
{
- DeviceCoordinate nOldWidth = GetTextWidth();
+ double nOldWidth = GetTextWidth();
if( !nOldWidth || nNewWidth==nOldWidth )
return;
@@ -292,7 +292,7 @@ void GenericSalLayout::Justify( DeviceCoordinate nNewWidth )
std::vector<GlyphItem>::iterator pGlyphIter;
// count stretchable glyphs
int nStretchable = 0;
- int nMaxGlyphWidth = 0;
+ double nMaxGlyphWidth = 0;
for(pGlyphIter = m_GlyphItems.begin(); pGlyphIter != pGlyphIterRight; ++pGlyphIter)
{
if( !pGlyphIter->IsInCluster() )
@@ -311,7 +311,7 @@ void GenericSalLayout::Justify( DeviceCoordinate nNewWidth )
pGlyphIterRight->setLinearPosX( nNewWidth );
// justify glyph widths and positions
- int nDiffWidth = nNewWidth - nOldWidth;
+ double nDiffWidth = nNewWidth - nOldWidth;
if( nDiffWidth >= 0) // expanded case
{
// expand width by distributing space between glyphs evenly
@@ -326,7 +326,7 @@ void GenericSalLayout::Justify( DeviceCoordinate nNewWidth )
continue;
// distribute extra space equally to stretchable glyphs
- int nDeltaWidth = nDiffWidth / nStretchable--;
+ double nDeltaWidth = nDiffWidth / nStretchable--;
nDiffWidth -= nDeltaWidth;
pGlyphIter->addNewWidth(nDeltaWidth);
nDeltaSum += nDeltaWidth;
@@ -335,13 +335,13 @@ void GenericSalLayout::Justify( DeviceCoordinate nNewWidth )
else // condensed case
{
// squeeze width by moving glyphs proportionally
- double fSqueeze = static_cast<double>(nNewWidth) / nOldWidth;
+ double fSqueeze = nNewWidth / nOldWidth;
if(m_GlyphItems.size() > 1)
{
for( pGlyphIter = m_GlyphItems.begin(); ++pGlyphIter != pGlyphIterRight;)
{
- int nX = pGlyphIter->linearPos().getX();
- nX = static_cast<int>(nX * fSqueeze);
+ double nX = pGlyphIter->linearPos().getX();
+ nX = nX * fSqueeze;
pGlyphIter->setLinearPosX( nX );
}
}
@@ -423,7 +423,7 @@ void GenericSalLayout::ApplyAsianKerning(std::u16string_view rStr)
continue;
// apply punctuation compression to logical glyph widths
- DeviceCoordinate nDelta = (nKernCurrent < nKernNext) ? nKernCurrent : nKernNext;
+ double nDelta = (nKernCurrent < nKernNext) ? nKernCurrent : nKernNext;
if (nDelta < 0)
{
nDelta = (nDelta * pGlyphIter->origWidth() + 2) / 4;
@@ -640,7 +640,7 @@ void MultiSalLayout::AdjustLayout( vcl::text::ImplLayoutArgs& rArgs )
{
// for stretched text in a MultiSalLayout the target width needs to be
// distributed by individually adjusting its virtual character widths
- DeviceCoordinate nTargetWidth = aMultiArgs.mnLayoutWidth;
+ double nTargetWidth = aMultiArgs.mnLayoutWidth;
aMultiArgs.mnLayoutWidth = 0;
// we need to get the original unmodified layouts ready
@@ -652,7 +652,7 @@ void MultiSalLayout::AdjustLayout( vcl::text::ImplLayoutArgs& rArgs )
// #i17359# multilayout is not simplified yet, so calculating the
// unjustified width needs handholding; also count the number of
// stretchable virtual char widths
- DeviceCoordinate nOrigWidth = 0;
+ double nOrigWidth = 0;
int nStretchable = 0;
for( int i = 0; i < nCharCount; ++i )
{
@@ -665,14 +665,14 @@ void MultiSalLayout::AdjustLayout( vcl::text::ImplLayoutArgs& rArgs )
// now we are able to distribute the extra width over the virtual char widths
if( nOrigWidth && (nTargetWidth != nOrigWidth) )
{
- DeviceCoordinate nDiffWidth = nTargetWidth - nOrigWidth;
- DeviceCoordinate nWidthSum = 0;
+ double nDiffWidth = nTargetWidth - nOrigWidth;
+ double nWidthSum = 0;
for( int i = 0; i < nCharCount; ++i )
{
- DeviceCoordinate nJustWidth = aJustificationArray[i];
+ double nJustWidth = aJustificationArray[i];
if( (nJustWidth > 0) && (nStretchable > 0) )
{
- DeviceCoordinate nDeltaWidth = nDiffWidth / nStretchable;
+ double nDeltaWidth = nDiffWidth / nStretchable;
nJustWidth += nDeltaWidth;
nDiffWidth -= nDeltaWidth;
--nStretchable;
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index 81f4aa095840..6e35beccfec0 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -1115,7 +1115,7 @@ void OutputDevice::DrawStretchText( const Point& rStartPt, sal_Int32 nWidth,
vcl::text::ImplLayoutArgs OutputDevice::ImplPrepareLayoutArgs( OUString& rStr,
const sal_Int32 nMinIndex, const sal_Int32 nLen,
- DeviceCoordinate nPixelWidth,
+ double nPixelWidth,
SalLayoutFlags nLayoutFlags,
vcl::text::TextLayoutCache const*const pLayoutCache) const
{
@@ -1328,17 +1328,17 @@ std::unique_ptr<SalLayout> OutputDevice::ImplLayout(const OUString& rOrigStr,
pGlyphs = nullptr;
}
- DeviceCoordinate nPixelWidth = static_cast<DeviceCoordinate>(nLogicalWidth);
+ double nPixelWidth = nLogicalWidth;
if( nLogicalWidth && mbMap )
{
// convert from logical units to physical units
- nPixelWidth = LogicWidthToDeviceCoordinate( nLogicalWidth );
+ nPixelWidth = ImplLogicWidthToDeviceSubPixel(nLogicalWidth);
}
vcl::text::ImplLayoutArgs aLayoutArgs = ImplPrepareLayoutArgs( aStr, nMinIndex, nLen,
nPixelWidth, flags, pLayoutCache);
- DeviceCoordinate nEndGlyphCoord(0);
+ double nEndGlyphCoord(0);
std::unique_ptr<double[]> xDXPixelArray;
if( !pDXArray.empty() )
{
@@ -1405,7 +1405,7 @@ std::unique_ptr<SalLayout> OutputDevice::ImplLayout(const OUString& rOrigStr,
// adjust to right alignment if necessary
if( aLayoutArgs.mnFlags & SalLayoutFlags::RightAlign )
{
- DeviceCoordinate nRTLOffset;
+ double nRTLOffset;
if (!pDXArray.empty())
nRTLOffset = nEndGlyphCoord;
else if( nPixelWidth )
diff --git a/vcl/source/text/ImplLayoutArgs.cxx b/vcl/source/text/ImplLayoutArgs.cxx
index 80aec6b5f42c..826d288bba6f 100644
--- a/vcl/source/text/ImplLayoutArgs.cxx
+++ b/vcl/source/text/ImplLayoutArgs.cxx
@@ -88,7 +88,7 @@ ImplLayoutArgs::ImplLayoutArgs(const OUString& rStr, int nMinCharPos, int nEndCh
maRuns.ResetPos();
}
-void ImplLayoutArgs::SetLayoutWidth(DeviceCoordinate nWidth) { mnLayoutWidth = nWidth; }
+void ImplLayoutArgs::SetLayoutWidth(double nWidth) { mnLayoutWidth = nWidth; }
void ImplLayoutArgs::SetDXArray(double const* pDXArray) { mpDXArray = pDXArray; }