mirror of
https://github.com/2234839/web-font.git
synced 2026-09-04 23:02:27 +08:00
fix: 字体加载合并所有预览文字(previewText+bodyTitle+bodyText+charsetPreview)
之前 <link> 只加载 previewText 的字符子集,导致 bodyTitle/bodyText/charsetPreview 区域显示 fallback serif 而非实际字体。现在 allPreviewText 合并所有预览文字请求子集。
This commit is contained in:
parent
7638ce7e2d
commit
afbd4db77c
@ -99,6 +99,13 @@ const bodyText = computed(() => meta.value?.config?.bodyText ?? "");
|
|||||||
/** 字符预览行:来自 config.charsetPreview */
|
/** 字符预览行:来自 config.charsetPreview */
|
||||||
const charsetPreview = computed(() => meta.value?.config?.charsetPreview ?? "");
|
const charsetPreview = computed(() => meta.value?.config?.charsetPreview ?? "");
|
||||||
|
|
||||||
|
/** 所有需要预览的文字合并,用于字体子集加载 */
|
||||||
|
const allPreviewText = computed(() => {
|
||||||
|
if (!meta.value?.config) return "";
|
||||||
|
const c = meta.value.config;
|
||||||
|
return [c.previewText ?? "", c.bodyTitle ?? "", c.bodyText ?? "", c.charsetPreview ?? ""].join("");
|
||||||
|
});
|
||||||
|
|
||||||
/** 使用方法示例代码(动态拼接 origin + fontName) */
|
/** 使用方法示例代码(动态拼接 origin + fontName) */
|
||||||
const usageCode = computed(() =>
|
const usageCode = computed(() =>
|
||||||
`<link rel="stylesheet"
|
`<link rel="stylesheet"
|
||||||
@ -112,11 +119,11 @@ const usageCode = computed(() =>
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div style="min-height: 100vh; background: #fafafa">
|
<div style="min-height: 100vh; background: #fafafa">
|
||||||
<!-- 字体加载:previewContent 为空时不加载(避免无效请求) -->
|
<!-- 字体加载:合并所有预览文字请求字体子集 -->
|
||||||
<link
|
<link
|
||||||
v-if="previewContent"
|
v-if="allPreviewText"
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
:href="`${origin}/api?font=${fontName}&text=${encodeURIComponent(previewContent)}&outType=woff2`"
|
:href="`${origin}/api?font=${fontName}&text=${encodeURIComponent(allPreviewText)}&outType=woff2`"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- 顶部导航 -->
|
<!-- 顶部导航 -->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user