Package org.axsl.font

Examples of org.axsl.font.FontUse


    public int traitFontSize() {
        final CharacterSequence generatedBy = this.traitGeneratedBy();
        final int nominalFontSize = generatedBy.traitFontSizeActual(this,
                this.getPrimaryFont().getFont());
        if (this.hasFauxSmallCaps()) {
            final FontUse fontUse = getPrimaryFont();
            return fontUse.smallCapsSize(nominalFontSize);
        }
        return nominalFontSize;
    }
View Full Code Here


    public PDFFont getPdfFont(final FontPdf fontUse) {
        final Font font = fontUse.getFontUse().getFont();
        /* Look for a match in the existing fonts. */
        for (int i = 0; i < this.usedFonts.size(); i++) {
            final PDFFont pdfFont = this.usedFonts.get(i);
            final FontUse testFontUse = pdfFont.getFsFont();
            final Font testFont = testFontUse.getFont();
            /* For there to be a match, the underlying fonts must be the same
             * and the encoding must be the same. */
            if (testFont == font
                    && fontUse.getFontUse().getEncoding() == testFontUse.getEncoding()) {
                return pdfFont;
            }
        }
        final PDFFont pdfFont = PDFFont.makeFont(this, fontUse);
        this.usedFonts.add(pdfFont);
View Full Code Here

     * Computes the width of a character, in millipoints.
     * @param c The Unicode codepoint whose width should be computed.
     * @return The width of the codepoint, in millipoints.
     */
    public int getCharWidth(final int c) {
        final FontUse fontUse = getPrimaryFont();
        final Font font = getPrimaryFont().getFont();
        fontUse.registerCharUsed(c);
        return font.width(c, traitFontSize())
                + this.traitGeneratedBy().traitLetterSpacingOpt(this);
    }
View Full Code Here

     * Computes the width of a word, in millipoints.
     * @param word The word whose width should be computed.
     * @return The width of the word, in millipoints.
     */
    public int getWordWidth(final CharSequence word) {
        final FontUse fontUse = getPrimaryFont();
        final Font font = fontUse.getFont();
        fontUse.registerCharsUsed(word);
        return font.width(word, traitFontSize(),
                traitGeneratedBy().traitLetterSpacingOpt(this),
                traitGeneratedBy().traitWordSpacingOpt(this), true);
    }
View Full Code Here

     * Return the font subtype.
     * @param font The Font whose PDF subtype is needed.
     * @return The font subtype.
     */
    public static SubType getFontSubtype(final FontPdf font) {
        final FontUse fontUse = font.getFontUse();
        if (fontUse.getFont().getFontComplexity() == Font.Complexity.COMPOSITE) {
            return PDFFont.SubType.TYPE0;
        }
        if (fontUse.getFont().getFontFormat() == Font.Format.TYPE1) {
            return PDFFont.SubType.TYPE1;
        }
        return PDFFont.SubType.TRUETYPE;
    }
View Full Code Here

    protected void writeFontDict() throws IOException {
        final FontUse[] fontUses = getFontConsumer().getUsedFontUses();

        /* Embed fonts. */
        for (int i = 0; i < fontUses.length; i++) {
            final FontUse fontUse = fontUses[i];
            final FontPs fontPS = (FontPs) fontUse.getFontOutput(
                    "application/ps");
            /* For now, we don't know how to process TrueType fonts. */
            if (! (fontUses[i].getEncoding() instanceof EncodingVector)) {
                continue;
            }
            final Font font = fontUse.getFont();
            if (! font.isEmbeddable()) {
                continue;
            }
            final String fontContents = new String(
                    fontPS.getContentsPostScriptHex());
            write(fontContents);
        }

        this.fontProcSet = getApplicationNameShort()
                + "Fonts";
        write("%%BeginResource: procset " + this.fontProcSet);
        write("%%Title: Font setup (shortcuts) for this file");
        write("/" + this.fontProcSet + " 100 dict dup begin");

        /* Bind each font to a short resource name. */
        for (int i = 0; i < fontUses.length; i++) {
            final FontUse fontUse = fontUses[i];
            /* For now, we don't know how to process TrueType fonts. */
            if (! (fontUses[i].getEncoding() instanceof EncodingVector)) {
                continue;
            }
            final PSFont psFont = getPSFont(fontUse);
            write("/" + psFont.getName() + " /" + fontUse.getPostscriptName()
                    + " def");
        }
        write("end def");
        write("%%EndResource");

        /* 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()) {
                continue;
            }
            if (encoding instanceof EncodingVector) {
                boolean encodingFound = false;
                for (int j = 0; j < encodingsUsed.size() && ! encodingFound;
                        j++) {
                    if (encodingsUsed.get(j) == encoding) {
                        encodingFound = true;
                    }
                }
                if (! encodingFound) {
                    encodingsUsed.add((EncodingVector) encoding);
                }
            }
        }

        /* 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

    private void writeTextSegment(final TextArea area, final CharSequence text)
            throws IOException {
        if (text == null || text.length() < 1) {
            return;
        }
        final FontUse fontUse = area.getPrimaryFont();
        final PSFont psFont = this.fontMap.get(fontUse);
        useFont(psFont, area.traitFontSize());
        useColor(area.traitColor());
        write(moveTo(area));
        StringBuilder sb = new StringBuilder();
View Full Code Here

                = org.axsl.font.Font.Weight.NORMAL;
        if (gFont.isBold()) {
            fontWeight = org.axsl.font.Font.Weight.BOLD;
        }
        try {
            final FontUse fontUse = this.fontConsumer.selectFontXsl(
                    org.axsl.font.Font.SelectionStrategy.AUTO,
                    FontUtility.foFontFamily(fontFamily),
                    fontStyle, fontWeight,
                    org.axsl.font.Font.Variant.NORMAL,
                    org.axsl.font.Font.Stretch.NORMAL,
                    (int) (fontSize * WKConstants.MILLIPOINTS_PER_POINT),
                    ' ');
            return (FontPdf) fontUse.getFontOutput(Mime.PDF.getMimeString());
        } catch (final FontException exception) {
            this.logger.error(exception.getMessage());
            return null;
        }
    }
View Full Code Here

            final String[] fontFamily = new String[1];
            fontFamily[0] = (String) iterator.getAttribute(
                    TextAttribute.FAMILY);
            final Float fontSize = (Float) iterator.getAttribute(
                    TextAttribute.FAMILY);
            FontUse font;
            try {
                font = this.fontConsumer.selectFontCss(fontFamily,
                        org.axsl.font.Font.Style.NORMAL,
                        org.axsl.font.Font.Weight.NORMAL,
                        org.axsl.font.Font.Variant.NORMAL,
                        org.axsl.font.Font.Stretch.NORMAL, 0, ch);
            } catch (final FontException e) {
                /* We can't find a font for this character, so skip it. */
                continue;
            }
            final float size = fontSize.floatValue();
            final FontPdf fontPdf = (FontPdf) font.getFontOutput(Mime.PDF.getMimeString());
            if ((fontPdf != this.getGraphicsState().font)
                    || (size != this.getGraphicsState().fontSize)) {
                this.getGraphicsState().font = fontPdf;
                this.getGraphicsState().fontSize = size;
                final String fontName = this.pdfContext.getFontName(font);
View Full Code Here

     * Computes the width of a word, in millipoints.
     * @param word The word whose width should be computed.
     * @return The width of the word, in millipoints.
     */
    public int getWordWidth(final CharSequence word) {
        final FontUse fontUse = getPrimaryFont();
        final Font font = fontUse.getFont();
        fontUse.registerCharsUsed(word);
        return font.width(word, traitFontSize(),
                traitGeneratedBy().traitLetterSpacingOpt(this),
                traitGeneratedBy().traitWordSpacingOpt(this), true);
    }
View Full Code Here

TOP

Related Classes of org.axsl.font.FontUse

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.