Class Panose
java.lang.Object
org.docx4j.fonts.foray.font.format.Panose
- All Implemented Interfaces:
java.io.Serializable
public final class Panose
extends java.lang.Object
implements java.io.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:
- Serialized Form
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPanose.FieldEnumeration of the fields that comprise a PANOSE description. -
Method Summary
Modifier and Type Method Description longdifference(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.PanosegetBold()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.PanosegetItalic()Returns the italic version of this Panose instance.byte[]getPanoseArray()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.java.lang.StringtoString()static java.lang.StringvalidPanose(byte[] panoseDescription)Tests the validity of a panose description.
-
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(byte[])
-
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:
makeInstance(byte[])
-
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.
-
validPanose
public static java.lang.String validPanose(byte[] panoseDescription)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
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-
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.
-