IppFont.java 8.38 KB
/*
 * Decompiled with CFR 0_118.
 */
package com.scene7.is.ipp.messages;

import com.scene7.is.ipp.messages.Ipp;
import com.scene7.is.ipp.messages.IppBool;
import com.scene7.is.ipp.messages.IppInt;
import com.scene7.is.ipp.messages.IppLongString;
import com.scene7.is.ipp.messages.Offset;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.io.Writer;

public class IppFont {
    private String name_;
    private String postscriptName_;
    private String file_;
    private String metricsFile_;
    private String customKerningFile_;
    private boolean bold_;
    private boolean italic_;

    public IppFont(String name, String postscriptName, String file, String metricsFile, String customKerningFile, boolean bold, boolean italic) {
        this.name_ = name;
        this.postscriptName_ = postscriptName;
        this.file_ = file;
        this.metricsFile_ = metricsFile;
        this.customKerningFile_ = customKerningFile;
        this.bold_ = bold;
        this.italic_ = italic;
    }

    public String toString() {
        StringBuffer buffer = new StringBuffer();
        buffer.append("[");
        buffer.append("name: ").append(String.valueOf(this.name_)).append(" ");
        buffer.append("postscriptName: ").append(String.valueOf(this.postscriptName_)).append(" ");
        buffer.append("file: ").append(String.valueOf(this.file_)).append(" ");
        buffer.append("metricsFile: ").append(String.valueOf(this.metricsFile_)).append(" ");
        buffer.append("customKerningFile: ").append(String.valueOf(this.customKerningFile_)).append(" ");
        buffer.append("bold: ").append(String.valueOf(this.bold_)).append(" ");
        buffer.append("italic: ").append(String.valueOf(this.italic_)).append(" ");
        buffer.append("]");
        return buffer.toString();
    }

    public boolean equals(Object o) {
        if (!(o instanceof IppFont)) {
            return false;
        }
        IppFont e = (IppFont)o;
        if (!this.name_.equals(e.name_)) {
            return false;
        }
        if (!this.postscriptName_.equals(e.postscriptName_)) {
            return false;
        }
        if (!this.file_.equals(e.file_)) {
            return false;
        }
        if (!this.metricsFile_.equals(e.metricsFile_)) {
            return false;
        }
        if (!this.customKerningFile_.equals(e.customKerningFile_)) {
            return false;
        }
        if (this.bold_ != e.bold_) {
            return false;
        }
        if (this.italic_ != e.italic_) {
            return false;
        }
        return true;
    }

    public static IppFont Unstuff(byte[] arr, Offset arrayPos) {
        Ipp.Assert((arrayPos.val & 3) == 0, "IppFont align");
        String name = IppLongString.Unstuff(arr, arrayPos);
        String postscriptName = IppLongString.Unstuff(arr, arrayPos);
        String file = IppLongString.Unstuff(arr, arrayPos);
        String metricsFile = IppLongString.Unstuff(arr, arrayPos);
        String customKerningFile = IppLongString.Unstuff(arr, arrayPos);
        boolean bold = IppBool.Unstuff(arr, arrayPos);
        boolean italic = IppBool.Unstuff(arr, arrayPos);
        return new IppFont(name, postscriptName, file, metricsFile, customKerningFile, bold, italic);
    }

    public static IppFont[] UnstuffArray(byte[] arr, Offset arrayPos) {
        Ipp.Assert((arrayPos.val & 3) == 0, "IppFont alignemt");
        int count = IppInt.Unstuff(arr, arrayPos);
        int size = IppInt.Unstuff(arr, arrayPos);
        Ipp.Assert(count == 0 || size >= 28, "IppFont count");
        Offset roff = new Offset(IppInt.Unstuff(arr, arrayPos));
        Offset loff = new Offset(roff.val);
        IppFont[] result = new IppFont[count];
        for (int i = 0; i < count; ++i) {
            loff.val = roff.val;
            result[i] = IppFont.Unstuff(arr, loff);
            roff.val += size;
        }
        return result;
    }

    public static IppFont[] UnstuffFixedArray(byte[] arr, Offset arrayPos, int count) {
        IppFont[] result = new IppFont[count];
        for (int i = 0; i < count; ++i) {
            result[i] = IppFont.Unstuff(arr, arrayPos);
        }
        return result;
    }

