gfx: Text: remove __entities internal usage

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2024-05-07 17:57:02 -07:00 committed by Stephen Gutekanst
parent e041bc65ea
commit b5b094642a

View file

@ -61,6 +61,7 @@ const BuiltText = struct {
fn update( fn update(
entities: *mach.Entities.Mod, entities: *mach.Entities.Mod,
text: *Mod, text: *Mod,
text_style: *gfx.TextStyle.Mod,
core: *mach.Core.Mod, core: *mach.Core.Mod,
text_pipeline: *gfx.TextPipeline.Mod, text_pipeline: *gfx.TextPipeline.Mod,
) !void { ) !void {
@ -70,7 +71,7 @@ fn update(
}); });
while (q.next()) |v| { while (q.next()) |v| {
for (v.ids, v.built_pipelines) |pipeline_id, *built| { for (v.ids, v.built_pipelines) |pipeline_id, *built| {
try updatePipeline(entities, text, core, text_pipeline, pipeline_id, built); try updatePipeline(entities, text, text_style, core, text_pipeline, pipeline_id, built);
} }
} }
} }
@ -80,6 +81,7 @@ var font_once: ?gfx.Font = null;
fn updatePipeline( fn updatePipeline(
entities: *mach.Entities.Mod, entities: *mach.Entities.Mod,
text: *Mod, text: *Mod,
text_style: *gfx.TextStyle.Mod,
core: *mach.Core.Mod, core: *mach.Core.Mod,
text_pipeline: *gfx.TextPipeline.Mod, text_pipeline: *gfx.TextPipeline.Mod,
pipeline_id: mach.EntityID, pipeline_id: mach.EntityID,
@ -147,7 +149,7 @@ fn updatePipeline(
// Load the font // Load the font
// TODO(text): allow specifying a custom font // TODO(text): allow specifying a custom font
// TODO(text): keep fonts around for reuse later // TODO(text): keep fonts around for reuse later
const font_name = core.__entities.getComponent(style, .mach_gfx_text_style, .font_name).?; const font_name = text_style.get(style, .font_name).?;
_ = font_name; // TODO: actually use font name _ = font_name; // TODO: actually use font name
const font_bytes = @import("font-assets").fira_sans_regular_ttf; const font_bytes = @import("font-assets").fira_sans_regular_ttf;
var font = if (font_once) |f| f else blk: { var font = if (font_once) |f| f else blk: {
@ -156,13 +158,13 @@ fn updatePipeline(
}; };
// defer font.deinit(allocator); // defer font.deinit(allocator);
const font_size = text_style.get(style, .font_size).?;
// TODO(text): respect these style parameters // TODO(text): respect these style parameters
const font_size = core.__entities.getComponent(style, .mach_gfx_text_style, .font_size).?; const font_weight = text_style.get(style, .font_weight).?;
const font_weight = core.__entities.getComponent(style, .mach_gfx_text_style, .font_weight); const italic = text_style.get(style, .italic).?;
const color = text_style.get(style, .color).?;
_ = font_weight; _ = font_weight;
const italic = core.__entities.getComponent(style, .mach_gfx_text_style, .italic);
_ = italic; _ = italic;
const color = core.__entities.getComponent(style, .mach_gfx_text_style, .color);
_ = color; _ = color;
// Create a text shaper // Create a text shaper