Class Panose
java.lang.Object
org.docx4j.fonts.foray.font.format.Panose
- All Implemented Interfaces:
Serializable
A PANOSE-1 classification number.
References:
- The TTF OS/2 Table doc
- Panose 2.0 White Paper
- The Panose Typeface-Matching System
- Michael S. De Laurentis, PANOSE 1.0 Core Mapper Services, Hewlett-Packard Document EWC-93-0023b, Hewlett-Packard Corporation, 101 Stewart, Suite 700, Seattle, WA 98101 (1993).
- The "Grey Book"
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnumeration of the fields that comprise a PANOSE description. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final byteConstant indicating the minimum italic value for the letterform field.private static final byte[]An array of weights indicating that all elements in a comparison between two PANOSE values shall be considered to be of the same weight.private byte[]The encapsulated array of PANOSE numbers.private static final longprivate static final byteConstant indicating the minimum bold value for the weight field. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongdifference(Panose otherPanose, byte[] weights) Computes the weighted "closeness" of another Panose to this value.static PanoseforceInstance(byte[] panoseArray) Creates a new Panose instance without any error checking.getBold()Returns the bold version of this Panose instance.bytegetElement(int index) Returns a given element from the underlying Panose array.bytegetElement(Panose.Field field) Returns a given element from the underlying Panose array.Returns the italic version of this Panose instance.byte[]Returns a clone of the the array of bytes representing the PANOSE number.static PanosemakeInstance(byte[] panoseArray) Creates a new Panose instance, first checking it for validity.toString()private static StringtoString(byte[] panoseArray) Returns a String representation of a Panose array.private static voidvalidateWeights(byte[] weights) Examines an array of weights, throwing various unchecked exceptions if the data is not valid.static StringvalidPanose(byte[] panoseDescription) Tests the validity of a panose description.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
LETTERFORM_MIN_ITALIC
private static final byte LETTERFORM_MIN_ITALICConstant indicating the minimum italic value for the letterform field. This is based on an analysis of the MS ClearType Collection fonts:- consolas [ 2 11 6 9 2 2 4 3 2 4 ] bold 6 ital 3
- consolas-bold [ 2 11 7 9 2 2 4 3 2 4 ] bold 7 ital 3
- consolas-italic [ 2 11 6 9 2 2 4 10 2 4 ] bold 6 ital 10
- consolas-bolditalic [ 2 11 7 9 2 2 4 10 2 4 ] bold 7 ital 10
- cordianew [ 2 11 3 4 2 2 2 2 2 4 ] bold 3 ital 2
- cordianew-bolditalic [ 2 11 6 4 2 2 2 9 2 4 ] bold 6 ital 9
- calibri [ 2 15 5 2 2 2 4 3 2 4 ] bold 5 ital 3
- calibri-bold [ 2 15 7 2 3 4 4 3 2 4 ] bold 7 ital 3
- calibri-bolditalic [ 2 15 7 2 3 4 4 10 2 4 ] bold 7 ital 10
- constantia [ 2 3 6 2 5 3 6 3 3 3 ] bold 6 ital 3
- constantia-bold [ 2 3 7 2 6 3 6 3 3 3 ] bold 7 ital 3 (note the 6 at index 4)
- constantia-italic [ 2 3 6 2 5 3 6 10 3 3 ] bold 6 ital 10
- candara-bold [ 2 14 7 2 3 3 3 2 2 4 ] bold 7 ital 2
- candara-italic [ 2 14 5 2 3 3 3 9 2 4 ] bold 5 ital 9
- candara-bolditalic [ 2 14 7 2 3 3 3 9 2 4 ] bold 7 ital 9
- cambria-bold [ 2 4 8 3 5 4 6 3 2 4 ] bold 8 ital 3
- cambria-italic [ 2 4 5 3 5 4 6 10 2 4 ] bold 5 ital 10
- See Also:
-
WEIGHT_MIN_BOLD
private static final byte WEIGHT_MIN_BOLDConstant indicating the minimum bold value for the weight field. This is based on an analysis of the MS ClearType Collection fonts, which can be found atLETTERFORM_MIN_ITALIC.- See Also:
-
NEUTRAL_WEIGHTS
private static final byte[] NEUTRAL_WEIGHTSAn array of weights indicating that all elements in a comparison between two PANOSE values shall be considered to be of the same weight. -
panoseArray
private byte[] panoseArrayThe encapsulated array of PANOSE numbers.
-
-
Constructor Details
-
Panose
private Panose(byte[] panoseArray) Private Constructor. UsemakeInstance(byte[])to create an instance of this class.- Parameters:
panoseArray- The array of bytes recording the PANOSE classification.
-
-
Method Details
-
makeInstance
Creates a new Panose instance, first checking it for validity.- Parameters:
panoseArray- The array of bytes recording the PANOSE classification.- Returns:
- The newly-created instance.
- Throws:
FontException- IfpanoseArraycontains an illegal value.- See Also:
-
forceInstance
Creates a new Panose instance without any error checking.- Parameters:
panoseArray- The array of bytes recording the PANOSE classification.- Returns:
- The newly-created instance.
- See Also:
-
getPanoseArray
public byte[] getPanoseArray()Returns a clone of the the array of bytes representing the PANOSE number. To avoid the cost of this cloning operation, usegetElement(int)to obtain the value of individual elements in the array.- Returns:
- The PANOSE array.
-
getElement
public byte getElement(int index) Returns a given element from the underlying Panose array.- Parameters:
index- The index to the element desired.- Returns:
- The value of the element at
index.
-
getElement
Returns a given element from the underlying Panose array.- Parameters:
field- The field for which the value is desired.- Returns:
- The value of the element at
field.
-
difference
Computes the weighted "closeness" of another Panose to this value.- Parameters:
otherPanose- Another Panose instance which is being compared to this.weights- 10-element byte array of weights that should be used for each of the elements in the comparison. Values in this array must be between 0 and 127 inclusive. (This constant is documented at http://www.w3.org/Fonts/Panose/pan2.html#StaticDigits). Use null if all elements are to be weighted equally.- Returns:
- The weighted difference between the two Panose values. A smaller value indicates that the two values are closer, and a larger value indicates that they are farther apart.
-
validateWeights
private static void validateWeights(byte[] weights) Examines an array of weights, throwing various unchecked exceptions if the data is not valid.- Parameters:
weights- The array of weights to be tested.
-
validPanose
Tests the validity of a panose description.- Parameters:
panoseDescription- The panose values to be tested.- Returns:
- Null for a valid PANOSE description. For an invalid PANOSE description, returns a descriptive message indicating which element is invalid.
-
toString
-
toString
Returns a String representation of a Panose array.- Parameters:
panoseArray- The Panose array to be expressed as a String.- Returns:
- The String representation of
panoseArray.
-
getBold
Returns the bold version of this Panose instance.- Returns:
- If this already describes a bold font, returns this. Otherwise, returns a new Panose instance that is identical to this, except describing a bold font.
-
getItalic
Returns the italic version of this Panose instance.- Returns:
- If this already describes an italic font, returns this. Otherwise, returns a new Panose instance that is identical to this, except describing an italic font.
-