diff options
author | Jonathan Clark <jonathan@libreoffice.org> | 2024-10-18 06:12:39 -0600 |
---|---|---|
committer | Jonathan Clark <jonathan@libreoffice.org> | 2024-10-18 21:49:03 +0200 |
commit | 224fae69b224d28a1664c48117e77265ed67a136 (patch) | |
tree | 57e66f932aac2cadcf95804f0d293e38c6597f9d /vcl/source/gdi | |
parent | 3cc367f426506e3165dda06feeb20e0a9b4c6194 (diff) |
tdf#163215: Enable kashida justification for AAT fonts
Currently, we use HarfBuzz-provided kashida insertion position
information to decide on positions to insert kashida. This data is used
both while ranking kashida insertion positions, and to avoid inserting
kashida in positions that would break shaping on a per-font basis.
Unfortunately, HarfBuzz cannot validate kashida insertion positions for
AAT fonts. As a result, kashida were previously not inserted for text
using AAT fonts.
This change updates kashida justification to skip validation against
HarfBuzz when AAT fonts are used.
Change-Id: If0d31512b1db0f1f8155963f9b1031eb01bacc45
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175165
Tested-by: Jenkins
Reviewed-by: Jonathan Clark <jonathan@libreoffice.org>
Diffstat (limited to 'vcl/source/gdi')
-rw-r--r-- | vcl/source/gdi/CommonSalLayout.cxx | 15 | ||||
-rw-r--r-- | vcl/source/gdi/sallayout.cxx | 15 |
2 files changed, 29 insertions, 1 deletions
diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx index a932dd54b16f..26347233d65f 100644 --- a/vcl/source/gdi/CommonSalLayout.cxx +++ b/vcl/source/gdi/CommonSalLayout.cxx @@ -40,6 +40,7 @@ #include <hb-ot.h> #include <hb-graphite2.h> #include <hb-icu.h> +#include <hb-aat.h> #include <map> #include <memory> @@ -376,6 +377,14 @@ bool GenericSalLayout::LayoutText(vcl::text::ImplLayoutArgs& rArgs, const SalLay hb_font_t *pHbFont = GetFont().GetHbFont(); bool isGraphite = GetFont().IsGraphiteFont(); + // tdf#163215: Identify layouts that don't have strict kashida position validation. + m_bHasFontKashidaPositions = false; + if (!(rArgs.mnFlags & SalLayoutFlags::DisableKashidaValidation)) + { + hb_face_t* pHbFace = hb_font_get_face(pHbFont); + m_bHasFontKashidaPositions = !hb_aat_layout_has_substitution(pHbFace); + } + int nGlyphCapacity = 2 * (rArgs.mnEndCharPos - rArgs.mnMinCharPos); m_GlyphItems.reserve(nGlyphCapacity); @@ -683,7 +692,9 @@ bool GenericSalLayout::LayoutText(vcl::text::ImplLayoutArgs& rArgs, const SalLay if (hb_glyph_info_get_glyph_flags(&pHbGlyphInfos[i]) & HB_GLYPH_FLAG_UNSAFE_TO_BREAK) nGlyphFlags |= GlyphItemFlags::IS_UNSAFE_TO_BREAK; - if (hb_glyph_info_get_glyph_flags(&pHbGlyphInfos[i]) & HB_GLYPH_FLAG_SAFE_TO_INSERT_TATWEEL) + if (!m_bHasFontKashidaPositions + || (hb_glyph_info_get_glyph_flags(&pHbGlyphInfos[i]) + & HB_GLYPH_FLAG_SAFE_TO_INSERT_TATWEEL)) nGlyphFlags |= GlyphItemFlags::IS_SAFE_TO_INSERT_KASHIDA; double nAdvance, nXOffset, nYOffset; @@ -1010,6 +1021,8 @@ void GenericSalLayout::ApplyJustificationData(const JustificationData& rstJustif } } +bool GenericSalLayout::HasFontKashidaPositions() const { return m_bHasFontKashidaPositions; } + // Kashida will be inserted between nCharPos and nNextCharPos. bool GenericSalLayout::IsKashidaPosValid(int nCharPos, int nNextCharPos) const { diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index 4d2d4fe68475..e8dc3999e216 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -1243,6 +1243,21 @@ bool MultiSalLayout::GetOutline(basegfx::B2DPolyPolygonVector& rPPV) const return bRet; } +bool MultiSalLayout::HasFontKashidaPositions() const +{ + // tdf#163215: VCL cannot suggest valid kashida positions for certain fonts (e.g. AAT). + // In order to strictly validate kashida positions, all fallback fonts must allow it. + for (int n = 0; n < mnLevel; ++n) + { + if (!mpLayouts[n]->HasFontKashidaPositions()) + { + return false; + } + } + + return true; +} + bool MultiSalLayout::IsKashidaPosValid(int nCharPos, int nNextCharPos) const { // Check the base layout |