aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache/fop/fo/PropertyManager.java
diff options
context:
space:
mode:
authorKeiron Liddle <keiron@apache.org>2002-07-23 11:06:51 +0000
committerKeiron Liddle <keiron@apache.org>2002-07-23 11:06:51 +0000
commitf6a0559f5fe65405fa202434fe514de7a0f372bc (patch)
tree95c06a67fc1eae9b0f36bf885994ec04b415b96d /src/org/apache/fop/fo/PropertyManager.java
parent7f263c27804a4882f33f5a423150d5cc52448361 (diff)
downloadxmlgraphics-fop-f6a0559f5fe65405fa202434fe514de7a0f372bc.tar.gz
xmlgraphics-fop-f6a0559f5fe65405fa202434fe514de7a0f372bc.zip
cleaned up the font state a bit
exception only thrown after setup as exception indicates invalid setup only font name key and size are set on the area tree FontState used as handler to get metric info git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@195024 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache/fop/fo/PropertyManager.java')
-rw-r--r--src/org/apache/fop/fo/PropertyManager.java36
1 files changed, 25 insertions, 11 deletions
diff --git a/src/org/apache/fop/fo/PropertyManager.java b/src/org/apache/fop/fo/PropertyManager.java
index 71a902539..2599cb0df 100644
--- a/src/org/apache/fop/fo/PropertyManager.java
+++ b/src/org/apache/fop/fo/PropertyManager.java
@@ -14,6 +14,7 @@ import org.apache.fop.datatypes.FODimension;
import org.apache.fop.fo.TextInfo; // should be somewhere else probably...
import org.apache.fop.layout.FontState;
import org.apache.fop.layout.FontInfo;
+import org.apache.fop.layout.FontMetric;
import org.apache.fop.layout.BorderAndPadding;
import org.apache.fop.layout.MarginProps;
import org.apache.fop.layout.MarginInlineProps;
@@ -68,7 +69,7 @@ public class PropertyManager {
}
- public FontState getFontState(FontInfo fontInfo) throws FOPException {
+ public FontState getFontState(FontInfo fontInfo) {
if (fontState == null) {
if (fontInfo == null) {
fontInfo = m_fontInfo;
@@ -78,14 +79,33 @@ public class PropertyManager {
}
String fontFamily = properties.get("font-family").getString();
String fontStyle = properties.get("font-style").getString();
- String fontWeight = properties.get("font-weight").getString();
+ String fw = properties.get("font-weight").getString();
+ int fontWeight = 400;
+ if(fw.equals("bolder")) {
+ // +100 from inherited
+ } else if(fw.equals("lighter")) {
+ // -100 from inherited
+ } else {
+ try {
+ fontWeight = Integer.parseInt(fw);
+ } catch(NumberFormatException nfe) {
+ }
+ }
+ fontWeight = ((int)fontWeight / 100) * 100;
+ if(fontWeight < 100) {
+ fontWeight = 100;
+ } else if(fontWeight > 900) {
+ fontWeight = 900;
+ }
+
// NOTE: this is incomplete. font-size may be specified with
// various kinds of keywords too
int fontSize = properties.get("font-size").getLength().mvalue();
int fontVariant = properties.get("font-variant").getEnum();
- // fontInfo is same for the whole FOP run but set in all FontState
- fontState = new FontState(fontInfo, fontFamily, fontStyle,
- fontWeight, fontSize, fontVariant);
+ String fname = fontInfo.fontLookup(fontFamily, fontStyle,
+ fontWeight);
+ FontMetric metrics = fontInfo.getMetricsFor(fname);
+ fontState = new FontState(fname, metrics, fontSize);
}
return fontState;
}
@@ -299,13 +319,7 @@ public class PropertyManager {
public TextInfo getTextLayoutProps(FontInfo fontInfo) {
if (textInfo == null) {
textInfo = new TextInfo();
- try {
textInfo.fs = getFontState(fontInfo);
- } catch (FOPException fopex) {
- /* log.error("Error setting FontState for characters: " +
- fopex.getMessage());*/
- // Now what should we do ???
- }
textInfo.color = properties.get("color").getColorType();
textInfo.verticalAlign =