Package org.axsl.ps

Examples of org.axsl.ps.EncodingVector


            /* CMap encodings should be able to handle any character in the
             * font's character set. */
            return internalEncoding;
        }
        /* Cast checked above. */
        final EncodingVector internalEncodingVector = (EncodingVector) internalEncoding;
        if (internalEncodingVector.getPredefinedType() == EncodingVector.Predefined.SYMBOL
                || internalEncodingVector.getPredefinedType() == EncodingVector.Predefined.ZAPF_DINGBATS) {
            /* The specialized encodings cover their entire character set. */
            return internalEncoding;
        }
        if (internalEncodingVector.getPredefinedType() == EncodingVector.Predefined.STANDARD) {
            final PsServer psServer = this.getFontConsumer().getFontServer().getPsServer();
            /* Try WinAnsiEncoding. */
            trialEncoding = psServer.getPredefinedEncoding(EncodingVector.Predefined.WIN_ANSI);
            if (trialEncoding.canEncode(codePoint)) {
                return trialEncoding;
View Full Code Here


     * @param psServer The PostScript server.
     * @param glyphIndex The glyph index whose PostScript name is sought.
     * @return The PostScript name for {@code glyphIndex}.
     */
    public String getPostScriptName(final PsServer psServer, final char glyphIndex) {
        final EncodingVector macOrdering = psServer.getPredefinedEncoding(
                EncodingVector.Predefined.STANDARD_MACINTOSH_ORDERING);
        final int codePoint = macOrdering.decodeCharacter(glyphIndex);
        switch (this.postFormat) {
        case TTFTablePOST.PS_FORMAT_1:
            return macOrdering.mapCodePointToGlyphName(codePoint);
        case TTFTablePOST.PS_FORMAT_2:
            if (codePoint != Encoding.INVALID_UNICODE_CHAR) {
                return macOrdering.mapCodePointToGlyphName(codePoint);
            }
            if (this.glyphNameIndex == null
                    || this.glyphNames == null) {
                return null;
            }
View Full Code Here

            System.arraycopy(this.internalCodePointIndexes, 0, newArray, 0,
                    this.internalCodePointCount);
            this.internalCodePointIndexes = newArray;
        }
        /* Create a tentative EncodingVector instance. */
        final EncodingVector newEncoding = psServer.makeEncodingVector("internal-" + this.getPostscriptName(),
                this.internalCodePoints, this.internalCodePointIndexes);
        /* Is this a predefined encoding? */
        EncodingVector predefinedEncoding = null;
        if (this.getPostscriptName().equals("ZapfDingbats")) {
            predefinedEncoding = psServer.getPredefinedEncoding(EncodingVector.Predefined.ZAPF_DINGBATS);
            if (newEncoding.isSubsetOf(predefinedEncoding)) {
                return predefinedEncoding;
            }
View Full Code Here

     * Parses the kernPairs part of the pfm file.
     * @param reader The metrics file reader.
     * @throws IOException For I/O Error.
     */
    private void loadKernPairs(final MetricsFileReader reader) throws IOException {
        final EncodingVector encoding = this.getInternalEncoding();
        final int qtyPairs = reader.readUnsignedShortLoHi();

        if (this.getKerning() == null) {
            this.kerning = new Kerning(qtyPairs);
        }
        for (int i = 0; i < qtyPairs; i++) {
            final char glyphIndex1 = (char) reader.readUnsignedByte();
            final char glyphIndex2 = (char) reader.readUnsignedByte();
            final int adj = reader.readShortLoHi();
            this.getKerning().addKerningEntry(
                    encoding.decodeCharacter(glyphIndex1),
                    encoding.decodeCharacter(glyphIndex2),
                    (short) adj);
        }
        this.getKerning().lock();
    }
View Full Code Here

     * Parses the extent table of the PFM file.
     * @param reader The metrics file reader.
     * @throws IOException For I/O Error.
     */
    private void loadExtentTable(final MetricsFileReader reader) throws IOException {
        final EncodingVector internalEncoding = this.getInternalEncoding();
        if (internalEncoding == null) {
            return;
        }
        final CharSet charSet = this.getCharSet();
        if (charSet == null) {
            return;
        }
        final short[] extentTable = new short[charSet.size()];
        this.dfMinWidth = this.getMaxWidth();
        for (int i = this.dfFirstChar; i <= this.dfLastChar; i++) {
            final short width = (short) reader.readUnsignedShortLoHi();
            final char encodedIndex = (char) i;
            final int codePoint = internalEncoding.decodeCharacter(
                    encodedIndex);
            final int charSetIndex = charSet.getIndex(codePoint);
            if (charSetIndex < 0
                    || charSetIndex >= extentTable.length) {
                continue;
View Full Code Here

            }
        }

        /* Except PostScript-native encodings, write each encoding vector. */
        for (int i = 0; i < encodingsUsed.size(); i++) {
            final EncodingVector vector = encodingsUsed.get(i);
            if (! vector.isPredefinedPs()) {
                writeRaw(vector.asPostScript(null));
            }
        }

        /* Bind the proper encoding to each font. */
        for (int i = 0; i < fontUses.length; i++) {
            final FontUse fontUse = fontUses[i];
            final Font font = fontUse.getFont();
            EncodingVector vector = null;
            if (! (fontUse.getEncoding() instanceof EncodingVector)) {
                /* For now, we don't know how to handle TrueType fonts here. */
                continue;
            }
            vector = (EncodingVector) fontUse.getEncoding();
            if (vector == font.getInternalEncoding()) {
                /* If using font's internal encoding, don't re-encode. */
                continue;
            }
            write("/" + font.getPostscriptName() + " findfont");
            write("dup length dict begin");
            write("  {1 index /FID ne {def} {pop pop} ifelse} forall");
            write("  /Encoding " + vector.getName() + " def");
            write("  currentdict");
            write("end");
            write("/" + fontUse.getPostscriptName() + " exch definefont pop");
        }
    }
View Full Code Here

        this.setAllowsEmbedding(true);

        /* If not already set, set the Encoding. */
        if (this.getInternalEncoding() == null) {
            final String encodingName = this.metricsFile.getEncoding();
            EncodingVector encoding = null;
            final PsServer psServer = this.getRegisteredFont().getFontServer().getPsServer();
            if (encodingName.equals("StandardEncoding")
                    || encodingName.equals("AdobeStandardEncoding")) {
                encoding = psServer.getPredefinedEncoding(EncodingVector.Predefined.WIN_ANSI);
            }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public EncodingVector getPredefinedEncoding(final String name) {
        final EncodingVector.Predefined predefined = EncodingVector.Predefined.findByName(name);
        EncodingVector encoding = getPredefinedEncoding(predefined);

        if (name.equals("FOrayLatinExtraEncoding")) {
            encoding = EncodingFOrayLatinExtra.getInstance();
        } else if (name.equals("InternalEncoding")) {
            /* The statement below is a bit redundant, but is included to
View Full Code Here

            System.err.println("File cannot be opened for output: " + output);
            System.exit(1);
        }

        final PsServer4a psServer = new PsServer4a();
        final EncodingVector encoding = psServer.getPredefinedEncoding(encodingString);
        final EncodingVectorInputStream inputFilter = new EncodingVectorInputStream(inputStream, encoding);

        try {
            while (true) {
                final int inputByte = inputFilter.read();
View Full Code Here

        // Register this as the parent of the System Dictionary
        systemDictToUse.setPSInterpreter(this);
        final PsServer4a psServer = new PsServer4a();
        // Add the Standard Encoding to the System Dictionary.
        PsName name = new PsName("StandardEncoding", false, false);
        EncodingVector encoding = psServer.getPredefinedEncoding(name.getValue());
        PsArray array = new PsArray(encoding.getGlyphNames(), false);
        systemDictToUse.addItem(this, name, array);
        // Add the ISO Latin 1 Encoding to the System Dictionary.
        name = new PsName("ISOLatin1Encoding", false, false);
        encoding = psServer.getPredefinedEncoding(name.getValue());
        array = new PsArray(encoding.getGlyphNames(), false);
        systemDictToUse.addItem(this, name, array);
        // Add the System Dictionary to the dictionary stack.
        this.dictionaryStack.push(systemDictToUse);
        /*
         * Add "systemdict" as an entry in itself. See PLRM2, Section 8.2,
View Full Code Here

TOP

Related Classes of org.axsl.ps.EncodingVector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.