aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/fonts
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2007-11-03 10:51:31 +0000
committerJeremias Maerki <jeremias@apache.org>2007-11-03 10:51:31 +0000
commit281ac8bcab030f3cb9646f4eb3895f320a1abb6b (patch)
tree691fef15e6dd437269f05c030adde096d2f72a22 /src/java/org/apache/fop/fonts
parentb58bd2b16672a0a39ac5d3d4d24291569fad6697 (diff)
downloadxmlgraphics-fop-281ac8bcab030f3cb9646f4eb3895f320a1abb6b.tar.gz
xmlgraphics-fop-281ac8bcab030f3cb9646f4eb3895f320a1abb6b.zip
More fine-grained mechanism to detect if a font has been used or not. If a font list is given for a text run and each character should be painted in the right font, it might be accessed but never really used. Needed for PDF text painting improvements.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@591583 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/fonts')
-rw-r--r--src/java/org/apache/fop/fonts/LazyFont.java10
-rw-r--r--src/java/org/apache/fop/fonts/MultiByteFont.java1
-rw-r--r--src/java/org/apache/fop/fonts/SingleByteFont.java4
-rw-r--r--src/java/org/apache/fop/fonts/Typeface.java19
4 files changed, 31 insertions, 3 deletions
diff --git a/src/java/org/apache/fop/fonts/LazyFont.java b/src/java/org/apache/fop/fonts/LazyFont.java
index c629f14fe..cc8989b7d 100644
--- a/src/java/org/apache/fop/fonts/LazyFont.java
+++ b/src/java/org/apache/fop/fonts/LazyFont.java
@@ -22,6 +22,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Map;
+
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
@@ -166,6 +167,14 @@ public class LazyFont extends Typeface implements FontDescriptor {
/**
* {@inheritDoc}
*/
+ public boolean hadMappingOperations() {
+ load(true);
+ return realFont.hadMappingOperations();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public boolean hasChar(char c) {
load(true);
return realFont.hasChar(c);
@@ -332,5 +341,6 @@ public class LazyFont extends Typeface implements FontDescriptor {
load(true);
return realFontDescriptor.isEmbeddable();
}
+
}
diff --git a/src/java/org/apache/fop/fonts/MultiByteFont.java b/src/java/org/apache/fop/fonts/MultiByteFont.java
index e00300324..dcd3bdfa0 100644
--- a/src/java/org/apache/fop/fonts/MultiByteFont.java
+++ b/src/java/org/apache/fop/fonts/MultiByteFont.java
@@ -214,6 +214,7 @@ public class MultiByteFont extends CIDFont {
* {@inheritDoc}
*/
public char mapChar(char c) {
+ notifyMapOperation();
int retIdx = findGlyphIndex(c);
if (isEmbeddable()) {
diff --git a/src/java/org/apache/fop/fonts/SingleByteFont.java b/src/java/org/apache/fop/fonts/SingleByteFont.java
index 402a630e8..1baee3f98 100644
--- a/src/java/org/apache/fop/fonts/SingleByteFont.java
+++ b/src/java/org/apache/fop/fonts/SingleByteFont.java
@@ -98,6 +98,7 @@ public class SingleByteFont extends CustomFont {
* {@inheritDoc}
*/
public char mapChar(char c) {
+ notifyMapOperation();
char d = mapping.mapChar(c);
if (d != 0) {
return d;
@@ -129,8 +130,5 @@ public class SingleByteFont extends CustomFont {
this.width[index] = width;
}
- public char[] getCharsUsed() {
- return null;
- }
}
diff --git a/src/java/org/apache/fop/fonts/Typeface.java b/src/java/org/apache/fop/fonts/Typeface.java
index c165b4068..ebfc02c39 100644
--- a/src/java/org/apache/fop/fonts/Typeface.java
+++ b/src/java/org/apache/fop/fonts/Typeface.java
@@ -27,6 +27,8 @@ package org.apache.fop.fonts;
*/
public abstract class Typeface implements FontMetrics {
+ private long charMapOps = 0;
+
/**
* Get the encoding of the font.
* @return the encoding
@@ -41,6 +43,23 @@ public abstract class Typeface implements FontMetrics {
public abstract char mapChar(char c);
/**
+ * Used for keeping track of character mapping operations in order to determine if a font
+ * was used at all or not.
+ */
+ protected void notifyMapOperation() {
+ this.charMapOps++;
+ }
+
+ /**
+ * Indicates whether this font had to do any character mapping operations. If that was
+ * not the case, it's an indication that the font has never actually been used.
+ * @return true if the font had to do any character mapping operations
+ */
+ public boolean hadMappingOperations() {
+ return (this.charMapOps > 0);
+ }
+
+ /**
* Determines whether this font contains a particular character/glyph.
* @param c character to check
* @return True if the character is supported, Falso otherwise