aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Hancock <phancock@apache.org>2013-01-09 09:51:11 +0000
committerPeter Hancock <phancock@apache.org>2013-01-09 09:51:11 +0000
commitdc7f036c5e0ee8ee8b51f5f4bb2940a77da2bffa (patch)
treee966faba44a95561c45dde1a11b43e1bc1cad2be
parent91d9b34a7a9a443e58938697d2a5cb43a9475d77 (diff)
downloadxmlgraphics-fop-dc7f036c5e0ee8ee8b51f5f4bb2940a77da2bffa.tar.gz
xmlgraphics-fop-dc7f036c5e0ee8ee8b51f5f4bb2940a77da2bffa.zip
JIRA#FOP-2180: TTFReader outputs bounding box information for glyphs.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1430752 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/java/org/apache/fop/fonts/apps/TTFReader.java5
-rw-r--r--src/java/org/apache/fop/fonts/truetype/TTFFile.java15
-rw-r--r--status.xml3
3 files changed, 23 insertions, 0 deletions
diff --git a/src/java/org/apache/fop/fonts/apps/TTFReader.java b/src/java/org/apache/fop/fonts/apps/TTFReader.java
index 25b9e3924..900417350 100644
--- a/src/java/org/apache/fop/fonts/apps/TTFReader.java
+++ b/src/java/org/apache/fop/fonts/apps/TTFReader.java
@@ -408,6 +408,11 @@ public class TTFReader extends AbstractFontReader {
for (int i = 0; i < wx.length; i++) {
Element wxel = doc.createElement("wx");
wxel.setAttribute("w", String.valueOf(wx[i]));
+ int[] bbox = ttf.getBBox(i);
+ wxel.setAttribute("xMin", String.valueOf(bbox[0]));
+ wxel.setAttribute("yMin", String.valueOf(bbox[1]));
+ wxel.setAttribute("xMax", String.valueOf(bbox[2]));
+ wxel.setAttribute("yMax", String.valueOf(bbox[3]));
el.appendChild(wxel);
}
}
diff --git a/src/java/org/apache/fop/fonts/truetype/TTFFile.java b/src/java/org/apache/fop/fonts/truetype/TTFFile.java
index 878af1124..442407d6b 100644
--- a/src/java/org/apache/fop/fonts/truetype/TTFFile.java
+++ b/src/java/org/apache/fop/fonts/truetype/TTFFile.java
@@ -981,6 +981,21 @@ public class TTFFile {
}
/**
+ * Returns an array (xMin, yMin, xMax, yMax) for a glyph.
+ *
+ * @param glyphIndex the index of the glyph
+ * @return int[] Array defining bounding box.
+ */
+ public int[] getBBox(int glyphIndex) {
+ int[] bboxInTTFUnits = mtxTab[glyphIndex].getBoundingBox();
+ int[] bbox = new int[4];
+ for (int i = 0; i < 4; i++) {
+ bbox[i] = (int) convertTTFUnit2PDFUnit(bboxInTTFUnits[i]);
+ }
+ return bbox;
+ }
+
+ /**
* Returns the width of a given character.
* @param idx Index of the character
* @return int Standard width
diff --git a/status.xml b/status.xml
index efbd518b2..309e48413 100644
--- a/status.xml
+++ b/status.xml
@@ -59,6 +59,9 @@
documents. Example: the fix of marks layering will be such a case when it's done.
-->
<release version="FOP Trunk" date="TBD">
+ <action context="Fonts" dev="PH" type="add" fixes-bug="FOP-1069" due-to="Alexey Neyman">
+ TTFReader: Output bounding box information for glyphs.
+ </action>
<action context="Code" dev="PH" type="fix" fixes-bug="FOP-1069" due-to="Robert Meyer">
Warn instead or error on invalid property values.
</action>