Skip to content

Instantly share code, notes, and snippets.

@kentcollins
Created June 26, 2020 09:41
Show Gist options
  • Save kentcollins/0eca12aaf51a6590860c69a2122dc217 to your computer and use it in GitHub Desktop.
Save kentcollins/0eca12aaf51a6590860c69a2122dc217 to your computer and use it in GitHub Desktop.
StdLib way of changing the font face or size
public static void main(String[] args) {
Font larger = new Font("Arial", Font.BOLD, 128);
StdDraw.setFont(larger);
StdDraw.text(0.5, 0.5, "OK");
Font smaller = new Font("Times New Roman", Font.ITALIC, 64);
StdDraw.setFont(smaller);
StdDraw.text(0.6, 0.45, "Go!");
}
@kentcollins
Copy link
Author

The name of the font must refer to a system font loaded onto your system. Once setFont has been called, any further text() operations will use the new font.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment