[aXSL-commit] SF.net SVN: axsl: [465] trunk/axsl/axsl-font/src/java/org/axsl/font
An API for XSL-FO.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2006-04-28 20:28:44
|
Revision: 465 Author: victormote Date: 2006-04-28 13:28:33 -0700 (Fri, 28 Apr 2006) ViewCVS: http://svn.sourceforge.net/axsl/?rev=465&view=rev Log Message: ----------- 1. For font-selection, require a value representing a font-selection-strategy. 2. Add static method to FontUtility to convert String font-selection-strategy values to integral representations. Modified Paths: -------------- trunk/axsl/axsl-font/src/java/org/axsl/font/Font.java trunk/axsl/axsl-font/src/java/org/axsl/font/FontConsumer.java trunk/axsl/axsl-font/src/java/org/axsl/font/FontUtility.java Modified: trunk/axsl/axsl-font/src/java/org/axsl/font/Font.java =================================================================== --- trunk/axsl/axsl-font/src/java/org/axsl/font/Font.java 2006-04-28 16:56:48 UTC (rev 464) +++ trunk/axsl/axsl-font/src/java/org/axsl/font/Font.java 2006-04-28 20:28:33 UTC (rev 465) @@ -122,6 +122,12 @@ /** Font-stretch constant indicating no preference. */ public static final byte FONT_STRETCH_ANY = Byte.MIN_VALUE; + /** font-selection-strategy constant indicating "character-by-character". */ + public static final byte FONT_SELECTION_CBC = 0; + + /** font-selection-strategy constant indicating "auto". */ + public static final byte FONT_SELECTION_AUTO = 1; + /** Font-complexity constant indicating that the complexity is not known. */ public static final byte FONT_COMPLEXITY_UNKNOWN = -1; Modified: trunk/axsl/axsl-font/src/java/org/axsl/font/FontConsumer.java =================================================================== --- trunk/axsl/axsl-font/src/java/org/axsl/font/FontConsumer.java 2006-04-28 16:56:48 UTC (rev 464) +++ trunk/axsl/axsl-font/src/java/org/axsl/font/FontConsumer.java 2006-04-28 20:28:33 UTC (rev 465) @@ -44,6 +44,9 @@ * Accepts the client's description of the desired font, and returns the * best-fitting Font found, using the algorithm specified by the XSL-FO * 1.1 Standard. + * @param selectionStrategy One of {@link Font#FONT_SELECTION_CBC} (for + * "character-by-character" selection) or {@link Font#FONT_SELECTION_AUTO} + * (for "auto" selection"). * @param familyList An array of possible font family names from which to * choose the font. * The most desirable font-family name is listed first, then the next @@ -94,13 +97,15 @@ * @see #selectFontCSS * @throws FontException if there is no matching font. */ - public FontUse selectFontXSL(String[] familyList, int style, int weight, - int variant, int stretch, int size, int codePoint) - throws FontException; + public FontUse selectFontXSL(int selectionStrategy, String[] familyList, + int style, int weight, int variant, int stretch, int size, + int codePoint) throws FontException; /** * The same as {@link #selectFontXSL}, except that the algorithm specified * by CSS 2.1 is used instead. + * Note also that CSS has no concept of a font-selection-strategy as XSL-FO + * does. * @param familyList See {@link #selectFontXSL}. * Client applications may use {@link FontUtility#cssFontFamily(String)} to * convert String input into the value expected here. Modified: trunk/axsl/axsl-font/src/java/org/axsl/font/FontUtility.java =================================================================== --- trunk/axsl/axsl-font/src/java/org/axsl/font/FontUtility.java 2006-04-28 16:56:48 UTC (rev 464) +++ trunk/axsl/axsl-font/src/java/org/axsl/font/FontUtility.java 2006-04-28 20:28:33 UTC (rev 465) @@ -38,6 +38,34 @@ } /** + * Converts XSL-FO String input for font-selection-strategy into a value + * expected by {@link FontConsumer#selectFontXSL(int, String[], int, int, + * int, int, int, int)}. + * @param input The XSL-FO-style String to be converted. + * @param lowerCaseOnly Set to true to insist that all input values be + * lowercase. + * @return One of {@link Font#FONT_SELECTION_CBC} or + * {@link Font#FONT_SELECTION_AUTO}. + * For invalid input, -1. + */ + public static byte foFontSelectionStrategy(String input, + boolean lowerCaseOnly) { + if (input == null) { + return -1; + } + if (! lowerCaseOnly) { + input.toLowerCase(); + } + if (input.equals("character-by-character")) { + return Font.FONT_SELECTION_CBC; + } + if (input.equals("auto")) { + return Font.FONT_SELECTION_AUTO; + } + return -1; + } + + /** * Converts a CSS2-style String input for font-style into a value expected * by {@link FontConsumer#selectFontCSS(String[], int, int, int, int, int, * int)}. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |