SyntheticFont.java 7.87 KB
/*
 * Decompiled with CFR 0_118.
 */
package com.adobe.fontengine.font.cff;

import com.adobe.fontengine.font.CodePage;
import com.adobe.fontengine.font.Font;
import com.adobe.fontengine.font.InvalidFontException;
import com.adobe.fontengine.font.LineMetrics;
import com.adobe.fontengine.font.Matrix;
import com.adobe.fontengine.font.OrigFontType;
import com.adobe.fontengine.font.OutlineConsumer;
import com.adobe.fontengine.font.PDFFontDescription;
import com.adobe.fontengine.font.Permission;
import com.adobe.fontengine.font.ROS;
import com.adobe.fontengine.font.Rect;
import com.adobe.fontengine.font.Subset;
import com.adobe.fontengine.font.SubsetSimpleTrueType;
import com.adobe.fontengine.font.SubsetSimpleType1;
import com.adobe.fontengine.font.UnsupportedFontException;
import com.adobe.fontengine.font.XDCFontDescription;
import com.adobe.fontengine.font.cff.CFFByteArray;
import com.adobe.fontengine.font.cff.CFFFont;
import com.adobe.fontengine.font.cff.CharStrings;
import com.adobe.fontengine.font.cff.Dict;
import com.adobe.fontengine.font.cff.StringIndex;
import com.adobe.fontengine.font.cff.Type2OutlineParser;
import java.io.OutputStream;

public final class SyntheticFont
extends CFFFont {
    protected final CFFFont base;
    private final XDCFontDescription xdcDescription;

    public Subset createSubset() throws UnsupportedFontException {
        throw new UnsupportedFontException("createSubset of CFF Synthetic fonts");
    }

    SyntheticFont(StringIndex stringIndex, CFFFont base, String name, Dict topDict, CFFByteArray data, byte[] digest) throws UnsupportedFontException, InvalidFontException {
        super(stringIndex, null, topDict, name, digest);
        this.xdcDescription = new SyntheticFontXDCFontDescription();
        this.base = base;
    }

    public int getNumGlyphs() throws UnsupportedFontException, InvalidFontException {
        return this.base.getNumGlyphs();
    }

    public String getGlyphName(int gid) throws InvalidFontException, UnsupportedFontException {
        return this.base.getGlyphName(gid);
    }

    public ROS getROS() {
        return this.base.getROS();
    }

    public int getGlyphCid(int glyphID) throws InvalidFontException, UnsupportedFontException {
        return this.base.getGlyphCid(glyphID);
    }

    int[] getXUID() {
        return this.base.getXUID();
    }

    String getNotice() {
        return this.base.getNotice();
    }

    Integer getFSType() {
        return this.base.getFSType();
    }

    OrigFontType getOrigFontType() {
        return this.base.getOrigFontType();
    }

    public void getGlyphOutline(int gid, OutlineConsumer consumer) throws InvalidFontException, UnsupportedFontException {
        this.base.getGlyphOutline(gid, consumer);
    }

    public void getOutline(int gid, Type2OutlineParser parser, OutlineConsumer consumer) throws InvalidFontException, UnsupportedFontException {
        this.base.getOutline(gid, parser, consumer);
    }

    public double getStemVForGlyph(int gid) throws InvalidFontException {
        return this.base.getStemVForGlyph(gid);
    }

    public Matrix getFontMatrix() {
        Matrix m = new Matrix(this.topDict.get(Dict.Key.FontMatrix, true).getValuesAsDouble());
        return this.base.getFontMatrix().multiply(m);
    }

    public double getHorizontalAdvance(int gid) throws InvalidFontException, UnsupportedFontException {
        return this.base.getHorizontalAdvance(gid);
    }

    double getItalicAngle() {
        return this.base.getItalicAngle();
    }

    Rect getRawFontBBox() {
        return this.base.getRawFontBBox();
    }

    private Matrix getFontToMetricsMatrix() throws InvalidFontException, UnsupportedFontException {
        Matrix m = this.getFontMatrix();
        double x = this.getUnitsPerEmX();
        double y = this.getUnitsPerEmY();
        return new Matrix(x * m.a, y * m.b, x * m.c, y * m.d, x * m.tx, y * m.ty);
    }

    public Rect getFontBBox() throws InvalidFontException, UnsupportedFontException {
        Rect rawBBox = this.getRawFontBBox();
        if (rawBBox == null) {
            return null;
        }
        return rawBBox.applyMatrix(this.getFontToMetricsMatrix());
    }

    public Rect getCoolTypeRawFontBBox() throws InvalidFontException, UnsupportedFontException {
        return this.getFontBBox();
    }

    public int getGlyphForChar(int usv) throws InvalidFontException, UnsupportedFontException {
        return this.base.getGlyphForChar(usv);
    }

    double getDefaultWidthForFD(int fd) {
        return this.base.getDefaultWidthForFD(fd);
    }

    double getNominalWidthForFD(int fd) {
        return this.base.getNominalWidthForFD(fd);
    }

    int getFDForGlyph(int fullGid) throws InvalidFontException {
        return this.base.getFDForGlyph(fullGid);
    }

    CharStrings getLocalSubrsForFD(int fd) {
        return this.base.getLocalSubrsForFD(fd);
    }

    int getNumFDs() {
        return this.base.getNumFDs();
    }

    CharStrings getCharStrings() {
        return this.base.getCharStrings();
    }

    public LineMetrics getCoolTypeLineMetrics() throws UnsupportedFontException, InvalidFontException {
        return this.base.getCoolTypeLineMetrics();
    }

    public Rect getCoolTypeIdeoEmBox() throws UnsupportedFontException, InvalidFontException {
        return this.base.getCoolTypeIdeoEmBox();
    }

    public Rect getCoolTypeIcfBox() throws UnsupportedFontException, InvalidFontException {
        return this.base.getCoolTypeIcfBox();
    }

    public Permission getEmbeddingPermission(boolean wasEmbedded) throws InvalidFontException, UnsupportedFontException {
        return this.base.getEmbeddingPermission(wasEmbedded);
    }

    public void subsetAndStream(Subset subset, OutputStream out, boolean preserveROS, Integer fsType) throws InvalidFontException, UnsupportedFontException {
        throw new UnsupportedFontException("subsetAndStream of CFF Synthetic fonts");
    }

    String getCopyright() {
        return this.base.getCopyright();
    }

    String getFullName() {
        return this.base.getFullName();
    }

    int getFirstChar() throws InvalidFontException, UnsupportedFontException {
        return this.base.getFirstChar();
    }

    int getLastChar() throws InvalidFontException, UnsupportedFontException {
        return this.base.getLastChar();
    }

    public PDFFontDescription getPDFFontDescription(Font font) {
        return this.xdcDescription;
    }

    public XDCFontDescription getXDCFontDescription(Font font) {
        return this.xdcDescription;
    }

    public void stream(OutputStream out, Integer fsType) throws UnsupportedFontException {
        throw new UnsupportedFontException("stream of CFF Synthetic fonts");
    }

    private class SyntheticFontXDCFontDescription
    extends CFFFont.CFFFontXDCFontDescription {
        private SyntheticFontXDCFontDescription() {
        }

        public int getCIDCount() {
            return -1;
        }

        public void subsetAndStream(Subset subset, OutputStream out, boolean preserveROS) throws UnsupportedFontException {
            throw new UnsupportedFontException("subsetAndStream of CFF Synthetic fonts");
        }

        public void subsetAndStream(SubsetSimpleType1 t1Subset, OutputStream out) throws UnsupportedFontException {
            throw new UnsupportedFontException("subsetAndStream of CFF Synthetic fonts");
        }

        public void subsetAndStream(SubsetSimpleTrueType ttSubset, OutputStream out) throws UnsupportedFontException {
            throw new UnsupportedFontException("subsetAndStream of CFF Synthetic fonts");
        }

        public CodePage[] getXDCCodePages() throws InvalidFontException, UnsupportedFontException {
            return SyntheticFont.this.base.getXDCFontDescription(null).getXDCCodePages();
        }

        public void stream(OutputStream out, boolean openTypeFontsAllowed) throws UnsupportedFontException {
            throw new UnsupportedFontException("stream of CFF Synthetic fonts");
        }
    }

}