hokusai-zero 0.2.6 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/Gemfile.lock +0 -2
- data/README.md +1 -1
- data/ast/src/core/ast.c +3 -11
- data/ast/src/core/hml.c +214 -40
- data/ast/src/core/hml.h +1 -0
- data/ast/src/core/input.h +0 -1
- data/ast/src/core/log.c +87 -0
- data/ast/src/core/log.h +41 -0
- data/ast/src/core/util.c +23 -23
- data/ast/src/core/util.h +7 -7
- data/ast/test/parser.c +1 -0
- data/ext/extconf.rb +6 -6
- data/hokusai.gemspec +1 -2
- data/ui/examples/drag.rb +154 -0
- data/ui/examples/embedded.rb +58 -0
- data/ui/examples/forum/file.rb +1 -1
- data/ui/examples/forum/post.rb +0 -1
- data/ui/examples/forum.rb +7 -7
- data/ui/examples/game.rb +143 -0
- data/ui/examples/keyboard.rb +47 -0
- data/ui/examples/overlay.rb +233 -0
- data/ui/examples/provider.rb +56 -0
- data/ui/examples/shader/test.rb +155 -0
- data/ui/examples/shader.rb +100 -0
- data/ui/examples/spreadsheet.rb +12 -11
- data/ui/examples/wiki.rb +82 -0
- data/ui/lib/lib_hokusai.rb +43 -24
- data/ui/spec/hokusai/e2e/client_spec.rb +0 -1
- data/ui/spec/hokusai/e2e/keyboard_spec.rb +52 -0
- data/ui/spec/spec_helper.rb +1 -1
- data/ui/src/hokusai/assets/arrow-down-line.png +0 -0
- data/ui/src/hokusai/assets/arrow-down-wide-line.png +0 -0
- data/ui/src/hokusai/assets/icons/outline/arrow-big-up.svg +19 -0
- data/ui/src/hokusai/assets/icons/outline/backspace.svg +20 -0
- data/ui/src/hokusai/automation/driver_commands/base.rb +2 -8
- data/ui/src/hokusai/automation/driver_commands/trigger_keyboard.rb +3 -6
- data/ui/src/hokusai/automation/driver_commands/trigger_mouse.rb +12 -5
- data/ui/src/hokusai/automation/server.rb +2 -3
- data/ui/src/hokusai/backends/raylib/config.rb +2 -1
- data/ui/src/hokusai/backends/raylib/font.rb +55 -4
- data/ui/src/hokusai/backends/raylib.rb +199 -36
- data/ui/src/hokusai/backends/sdl2/config.rb +9 -6
- data/ui/src/hokusai/backends/sdl2/font.rb +3 -1
- data/ui/src/hokusai/backends/sdl2.rb +188 -93
- data/ui/src/hokusai/blocks/color_picker.rb +1080 -0
- data/ui/src/hokusai/blocks/dynamic.rb +2 -0
- data/ui/src/hokusai/blocks/input.rb +2 -2
- data/ui/src/hokusai/blocks/keyboard.rb +249 -0
- data/ui/src/hokusai/blocks/panel.rb +2 -0
- data/ui/src/hokusai/blocks/scrollbar.rb +7 -0
- data/ui/src/hokusai/blocks/selectable.rb +1 -0
- data/ui/src/hokusai/blocks/shader_begin.rb +22 -0
- data/ui/src/hokusai/blocks/shader_end.rb +12 -0
- data/ui/src/hokusai/blocks/slider.rb +139 -0
- data/ui/src/hokusai/blocks/text_stream.rb +130 -0
- data/ui/src/hokusai/blocks/texture.rb +23 -0
- data/ui/src/hokusai/blocks/translation.rb +91 -0
- data/ui/src/hokusai/commands/rect.rb +12 -3
- data/ui/src/hokusai/commands/rotation.rb +21 -0
- data/ui/src/hokusai/commands/scale.rb +20 -0
- data/ui/src/hokusai/commands/shader.rb +33 -0
- data/ui/src/hokusai/commands/texture.rb +26 -0
- data/ui/src/hokusai/commands/translation.rb +20 -0
- data/ui/src/hokusai/commands.rb +49 -3
- data/ui/src/hokusai/event.rb +2 -1
- data/ui/src/hokusai/events/keyboard.rb +11 -18
- data/ui/src/hokusai/events/mouse.rb +10 -8
- data/ui/src/hokusai/events/touch.rb +62 -0
- data/ui/src/hokusai/meta.rb +13 -6
- data/ui/src/hokusai/mounting/loop_entry.rb +4 -4
- data/ui/src/hokusai/mounting/update_entry.rb +5 -6
- data/ui/src/hokusai/painter.rb +31 -8
- data/ui/src/hokusai/types/display.rb +155 -0
- data/ui/src/hokusai/types/keyboard.rb +168 -0
- data/ui/src/hokusai/types/mouse.rb +36 -0
- data/ui/src/hokusai/types/primitives.rb +56 -0
- data/ui/src/hokusai/types/touch.rb +181 -0
- data/ui/src/hokusai/types.rb +20 -244
- data/ui/src/hokusai/util/selection.rb +28 -7
- data/ui/src/hokusai/util/wrap_stream.rb +268 -0
- data/ui/src/hokusai.rb +72 -35
- data/xmake.lua +2 -1
- metadata +39 -22
- data/ui/src/hokusai/assets/chevron-down.svg +0 -1
data/ui/lib/lib_hokusai.rb
CHANGED
@@ -122,23 +122,7 @@ module LibHokusai
|
|
122
122
|
:next_child, HmlAst.ptr
|
123
123
|
end
|
124
124
|
|
125
|
-
|
126
|
-
# fun hashmap_iter(map : Hashmap, i : LibC::SizeT*, item : Void**) : Bool
|
127
|
-
# ast methods
|
128
|
-
attach_function :hoku_ast_prop_init, [:pointer, :string], :int
|
129
|
-
attach_function :hoku_ast_class_list_includes, [:pointer, :string], :int
|
130
|
-
attach_function :hoku_ast_get_prop, [HmlAst.by_ref, HmlAstProp.by_ref], HmlAstProp.by_ref
|
131
|
-
attach_function :hoku_ast_get_event, [:pointer, :pointer], HmlAstEvent.by_ref
|
132
|
-
attach_function :hashmap_iter, [:hashmap, :pointer, :pointer], :bool
|
133
|
-
attach_function :hashmap_count, [:hashmap], :int
|
134
|
-
attach_function :hoku_ast_free, [:pointer], :void
|
135
|
-
attach_function :hoku_errored_ast, [HmlAst.by_ref], HmlAst.by_ref
|
136
|
-
attach_function :hoku_ast_from_template, [:pointer, :string, :string], :int
|
137
|
-
attach_function :hoku_style_from_template, [:pointer, :string], :int
|
138
|
-
attach_function :hoku_style_free, [:pointer], :void
|
139
|
-
attach_function :hoku_dump, [:pointer, :int], :void
|
140
|
-
|
141
|
-
enum :hml_input_key, [
|
125
|
+
HOKUSAI_KEYS = [
|
142
126
|
:null, :apostrophe, :comma, :minus,
|
143
127
|
:period, :slash, :zero, :one, :two,
|
144
128
|
:three, :four, :five, :six, :seven,
|
@@ -162,6 +146,41 @@ module LibHokusai
|
|
162
146
|
:max
|
163
147
|
]
|
164
148
|
|
149
|
+
def self.set_log_level(symbol)
|
150
|
+
case symbol
|
151
|
+
when :fine
|
152
|
+
LibHokusai.f_logger_set_level(1 | 2 | 4 | 8 | 16)
|
153
|
+
when :debug
|
154
|
+
LibHokusai.f_logger_set_level(1 | 2 | 4 | 8)
|
155
|
+
when :info
|
156
|
+
LibHokusai.f_logger_set_level(1 | 2 | 4)
|
157
|
+
when :warn
|
158
|
+
LibHokusai.f_logger_set_level(1 | 2)
|
159
|
+
when :error
|
160
|
+
LibHokusai.f_logger_set_level(1)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
enum :log_level, [:error, 1, :warn, 2, :info, 4, :debug, 8, :fine, 16]
|
165
|
+
|
166
|
+
# fun hashmap_iter(map : Hashmap, i : LibC::SizeT*, item : Void**) : Bool
|
167
|
+
# ast methods
|
168
|
+
attach_function :f_logger_set_level, [:log_level], :void
|
169
|
+
attach_function :hoku_ast_prop_init, [:pointer, :string], :int
|
170
|
+
attach_function :hoku_ast_class_list_includes, [:pointer, :string], :int
|
171
|
+
attach_function :hoku_ast_get_prop, [HmlAst.by_ref, HmlAstProp.by_ref], HmlAstProp.by_ref
|
172
|
+
attach_function :hoku_ast_get_event, [:pointer, :pointer], HmlAstEvent.by_ref
|
173
|
+
attach_function :hashmap_iter, [:hashmap, :pointer, :pointer], :bool
|
174
|
+
attach_function :hashmap_count, [:hashmap], :int
|
175
|
+
attach_function :hoku_ast_free, [:pointer], :void
|
176
|
+
attach_function :hoku_errored_ast, [HmlAst.by_ref], HmlAst.by_ref
|
177
|
+
attach_function :hoku_ast_from_template, [:pointer, :string, :string], :int
|
178
|
+
attach_function :hoku_style_from_template, [:pointer, :string], :int
|
179
|
+
attach_function :hoku_style_free, [:pointer], :void
|
180
|
+
attach_function :hoku_dump, [:pointer, :int], :void
|
181
|
+
|
182
|
+
enum :hml_input_key, HOKUSAI_KEYS
|
183
|
+
|
165
184
|
enum :hml_input_select_type, [
|
166
185
|
:ACTIVE, 0x01,
|
167
186
|
:FROZEN, 0x02,
|
@@ -352,16 +371,16 @@ module LibHokusai
|
|
352
371
|
|
353
372
|
attach_function :hoku_selection_init, [:pointer], :int
|
354
373
|
attach_function :hoku_selection_selected, [HokuSelection.by_ref, :float, :float, :float, :float], :bool
|
355
|
-
attach_function :hoku_selection_cursor_set, [HokuSelection.by_ref, HokuCursorPosition.
|
374
|
+
attach_function :hoku_selection_cursor_set, [HokuSelection.by_ref, HokuCursorPosition.by_ref], :int
|
356
375
|
attach_function :hoku_selection_cursor_free, [HokuSelection.by_ref], :void
|
357
376
|
attach_function :hoku_selection_free, [HokuSelection.by_ref], :void
|
358
377
|
|
359
|
-
attach_function :hoku_rect_includes_y, [HmlRect.
|
360
|
-
attach_function :hoku_rect_includes_x, [HmlRect.
|
361
|
-
attach_function :hoku_rect_x_left, [HmlRect.
|
362
|
-
attach_function :hoku_rect_x_right, [HmlRect.
|
363
|
-
attach_function :hoku_rect_y_up, [HmlRect.
|
364
|
-
attach_function :hoku_rect_y_down, [HmlRect.
|
378
|
+
attach_function :hoku_rect_includes_y, [HmlRect.by_ref, :float], :bool
|
379
|
+
attach_function :hoku_rect_includes_x, [HmlRect.by_ref, :float], :bool
|
380
|
+
attach_function :hoku_rect_x_left, [HmlRect.by_ref, :int], :float
|
381
|
+
attach_function :hoku_rect_x_right, [HmlRect.by_ref, :int], :float
|
382
|
+
attach_function :hoku_rect_y_up, [HmlRect.by_ref, :int], :float
|
383
|
+
attach_function :hoku_rect_y_down, [HmlRect.by_ref, :int], :float
|
365
384
|
|
366
385
|
class HokuChar < FFI::Struct
|
367
386
|
layout :offset, :int,
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# describe Hokusai::Automation::Client do
|
2
|
+
# let(:keyboard) do
|
3
|
+
# klass = Class.new(Hokusai::Block) do
|
4
|
+
# template <<~EOF
|
5
|
+
# [template]
|
6
|
+
# vblock
|
7
|
+
# text#display {
|
8
|
+
# @keypress="update_content"
|
9
|
+
# :content="content" size="90"
|
10
|
+
# }
|
11
|
+
# keyboard{ :automatic="true" }
|
12
|
+
# EOF
|
13
|
+
|
14
|
+
# uses(
|
15
|
+
# text: Hokusai::Blocks::Text,
|
16
|
+
# keyboard: Hokusai::Blocks::Keyboard
|
17
|
+
# )
|
18
|
+
|
19
|
+
# attr_accessor :content
|
20
|
+
|
21
|
+
# def update_content(event)
|
22
|
+
# self.content << event.char
|
23
|
+
# end
|
24
|
+
|
25
|
+
# def initialize(**args)
|
26
|
+
# @content = ""
|
27
|
+
|
28
|
+
# super(**args)
|
29
|
+
# end
|
30
|
+
# end
|
31
|
+
|
32
|
+
# klass
|
33
|
+
# end
|
34
|
+
|
35
|
+
# def click_key(client, key)
|
36
|
+
# client.block("keyboard.#{key}").click
|
37
|
+
# end
|
38
|
+
|
39
|
+
# it "client works" do
|
40
|
+
# with_app(keyboard) do |client, app|
|
41
|
+
# display = client.block("#display")
|
42
|
+
|
43
|
+
# expect(display.prop("content")).to eq("")
|
44
|
+
|
45
|
+
# "hello world".split("").each do |key|
|
46
|
+
# click_key(client, key)
|
47
|
+
# end
|
48
|
+
|
49
|
+
# expect(display.prop("content")).to eq("hello world")
|
50
|
+
# end
|
51
|
+
# end
|
52
|
+
# end
|
data/ui/spec/spec_helper.rb
CHANGED
Binary file
|
Binary file
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<!--
|
2
|
+
tags: [direction, north]
|
3
|
+
category: Arrows
|
4
|
+
version: "1.37"
|
5
|
+
unicode: "eddd"
|
6
|
+
-->
|
7
|
+
<svg
|
8
|
+
xmlns="http://www.w3.org/2000/svg"
|
9
|
+
width="24"
|
10
|
+
height="24"
|
11
|
+
viewBox="0 0 24 24"
|
12
|
+
fill="none"
|
13
|
+
stroke="white"
|
14
|
+
stroke-width="2"
|
15
|
+
stroke-linecap="round"
|
16
|
+
stroke-linejoin="round"
|
17
|
+
>
|
18
|
+
<path d="M9 20v-8h-3.586a1 1 0 0 1 -.707 -1.707l6.586 -6.586a1 1 0 0 1 1.414 0l6.586 6.586a1 1 0 0 1 -.707 1.707h-3.586v8a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1z" />
|
19
|
+
</svg>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<!--
|
2
|
+
category: Text
|
3
|
+
tags: [delete, remove, eliminate]
|
4
|
+
version: "1.0"
|
5
|
+
unicode: "ea2d"
|
6
|
+
-->
|
7
|
+
<svg
|
8
|
+
xmlns="http://www.w3.org/2000/svg"
|
9
|
+
width="24"
|
10
|
+
height="24"
|
11
|
+
viewBox="0 0 24 24"
|
12
|
+
fill="none"
|
13
|
+
stroke="white"
|
14
|
+
stroke-width="2"
|
15
|
+
stroke-linecap="round"
|
16
|
+
stroke-linejoin="round"
|
17
|
+
>
|
18
|
+
<path d="M20 6a1 1 0 0 1 1 1v10a1 1 0 0 1 -1 1h-11l-5 -5a1.5 1.5 0 0 1 0 -2l5 -5z" />
|
19
|
+
<path d="M12 10l4 4m0 -4l-4 4" />
|
20
|
+
</svg>
|
@@ -65,14 +65,8 @@ module Hokusai::Automation
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def mouse_move(x, y, input)
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
private
|
72
|
-
|
73
|
-
# Returns an HmlVec2 from {x,y}
|
74
|
-
def vec2(x, y)
|
75
|
-
LibHokusai::HmlVec2.create(x, y)
|
68
|
+
input.mouse.pos.x = x
|
69
|
+
input.mouse.pos.y = y
|
76
70
|
end
|
77
71
|
end
|
78
72
|
end
|
@@ -33,21 +33,18 @@ module Hokusai::Automation
|
|
33
33
|
decode_key = keys.shift
|
34
34
|
|
35
35
|
mouse_center(canvas, input)
|
36
|
-
|
37
|
-
LibHokusai.hoku_input_mouse_set_button(input, state, 0)
|
36
|
+
input.mouse.left.clicked = true
|
38
37
|
|
39
38
|
begin
|
40
39
|
key_results = to_hml_keygroup(decode_key)
|
41
40
|
|
42
|
-
|
41
|
+
input.keyboard.reset
|
43
42
|
|
44
43
|
key_results.each do |key|
|
45
44
|
Log.info { "populating #{key}"}
|
46
45
|
|
47
|
-
|
46
|
+
input.keyboard.set(key, true)
|
48
47
|
end
|
49
|
-
|
50
|
-
LibHokusai.hoku_input_keyboard_stop(input)
|
51
48
|
rescue Automation::Error => ex
|
52
49
|
keys.clear
|
53
50
|
self.exeception = ex
|
@@ -2,9 +2,9 @@ module Hokusai::Automation
|
|
2
2
|
module DriverCommands
|
3
3
|
module MouseMethods
|
4
4
|
def trigger_mouse(input, **args)
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
args.each do |which, bool|
|
6
|
+
input.mouse.left.send("#{which}=", bool)
|
7
|
+
end
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
@@ -27,6 +27,14 @@ module Hokusai::Automation
|
|
27
27
|
state[:button]
|
28
28
|
end
|
29
29
|
|
30
|
+
def button_symbol
|
31
|
+
{
|
32
|
+
0 => :left,
|
33
|
+
1 => :middle,
|
34
|
+
2 => :right
|
35
|
+
}[button]
|
36
|
+
end
|
37
|
+
|
30
38
|
def on_complete
|
31
39
|
return value if done?
|
32
40
|
|
@@ -65,7 +73,6 @@ module Hokusai::Automation
|
|
65
73
|
class TriggerMouseClick < TriggerMouseBase
|
66
74
|
def execute(blocks, canvas, input)
|
67
75
|
if matches_blocks(blocks)
|
68
|
-
|
69
76
|
mouse_center(canvas, input)
|
70
77
|
trigger_mouse(input, clicked: true)
|
71
78
|
|
@@ -202,8 +209,8 @@ module Hokusai::Automation
|
|
202
209
|
def execute(blocks, canvas, input)
|
203
210
|
if matches_block(blocks[0])
|
204
211
|
mouse_center(canvas, input)
|
205
|
-
LibHokusai.hoku_input_mouse_set_scroll(input, scroll_amount)
|
206
212
|
|
213
|
+
input.mouse.scroll = scroll_amount
|
207
214
|
|
208
215
|
done!
|
209
216
|
end
|
@@ -99,15 +99,14 @@ module Hokusai
|
|
99
99
|
app = App.new(driver)
|
100
100
|
|
101
101
|
@socket = Thin::Server.new(*args, app)
|
102
|
-
|
102
|
+
|
103
|
+
Thread.new do
|
103
104
|
@socket.start
|
104
105
|
end
|
105
106
|
end
|
106
107
|
|
107
108
|
def self.stop
|
108
109
|
@socket.stop
|
109
|
-
|
110
|
-
Hokusai::ThreadPool.prune_pool
|
111
110
|
end
|
112
111
|
end
|
113
112
|
end
|
@@ -5,7 +5,7 @@ module Hokusai::Backends
|
|
5
5
|
attr_accessor :width, :height, :fps,
|
6
6
|
:title, :config_flags, :window_state_flags,
|
7
7
|
:automation_driver, :background, :after_load_cb,
|
8
|
-
:host, :port, :automated, :on_reload, :event_waiting
|
8
|
+
:host, :port, :automated, :on_reload, :event_waiting, :touch
|
9
9
|
|
10
10
|
def initialize
|
11
11
|
@width = 500
|
@@ -22,6 +22,7 @@ module Hokusai::Backends
|
|
22
22
|
@automated = false
|
23
23
|
@on_reload = ->(_){}
|
24
24
|
@event_waiting = false
|
25
|
+
@touch = false
|
25
26
|
end
|
26
27
|
|
27
28
|
def start_automation_driver
|
@@ -24,9 +24,9 @@ module Hokusai
|
|
24
24
|
end
|
25
25
|
|
26
26
|
class Font < Hokusai::Font
|
27
|
-
attr_reader :raw
|
27
|
+
attr_reader :raw, :sdf
|
28
28
|
|
29
|
-
DEFAULT = "–—‘’“”…\r\n\
|
29
|
+
DEFAULT = "–—‘’“”…\r\n\t\s0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%%^&*(),.?/\"\\[]-_=+|~`{}<>;:'\0"
|
30
30
|
|
31
31
|
def self.default
|
32
32
|
font = Raylib.GetFontDefault
|
@@ -51,7 +51,7 @@ module Hokusai
|
|
51
51
|
|
52
52
|
raylib_font = Raylib.LoadFontEx(file, font_size, codepoints, count)
|
53
53
|
Raylib.GenTextureMipmaps(raylib_font.texture)
|
54
|
-
Raylib.SetTextureFilter(raylib_font.texture, Raylib::
|
54
|
+
Raylib.SetTextureFilter(raylib_font.texture, Raylib::TEXTURE_FILTER_POINT)
|
55
55
|
|
56
56
|
font = new(raylib_font)
|
57
57
|
Raylib.UnloadCodepoints(codepoints)
|
@@ -59,9 +59,50 @@ module Hokusai
|
|
59
59
|
font
|
60
60
|
end
|
61
61
|
|
62
|
-
def
|
62
|
+
def self.sdf(file, size)
|
63
|
+
ptr = FFI::MemoryPointer.new(:int)
|
64
|
+
data = Raylib.LoadFileData(file, ptr)
|
65
|
+
font = Raylib::Font.new
|
66
|
+
font.baseSize = size
|
67
|
+
font.glyphCount = 95
|
68
|
+
|
69
|
+
font.glyphs = Raylib.LoadFontData(data, ptr.read_int, size, nil, 0, Raylib::FONT_SDF)
|
70
|
+
buf = FFI::MemoryPointer.new(:pointer, 1)
|
71
|
+
atlas = Raylib.GenImageFontAtlas(font.glyphs, buf, 95, size, 4, 0)
|
72
|
+
font.recs = buf.read_pointer
|
73
|
+
font.texture = Raylib.LoadTextureFromImage(atlas)
|
74
|
+
Raylib.UnloadImage(atlas)
|
75
|
+
Raylib.UnloadFileData(data)
|
76
|
+
buf.free
|
77
|
+
ptr.free
|
78
|
+
|
79
|
+
new(font, sdf: true)
|
80
|
+
end
|
81
|
+
|
82
|
+
def initialize(raw, spacing = 1.0, sdf: false)
|
63
83
|
@raw = raw
|
64
84
|
@spacing = spacing
|
85
|
+
@sdf = sdf
|
86
|
+
@measure_map = {}
|
87
|
+
|
88
|
+
DEFAULT.split("").each do |char|
|
89
|
+
@measure_map[char] ||= begin
|
90
|
+
bcount = FFI::MemoryPointer.new(:int)
|
91
|
+
letter = Raylib.GetCodepoint(char, bcount)
|
92
|
+
bcount.free
|
93
|
+
info = Raylib.GetGlyphInfo(raw, letter)
|
94
|
+
if info.advanceX > 0
|
95
|
+
w = info.advanceX
|
96
|
+
else
|
97
|
+
w = info.image.width + info.offsetX
|
98
|
+
end
|
99
|
+
|
100
|
+
->(size) do
|
101
|
+
width = (size.to_f / raw.baseSize.to_f) * w + (spacing)
|
102
|
+
width
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
65
106
|
end
|
66
107
|
|
67
108
|
# returns the spacing for this font
|
@@ -73,6 +114,16 @@ module Hokusai
|
|
73
114
|
(ssize / (raw.baseSize.zero? ? 1 : raw.baseSize)).to_f
|
74
115
|
end
|
75
116
|
|
117
|
+
def measure_char(char, size)
|
118
|
+
w = @measure_map[char]&.call(size)
|
119
|
+
|
120
|
+
if w.nil?
|
121
|
+
measure(char, size).first
|
122
|
+
else
|
123
|
+
w
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
76
127
|
def measure(string, size)
|
77
128
|
vec = Raylib.MeasureTextEx(raw, string, size, spacing)
|
78
129
|
|