From 1c50f69853f960395f053653f15d5593091111a0 Mon Sep 17 00:00:00 2001 From: VAN BOSSUYT Nicolas Date: Sun, 6 Aug 2023 21:33:22 +0200 Subject: [PATCH] app: Enabled AA fonts. --- sources/libs/brutal-gfx/font.h | 4 ++++ sources/libs/brutal-gfx/gfx.c | 5 +++-- sources/libs/brutal-ui/app.c | 11 +++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/sources/libs/brutal-gfx/font.h b/sources/libs/brutal-gfx/font.h index 96f8687c8..887aa110a 100644 --- a/sources/libs/brutal-gfx/font.h +++ b/sources/libs/brutal-gfx/font.h @@ -112,3 +112,7 @@ void gfx_font_render_str(GfxFont font, GfxFontStyle style, struct _Gfx *gfx, MVe extern uint8_t gfx_font_builtin_data[256 * 16]; GfxFont gfx_font_builtin(void); + +/* --- Load SSFN2 Font ------------------------------------------------------ */ + +GfxFont gfx_font_load_ssfn2(IoReader reader); diff --git a/sources/libs/brutal-gfx/gfx.c b/sources/libs/brutal-gfx/gfx.c index 181f1dae3..e4955fcf9 100644 --- a/sources/libs/brutal-gfx/gfx.c +++ b/sources/libs/brutal-gfx/gfx.c @@ -201,10 +201,11 @@ void gfx_fill(Gfx *self, GfxFillRule rule) vec_foreach_v(edge, &self->path) { - if (m_edge_min_y(edge) <= yy && m_edge_max_y(edge) > yy) + AutoType sample = yy + (1.0f / RAST_AA / 2); + if (m_edge_min_y(edge) <= sample && m_edge_max_y(edge) > sample) { GfxActiveEdge active; - active.x = edge.sx + (yy - edge.sy) / (edge.ey - edge.sy) * (edge.ex - edge.sx); + active.x = edge.sx + (sample - edge.sy) / (edge.ey - edge.sy) * (edge.ex - edge.sx); active.winding = edge.sy > edge.ey ? 1 : -1; diff --git a/sources/libs/brutal-ui/app.c b/sources/libs/brutal-ui/app.c index 164b45a4e..4c014fdd6 100644 --- a/sources/libs/brutal-ui/app.c +++ b/sources/libs/brutal-ui/app.c @@ -1,4 +1,5 @@ #include +#include #include #include "app.h" @@ -17,7 +18,17 @@ void ui_app_init(UiApp *self) vec_init(&self->windows, alloc_global()); embed_app_init(self); self->alive = true; + +#ifdef __brutal__ self->font = gfx_font_builtin(); +#else + static SSFN2Collection ssfn_coll; + IoFile font_file; + io_file_view(&font_file, str$("sysroot/pkgs/font-inter/Inter.sfnc.gz")); + ssfn2_load(io_file_rseek(&font_file), &ssfn_coll, alloc_global()); + self->font = ssfn2_font(&ssfn_coll); +#endif + ui_palette_init(&self->palette); _instance = self; }