Skip to content

Commit 6b9048d

Browse files
committed
fix: align box-drawing code blocks
1 parent 9a6ba52 commit 6b9048d

2 files changed

Lines changed: 17 additions & 11 deletions

File tree

‎.changeset/eight-doors-care.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@node-core/ui-components': patch
3+
---
4+
5+
Fix monospace box-drawing alignment on platforms without compatible system fonts

‎packages/ui-components/src/styles/markdown.css‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,24 +95,25 @@ main {
9595
}
9696

9797
/*
98-
* Fenced code blocks use a system monospace stack instead of IBM Plex Mono.
99-
* Plex has no glyphs for the Unicode Box Drawing block (U+2500–U+257F) and
100-
* Google Fonts never serves that block, so the box-drawing characters in
101-
* ASCII-art diagrams (e.g. the URL table in url.md) fall back per-glyph to
102-
* the OS default monospace. On Windows that is Consolas (0.55em) while Plex
103-
* letters are 0.60em; the mismatched advance widths shear the diagram out of
104-
* alignment. Rendering the whole block in one system font keeps every glyph
105-
* the same width — the same stack nodejs.org and the legacy-html generator
106-
* already use. See https://github.com/nodejs/doc-kit/issues/909.
98+
* Fenced code blocks prefer a system monospace stack to keep ASCII-art
99+
* diagrams on consistent font metrics. The IBM Plex Mono Latin webfont subset
100+
* does not contain the Unicode Box Drawing block (U+2500–U+257F), so platforms
101+
* whose system fonts also lack those glyphs may otherwise fall back per-glyph
102+
* to a font with incompatible advance widths.
103+
*
104+
* IBM Plex Mono is kept before Courier New as a late fallback. Doc Kit
105+
* provides a matching IBM Plex Mono box-drawing subset, allowing platforms
106+
* such as Android to render the diagram with compatible metrics.
107+
* See https://github.com/nodejs/doc-kit/issues/909.
107108
*
108109
* This only overrides the variable within `pre`, so inline code and the rest
109110
* of the UI keep IBM Plex Mono. The variable keeps its name because the
110111
* compiled @node-core/ui-components CSS reads `var(--font-ibm-plex-mono)`.
111112
*/
112113
pre {
113114
--font-ibm-plex-mono:
114-
'SFMono-Regular', 'Menlo', 'Consolas', 'Liberation Mono', 'Courier New',
115-
monospace;
115+
'SFMono-Regular', 'Menlo', 'Consolas', 'Liberation Mono', 'IBM Plex Mono',
116+
'Courier New', monospace;
116117
}
117118

118119
p {

0 commit comments

Comments
 (0)