Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
Small fixes in test; plan Operation: Zen.
Browse files Browse the repository at this point in the history
Former-commit-id: e19b6cf
  • Loading branch information
tommyettinger committed Apr 24, 2023
1 parent 9f3cd44 commit 233e976
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
34 changes: 34 additions & 0 deletions OperationZen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# The Problem

It is too hard right now to configure the many various aspects of a font.

Because anything you might want to adjust is affected by shared metrics, it's nearly impossible to make a small change
without causing a chain reaction.

Strikethrough and underline are stuck together and update in lockstep. They're affected by the x and y offsets, but
those also affect inline image (usually emoji) positions. Emoji may need different position adjustments than the
game-icons.net images, and right now there's no way for a Font to specify that emoji should be some distance away.

The measurement systems for fonts are a total mess, with many parts operating on the numbers as used in a .fnt file
(without any scaling), but some operating on the current scaled size or working with a multiplier on one of those sizes.

# Commencing Operation: Zen

The goal here is to keep the old ways of adjusting fonts where possible, but to allow additional configuration on every
little detail of a font's metrics, and to have the new configuration consistently use fractions of the displayed size
as its unit of measure.

I feel like I need a fancy codename here because this is a large and important section for the code changes soon.

A checklist:
- I think we should separate strikethrough and underline configuration.
- Allow each to have x and y positions and sizes configured, including thickness.
- Store configurations for atlases on a per-atlas basis, using a keyword to identify an atlas.
- Only a small amount of configuration is needed for each atlas, probably x and y offsets, plus x advance.
- General font metrics should be configurable by normal human beings, not just experts in this weird system.
- We may want to look into making a new file format to save this information outside of code.
- This isn't necessary, probably, but would allow storing more data than .fnt might permit.
- It's possible .fnt is extensible enough already that we wouldn't need this.
- Using a standard file format, such as JSON, may have real advantages.
- AngelCode BMFont is fairly standard already, though.

Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ public void create () {
TextureRegion imageFlipped = new TextureRegion(image);
imageFlipped.flip(true, true);
TextureRegion image2 = new TextureRegion(texture2);
final Font font = new Font(skin.get(Label.LabelStyle.class).font)
.adjustLineHeight(0.75f)
final Font font = new Font(skin.get(Label.LabelStyle.class).font, 0f, 4f, 0f, 0f)
// .adjustLineHeight(0.75f)
.useIntegerPositions(true);
// For unknown reasons, emoji added to this particular font default to being offset by a full emoji width (32)
// on x, and a quarter-emoji width on height (probably because we adjusted line height to 1.25x).
// Using the extra three float arguments for offsetX, offsetY, and xAdvance changes helps a lot here.
KnownFonts.addEmoji(font, -48f, 0f, 0f);
KnownFonts.addEmoji(font, -32f, 4f, 0f);
final Font title = new Font(skin.get("title", Label.LabelStyle.class).font, 0, -2, 0, 0)
.adjustLineHeight(0.75f)
.useIntegerPositions(true);
Expand Down

0 comments on commit 233e976

Please sign in to comment.