Skip to content

Flutter UI Guides overlap with text when using certain fonts #1887

Open

Description

@driftWithToyota86

recently i've changed to manjaro from ubuntu
flutter ui guides works perfect in ubuntu but have some issue with manjaro + vscode official 13.6.1

Screenshot_20190723_153812

Activity

  1. DanTup commented on Jul 23, 2019

    @DanTup
    Member

    Thanks for the report - are you able to get a screenshot that includes the top of the lines too? Are they also misaligned, or only the bottom?

  2. added this to the v3.4.0 milestone on Jul 23, 2019
  3. added
    in editor
    in flutter
    on Jul 23, 2019
  4. DanTup commented on Jul 23, 2019

    @DanTup
    Member

    I've so far been unable to get Manjaro to boot in a VM :(

    Can you confirm which version you used? (There's KDE, Gnome, etc.).

  5. modified the milestones: v3.4.0, v3.5.0 on Aug 26, 2019
  6. DanTup commented on Sep 11, 2019

    @DanTup
    Member

    Ok, I tracked this down because it came up again. The issue occurs when the font you ahve selected does not contain the ascii characters we're using to draw the lines (we're using ascii characters because VS Code doesn't give us a real API - see microsoft/vscode#73780). When the font doesn't have these characters, a fallback font is used, and the width of its characters may differ - which results in them getting out-of-alignment.

    Here's an example using a monospaced font (Roboto Mono) from Google Fonts with the same characters in it:

    https://jsfiddle.net/b08ge6fz/

    It renders like this:

    Screenshot 2019-09-11 at 2 02 35 pm

    So for now I think there are only two solutions:

    1. VS Code gets new APIs (Add more flexible Decorations or editor overlays for extensions microsoft/vscode#73780) - there hasn't been any feedback on that issue
    2. Use a font that includes those characters (or at least, has normal characters at the same width as the unicode lines in the fallback font ☹️)

    Unfortunately neither of these are good solutions. I'll post back if I can come up with anything better.

  7. added
    blocked on vs code / lsp / dap
    on Sep 11, 2019
  8. modified the milestones: v3.5.0, On Deck on Sep 11, 2019
  9. changed the title [-]Flutter UI Guides workds awful in Manjaro VScode official 13.6.1[/-] [+]Flutter UI Guides overlap with text when using certain fonts[/+] on Sep 11, 2019
  10. DanTup commented on Sep 11, 2019

    @DanTup
    Member

    My mistake - these characters are Unicode, not extended ascii (I can't get the extended ascii ones to render at all in Chrome).

    I'm not sure whether it's coincidence that the lengths match up with the default font or not though!

  11. removed
    blocked on vs code / lsp / dap
    on Sep 11, 2019
  12. 1 remaining item

  13. modified the milestones: On Deck, v3.16.0 on Oct 1, 2020
  14. modified the milestones: v3.16.0, v3.17.0 on Oct 26, 2020
  15. modified the milestones: v3.17.0, On Deck on Nov 18, 2020
  16. manikantag commented on Jun 28, 2021

    @manikantag

    Same issue with Input font and VSCode on Ubuntu

    image

  17. DanTup commented on Jun 28, 2021

    @DanTup
    Member

    Please add 👍 's to microsoft/vscode#73780 if you're affected by this. There's not a great way to solve this without a better API (besides changing your font to one where those unicode characters being used have the same width as your spaces).

  18. manikantag commented on Jun 29, 2021

    @manikantag

    For now, I've changed editor font to Input Mono and now guides are drawn properly.

    image

  19. added
    blocked on dart / flutter
    on Jul 21, 2021
  20. modified the milestones: On Deck, Backlog on Jul 21, 2021
  21. added
    blocked on vs code / lsp / dap
    and removed
    blocked on dart / flutter
    on Aug 5, 2025
  22. DanTupBot commented on Nov 25, 2026

    @DanTupBot
    Collaborator

    We revisited this to see whether newer VS Code APIs or a different decoration layout could fix the overlap/misalignment without needing changes in VS Code. Unfortunately, there is still no clean fix available on the extension side, so this remains blocked on microsoft/vscode#73780.

    Why this happens & why alternative decoration approaches don't work

    Today, Flutter UI Guides emit a single before decoration per line containing a combined string of non-breaking spaces (\xa0) and box-drawing glyphs (│, ─, ╰, ├). When the editor font is missing those glyphs (falling back to a font with a different width) or is proportional, every character's width difference compounds across the line and pushes the guides onto code text.

    We evaluated the available VS Code decoration mechanisms:

    • Forcing a working font in CSS (fontFamily): ThemableDecorationAttachmentRenderOptions does not expose fontFamily (VS Code's ExtHostTypeConverters strips unsupported properties). Even if it could be forced, a fixed font wouldn't match the character advance width of arbitrary user fonts, and no single box-drawing font is guaranteed to be installed across platforms.
    • Overlay CSS borders (borderWidth/borderStyle/borderColor): Borders avoid font-width dependence, but VS Code clamps .cdr decoration overlays to the line's text length (so ranges on blank lines collapse to column 0), and .cdr overlays are fixed at height: 100% (preventing mid-line horizontal connectors and overlapping VS Code's built-in indent guides).
    • SVG contentIconPath: Cannot reference ThemeColor (dart.flutterUiGuides), doesn't adapt cleanly to arbitrary font sizes / custom line heights, and triggers inline-block baseline / line-height expansion issues.
    • CSS injection via textDecoration: Relies on undocumented, unsanitized CSS interpolation and VS Code's internal .view-line DOM layout, which could break in any VS Code update.

    Experiment: Per-column anchoring

    We also prototyped anchoring each guide character individually at its document column on non-blank lines (and emitting separate zero-width before decorations per vertical guide on blank lines) so glyph-width errors would not accumulate across a line:

    Monospace fallback (Share Tech Mono 0.540em falling back to DejaVu Sans Mono 0.602em)

    Per-column anchoring eliminates cumulative drift and fixes blank-line alignment, leaving only a slight touch on the final ─ (since a fallback ─ is slightly wider than a Share Tech Mono space):

    Before After (per-column prototype)
    Before - Monospace Fallback After - Monospace Fallback

    Proportional font (Liberation Sans: space 0.278em, │ 0.625em, ├/─ 0.708em, ╰ fallback in DejaVu Sans Mono 0.602em)

    Even when every guide glyph is anchored at the exact same column, the result still looks janky across rows:

    Before After (per-column prototype)
    Before - Proportional After - Proportional

    Two glyph-metric issues remain unsolvable with text decorations:

    1. Different stem offsets within and across fonts: In Liberation Sans, │ (U+2502) places its vertical stem at xMin = 0.230em, whereas ├ (U+251C) places it at xMin = 0.319em, and the missing rounded corner ╰ (U+2570) falls back to DejaVu Sans Mono (0.602em) with a third stem position—causing vertical lines to zig-zag across rows even when anchored at the exact same pixel column. Partial-coverage monospace fonts that have │/─/├ but lack ╰ (U+2570)—such as Ubuntu Mono and Anonymous Pro—also suffer this stem mismatch on ╰.
    2. Final ─ overhang: In proportional fonts, ─ (0.708em) is ~2.5× wider than a space (0.278em), so the final ─ anchored one space before the widget still overhangs onto the text.

    Combined with ~2.7× more decoration ranges per file, per-column anchoring is not a clean general fix. Any glyph-based workaround runs into these font/glyph-metric limits, so this issue remains blocked on VS Code providing a proper overlay/line-drawing API (microsoft/vscode#73780). Please add 👍 reactions there if you're affected!

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

    blocked on vs code / lsp / dapin editorin flutteris bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions