diff options
author | Khaled Hosny <khaled@aliftype.com> | 2022-11-21 17:32:42 +0200 |
---|---|---|
committer | خالد حسني <khaled@aliftype.com> | 2022-11-21 19:58:54 +0100 |
commit | ab5c60f2fd3e24f24fd82d7756d45a5fd4d19f1d (patch) | |
tree | 772f9bd330ab3e129030efdb43e710203b3b6756 /vcl | |
parent | 1ff2f5fa2d8c353b0cad28317a696c2ba9a4aab5 (diff) |
vcl: fix accessing color font colors
Don’t unconditionally access palette 0.
Change-Id: I3de3f005371fcb9360ee0cf245a1d0a7434ffbd8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143042
Tested-by: Jenkins
Reviewed-by: خالد حسني <khaled@aliftype.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/font/PhysicalFontFace.hxx | 3 | ||||
-rw-r--r-- | vcl/source/font/PhysicalFontFace.cxx | 4 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 5 |
3 files changed, 7 insertions, 5 deletions
diff --git a/vcl/inc/font/PhysicalFontFace.hxx b/vcl/inc/font/PhysicalFontFace.hxx index 96f2533f22fe..ac8ba2d958c7 100644 --- a/vcl/inc/font/PhysicalFontFace.hxx +++ b/vcl/inc/font/PhysicalFontFace.hxx @@ -174,9 +174,10 @@ public: bool IsColorFont() const { return HasColorLayers() || HasColorBitmaps(); } bool HasColorLayers() const; - const ColorPalette& GetColorPalette(size_t) const; std::vector<ColorLayer> GetGlyphColorLayers(sal_GlyphId) const; + const std::vector<ColorPalette>& GetColorPalettes() const; + bool HasColorBitmaps() const; RawFontData GetGlyphColorBitmap(sal_GlyphId, tools::Rectangle&) const; diff --git a/vcl/source/font/PhysicalFontFace.cxx b/vcl/source/font/PhysicalFontFace.cxx index 83f50b31e690..682113cad102 100644 --- a/vcl/source/font/PhysicalFontFace.cxx +++ b/vcl/source/font/PhysicalFontFace.cxx @@ -383,7 +383,7 @@ bool PhysicalFontFace::HasColorLayers() const return hb_ot_color_has_layers(pHbFace) && hb_ot_color_has_palettes(pHbFace); } -const ColorPalette& PhysicalFontFace::GetColorPalette(size_t nIndex) const +const std::vector<ColorPalette>& PhysicalFontFace::GetColorPalettes() const { if (!mxColorPalettes) { @@ -410,7 +410,7 @@ const ColorPalette& PhysicalFontFace::GetColorPalette(size_t nIndex) const } } - return (*mxColorPalettes)[nIndex]; + return *mxColorPalettes; } std::vector<ColorLayer> PhysicalFontFace::GetGlyphColorLayers(sal_GlyphId nGlyphIndex) const diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 8ba2ac6e0428..57ea2c785b81 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -2446,7 +2446,7 @@ bool PDFWriterImpl::emitType3Font(const vcl::font::PhysicalFontFace* pFace, if (g_bDebugDisableCompression) emitComment("PDFWriterImpl::emitType3Font"); - const auto& aPalette = pFace->GetColorPalette(0); + const auto& rColorPalettes = pFace->GetColorPalettes(); FontSubsetInfo aSubsetInfo; sal_GlyphId pTempGlyphIds[] = { 0 }; @@ -2587,7 +2587,8 @@ bool PDFWriterImpl::emitType3Font(const vcl::font::PhysicalFontFace* pFace, // 0xFFFF is a special value means foreground color. if (rLayer.m_nColorIndex != 0xFFFF) { - auto aColor(aPalette[rLayer.m_nColorIndex]); + auto& rPalette = rColorPalettes[0]; + auto aColor(rPalette[rLayer.m_nColorIndex]); appendNonStrokingColor(aColor, aContents); aContents.append(" "); if (aColor.GetAlpha() != 0xFF |