-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add generic font interface + sample (#192)
Signed-off-by: Marek Maškarinec <marek@mrms.cz>
- Loading branch information
1 parent
c7813a9
commit 34ab8b9
Showing
8 changed files
with
200 additions
and
89 deletions.
There are no files selected for viewing
Submodule miniaudio
updated
5 files
+13 −0 | CHANGES.md | |
+70 −51 | extras/miniaudio_split/miniaudio.c | |
+4 −3 | extras/miniaudio_split/miniaudio.h | |
+73 −53 | miniaudio.h | |
+1 −0 | tests/test_deviceio/ma_test_deviceio.c |
Submodule sokol
updated
5 files
+5 −0 | CHANGELOG.md | |
+3 −2 | bindgen/README.md | |
+1 −0 | sokol_app.h | |
+13 −0 | sokol_audio.h | |
+1 −1 | sokol_gfx.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
import ( | ||
"canvas.um" | ||
"font.um" | ||
"input.um" | ||
"std.um" | ||
"th.um" | ||
"window.um" | ||
) | ||
|
||
var fonts: [2]font::Font | ||
var idx: int | ||
|
||
fn init*() { | ||
window::setup("combined font sample", 640, 480) | ||
|
||
var err: std::Err | ||
fonts[0], err = font::load("../../../etc/roboto.ttf", 16, .nearest) | ||
std::exitif(err) | ||
|
||
fonts[1] = canvas::pixelFont | ||
|
||
window::onFrame.register({ | ||
const scale = 2.0 | ||
m := fonts[idx].measure("Press SPACE").mulf(scale) | ||
pos := window::wp.sub(m).divf(2) | ||
fonts[idx].draw("Press SPACE", pos, th::black, scale) | ||
|
||
if input::isJustPressed(.space) { | ||
idx = (idx + 1) % len(fonts) | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
import ( | ||
"canvas.um" | ||
"th.um" | ||
"window.um" | ||
"std.um" | ||
"font.um" | ||
) | ||
|
||
var f: font::Font | ||
|
||
fn init*() { | ||
window::setup("font sample", 640, 480) | ||
|
||
var err: std::Err | ||
f, err = font::load("../../../etc/roboto.ttf", 16, .nearest) | ||
std::exitif(err) | ||
|
||
window::onFrame.register({ | ||
const scale = 2.0 | ||
m := f.measure("Hello World!").mulf(scale) | ||
pos := window::wp.sub(m).divf(2) | ||
f.draw("Hello World!", pos, th::black, scale) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.