vuejs / core

🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
https://vuejs.org/
MIT License
47.75k stars 8.34k forks source link

Font rendering difference between dev vite server and built #12414

Closed alexchexes closed 5 days ago

alexchexes commented 6 days ago

Vue version

3.5.12

Link to minimal reproduction

https://github.com/alexchexes/vue-built-font-rendering-difference

Steps to reproduce

  1. Use a display with PPI < 130 (e.g., a FullHD 17.3" laptop screen). Set your Windows and/or Chrome browser display scaling to 100%.
  2. Clone the repro repo https://github.com/alexchexes/vue-built-font-rendering-difference
  3. pnpm install, pnpm run dev
  4. Observe how the pink text "Font rendering difference" is rendered in the running Vite dev server
  5. pnpm run build, pnpm run preview
  6. Observe how the pink text "Font rendering difference" is rendered in the built files

What is expected?

The font should render identically in both environments — live preview via the Vite dev server and the built HTML

What is actually happening?

The font renders thinner in the Vite dev server compared to the built HTML (or the other way around - font rendered thicker in the built HTML compared to the Vite dev server)

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700H
    Memory: 42.78 GB / 63.67 GB
  Binaries:
    Node: 22.11.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.9.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: 9.12.3 - ~\AppData\Roaming\npm\pnpm.CMD
  Browsers:
    Edge: Chromium (130.0.2849.80)
    Chrome 130.0.6723.117 (Official Build) (64-bit) (cohort: Stable) 
  npmPackages:
    vue: ^3.5.12 => 3.5.13

Any additional comments?

The issue arises in the default Vue HelloWorld template with all styles and settings being default. Only a single line of HTML and one CSS rule were added to demonstrate the issue.

I first encountered this while setting up Tailwind CSS in a freshly created Vue HelloWorld app. Later, I reproduced the issue without Tailwind or any other modifications — only the default Vue HelloWorld setup was used.

Here is a screencast demonstration:

https://github.com/user-attachments/assets/26361b69-5bdb-4e24-9ff2-6a9cbcc50aba

Vite dev server: 2024-11-16--13-26-14--552

Build: 2024-11-16--13-26-26--657

Computed styles are identical in both cases:

2024-11-16--12-42-04--126 2024-11-16--12-41-38--110