From 6b7b14d954b10a87761e5f894b24909e55ecc8bf Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Tue, 22 Mar 2022 22:11:12 -0400 Subject: [PATCH] Add Framebuffer.character() --- src/hulk/framebuffer.d | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/hulk/framebuffer.d b/src/hulk/framebuffer.d index b099a3d..5492dd4 100644 --- a/src/hulk/framebuffer.d +++ b/src/hulk/framebuffer.d @@ -4,6 +4,7 @@ module hulk.framebuffer; import hos.memory; +import hulk.kfont; /** * Represent a graphical frame buffer. @@ -105,6 +106,20 @@ struct Framebuffer } } + /** + * Draw a character. + * + * @param x X coordinate of left side of character. + * @param y Y coordinate of bottom side of character. + * @param ch Character to draw. + * @param color Color of character. + */ + void character(int x, int y, char ch, uint color) + { + const(CharInfo) * ci = &kfont.chars[ch]; + blit_alpha_bitmap(x + ci.left, y + kfont.baseline_offset + ci.top - ci.height, ci.bitmap, ci.width, ci.height, color); + } + /** * Blit an 8-bit alpha bitmap to the framebuffer. *