From aa4fd5e6b10f29ac5f17a6875291ae3ab0d106ea Mon Sep 17 00:00:00 2001 From: michael Date: Wed, 17 Feb 2021 13:32:03 +0000 Subject: [PATCH] * Fix issue ID #35251 (patch from Rumen Gyurov) git-svn-id: trunk@48696 - --- packages/fcl-pdf/src/fpttfsubsetter.pp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/fcl-pdf/src/fpttfsubsetter.pp b/packages/fcl-pdf/src/fpttfsubsetter.pp index df8976c36a..f290a3992d 100644 --- a/packages/fcl-pdf/src/fpttfsubsetter.pp +++ b/packages/fcl-pdf/src/fpttfsubsetter.pp @@ -940,12 +940,18 @@ end; function TFontSubsetter.buildHmtxTable: TStream; var n: integer; + GID: longint; + LastGID: longint; begin Result := TMemoryStream.Create; + LastGID := Length(FFontInfo.Widths)-1; for n := 0 to FGlyphIDs.Count-1 do begin - WriteUInt16(Result, FFontInfo.Widths[FGlyphIDs[n].GID].AdvanceWidth); - WriteInt16(Result, FFontInfo.Widths[FGlyphIDs[n].GID].LSB); + GID := FGlyphIDs[n].GID; + if GID > LastGID then + GID := LastGID; + WriteUInt16(Result, FFontInfo.Widths[GID].AdvanceWidth); + WriteInt16(Result, FFontInfo.Widths[GID].LSB); end; end;