• 全新单提交:清除含敏感信息的旧历史(sudo 口令、内网 IP、SSH 密钥路径、热点 SSID、设备 MAC) • 本地开发文档/测试记录/构建脚本全部移入 gitignored 的 devdocs/ 与 scripts/build/(不入库) • 保留:MeowOS 源码(launcher/watchdog/bootmenu/meow_svcd/SDK)、项目规范文档、mips-repo 增补组件:SDK 统一日志+通知 API、meow_svcd 服务管理器、mips-repo 软件仓库
58 lines
2.5 KiB
C
58 lines
2.5 KiB
C
#ifndef MEOW_FONT_H
|
||
#define MEOW_FONT_H
|
||
/*
|
||
* meow_font.h — MeowOS 预渲染位图字体运行时(独立、可复用,不绑定启动器)。
|
||
*
|
||
* 数据来源:由 gen/gen_font.py 生成的 font.png(灰度 PNG,bit depth 4|8,含各字号面)
|
||
* + font.idx(索引:头部 + 每面元数据 + 每字符 16B 记录)。
|
||
*
|
||
* 设备端加载:模块内建最小 PNG 解码(仅支持灰度非隔行)经 zlib inflate + 反滤波还原像素,
|
||
* 无需 libpng;交叉链接 musl 静态 libz.a。像素面按 depth=4|8 打包存储,取像素时按 nibble 解包。
|
||
*
|
||
* 绘制模型:drawtext(fb, x, y, utf8, color, size);(x,y)=行首「升线(top)」锚点;
|
||
* baseline = y + ascent;每字形 blit 于 (x + pen + dx, y + dy);pen 累加 advance。
|
||
* color 为 565 位 RGB(R 在 bit15..11,G bit10..5,B bit4..0),与 launcher 一致。
|
||
* 无字回退:缺码位画空心方块(tofu)并前进空格宽度。
|
||
*
|
||
* 字号:字库含若干原生面(如 28、20)。drawtext 请求 size 时先找精确匹配面;
|
||
* 若无则就近取一面做最近邻缩放(最优仍用原生字号)。
|
||
*/
|
||
#include <stdint.h>
|
||
#include <stddef.h>
|
||
|
||
#ifdef __cplusplus
|
||
extern "C" {
|
||
#endif
|
||
|
||
/* 设置 framebuffer 几何:宽/高(像素)与每行字节数(如 480*2)。绘制前调用一次。 */
|
||
void meow_font_set_fb(unsigned fb_w, unsigned fb_h, unsigned pitch_bytes);
|
||
|
||
/* 加载字库(全部字号)。成功返回 0,失败返回负值。可重复调用(先卸载旧的)。 */
|
||
int meow_font_load(const char *png_path, const char *idx_path);
|
||
|
||
/* 释放字库。 */
|
||
void meow_font_unload(void);
|
||
|
||
/* 某字号是否存在(命中原生面返回 1)。 */
|
||
int meow_font_has_size(int size);
|
||
|
||
/* UTF-8 字符串渲染宽度(px)。字面不存在返回 0。 */
|
||
int meow_font_width_text(const char *utf8, int size);
|
||
|
||
/* 行高(px = ascent + descent)。 */
|
||
int meow_font_line_height(int size);
|
||
int meow_font_ascent(int size);
|
||
|
||
/* 绘制文本:(x,y)=行首升线顶部;color=RGB565。已按 fb_w/fb_h 裁剪。 */
|
||
void meow_font_drawtext(uint16_t *fb, int x, int y, const char *utf8,
|
||
uint16_t color, int size);
|
||
|
||
/* 描边绘制:先以 outline_color 将每字形向 4/8 邻域平移 ol 绘制一圈,再以 color 填充。 */
|
||
void meow_font_drawtext_outline(uint16_t *fb, int x, int y, const char *utf8,
|
||
uint16_t color, uint16_t outline_color, int ol, int size);
|
||
|
||
#ifdef __cplusplus
|
||
}
|
||
#endif
|
||
#endif /* MEOW_FONT_H */
|