diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2022-05-16 13:11:17 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2022-05-16 21:14:47 +0200 |
commit | be441f1a8c40ecbd99653043aa443fc1130d91c2 (patch) | |
tree | f61a086feebb4b9e1f17480249175e972576e93d /vcl/source | |
parent | Fix a UITest on Windows (diff) | |
download | core-be441f1a8c40ecbd99653043aa443fc1130d91c2.tar.gz core-be441f1a8c40ecbd99653043aa443fc1130d91c2.zip |
use FontMetric as SalLayoutGlyphsCache key rather than vcl::Font
Apparently even calling OutputDevice::GetFontMetric() rather than
GetFont() makes a difference with e.g. tdf#65046-1, when only
vcl::Font is used it triggers the assert in checkGlyphsEqual()
because of the fonts actually being different.
Change-Id: I2a2aba6bf6d4bf78b7449ccdb16be0746663ee87
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134401
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/font/fontmetric.cxx | 44 | ||||
-rw-r--r-- | vcl/source/gdi/impglyphitem.cxx | 6 |
2 files changed, 44 insertions, 6 deletions
diff --git a/vcl/source/font/fontmetric.cxx b/vcl/source/font/fontmetric.cxx index dfc005b6a9d6..1fddb1195ab7 100644 --- a/vcl/source/font/fontmetric.cxx +++ b/vcl/source/font/fontmetric.cxx @@ -78,10 +78,8 @@ FontMetric& FontMetric::operator=(const FontMetric& rFontMetric) = default; FontMetric& FontMetric::operator=(FontMetric&& rFontMetric) = default; -bool FontMetric::operator==( const FontMetric& r ) const +bool FontMetric::EqualNoBase( const FontMetric& r ) const { - if( Font::operator!=(r) ) - return false; if (mbFullstopCentered != r.mbFullstopCentered) return false; if( mnAscent != r.mnAscent ) @@ -98,6 +96,46 @@ bool FontMetric::operator==( const FontMetric& r ) const return true; } +bool FontMetric::operator==( const FontMetric& r ) const +{ + if( Font::operator!=(r) ) + return false; + return EqualNoBase(r); +} + +bool FontMetric::EqualIgnoreColor( const FontMetric& r ) const +{ + if( !Font::EqualIgnoreColor(r) ) + return false; + return EqualNoBase(r); +} + +size_t FontMetric::GetHashValueNoBase() const +{ + size_t hash = 0; + o3tl::hash_combine( hash, mbFullstopCentered ); + o3tl::hash_combine( hash, mnAscent ); + o3tl::hash_combine( hash, mnDescent ); + o3tl::hash_combine( hash, mnIntLeading ); + o3tl::hash_combine( hash, mnExtLeading ); + o3tl::hash_combine( hash, mnSlant ); + return hash; +} + +size_t FontMetric::GetHashValue() const +{ + size_t hash = GetHashValueNoBase(); + o3tl::hash_combine( hash, Font::GetHashValue()); + return hash; +} + +size_t FontMetric::GetHashValueIgnoreColor() const +{ + size_t hash = GetHashValueNoBase(); + o3tl::hash_combine( hash, Font::GetHashValueIgnoreColor()); + return hash; +} + ImplFontMetricData::ImplFontMetricData( const vcl::font::FontSelectPattern& rFontSelData ) : FontAttributes( rFontSelData ) , mnHeight ( rFontSelData.mnHeight ) diff --git a/vcl/source/gdi/impglyphitem.cxx b/vcl/source/gdi/impglyphitem.cxx index 648696a55107..6ab5663ddef6 100644 --- a/vcl/source/gdi/impglyphitem.cxx +++ b/vcl/source/gdi/impglyphitem.cxx @@ -450,7 +450,7 @@ SalLayoutGlyphsCache::CachedGlyphsKey::CachedGlyphsKey( , logicWidth(w) // we also need to save things used in OutputDevice::ImplPrepareLayoutArgs(), in case they // change in the output device, plus mapMode affects the sizes. - , font(outputDevice->GetFont()) + , fontMetric(outputDevice->GetFontMetric()) // TODO It would be possible to get a better hit ratio if mapMode wasn't part of the key // and results that differ only in mapmode would have coordinates adjusted based on that. // That would occasionally lead to rounding errors (at least differences that would @@ -471,7 +471,7 @@ SalLayoutGlyphsCache::CachedGlyphsKey::CachedGlyphsKey( o3tl::hash_combine(hashValue, outputDevice.get()); // Need to use IgnoreColor, because sometimes the color changes, but it's irrelevant // for text layout (and also obsolete in vcl::Font). - o3tl::hash_combine(hashValue, font.GetHashValueIgnoreColor()); + o3tl::hash_combine(hashValue, fontMetric.GetHashValueIgnoreColor()); // For some reason font scale may differ even if vcl::Font is the same, // so explicitly check it too. o3tl::hash_combine(hashValue, fontScaleX); @@ -488,7 +488,7 @@ inline bool SalLayoutGlyphsCache::CachedGlyphsKey::operator==(const CachedGlyphs && logicWidth == other.logicWidth && mapMode == other.mapMode && rtl == other.rtl && layoutMode == other.layoutMode && digitLanguage == other.digitLanguage && fontScaleX == other.fontScaleX && fontScaleY == other.fontScaleY - && font.EqualIgnoreColor(other.font) + && fontMetric.EqualIgnoreColor(other.fontMetric) && vcl::text::FastStringCompareEqual()(text, other.text); // Slower things last in the comparison. } |