Merge pull request #1249 from mitchellh/constrain-dingbats

renderer: constrain dingbats unicode block to cell size
This commit is contained in:
Mitchell Hashimoto
2024-01-07 15:06:11 -08:00
committed by GitHub
3 changed files with 5 additions and 3 deletions

View File

@ -41,7 +41,9 @@ pub fn fgMode(
// the subsequent character is empty, then we allow it to use // the subsequent character is empty, then we allow it to use
// the full glyph size. See #1071. // the full glyph size. See #1071.
.text => text: { .text => text: {
if (!ziglyph.general_category.isPrivateUse(@intCast(cell.char))) { if (!ziglyph.general_category.isPrivateUse(@intCast(cell.char)) and
!ziglyph.blocks.isDingbats(@intCast(cell.char)))
{
break :text .normal; break :text .normal;
} }

View File

@ -165,7 +165,7 @@ vertex VertexOut uber_vertex(
if (input.mode == MODE_FG_CONSTRAINED) { if (input.mode == MODE_FG_CONSTRAINED) {
if (glyph_size.x > cell_size_scaled.x) { if (glyph_size.x > cell_size_scaled.x) {
float new_y = glyph_size.y * (cell_size_scaled.x / glyph_size.x); float new_y = glyph_size.y * (cell_size_scaled.x / glyph_size.x);
glyph_offset.y += glyph_size.y - new_y; glyph_offset.y += (glyph_size.y - new_y) / 2;
glyph_size.y = new_y; glyph_size.y = new_y;
glyph_size.x = cell_size_scaled.x; glyph_size.x = cell_size_scaled.x;
} }

View File

@ -194,7 +194,7 @@ void main() {
if (mode == MODE_FG_CONSTRAINED) { if (mode == MODE_FG_CONSTRAINED) {
if (glyph_size.x > cell_size_scaled.x) { if (glyph_size.x > cell_size_scaled.x) {
float new_y = glyph_size.y * (cell_size_scaled.x / glyph_size.x); float new_y = glyph_size.y * (cell_size_scaled.x / glyph_size.x);
glyph_offset_calc.y = glyph_offset_calc.y + (glyph_size.y - new_y); glyph_offset_calc.y = glyph_offset_calc.y + ((glyph_size.y - new_y) / 2);
glyph_size_calc.y = new_y; glyph_size_calc.y = new_y;
glyph_size_calc.x = cell_size_scaled.x; glyph_size_calc.x = cell_size_scaled.x;
} }