[FOray-commit] SF.net SVN: foray:[10613] trunk/foray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2008-07-18 02:12:33
|
Revision: 10613
http://foray.svn.sourceforge.net/foray/?rev=10613&view=rev
Author: victormote
Date: 2008-07-18 02:12:39 +0000 (Fri, 18 Jul 2008)
Log Message:
-----------
Add some more Type 1 dictionary wrapper classes, and move more of the "get" logic to them.
Modified Paths:
--------------
trunk/foray/foray-font/src/java/org/foray/font/format/Type1File.java
trunk/foray/foray-ps/src/java/org/foray/ps/PsDictionary.java
trunk/foray/foray-ps/src/java/org/foray/ps/type1/PsFontDictionary.java
Added Paths:
-----------
trunk/foray/foray-ps/src/java/org/foray/ps/PsDictionaryWrapper.java
trunk/foray/foray-ps/src/java/org/foray/ps/type1/PsFontInfoDictionary.java
trunk/foray/foray-ps/src/java/org/foray/ps/type1/PsMetricsDictionary.java
trunk/foray/foray-ps/src/java/org/foray/ps/type1/PsPrivateDictionary.java
Modified: trunk/foray/foray-font/src/java/org/foray/font/format/Type1File.java
===================================================================
--- trunk/foray/foray-font/src/java/org/foray/font/format/Type1File.java 2008-07-18 00:49:26 UTC (rev 10612)
+++ trunk/foray/foray-font/src/java/org/foray/font/format/Type1File.java 2008-07-18 02:12:39 UTC (rev 10613)
@@ -29,18 +29,16 @@
package org.foray.font.format;
import org.foray.common.WKConstants;
-import org.foray.ps.PsArray;
import org.foray.ps.PsDictionary;
import org.foray.ps.PsException;
import org.foray.ps.PsInput;
-import org.foray.ps.PsInteger;
import org.foray.ps.PsInterpreter;
import org.foray.ps.PsObject;
import org.foray.ps.filter.PSFilter;
import org.foray.ps.type1.PsFontDictionary;
+import org.foray.ps.type1.PsFontInfoDictionary;
+import org.foray.ps.type1.PsPrivateDictionary;
-import org.axsl.ps.BoundingBox;
-
import org.apache.commons.logging.Log;
import java.io.IOException;
@@ -96,9 +94,6 @@
/** The font bounding box parsed from this file. */
private int[] fontBBox = null;
- /** The stemV value parsed from this file. */
- private int stemV = 0;
-
/** The PostScript interpreter used to parse this file. */
private PsInterpreter interpreter;
@@ -173,54 +168,6 @@
}
/**
- * Parses and returns the font bounding box.
- * @return The font bbox.
- */
- private int[] parseFontBBox() {
- final Object object = getFontDictionary().getItem("FontBBox");
- if (! (object instanceof PsArray)) {
- return null;
- }
- final PsArray psarray = (PsArray) object;
- if (psarray.size() != BoundingBox.BBOX_ENTRIES) {
- return null;
- }
- this.fontBBox = new int[BoundingBox.BBOX_ENTRIES];
- for (int i = 0; i < psarray.size(); i++) {
- final Object arrayItem = psarray.get(i);
- if (arrayItem instanceof PsInteger) {
- final PsInteger psInteger = (PsInteger) arrayItem;
- final int itemValue = psInteger.intValue();
- this.fontBBox[i] = itemValue;
- } else {
- return null;
- }
- }
- return this.fontBBox;
- }
-
- /**
- * Parses and returns the StemV value from the font file.
- * @return The StemV value.
- */
- private int parseStemV() {
- final PsDictionary privateDict = getPrivateDictionary();
- if (privateDict == null) {
- return 0;
- }
- final PsObject object = privateDict.getItem("StdVW");
- if (object == null || ! (object instanceof PsArray)) {
- return 0;
- }
- final PsArray psArray = (PsArray) object;
- final Object item = psArray.get(0);
- if (! (item instanceof PsInteger)) {
- return 0;
- }
- return ((PsInteger) item).intValue();
- }
-
- /**
* Caches the FontDictionary in an instance variable for easier access.
* @return The font dictionary for the font file.
*/
@@ -230,51 +177,17 @@
}
/**
- * Returns the FontInfo dictionary.
- * @return The FontInfo dictionary, or null if it does not exist.
- */
- private PsDictionary getFontInfoDictionary() {
- final PsFontDictionary fontDictionary = this.getFontDictionary();
- if (fontDictionary == null) {
- return null;
- }
- final PsObject psObject = fontDictionary.getItem("FontInfo");
- if (psObject == null) {
- return null;
- }
- if (psObject instanceof PsDictionary) {
- return (PsDictionary) psObject;
- }
- throw new IllegalStateException("FontInfo expected to be a PsDictionary");
- }
-
- /**
* Returns the private dictionary portion of the font file.
* @return The private dictionary portion of the font file.
*/
- private PsDictionary getPrivateDictionary() {
- final PsObject privateDict = getFontDictionary().getItem("Private");
- if (privateDict == null
- || ! (privateDict instanceof PsDictionary)) {
+ private PsPrivateDictionary getPrivateDictionary() {
+ if (this.fontDictionary == null) {
return null;
}
- return (PsDictionary) privateDict;
+ return this.fontDictionary.getPrivateDictionary();
}
/**
- * Returns the metrics dictionary portion of the font file.
- * @return The metrics dictionary portion of the font file.
- */
- PsDictionary getMetricsDictionary() {
- final PsObject metricsDict = getFontDictionary().getItem("Metrics");
- if (metricsDict == null
- || ! (metricsDict instanceof PsDictionary)) {
- return null;
- }
- return (PsDictionary) metricsDict;
- }
-
- /**
* Returns the full length of the raw font file.
* @return int the raw file length
*/
@@ -411,7 +324,7 @@
public int[] getFontBBox() {
if (this.fontBBox == null) {
parseDetail();
- this.fontBBox = parseFontBBox();
+ this.fontBBox = getFontDictionary().getFontBBox();
if (this.fontBBox == null) {
this.getLogger().error("Unable to parse Font BBox:\n"
+ " " + this.getReader().getDescription().toString());
@@ -425,15 +338,11 @@
* @return The stemV value.
*/
public int getStemV() {
- if (this.stemV == 0) {
- parseDetail();
- this.stemV = parseStemV();
- if (this.stemV == 0) {
- this.getLogger().error("Unable to parse StemV:\n"
- + " " + this.getReader().getDescription().toString());
- }
+ final PsPrivateDictionary privateDict = this.getPrivateDictionary();
+ if (privateDict == null) {
+ return 0;
}
- return this.stemV;
+ return privateDict.getStdVW().intValue();
}
/**
@@ -472,8 +381,7 @@
if (this.fontDictionary == null) {
return null;
}
- final PsObject psObject = this.fontDictionary.getItem("FontName");
- return psObject.toString();
+ return this.fontDictionary.getFontName();
}
/**
@@ -481,12 +389,11 @@
* @return The PostScript name of this font.
*/
public String getFamilyName() {
- final PsDictionary fontInfo = this.getFontInfoDictionary();
+ final PsFontInfoDictionary fontInfo = getFontDictionary().getFontInfoDictionary();
if (fontInfo == null) {
return null;
}
- final PsObject psObject = this.fontDictionary.getItem("FamilyName");
- return psObject.toString();
+ return fontInfo.getFamilyName();
}
/**
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/PsDictionary.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/PsDictionary.java 2008-07-18 00:49:26 UTC (rev 10612)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/PsDictionary.java 2008-07-18 02:12:39 UTC (rev 10613)
@@ -28,8 +28,7 @@
package org.foray.ps;
-import org.foray.common.StringUtil;
-
+import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
@@ -257,7 +256,7 @@
final PsObject object = this.getItem(key);
if (object == null
|| ! (object instanceof PsString)) {
- return StringUtil.EMPTY_STRING;
+ return null;
}
final PsString string = (PsString) object;
return string.getValue();
@@ -273,10 +272,42 @@
final PsObject object = this.getItem(key);
if (object == null
|| ! (object instanceof PsName)) {
- return StringUtil.EMPTY_STRING;
+ return null;
}
final PsName string = (PsName) object;
return string.getValue();
}
+ /**
+ * Returns a value expected to be a Number from this dictionary.
+ * @param key The key to the expected Number value.
+ * @return The value for <code>key</code>, if it is found and is a {@link PsNumber}, or null
+ * otherwise.
+ */
+ public BigDecimal getNumber(final String key) {
+ final PsObject object = this.getItem(key);
+ if (object == null
+ || ! (object instanceof PsNumber)) {
+ return null;
+ }
+ final PsNumber number = (PsNumber) object;
+ return number.getValue();
+ }
+
+ /**
+ * Returns a value expected to be a Boolean from this dictionary.
+ * @param key The key to the expected Boolean value.
+ * @return The value for <code>key</code>, if it is found and is a {@link PsBoolean}, or null
+ * otherwise.
+ */
+ public Boolean getBoolean(final String key) {
+ final PsObject object = this.getItem(key);
+ if (object == null
+ || ! (object instanceof PsBoolean)) {
+ return null;
+ }
+ final PsBoolean theBoolean = (PsBoolean) object;
+ return theBoolean.getValue();
+ }
+
}
Added: trunk/foray/foray-ps/src/java/org/foray/ps/PsDictionaryWrapper.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/PsDictionaryWrapper.java (rev 0)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/PsDictionaryWrapper.java 2008-07-18 02:12:39 UTC (rev 10613)
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2008 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.ps;
+
+/**
+ * Abstract superclass for classes that wrap {@link PsDictionary} and provide specialized methods.
+ */
+public abstract class PsDictionaryWrapper {
+
+ /** The wrapped dictionary instance. */
+ private PsDictionary wrappedDictionary;
+
+ /**
+ * Constructor.
+ * @param dictionary The wrapped dictionary instance.
+ */
+ public PsDictionaryWrapper(final PsDictionary dictionary) {
+ if (dictionary == null) {
+ throw new NullPointerException("Wrapped dictionary cannot be null.");
+ }
+ this.wrappedDictionary = dictionary;
+ }
+
+ /**
+ * Returns the wrapped dictionary.
+ * @return The wrapped dictionary instance.
+ */
+ public PsDictionary getWrappedDictionary() {
+ return this.wrappedDictionary;
+ }
+
+}
Property changes on: trunk/foray/foray-ps/src/java/org/foray/ps/PsDictionaryWrapper.java
___________________________________________________________________
Added: svn:keywords
+ "Author Id Rev Date URL"
Added: svn:eol-style
+ native
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/type1/PsFontDictionary.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/type1/PsFontDictionary.java 2008-07-18 00:49:26 UTC (rev 10612)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/type1/PsFontDictionary.java 2008-07-18 02:12:39 UTC (rev 10613)
@@ -28,44 +28,106 @@
package org.foray.ps.type1;
+import org.foray.ps.PsArray;
import org.foray.ps.PsDictionary;
+import org.foray.ps.PsDictionaryWrapper;
+import org.foray.ps.PsInteger;
import org.foray.ps.PsObject;
+import org.axsl.ps.BoundingBox;
+
/**
* Wrapper around a {@link PsDictionary} instance providing some convenience methods for Type 1
* fonts.
*/
-public class PsFontDictionary {
+public class PsFontDictionary extends PsDictionaryWrapper {
- /** The wrapped dictionary instance. */
- private PsDictionary wrappedDictionary;
-
/**
* Constructor.
* @param dictionary The wrapped dictionary instance.
*/
public PsFontDictionary(final PsDictionary dictionary) {
- if (dictionary == null) {
- throw new NullPointerException("Wrapped dictionary cannot be null.");
+ super(dictionary);
+ }
+
+ /**
+ * Returns the /FontName for this font dictionary.
+ * @return The /FontName.
+ */
+ public String getFontName() {
+ return this.getWrappedDictionary().getName("FontName");
+ }
+
+ /**
+ * Parses and returns the font bounding box.
+ * @return The font bbox.
+ */
+ public int[] getFontBBox() {
+ final Object object = this.getWrappedDictionary().getItem("FontBBox");
+ if (! (object instanceof PsArray)) {
+ return null;
}
- this.wrappedDictionary = dictionary;
+ final PsArray psarray = (PsArray) object;
+ if (psarray.size() != BoundingBox.BBOX_ENTRIES) {
+ return null;
+ }
+ final int[] fontBBox = new int[BoundingBox.BBOX_ENTRIES];
+ for (int i = 0; i < psarray.size(); i++) {
+ final Object arrayItem = psarray.get(i);
+ if (arrayItem instanceof PsInteger) {
+ final PsInteger psInteger = (PsInteger) arrayItem;
+ final int itemValue = psInteger.intValue();
+ fontBBox[i] = itemValue;
+ } else {
+ return null;
+ }
+ }
+ return fontBBox;
}
/**
- * Return the value for a given key from the wrapped dictionary.
- * @param key The key whose value should be retrieved.
- * @return The value.
+ * Returns the FontInfo dictionary.
+ * @return The FontInfo dictionary, or null if it does not exist.
*/
- public PsObject getItem(final String key) {
- return this.wrappedDictionary.getItem(key);
+ public PsFontInfoDictionary getFontInfoDictionary() {
+ final PsObject psObject = getWrappedDictionary().getItem("FontInfo");
+ if (psObject == null) {
+ return null;
+ }
+ if (psObject instanceof PsDictionary) {
+ return new PsFontInfoDictionary((PsDictionary) psObject);
+ }
+ throw new IllegalStateException("/FontInfo expected to be a PsDictionary");
}
/**
- * Returns the /FontName for this font dictionary.
- * @return The /FontName.
+ * Returns the Private dictionary.
+ * @return The Private dictionary, or null if it does not exist.
*/
- public String getFontName() {
- return this.wrappedDictionary.getName("FontName");
+ public PsPrivateDictionary getPrivateDictionary() {
+ final PsObject psObject = getWrappedDictionary().getItem("Private");
+ if (psObject == null) {
+ return null;
+ }
+ if (psObject instanceof PsDictionary) {
+ return new PsPrivateDictionary((PsDictionary) psObject);
+ }
+ throw new IllegalStateException("/Private expected to be a PsDictionary");
}
+ /**
+ * Returns the Metrics dictionary.
+ * @return The Metrics dictionary, or null if it does not exist.
+ */
+ public PsMetricsDictionary getMetricsDictionary() {
+ final PsObject psObject = getWrappedDictionary().getItem("Metrics");
+ if (psObject == null) {
+ return null;
+ }
+ if (psObject instanceof PsDictionary) {
+ return new PsMetricsDictionary((PsDictionary) psObject);
+ }
+ throw new IllegalStateException("/Metrics expected to be a PsDictionary");
+ }
+
}
Added: trunk/foray/foray-ps/src/java/org/foray/ps/type1/PsFontInfoDictionary.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/type1/PsFontInfoDictionary.java (rev 0)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/type1/PsFontInfoDictionary.java 2008-07-18 02:12:39 UTC (rev 10613)
@@ -0,0 +1,149 @@
+/*
+ * Copyright 2008 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.ps.type1;
+
+import org.foray.ps.PsDictionary;
+import org.foray.ps.PsDictionaryWrapper;
+
+import java.math.BigDecimal;
+
+/**
+ * Wrapper around a {@link PsDictionary} instance providing some convenience methods for Type 1
+ * fonts.
+ */
+public class PsFontInfoDictionary extends PsDictionaryWrapper {
+
+ /** Key to the "version" entry. */
+ public static final String VERSION_KEY = "version";
+
+ /** Key to the "Notice" entry. */
+ public static final String NOTICE_KEY = "Notice";
+
+ /** Key to the "FullName" entry. */
+ public static final String FULL_NAME_KEY = "FullName";
+
+ /** Key to the "FamilyName" entry. */
+ public static final String FAMILY_NAME_KEY = "FamilyName";
+
+ /** Key to the "Weight" entry. */
+ public static final String WEIGHT_KEY = "Weight";
+
+ /** Key to the "ItalicAngle" entry. */
+ public static final String ITALIC_ANGLE_KEY = "ItalicAngle";
+
+ /** Key to the "isFixedPitch" entry. */
+ public static final String IS_FIXED_PITCH_KEY = "isFixedPitch";
+
+ /** Key to the "UnderlinePosition" entry. */
+ public static final String UNDERLINE_POSITION_KEY = "UnderlinePosition";
+
+ /** Key to the "UnderlineThickness" entry. */
+ public static final String UNDERLINE_THICKNESS_KEY = "UnderlineThickness";
+
+ /**
+ * Constructor.
+ * @param dictionary The wrapped dictionary instance.
+ */
+ public PsFontInfoDictionary(final PsDictionary dictionary) {
+ super(dictionary);
+ }
+
+ /**
+ * Returns the /version for this font dictionary.
+ * @return The /version.
+ */
+ public String getVersion() {
+ return this.getWrappedDictionary().getString(PsFontInfoDictionary.VERSION_KEY);
+ }
+
+ /**
+ * Returns the /Notice for this font dictionary.
+ * @return The /Notice.
+ */
+ public String getNotice() {
+ return this.getWrappedDictionary().getString(PsFontInfoDictionary.NOTICE_KEY);
+ }
+
+ /**
+ * Returns the /FullName for this font dictionary.
+ * @return The /FullName.
+ */
+ public String getFullName() {
+ return this.getWrappedDictionary().getString(PsFontInfoDictionary.FULL_NAME_KEY);
+ }
+
+ /**
+ * Returns the /FamilyName for this font dictionary.
+ * @return The /FamilyName.
+ */
+ public String getFamilyName() {
+ return this.getWrappedDictionary().getString(PsFontInfoDictionary.FAMILY_NAME_KEY);
+ }
+
+ /**
+ * Returns the /Weight for this font dictionary.
+ * @return The /Weight.
+ */
+ public String getWeight() {
+ return this.getWrappedDictionary().getString(PsFontInfoDictionary.WEIGHT_KEY);
+ }
+
+ /**
+ * Returns the /ItalicAngle for this font dictionary.
+ * @return The /ItalicAngle.
+ */
+ public BigDecimal getItalicAngle() {
+ return this.getWrappedDictionary().getNumber(PsFontInfoDictionary.ITALIC_ANGLE_KEY);
+ }
+
+ /**
+ * Returns the /isFixedPitch for this font dictionary.
+ * @return The /isFixedPitch.
+ */
+ public boolean isFixedPitch() {
+ return this.getWrappedDictionary().getBoolean(PsFontInfoDictionary.IS_FIXED_PITCH_KEY);
+ }
+
+ /**
+ * Returns the /UnderlinePosition for this font dictionary.
+ * @return The /UnderlinePosition.
+ */
+ public BigDecimal getUnderlinePosition() {
+ return this.getWrappedDictionary().getNumber(PsFontInfoDictionary.UNDERLINE_POSITION_KEY);
+ }
+
+ /**
+ * Returns the /UnderlineThickness for this font dictionary.
+ * @return The /UnderlineThickness.
+ */
+ public BigDecimal getUnderlineThickness() {
+ return this.getWrappedDictionary().getNumber(PsFontInfoDictionary.UNDERLINE_THICKNESS_KEY);
+ }
+
+}
Property changes on: trunk/foray/foray-ps/src/java/org/foray/ps/type1/PsFontInfoDictionary.java
___________________________________________________________________
Added: svn:keywords
+ "Author Id Rev Date URL"
Added: svn:eol-style
+ native
Added: trunk/foray/foray-ps/src/java/org/foray/ps/type1/PsMetricsDictionary.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/type1/PsMetricsDictionary.java (rev 0)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/type1/PsMetricsDictionary.java 2008-07-18 02:12:39 UTC (rev 10613)
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2008 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.ps.type1;
+
+import org.foray.ps.PsDictionary;
+import org.foray.ps.PsDictionaryWrapper;
+
+public class PsMetricsDictionary extends PsDictionaryWrapper {
+
+ /**
+ * Constructor.
+ * @param dictionary The wrapped dictionary instance.
+ */
+ public PsMetricsDictionary(final PsDictionary dictionary) {
+ super(dictionary);
+ }
+
+}
Property changes on: trunk/foray/foray-ps/src/java/org/foray/ps/type1/PsMetricsDictionary.java
___________________________________________________________________
Added: svn:keywords
+ "Author Id Rev Date URL"
Added: svn:eol-style
+ native
Added: trunk/foray/foray-ps/src/java/org/foray/ps/type1/PsPrivateDictionary.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/type1/PsPrivateDictionary.java (rev 0)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/type1/PsPrivateDictionary.java 2008-07-18 02:12:39 UTC (rev 10613)
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2008 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.ps.type1;
+
+import org.foray.ps.PsArray;
+import org.foray.ps.PsDictionary;
+import org.foray.ps.PsDictionaryWrapper;
+import org.foray.ps.PsNumber;
+import org.foray.ps.PsObject;
+
+import java.math.BigDecimal;
+
+public class PsPrivateDictionary extends PsDictionaryWrapper {
+
+ /** Key to the "StdVW" entry. */
+ public static final String STD_VW_KEY = "StdVW";
+
+ /**
+ * Constructor.
+ * @param dictionary The wrapped dictionary instance.
+ */
+ public PsPrivateDictionary(final PsDictionary dictionary) {
+ super(dictionary);
+ }
+
+ /**
+ * Returns the StdVW value from the font file.
+ * @return The StdVW value, or null if it does not exist.
+ */
+ public BigDecimal getStdVW() {
+ final PsObject object = getWrappedDictionary().getItem(PsPrivateDictionary.STD_VW_KEY);
+ if (object == null || ! (object instanceof PsArray)) {
+ return null;
+ }
+ final PsArray psArray = (PsArray) object;
+ final Object item = psArray.get(0);
+ if (! (item instanceof PsNumber)) {
+ throw new IllegalStateException("/StdVW expected to be a PsNumber");
+ }
+ return ((PsNumber) item).getValue();
+ }
+
+}
Property changes on: trunk/foray/foray-ps/src/java/org/foray/ps/type1/PsPrivateDictionary.java
___________________________________________________________________
Added: svn:keywords
+ "Author Id Rev Date URL"
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|