Package java.awt

Examples of java.awt.Font


    // correct Font
    if (html.indexOf("<html>") >= 0) {
      html = StringUtils.substringBetween(html, "<html>", "</html>");
    }
    JLabel label = new JLabel();
    Font font = label.getFont();
    html = "<html><div style=\"color:" + UiUtilities.getHTMLColorCode(label.getForeground())+";font-family:" + font.getName()
        + "; font-size:" + font.getSize() +";background-color:rgb(" + background.getRed() + "," + background.getGreen() + "," + background.getBlue() + ");\">" + html + "</div></html>";

    final JEditorPane pane = new JEditorPane("text/html", html);
    pane.setBorder(BorderFactory.createEmptyBorder());
    pane.setEditable(false);
    pane.setFont(font);
View Full Code Here


  /**
   * Set local FontMetrics from the <code>JTextArea</code>
   * Calls revalidate() and repaint()
   */
  private void setMetrics() {
    Font refFont = null;
  
    Document doc = this.textComponent.getDocument();
    if(doc instanceof DefaultStyledDocument) {
        DefaultStyledDocument myDoc = (DefaultStyledDocument)doc;
        refFont = myDoc.getFont(myDoc.getDefaultRootElement().getElement(0)
View Full Code Here

      mTitle.setEnabled(enabled);
    }
  }

  public Font getChosenFont() {
    Font result;
    int style;
    int inx = mStyleCB.getSelectedIndex();
    if (inx == 0) {
      style = Font.PLAIN;
    } else if (inx == 1) {
      style = Font.BOLD;
    } else {
      style = Font.ITALIC;
    }
    result = new Font((String) mFontCB.getSelectedItem(), style, ((Integer) mSizeSpinner.getValue()).intValue());

    return result;
  }
View Full Code Here

   * Reloads the font settings and sets a dynamic font size
   * @param newOffset increase or decrease compared to standard font size
   * @since 2.6
   */
  public static boolean updateFonts(int newOffset) {
    Font oldTitleFont = mTitleFont;
    Font oldTimeFont = mTimeFont;
    Font oldNormalFont = mNormalFont;
    boolean useDefaults = Settings.propUseDefaultFonts.getBoolean();
    if (useDefaults) {
      mTitleFont = Settings.propProgramTitleFont.getDefault();
      mTimeFont = Settings.propProgramTimeFont.getDefault();
      mNormalFont = Settings.propProgramInfoFont.getDefault();
View Full Code Here

* @author Til Schneider, www.murfman.de
*/
public class TextLineBreakerTest extends TestCase {

  public void testLineBreak() throws IOException {
    Font font = new Font("Dialog", Font.PLAIN, 12);
   
    TextLineBreakerFontWidth breaker = new TextLineBreakerFontWidth(font);

    // A normal line break   
    String text = "Es ging der Stiefel und sein Knecht von Kniggeb\u00fchl "
View Full Code Here

*/
public TextFieldWidget(SectionWidget sw, Field field) {
    super(sw, field);

    // Calculate line height.
    Font f = field.getFormat().getFont();
    FontMetrics fm = swingField.getComponent().getFontMetrics(f);
    lineHeight = fm.getHeight();
}
View Full Code Here

                        string, graphics.getFontRenderContext()));
    }
   
    public int getWidth(FontContext fc, FSFont font, String string) {
        Graphics2D graphics = ((Java2DFontContext)fc).getGraphics();
        Font awtFont = ((AWTFSFont)font).getAWTFont();
        return (int)Math.ceil(
                graphics.getFontMetrics(awtFont).getStringBounds(string, graphics).getWidth());
    }
View Full Code Here

    }

    public float[] getGlyphPositions(OutputDevice outputDevice, FSFont font, String text) {
        Object prevHint = null;
        Graphics2D graphics = ((Java2DOutputDevice)outputDevice).getGraphics();
        Font awtFont = ((AWTFSFont)font).getAWTFont();
       
        if (awtFont.getSize() > threshold && level > NONE ) {
            prevHint = graphics.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING);
            graphics.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING, antiAliasRenderingHint );
        }
       
        GlyphVector vector = awtFont.createGlyphVector(
                graphics.getFontRenderContext(),
                text);
        float[] result = vector.getGlyphPositions(0, text.length() + 1, null);
       
        if (awtFont.getSize() > threshold && level > NONE ) {
            graphics.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING, prevHint );
        }
       
        return result;
    }
View Full Code Here

    }

    public Rectangle getGlyphBounds(OutputDevice outputDevice, FSFont font, FSGlyphVector fsGlyphVector, int index, float x, float y) {
        Object prevHint = null;
        Graphics2D graphics = ((Java2DOutputDevice)outputDevice).getGraphics();
        Font awtFont = ((AWTFSFont)font).getAWTFont();
       
        if (awtFont.getSize() > threshold && level > NONE ) {
            prevHint = graphics.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING);
            graphics.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING, antiAliasRenderingHint );
        }
       
        GlyphVector vector = ((AWTFSGlyphVector)fsGlyphVector).getGlyphVector();
       
        Rectangle result = vector.getGlyphPixelBounds(index, graphics.getFontRenderContext(), x, y);
       
        if (awtFont.getSize() > threshold && level > NONE ) {
            graphics.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING, prevHint );
        }
       
        return result;
    }
View Full Code Here

    }

    public float[] getGlyphPositions(OutputDevice outputDevice, FSFont font, FSGlyphVector fsGlyphVector) {
        Object prevHint = null;
        Graphics2D graphics = ((Java2DOutputDevice)outputDevice).getGraphics();
        Font awtFont = ((AWTFSFont)font).getAWTFont();
       
        if (awtFont.getSize() > threshold && level > NONE ) {
            prevHint = graphics.getRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING);
            graphics.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING, antiAliasRenderingHint );
        }
       
        GlyphVector vector = ((AWTFSGlyphVector)fsGlyphVector).getGlyphVector();
       
        float[] result = vector.getGlyphPositions(0, vector.getNumGlyphs() + 1, null);
       
        if (awtFont.getSize() > threshold && level > NONE ) {
            graphics.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING, prevHint );
        }
       
        return result;
    }
View Full Code Here

TOP

Related Classes of java.awt.Font

Copyright © 2015 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.