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:

See Also:
Serialized Form
  • Nested Class Summary

    Nested Classes 
    Modifier and Type Class Description
    static class  Panose.Field
    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.
    Panose getBold()
    Returns the bold version of this Panose instance.
    byte getElement​(int index)
    Returns a given element from the underlying Panose array.
    byte getElement​(Panose.Field field)
    Returns a given element from the underlying Panose array.
    Panose getItalic()
    Returns the italic version of this Panose instance.
    byte[] getPanoseArray()
    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.
    java.lang.String toString()
    static java.lang.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(byte[])
    • 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:
      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, 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 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:
      toString in class java.lang.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.