Package com.google.code.appengine.awt

Examples of com.google.code.appengine.awt.Font


     */
   
    public Font pdfToAwt(BaseFont font, int size) {
        String names[][] = font.getFullFontName();
        if (names.length == 1)
            return new Font(names[0][3], 0, size);
        String name10 = null;
        String name3x = null;
        for (int k = 0; k < names.length; ++k) {
            String name[] = names[k];
            if (name[0].equals("1") && name[1].equals("0"))
                name10 = name[3];
            else if (name[2].equals("1033")) {
                name3x = name[3];
                break;
            }
        }
        String finalName = name3x;
        if (finalName == null)
            finalName = name10;
        if (finalName == null)
            finalName = names[0][3];
        return new Font(finalName, 0, size);
    }
View Full Code Here


        currentStroke = new BasicStroke(1.0f, BasicStroke.CAP_SQUARE,
                BasicStroke.JOIN_MITER, 10.0f, null, 0.0f);

        super.setColor(Color.BLACK);
        super.setBackground(Color.BLACK);
        super.setFont(new Font("Dialog", Font.PLAIN, 12));

        // Initialize the rendering hints.
        hints = new RenderingHints(null);
    }
View Full Code Here

        }

        // draw strings directly?
        if (isProperty(TEXT_AS_SHAPES)) {
         
          Font font = getFont();
         
            // NOTE, see FVG-199, createGlyphVector does not seem to create the proper glyphcodes
            // for either ZapfDingbats or Symbol. We use our own encoding which seems to work...
          String fontName = font.getName();
//          if (fontName.equals("Symbol") || fontName.equals("ZapfDingbats")) {
//            string = FontEncoder.getEncodedString(string, fontName);
//            // use a standard font, not Symbol.
//            font = new Font("Serif", font.getStyle(), font.getSize());
//          }
         
          // create glyph
            GlyphVector gv = font.createGlyphVector(getFontRenderContext(), string);

            // draw it
            drawGlyphVector(gv, (float) x, (float) y);
        } else {
            // write string directly
View Full Code Here

            // draws all attributes
            TextLayout tl = new TextLayout(iterator, getFontRenderContext());
            tl.draw(this, x, y);
        } else {
            // reset to that font at the end
            Font font = getFont();

            // initial attributes, we us TextAttribute.equals() rather
            // than Font.equals() because using Font.equals() we do
            // not get a 'false' if underline etc. is changed
            Map/*<TextAttribute, ?>*/ attributes = FontUtilities.getAttributes(font);

            // stores all characters which are written with the same font
            // if font is changed the buffer will be written and cleared
            // after it
            StringBuffer sb = new StringBuffer();

            for (char c = iterator.first();
                 c != AttributedCharacterIterator.DONE;
                 c = iterator.next()) {

                // append c if font is not changed
                if (attributes.equals(iterator.getAttributes())) {
                    sb.append(c);

                } else {
                    // TextLayout does not like 0 length strings
                    if (sb.length() > 0) {
                        // draw sb if font is changed
                        drawString(sb.toString(), x, y);
   
                        // change the x offset for the next drawing
                        // FIXME: change y offset for vertical text
                        TextLayout tl = new TextLayout(
                            sb.toString(),
                            attributes,
                            getFontRenderContext());
   
                        // calculate real width
                        x = x + Math.max(
                            tl.getAdvance(),
                            (float)tl.getBounds().getWidth());
                    }
                   
                    // empty sb
                    sb = new StringBuffer();
                    sb.append(c);

                    // change the font
                    attributes = iterator.getAttributes();
                    setFont(new Font(attributes));
                }
            }

            // draw the rest
            if (sb.length() > 0) {
View Full Code Here

                int bulletSize = rt.getBulletSize();
                int fontSize = rt.getFontSize();
                if(bulletSize != -1) fontSize = Math.round(fontSize*bulletSize*0.01f);
                bat.addAttribute(TextAttribute.SIZE, new Float(fontSize));

                if(!new Font(bulletFont.getFontName(), Font.PLAIN, 1).canDisplay(rt.getBulletChar())){
                    bat.addAttribute(TextAttribute.FAMILY, "Arial");
                    bat = new AttributedString("" + DEFAULT_BULLET_CHAR, bat.getIterator().getAttributes());
                }

                if(text.substring(startIndex, endIndex).length() > 1){
View Full Code Here

            CharTable latinTable, ShowString device) throws IOException {

        if (latinTable == null) throw new RuntimeException("FontUtilities.showString(...): latinTable cannot be 'null'");

        STANDARD_FONT[0] = font;
        STANDARD_FONT[1] = new Font("Symbol", Font.PLAIN, font.getSize());
        STANDARD_FONT[2] = new Font("ZapfDingbats", Font.PLAIN, font.getSize());
        STANDARD_CHAR_TABLES[0] = latinTable;

        char[] chars = string.toCharArray();
        String out = "";
        int lastTable = 0;
View Full Code Here

        }

        // dialog.bold -> Dialog with TextAttribute.WEIGHT_BOLD
        Map attributes = FontUtilities.getAttributes(getFont());
        FontTable.normalize(attributes);
        Font font = new Font(attributes);

        Font unitFont = (Font) unitFontTable.get(font);

        Integer fontIndex = (Integer) fontTable.get(font);
        if (fontIndex == null) {
            // for special fonts (Symbol, ZapfDingbats) we choose a standard
            // font and
            // encode using unicode.
            String fontName = font.getName();
            ///string = FontEncoder.getEncodedString(string, fontName);

            String windowsFontName = FontUtilities
                .getWindowsFontName(fontName);

            unitFont = new Font(windowsFontName, font.getStyle(), font
                .getSize());
            unitFont = unitFont.deriveFont(font.getSize2D()
                * UNITS_PER_PIXEL * TWIPS);
            unitFontTable.put(font, unitFont);

            ExtLogFontW logFontW = new ExtLogFontW(unitFont);
            int handle = handleManager.getHandle();
            os.writeTag(new ExtCreateFontIndirectW(handle, logFontW));

            fontIndex = new Integer(handle);
            fontTable.put(font, fontIndex);
        }
        os.writeTag(new SelectObject(fontIndex.intValue()));

        int[] widths = new int[string.length()];
        for (int i = 0; i < widths.length; i++) {
            double w = unitFont.getStringBounds(string, i, i + 1,
                getFontRenderContext()).getWidth();
            widths[i] = (int) w;
        }

        // font transformation sould _not_ transform string position
View Full Code Here

        // remove font transformation
        attributes.remove(TextAttribute.TRANSFORM);
        attributes.remove(TextAttribute.SUPERSCRIPT);

        return new Font(attributes);
    }
View Full Code Here

            // remove font transformations
            attributes.remove(TextAttribute.TRANSFORM);
            attributes.remove(TextAttribute.SUPERSCRIPT);

            this.font = new Font(attributes);

            this.ref = createFontReference(this.font);
            this.encoding = encoding;
            this.written = false;
        }
