IME pre-edit is rendered differently than the committed text · Issue #8709 · alacritty/alacritty · GitHub
Skip to content

IME pre-edit is rendered differently than the committed text #8709

Open

Description

@mahkoh

I have an IME that allows me to enter characters by their unicode code point.

For example, if I invoke the IME and then enter a9, the pre-edit in alacritty looks like this:

U+a9 = ©

When I press enter, this becomes

©

However, if I instead enter control characters, the output is unexpected:

Image Image Image Image

After pressing enter, I get the expected output ^A and ^B for the first two and the effects of Ctrl-C and Ctrl-D for the latter two.

Activity

  1. chrisduerr commented on Oct 17, 2025

    @chrisduerr
    Member

    I'm not sure where the IME is getting its character representations from, but in principle at least that's not entirely surprising to me. Your issue seems to be with what the IME displays, not Alacritty's actions, so that's up to the IME.

  2. mahkoh commented on Oct 17, 2025

    @mahkoh
    ContributorAuthor

    The IME does not display anything. Alacritty draws the string here:

    For comparison, here is how chrome handles this:

    Image

    Which makes sense because U+1 = SOH: https://en.wikipedia.org/wiki/C0_and_C1_control_codes#C0_controls

  3. kchibisov commented on Oct 17, 2025

    @kchibisov
    Member

    maybe shaping issue? Could you share the log from winit?

  4. mahkoh commented on Oct 17, 2025

    @mahkoh
    ContributorAuthor

    I don't know how to do that, but here are the logs from alacritty:

    [0.000002204s] [INFO ] [alacritty] Welcome to Alacritty
    [0.000035859s] [INFO ] [alacritty] Version 0.15.1 (0c405d53)
    [0.000042382s] [INFO ] [alacritty] Running on Wayland
    [0.000180581s] [INFO ] [alacritty] Configuration files loaded from:
                                         "/home/julian/.config/alacritty/alacritty.toml"
    [0.018336971s] [INFO ] [alacritty] Using EGL 1.5
    [0.018374484s] [DEBUG] [alacritty] Picked GL Config:
                                         buffer_type: Some(Rgb { r_size: 8, g_size: 8, b_size: 8 })
                                         alpha_size: 8
                                         num_samples: 0
                                         hardware_accelerated: true
                                         supports_transparency: Some(true)
                                         config_api: Api(OPENGL | GLES1 | GLES2 | GLES3)
                                         srgb_capable: true
    [0.018564734s] [INFO ] [alacritty] Window scale factor: 1
    [0.020029141s] [DEBUG] [alacritty] Loading "DejaVu Sans Mono" font
    [0.027248147s] [TRACE] [crossfont] Number of fonts is 188
    [0.027275650s] [TRACE] [crossfont] Got font path="/usr/share/fonts/TTF/DejaVuSansMono.ttf", index=0
    [0.027318363s] [DEBUG] [crossfont] Loaded Face Face { ft_face: Font Face: Book, load_flags: LoadFlag(0x0), render_mode: "Normal", lcd_filter: 1 }
    [0.030431446s] [TRACE] [crossfont] Number of fonts is 188
    [0.030447667s] [TRACE] [crossfont] Got font path="/usr/share/fonts/TTF/DejaVuSansMono-Bold.ttf", index=0
    [0.030474790s] [DEBUG] [crossfont] Loaded Face Face { ft_face: Font Face: Bold, load_flags: LoadFlag(0x0), render_mode: "Normal", lcd_filter: 1 }
    [0.033366833s] [TRACE] [crossfont] Number of fonts is 188
    [0.033381662s] [TRACE] [crossfont] Got font path="/usr/share/fonts/TTF/DejaVuSansMono-Oblique.ttf", index=0
    [0.033409486s] [DEBUG] [crossfont] Loaded Face Face { ft_face: Font Face: Oblique, load_flags: LoadFlag(0x0), render_mode: "Normal", lcd_filter: 1 }
    [0.036355584s] [TRACE] [crossfont] Number of fonts is 188
    [0.036369591s] [TRACE] [crossfont] Got font path="/usr/share/fonts/TTF/DejaVuSansMono-BoldOblique.ttf", index=0
    [0.036394800s] [DEBUG] [crossfont] Loaded Face Face { ft_face: Font Face: Bold Oblique, load_flags: LoadFlag(0x0), render_mode: "Normal", lcd_filter: 1 }
    [0.038699952s] [INFO ] [alacritty] Running on AMD Radeon RX 6600 (radeonsi, navi23, LLVM 20.1.8, DRM 3.64, 6.17.1-arch1-1)
    [0.038712566s] [INFO ] [alacritty] OpenGL version 4.6 (Core Profile) Mesa 25.2.4-arch1.1, shader_version 4.60
    [0.038720862s] [INFO ] [alacritty] Using OpenGL 3.3 renderer
    [0.044325730s] [DEBUG] [alacritty] Enabled debug logging for OpenGL
    [0.044386598s] [DEBUG] [alacritty] Filling glyph cache with common glyphs
    [0.054915418s] [INFO ] [alacritty] Cell size: 9 x 18
    [0.054930999s] [INFO ] [alacritty] Padding: 0 x 0
    [0.054937491s] [INFO ] [alacritty] Width: 800, Height: 600
    [0.054956248s] [TRACE] [alacritty] Deriving dim colors from normal colors
    [0.054963652s] [INFO ] [alacritty] PTY dimensions: 33 x 88
    [0.057031142s] [INFO ] [alacritty] Initialisation complete
    [0.059345772s] [TRACE] [crossfont] Number of fonts is 188
    [0.061364988s] [TRACE] [crossfont] Number of fonts is 188
    [0.063355909s] [TRACE] [crossfont] Number of fonts is 188
    [0.065311992s] [TRACE] [crossfont] Number of fonts is 188
    [0.065369794s] [INFO ] [alacritty] Font size changed to 15.0 px
    [0.065376177s] [INFO ] [alacritty] Cell size: 9 x 18
    [0.072256914s] [INFO ] [alacritty] Padding: 0 x 0
    [0.072269519s] [INFO ] [alacritty] Width: 800, Height: 600
    [0.081852631s] [DEBUG] [alacritty_terminal] New num_cols is 106 and num_lines is 57
    [0.085984194s] [INFO ] [alacritty] Padding: 0 x 0
    [0.086006136s] [INFO ] [alacritty] Width: 958, Height: 1026
    [0.088151748s] [TRACE] [alacritty_terminal] Setting attribute: Bold
    [0.088166897s] [TRACE] [alacritty_terminal] Setting attribute: Reverse
    [0.088174151s] [TRACE] [alacritty_terminal] Setting attribute: CancelReverse
    [0.088181656s] [TRACE] [alacritty_terminal] Setting attribute: Bold
    [0.088186375s] [TRACE] [alacritty_terminal] Setting attribute: Reset
    [0.088198639s] [TRACE] [alacritty_terminal] Carriage return
    [0.088209610s] [TRACE] [alacritty_terminal] Carriage return
    [0.088215632s] [TRACE] [alacritty_terminal] Carriage return
    [0.088220311s] [TRACE] [alacritty_terminal] Setting attribute: Reset
    [0.088225131s] [TRACE] [alacritty_terminal] Setting attribute: CancelReverse
    [0.088229810s] [TRACE] [alacritty_terminal] Setting attribute: CancelUnderline
    [0.088235000s] [TRACE] [alacritty_terminal] Clearing screen: Below
    [0.088243376s] [TRACE] [alacritty_terminal] Setting attribute: Bold
    [0.088248125s] [TRACE] [alacritty_terminal] Setting attribute: Foreground(Named(BrightGreen))
    [0.088253756s] [TRACE] [alacritty_terminal] Setting attribute: Reset
    [0.088258505s] [TRACE] [alacritty_terminal] Setting attribute: Foreground(Named(BrightGreen))
    [0.088263375s] [TRACE] [alacritty_terminal] Setting attribute: Foreground(Named(White))
    [0.088268806s] [TRACE] [alacritty_terminal] Clearing line: Right
    [0.088274346s] [TRACE] [alacritty_terminal] Setting private mode: BracketedPaste
    [1.962314604s] [TRACE] [crossfont] Got font path="/usr/share/fonts/misc/ter-x14n.pcf.gz", index=0
    [1.962787583s] [DEBUG] [crossfont] Loaded Face Face { ft_face: Font Face: Regular, load_flags: LoadFlag(0x0), render_mode: "Normal", lcd_filter: 1 }
    

    The font at the end is loaded when the preview for the control character appears.

  5. kchibisov commented on Oct 17, 2025

    @kchibisov
    Member

    Ah, sorry for not providing instruction.

    --print-events should do that.

  6. mahkoh commented on Oct 17, 2025

    @mahkoh
    ContributorAuthor
    Created log file at "/tmp/Alacritty-1427066.log"
    [0.000002695s] [INFO ] [alacritty] Welcome to Alacritty
    [0.000035609s] [INFO ] [alacritty] Version 0.15.1 (0c405d53)
    [0.000042473s] [INFO ] [alacritty] Running on Wayland
    [0.000168488s] [INFO ] [alacritty] Configuration files loaded from:
                                         "/home/julian/.config/alacritty/alacritty.toml"
    [0.018826254s] [INFO ] [alacritty] Using EGL 1.5
    [0.019037785s] [INFO ] [alacritty] Window scale factor: 1
    [0.039443400s] [INFO ] [alacritty] Running on AMD Radeon RX 6600 (radeonsi, navi23, LLVM 20.1.8, DRM 3.64, 6.17.1-arch1-1)
    [0.039460854s] [INFO ] [alacritty] OpenGL version 4.6 (Core Profile) Mesa 25.2.4-arch1.1, shader_version 4.60
    [0.039471074s] [INFO ] [alacritty] Using OpenGL 3.3 renderer
    [0.055250302s] [INFO ] [alacritty] Cell size: 9 x 18
    [0.055274038s] [INFO ] [alacritty] Padding: 0 x 0
    [0.055280751s] [INFO ] [alacritty] Width: 800, Height: 600
    [0.055296422s] [INFO ] [alacritty] PTY dimensions: 33 x 88
    [0.057319336s] [INFO ] [alacritty] Initialisation complete
    [0.057332842s] [INFO ] [alacritty_winit_event] ScaleFactorChanged { scale_factor: 1.0, inner_size_writer: InnerSizeWriter { new_inner_size: (Weak) } }
    [0.057344776s] [INFO ] [alacritty_winit_event] Resized(PhysicalSize { width: 800, height: 600 })
    [0.057352952s] [INFO ] [alacritty_winit_event] RedrawRequested
    [0.065671259s] [INFO ] [alacritty] Font size changed to 15.0 px
    [0.065681649s] [INFO ] [alacritty] Cell size: 9 x 18
    [0.072506873s] [INFO ] [alacritty] Padding: 0 x 0
    [0.072526692s] [INFO ] [alacritty] Width: 800, Height: 600
    [0.081774086s] [INFO ] [alacritty_winit_event] About to wait
    [0.081839173s] [INFO ] [alacritty_winit_event] About to wait
    [0.082389794s] [INFO ] [alacritty_winit_event] Resized(PhysicalSize { width: 958, height: 1026 })
    [0.082402539s] [INFO ] [alacritty_winit_event] Focused(true)
    [0.082410193s] [INFO ] [alacritty_winit_event] ModifiersChanged(Modifiers { state: ModifiersState(0x0), pressed_mods: ModifiersKeys(0x0) })
    [0.082419912s] [INFO ] [alacritty_winit_event] Ime(Enabled)
    [0.082429351s] [INFO ] [alacritty_winit_event] Ime(Preedit("", None))
    [0.082454089s] [INFO ] [alacritty_winit_event] About to wait
    [0.084665409s] [INFO ] [alacritty_winit_event] RedrawRequested
    [0.084681390s] [INFO ] [alacritty] Padding: 0 x 0
    [0.084688985s] [INFO ] [alacritty] Width: 958, Height: 1026
    [0.085080887s] [INFO ] [alacritty_winit_event] About to wait
    [0.088097584s] [INFO ] [alacritty_winit_event] Event { window_id: Some(WindowId(94592576961392)), payload: Terminal(Wakeup) }
    [0.088112383s] [INFO ] [alacritty_winit_event] Event { window_id: Some(WindowId(94592576961392)), payload: Terminal(Wakeup) }
    [0.088120288s] [INFO ] [alacritty_winit_event] About to wait
    [0.088132101s] [INFO ] [alacritty_winit_event] About to wait
    [0.091246499s] [INFO ] [alacritty_winit_event] KeyboardInput { device_id: DeviceId(Wayland(DeviceId)), event: KeyEvent { physical_key: Code(Enter), logical_key: Named(Enter), text: Some("\r"), location: Standard, state: Released, repeat: false, platform_specific: KeyEventExtra { text_with_all_modifiers: Some("\r"), key_without_modifiers: Named(Enter) } }, is_synthetic: false }
    [0.091267529s] [INFO ] [alacritty_winit_event] About to wait
    [0.092985400s] [INFO ] [alacritty_winit_event] RedrawRequested
    [0.093327616s] [INFO ] [alacritty_winit_event] About to wait
    [0.925306728s] [INFO ] [alacritty_winit_event] KeyboardInput { device_id: DeviceId(Wayland(DeviceId)), event: KeyEvent { physical_key: Code(ControlLeft), logical_key: Named(Control), text: None, location: Left, state: Pressed, repeat: false, platform_specific: KeyEventExtra { text_with_all_modifiers: None, key_without_modifiers: Named(Control) } }, is_synthetic: false }
    [0.925340073s] [INFO ] [alacritty_winit_event] ModifiersChanged(Modifiers { state: ModifiersState(CONTROL), pressed_mods: ModifiersKeys(0x0) })
    [0.925350683s] [INFO ] [alacritty_winit_event] About to wait
    [0.964271818s] [INFO ] [alacritty_winit_event] KeyboardInput { device_id: DeviceId(Wayland(DeviceId)), event: KeyEvent { physical_key: Code(AltLeft), logical_key: Named(Alt), text: None, location: Left, state: Pressed, repeat: false, platform_specific: KeyEventExtra { text_with_all_modifiers: None, key_without_modifiers: Named(Alt) } }, is_synthetic: false }
    [0.964295324s] [INFO ] [alacritty_winit_event] ModifiersChanged(Modifiers { state: ModifiersState(CONTROL | ALT), pressed_mods: ModifiersKeys(0x0) })
    [0.964302317s] [INFO ] [alacritty_winit_event] About to wait
    [1.085286170s] [INFO ] [alacritty_winit_event] Ime(Preedit("U+", Some((2, 2))))
    [1.085302521s] [INFO ] [alacritty_winit_event] About to wait
    [1.085315667s] [INFO ] [alacritty_winit_event] RedrawRequested
    [1.086027211s] [INFO ] [alacritty_winit_event] About to wait
    [1.246282439s] [INFO ] [alacritty_winit_event] KeyboardInput { device_id: DeviceId(Wayland(DeviceId)), event: KeyEvent { physical_key: Code(ControlLeft), logical_key: Named(Control), text: None, location: Left, state: Released, repeat: false, platform_specific: KeyEventExtra { text_with_all_modifiers: None, key_without_modifiers: Named(Control) } }, is_synthetic: false }
    [1.246298871s] [INFO ] [alacritty_winit_event] ModifiersChanged(Modifiers { state: ModifiersState(ALT), pressed_mods: ModifiersKeys(0x0) })
    [1.246306456s] [INFO ] [alacritty_winit_event] About to wait
    [1.247269398s] [INFO ] [alacritty_winit_event] KeyboardInput { device_id: DeviceId(Wayland(DeviceId)), event: KeyEvent { physical_key: Code(AltLeft), logical_key: Named(Alt), text: None, location: Left, state: Released, repeat: false, platform_specific: KeyEventExtra { text_with_all_modifiers: None, key_without_modifiers: Named(Alt) } }, is_synthetic: false }
    [1.247276883s] [INFO ] [alacritty_winit_event] ModifiersChanged(Modifiers { state: ModifiersState(0x0), pressed_mods: ModifiersKeys(0x0) })
    [1.247282764s] [INFO ] [alacritty_winit_event] About to wait
    [1.534293329s] [INFO ] [alacritty_winit_event] Ime(Preedit("U+1 = \u{1}", Some((3, 3))))
    [1.534307687s] [INFO ] [alacritty_winit_event] About to wait
    [1.534319720s] [INFO ] [alacritty_winit_event] RedrawRequested
    [1.535143552s] [INFO ] [alacritty_winit_event] About to wait
    [1.987330185s] [INFO ] [alacritty_winit_event] Ime(Preedit("", None))
    [1.987354392s] [INFO ] [alacritty_winit_event] Ime(Commit("\u{1}"))
    [1.987363780s] [INFO ] [alacritty_winit_event] About to wait
    [1.987380663s] [INFO ] [alacritty_winit_event] RedrawRequested
    [1.987594729s] [INFO ] [alacritty_winit_event] About to wait
    [1.987609428s] [INFO ] [alacritty_winit_event] Event { window_id: Some(WindowId(94592576961392)), payload: Terminal(Wakeup) }
    [1.987618596s] [INFO ] [alacritty_winit_event] About to wait
    [1.987626411s] [INFO ] [alacritty_winit_event] About to wait
    [1.993012095s] [INFO ] [alacritty_winit_event] RedrawRequested
    [1.993156666s] [INFO ] [alacritty_winit_event] About to wait
    [3.160453441s] [INFO ] [alacritty_winit_event] Ime(Preedit("", None))
    [3.160481605s] [INFO ] [alacritty_winit_event] Ime(Disabled)
    [3.160489581s] [INFO ] [alacritty_winit_event] ModifiersChanged(Modifiers { state: ModifiersState(0x0), pressed_mods: ModifiersKeys(0x0) })
    [3.160497897s] [INFO ] [alacritty_winit_event] Focused(false)
    [3.160508237s] [INFO ] [alacritty_winit_event] RedrawRequested
    [3.161271001s] [INFO ] [alacritty_winit_event] About to wait
    
  7. kchibisov commented on Oct 17, 2025

    @kchibisov
    Member

    Given that character is the same in Preedit and Commit they should render the same, so will open to look into it.

  8. sigprof commented on Oct 31, 2025

    @sigprof

    The mentioned Terminus font has glyphs in the 0x00...0x1F range which match the old X11 fixed font (AFAIK Xterm used at least the line drawing characters from that range):

    Image Image

    Maybe Alacritty should perform some preprocessing to avoid rendering characters from the C0 control code range directly, so that it won't be tricked by such fonts with nonstandard encodings.

  9. kchibisov commented on Nov 9, 2025

    @kchibisov
    Member

    Isn't the whole issue is that control bytes can not be rendered really, because they are control sequences, thus even if you type 0x01, it'll either be altered by kernel to entered as ^A, or it'll be executed by alacritty (and thus ignored, since we ignore \0xa1) in particular?

    But IME preview is not aware of any of that, thus it just renders characters as is according to the font. Chrome also being a GUI application doesn't have an issue of actually reacting to those bytes, etc, etc.

    So, I'd say that the display is correct, it's just it cannot be represented as it originally was in 0x01 form later on.

    Maybe Alacritty should perform some preprocessing to avoid rendering characters from the C0 control code range directly, so that it won't be tricked by such fonts with nonstandard encodings.

    Yeah, that's what it sounds like. @chrisduerr what do you think for doing that for IME preview, otherwise they'll always be desynced?

  10. chrisduerr commented on Nov 9, 2025

    @chrisduerr
    Member

    So, I'd say that the display is correct, it's just it cannot be represented as it originally was in 0x01 form later on.

    That's essentially my take, yes. That's why I closed the issue.

    Yeah, that's what it sounds like. @chrisduerr what do you think for doing that for IME preview, otherwise they'll always be desynced?

    Well we technically don't know what it's actually going to look like. So the argument of "keeping it in sync" is something I disagree with. Having a nicely rendered version for these characters is an argument I can somewhat get behind, but that's something fonts can already do as shown in terminus (the terminus font itself is just broken).

    I'm not sure if explicitly replacing these glyphs makes sense, though I do see why you would always want some renderable representation. That said, why should Alacritty be doing that? If IME is requesting us to render text, and that text is considering invisible characters, why should Alacritty replace these characters? That doesn't make sense to me and seems like something IMEs would actually find harmful. If your IME doesn't want the invisible character, why are they sending it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions