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.
  • 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.
    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
  • 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.
    • 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
    • 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.