Package org.axsl.font

Examples of org.axsl.font.Font


     * The following items are <em>not </em>considered: space-start, space-end.
     * @return The new progression dimension value, in millipoints.
     */
    private int recomputeProgressionDimension() {
        final CharSequence text = getText();
        final Font font = this.getPrimaryFont().getFont();
        final int pd = font.width(text, this.traitFontSize(), this.traitLetterSpacingOpt(),
                this.traitWordSpacingOpt(), true);
        return pd;
    }
View Full Code Here


     * not created.
     * @param fontUse The font for which a PDFFont is needed.
     * @return The appropriate PDFFont instance.
     */
    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;
View Full Code Here

     * writing this text.
     * @return The String that should actually be written into the PDF to show
     * the input text.
     */
    public String textToPdf(final CharSequence theString, final boolean kerningActive) {
        final Font font = this.getFOrayFont();
        final StringBuilder buffer = new StringBuilder();
        buffer.append("[");
        buffer.append(startTextDelimiter(font));
        for (int i = 0; i < theString.length(); i++) {
            final int codePoint = Character.codePointAt(theString, i);
View Full Code Here

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

    /**
     * {@inheritDoc}
     */
    public byte[] getContentsPostScriptHex() {
        final Font font = this.getFontUse().getFont();
        if (! (font instanceof FSType1Font)) {
            return null;
        }
        final FSType1Font type1Font = (FSType1Font) font;
        final Type1File pfb = type1Font.getType1File();
        try {
            return pfb.getByteArray(PsFilterType.ASCII_HEX);
        } catch (final IOException e) {
            this.getLogger().fatal("Failed to get contents for "
                    + font.getPostscriptName() + ": " + e.getMessage());
        }
        return null;
    }
View Full Code Here

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

    /**
     * {@inheritDoc}
     */
    public String toPDF() {
        final Font font = this.fsFont.getFontUse().getFont();
        final StringBuilder p = new StringBuilder();
        p.append(pdfID() + EOL);
        p.append("<< /Type /Font");
        p.append(EOL + "/BaseFont /");
        p.append(font.getPostscriptName());
        if (this.cidMap != null) {
            p.append(EOL + "/CIDToGIDMap ");
            p.append(this.cidMap.pdfReference());
        }
        p.append(EOL + "/Subtype /");
        p.append(this.subType.getPdfName());
        p.append(EOL);
        p.append(this.systemInfo.toPDF());
        p.append(EOL + "/FontDescriptor ");
        p.append(this.descriptor.pdfReference());

        p.append(EOL + "/DW ");
        p.append(font.getDefaultWidth());

        p.append(widthArrayToPDFString(getCIDWidths()));

        /*
         * Always a two-element array. See PDF Reference, Second Edition,
View Full Code Here

     * Finds the CID Font subtype for a given font.
     * @param fsFont The font for which the CID subtype is needed.
     * @return The CID Font subtype for {@code fsFont}.
     */
    protected static PDFCIDFont.SubType getCidType(final FontPdf fsFont) {
        final Font font = fsFont.getFontUse().getFont();
        if (font.getFontFormat() == Font.Format.TRUETYPE) {
            return PDFCIDFont.SubType.CID_TYPE2;
        }
        return PDFCIDFont.SubType.CID_TYPE0;
    }
View Full Code Here

                    "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");
View Full Code Here

        final StringBuilder buffer = new StringBuilder();
        outputGeneratedBy(area, buffer);
        writeStartTag(area, buffer);
        outputAllRectangles(area);
        if (this.printFont) {
            final Font font = area.getPrimaryFont().getFont();
            final StringBuilder fontBuffer = new StringBuilder();
            outputAttribute(fontBuffer, "name", font.getFontName());
            outputAttribute(fontBuffer, "size", area.traitFontSize());
            this.writeEmptyElement("font", fontBuffer);
        }
        final CharSequence rawText = area.getText();
        final CharSequence cookedText = XMLCharacter.expandEntityReferences(rawText);
View Full Code Here

TOP

Related Classes of org.axsl.font.Font

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.