Package java.awt.font

Examples of java.awt.font.FontRenderContext


public class LineMetricsImplRTest extends TestCase {
   
    public void testGetLineMetrics() {
            Font font = new Font("Dialog", Font.PLAIN, 12);
            FontRenderContext frc = new FontRenderContext(null, false, false);
            final int count = 100;
        try {
            for (int i = 0; i < count; i++) {
                LineMetrics lm = font.getLineMetrics("", frc);
            }
View Full Code Here


  {
    super.setFont(font);

    if (renderNamesVertically)
    {
      final Rectangle2D bounds = font.getStringBounds("100%", new FontRenderContext(null, true, true));
      this.padding = bounds.getWidth() - bounds.getHeight();
    }
    else
    {
      final Rectangle2D bounds = font.getStringBounds("xxxPage Headerxxx", new FontRenderContext(null, true, true)); // NON-NLS
      this.padding = bounds.getWidth();
    }
  }
View Full Code Here

    }
  }

  private void drawRotatedText(final Graphics2D g2d, final int x, final int y, final String text)
  {
    final FontRenderContext fontRenderContext = g2d.getFontRenderContext();
    final Font font = getFont();
    final Rectangle2D sb = font.getStringBounds(text, fontRenderContext);
    final int width = (int) sb.getWidth() + 4;

    final LineMetrics lineMetrics = font.getLineMetrics(text, fontRenderContext);
View Full Code Here

    g2d.setTransform(oldTransform);
  }

  private void drawText(final Graphics2D g2d, final int x, final int y, final String text)
  {
    final FontRenderContext fontRenderContext = g2d.getFontRenderContext();
    final Font font = getFont();
    final LineMetrics lineMetrics = font.getLineMetrics(text, fontRenderContext);
    final float ascent = lineMetrics.getAscent();
    g2d.setFont(font);
    g2d.setColor(getForeground());
View Full Code Here

  private static ImageIcon createRotatedTextIcon(final Color foreground,
                                                 final int rotate,
                                                 final Font font,
                                                 final String text)
  {
    final FontRenderContext fontRenderContext = new FontRenderContext(null, false, false);
    final GlyphVector glyphs = font.createGlyphVector(fontRenderContext, text);
    final int width = (int) glyphs.getLogicalBounds().getWidth() + 4;
    //height = (int)glyphs.getLogicalBounds().getHeight();

    final LineMetrics lineMetrics = font.getLineMetrics(text, fontRenderContext);
View Full Code Here

  }

  private FontRenderContext createFontRenderContext(final StyleSheet layoutContext)
  {
    final boolean antiAliasing = RenderUtility.isFontSmooth(layoutContext, getMetaData());
    return new FontRenderContext(null, antiAliasing, true);
  }
View Full Code Here

  private LineBreakIterator createLineBreakIterator(final ParagraphRenderBox box,
                                                    final StyleSheet layoutContext,
                                                    final RichTextSpec richText)
  {
    final AttributedCharacterIterator ci = richText.createAttributedCharacterIterator();
    final FontRenderContext fontRenderContext = createFontRenderContext(layoutContext);
    final boolean breakOnWordBoundary = strictCompatibility ||
        layoutContext.getBooleanStyleProperty(TextStyleKeys.WORDBREAK);

    if (breakOnWordBoundary)
    {
View Full Code Here

                               final ParagraphPoolBox lineBoxContainer,
                               final StyleSheet layoutContext)
  {
    RichTextSpec richText = RichTextSpecProducer.compute(lineBoxContainer, metaData, resourceManager);

    final FontRenderContext fontRenderContext = createFontRenderContext(layoutContext);
    final TextLayout textLayout = new TextLayout(richText.createAttributedCharacterIterator(), fontRenderContext);
    double height = textLayout.getAscent() + textLayout.getDescent() + textLayout.getLeading();

    final RenderableComplexText text = richText.create(lineBoxContainer);
    text.setTextLayout(textLayout);
View Full Code Here

  {
    final boolean antialias = RenderingHints.VALUE_TEXT_ANTIALIAS_ON.equals(getRenderingHint(
        RenderingHints.KEY_TEXT_ANTIALIASING));
    final boolean fractions = RenderingHints.VALUE_FRACTIONALMETRICS_ON.equals(getRenderingHint(
        RenderingHints.KEY_FRACTIONALMETRICS));
    return new FontRenderContext(new AffineTransform(), antialias, fractions);
  }
View Full Code Here

    }
    g2.translate(-x, -y);
    x += b.getWidth() / 2.0 + 3.0;
    g2.setFont(this.font);

    final FontRenderContext frc = g2.getFontRenderContext();
    final Font f = g2.getFont();
//    final FontMetrics fm = g2.getFontMetrics(f);
    final LineMetrics metrics = f.getLineMetrics(label, frc);
    final float ascent = metrics.getAscent();
    final float halfAscent = ascent / 2.0f;
View Full Code Here

TOP

Related Classes of java.awt.font.FontRenderContext

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.