@embedpdf/plugin-fonts (英语)
EmbedPDF的字体:列出文档可以被写入的字体,并像引擎写的那样在浏览器中绘制出文字.
此插件与每个 EmbedPDF 框架包相伴而来 。 从您使用的那个导入 :
| 框架 | 从 | 文档 |
|---|---|---|
| 反应 | @embedpdf/react/fonts | 字体 |
| 阴道 | @embedpdf/vue/fonts | 字体 |
| 丝绒 | @embedpdf/svelte/fonts | 字体 |
| 角质 | @embedpdf/angular/fonts | 字体 |
在反应中
文本 引擎在自由文本框、窗体字段或编辑标签中写到它的字体
fontFamily 名称。 登记册 fontsPlugin() 来列出文档中可以写入的字体,然后
在浏览器中以字体绘制文字, 引擎将用 :
font-select.tsx
import { useFontsState } from '@embedpdf/react/fonts';
export function FontSelect({
value,
onChange,
}: {
value: string;
onChange: (font: string) => void;
}) {
const { fonts } = useFontsState();
const choosable = fonts?.fonts.filter((font) => font.canChoose) ?? [];
return (
<select value={value} onChange={(event) => onChange(event.target.value)}>
{choosable.map((font) => (
<option key={font.name} value={font.name}>
{font.name}
</option>
))}
</select>
);
}
注释和窗体层自行使用插件:用它键入文本显示 引擎的字体用它写;没有它,在标准字体中,引擎会倒回. 文档打开时不读:字体第一次读取时需要它们.
许可证
阿帕奇 - 2.0