summaryrefslogtreecommitdiff
path: root/vcl/win
diff options
context:
space:
mode:
authorKhaled Hosny <khaled@aliftype.com>2022-11-19 14:58:40 +0200
committerخالد حسني <khaled@aliftype.com>2022-11-19 15:45:21 +0100
commita38bb773bb568ef942293f23d0701da933817e8f (patch)
treee628431e3afb207f2849afe923a6668e0e68d795 /vcl/win
parente65b0bf83b8225fde81ee7b10c1fa4b9f32b6ed1 (diff)
vcl: use std::optional in PhysicalFontFace
Otherwise when a font does not, say, support variations or color palettes, we keep querying the font each time they are requested. Change-Id: I3a41bc73dd814b25af3a8b5b009632ecf7ef27ab Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142963 Tested-by: Jenkins Reviewed-by: خالد حسني <khaled@aliftype.com>
Diffstat (limited to 'vcl/win')
-rw-r--r--vcl/win/gdi/salfont.cxx11
1 files changed, 6 insertions, 5 deletions
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 986b09433da1..8719829ee8d4 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -566,10 +566,11 @@ IDWriteFontFace* WinFontFace::GetDWFontFace() const
return mxDWFontFace;
}
-std::vector<hb_variation_t> WinFontFace::GetVariations() const
+const std::vector<hb_variation_t>& WinFontFace::GetVariations() const
{
- if (m_aVariations.empty())
+ if (!mxVariations)
{
+ mxVariations.emplace();
auto pDWFontFace = WinFontFace::GetDWFontFace();
if (pDWFontFace)
{
@@ -583,16 +584,16 @@ std::vector<hb_variation_t> WinFontFace::GetVariations() const
hr = xDWFontFace5->GetFontAxisValues(aAxisValues.data(), aAxisValues.size());
if (SUCCEEDED(hr))
{
- m_aVariations.reserve(aAxisValues.size());
+ mxVariations->reserve(aAxisValues.size());
for (auto& rAxisValue : aAxisValues)
- m_aVariations.push_back(
+ mxVariations->push_back(
{ OSL_NETDWORD(rAxisValue.axisTag), rAxisValue.value });
}
}
}
}
- return m_aVariations;
+ return *mxVariations;
}
namespace