Introduce Kern space

This commit is contained in:
2024-01-05 12:24:30 -06:00
parent ff9186ea67
commit e1c0f2bcb1
4 changed files with 38 additions and 23 deletions

View File

@@ -54,11 +54,11 @@ namespace JabyEngine {
return &buffer[BufferStartID];
}
void FontWriter :: setup(const SimpleTIM& vram_dst, const GPU::SizeI16& font_size) {
void FontWriter :: setup(const SimpleTIM& vram_dst, const FontInfo::RenderInfo& font_render_info) {
for(auto& tex_page : this->tex_page) {
tex_page = Make::TexPage(vram_dst.get_texture_position(), GPU::TexturePageColor::$4bit).linked();
}
this->font_size = font_size;
this->render_info = font_render_info;
this->clut = Make::PageClut(vram_dst.get_clut_position());
this->last_primitive = nullptr;
}
@@ -76,23 +76,24 @@ namespace JabyEngine {
FontWriter::clear();
}
const auto row_count = 256/font_size.width;
const auto sprt_size = GPU::SizeI16::from(this->render_info.font_size);
const auto row_count = 256/sprt_size.width;
const auto push_char = [&](State& state, char cur_char) -> bool {
auto& primitive = GlobalPrimitiveFactory.new_primitive();
primitive->position = state.pos;
primitive->size = this->font_size;
primitive->size = sprt_size;
if(wiggle) {
const auto [off_x, off_y] = (*wiggle)[(state.wiggle_count++)&0x7];
primitive->position.move(off_x, off_y);
}
primitive->tex_offset = GPU::PageOffset::from_tile_id(cur_char - '!', row_count, font_size);
primitive->tex_offset = GPU::PageOffset::from_tile_id(cur_char - '!', row_count, sprt_size);
primitive->clut = this->clut;
primitive->color = color;
this->last_primitive->concat(primitive);
this->last_primitive = &primitive;
state.pos.move(this->font_size.width, 0);
state.pos.move(this->render_info.kern_size.width, 0);
return true;
};
const auto old_x = state.pos.x;
@@ -112,11 +113,11 @@ namespace JabyEngine {
case '\n':
state.pos.x = old_x;
state.pos.y += font_size.height;
state.pos.y += this->render_info.kern_size.height;
continue;
case ' ':
state.pos.x += font_size.width;
state.pos.x += this->render_info.kern_size.width;
continue;
case '%':