View Full Code Here

    public String toString() {
        StringBuffer result = new StringBuffer();

        Enumeration/*<Font>*/ fonts = this.glyphs.keys();
        while (fonts.hasMoreElements()) {
            Font font = (Font) fonts.nextElement();

            // replace font family for svg
            Map /*<TextAttribute, ?>*/ attributes = FontUtilities.getAttributes(font);

            // Dialog -> Helvetica
            normalize(attributes);

            // familiy
            result.append("<font id=\"");
            result.append(attributes.get(TextAttribute.FAMILY));
            result.append("\">\n");

            // font-face
            result.append("<font-face font-family=\"");
            result.append(attributes.get(TextAttribute.FAMILY));
            result.append("\" ");

            // bold
            if (TextAttribute.WEIGHT_BOLD.equals(attributes.get(TextAttribute.WEIGHT))) {
                result.append("font-weight=\"bold\" ");
            } else {
                result.append("font-weight=\"normal\" ");
            }

            // italic
            if (TextAttribute.POSTURE_OBLIQUE.equals(attributes.get(TextAttribute.POSTURE))) {
                result.append("font-style=\"italic\" ");
            } else {
                result.append("font-style=\"normal\" ");
            }

            // size
            Float size = (Float) attributes.get(TextAttribute.SIZE);
            result.append("font-size=\"");
            result.append(SVGGraphics2D.fixedPrecision(size.floatValue()));
            result.append("\" ");

            // number of coordinate units on the em square,
            // the size of the design grid on which glyphs are laid out
            result.append("units-per-em=\"");
            result.append(SVGGraphics2D.fixedPrecision(SVGGlyph.FONT_SIZE));
            result.append("\" ");

            TextLayout tl = new TextLayout("By", font, new FontRenderContext(new AffineTransform(), true, true));

            // The maximum unaccented height of the font within the font coordinate system.
            // If the attribute is not specified, the effect is as if the attribute were set
            // to the difference between the units-per-em value and the vert-origin-y value
            // for the corresponding font.
            result.append("ascent=\"");
            result.append(tl.getAscent());
            result.append("\" ");

            // The maximum unaccented depth of the font within the font coordinate system.
            // If the attribute is not specified, the effect is as if the attribute were set
            // to the vert-origin-y value for the corresponding font.
            result.append("desscent=\"");
            result.append(tl.getDescent());
            result.append("\" ");

            // For horizontally oriented glyph layouts, indicates the alignment
            // coordinate for glyphs to achieve alphabetic baseline alignment.
            // result.append("alphabetic=\"0\"

            // close "<font-face"
            result.append("/>\n");

            // missing glyph
            SVGGlyph glyph = createGlyph(font.getMissingGlyphCode(), font);
            result.append("<missing-glyph ");
            result.append(glyph.getHorizontalAdvanceXString());
            result.append(" ");
            result.append(glyph.getPathString());
            result.append("/>\n");
View Full Code Here

TOP

Related Classes of com.google.code.appengine.awt.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.