Text-fit test measures with bundled Noto Sans, so CI and this PC agree
It used the machine's own sans-serif: Noto Sans here, the wider DejaVu in the CI container, so 8 checks failed only in CI. Noto Sans (OFL) is now a test resource. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -20,6 +20,12 @@ import java.io.File
|
||||
*/
|
||||
class TitleTextFitsTest {
|
||||
private val frc = FontRenderContext(null, true, true)
|
||||
/**
|
||||
* The stand-in for the TV's system font: Noto Sans, from the test resources (9 November 2026), so every machine measures
|
||||
* the same. It was the computer's own sans-serif, which is Noto here but the wider DejaVu in CI.
|
||||
*/
|
||||
private fun standIn(style: Int): Font = Font.createFont(Font.TRUETYPE_FONT,
|
||||
javaClass.getResourceAsStream(if (style == Font.BOLD) "/fonts/NotoSans-Bold.ttf" else "/fonts/NotoSans-Regular.ttf")!!).deriveFont(style, 1f)
|
||||
private fun width(font: Font, text: String) = font.getStringBounds(text, frc).width
|
||||
|
||||
@Test fun bumbleHiveButtonsFitInBarlow() {
|
||||
@@ -47,7 +53,7 @@ class TitleTextFitsTest {
|
||||
|
||||
@Test fun orbiRaidersTitleButtonsFitAtTheLargestFontScale() {
|
||||
// The Arcade buttons' text: 14 sp semibold; a generous sans as a stand-in for the TV's system font.
|
||||
val font = Font(Font.SANS_SERIF, Font.BOLD, 1).deriveFont(14f * 1.3f)
|
||||
val font = standIn(Font.BOLD).deriveFont(14f * 1.3f)
|
||||
val room = 190.0 - 2 * 12 - 4 // the column, its padding, the focus border
|
||||
for (label in listOf(modeLabel(RaidersMode.Story), modeLabel(RaidersMode.Endless), "▶ Play", "? How to Play", "← Back to Arcade")) {
|
||||
val w = width(font, label)
|
||||
@@ -56,13 +62,13 @@ class TitleTextFitsTest {
|
||||
}
|
||||
|
||||
@Test fun channelChaosButtonsAndCardsFitAtTheLargestFontScale() {
|
||||
val font = Font(Font.SANS_SERIF, Font.BOLD, 1).deriveFont(14f * 1.3f)
|
||||
val font = standIn(Font.BOLD).deriveFont(14f * 1.3f)
|
||||
for ((label, column) in listOf("▶ Play" to 210, "? How to Play" to 210, "← Back to Arcade" to 210, "▶ Play Again" to 160, "← Back to Arcade" to 200)) {
|
||||
val room = column - 2 * 12.0 - 4
|
||||
assertTrue("$label is ${"%.0f".format(width(font, label))} dp, room $room", width(font, label) <= room)
|
||||
}
|
||||
// The interruptions' captions wrap inside their 420 dp card; no single word may be wider than it.
|
||||
val caption = Font(Font.SANS_SERIF, Font.BOLD, 1).deriveFont(20f * 1.3f)
|
||||
val caption = standIn(Font.BOLD).deriveFont(20f * 1.3f)
|
||||
for (l in tv.orbit.classic.arcade.chaos.Interludes.ALL) for (w in l.text.split(' ')) assertTrue(w, width(caption, w) < 420 - 28)
|
||||
}
|
||||
|
||||
@@ -74,7 +80,7 @@ class TitleTextFitsTest {
|
||||
val w = width(anton, g.title.uppercase())
|
||||
assertTrue("${g.title} is ${"%.0f".format(w)} dp", w <= 960.0 - 96 - 230 - 16)
|
||||
}
|
||||
val font = Font(Font.SANS_SERIF, Font.BOLD, 1).deriveFont(14f * 1.3f)
|
||||
val font = standIn(Font.BOLD).deriveFont(14f * 1.3f)
|
||||
val labels = listOf("▶ Play" to 210, "▶ Deal" to 210, "▶ Today's puzzle" to 210, "▶ New puzzle" to 210, "? How to Play" to 210, "← Back to Arcade" to 210,
|
||||
"▶ Play Again" to 180, "▶ Deal again" to 180, "▶ Try it again" to 180, "▶ New puzzle" to 180, "✦ New puzzle" to 160, "← Back to Arcade" to 200)
|
||||
for ((label, column) in labels) {
|
||||
@@ -89,7 +95,7 @@ class TitleTextFitsTest {
|
||||
|
||||
@Test fun theModeButtonSpellsEachModeOutInFull() {
|
||||
// The mode's whole name on the button, after its ◆, in the title's 210 dp column.
|
||||
val label = Font(Font.SANS_SERIF, Font.BOLD, 1).deriveFont(14f * 1.3f)
|
||||
val label = standIn(Font.BOLD).deriveFont(14f * 1.3f)
|
||||
for (mode in listOf("Classic", "Signal Run", "Challenge", "Challenges", "40-Line Sprint", "Daily Challenge", "Daily · Draw Three", "Orbit Deck", "Showtime", "Broadcast", "Wind Down", "Constellations") + tv.orbit.classic.PairsMode.entries.map { it.title } +
|
||||
tv.orbit.classic.arcade.rush.RPilot.entries.map { "${it.title} · ${it.ability}" }) {
|
||||
val w = width(label, "◆ $mode")
|
||||
@@ -98,7 +104,7 @@ class TitleTextFitsTest {
|
||||
}
|
||||
|
||||
@Test fun theModesPlayAndResultButtonsFit() {
|
||||
val font = Font(Font.SANS_SERIF, Font.BOLD, 1).deriveFont(14f * 1.3f)
|
||||
val font = standIn(Font.BOLD).deriveFont(14f * 1.3f)
|
||||
for ((label, column) in listOf("▶ Start the climb" to 210, "▶ Today's deal" to 210, "▶ Challenge 20" to 210, "▶ Climb again" to 180,
|
||||
"▶ Next board" to 180, "▶ Go again" to 180, "▶ Try it again" to 180, "▶ Play it again" to 180, "✦ Try again" to 160)) {
|
||||
val w = width(font, label)
|
||||
@@ -124,13 +130,13 @@ class TitleTextFitsTest {
|
||||
|
||||
@Test fun orbitRushsWordsFit() {
|
||||
// Fly with each pilot on the Play button; the region's banner across the middle of the screen in Anton at 26 sp.
|
||||
val label = Font(Font.SANS_SERIF, Font.BOLD, 1).deriveFont(14f * 1.3f)
|
||||
val label = standIn(Font.BOLD).deriveFont(14f * 1.3f)
|
||||
for (p in tv.orbit.classic.arcade.rush.RPilot.entries) assertTrue(width(label, "▶ Fly with ${p.title}") <= 230 - 2 * 12 - 4)
|
||||
val anton = Font.createFont(Font.TRUETYPE_FONT, File("src/main/res/font/anton_regular.ttf")).deriveFont(26f * 1.3f)
|
||||
for ((i, n) in tv.orbit.classic.arcade.rush.RRegion.names.withIndex()) assertTrue(n, width(anton, "SECTOR ${i + 1} · ${n.uppercase()}") <= 960 - 64 - 36)
|
||||
assertTrue(width(anton, "PAGE 999 · THE WIZARD TIPS HIS HAT") <= 960 - 64 - 36)
|
||||
// The HUD's power line on the right: the longest it says.
|
||||
val hud = Font(Font.SANS_SERIF, Font.BOLD, 1).deriveFont(15f * 1.3f)
|
||||
val hud = standIn(Font.BOLD).deriveFont(15f * 1.3f)
|
||||
assertTrue(width(hud, "Double Stars on: 8 s") <= 260)
|
||||
}
|
||||
|
||||
@@ -147,11 +153,11 @@ class TitleTextFitsTest {
|
||||
}
|
||||
// The title and the HUD's chapter name.
|
||||
assertTrue(width(anton.deriveFont(64f), "NIGHT SHIFT") <= 960.0 - 96 - 270 - 16)
|
||||
val sans = Font(Font.SANS_SERIF, Font.BOLD, 1).deriveFont(14f * 1.3f)
|
||||
val sans = standIn(Font.BOLD).deriveFont(14f * 1.3f)
|
||||
for ((label, column) in listOf("▶ Next Level" to 150, "↻ Replay" to 120, "☰ Chapters" to 140, "☰ Chapters" to 230))
|
||||
assertTrue("$label in $column", width(sans, label) <= column - 2 * 12 - 4)
|
||||
// Continue carries where it goes on the right of the title's 230 dp button.
|
||||
val detail = Font(Font.SANS_SERIF, Font.PLAIN, 1).deriveFont(12f * 1.3f)
|
||||
val detail = standIn(Font.PLAIN).deriveFont(12f * 1.3f)
|
||||
assertTrue(width(sans, "▶ Continue") + 8 + width(detail, "Ch 5 · Level 12") <= 270 - 2 * 12 - 4)
|
||||
// The level-complete panel's three buttons fit beside Nite Owl.
|
||||
assertTrue(150 + 120 + 140 + 2 * 10 <= 600 - 44 - 110 - 16)
|
||||
@@ -161,29 +167,29 @@ class TitleTextFitsTest {
|
||||
val anton = Font.createFont(Font.TRUETYPE_FONT, File("src/main/res/font/anton_regular.ttf"))
|
||||
// The title's name in Anton at 70 sp, from 60 dp in, beside the 230 dp button column.
|
||||
assertTrue(width(anton.deriveFont(70f), "ORBITEROIDS") <= 960.0 - 96 - 60 - 230)
|
||||
val sans = Font(Font.SANS_SERIF, Font.BOLD, 1).deriveFont(14f * 1.3f)
|
||||
val sans = standIn(Font.BOLD).deriveFont(14f * 1.3f)
|
||||
for (label in listOf("▶ Play", "? How to Play", "← Back to Arcade")) assertTrue(label, width(sans, label) <= 230 - 2 * 12 - 4)
|
||||
// The sector card's button, and each power-up's name in the HUD's right column (about 200 dp).
|
||||
assertTrue(width(sans, "▶ On to sector 99") <= 240 - 2 * 12 - 4)
|
||||
val hud = Font(Font.SANS_SERIF, Font.BOLD, 1).deriveFont(15f * 1.3f)
|
||||
val hud = standIn(Font.BOLD).deriveFont(15f * 1.3f)
|
||||
for (p in tv.orbit.classic.arcade.orbiteroids.OPower.entries) assertTrue(p.title, width(hud, p.title) <= 200)
|
||||
// Every sector teaser fits the card (380 dp less padding) in at most three lines.
|
||||
val body = Font(Font.SANS_SERIF, Font.PLAIN, 1).deriveFont(14f * 1.3f)
|
||||
val body = standIn(Font.PLAIN).deriveFont(14f * 1.3f)
|
||||
for (n in 2..8) assertTrue("sector $n", width(body, tv.orbit.classic.arcade.orbiteroids.sectorTeaser(n)) <= 3 * (380 - 40))
|
||||
}
|
||||
|
||||
@Test fun thePauseMenusSoundLineFitsWithItsValue() {
|
||||
// The pause menu is 250 dp less 2 × 16 padding; the button 12 dp each side, the ♪, 8 dp gaps, then "Sound" and its value.
|
||||
val label = Font(Font.SANS_SERIF, Font.BOLD, 1).deriveFont(14f * 1.3f)
|
||||
val detail = Font(Font.SANS_SERIF, Font.PLAIN, 1).deriveFont(12f * 1.3f)
|
||||
val label = standIn(Font.BOLD).deriveFont(14f * 1.3f)
|
||||
val detail = standIn(Font.PLAIN).deriveFont(12f * 1.3f)
|
||||
val room = 250.0 - 32 - 24 - 4
|
||||
for (value in listOf("On", "Off", "Effects on", "Effects off", "Music on", "Music off"))
|
||||
assertTrue("Sound · $value", width(label, "♪") + 8 + width(label, "Sound") + 8 + width(detail, value) <= room)
|
||||
}
|
||||
|
||||
@Test fun everyGamesSettingsAndHowToPlayFit() {
|
||||
val label = Font(Font.SANS_SERIF, Font.BOLD, 1).deriveFont(14f * 1.3f)
|
||||
val detail = Font(Font.SANS_SERIF, Font.PLAIN, 1).deriveFont(12f * 1.3f)
|
||||
val label = standIn(Font.BOLD).deriveFont(14f * 1.3f)
|
||||
val detail = standIn(Font.PLAIN).deriveFont(12f * 1.3f)
|
||||
// A game's settings sheet (Menu on its card): 380 dp less 2 × 16 padding, 2 × 12 inside the button, a gap and "Off".
|
||||
val room = 380.0 - 32 - 24 - 4
|
||||
for (g in ArcadeGames.all) for (t in g.settings.map { it.title } + "Show How to Play every time")
|
||||
@@ -197,20 +203,20 @@ class TitleTextFitsTest {
|
||||
@Test fun quizNightsWordsFit() {
|
||||
// Each answer button is half the answers' column (960 less the side padding, the 170 dp scoreboard, Ollie's 150 and
|
||||
// the gaps), less its padding and letter: every answer fits in two lines at the largest font scale.
|
||||
val answer = Font(Font.SANS_SERIF, Font.BOLD, 1).deriveFont(18f * 1.3f)
|
||||
val answer = standIn(Font.BOLD).deriveFont(18f * 1.3f)
|
||||
val room = ((960.0 - 64 - 170 - 150 - 40) - 10) / 2 - 28 - 24 - 12
|
||||
for (q in tv.orbit.classic.arcade.quiz.QuizQuestions) for (a in q.answers) assertTrue("$a", width(answer, a) <= room * 2)
|
||||
// Every question fits its panel in at most three lines.
|
||||
val question = Font(Font.SANS_SERIF, Font.BOLD, 1).deriveFont(24f * 1.3f)
|
||||
val question = standIn(Font.BOLD).deriveFont(24f * 1.3f)
|
||||
val panel = (960.0 - 64 - 170 - 150 - 40) - 36
|
||||
for (q in tv.orbit.classic.arcade.quiz.QuizQuestions) assertTrue(q.text, width(question, q.text) <= panel * 3)
|
||||
val sans = Font(Font.SANS_SERIF, Font.BOLD, 1).deriveFont(14f * 1.3f)
|
||||
val sans = standIn(Font.BOLD).deriveFont(14f * 1.3f)
|
||||
for (mode in tv.orbit.classic.arcade.quiz.QuizMix.entries) assertTrue(mode.title, width(sans, "◆ ${mode.title}") <= 230 - 2 * 12 - 4)
|
||||
assertTrue(width(sans, "▶ Who's playing?") <= 230 - 2 * 12 - 4)
|
||||
}
|
||||
|
||||
@Test fun theNewOriginalsWordsFit() {
|
||||
val sans = Font(Font.SANS_SERIF, Font.BOLD, 1).deriveFont(14f * 1.3f)
|
||||
val sans = standIn(Font.BOLD).deriveFont(14f * 1.3f)
|
||||
// Arcade Daily's Play button names the day's game: every game's title fits it.
|
||||
for (g in ArcadeGames.all) assertTrue(g.title, width(sans, "▶ Play ${g.title}") <= 340 - 2 * 12 - 4)
|
||||
assertTrue(340 + 10 + 200 <= 960 - 96 - 24 - 240 - 40)
|
||||
@@ -218,7 +224,7 @@ class TitleTextFitsTest {
|
||||
for (label in listOf("▶ Level 30", "◆ Picture Perfect", "◆ Daily code", "◆ Practice", "▶ Practise instead", "▶ A practice code", "▶ Today's code"))
|
||||
assertTrue(label, width(sans, label) <= 230 - 2 * 12 - 4)
|
||||
// The backdrop button's longest name, in an Arcade Settings card (about 330 dp).
|
||||
val detail = Font(Font.SANS_SERIF, Font.PLAIN, 1).deriveFont(12f * 1.3f)
|
||||
val detail = standIn(Font.PLAIN).deriveFont(12f * 1.3f)
|
||||
for (b in tv.orbit.classic.ArcadeBackdrop.entries) assertTrue(b.title, width(sans, "Backdrop") + 8 + width(detail, b.title) <= 330 - 24 - 4)
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,2 @@
|
||||
Noto Sans (Regular, Bold), SIL Open Font License 1.1, from the Noto project (https://notofonts.github.io).
|
||||
Used only by TitleTextFitsTest as a fixed stand-in for the TV's system font, so text widths measure the same on every machine.
|
||||
Reference in New Issue
Block a user