Improve Korean UI text fitting

This commit is contained in:
2026-06-19 16:18:10 +09:00
parent ee6e82e5eb
commit b6a58c2327
2 changed files with 143 additions and 5 deletions

View File

@@ -166,9 +166,50 @@ func _check_readability_contract(failures: Array[String]) -> void:
failures.append("briefing objective section should have a close/open button")
elif scene.briefing_objective_toggle_button.text != "닫기":
failures.append("briefing objective button should start with a clear close label")
_check_text_fit_contract(scene, failures)
scene.free()
func _check_text_fit_contract(scene, failures: Array[String]) -> void:
for method_name in [
"_fit_label_font_size_to_text",
"_fit_font_size_for_text",
"_estimated_wrapped_text_height",
"_estimated_wrapped_line_count",
"_weighted_text_length"
]:
if not scene.has_method(method_name):
failures.append("missing text fit helper: %s" % method_name)
var dialogue_area := Vector2(666.0, 144.0)
var short_dialogue_size := int(scene._fit_font_size_for_text("군령을 전하라.", 17, 14, dialogue_area))
if short_dialogue_size != 17:
failures.append("short dialogue text should keep the base font size, got %d" % short_dialogue_size)
var long_dialogue := "" \
+ "서영의 매복은 아직 끝나지 않았다. 숲 뒤 봉쇄병이 동쪽 길목을 닫기 전에 전열을 유지하고, 부상병을 마을로 물려 회복시킨 뒤 다시 밀어붙여라. " \
+ "하후돈은 비탈 궁병을 묶고, 하후연은 길목을 살펴라. 조인은 뒤따르는 병력을 모아 조조의 깃발이 끊기지 않게 하라. " \
+ "마지막 봉쇄병이 모습을 드러내면 조급히 흩어지지 말고, 마을과 성채의 회복지를 번갈아 쓰며 전열을 앞으로 밀어라. " \
+ "적이 다시 숲을 흔들어도 군령은 하나다. 길목을 열고 남은 병력을 정리한 뒤 추격로를 확보하라. " \
+ "북쪽 비탈과 남쪽 수풀을 동시에 살피고, 어느 한 장수가 고립되지 않도록 서로의 이동 거리를 맞추어라.」"
var fitted_dialogue_size := int(scene._fit_font_size_for_text(long_dialogue, 17, 14, dialogue_area))
if fitted_dialogue_size >= 17:
failures.append("long dialogue text should reduce font size to avoid clipping")
if fitted_dialogue_size < 14:
failures.append("long dialogue text should not shrink below its readable minimum")
var fitted_dialogue_height := float(scene._estimated_wrapped_text_height(long_dialogue, dialogue_area.x, fitted_dialogue_size))
if fitted_dialogue_height > dialogue_area.y:
failures.append("fitted long dialogue should stay within the dialogue text area")
var objective_area := Vector2(500.0, 104.0)
var long_objective := "승리: 서영의 후군을 꺾었다. 동쪽 길목을 장악하고 뒤따르는 봉쇄병까지 정리하라.\n패배: 조조가 퇴각하거나 제17턴이 시작되면 패한다.\n보상: 군자금 700냥, 콩, 술, 철검"
var fitted_objective_size := int(scene._fit_font_size_for_text(long_objective, 15, 12, objective_area))
if fitted_objective_size < 12 or fitted_objective_size > 15:
failures.append("briefing objective font fit should stay inside its configured bounds")
var fitted_objective_height := float(scene._estimated_wrapped_text_height(long_objective, objective_area.x, fitted_objective_size))
if fitted_objective_height > objective_area.y:
failures.append("fitted briefing objective text should stay within its panel")
func _check_dialogue_localization_and_side(failures: Array[String]) -> void:
var scene = BattleSceneScript.new()
var lines := scene._normalized_dialogue_lines([