Skip to content

Commit

Permalink
update font
Browse files Browse the repository at this point in the history
  • Loading branch information
YutaUra committed Feb 11, 2024
1 parent 32f9d76 commit 6b3c3df
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
20 changes: 15 additions & 5 deletions scripts/make-term.mts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { writeFileSync } from 'fs'
import { writeFile } from 'node:fs/promises'
import { resolve } from 'node:path'
import MarkdownIt from 'markdown-it'
import MarkdownItContainer from 'markdown-it-container'
import { compileStringAsync } from 'sass'
import { chromium } from 'playwright-core'
import termMarkdown from '../term.md'
import notoSerifJpFont from '@fontsource/noto-serif-jp/index.css'
import style from './style/term.scss'

const notoSerifJpFont = import.meta.resolve(
'@fontsource/noto-serif-jp/index.css'
)

const md = new MarkdownIt({
html: true,
})
Expand All @@ -21,6 +25,9 @@ const dateOption: Parameters<typeof MarkdownItContainer>['2'] = {
if (m) {
const jstString = new Intl.DateTimeFormat('ja-JP-u-ca-japanese', {
era: 'long',
year: 'numeric',
month: 'long',
day: 'numeric',
}).format(new Date())
return `<p>制定 ${jstString}</p>`
}
Expand All @@ -40,17 +47,20 @@ const scss = (await compileStringAsync(style)).css

const html = `
<body>
<style>${notoSerifJpFont}</style>
<link rel="stylesheet" href="${notoSerifJpFont}">
<style>${scss}</style>
${termHTML}
</body>
`

writeFileSync('./term.html', html)
await writeFile('./term.html', html)

// file:///Users/yuta/work/github.com/ycu-engine/community/term.pdf
const browser = await chromium.launch()
const page = await browser.newPage()
await page.setContent(html)
await page.goto(`file://${resolve(import.meta.dirname, '../term.html')}`, {
waitUntil: 'networkidle',
})
await page.pdf({
path: './term.pdf',
margin: { top: 80, left: 60, bottom: 80, right: 60 },
Expand Down
14 changes: 0 additions & 14 deletions scripts/style/term.scss
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
@font-face {
font-family: 'Noto Serif JP';
src: url('scripts/style/Noto_Serif_JP/NotoSerifJP-ExtraLight.otf')
format('opentype'),
url('scripts/style/Noto_Serif_JP/NotoSerifJP-Light.otf') format('opentype'),
url('scripts/style/Noto_Serif_JP/NotoSerifJP-Medium.otf') format('opentype'),
url('scripts/style/Noto_Serif_JP/NotoSerifJP-Regular.otf')
format('opentype'),
url('scripts/style/Noto_Serif_JP/NotoSerifJP-SemiBold.otf')
format('opentype'),
url('scripts/style/Noto_Serif_JP/NotoSerifJP-Bold.otf') format('opentype'),
url('scripts/style/Noto_Serif_JP/NotoSerifJP-Black.otf') format('opentype');
}

body {
padding-top: 3rem;
max-width: 500px;
Expand Down

0 comments on commit 6b3c3df

Please sign in to comment.