Package org.axsl.ps

Examples of org.axsl.ps.Encoding


        /* If none already exists, create one. */
        if (sf != null) {
            /* We don't care about encodings for SystemFonts. */
            fontUse = new FontUse4a(this, rfd, null);
        } else {
            final Encoding encoding = findEncoding(rfd, codePoint);
            if (encoding == null) {
                /* We can't encode this character.
                 * Return null so that the upstream font selection routines can
                 * try another font family. */
                return null;
View Full Code Here


     * Finds the best encoding to use for a given Unicode code point.
     * @param codePoint The Unicode code point to be tested.
     * @return The best encoding to use for the code point.
     */
    private Encoding getBestEncoding(final int codePoint) {
        Encoding trialEncoding = null;
        final Encoding internalEncoding = this.font.getInternalEncoding();
        if (! (internalEncoding instanceof 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;
            }
            /* Try the Central European encoding. */
            trialEncoding = psServer.getPredefinedEncoding(EncodingVector.Predefined.CE);
            if (trialEncoding.canEncode(codePoint)) {
                return trialEncoding;
            }
            /* Try the FOray catch-all encoding. */
            /* TODO: Move this encoding from the PS package to the Fonts package so that we don't have to address it
             * by name. */
            trialEncoding = psServer.getPredefinedEncoding("FOrayLatinExtraEncoding");
            if (trialEncoding != null
                    && trialEncoding.canEncode(codePoint)) {
                return trialEncoding;
            }
        }
        if (internalEncoding.canEncode(codePoint)) {
            return internalEncoding;
        }
        return null;
    }
View Full Code Here

        }
        final FSTrueTypeFont ttf = (FSTrueTypeFont) getFOrayFont();
        if (this.fontUse.subSetting()) {
            return getSubsetCharsUsed();
        }
        final Encoding encoding = this.fontUse.getEncoding();
        final int arraySize = ttf.getNumGlyphs();
        final char[] charArray = new char[arraySize];
        for (int i = 0; i < ttf.getNumGlyphs(); i++) {
            final int arrayItem = encoding.decodeCharacter((char) i);
            charArray[i] = (char) arrayItem;
        }
        return charArray;
    }
View Full Code Here

     * returns the chars used for the font subset.
     * @return The chars actually used by the document.
     */
    private char[] getSubsetCharsUsed() {
        final Subset subset = this.fontUse.getSubset();
        final Encoding encoding = this.fontUse.getEncoding();
        final char[] charArray = new char[subset.numGlyphsUsed()];
        for (int i = 0; i < subset.numGlyphsUsed(); i++) {
            final int originalGlyphIndex = subset.decodeSubsetIndex(i);
            final int codePoint = encoding.decodeCharacter(
                    (char) originalGlyphIndex);
            charArray[i] = (char) codePoint;
        }
        return charArray;
    }
View Full Code Here

            if (subset == null) {
                return fsf.getWidths();
            }
            return getSubsetWidths();
        }
        final Encoding encoding = this.fontUse.getEncoding();
        final CharSet charSet = fsf.getCharSet();
        final int firstIndex = encoding.getFirstIndex();
        final int lastIndex = encoding.getLastIndex();
        final int size = lastIndex - firstIndex + 1;
        final short[] widthsByFontIndex = new short[size];
        for (int i = firstIndex; i <= lastIndex; i++) {
            // Decode the character for this index
            final int codePoint = encoding.decodeCharacter(i);
            // Find the charSet index for that character.
            final int charSetIndex = charSet.getIndex(codePoint);
            if (charSetIndex < 0) {
                continue;
            }
View Full Code Here

        /* TODO: This method is untested */
        final FreeStandingFont fsf = this.consumerFont.getFreeStandingFont();
        if (fsf == null) {
            return;
        }
        final Encoding encoding = fsf.getInternalEncoding();

        /* Sort the content, using a bubble sort. */
         boolean stillSorting = true;
         while (stillSorting) {
             stillSorting = false;
             for (char i = 1; i < this.numGlyphsUsed(); i++) {
                 final char currentOriginalIndex =
                         (char) this.decodeSubsetIndex(i);
                 final int currentCodePoint = encoding.decodeCharacter(
                         currentOriginalIndex);
                 final char previousOriginalIndex
                         = (char) this.decodeSubsetIndex(i - 1);
                 final int previousCodePoint = encoding.decodeCharacter(
                         previousOriginalIndex);
                 if (previousCodePoint > currentCodePoint) {
                     /* They are out of order and should be switched. */

                     /* First, switch the originalBySubset array. */
 
View Full Code Here

    private boolean isStandardFont() {
        /* This method is necessary to allow standard PDF fonts to be treated
         * as if they were not standard when they use a non-standard encoding.
         * We're not sure why this is necessary, but it seems to be. */
        if (this.fsFont.getFontUse().getFont().isPdfStandardFont()) {
            final Encoding encoding = this.fsFont.getFontUse().getEncoding();
            if (encoding.isPredefinedPdf()) {
                return true;
            }
            if (encoding == this.fsFont.getFontUse().getFont().getInternalEncoding()) {
                /* This covers the cases of Symbol & ZapfDingbats, which don't
                 * use standard PDF encodings. */
 
View Full Code Here

        /* Get a List of all EncodingVectors used. */
        final List<EncodingVector> encodingsUsed
                = new ArrayList<EncodingVector>();
        for (int i = 0; i < fontUses.length; i++) {
            final Encoding encoding = fontUses[i].getEncoding();
            final Font font = fontUses[i].getFont();
            /* If the FontUse has the same encoding as the Font, there is no
             * need to write the encoding again, because it is already defined
             * in the Font dictionary itself. */
            if (encoding == font.getInternalEncoding()) {
View Full Code Here

                rfd.getRegisteredFont().getFreeStandingFont();
        if (fsf == null) {
            return null;
        }
        final ConsumerFont4a consumerFont = this.getConsumerFont(fsf);
        final Encoding encoding = consumerFont.findEncoding(rfd, codePoint);
        if (encoding == null) {
            /* Either no known encoding for this font can encode this character
             * or we have been restricted from using an encoding that can.
             * Either way, this font can't be used. */
            return null;
View Full Code Here

     * @throws FontException For errors during registration.
     */
    private void registerBase14Description(final String fontFamily,
            final String fontName, final org.axsl.font.Font.Style style,
            final org.axsl.font.Font.Weight weight) throws FontException {
        Encoding encoding = this.psServer.getPredefinedEncoding("WinAnsiEncoding");
        if (fontFamily.equals("Base14-Symbol")) {
            encoding = this.psServer.getPredefinedEncoding("SymbolEncoding");
        }
        if (fontFamily.equals("Base14-ZapfDingbats")) {
            encoding = this.psServer.getPredefinedEncoding("ZapfDingbatsEncoding");
View Full Code Here

TOP

Related Classes of org.axsl.ps.Encoding

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.