Merge pull request #1406 from mitchellh/constrain-emoji

renderer: constrain emoji to cell width
This commit is contained in:
Mitchell Hashimoto
2024-01-28 10:24:52 -08:00
committed by GitHub
2 changed files with 6 additions and 2 deletions

View File

@ -162,7 +162,9 @@ vertex VertexOut uber_vertex(
glyph_offset.y = cell_size_scaled.y - glyph_offset.y;
// If we're constrained then we need to scale the glyph.
if (input.mode == MODE_FG_CONSTRAINED) {
// We also always constrain colored glyphs since we should have
// their scaled cell size exactly correct.
if (input.mode == MODE_FG_CONSTRAINED || input.mode == MODE_FG_COLOR) {
if (glyph_size.x > cell_size_scaled.x) {
float new_y = glyph_size.y * (cell_size_scaled.x / glyph_size.x);
glyph_offset.y += (glyph_size.y - new_y) / 2;

View File

@ -190,8 +190,10 @@ void main() {
glyph_offset_calc.y = cell_size_scaled.y - glyph_offset_calc.y;
// If this is a constrained mode, we need to constrain it!
// We also always constrain colored glyphs since we should have
// their scaled cell size exactly correct.
vec2 glyph_size_calc = glyph_size;
if (mode == MODE_FG_CONSTRAINED) {
if (mode == MODE_FG_CONSTRAINED || mode == MODE_FG_COLOR) {
if (glyph_size.x > cell_size_scaled.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) / 2);