    public static void Stuff(byte[] arr, Offset arrayPos, Offset varPos, IppFont val) {
        Ipp.Assert((arrayPos.val & 3) == 0, "IppFont align");
        if (val != null) {
            IppLongString.Stuff(arr, arrayPos, varPos, val.name());
            IppLongString.Stuff(arr, arrayPos, varPos, val.postscriptName());
            IppLongString.Stuff(arr, arrayPos, varPos, val.file());
            IppLongString.Stuff(arr, arrayPos, varPos, val.metricsFile());
            IppLongString.Stuff(arr, arrayPos, varPos, val.customKerningFile());
            IppBool.Stuff(arr, arrayPos, varPos, val.bold());
            IppBool.Stuff(arr, arrayPos, varPos, val.italic());
        } else {
            Ipp.StuffNullBytes(arr, arrayPos, 28);
        }
    }

    public static void StuffArray(byte[] arr, Offset arrayPos, Offset varPos, IppFont[] val) {
        Ipp.Assert((arrayPos.val & 3) == 0, "IppFont stuffarray align");
        int len = val != null ? val.length : 0;
        IppInt.Stuff(arr, arrayPos, varPos, len);
        IppInt.Stuff(arr, arrayPos, varPos, 28);
        Ipp.StuffOffset(arr, arrayPos, varPos, len > 0 ? 4 : 1);
        Offset varvarPos = new Offset(varPos.val + 28 * len);
        for (int i = 0; i < len; ++i) {
            IppFont.Stuff(arr, varPos, varvarPos, val[i]);
        }
        varPos.val = varvarPos.val;
    }

    public static void StuffFixedArray(byte[] arr, Offset arrayPos, Offset varPos, int count, IppFont[] val) {
        Ipp.Assert(val.length == count, "IppFont count");
        for (int i = 0; i < count; ++i) {
            IppFont.Stuff(arr, arrayPos, varPos, val[i]);
        }
    }

    public static void Print(Writer tf, String label, IppFont it) throws IOException {
        String ll = label + "IppFont: ";
        if (it == null) {
            tf.write(ll + "NULL!!\n");
            return;
        }
        tf.write(ll + "\n");
        IppLongString.Print(tf, ll + "name: ", it.name());
        IppLongString.Print(tf, ll + "postscriptName: ", it.postscriptName());
        IppLongString.Print(tf, ll + "file: ", it.file());
        IppLongString.Print(tf, ll + "metricsFile: ", it.metricsFile());
        IppLongString.Print(tf, ll + "customKerningFile: ", it.customKerningFile());
        IppBool.Print(tf, ll + "bold: ", it.bold());
        IppBool.Print(tf, ll + "italic: ", it.italic());
    }

    public static void PrintArray(Writer tf, String label, IppFont[] it) throws IOException {
        String ll = label + "IppFont Array, length: ";
        tf.write(ll);
        if (it == null) {
            tf.write("NULL!!!\n");
            return;
        }
        tf.write("" + it.length + "\n");
        for (int i = 0; i < it.length; ++i) {
            ll = label + "IppFont[" + String.valueOf(i) + "]: ";
            IppFont.Print(tf, ll, it[i]);
        }
    }

    public void adjustVarPos(Offset varPos) {
        try {
            varPos.val += this.name_.getBytes("UTF-8").length + 1;
        }
        catch (UnsupportedEncodingException e) {
            throw new AssertionError(e);
        }
        try {
            varPos.val += this.postscriptName_.getBytes("UTF-8").length + 1;
        }
        catch (UnsupportedEncodingException e) {
            throw new AssertionError(e);
        }
        try {
            varPos.val += this.file_.getBytes("UTF-8").length + 1;
        }
        catch (UnsupportedEncodingException e) {
            throw new AssertionError(e);
        }
        try {
            varPos.val += this.metricsFile_.getBytes("UTF-8").length + 1;
        }
        catch (UnsupportedEncodingException e) {
            throw new AssertionError(e);
        }
        try {
            varPos.val += this.customKerningFile_.getBytes("UTF-8").length + 1;
        }
        catch (UnsupportedEncodingException e) {
            throw new AssertionError(e);
        }
    }

    public String name() {
        return this.name_;
    }

    public String postscriptName() {
        return this.postscriptName_;
    }

    public String file() {
        return this.file_;
    }

    public String metricsFile() {
        return this.metricsFile_;
    }

    public String customKerningFile() {
        return this.customKerningFile_;
    }

    public boolean bold() {
        return this.bold_;
    }

    public boolean italic() {
        return this.italic_;
    }
}