Class Panose

java.lang.Object
org.docx4j.fonts.foray.font.format.Panose
All Implemented Interfaces:
Serializable

public final class Panose extends Object implements Serializable
A PANOSE-1 classification number.

References:

See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Enumeration of the fields that comprise a PANOSE description.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final byte
    Constant 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 long
     
    private static final byte
    Constant indicating the minimum bold value for the weight field.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Panose(byte[] panoseArray)
    Private Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    difference(Panose otherPanose, byte[] weights)
    Computes the weighted "closeness" of another Panose to this value.
    static Panose
    forceInstance(byte[] panoseArray)
    Creates a new Panose instance without any error checking.
    Returns the bold version of this Panose instance.
    byte
    getElement(int index)
    Returns a given element from the underlying Panose array.
    byte
    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 Panose
    makeInstance(byte[] panoseArray)
    Creates a new Panose instance, first checking it for validity.
    private static String
    toString(byte[] panoseArray)
    Returns a String representation of a Panose array.
    private static void
    validateWeights(byte[] weights)
    Examines an array of weights, throwing various unchecked exceptions if the data is not valid.
    static String
    validPanose(byte[] panoseDescription)
    Tests the validity of a panose description.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • LETTERFORM_MIN_ITALIC

      private static final byte LETTERFORM_MIN_ITALIC
      Constant 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_BOLD
      Constant 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 at LETTERFORM_MIN_ITALIC.
      See Also:
    • NEUTRAL_WEIGHTS

      private static final byte[] NEUTRAL_WEIGHTS
      An 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[] panoseArray
      The encapsulated array of PANOSE numbers.
  • Constructor Details

    • Panose

      private Panose(byte[] panoseArray)
      Private Constructor. Use makeInstance(byte[]) to create an instance of this class.
      Parameters:
      panoseArray - The array of bytes recording the PANOSE classification.
  • Method Details

    • makeInstance

      public static Panose makeInstance(byte[] panoseArray)
      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 - If panoseArray contains an illegal value.
      See Also:
    • forceInstance

      public static Panose forceInstance(byte[] panoseArray)
      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, use getElement(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

      public byte getElement(Panose.Field field)
      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

      public long difference(Panose otherPanose, byte[] weights)
      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

      public static 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 String toString()
      Overrides:
      toString in class Object
    • toString

      private static String toString(byte[] panoseArray)
      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

      public Panose 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

      public Panose 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.