Skip to content

Commit

Permalink
app: Enabled AA fonts.
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepy-monax committed Aug 6, 2023
1 parent 40c7601 commit 1c50f69
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions sources/libs/brutal-gfx/font.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
5 changes: 3 additions & 2 deletions sources/libs/brutal-gfx/gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
11 changes: 11 additions & 0 deletions sources/libs/brutal-ui/app.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <brutal-time>
#include <codec-ssfn2>
#include <embed/app.h>

#include "app.h"
Expand All @@ -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;
}
Expand Down

0 comments on commit 1c50f69

Please sign in to comment.