Commit: a9efd2c999918d6fb8dc30136afb3caa597517af
Parent: c1a10af51ff1c0eff85d48a6bdd2d9a46e94d4ad
Author: Randy Palamar
Date: Fri, 27 Sep 2024 02:15:00 -0600
use a mask for face style in push_cell
Diffstat:
2 files changed, 7 insertions(+), 15 deletions(-)
diff --git a/util.h b/util.h
@@ -281,11 +281,12 @@ struct conversion_result {
#endif
enum face_style {
- FS_NORMAL,
- FS_BOLD,
- FS_ITALIC,
- FS_BOLD_ITALIC,
- FS_LAST
+ FS_NORMAL = ATTR_NULL,
+ FS_BOLD = ATTR_BOLD,
+ FS_ITALIC = ATTR_ITALIC,
+ FS_BOLD_ITALIC = ATTR_BOLD|ATTR_ITALIC,
+ FS_LAST,
+ FS_MASK = FS_BOLD_ITALIC,
};
typedef struct {
diff --git a/vtgl.c b/vtgl.c
@@ -255,16 +255,7 @@ push_cell(RenderPushBuffer *rpb, GLCtx *gl, Arena a, FontAtlas *fa, Cell c, Rect
ASSERT(c.cp);
Glyph g;
- i32 style = FS_NORMAL;
- /* TODO: performance */
- if ((c.style.attr & (ATTR_BOLD|ATTR_ITALIC)) == (ATTR_BOLD|ATTR_ITALIC))
- style = FS_BOLD_ITALIC;
- else if (c.style.attr & ATTR_BOLD)
- style = FS_BOLD;
- else if (c.style.attr & ATTR_ITALIC)
- style = FS_ITALIC;
-
- i32 depth_idx = get_gpu_glyph_index(a, fa, c.cp, style, &g);
+ i32 depth_idx = get_gpu_glyph_index(a, fa, c.cp, c.style.attr & FS_MASK, &g);
rpb->vertscales[idx + 0] = r.size;
rpb->vertscales[idx + 1] = (v2){.x = g.size.w, .y = g.size.h};