From 32ad33cda1ee32f8bb6fa5212933827485787d37 Mon Sep 17 00:00:00 2001 From: Chris Bowditch Date: Thu, 17 Nov 2011 12:10:34 +0000 Subject: [PATCH] Bugzilla #51592: TTFFontLoader ignores the useKerning attribute used with fonts Patch submitted by Mehdi Houshmand (mehdi1985 at gmail.com) git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1203163 13f79535-47bb-0310-9956-ffa450edef68 --- .../fop/fonts/truetype/TTFFontLoader.java | 2 +- .../fonts/truetype/TTFFontLoaderTestCase.java | 57 +++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 test/java/org/apache/fop/fonts/truetype/TTFFontLoaderTestCase.java diff --git a/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java b/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java index 8ee36ec1f..dc2bec352 100644 --- a/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java +++ b/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java @@ -70,7 +70,7 @@ public class TTFFontLoader extends FontLoader { public TTFFontLoader(String fontFileURI, String subFontName, boolean embedded, EncodingMode encodingMode, boolean useKerning, FontResolver resolver) { - super(fontFileURI, embedded, true, resolver); + super(fontFileURI, embedded, useKerning, resolver); this.subFontName = subFontName; this.encodingMode = encodingMode; if (this.encodingMode == EncodingMode.AUTO) { diff --git a/test/java/org/apache/fop/fonts/truetype/TTFFontLoaderTestCase.java b/test/java/org/apache/fop/fonts/truetype/TTFFontLoaderTestCase.java new file mode 100644 index 000000000..595eb9b5f --- /dev/null +++ b/test/java/org/apache/fop/fonts/truetype/TTFFontLoaderTestCase.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Id$ */ + +package org.apache.fop.fonts.truetype; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.io.IOException; + +import org.junit.Test; + +import org.apache.fop.fonts.EncodingMode; +import org.apache.fop.fonts.FontManager; +import org.apache.fop.fonts.FontResolver; + +/** + * Test case for {@link TTFFontLoader}. + */ +public class TTFFontLoaderTestCase { + + @Test + public void testUseKerning() throws IOException { + File file = new File("test/resources/fonts/DejaVuLGCSerif.ttf"); + String absoluteFilePath = file.toURL().toExternalForm(); + FontResolver resolver = FontManager.createMinimalFontResolver(); + String fontName = "Deja Vu"; + boolean embedded = false; + boolean useKerning = true; + + TTFFontLoader fontLoader = new TTFFontLoader(absoluteFilePath, fontName, embedded, + EncodingMode.AUTO, useKerning, resolver); + assertTrue(fontLoader.getFont().hasKerningInfo()); + useKerning = false; + + fontLoader = new TTFFontLoader(absoluteFilePath, fontName, embedded, EncodingMode.AUTO, + useKerning, resolver); + assertFalse(fontLoader.getFont().hasKerningInfo()); + } +} \ No newline at end of file -- 2.39.5