Example usage for java.awt Font isItalic

List of usage examples for java.awt Font isItalic

Introduction

In this page you can find the example usage for java.awt Font isItalic.

Prototype

public boolean isItalic() 

Source Link

Document

Indicates whether or not this Font object's style is ITALIC.

Usage

From source file:Main.java

public static String getHTMLFontStyle(Font font) {
    StringBuffer out = new StringBuffer();
    out.append("font-size: " + font.getSize() + "px; ");
    out.append("font-family: " + font.getSize() + "; ");
    if (font.isItalic())
        out.append("font-style: italic; ");
    if (font.isBold())
        out.append("font-weight: bold; ");
    return out.toString();
}

From source file:NwFontChooserS.java

static public String fontString(Font font) {
    String fs = font.getFamily();
    if (!font.isPlain()) {
        fs += "-";
        if (font.isBold()) {
            fs += "BOLD";
        }//from w w w  . j a v a2s.com
        if (font.isItalic()) {
            fs += "ITALIC";
        }
    }
    fs += "-" + font.getSize();
    return (fs);
}

From source file:Main.java

public static String displayPropertiesToCSS(Font font, Color fg) {
    StringBuffer rule = new StringBuffer("body {");
    if (font != null) {
        rule.append(" font-family: ");
        rule.append(font.getFamily());//from   w w  w .  j a v a2 s . com
        rule.append(" ; ");
        rule.append(" font-size: ");
        rule.append(font.getSize());
        rule.append("pt ;");
        if (font.isBold()) {
            rule.append(" font-weight: 700 ; ");
        }
        if (font.isItalic()) {
            rule.append(" font-style: italic ; ");
        }
    }
    if (fg != null) {
        rule.append(" color: #");
        if (fg.getRed() < 16) {
            rule.append('0');
        }
        rule.append(Integer.toHexString(fg.getRed()));
        if (fg.getGreen() < 16) {
            rule.append('0');
        }
        rule.append(Integer.toHexString(fg.getGreen()));
        if (fg.getBlue() < 16) {
            rule.append('0');
        }
        rule.append(Integer.toHexString(fg.getBlue()));
        rule.append(" ; ");
    }
    rule.append(" }");
    return rule.toString();
}

From source file:Main.java

public void paint(Graphics g) {
    Font f = g.getFont();

    System.out.println(f.isItalic());

    g.drawString("java2s.com", 4, 16);
}

From source file:FontChooser.java

public void setFont(Font font) throws IllegalArgumentException {
    if (font == null) {
        throw new IllegalArgumentException("Null Font passed");
    }/*  w w  w .ja va 2 s .  c om*/
    _familyName = font.getFamily();
    _isBold = font.isBold();
    _isItalic = font.isItalic();
    _size = font.getSize();
}

From source file:FontChooser.java

/**
 * Show dialog defaulting to the passed font.
 *
 * @param font  The font to default to./*from   ww  w.ja  v  a 2 s .  c  om*/
 */
public Font showDialog(Font font) {
    if (font != null) {
        _fontNamesCmb.setSelectedItem(font.getName());
        _fontSizesCmb.setSelectedItem("" + font.getSize());
        _boldChk.setSelected(_selectStyles && font.isBold());
        _italicChk.setSelected(_selectStyles && font.isItalic());
    } else {
        _fontNamesCmb.setSelectedIndex(0);
        _fontSizesCmb.setSelectedIndex(0);
        _boldChk.setSelected(false);
        _italicChk.setSelected(false);
    }
    setupPreviewLabel();
    setVisible(true);
    return _font;
}

From source file:au.org.ala.delta.editor.ui.image.ImageSettingsDialog.java

private void updateFromFont(Font font, JComboBox name, JComboBox size, JCheckBox bold, JCheckBox italic) {
    name.getModel().setSelectedItem(font.getFamily());
    size.getModel().setSelectedItem(font.getSize());
    bold.setSelected(font.isBold());//w ww.  jav a  2 s  . c  o  m
    italic.setSelected(font.isItalic());
}

From source file:org.nuclos.client.ui.collect.Chart.java

static String fontToString(Font font) {
    String strStyle;/*w ww. j a va2  s .  c om*/

    if (font.isBold()) {
        strStyle = font.isItalic() ? "bolditalic" : "bold";
    } else {
        strStyle = font.isItalic() ? "italic" : "plain";
    }

    return font.getName() + "-" + strStyle + "-" + font.getSize();
}

From source file:nz.govt.natlib.ndha.manualdeposit.metadata.PersonalSettings.java

public void setStandardFont(final Font value) {
    fontName = value.getFontName();/*from   w ww.  j  a  v  a  2  s.co m*/
    fontSize = value.getSize();
    fontBold = value.isBold();
    fontItalic = value.isItalic();
    fontPlain = value.isPlain();
    saveData();
}

From source file:org.docx4j.fonts.fop.fonts.FontInfo.java

/**
 * Returns a suitable internal font given an AWT Font instance.
 *
 * @param awtFont the AWT font/*www .  java2  s.  c  o  m*/
 * @return a best matching internal Font
 */
public Font getFontInstanceForAWTFont(java.awt.Font awtFont) {
    String awtFontName = awtFont.getName();
    String awtFontFamily = awtFont.getFamily();
    String awtFontStyle = awtFont.isItalic() ? Font.STYLE_ITALIC : Font.STYLE_NORMAL;
    int awtFontWeight = awtFont.isBold() ? Font.WEIGHT_BOLD : Font.WEIGHT_NORMAL;

    FontTriplet matchedTriplet = null;
    List/*<FontTriplet>*/ triplets = getTripletsForName(awtFontName);
    if (!triplets.isEmpty()) {
        Iterator it = triplets.iterator();
        while (it.hasNext()) {
            FontTriplet triplet = (FontTriplet) it.next();
            boolean styleMatched = triplet.getStyle().equals(awtFontStyle);
            boolean weightMatched = triplet.getWeight() == awtFontWeight;
            if (styleMatched && weightMatched) {
                matchedTriplet = triplet;
                break;
            }
        }
    }

    // not matched on font name so do a lookup using family
    if (matchedTriplet == null) {
        if (awtFontFamily.equals("sanserif")) {
            awtFontFamily = "sans-serif";
        }
        matchedTriplet = fontLookup(awtFontFamily, awtFontStyle, awtFontWeight);
    }
    int fontSize = Math.round(awtFont.getSize2D() * 1000);
    return getFontInstance(matchedTriplet, fontSize);
}