diff options
author | Khaled Hosny <khaled@libreoffice.org> | 2023-05-31 17:37:27 +0300 |
---|---|---|
committer | خالد حسني <khaled@libreoffice.org> | 2023-06-01 07:09:45 +0200 |
commit | 99d22fd79c5532fd6c1b167996e1c27216b92469 (patch) | |
tree | 1a521f04e5c7fe12ffa9658ec854fd99764311ff /sw/source | |
parent | 70fd835b4cf75e386ee115c705241a4059fb68a8 (diff) |
tdf#155557: Fix drawing mixed direction underlined text
The code here first unsets the underline style, draws the text, then
measures the text size, change the text to two blank spaces, sets the
measured width back and tries to guess how much space was added by
justification, sets the underline style back and then draws again.
I have no idea why it is doing it in this highly convoluted way, but
this code goes all way back to the initial import. However, it currently
fails to account for Arabic justification when the Arabic text does not
have any space characters.
Instead of trying to guess more how much width the Arabic justification
adds, I’m removing this code altogether to let the normal drawing code
handle the underline drawing.
Lets see what will break.
Update text expectation because we now do one-less drawing.
Change-Id: I8158bd15370005a78b866c8192414e4b46af2727
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152452
Tested-by: Jenkins
Reviewed-by: خالد حسني <khaled@libreoffice.org>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/txtnode/swfont.cxx | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/sw/source/core/txtnode/swfont.cxx b/sw/source/core/txtnode/swfont.cxx index c0149d9a6573..a4ac4f675aea 100644 --- a/sw/source/core/txtnode/swfont.cxx +++ b/sw/source/core/txtnode/swfont.cxx @@ -1099,16 +1099,6 @@ void SwSubFont::DrawText_( SwDrawTextInfo &rInf, const bool bGrey ) if (TextFrameIndex(COMPLETE_STRING) == rInf.GetLen()) rInf.SetLen( nLn ); - FontLineStyle nOldUnder = LINESTYLE_NONE; - SwUnderlineFont* pUnderFnt = nullptr; - - if( rInf.GetUnderFnt() ) - { - nOldUnder = GetUnderline(); - SetUnderline( LINESTYLE_NONE ); - pUnderFnt = rInf.GetUnderFnt(); - } - if( !pLastFont || pLastFont->GetOwner() != m_nFontCacheId ) ChgFnt( rInf.GetShell(), rInf.GetOut() ); @@ -1165,57 +1155,6 @@ void SwSubFont::DrawText_( SwDrawTextInfo &rInf, const bool bGrey ) } } - if( pUnderFnt && nOldUnder != LINESTYLE_NONE ) - { - Size aFontSize = GetTextSize_( rInf ); - const OUString oldStr = rInf.GetText(); - - TextFrameIndex const nOldIdx = rInf.GetIdx(); - TextFrameIndex const nOldLen = rInf.GetLen(); - tools::Long nSpace = 0; - if( rInf.GetSpace() ) - { - TextFrameIndex nTmpEnd = nOldIdx + nOldLen; - if (nTmpEnd > TextFrameIndex(oldStr.getLength())) - nTmpEnd = TextFrameIndex(oldStr.getLength()); - - const SwScriptInfo* pSI = rInf.GetScriptInfo(); - - const bool bAsianFont = - ( rInf.GetFont() && SwFontScript::CJK == rInf.GetFont()->GetActual() ); - for (TextFrameIndex nTmp = nOldIdx; nTmp < nTmpEnd; ++nTmp) - { - if (CH_BLANK == oldStr[sal_Int32(nTmp)] || bAsianFont || - (nTmp + TextFrameIndex(1) < TextFrameIndex(oldStr.getLength()) - && pSI - && i18n::ScriptType::ASIAN == pSI->ScriptType(nTmp + TextFrameIndex(1)))) - { - ++nSpace; - } - } - - // if next portion if a hole portion we do not consider any - // extra space added because the last character was ASIAN - if ( nSpace && rInf.IsSpaceStop() && bAsianFont ) - --nSpace; - - nSpace *= rInf.GetSpace() / SPACING_PRECISION_FACTOR; - } - - rInf.SetWidth( sal_uInt16(aFontSize.Width() + nSpace) ); - rInf.SetTextIdxLen( " ", TextFrameIndex(0), TextFrameIndex(2) ); - SetUnderline( nOldUnder ); - rInf.SetUnderFnt( nullptr ); - - // set position for underline font - rInf.SetPos( pUnderFnt->GetPos() ); - - pUnderFnt->GetFont().DrawStretchText_( rInf ); - - rInf.SetUnderFnt( pUnderFnt ); - rInf.SetTextIdxLen(oldStr, nOldIdx, nOldLen); - } - rInf.SetPos(aOldPos); } |