[feat] 低质量ttf render
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include <efi.h>
|
||||
#include <common.h>
|
||||
#include <graphics/context.h>
|
||||
|
||||
// Opaque font face. Created by ttf_open() over a memory-mapped TTF blob.
|
||||
typedef struct ttf_face ttf_face_t;
|
||||
|
||||
// Open a TrueType font from a memory buffer. Buffer must remain valid
|
||||
// for the lifetime of the face. Returns NULL on parse failure.
|
||||
ttf_face_t* ttf_open(const void* data, UINTN size);
|
||||
|
||||
// Free face. Does NOT free the source buffer.
|
||||
void ttf_close(ttf_face_t* face);
|
||||
|
||||
// Vertical metrics in 26.6 fixed point, scaled to pixel_size.
|
||||
SSINT32 ttf_ascender (ttf_face_t* face, SUINT32 pixel_size);
|
||||
SSINT32 ttf_descender(ttf_face_t* face, SUINT32 pixel_size);
|
||||
SSINT32 ttf_line_gap (ttf_face_t* face, SUINT32 pixel_size);
|
||||
|
||||
// Measure total advance width of a UTF-8 string at pixel_size (26.6 fp).
|
||||
SSINT32 ttf_text_width(ttf_face_t* face, const char* utf8, SUINT32 pixel_size);
|
||||
|
||||
// Render a UTF-8 string onto the current draw target.
|
||||
// (x, y) = baseline origin in TARGET coordinates
|
||||
// pixel_size = nominal glyph height in pixels (e.g. 16, 24, 48)
|
||||
// color = foreground; alpha-blended over the current buffer
|
||||
// Returns the total pen advance (26.6 fp) consumed.
|
||||
SSINT32 ttf_draw_text(ttf_face_t* face, const char* utf8,
|
||||
SSINT32 x, SSINT32 y, SUINT32 pixel_size, EFI_GRAPHICS_OUTPUT_BLT_PIXEL color);
|
||||
@@ -10,3 +10,6 @@ void global_draw_rect(SUINT32 bx, SUINT32 by, SUINT32 ex, SUINT32 ey,
|
||||
void draw_pixel(SUINT32 x, SUINT32 y, EFI_GRAPHICS_OUTPUT_BLT_PIXEL color);
|
||||
void draw_rect(SUINT32 bx, SUINT32 by, SUINT32 ex, SUINT32 ey,
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL color);
|
||||
|
||||
// Alpha blend (alpha 0..255). dest = src*alpha/255 + dest*(255-alpha)/255.
|
||||
void draw_pixel_alpha(SUINT32 x, SUINT32 y, EFI_GRAPHICS_OUTPUT_BLT_PIXEL color, SUINT8 alpha);
|
||||
|
||||
+1
-1
@@ -13,5 +13,5 @@ extern serial_context g_serial;
|
||||
void serial_init(EFI_SERIAL_IO_PROTOCOL *SerialIo); // 初始化串行驱动
|
||||
void serial_write(String str); // 往串行写string
|
||||
void serial_write_char(char c); // 往串行写char(不推荐使用)
|
||||
void serial_write_hex(UINTN val, bool fill = true); // 往串行写十六进制数字(fill=false 不补前导0)
|
||||
void serial_write_hex(UINTN val); // 往串行写十六进制数字
|
||||
char serial_read_char(); // 读串行
|
||||
Reference in New Issue
Block a user