tdf#112152: Fix subsetting empty glyphs
When traversing the components of composite glyphs, the code was
treating a component pointing to an empty glyph (e.g. space) as an
error, but it is not. An overzealous bounds check.
Regression from:
commit 41007842ed9bb5d6165792a197769f72dae55a2c
Author: Martin Hosken <martin_hosken@sil.org>
Date: Thu Sep 10 10:14:18 2015 +0700
Refactor graphite integration and update graphite
Change-Id: Ie352f17cb08cd5762ff2a339662248a536b4e934
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140897
Tested-by: Jenkins
Reviewed-by: خالد حسني <khaled@aliftype.com>
(cherry picked from commit bb67f10786fd5e232b198d09139c41078c3fc60d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140876
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index a164757..93ad3e9 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -1479,7 +1479,7 @@ int GetTTGlyphComponents(AbstractTrueTypeFont *ttf, sal_uInt32 glyphID, std::vec
const sal_uInt8* ptr = glyf + nOffset;
const sal_uInt8* nptr = glyf + nNextOffset;
if (nptr <= ptr)
if (nptr < ptr)
return 0;
if (std::find(glyphlist.begin(), glyphlist.end(), glyphID) != glyphlist.end())
@@ -1490,6 +1490,10 @@ int GetTTGlyphComponents(AbstractTrueTypeFont *ttf, sal_uInt32 glyphID, std::vec
glyphlist.push_back( glyphID );
// Empty glyph.
if (nptr == ptr)
return n;
sal_uInt32 nRemainingData = glyflength - nOffset;
if (nRemainingData >= 10 && GetInt16(ptr, 0) == -1) {