Skip to content

Render ambiguous width emoji always full-width#840

Draft
tompng wants to merge 1 commit intoruby:masterfrom
tompng:ambiguous_emoji_always_wide
Draft

Render ambiguous width emoji always full-width#840
tompng wants to merge 1 commit intoruby:masterfrom
tompng:ambiguous_emoji_always_wide

Conversation

@tompng
Copy link
Member

@tompng tompng commented Jul 8, 2025

Note: This ambiguous is not about EastAsianWidth.

Width of some emoji such as 🇯🇵(Flag emoji) and ©️(Extended_Pictographic + Variation_Selector_16) are ambiguous.
It depends on terminal emulator and its configuration.
For example, iTerm has "Flag emoji render full-width: Yes/No" and "Support variation selector 16 making emoji fullwidth" configuration.

This pull request renders these ambiguous width emoji always in full-width by this step.

  1. Render " " to clear text and background
  2. Render ambiguous emoji. Actual rendered width is uncontrollable.
  3. Move cursor as if it was rendered in full-width.

Here's an example.

# Width of ©️ and 🇯🇵 depends on environment
print "\e[1G😀😀©️🇯🇵😀"

# Render ©️ and 🇯🇵 always in full-width
print "\e[40m0123456789\e[m" # This text and background needs to be cleared
print "\e[1G😀😀\e[5G  \e[5G©️\e[7G  \e[7G🇯🇵\e[9G😀"

Some emoji such as flag emoji and Extended_Pictographic followed by variation-selector-16
are rendered in half-width or full-width depend on terminal emulator and its configuration.
Adds a special rendering flow to always render these character in full-width.
@tompng tompng force-pushed the ambiguous_emoji_always_wide branch from 1776644 to f661675 Compare July 19, 2025 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant