You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Flutter UI Guides overlap with text when using certain fonts #1887
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:
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
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).
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 Mono0.540em falling back to DejaVu Sans Mono0.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)
Proportional font (Liberation Sans: space 0.278em, │0.625em, ├/─0.708em, ╰ fallback in DejaVu Sans Mono0.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)
Two glyph-metric issues remain unsolvable with text decorations:
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 ╰.
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!
Activity
DanTup commentedon Jul 23, 2019
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?
DanTup commentedon Jul 23, 2019
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.).
DanTup commentedon Sep 11, 2019
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:
So for now I think there are only two solutions:
Unfortunately neither of these are good solutions. I'll post back if I can come up with anything better.
[-]Flutter UI Guides workds awful in Manjaro VScode official 13.6.1[/-][+]Flutter UI Guides overlap with text when using certain fonts[/+]DanTup commentedon Sep 11, 2019
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!
1 remaining item
manikantag commentedon Jun 28, 2021
Same issue with
Inputfont and VSCode on UbuntuDanTup commentedon Jun 28, 2021
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).
manikantag commentedon Jun 29, 2021
For now, I've changed editor font to
Input Monoand now guides are drawn properly.DanTupBot commentedon Nov 25, 2026
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
beforedecoration 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:
fontFamily):ThemableDecorationAttachmentRenderOptionsdoes not exposefontFamily(VS Code'sExtHostTypeConvertersstrips 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.borderWidth/borderStyle/borderColor): Borders avoid font-width dependence, but VS Code clamps.cdrdecoration overlays to the line's text length (so ranges on blank lines collapse to column0), and.cdroverlays are fixed atheight: 100%(preventing mid-line horizontal connectors and overlapping VS Code's built-in indent guides).contentIconPath: Cannot referenceThemeColor(dart.flutterUiGuides), doesn't adapt cleanly to arbitrary font sizes / custom line heights, and triggers inline-block baseline / line-height expansion issues.textDecoration: Relies on undocumented, unsanitized CSS interpolation and VS Code's internal.view-lineDOM 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
beforedecorations per vertical guide on blank lines) so glyph-width errors would not accumulate across a line:Monospace fallback (
Share Tech Mono0.540emfalling back toDejaVu Sans Mono0.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 aShare Tech Monospace):Proportional font (
Liberation Sans: space0.278em,│0.625em,├/─0.708em,╰fallback inDejaVu Sans Mono0.602em)Even when every guide glyph is anchored at the exact same column, the result still looks janky across rows:
Two glyph-metric issues remain unsolvable with text decorations:
Liberation Sans,│(U+2502) places its vertical stem atxMin = 0.230em, whereas├(U+251C) places it atxMin = 0.319em, and the missing rounded corner╰(U+2570) falls back toDejaVu 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 asUbuntu MonoandAnonymous Pro—also suffer this stem mismatch on╰.─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!