fix: use a box-drawing-capable monospace font for the mono typography token - #1163
fix: use a box-drawing-capable monospace font for the mono typography token#1163alexey-milovidov wants to merge 1 commit into
Conversation
The mono stack started with Inconsolata. The full Inconsolata font has box-drawing glyphs, but the Google Fonts webfont is served as latin/latin-ext subsets whose unicode-range does not include U+2500-U+259F, so the frames of ClickHouse Pretty* output formats fall through to the next font in the stack. Consolas is absent on Linux/macOS and 'SFMono Regular' is not a real family name, so those characters land in a generic monospace with different advance widths and every frame line breaks apart. Use the same font stack as the ClickHouse Play UI instead: every font in it covers box drawing. Also set line-height to normal for the mono text styles: these fonts draw box glyphs to fill exactly their normal line box (1.164em for DejaVu Sans Mono, 1.133em for Liberation Mono), so vertical lines touch at 'normal' and break apart at anything larger. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 099b31c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Storybook Preview Deployed✅ Preview URL: https://click-o7x6y2d58-clickhouse.vercel.app Built from commit: |
|
Hi @alexey-milovidov ! 👋 Thank you for the PR! Created a follow up ticket Proposal:
|
|
Yeah agreed, for context, in addition to CodeBlock, the SQL Console uses Inconsolata so any change needs to be deeply tested to ensure that all existing functionality is preserved and unaffected. Special characters, Cyrillic fallback etc etc. cc @ArctypeZach for awareness as we'll want to collaborate on testing. |
Problem
The
typography.font.families.monotoken was"Inconsolata", Consolas, "SFMono Regular", monospace. In apps that load Inconsolata from Google Fonts (as.storybook/preview-head.htmldid, and as ClickHouse Fiddle does), box-drawing characters — the frames of ClickHousePretty*output formats, U+2500–U+259F — render broken:unicode-rangedoes not include U+2500–U+259F, so those characters fall through to the rest of the stack.Consolasis absent on Linux and macOS, andSFMono Regularis not a real family name (the PostScript name isSFMono-Regular, the family isSF Mono), so the characters land in a generic monospace whose advance width differs from Inconsolata — every frame line breaks apart horizontally.│glyphs of consecutive rows even with a correct font.This is the upstream half of ClickHouse/clickhouse-fiddle#82.
Fix
"DejaVu Sans Mono", "Liberation Mono", MonoLisa, Consolas, monospace— the same stack the ClickHouse Play UI uses. Every font in it (and the typicalmonospacedefaults such as Menlo) covers box drawing.line-height: normalfor theproduct/text/monostyles. These fonts draw box-drawing glyphs to fill exactly their normal line box (1.164 em for DejaVu Sans Mono, 1.133 em for Liberation Mono), so vertical lines touch atnormaland break apart at anything larger — a fixed value like 1.25 measurably leaves gaps (comparison).yarn generate:tokens; removed the now-unused Inconsolata webfont from the Storybook preview head.Before / after
The same
PrettyMonoBlockoutput rendered with the old and new--click-codeblock-typography-text-defaulttoken values:And the effect in ClickHouse Fiddle (https://fiddle.clickhouse.com/7ae4e9f7-bd3a-4638-8d98-540c90aa14bd): before → after.
Verification
yarn buildpasses (including the dist health check)yarn vitest run: 544 tests in 61 files passyarn lint: only pre-existing warnings🤖 Generated with Claude Code