https://kotlinlang.org logo
r

Ruckus

03/30/2017, 2:49 PM
@ron Make sure the font is loaded. JavaFX can only use a font that is loaded. Here's an example:
Copy code
class FontTest : App(Main::class, Styles::class) {
    class Main : View("Font Test") {
        override val root = stackpane {
            label("This is my Label") {
                addClass(Styles.custom)
            }
        }
    }

    class Styles : Stylesheet() {
        companion object {
            val custom by cssclass()
            val riesling: Font = Styles::class.java.getResourceAsStream("/fonts/riesling.ttf").use {
                Font.loadFont(it, 48.0)
            }
        }

        init {
            custom {
                padding = box(25.px)
                font = riesling
            }
        }
    }
}