From c1adcd12048d2a8453f29cb0ee86d05326c3953e Mon Sep 17 00:00:00 2001 From: bae Date: Wed, 19 Jun 2019 19:07:08 +0300 Subject: [PATCH] 8219018: Adjust positions of glyphs Reviewed-by: mbalao --- src/share/native/sun/font/layout/MarkToBasePosnSubtables.cpp | 3 +++ .../native/sun/font/layout/MarkToLigaturePosnSubtables.cpp | 3 +++ src/share/native/sun/font/layout/MarkToMarkPosnSubtables.cpp | 3 +++ src/share/native/sun/font/layout/OpenTypeLayoutEngine.cpp | 2 +- 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/share/native/sun/font/layout/MarkToBasePosnSubtables.cpp b/src/share/native/sun/font/layout/MarkToBasePosnSubtables.cpp index 086da9162..f8081a9c2 100644 --- a/src/share/native/sun/font/layout/MarkToBasePosnSubtables.cpp +++ b/src/share/native/sun/font/layout/MarkToBasePosnSubtables.cpp @@ -80,6 +80,9 @@ le_int32 MarkToBasePositioningSubtable::process(const LETableReference &base, Gl // FIXME: We probably don't want to find a base glyph before a previous ligature... GlyphIterator baseIterator(*glyphIterator, (le_uint16) (lfIgnoreMarks /*| lfIgnoreLigatures*/)); LEGlyphID baseGlyph = findBaseGlyph(&baseIterator); + if (baseGlyph == 0xFFFF) { + return 0; + } le_int32 baseCoverage = getBaseCoverage(base, (LEGlyphID) baseGlyph, success); LEReferenceTo baseArray(base, success, (const BaseArray *) ((char *) this + SWAPW(baseArrayOffset))); if(LE_FAILURE(success)) return 0; diff --git a/src/share/native/sun/font/layout/MarkToLigaturePosnSubtables.cpp b/src/share/native/sun/font/layout/MarkToLigaturePosnSubtables.cpp index 2515b8afb..e70f35c50 100644 --- a/src/share/native/sun/font/layout/MarkToLigaturePosnSubtables.cpp +++ b/src/share/native/sun/font/layout/MarkToLigaturePosnSubtables.cpp @@ -81,6 +81,9 @@ le_int32 MarkToLigaturePositioningSubtable::process(const LETableReference &base // FIXME: we probably don't want to find a ligature before a previous base glyph... GlyphIterator ligatureIterator(*glyphIterator, (le_uint16) (lfIgnoreMarks /*| lfIgnoreBaseGlyphs*/)); LEGlyphID ligatureGlyph = findLigatureGlyph(&ligatureIterator); + if (ligatureGlyph == 0xFFFF) { + return 0; + } le_int32 ligatureCoverage = getBaseCoverage(base, (LEGlyphID) ligatureGlyph, success); LEReferenceTo ligatureArray(base, success, SWAPW(baseArrayOffset)); if (LE_FAILURE(success)) { return 0; } diff --git a/src/share/native/sun/font/layout/MarkToMarkPosnSubtables.cpp b/src/share/native/sun/font/layout/MarkToMarkPosnSubtables.cpp index 4ed835453..0e16a2fce 100644 --- a/src/share/native/sun/font/layout/MarkToMarkPosnSubtables.cpp +++ b/src/share/native/sun/font/layout/MarkToMarkPosnSubtables.cpp @@ -81,6 +81,9 @@ le_int32 MarkToMarkPositioningSubtable::process(const LETableReference &base, Gl GlyphIterator mark2Iterator(*glyphIterator); LEGlyphID mark2Glyph = findMark2Glyph(&mark2Iterator); + if (mark2Glyph == 0xFFFF) { + return 0; + } le_int32 mark2Coverage = getBaseCoverage(base, (LEGlyphID) mark2Glyph, success); LEReferenceTo mark2Array(base, success, (const Mark2Array *) ((char *) this + SWAPW(baseArrayOffset))); if(LE_FAILURE(success)) return 0; diff --git a/src/share/native/sun/font/layout/OpenTypeLayoutEngine.cpp b/src/share/native/sun/font/layout/OpenTypeLayoutEngine.cpp index b4c9122c5..a02894954 100644 --- a/src/share/native/sun/font/layout/OpenTypeLayoutEngine.cpp +++ b/src/share/native/sun/font/layout/OpenTypeLayoutEngine.cpp @@ -543,7 +543,7 @@ void OpenTypeLayoutEngine::adjustGlyphPositions(const LEUnicode chars[], le_int3 yAdjust += yKerning; #endif - for (le_int32 base = i; base >= 0; base = adjustments->getBaseOffset(base)) { + for (le_int32 base = i; base >= 0 && base < glyphCount; base = adjustments->getBaseOffset(base)) { xPlacement += adjustments->getXPlacement(base); yPlacement += adjustments->getYPlacement(base); } -- GitLab