diff --git a/dejavusansmono.data b/dejavusansmono.data index aca0123..e61fec3 100644 Binary files a/dejavusansmono.data and b/dejavusansmono.data differ diff --git a/dejavusansmono_mono.data b/dejavusansmono_mono.data index 6e74696..7e234c5 100644 Binary files a/dejavusansmono_mono.data and b/dejavusansmono_mono.data differ diff --git a/example/font_outline.cpp b/example/font_outline.cpp index 8feebfe..9535d53 100644 --- a/example/font_outline.cpp +++ b/example/font_outline.cpp @@ -39,8 +39,8 @@ const struct vertex strip_vertices[4] = { constexpr uint32_t strip_length = (sizeof (strip_vertices)) / (sizeof (struct vertex)); uint32_t transform(ta_parameter_writer& parameter, - const uint32_t first_char_code, const uint32_t texture_width, uint32_t texture_height, + const uint32_t first_char_code, const glyph * glyphs, const char * s, const uint32_t len, const uint32_t y_offset) @@ -110,6 +110,53 @@ uint32_t transform(ta_parameter_writer& parameter, return parameter.offset; } +uint32_t transform2(ta_parameter_writer& parameter, + const uint32_t texture_width, uint32_t texture_height) +{ + uint32_t texture_address = (offsetof (struct texture_memory_alloc, texture)); + + auto polygon = global_polygon_type_0(texture_address); + polygon.parameter_control_word = para_control::para_type::polygon_or_modifier_volume + | para_control::list_type::opaque + | obj_control::col_type::packed_color + | obj_control::texture; + + polygon.tsp_instruction_word = tsp_instruction_word::src_alpha_instr::one + | tsp_instruction_word::dst_alpha_instr::zero + | tsp_instruction_word::fog_control::no_fog + | tsp_instruction_word::texture_u_size::from_int(texture_width) + | tsp_instruction_word::texture_v_size::from_int(texture_height); + + polygon.texture_control_word = texture_control_word::pixel_format::_8bpp_palette + | texture_control_word::scan_order::twiddled + | texture_control_word::texture_address(texture_address / 8); + parameter.append() = polygon; + + for (uint32_t i = 0; i < strip_length; i++) { + bool end_of_strip = i == strip_length - 1; + + float x = strip_vertices[i].x; + float y = strip_vertices[i].y; + float z = strip_vertices[i].z; + + x *= 128.f; + y *= 256.f; + x += 50.f; + y += 50.f; + z = 1.f / (z + 9.f); + + float u = strip_vertices[i].u; + float v = strip_vertices[i].v; + + parameter.append() = + vertex_polygon_type_3(x, y, z, + u, v, + 0x00000000, // base_color + end_of_strip); + } + + return parameter.offset; +} void init_texture_memory(const struct opb_size& opb_size) { @@ -219,19 +266,24 @@ void main() auto parameter = ta_parameter_writer(ta_parameter_buf); + transform2(parameter, + font->texture_width, font->texture_height); + + /* transform(parameter, - font->first_char_code, font->texture_width, font->texture_height, + font->first_char_code, glyphs, ana, 17, font->glyph_height * 0); transform(parameter, - font->first_char_code, font->texture_width, font->texture_height, + font->first_char_code, glyphs, cabal, 26, font->glyph_height * 1); + */ parameter.append() = global_end_of_list(); diff --git a/example/font_outline_punch_through.cpp b/example/font_outline_punch_through.cpp index cb119d4..30f1a05 100644 --- a/example/font_outline_punch_through.cpp +++ b/example/font_outline_punch_through.cpp @@ -39,8 +39,8 @@ const struct vertex strip_vertices[4] = { constexpr uint32_t strip_length = (sizeof (strip_vertices)) / (sizeof (struct vertex)); uint32_t transform(ta_parameter_writer& parameter, - const uint32_t first_char_code, const uint32_t texture_width, uint32_t texture_height, + const uint32_t first_char_code, const glyph * glyphs, const char * s, const uint32_t len, const uint32_t y_offset) @@ -230,15 +230,15 @@ void main() auto parameter = ta_parameter_writer(ta_parameter_buf); transform(parameter, - font->first_char_code, font->texture_width, font->texture_height, + font->first_char_code, glyphs, ana, 17, font->glyph_height * 0); transform(parameter, - font->first_char_code, font->texture_width, font->texture_height, + font->first_char_code, glyphs, cabal, 26, font->glyph_height * 1); diff --git a/tools/ttf_outline.cpp b/tools/ttf_outline.cpp index 2327b74..ba5c042 100644 --- a/tools/ttf_outline.cpp +++ b/tools/ttf_outline.cpp @@ -279,10 +279,10 @@ int main(int argc, char *argv[]) uint32_t texture_size; if (monochrome) { texture_stride = window_curve_ix.window.width / 8; - texture_size = byteswap((window_curve_ix.max_z_curve_ix / 8) + 1); + texture_size = window_curve_ix.window.width * window_curve_ix.window.height / 8; } else { texture_stride = window_curve_ix.window.width; - texture_size = byteswap((window_curve_ix.max_z_curve_ix / 1) + 1); + texture_size = window_curve_ix.window.width * window_curve_ix.window.height; } font font;