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>
This commit is contained in:
@@ -1232,7 +1232,7 @@ public:
|
||||
const SalLayoutGlyphs* pGlyphs = nullptr) const;
|
||||
|
||||
SAL_DLLPRIVATE vcl::text::ImplLayoutArgs ImplPrepareLayoutArgs( OUString&, const sal_Int32 nIndex, const sal_Int32 nLen,
|
||||
DeviceCoordinate nPixelWidth,
|
||||
double nPixelWidth,
|
||||
SalLayoutFlags flags = SalLayoutFlags::NONE,
|
||||
vcl::text::TextLayoutCache const* = nullptr) const;
|
||||
SAL_DLLPRIVATE std::unique_ptr<SalLayout>
|
||||
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
// positioning related inputs
|
||||
const double* mpDXArray; // in floating point pixel units
|
||||
const sal_Bool* mpKashidaArray;
|
||||
DeviceCoordinate mnLayoutWidth; // in pixel units
|
||||
double mnLayoutWidth; // in pixel units
|
||||
Degree10 mnOrientation; // in 0-3600 system
|
||||
|
||||
// data for bidi and glyph+script fallback
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
ImplLayoutArgs(OUString const& rStr, int nMinCharPos, int nEndCharPos, SalLayoutFlags nFlags,
|
||||
LanguageTag aLanguageTag, vcl::text::TextLayoutCache const* pLayoutCache);
|
||||
|
||||
void SetLayoutWidth(DeviceCoordinate nWidth);
|
||||
void SetLayoutWidth(double nWidth);
|
||||
void SetDXArray(const double* pDXArray);
|
||||
void SetKashidaArray(const sal_Bool* pKashidaArray);
|
||||
void SetOrientation(Degree10 nOrientation);
|
||||
|
||||
@@ -141,7 +141,7 @@ private:
|
||||
GenericSalLayout& operator=( const GenericSalLayout& ) = delete;
|
||||
|
||||
void ApplyDXArray(const double*, const sal_Bool*);
|
||||
void Justify(DeviceCoordinate nNewWidth);
|
||||
void Justify(double nNewWidth);
|
||||
void ApplyAsianKerning(std::u16string_view rStr);
|
||||
|
||||
void GetCharWidths(std::vector<double>& rCharWidths,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 )
|
||||
|
||||
@@ -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; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user