Search in sources :

Example 1 with FontPosture

use of javafx.scene.text.FontPosture in project org.csstudio.display.builder by kasemir.

the class GraphicsUtils method convert.

/**
 * Convert font
 *  @param font AWT font
 *  @return JFX font
 */
public static Font convert(final java.awt.Font font) {
    final FontWeight weight = font.isBold() ? FontWeight.BOLD : FontWeight.NORMAL;
    final FontPosture posture = font.isItalic() ? FontPosture.ITALIC : FontPosture.REGULAR;
    return Font.font(font.getFamily(), weight, posture, font.getSize());
}
Also used : FontPosture(javafx.scene.text.FontPosture) FontWeight(javafx.scene.text.FontWeight)

Example 2 with FontPosture

use of javafx.scene.text.FontPosture in project Zong by Xenoage.

the class JfxFontUtils method toJavaFXFont.

public static Font toJavaFXFont(FontInfo font) {
    String family = font.getFamilies().get(0);
    FontWeight weight = (font.getStyle().isSet(FontStyle.Bold) ? FontWeight.BOLD : FontWeight.NORMAL);
    FontPosture posture = (font.getStyle().isSet(FontStyle.Italic) ? FontPosture.ITALIC : FontPosture.REGULAR);
    double size = font.getSize();
    return Font.font(family, weight, posture, size);
}
Also used : FontPosture(javafx.scene.text.FontPosture) FontWeight(javafx.scene.text.FontWeight)

Example 3 with FontPosture

use of javafx.scene.text.FontPosture in project fxexperience2 by EricCanull.

the class FontPickerController method changeFont.

private void changeFont() {
    try {
        double size = numberFormat.parse(sizeComboBox.getValue()).doubleValue();
        FontWeight weight = styleChoiceBox.getSelectionModel().isSelected(0) || styleChoiceBox.getSelectionModel().isSelected(1) ? FontWeight.BOLD : FontWeight.NORMAL;
        FontPosture posture = styleChoiceBox.getSelectionModel().isSelected(1) || styleChoiceBox.getSelectionModel().isSelected(2) ? FontPosture.ITALIC : FontPosture.REGULAR;
        String family = familyComboBox.getValue();
        font.setValue(Font.font(family, weight, posture, size));
        sampleFontText.setFont(font.get());
    } catch (java.text.ParseException ex) {
        Logger.getLogger(FontPickerController.class.getName()).log(Level.SEVERE, null, ex);
    }
}
Also used : FontPosture(javafx.scene.text.FontPosture) FontWeight(javafx.scene.text.FontWeight)

Example 4 with FontPosture

use of javafx.scene.text.FontPosture in project Gargoyle by callakrsos.

the class FontViewComposite method loadFont.

/**
	 * @작성자 : KYJ
	 * @작성일 : 2016. 12. 2.
	 */
private void loadFont() {
    FontWeight fontWeight = FontWeight.findByWeight((int) sliderFontWeight.getValue());
    FontPosture fontStyle = FontPosture.findByName(cbFontStyles.getValue());
    double fontSize = sliderFontSize.getValue();
    String fontName = cbFontNames.getValue();
    LOGGER.debug("{} {} {} {}", fontName, fontWeight, fontStyle, fontSize);
    Font font = Font.font(fontName, fontWeight, fontStyle, fontSize);
    if (font != null)
        lblPreviewText.setFont(font);
}
Also used : FontPosture(javafx.scene.text.FontPosture) FontWeight(javafx.scene.text.FontWeight) Font(javafx.scene.text.Font)

Example 5 with FontPosture

use of javafx.scene.text.FontPosture in project jphp by jphp-compiler.

the class UXFont method withNameAndSize.

protected Font withNameAndSize(String name, double size, Boolean bold, Boolean italic) {
    Font font = getWrappedObject();
    FontWeight weight = bold != null && bold ? FontWeight.BOLD : FontWeight.THIN;
    FontPosture posture = italic != null && italic ? FontPosture.ITALIC : FontPosture.REGULAR;
    if (font.getStyle().toUpperCase().contains("BOLD")) {
        weight = FontWeight.BOLD;
    }
    if (font.getStyle().toUpperCase().contains("ITALIC")) {
        posture = FontPosture.ITALIC;
    }
    return Font.font(name, weight, posture, size);
}
Also used : FontPosture(javafx.scene.text.FontPosture) FontWeight(javafx.scene.text.FontWeight) Font(javafx.scene.text.Font)

Aggregations

FontPosture (javafx.scene.text.FontPosture)5 FontWeight (javafx.scene.text.FontWeight)5 Font (javafx.scene.text.Font)2