You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2024/04/26 12:05:32 UTC
svn commit: r1917364 - /pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/ttf/gsub/GsubWorkerForLatinTest.java
Author: tilman
Date: Fri Apr 26 12:05:32 2024
New Revision: 1917364
URL: http://svn.apache.org/viewvc?rev=1917364&view=rev
Log:
PDFBOX-5808: add test that shows bug that happened with FoglihtenNo07 font, by Fabrice Calafat
Modified:
pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/ttf/gsub/GsubWorkerForLatinTest.java
Modified: pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/ttf/gsub/GsubWorkerForLatinTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/ttf/gsub/GsubWorkerForLatinTest.java?rev=1917364&r1=1917363&r2=1917364&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/ttf/gsub/GsubWorkerForLatinTest.java (original)
+++ pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/ttf/gsub/GsubWorkerForLatinTest.java Fri Apr 26 12:05:32 2024
@@ -25,6 +25,7 @@ import java.util.Arrays;
import java.util.List;
import org.apache.fontbox.ttf.CmapLookup;
+import org.apache.fontbox.ttf.OTFParser;
import org.apache.fontbox.ttf.TTFParser;
import org.apache.fontbox.ttf.TrueTypeFont;
import org.apache.pdfbox.io.RandomAccessReadBufferedFile;
@@ -41,7 +42,7 @@ import org.junit.jupiter.api.Test;
class GsubWorkerForLatinTest
{
@Test
- void testApplyLigatures() throws IOException
+ void testApplyLigaturesCalibri() throws IOException
{
File file = new File("c:/windows/fonts/calibri.ttf");
Assumptions.assumeTrue(file.exists(), "calibri ligature test skipped");
@@ -68,6 +69,32 @@ class GsubWorkerForLatinTest
gsubWorkerForLatin.applyTransforms(getGlyphIds("platform", cmapLookup)));
}
+ @Test
+ void testApplyLigaturesFoglihtenNo07() throws IOException
+ {
+ CmapLookup cmapLookup;
+ GsubWorker gsubWorkerForLatin;
+ try (TrueTypeFont ttf = new OTFParser().parse(
+ new RandomAccessReadBufferedFile("src/test/resources/otf/FoglihtenNo07.otf")))
+ {
+ cmapLookup = ttf.getUnicodeCmapLookup();
+ gsubWorkerForLatin = new GsubWorkerFactory().getGsubWorker(cmapLookup, ttf.getGsubData());
+ }
+
+ assertEquals(Arrays.asList(66, 1590, 645, 70),
+ gsubWorkerForLatin.applyTransforms(getGlyphIds("affine", cmapLookup)));
+ assertEquals(Arrays.asList(538, 633, 85, 86, 69, 70),
+ gsubWorkerForLatin.applyTransforms(getGlyphIds("attitude", cmapLookup)));
+ assertEquals(Arrays.asList(66, 1590, 525, 74, 683),
+ gsubWorkerForLatin.applyTransforms(getGlyphIds("affiliate", cmapLookup)));
+ assertEquals(Arrays.asList(542, 1, 1591, 498),
+ gsubWorkerForLatin.applyTransforms(getGlyphIds("The film", cmapLookup)));
+ assertEquals(Arrays.asList(542, 1, 45, 703, 85),
+ gsubWorkerForLatin.applyTransforms(getGlyphIds("The Last", cmapLookup)));
+ assertEquals(Arrays.asList(81, 77, 538, 71, 80, 83, 78),
+ gsubWorkerForLatin.applyTransforms(getGlyphIds("platform", cmapLookup)));
+ }
+
private List<Integer> getGlyphIds(String word, CmapLookup cmapLookup)
{
List<Integer> originalGlyphIds = new ArrayList<>();