Skip to content

fix(viewer): fix monospace font rendering in pre/code blocks on Windows#328

Merged
lizhengfeng101 merged 1 commit into
alibaba:mainfrom
Kakarot30:main
Jul 9, 2026
Merged

fix(viewer): fix monospace font rendering in pre/code blocks on Windows#328
lizhengfeng101 merged 1 commit into
alibaba:mainfrom
Kakarot30:main

Conversation

@Kakarot30

Copy link
Copy Markdown
Contributor

Summary

Fixes monospace font rendering in pre and code blocks on Windows
(Chrome & Edge). Closes #325.

Root Cause

Two issues combined to break monospace rendering on Windows:

  1. Missing global rule — bare <pre> and <code> elements had no
    explicit font-family declaration, so they inherited the body's
    sans-serif stack (-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif)
    instead of the monospace --mono variable.
  2. Wrong font priority — the --mono CSS variable led with
    ui-monospace and SFMono-Regular, which are macOS-native aliases
    that don't resolve on Windows. The browser skipped all the way to
    the generic monospace fallback, which renders poorly.

Changes

internal/viewer/static/style.css

  • Added a global code, pre rule immediately after the body block:
    code, pre {
        font-family: var(--mono);
    }

@CLAassistant

CLAassistant commented Jul 8, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

OpenCodeReview: No comments generated. Looks good to me.

@lizhengfeng101 lizhengfeng101 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lizhengfeng101 lizhengfeng101 merged commit bf0af14 into alibaba:main Jul 9, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Monospace font in pre and code blocks are incorrectly rendered on Windows

3 participants