kuroko: _yutani: expose shm font support

This commit is contained in:
K. Lange 2021-08-28 17:40:41 +09:00
parent 9e018d2932
commit 913a2c1c84
2 changed files with 8 additions and 2 deletions

View File

@ -7,7 +7,7 @@ from _yutani import (color, Yutani, Window, Decorator, Message,
let running = True
let y = Yutani()
let w = Window(640,480,title="Test Window",doublebuffer=True)
let dejavu = Font("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf",13)
let dejavu = Font("sans-serif",13)
w.move(200,200)

View File

@ -889,7 +889,13 @@ static KrkValue _font_init(int argc, KrkValue argv[], int hasKw) {
if (!krk_isInstanceOf(fontColor, YutaniColor)) return krk_runtimeError(vm.exceptions->typeError, "expected color");
}
/* Try to be smart about this */
if (strstr(AS_CSTRING(argv[1]), "sans-serif") == AS_CSTRING(argv[1]) || strstr(AS_CSTRING(argv[1]), "monospace") == AS_CSTRING(argv[1])) {
self->fontData = tt_font_from_shm(AS_CSTRING(argv[1]));
} else {
self->fontData = tt_font_from_file(AS_CSTRING(argv[1]));
}
if (!self->fontData)
return krk_runtimeError(vm.exceptions->typeError, "failed to load font");