Files
genoffice/apps/docs/tests/fonts-css-contract.test.ts
T
merrick-2002andGenOffice 9f971edafa Sync snapshot (2026-09-02) (#181)
- Docs: DOCX rendering and pagination fidelity (page borders, VML pictures, header/footer images, cross-page tables, anchored floats, character-unit indents, CJK typography)
- Docs: more reliable PDF export for huge documents; AI rewrites keep the replaced content's formatting
- Sheets: merge workbooks; Excel-standard keyboard shortcuts; PDF export with header/footer variants and pictures
- Sheets: rendering, conditional formatting, chart and formula fidelity fixes; right-to-left sheet support
- Slides: WordArt text warp, improved text layout and font substitution; AI table edits keep formatting

Co-authored-by: GenOffice <merrick-2002@users.noreply.github.com>
2026-09-03 00:12:17 +08:00

28 lines
1.1 KiB
TypeScript

/**
* Weight contract of the JP Mincho fallback alias (fonts.css): Word's
* Japanese serif faces ship no bold and Word synthesizes uniform thick
* strokes, so the alias must register weight-normal only. A real W6 bold
* face keeps hairline horizontals — bold U+4E00 reads as an arrow at body sizes.
*/
import { readFileSync } from 'node:fs'
import { join } from 'node:path'
import { describe, expect, it } from 'vitest'
const css = readFileSync(join(__dirname, '../src/renderer/fonts/fonts.css'), 'utf8')
function facesOf(family: string): string[] {
return [...css.matchAll(/@font-face\s*\{[^}]*\}/g)]
.map((m) => m[0])
.filter((f) => f.includes(`font-family: '${family}'`))
}
describe('JP Mincho fallback aliases synthesize bold', () => {
for (const family of ['GenOffice Hiragino Mincho', 'GenOffice MS Mincho']) {
it(`${family} registers weight-normal faces only`, () => {
const faces = facesOf(family)
expect(faces.length).toBeGreaterThan(0)
for (const face of faces) expect(face).toContain('font-weight: normal')
})
}
})