aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache/fop/layout/FontState.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/apache/fop/layout/FontState.java')
-rw-r--r--src/org/apache/fop/layout/FontState.java61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/org/apache/fop/layout/FontState.java b/src/org/apache/fop/layout/FontState.java
new file mode 100644
index 000000000..dea5014de
--- /dev/null
+++ b/src/org/apache/fop/layout/FontState.java
@@ -0,0 +1,61 @@
+package org.apache.xml.fop.layout;
+
+import org.apache.xml.fop.apps.FOPException;
+
+public class FontState {
+
+ protected FontInfo fontInfo;
+ private String fontName;
+ private int fontSize;
+ private String fontFamily;
+ private String fontStyle;
+ private String fontWeight;
+ private FontMetric metric;
+
+ public FontState(FontInfo fontInfo, String fontFamily, String fontStyle, String fontWeight, int fontSize) throws FOPException {
+ this.fontInfo = fontInfo;
+ this.fontFamily = fontFamily;
+ this.fontStyle = fontStyle;
+ this.fontWeight = fontWeight;
+ this.fontSize = fontSize;
+ this.fontName = fontInfo.fontLookup(fontFamily,fontStyle,fontWeight);
+ this.metric = fontInfo.getMetricsFor(fontName);
+ }
+
+ public int getAscender() {
+ return fontSize * metric.getAscender() / 1000;
+ }
+
+ public int getCapHeight() {
+ return fontSize * metric.getCapHeight() / 1000;
+ }
+
+ public int getDescender() {
+ return fontSize * metric.getDescender() / 1000;
+ }
+
+ public String getFontName() {
+ return this.fontName;
+ }
+
+ public int getFontSize() {
+ return this.fontSize;
+ }
+
+ public String getFontWeight() {
+ return this.fontWeight;
+ }
+
+ public FontInfo getFontInfo() {
+ return this.fontInfo;
+ }
+
+ public int getXHeight() {
+ return fontSize * metric.getXHeight() / 1000;
+ }
+
+ public int width(int charnum) {
+ // returns width of given character number in millipoints
+ return (fontSize * metric.width(charnum) / 1000);
+ }
+}