Skip to content

長文駅名がadjustsFontSizeToFitで過剰に縮小される不具合をminimumFontScale導入で修正 - #5988

Merged
TinyKitten merged 2 commits into
devfrom
fix/station-name-min-font-scale
May 13, 2026
Merged

TinyKitten merged 2 commits into
devfrom
fix/station-name-min-font-scale

Conversation

@TinyKitten

@TinyKitten TinyKitten commented May 13, 2026 •

Copy link
Copy Markdown
Member

概要

ヘッダー駅名の adjustsFontSizeToFit に minimumFontScale が指定されておらず、「はねだくうこうだいさんたーみなる」「ちょうじゃがはまましおさいはまなすこうえんまえ」などの長文(特に KANA 表記)駅名で文字が判読不能なほど縮小される不具合を修正する。

変更の種類

  • バグ修正
  • 新機能
  • リファクタリング
  • ドキュメント
  • CI/CD
  • その他

変更内容

  • 駅名の文字数と利用可能な画面幅から「幅いっぱいに収まるスケール」を算出する util calcStationNameMinScale を src/utils/stationNameScale.ts に追加。
  • 全 Header 実装(HeaderEast / HeaderE235 / HeaderE231 / HeaderSaikyo / HeaderJL / HeaderJRKyushu / HeaderJRWest)の駅名 Text に minimumFontScale を渡し、adjustsFontSizeToFit のデフォルト(0.01 倍まで縮小)による潰れを防止。
  • アニメーションを持つ Header では現在駅名と直前駅名(prevStationText)の双方に対して個別にスケールを算出。
  • 実フォントの 1 文字あたりの描画幅補正 CHAR_WIDTH_RATIO を 0.7 に設定し、KANA など文字数が多くなる表記でも実体に近いスケールが得られるよう調整。

テスト

  • npm run lint が通ること
  • npm test が通ること
  • npm run typecheck が通ること

関連Issue

スクリーンショット(任意)

Summary by CodeRabbit

  • 新機能
    • ステーション名の表示で最小フォント縮小率を算出・適用する仕組みを導入し、表示の一貫性を向上しました。
  • バグ修正
    • 長いステーション名でも画面幅に応じて適切なサイズで表示されるようスケーリング挙動を改善しました。
  • テスト
    • 最小スケール算出の挙動を確認する単体テストを追加しました。

Review Change Stack

@TinyKitten TinyKitten self-assigned this May 13, 2026
@coderabbitai

coderabbitai Bot commented May 13, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ff1d1cbc-8700-43d6-a5b9-d1ad8c8fa185

📥 Commits

Reviewing files that changed from the base of the PR and between c2123d3 and c5fc241.

📒 Files selected for processing (1)
  • src/utils/stationNameScale.test.ts

📝 Walkthrough

Walkthrough

新規ユーティリティ calcStationNameMinScale を追加し、端末幅と文字数に基づく最小フォント縮尺を計算して、7つのヘッダコンポーネントで駅名テキストに minimumFontScale として適用しています。

Changes

Station Name Font Scaling Utility and Application

Layer / File(s) Summary
Station name scale calculation utility
src/utils/stationNameScale.ts
新規モジュールが calcStationNameMinScale をエクスポート。ウィンドウ幅、文字数、文字幅比ヒューリスティック、基準フォントサイズから最小フォント縮尺を算出し、床値と 1 の間でクランプします。
Static station name headers with scaling
src/components/HeaderE231.tsx, src/components/HeaderE235.tsx, src/components/HeaderJL.tsx, src/components/HeaderJRWest.tsx
ユーティリティをインポートし、駅名を描画する Typography に対して minimumFontScale を設定(幅比 0.5 またはコンポーネントの設定フォントサイズを使用)。
Animated station name headers with scaling
src/components/HeaderEast/HeaderEast.tsx, src/components/HeaderJRKyushu.tsx, src/components/HeaderSaikyo.tsx
ユーティリティをインポートし、RNAnimated.Text の現在・前の駅名に対して minimumFontScale を設定(幅比 0.55 を使用)、既存の adjustsFontSizeToFit を補助。
Unit tests for scale function
src/utils/stationNameScale.test.ts
Dimensions.get をモックして calcStationNameMinScale の空文字、短名・長名でのクランプ、中間長での範囲、文字数増加に伴う単調非増加性を検証するテストを追加。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested labels

