From 589c8ab356833617014977ab1a7a8ee6c181359a Mon Sep 17 00:00:00 2001 From: Vincent Hennebert Date: Fri, 2 Jul 2010 17:23:36 +0000 Subject: Trying to get a glyph name out of a Unicode code point is already done by the call to mapChar, so doing it again in TTFFontLoader is useless. Instead, make use of the post table if it exists, that may contain a list of glyph names and allow more glyphs to be supported. That allows to reference instead of embed a TrueType font that is already installed on the printer. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript@960065 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/fonts/truetype/TTFFile.java | 4 ++++ src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java | 12 +++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/java/org/apache/fop/fonts/truetype/TTFFile.java b/src/java/org/apache/fop/fonts/truetype/TTFFile.java index 9fd6adbce..a1b6319ed 100644 --- a/src/java/org/apache/fop/fonts/truetype/TTFFile.java +++ b/src/java/org/apache/fop/fonts/truetype/TTFFile.java @@ -1691,6 +1691,10 @@ public class TTFFile { return result; } + String getGlyphName(int glyphIndex) { + return mtxTab[glyphIndex].getName(); + } + /** * Static main method to get info about a TrueType font. * @param args The command line arguments diff --git a/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java b/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java index df8cce1b2..10e618adf 100644 --- a/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java +++ b/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java @@ -27,8 +27,6 @@ import java.util.Map; import org.apache.commons.io.IOUtils; -import org.apache.xmlgraphics.fonts.Glyphs; - import org.apache.fop.fonts.BFEntry; import org.apache.fop.fonts.CIDFontType; import org.apache.fop.fonts.EncodingMode; @@ -187,11 +185,11 @@ public class TTFFontLoader extends FontLoader { for (char u = (char)ce.getUnicodeStart(); u <= ce.getUnicodeEnd(); u++) { int codePoint = singleFont.getEncoding().mapChar(u); if (codePoint <= 0) { - String unicode = Character.toString(u); - String charName = Glyphs.stringToGlyph(unicode); - if (charName.length() > 0) { - NamedCharacter nc = new NamedCharacter(charName, unicode); - int glyphIndex = ce.getGlyphStartIndex() + u - ce.getUnicodeStart(); + int glyphIndex = ce.getGlyphStartIndex() + u - ce.getUnicodeStart(); + String glyphName = ttf.getGlyphName(glyphIndex); + if (glyphName != "") { + String unicode = Character.toString(u); + NamedCharacter nc = new NamedCharacter(glyphName, unicode); singleFont.addUnencodedCharacter(nc, wx[glyphIndex]); } } -- cgit v1.2.3