@@ -11,6 +11,7 @@ const projectRoot = join(__dirname, '..')
1111const distDir = join ( projectRoot , 'dist' )
1212const fontsSourceDir = join ( projectRoot , 'fonts-source' )
1313const fontsOutputDir = join ( projectRoot , 'public' , 'fonts' )
14+ const distFontsDir = join ( distDir , 'fonts' )
1415
1516// 思源宋体字体文件路径(支持 TTF 和 OTF)
1617let sourceFontPath = ''
@@ -177,6 +178,22 @@ function generateFontSubset(characters) {
177178 const sizeMB = ( stats . size / 1024 / 1024 ) . toFixed ( 2 )
178179 console . log ( `📦 文件大小: ${ sizeKB } KB (${ sizeMB } MB)` )
179180
181+ // 复制字体文件到 dist/fonts/ 目录(构建后生成的文件需要手动复制)
182+ if ( ! fs . existsSync ( distFontsDir ) ) {
183+ fs . mkdirSync ( distFontsDir , { recursive : true } )
184+ }
185+ const distFontPath = join ( distFontsDir , 'NotoSerifCJK-Subset.woff2' )
186+ copyFileSync ( outputFontPath , distFontPath )
187+ console . log ( `📋 字体文件已复制到: ${ distFontPath } ` )
188+
189+ // 同时复制 LinBiolinum.woff2(如果存在)
190+ const linBiolinumPath = join ( fontsOutputDir , 'LinBiolinum.woff2' )
191+ if ( fs . existsSync ( linBiolinumPath ) ) {
192+ const distLinBiolinumPath = join ( distFontsDir , 'LinBiolinum.woff2' )
193+ copyFileSync ( linBiolinumPath , distLinBiolinumPath )
194+ console . log ( `📋 LinBiolinum 字体已复制到: ${ distLinBiolinumPath } ` )
195+ }
196+
180197 resolve ( )
181198 } )
182199
0 commit comments