react

🐰 駅名の縮尺をそっと見守り、
画面幅に合わせてやさしく縮む、
東も西も南も北も安らぎを、
小さくなりすぎぬその一線、
ウサギが祝うスケールの調整。

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed PRタイトルは、minimumFontScale導入により長文駅名の過度な縮小を修正するという主要な変更を明確かつ簡潔に要約している。
Description check ✅ Passed PR説明は必須セクション(概要、変更の種類、変更内容、テスト)をすべて完備し、変更内容の詳細、対象コンポーネント、技術的な実装詳細が十分に記載されている。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/station-name-min-font-scale

Warning

Review ran into problems

🔥 Problems

Stopped waiting for pipeline failures after 30000ms. One of your pipelines takes longer than our 30000ms fetch window to run, so review may not consider pipeline-failure results for inline comments if any failures occurred after the fetch window. Increase the timeout if you want to wait longer or run a @coderabbit review after the pipeline has finished.


Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added the react label May 13, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/utils/stationNameScale.ts (1)

13-25: ⚡ Quick win

calcStationNameMinScale の境界値テストを追加してください。

今回の不具合修正の中核ロジックなので、empty text / 極端に長い文字列 / 短い文字列(=1にクランプ) の3系統だけでも固定化しておくと回帰を防ぎやすいです。

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/utils/stationNameScale.ts` around lines 13 - 25, Add unit tests for
calcStationNameMinScale covering boundary cases: (1) empty text returns 1, (2)
extremely long string returns a value >= MIN_SCALE_FLOOR (likely clamped to
MIN_SCALE_FLOOR), and (3) short string (very short length) returns 1 (clamped at
upper bound). In your test file import calcStationNameMinScale and stable
constants STATION_NAME_FONT_SIZE, MIN_SCALE_FLOOR, CHAR_WIDTH_RATIO; create
deterministic inputs (e.g., '' for empty, a very long repeated character string
for long case, and a 1–2 character string for short case) and assert the
returned scale equals expected values or falls within expected bounds (===1 for
empty/short, >= MIN_SCALE_FLOOR and <=1 for long). Ensure tests run in CI and
use a deterministic window width mock if needed to control
Dimensions.get('window').width.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/utils/stationNameScale.ts`:
- Around line 13-25: Add unit tests for calcStationNameMinScale covering
boundary cases: (1) empty text returns 1, (2) extremely long string returns a
value >= MIN_SCALE_FLOOR (likely clamped to MIN_SCALE_FLOOR), and (3) short
string (very short length) returns 1 (clamped at upper bound). In your test file
import calcStationNameMinScale and stable constants STATION_NAME_FONT_SIZE,
MIN_SCALE_FLOOR, CHAR_WIDTH_RATIO; create deterministic inputs (e.g., '' for
empty, a very long repeated character string for long case, and a 1–2 character
string for short case) and assert the returned scale equals expected values or
falls within expected bounds (===1 for empty/short, >= MIN_SCALE_FLOOR and <=1
for long). Ensure tests run in CI and use a deterministic window width mock if
needed to control Dimensions.get('window').width.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2c1628a6-236e-4f32-b526-d4b81516680f

📥 Commits

Reviewing files that changed from the base of the PR and between c2d6c96 and c2123d3.

📒 Files selected for processing (8)
  • src/components/HeaderE231.tsx
  • src/components/HeaderE235.tsx
  • src/components/HeaderEast/HeaderEast.tsx
  • src/components/HeaderJL.tsx
  • src/components/HeaderJRKyushu.tsx
  • src/components/HeaderJRWest.tsx
  • src/components/HeaderSaikyo.tsx
  • src/utils/stationNameScale.ts

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant