Font

Font collects the typographic properties applied to JDance Text and other components. It can control size, weight, family, color, italics, underline, and line spacing.

For the complete API reference, visit https://doc.jdance.org.

Overview

A few font properties establish a visual hierarchy: a larger heading, a regular description, and an emphasized label.

CODE
BasicLayout layout = new BasicLayout(BasicLayout.Direction.VERTICAL);
layout.setRelativeWidth(100);
layout.setGap(6);
layout.add(new Text("Heading").setFont(new Font().setSize(22).setBold(true)));
layout.add(new Text("Body text").setFont(new Font().setSize(14)));
layout.add(new Text("Important").setFont(new Font().setColor(new Color("#0783C5")).setWeight(600)));
RESULT
Heading
Body text
Important

The preview above uses a small amount of space so the behavior is visible even in a narrow documentation panel.

Reusing and varying a font

A Font can be copied and modified to create related text styles. This keeps typography consistent without repeating every setting.

CODE
BasicLayout layout = new BasicLayout(BasicLayout.Direction.VERTICAL);
layout.setRelativeWidth(100);
layout.setGap(8);
layout.add(new Text("Italic").setFont(new Font().setItalic(true)));
layout.add(new Text("Underlined").setFont(new Font().setUnderlined(true)));
layout.add(new Text("Monospace").setFont(new Font().setFamily("monospace")));
RESULT
Italic
Underlined
Monospace

Readability first

Font size and line height influence how much room text needs. Bold and bright colors should highlight meaning rather than becoming the default for every label.

Copying a font

The same idea can also be expressed as a compact Java snippet without requiring a live preview.

CODE
Font regular = new Font().setSize(16).setColor(new Color("#333333"));
Font heading = new Font(regular).setSize(22).setBold(true);

Practical guidance

Use fonts consistently across the interface. A small set of heading, body and supporting styles is usually clearer than individually styling every piece of text.

Full API reference

These examples focus on the day-to-day use of Font. The full API documentation contains additional options, inherited properties and complete method signatures.

Visit https://doc.jdance.org for the full reference.