title: JavaFX - setFont() and setStyle() produce markedly different results. Why?
body: <p>I've noticed that if I set the font of an object using setFont(), it always renders on the screen quite a bit smaller than if I set that same font using setStyle(). Why is this?</p>
  
  <p>For Example:</p>
  
  <pre><code>import javafx.application.Application;
  import javafx.geometry.Insets;
  import javafx.scene.Scene;
  import javafx.scene.layout.FlowPane;
  import javafx.scene.text.Font;
  import javafx.scene.text.Text;
  import javafx.stage.Stage;
  
  public class Main extends Application {
  
      @Override
      public void start(Stage primaryStage) throws Exception{
          FlowPane contentPane = new FlowPane();
          contentPane.setPadding(new Insets(10));
  
          Text setFontText = new Text("setFont(\"Courier\", 14)");
          setFontText.setFont(Font.font("Courier", 14));
  
          Text setStyleText = new Text("setStyle(\"-fx-font-family:Courier; -fx-font-size: 14pt\")");
          setStyleText.setStyle("-fx-font-family: Courier; -fx-font-size: 14pt");
  
          contentPane.getChildren().addAll(setFontText, setStyleText);
  
          primaryStage.setTitle("These Fonts Though");
          primaryStage.setScene(new Scene(contentPane, 500, 275));
          primaryStage.show();
      }
  
      public static void main(String[] args) {
          launch(args);
      }
  }
  </code></pre>
  
  <p>This produces the following display:
  <a href="https://i.stack.imgur.com/aiklC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aiklC.png" alt="output"></a></p>