diff --git a/art/ui/fonts/GowunBatang-Bold.ttf b/art/ui/fonts/GowunBatang-Bold.ttf new file mode 100644 index 0000000..5c89211 Binary files /dev/null and b/art/ui/fonts/GowunBatang-Bold.ttf differ diff --git a/art/ui/fonts/GowunBatang-OFL.txt b/art/ui/fonts/GowunBatang-OFL.txt new file mode 100644 index 0000000..638ca4d --- /dev/null +++ b/art/ui/fonts/GowunBatang-OFL.txt @@ -0,0 +1,94 @@ +Copyright 2021 The Gowun Batang Project Authors (https://github.com/yangheeryu/Gowun-Batang) + + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/art/ui/fonts/GowunBatang-Regular.ttf b/art/ui/fonts/GowunBatang-Regular.ttf new file mode 100644 index 0000000..f466518 Binary files /dev/null and b/art/ui/fonts/GowunBatang-Regular.ttf differ diff --git a/scripts/scenes/battle_scene.gd b/scripts/scenes/battle_scene.gd index ab0ac60..50a2c16 100644 --- a/scripts/scenes/battle_scene.gd +++ b/scripts/scenes/battle_scene.gd @@ -32,6 +32,8 @@ const SFX_SKILL_CAST_PATH := "res://audio/sfx/skill_cast_01.wav" const SFX_SLASH_PATH := "res://audio/sfx/slash_01.wav" const SFX_UI_CLICK_PATH := "res://audio/sfx/ui_click_01.wav" const SFX_VICTORY_STING_PATH := "res://audio/sfx/victory_sting_01.wav" +const UI_FONT_REGULAR_PATH := "res://art/ui/fonts/GowunBatang-Regular.ttf" +const UI_FONT_BOLD_PATH := "res://art/ui/fonts/GowunBatang-Bold.ttf" const BGM_VOLUME_DB := -14.0 const SFX_VOLUME_DB := -4.0 const UI_SFX_VOLUME_DB := -8.0 @@ -118,6 +120,7 @@ var mission_title_label: Label var mission_detail_label: Label var objective_notice_panel: PanelContainer var objective_notice_label: Label +var ui_root_control: Control var hud_unit_portrait_panel: PanelContainer var hud_unit_portrait_texture: TextureRect var hud_unit_portrait_label: Label @@ -236,6 +239,8 @@ var unit_motion_by_unit: Dictionary = {} var unit_action_motion_by_unit: Dictionary = {} var battle_background_path := "" var battle_background_texture: Texture2D +var ui_regular_font: Font +var ui_bold_font: Font func _ready() -> void: @@ -431,6 +436,60 @@ func _make_button_style(fill: Color, border: Color, border_width: int) -> StyleB return style +func _ui_font(bold: bool = false) -> Font: + if bold: + if ui_bold_font == null: + ui_bold_font = _load_ui_font(UI_FONT_BOLD_PATH) + return ui_bold_font + if ui_regular_font == null: + ui_regular_font = _load_ui_font(UI_FONT_REGULAR_PATH) + return ui_regular_font + + +func _load_ui_font(font_path: String) -> Font: + if font_path.is_empty(): + return null + if ResourceLoader.exists(font_path): + var resource := ResourceLoader.load(font_path) + if resource is Font: + return resource as Font + var font := FontFile.new() + if font.load_dynamic_font(font_path) != OK: + return null + return font + + +func _make_ui_theme() -> Theme: + var theme := Theme.new() + var regular := _ui_font(false) + if regular != null: + theme.default_font = regular + theme.set_font("normal_font", "RichTextLabel", regular) + theme.set_font("italics_font", "RichTextLabel", regular) + theme.set_font("mono_font", "RichTextLabel", regular) + var bold := _ui_font(true) + if bold != null: + theme.set_font("bold_font", "RichTextLabel", bold) + theme.set_font("bold_italics_font", "RichTextLabel", bold) + return theme + + +func _draw_ui_font(bold: bool = false) -> Font: + var font := _ui_font(bold) + if font != null: + return font + return ThemeDB.fallback_font + + +func _apply_control_font(control: Control, bold: bool = false) -> void: + if control == null: + return + var font := _ui_font(bold) + if font == null: + return + control.add_theme_font_override("font", font) + + func _apply_button_style(button: Button, important: bool = false) -> void: if button == null: return @@ -447,6 +506,7 @@ func _apply_button_style(button: Button, important: bool = false) -> void: button.add_theme_color_override("font_pressed_color", UI_PARCHMENT_TEXT) button.add_theme_color_override("font_focus_color", UI_PARCHMENT_TEXT) button.add_theme_color_override("font_disabled_color", UI_DISABLED_TEXT) + _apply_control_font(button, important) func _apply_label_style(label: Label, font_color: Color, font_size: int = 0) -> void: @@ -455,6 +515,7 @@ func _apply_label_style(label: Label, font_color: Color, font_size: int = 0) -> label.add_theme_color_override("font_color", font_color) if font_size > 0: label.add_theme_font_size_override("font_size", font_size) + _apply_control_font(label, font_size >= 16) func _make_separator(width: float = 0.0, height: float = 2.0) -> ColorRect: @@ -545,6 +606,8 @@ func _create_hud() -> void: add_child(layer) var root := Control.new() + ui_root_control = root + root.theme = _make_ui_theme() root.set_anchors_preset(Control.PRESET_FULL_RECT) root.mouse_filter = Control.MOUSE_FILTER_IGNORE layer.add_child(root) @@ -2199,7 +2262,7 @@ func _draw_overlays() -> void: func _draw_units() -> void: - var font := ThemeDB.fallback_font + var font := _draw_ui_font() for unit in state.units: if not unit.get("alive", false) or not unit.get("deployed", true): continue @@ -2243,7 +2306,7 @@ func _draw_units() -> void: func _draw_target_selection_markers() -> void: if not _is_targeting_mode(): return - var font := ThemeDB.fallback_font + var font := _draw_ui_font(true) for marker in _target_selection_marker_entries(): var cell: Vector2i = marker.get("cell", Vector2i(-1, -1)) if not state.is_inside(cell): @@ -2391,7 +2454,7 @@ func _draw_unit_class_badge(rect: Rect2, unit: Dictionary, team_color: Color) -> var badge_rect := Rect2(rect.position + Vector2(5, 5), Vector2(28, 13)) draw_rect(badge_rect, Color(0.02, 0.022, 0.026, 0.82)) draw_rect(badge_rect, team_color.lightened(0.18), false, 1.2) - var font := ThemeDB.fallback_font + var font := _draw_ui_font(true) draw_string(font, badge_rect.position + Vector2(1, 11), _unit_class_abbrev(unit), HORIZONTAL_ALIGNMENT_CENTER, badge_rect.size.x - 2, 8, Color.WHITE) @@ -2741,7 +2804,7 @@ func _draw_action_impact_cue(cue: String, start: Vector2, end: Vector2, progress func _draw_floating_texts() -> void: if floating_texts.is_empty(): return - var font := ThemeDB.fallback_font + var font := _draw_ui_font(true) for popup in floating_texts: var duration: float = maxf(0.01, float(popup.get("duration", FLOATING_TEXT_LIFETIME))) var age := float(popup.get("age", 0.0)) @@ -2808,7 +2871,7 @@ func _draw_target_preview_badge() -> void: var kind := str(badge.get("kind", "")) var color := _target_preview_badge_color(kind) var background := Color(0.025, 0.028, 0.034, 0.88) - var font := ThemeDB.fallback_font + var font := _draw_ui_font(true) var text := str(badge.get("text", "")) draw_rect(badge_rect, background) diff --git a/tools/smoke_visual_assets.gd b/tools/smoke_visual_assets.gd index da43b68..77b9825 100644 --- a/tools/smoke_visual_assets.gd +++ b/tools/smoke_visual_assets.gd @@ -1814,6 +1814,20 @@ func _check_ancient_ui_theme(failures: Array[String]) -> void: failures.append("dialogue continue button should use ancient slip text") if scene.dialogue_previous_button == null or scene.dialogue_previous_button.text != "Earlier Slip": failures.append("dialogue previous button should use ancient slip text") + if scene._ui_font(false) == null: + failures.append("ancient UI regular font should load from project assets") + if scene._ui_font(true) == null: + failures.append("ancient UI bold font should load from project assets") + if scene.ui_root_control == null or scene.ui_root_control.theme == null or scene.ui_root_control.theme.default_font == null: + failures.append("ancient UI root should install the project serif font as its default theme font") + if scene._draw_ui_font(false) != scene._ui_font(false): + failures.append("map labels should draw with the project serif font") + if scene._draw_ui_font(true) != scene._ui_font(true): + failures.append("map emphasis labels should draw with the bold project serif font") + if scene.dialogue_text_label == null or not scene.dialogue_text_label.has_theme_font_override("font"): + failures.append("dialogue text should use the project serif font override") + if scene.dialogue_continue_button == null or not scene.dialogue_continue_button.has_theme_font_override("font"): + failures.append("dialogue continue button should use the project serif font override") if scene.mission_title_label == null or scene.mission_title_label.text != "Bronze Mandate Tablet": failures.append("mission panel title should use bronze tablet wording") if scene.shop_button == null or scene.shop_button.text != "Sutler":