aboutsummaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2006-01-03 13:08:45 +0000
committerJeremias Maerki <jeremias@apache.org>2006-01-03 13:08:45 +0000
commita2247e269485af984c3712debf23836caa92733d (patch)
tree11fd81d2b68aac7f7f7ddf75ac751f1621db062c /src/java
parent4a01bc4956bf6b6ceb00b902d9d9ce1bd71842a4 (diff)
downloadxmlgraphics-fop-a2247e269485af984c3712debf23836caa92733d.tar.gz
xmlgraphics-fop-a2247e269485af984c3712debf23836caa92733d.zip
The font loading code now reads the encoding value from the XML font metrics file so that Type 1 fonts like Symbol and ZapfDingbats can be embedded explicitely (Required by PDF/A).
Note that it is necessary to set the encoding value in the font metrics file manually since it cannot be extracted from the PFM file reliably, i.e. for "Symbol" use "SymbolEncoding" and for "ZapfDingbats" use "ZapfDingbatsEncoding". git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@365623 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
-rw-r--r--src/java/org/apache/fop/fonts/FontReader.java6
-rw-r--r--src/java/org/apache/fop/fonts/SingleByteFont.java35
2 files changed, 31 insertions, 10 deletions
diff --git a/src/java/org/apache/fop/fonts/FontReader.java b/src/java/org/apache/fop/fonts/FontReader.java
index 131f50a6a..5953c91fb 100644
--- a/src/java/org/apache/fop/fonts/FontReader.java
+++ b/src/java/org/apache/fop/fonts/FontReader.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2004,2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -218,6 +218,10 @@ public class FontReader extends DefaultHandler {
returnFont.setFontName(content);
} else if ("ttc-name".equals(localName) && isCID) {
multiFont.setTTCName(content);
+ } else if ("encoding".equals(localName)) {
+ if (singleFont != null && singleFont.getFontType() == FontType.TYPE1) {
+ singleFont.setEncoding(content);
+ }
} else if ("cap-height".equals(localName)) {
returnFont.setCapHeight(getInt(content));
} else if ("x-height".equals(localName)) {
diff --git a/src/java/org/apache/fop/fonts/SingleByteFont.java b/src/java/org/apache/fop/fonts/SingleByteFont.java
index 26bba54a6..f03f6f7b5 100644
--- a/src/java/org/apache/fop/fonts/SingleByteFont.java
+++ b/src/java/org/apache/fop/fonts/SingleByteFont.java
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2004,2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,15 +23,27 @@ package org.apache.fop.fonts;
*/
public class SingleByteFont extends CustomFont {
- private final CodePointMapping mapping
- = CodePointMapping.getMapping("WinAnsiEncoding");
+ private CodePointMapping mapping;
private String encoding = "WinAnsiEncoding";
- private int width[] = null;
-
+ private int[] width = null;
/**
+ * Main constructor.
+ */
+ public SingleByteFont() {
+ updateMapping();
+ }
+
+ /**
+ * Updates the mapping variable based on the encoding.
+ */
+ protected void updateMapping() {
+ mapping = CodePointMapping.getMapping(getEncoding());
+ }
+
+ /**
* @see org.apache.fop.fonts.FontDescriptor#isEmbeddable()
*/
public boolean isEmbeddable() {
@@ -47,6 +59,15 @@ public class SingleByteFont extends CustomFont {
}
/**
+ * Sets the encoding of the font.
+ * @param encoding the encoding (ex. "WinAnsiEncoding" or "SymbolEncoding")
+ */
+ public void setEncoding(String encoding) {
+ this.encoding = encoding;
+ updateMapping();
+ }
+
+ /**
* @see org.apache.fop.fonts.FontMetrics#getWidth(int, int)
*/
public int getWidth(int i, int size) {
@@ -59,10 +80,6 @@ public class SingleByteFont extends CustomFont {
public int[] getWidths() {
int[] arr = new int[width.length];
System.arraycopy(width, 0, arr, 0, width.length - 1);
- /*
- for (int i = 0; i < arr.length; i++)
- arr[i] *= size;
- */
return arr;
}