Package java.awt.font

Examples of java.awt.font.GlyphVector


     */
    private double calculateKerningOffset(int code1, int code2)
    {
        char[] chars =
        { (char) code1, (char) code2 };
        GlyphVector gv = font.createGlyphVector(frc, chars);
       
        //        double adj = (gv.getGlyphPosition(1).getX() - metrics.charWidth(chars[0])) * scale;
        double adj = (gv.getGlyphPosition(1).getX() - gv.getGlyphMetrics(0).getAdvanceX()) * scale;
       
        if (DEBUG_KERNING) System.out.println("Kerning for '" + (char) code1 + (char) code2 + "': " + adj);
       
        return adj;
    }
View Full Code Here


  //----------------------------------------------------------------------------
  protected void noEffect(Movie movie, int speed)
  {
    Frame frame = movie.appendFrame();
    AlphaColor fill_color = new AlphaColor(font_.getColor().getRed(), font_.getColor().getGreen(), font_.getColor().getBlue(), font_.getColor().getAlpha());
    GlyphVector glyphs = font_.getAWTFont().layoutGlyphVector(DrawSWFFont.CONTEXT, font_.getText().toCharArray(), 0, font_.getText().length(), Font.LAYOUT_LEFT_TO_RIGHT);

    Shape shape = new Shape();
    shape.defineFillStyle(fill_color);
    shape.setRightFillStyle(1);
    shape.drawAWTPathIterator(glyphs.getOutline().getPathIterator(null));

    Instance instance = frame.placeSymbol(shape, (int) position_.getX(), (int) position_.getY());

    waitMovie(movie, speed);
  }
View Full Code Here

  protected void fadeIn(Movie movie, int speed)
  {
    Frame frame;
    Instance instance;
    AlphaColor fill_color = new AlphaColor(font_.getColor().getRed(), font_.getColor().getGreen(), font_.getColor().getBlue(), font_.getColor().getAlpha());
    GlyphVector glyphs = font_.getAWTFont().layoutGlyphVector(DrawSWFFont.CONTEXT, font_.getText().toCharArray(), 0, font_.getText().length(), Font.LAYOUT_LEFT_TO_RIGHT);
    Shape shape = new Shape();
    shape.defineFillStyle(fill_color);
    shape.setRightFillStyle(1);
    shape.drawAWTPathIterator(glyphs.getOutline().getPathIterator(null));

    double width = glyphs.getLogicalBounds().getWidth() / 2.0;
    double center = position_.getX() + width;
    double scale = 2.0;

    frame = movie.appendFrame();
    instance = frame.placeSymbol(shape, new Transform(), new AlphaTransform());
View Full Code Here

  protected void typeLetters(Movie movie, int speed)
  {
    Frame frame;
    Instance instance;
    AlphaColor fill_color = new AlphaColor(font_.getColor().getRed(), font_.getColor().getGreen(), font_.getColor().getBlue(), font_.getColor().getAlpha());
    GlyphVector glyphs = font_.getAWTFont().layoutGlyphVector(DrawSWFFont.CONTEXT, font_.getText().toCharArray(), 0, font_.getText().length(), Font.LAYOUT_LEFT_TO_RIGHT);
    Shape shape;

    for (int char_index = 0; char_index < glyphs.getNumGlyphs(); char_index++)
    {
      if (font_.getText().charAt(char_index) != ' ')
      {
        shape = new Shape();
        shape.defineFillStyle(fill_color);
        shape.setRightFillStyle(1);
        shape.drawAWTPathIterator(glyphs.getGlyphOutline(char_index).getPathIterator(null));

        double width = glyphs.getGlyphOutline(char_index).getBounds2D().getX() + glyphs.getGlyphOutline(char_index).getBounds2D().getWidth() / 2.0;
        double height = glyphs.getLogicalBounds().getHeight() / 2.0;
        double center_x = position_.getX() + width;
        double center_y = position_.getY() - height;
        double scale = 2.0;

        frame = movie.appendFrame();
View Full Code Here

        Point3d upper = new Point3d(), lower = new Point3d();
        b.getLower(lower);
        b.getUpper(upper);
       
        // Workaround for a bounding box bug -- assumes that M and ( have same ascent
        GlyphVector fix = font.getFont().createGlyphVector(new FontRenderContext(null, false, false), "M(");
        Point3d fixu = new Point3d(), fixl = new Point3d();
        font.getBoundingBox(fix.getGlyphCode(0), b);
        b.getUpper(fixu);
        b.getLower(fixl);
        double h1 = fixu.y-fixl.y;
        font.getBoundingBox(fix.getGlyphCode(1), b);
        b.getUpper(fixu);
        b.getLower(fixl);
        double h2 = fixu.y-fixl.y;
        upper.y = h1;
        lower.y = h1-h2;
View Full Code Here

     *
     ***************************************************************************/

    @Override
    public void drawString(AttributedCharacterIterator iterator, float x, float y) {
        GlyphVector gv = font.createGlyphVector(frc, iterator);
        drawGlyphVector(gv, x, y);
    }
View Full Code Here

        this.font = font;

        int missingGlyphCode = font.getMissingGlyphCode();
        FontRenderContext fontRenderContext = Platform.getFontRenderContext();

        GlyphVector missingGlyphVector = font.createGlyphVector(fontRenderContext,
            new int[] {missingGlyphCode});
        Rectangle2D textBounds = missingGlyphVector.getLogicalBounds();

        Rectangle2D maxCharBounds = font.getMaxCharBounds(fontRenderContext);
        averageCharacterSize = new Dimensions((int)Math.ceil(textBounds.getWidth()),
            (int)Math.ceil(maxCharBounds.getHeight()));
View Full Code Here

            this.lineWidth = lineWidth;

            int missingGlyphCode = font.getMissingGlyphCode();
            FontRenderContext fontRenderContext = Platform.getFontRenderContext();

            GlyphVector missingGlyphVector = font.createGlyphVector(fontRenderContext,
                new int[] {missingGlyphCode});
            Rectangle2D textBounds = missingGlyphVector.getLogicalBounds();

            Rectangle2D maxCharBounds = font.getMaxCharBounds(fontRenderContext);
            averageCharacterSize = new Dimensions((int)Math.ceil(textBounds.getWidth()),
                (int)Math.ceil(maxCharBounds.getHeight()));
View Full Code Here

        }
    }

    private void appendLine(String text, int start, int end, FontRenderContext fontRenderContext) {
        StringCharacterIterator line = new StringCharacterIterator(text, start, end, start);
        GlyphVector glyphVector = font.createGlyphVector(fontRenderContext, line);
        glyphVectors.add(glyphVector);

        Rectangle2D textBounds = glyphVector.getLogicalBounds();
        textHeight += textBounds.getHeight();
    }
View Full Code Here

                    break;
                }
            }

            for (int i = 0, n = glyphVectors.getLength(); i < n; i++) {
                GlyphVector glyphVector = glyphVectors.get(i);

                Rectangle2D textBounds = glyphVector.getLogicalBounds();
                float lineWidth = (float)textBounds.getWidth();

                float x = 0;
                switch (horizontalAlignment) {
                    case LEFT: {
View Full Code Here

TOP

Related Classes of java.awt.font.GlyphVector

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.