summaryrefslogtreecommitdiff
path: root/vcl/source/outdev
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2017-12-26 15:58:21 +0100
committerKhaled Hosny <khaledhosny@eglug.org>2018-05-07 23:03:37 +0200
commit083b7ca26bbf4b9bad2922520caaf5c0227dac5e (patch)
treeb33576cd90c64cb2ede5ab1a930b11828f110105 /vcl/source/outdev
parent1ca1886d46f38a0759ab466e6a4a8c3c0866c523 (diff)
Move PhysicalFontFace member of FontSelectPattern
A FontSelectPattern describes a general font request. It can be used to find the best matching LogicalFontInstance. The instance will be created based on a PhysicalFontFace, which is really a factory since commit 8b700794b2746070814e9ff416ecd7bbb1c902e7. Following this workflow, this moves the PhysicalFontFace pointer to the instance and makes it constant. Which leaves some special symbol font handling code in the hash and instance lookup code path. It used to query the font face directly from the instance. I'm not sure of the correct handling. The related commits where made to fix #i89002#, which has an attached test document. 1. commit 849f618270da313f9339dda29a9f35938434c91d 2. commit 8c9823d311fdf8092cc75873e4565325d204a658 The document is as broken as it was before the patch. The symbol substitution still works, but the 'Q's are missing when displaying a symbol font. I also don't understand all the reinterpret_casts for fake font ids. I guess this was used to prevent the crashes I see, where a PhysicalFontFace referenced in a valid LogicalFontInstance is freed and a later FontId check in the GlyphCache crashes. So this now checks for a valid cache instead. Change-Id: If8ee5a6288e66cfa4c419289fbdd5b5da128c6ea Reviewed-on: https://gerrit.libreoffice.org/47279 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Khaled Hosny <khaledhosny@eglug.org>
Diffstat (limited to 'vcl/source/outdev')
-rw-r--r--vcl/source/outdev/font.cxx26
-rw-r--r--vcl/source/outdev/text.cxx5
2 files changed, 15 insertions, 16 deletions
diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx
index 25f3feec001f..c65dd0d5cce9 100644
--- a/vcl/source/outdev/font.cxx
+++ b/vcl/source/outdev/font.cxx
@@ -887,10 +887,8 @@ vcl::Font OutputDevice::GetDefaultFont( DefaultFontType nType, LanguageType eLan
LogicalFontInstance* pFontInstance = pOutDev->mpFontCache->GetFontInstance( pOutDev->mpFontCollection, aFont, aSize, fExactHeight );
if (pFontInstance)
{
- if( pFontInstance->maFontSelData.mpFontData )
- aFont.SetFamilyName( pFontInstance->maFontSelData.mpFontData->GetFamilyName() );
- else
- aFont.SetFamilyName( pFontInstance->maFontSelData.maTargetName );
+ assert(pFontInstance->GetFontFace());
+ aFont.SetFamilyName(pFontInstance->GetFontFace()->GetFamilyName());
pFontInstance->Release();
}
}
@@ -977,16 +975,17 @@ void OutputDevice::InitFont() const
{
// decide if antialiasing is appropriate
bool bNonAntialiased(GetAntialiasing() & AntialiasingFlags::DisableText);
+ FontSelectPattern aPattern(mpFontInstance->GetFontSelectPattern());
if (!utl::ConfigManager::IsFuzzing())
{
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
bNonAntialiased |= bool(rStyleSettings.GetDisplayOptions() & DisplayOptions::AADisable);
- bNonAntialiased |= (int(rStyleSettings.GetAntialiasingMinPixelHeight()) > mpFontInstance->maFontSelData.mnHeight);
+ bNonAntialiased |= (int(rStyleSettings.GetAntialiasingMinPixelHeight()) > aPattern.mnHeight);
}
- mpFontInstance->maFontSelData.mbNonAntialiased = bNonAntialiased;
+ aPattern.mbNonAntialiased = bNonAntialiased;
// select font in the device layers
- mpGraphics->SetFont( &(mpFontInstance->maFontSelData), 0 );
+ mpGraphics->SetFont(&aPattern, 0);
mbInitFont = false;
}
}
@@ -1063,7 +1062,7 @@ bool OutputDevice::ImplNewFont() const
{
pFontInstance->mbInit = true;
- pFontInstance->mxFontMetric->SetOrientation( sal::static_int_cast<short>(pFontInstance->maFontSelData.mnOrientation) );
+ pFontInstance->mxFontMetric->SetOrientation( sal::static_int_cast<short>(mpFontInstance->GetFontSelectPattern().mnOrientation) );
pGraphics->GetFontMetric( pFontInstance->mxFontMetric, 0 );
pFontInstance->mxFontMetric->ImplInitTextLineSize( this );
@@ -1150,9 +1149,9 @@ bool OutputDevice::ImplNewFont() const
void OutputDevice::SetFontOrientation( LogicalFontInstance* const pFontInstance ) const
{
- if( pFontInstance->maFontSelData.mnOrientation && !pFontInstance->mxFontMetric->GetOrientation() )
+ if( pFontInstance->GetFontSelectPattern().mnOrientation && !pFontInstance->mxFontMetric->GetOrientation() )
{
- pFontInstance->mnOwnOrientation = sal::static_int_cast<short>(pFontInstance->maFontSelData.mnOrientation);
+ pFontInstance->mnOwnOrientation = sal::static_int_cast<short>(pFontInstance->GetFontSelectPattern().mnOrientation);
pFontInstance->mnOrientation = pFontInstance->mnOwnOrientation;
}
else
@@ -1341,7 +1340,7 @@ std::unique_ptr<SalLayout> OutputDevice::ImplGlyphFallbackLayout( std::unique_pt
rLayoutArgs.ResetPos();
OUString aMissingCodes = aMissingCodeBuf.makeStringAndClear();
- FontSelectPattern aFontSelData = mpFontInstance->maFontSelData;
+ FontSelectPattern aFontSelData(mpFontInstance->GetFontSelectPattern());
// try if fallback fonts support the missing code units
for( int nFallbackLevel = 1; nFallbackLevel < MAX_FALLBACK; ++nFallbackLevel )
@@ -1357,13 +1356,12 @@ std::unique_ptr<SalLayout> OutputDevice::ImplGlyphFallbackLayout( std::unique_pt
break;
aFontSelData.mpFontInstance = pFallbackFont;
- aFontSelData.mpFontData = pFallbackFont->maFontSelData.mpFontData;
if( nFallbackLevel < MAX_FALLBACK-1)
{
// ignore fallback font if it is the same as the original font
// unless we are looking for a substitution for 0x202F, in which
// case we'll just use a normal space
- if( mpFontInstance->maFontSelData.mpFontData == aFontSelData.mpFontData &&
+ if( mpFontInstance->GetFontFace() == pFallbackFont->GetFontFace() &&
aMissingCodes.indexOf(0x202F) == -1 )
{
pFallbackFont->Release();
@@ -1379,7 +1377,7 @@ std::unique_ptr<SalLayout> OutputDevice::ImplGlyphFallbackLayout( std::unique_pt
if( !pMultiSalLayout )
pMultiSalLayout.reset( new MultiSalLayout( std::move(pSalLayout) ) );
pMultiSalLayout->AddFallback( std::move(pFallback),
- rLayoutArgs.maRuns, aFontSelData.mpFontData );
+ rLayoutArgs.maRuns, aFontSelData.mpFontInstance->GetFontFace() );
if (nFallbackLevel == MAX_FALLBACK-1)
pMultiSalLayout->SetIncomplete(true);
}
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index d794feb5ec42..1d115dc56397 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -217,9 +217,10 @@ bool OutputDevice::ImplDrawRotateText( SalLayout& rSalLayout )
if( !pVDev->SetOutputSizePixel( aBoundRect.GetSize() ) )
return false;
+ const FontSelectPattern& rPattern = mpFontInstance->GetFontSelectPattern();
vcl::Font aFont( GetFont() );
aFont.SetOrientation( 0 );
- aFont.SetFontSize( Size( mpFontInstance->maFontSelData.mnWidth, mpFontInstance->maFontSelData.mnHeight ) );
+ aFont.SetFontSize( Size( rPattern.mnWidth, rPattern.mnHeight ) );
pVDev->SetFont( aFont );
pVDev->SetTextColor( COL_BLACK );
pVDev->SetTextFillColor();
@@ -1358,7 +1359,7 @@ std::unique_ptr<SalLayout> OutputDevice::ImplLayout(const OUString& rOrigStr,
// do glyph fallback if needed
// #105768# avoid fallback for very small font sizes
- if (aLayoutArgs.NeedFallback() && mpFontInstance->maFontSelData.mnHeight >= 3)
+ if (aLayoutArgs.NeedFallback() && mpFontInstance->GetFontSelectPattern().mnHeight >= 3)
pSalLayout = ImplGlyphFallbackLayout(std::move(pSalLayout), aLayoutArgs);
// position, justify, etc. the layout