Class Dict


  • public class Dict
    extends java.lang.Object
    Represents a DICT.

    Keys and values

    The inner classes Dict.IntegerValue, Dict.StringValue, Dict.NumbersValue, Dict.OffsetValue, Dict.OffsetSizeValue, and Dict.ROSValue must be used for values.

    The inner class Dict.Key provide objects which must be used for the keys. Those objects are actually subtypes of Dict.Key, with one class per type of value: Dict.IntegerKey, Dict.StringKey, Dict.NumbersKey, Dict.OffsetKey, Dict.OffsetSizeKey, and Dict.ROSKey.

    The various get methods take one of the Dict.Key objects and return the corresponding Dict.Value object from the dictionary. Optionally, if the key is not present in the dictionary but a default value exists, that value is returned.

    Streaming a dictionary

    Streaming a dictionary is a little bit involved, because some values are actually offsets to other portions of the stream. Our strategy is to first stream all the key/value pairs which are not offsets, using the stream method of the dictionary, and then to stream immediately dummy values for each key/value pair which contains an offset. Streaming each such key/value pair gives back a marker. For example, for a dictionary that contains a Dict.Key.FDSelect entry and a Dict.Key.CharStrings entry:

       dict.stream (...);
       int fdSelectMarker = Key.FDSelect.streamDummyValue (...);
       int charstringsMarker = Key.CharStrings.streamDummyValue (...);
     

    Later, when the actual offset is known (e.g. just before streaming the portion that is pointed to), the offsets can be fixed:

       Key.FDSelect.fixOffset (bb, fdSelectMarker, offsetForFdSelect);
       ...
       Key.CharStrings.fixOffset (bb, charstringsMarker, offsetForCharStrings);
     

    Values which are a combination of an offset and a size are handled similarly:

       int privateMarker = Key.Private.streamDummyValue (...);
       ...
       Key.Private.fixOffset (bb, marker2, offsetForPrivate);
       ...
       Key.Private.fixSize (bb, marker2, sizeOfPrivate);
     

    Note that the offsets being passed are stored directly. In particular the value passed to fixOffset must account for the base of the offset.

    Since the values that contains offsets are streamed by separate calls, it is necessary for the stream call to not stream those values, even if they are present in the dictionary. Another situation to solve is that some dictionaries must be streamed with some key first. To solve both problems, the stream method takes a list of Key, and streams precisely those keys which are present in the dictionary, in the order in which they appear in the list. This mechanism is also useful to stream only part of an existing dictionary.

    Synchronization

    Dict, Key and Value and their subclasses are immutable.

    • Constructor Summary

      Constructors 
      Constructor Description
      Dict​(double[] blues, double[] otherBlues, double[] familyBlues, double[] familyOtherBlues, java.lang.Double blueScale, java.lang.Double blueShift, java.lang.Integer bluefuzz, java.lang.Double stdHW, java.lang.Double stdVW, double[] stemSnapH, double[] stemSnapV, java.lang.Boolean forceBold, java.lang.Integer langGroup, java.lang.Double expansionFactor, java.lang.Integer initRandSeed, java.lang.Double nominalWidth, java.lang.Double defaultWidth)
      Construct a Dict with the supplied values.
      Dict​(Matrix matrix)
      Construct a Dict with the supplied values.
      Dict​(java.lang.String registry, java.lang.String ordering, int supplement, java.lang.String version, java.lang.String notice, java.lang.String copyright, java.lang.String fullname, java.lang.String fontname, java.lang.String familyName, java.lang.String weight, java.lang.Boolean fixedPitch, java.lang.Double italicAngle, java.lang.Double underlinePosition, java.lang.Double underlineThickness, java.lang.Integer paintType, java.lang.Integer uniqueID, Rect bbox, java.lang.Double strokewidth, int[] xuid, java.lang.String postscript, java.lang.Integer fsType, int[] baseFontBlend, java.lang.String baseFontName, Matrix fontMatrix)
      Construct a Dict with the supplied values.
    • Method Summary

      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Dict

        public Dict​(double[] blues,
                    double[] otherBlues,
                    double[] familyBlues,
                    double[] familyOtherBlues,
                    java.lang.Double blueScale,
                    java.lang.Double blueShift,
                    java.lang.Integer bluefuzz,
                    java.lang.Double stdHW,
                    java.lang.Double stdVW,
                    double[] stemSnapH,
                    double[] stemSnapV,
                    java.lang.Boolean forceBold,
                    java.lang.Integer langGroup,
                    java.lang.Double expansionFactor,
                    java.lang.Integer initRandSeed,
                    java.lang.Double nominalWidth,
                    java.lang.Double defaultWidth)
        Construct a Dict with the supplied values. No scaling is applied to the given values. They are assumed to be scaled in the cff's font units.
        Parameters:
        blues - If non-null, an array of blue values. If null, no blue values will be used.
        otherBlues - If non-null, an array of other blue values. They are not delta encoded. If null, no other blue values will be used.
        familyBlues - If non-null, an array of family blue values. They are not delta encoded. If null, no family blue values will be used.
        familyOtherBlues - If non-null, an array of family other blue values. They are not delta encoded. If null, no family other blue values will be used.
        blueScale - If non-null, the blue scale to be used. If null, the cff default (0.039625) is used.
        blueShift - If non-null, the blue shift to be used. If null, the cff default (7) is used.
        bluefuzz - If non-null, the blue fuzz to be used. If null, the cff default (1) is used.
        stdHW - If non-null, the stdHW to be used. If null, no value will be used.
        stdVW - If non-null, the stdVW to be used. If null, no value will be used.
        stemSnapH - If non-null, the horizontal stemsnaps to be used. They are not delta encoded. If null, no value will be used.
        stemSnapV - If non-null, the vertical stemsnaps to be used. They are not delta encoded. If null, no value will be used.
        forceBold - If non-null and true, forceBold will be set to 1. Else, it will be set to 0.
        langGroup - If non-null, the language group to be used. Else, the cff default (0) is used.
        expansionFactor - If non-null, the expansionFactor to be used. Else, the cff default (0.06) is used.
        initRandSeed - If non-null, the initial random seed to be used. Otherwise, the cff default (0) is used.
      • Dict

        public Dict​(Matrix matrix)
        Construct a Dict with the supplied values.
        Parameters:
        matrix - If non-null, the font matrix associated with the cff. If null, the cff default (0.001 0 0 0.001 0 0) is used.
      • Dict

        public Dict​(java.lang.String registry,
                    java.lang.String ordering,
                    int supplement,
                    java.lang.String version,
                    java.lang.String notice,
                    java.lang.String copyright,
                    java.lang.String fullname,
                    java.lang.String fontname,
                    java.lang.String familyName,
                    java.lang.String weight,
                    java.lang.Boolean fixedPitch,
                    java.lang.Double italicAngle,
                    java.lang.Double underlinePosition,
                    java.lang.Double underlineThickness,
                    java.lang.Integer paintType,
                    java.lang.Integer uniqueID,
                    Rect bbox,
                    java.lang.Double strokewidth,
                    int[] xuid,
                    java.lang.String postscript,
                    java.lang.Integer fsType,
                    int[] baseFontBlend,
                    java.lang.String baseFontName,
                    Matrix fontMatrix)
             throws InvalidFontException
        Construct a Dict with the supplied values. No scaling is applied to the given values. They are assumed to be scaled in the cff's font units.
        Parameters:
        version - If non-null, the version string associated with the cff. If null, no version string is added.
        notice - If non-null, the notice string associated with the cff. If null, no notice string is added.
        copyright - If non-null, the copyright string associated with the cff. If null, no copyright is added.
        fullname - If non-null, the fullname string associated with the cff. If null, no fullname is added.
        fontname - If non-null, the fontname associated with the cff. If null, no fontname is added.
        familyName - If non-null, the familyname string associated with the cff. If null, no familyname is added.
        weight - If non-null, the weight string associated with the cff. If null, no weight is added.
        fixedPitch - If non-null and true, isFixedPitch is set to true. Otherwise, it is false.
        italicAngle - If non-null, the italicangle associated with the cff. If null, the cff default (0) is used.
        underlinePosition - If non-null, the underline position associated with the cff. If null, the cff default (-100) is used.
        underlineThickness - If non-null, the underline thickness associated with the cff. If null, the cff default (50) is used.
        paintType - If non-null, the painttype associated with the cff. If null, the cff default (0) is used.
        uniqueID - If non-null, the uniqueID associated with the cff. If null, no uid is used.
        bbox - If non-null, the font bounding box associated with the cff. If null, no bbox is used.
        strokewidth - If non-null, the strokewidth associated with the cff. If null, the default strokewidth (0) is used.
        xuid - If non-null, the xuid associated with the cff. If null, no xuid is used.
        postscript - If non-null, the postscript string associated with the cff.
        fsType - If non-null, the fsType associated with the cff. This exact value will be added to the postscript string associated with the cff. If null, the postscript string is not modified.
        baseFontBlend - If non-null, the base font blend associated with the cff. If null, no base font blend is used.
        baseFontName - If non-null, the base fontname associated with the cff. If null, no base font name is used.
        Throws:
        InvalidFontException