diff options
author | Jeremias Maerki <jeremias@apache.org> | 2006-03-16 13:51:14 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2006-03-16 13:51:14 +0000 |
commit | e6d53d8a9c84b6447f3db4b2b36576d418df1a4a (patch) | |
tree | 7c9c4dcaa414499c66c262383108879e5007c815 /src/java/org/apache/fop/util | |
parent | de1255b13f15201dbba5d6c282cded7719e3dc8f (diff) | |
download | xmlgraphics-fop-e6d53d8a9c84b6447f3db4b2b36576d418df1a4a.tar.gz xmlgraphics-fop-e6d53d8a9c84b6447f3db4b2b36576d418df1a4a.zip |
Added support for fixed-width spaces and kerning.
Note: letter-spacing is still implemented as before. Fixing this cannot be done without looking at space resolution as a whole on inline level.
The Character area tree object is now deprecated. Normal Text objects should be used to keep renderers simpler.
Introduced FontResolver interface to remove the dependency of FOUserAgent into the font package.
Added kerning information to the base14 fonts, Helvetica and Times. By default it is not used to keep the status-quo. Enable base14 kerning through the FOUserAgent (FopFactory after the API finalization).
Restored the production of EPS images in PDF output as PostScript XObjects.
Restored functionality for a more compact format for the area tree renderer to save space.
LayoutEngineTester slightly changed to allow for configuration values from the XML file. For now, only enabling base14 kerning is supported.
Removed duplicate offset variable in SpaceArea.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@386327 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/util')
-rw-r--r-- | src/java/org/apache/fop/util/CharUtilities.java | 74 |
1 files changed, 56 insertions, 18 deletions
diff --git a/src/java/org/apache/fop/util/CharUtilities.java b/src/java/org/apache/fop/util/CharUtilities.java index 43c2c3e41..f200c3e2f 100644 --- a/src/java/org/apache/fop/util/CharUtilities.java +++ b/src/java/org/apache/fop/util/CharUtilities.java @@ -1,5 +1,5 @@ /* - * Copyright 1999-2005 The Apache Software Foundation. + * Copyright 1999-2006 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,9 +53,13 @@ public class CharUtilities { public static final int XMLWHITESPACE = 4; + /** normal space */ + public static final char SPACE = '\u0020'; + /** non-breaking space */ + public static final char NBSPACE = '\u00A0'; /** zero-width space */ public static final char ZERO_WIDTH_SPACE = '\u200B'; - /** zero-width no-break space */ + /** zero-width no-break space (= byte order mark) */ public static final char ZERO_WIDTH_NOBREAK_SPACE = '\uFEFF'; @@ -89,22 +93,31 @@ public class CharUtilities { * @return True if the character is a normal space */ public static boolean isBreakableSpace(char c) { - return (c == ' ' - || (c >= '\u2000' && c <= '\u200B')); -// c == '\u2000' // en quad -// c == '\u2001' // em quad -// c == '\u2002' // en space -// c == '\u2003' // em space -// c == '\u2004' // three-per-em space -// c == '\u2005' // four--per-em space -// c == '\u2006' // six-per-em space -// c == '\u2007' // figure space -// c == '\u2008' // punctuation space -// c == '\u2009' // thin space -// c == '\u200A' // hair space -// c == '\u200B' // zero width space + return (c == SPACE || isFixedWidthSpace(c)); } - + + /** + * Method to determine if the character is a (breakable) fixed-width space. + * @param c the character to check + * @return true if the character has a fixed-width + */ + public static boolean isFixedWidthSpace(char c) { + return (c >= '\u2000' && c <= '\u200B') || c == '\u3000'; +// c == '\u2000' // en quad +// c == '\u2001' // em quad +// c == '\u2002' // en space +// c == '\u2003' // em space +// c == '\u2004' // three-per-em space +// c == '\u2005' // four--per-em space +// c == '\u2006' // six-per-em space +// c == '\u2007' // figure space +// c == '\u2008' // punctuation space +// c == '\u2009' // thin space +// c == '\u200A' // hair space +// c == '\u200B' // zero width space +// c == '\u3000' // ideographic space + } + /** * Method to determine if the character is a nonbreaking * space. @@ -113,7 +126,7 @@ public class CharUtilities { */ public static boolean isNonBreakableSpace(char c) { return - (c == '\u00A0' // no-break space + (c == NBSPACE // no-break space || c == '\u202F' // narrow no-break space || c == '\u3000' // ideographic space || c == ZERO_WIDTH_NOBREAK_SPACE); // zero width no-break space @@ -141,5 +154,30 @@ public class CharUtilities { boolean ret = (isBreakableSpace(c) || isNonBreakableSpace(c)); return ret; } + + /** + * Indicates whether a character is classified as "Alphabetic" by the Unicode standard. + * @param ch the character + * @return true if the character is "Alphabetic" + */ + public static boolean isAlphabetic(char ch) { + //http://www.unicode.org/Public/UNIDATA/UCD.html#Alphabetic + //Generated from: Other_Alphabetic + Lu + Ll + Lt + Lm + Lo + Nl + int generalCategory = Character.getType(ch); + switch (generalCategory) { + case Character.UPPERCASE_LETTER: //Lu + case Character.LOWERCASE_LETTER: //Ll + case Character.TITLECASE_LETTER: //Lt + case Character.MODIFIER_LETTER: //Lm + case Character.OTHER_LETTER: //Lo + case Character.LETTER_NUMBER: //Nl + return true; + default: + //TODO if (ch in Other_Alphabetic) return true; (Probably need ICU4J for that) + //Other_Alphabetic contains mostly more exotic characters + return false; + } + } + } |