diff --git a/FontTesting.gd b/FontTesting.gd new file mode 100644 index 0000000..8090179 --- /dev/null +++ b/FontTesting.gd @@ -0,0 +1,45 @@ +extends Control + +var fonts = [] +const path = 'res://assets/fonts/' +const font_size = 32 +func _ready() -> void: + var dir = Directory.new() + dir.open(path) + dir.list_dir_begin(true, true) + var filename = dir.get_next() + while filename != '': + var file = load(path+filename) + if file is DynamicFontData: + var font := DynamicFont.new() + font.size = font_size + font.font_data = file + fonts.append(font) + filename = dir.get_next() + dir.list_dir_end() + + +func _draw() -> void: + var teststr := 'abcdefghijklmnopqrstuvwxyz' + var string = teststr.to_upper() + teststr + '!?#$^²°' + 'らりるれろ(笑)' + var x = 100 + var y = 20 + for font in fonts: + y += 12 + var a = font.get_ascent() + var d = font.get_descent() + var bb = font.get_string_size(string) + assert(a+d == bb.y) + var pos = Vector2(x, y+a) + y += bb.y + draw_rect(Rect2(pos, Vector2(bb.x, -a)), Color.red) + draw_rect(Rect2(pos, Vector2(bb.x, d)), Color.blue) + draw_rect(Rect2(pos, Vector2(-32, -font_size)), Color.green) + draw_line(Vector2(x, y-bb.y/2), Vector2(x+bb.x, y-bb.y/2), Color.green, 2) +# draw_line(Vector2(x, y-d-a/2), Vector2(x+bb.x, y-d-a/2), Color.darkgray, 2) + draw_line(Vector2(x, y-d-font_size/2), Vector2(x+bb.x, y-d-font_size/2), Color.darkgray, 2) + draw_rect(Rect2(pos+Vector2.UP*a, Vector2(-8, bb.y)), Color.gray) + draw_string(font, pos, string) + +func _process(delta: float) -> void: + update() diff --git a/FontTesting.tscn b/FontTesting.tscn new file mode 100644 index 0000000..36b3de1 --- /dev/null +++ b/FontTesting.tscn @@ -0,0 +1,11 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://FontTesting.gd" type="Script" id=1] + +[node name="Control" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/OptionPanel.tscn b/OptionPanel.tscn index 5e66e1f..6126c26 100644 --- a/OptionPanel.tscn +++ b/OptionPanel.tscn @@ -1,15 +1,8 @@ -[gd_scene load_steps=8 format=2] +[gd_scene load_steps=7 format=2] -[ext_resource path="res://assets/NotoSans-Regular.ttf" type="DynamicFontData" id=1] +[ext_resource path="res://assets/fonts/NotoSans-Regular.ttf" type="DynamicFontData" id=1] [ext_resource path="res://scripts/OptionPanel.gd" type="Script" id=2] - -[sub_resource type="DynamicFont" id=1] -outline_size = 1 -outline_color = Color( 0, 0, 0, 1 ) -font_data = ExtResource( 1 ) - -[sub_resource type="Theme" id=2] -default_font = SubResource( 1 ) +[ext_resource path="res://default.theme" type="Theme" id=3] [sub_resource type="DynamicFont" id=3] size = 24 @@ -52,7 +45,7 @@ margin_right = 269.0 margin_bottom = 234.0 size_flags_horizontal = 3 size_flags_vertical = 3 -theme = SubResource( 2 ) +theme = ExtResource( 3 ) script = ExtResource( 2 ) __meta__ = { "_edit_use_anchors_": false diff --git a/assets/MenuDiffNumberFont.tres b/assets/MenuDiffNumberFont.tres index 4f91071..9e0cb5e 100644 --- a/assets/MenuDiffNumberFont.tres +++ b/assets/MenuDiffNumberFont.tres @@ -1,7 +1,7 @@ [gd_resource type="DynamicFont" load_steps=3 format=2] -[ext_resource path="res://assets/Sniglet-Regular.ttf" type="DynamicFontData" id=1] -[ext_resource path="res://assets/NotoSansJP-Bold.otf" type="DynamicFontData" id=2] +[ext_resource path="res://assets/fonts/Sniglet-Regular.ttf" type="DynamicFontData" id=1] +[ext_resource path="res://assets/fonts/NotoSansJP-Bold.otf" type="DynamicFontData" id=2] [resource] size = 36 diff --git a/assets/MenuGenreFont.tres b/assets/MenuGenreFont.tres index 2576375..2f5f57e 100644 --- a/assets/MenuGenreFont.tres +++ b/assets/MenuGenreFont.tres @@ -1,6 +1,6 @@ [gd_resource type="DynamicFont" load_steps=2 format=2] -[ext_resource path="res://assets/Sniglet-Regular.ttf" type="DynamicFontData" id=1] +[ext_resource path="res://assets/fonts/Sniglet-Regular.ttf" type="DynamicFontData" id=1] [resource] size = 48 diff --git a/assets/MenuScoreFont.tres b/assets/MenuScoreFont.tres index 3c27304..c6d8f0b 100644 --- a/assets/MenuScoreFont.tres +++ b/assets/MenuScoreFont.tres @@ -1,7 +1,7 @@ [gd_resource type="DynamicFont" load_steps=3 format=2] -[ext_resource path="res://assets/NotoSans-Regular.ttf" type="DynamicFontData" id=1] -[ext_resource path="res://assets/NotoSansJP-Regular.otf" type="DynamicFontData" id=2] +[ext_resource path="res://assets/fonts/NotoSans-Regular.ttf" type="DynamicFontData" id=1] +[ext_resource path="res://assets/fonts/NotoSansJP-Regular.otf" type="DynamicFontData" id=2] [resource] size = 96 diff --git a/assets/MenuTitleFont.tres b/assets/MenuTitleFont.tres index 84308fb..ec0eef5 100644 --- a/assets/MenuTitleFont.tres +++ b/assets/MenuTitleFont.tres @@ -1,7 +1,7 @@ [gd_resource type="DynamicFont" load_steps=3 format=2] -[ext_resource path="res://assets/NotoSans-Regular.ttf" type="DynamicFontData" id=1] -[ext_resource path="res://assets/NotoSansJP-Regular.otf" type="DynamicFontData" id=2] +[ext_resource path="res://assets/fonts/NotoSans-Regular.ttf" type="DynamicFontData" id=1] +[ext_resource path="res://assets/fonts/NotoSansJP-Regular.otf" type="DynamicFontData" id=2] [resource] size = 32 diff --git a/assets/NotoSans.tres b/assets/NotoSans.tres index ea93b27..955dcd7 100644 --- a/assets/NotoSans.tres +++ b/assets/NotoSans.tres @@ -1,6 +1,6 @@ [gd_resource type="DynamicFont" load_steps=2 format=2] -[ext_resource path="res://assets/NotoSans-Regular.ttf" type="DynamicFontData" id=1] +[ext_resource path="res://assets/fonts/NotoSans-Regular.ttf" type="DynamicFontData" id=1] [resource] size = 32 diff --git a/assets/NotoSans-Regular.ttf b/assets/fonts/NotoSans-Regular.ttf similarity index 100% rename from assets/NotoSans-Regular.ttf rename to assets/fonts/NotoSans-Regular.ttf diff --git a/assets/NotoSansJP-Black.otf b/assets/fonts/NotoSansJP-Black.otf similarity index 100% rename from assets/NotoSansJP-Black.otf rename to assets/fonts/NotoSansJP-Black.otf diff --git a/assets/NotoSansJP-Bold.otf b/assets/fonts/NotoSansJP-Bold.otf similarity index 100% rename from assets/NotoSansJP-Bold.otf rename to assets/fonts/NotoSansJP-Bold.otf diff --git a/assets/NotoSansJP-Regular.otf b/assets/fonts/NotoSansJP-Regular.otf similarity index 100% rename from assets/NotoSansJP-Regular.otf rename to assets/fonts/NotoSansJP-Regular.otf diff --git a/assets/Sniglet-ExtraBold.ttf b/assets/fonts/Sniglet-ExtraBold.ttf similarity index 100% rename from assets/Sniglet-ExtraBold.ttf rename to assets/fonts/Sniglet-ExtraBold.ttf diff --git a/assets/Sniglet-Regular.ttf b/assets/fonts/Sniglet-Regular.ttf similarity index 100% rename from assets/Sniglet-Regular.ttf rename to assets/fonts/Sniglet-Regular.ttf diff --git a/default.theme b/default.theme new file mode 100644 index 0000000..ebc7db2 Binary files /dev/null and b/default.theme differ diff --git a/main.tscn b/main.tscn index c7c3d9d..869eb08 100644 --- a/main.tscn +++ b/main.tscn @@ -1,12 +1,14 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=5 format=2] [ext_resource path="res://RadialGame.tscn" type="PackedScene" id=1] [ext_resource path="res://scripts/TouchInput.gd" type="Script" id=2] +[ext_resource path="res://default.theme" type="Theme" id=3] [ext_resource path="res://OptionPanel.tscn" type="PackedScene" id=13] [node name="main" type="Control"] anchor_right = 1.0 anchor_bottom = 1.0 +theme = ExtResource( 3 ) __meta__ = { "_edit_use_anchors_": false }