Bounds bounds = TextBuilder.create().text(text).font(font).build().getLayoutBounds(); double width=bounds.getWidth(); double height=bounds.getHeight();