mirror of
https://github.com/xiaoqidun/ofdgo.git
synced 2026-10-29 13:56:32 +08:00
1 parent
50898934dc
commit
f4429b126a
3 files changed
+9
-5
No files matched your search
@@ -4423,11 +4423,13 @@ function updateTextFonts(item, refresh = false) {
|
||||
if (document.activeElement === el.textFont && fontPicker.open) return;
|
||||
state.textFontID = key;
|
||||
state.textFonts = editorFonts(null);
|
||||
for (const [font, face] of rich.faces) {
|
||||
for (const font of rich.faces.keys()) {
|
||||
const choice = rich.choices?.get(font);
|
||||
state.textFonts.unshift(choice || { id: `embedded:${font}`, name: font === rich.editing.item.font ? rich.editing.item.fontName || font : face.family, embedded: !rich.imports.has(font), richKey: font });
|
||||
state.textFonts.unshift({ ...(choice || { id: `embedded:${font}`,
|
||||
name: state.doc?.fonts?.find(value => value.id === font)?.fontName || (font === rich.editing.item.font ? rich.editing.item.fontName : "") || font,
|
||||
embedded: !rich.imports.has(font) }), richKey: font });
|
||||
}
|
||||
fontPicker.setFonts(state.textFonts, id === undefined ? null : state.textFonts.find(font => font.richKey === id || rich.choices?.get(id) === font));
|
||||
fontPicker.setFonts(state.textFonts, id === undefined ? null : state.textFonts.find(font => font.richKey === id));
|
||||
el.textFont.placeholder = id === undefined ? "混合" : "";
|
||||
}
|
||||
return;
|
||||
@@ -4479,7 +4481,7 @@ async function changeTextFont() {
|
||||
await face.load();
|
||||
if (!isForegroundDocument(tab) || openSeq !== state.openSeq || canvasEditor.input !== editing) return;
|
||||
editing.fontChoice = font;
|
||||
if (item.draft) state.textDefaults.fontChoice = font;
|
||||
if (item.draft && !font.richKey) state.textDefaults.fontChoice = font;
|
||||
if (editing.rich) {
|
||||
const key = font.richKey || (font.embedded ? font.id.slice(9) : `temp-font-${crypto.randomUUID()}`);
|
||||
editing.rich.choices ||= new Map();
|
||||
|
||||
@@ -413,7 +413,9 @@ export class RichTextSession {
|
||||
}
|
||||
setFont(face, data, key) {
|
||||
key ||= `temp-font-${crypto.randomUUID()}`;
|
||||
const previous = this.faces.get(key);
|
||||
this.faces.set(key, face);
|
||||
if (previous && ![...this.faces.values()].includes(previous)) document.fonts.delete(previous);
|
||||
if (data) this.imports.set(key, data);
|
||||
document.fonts.add(face);
|
||||
this.apply({ font: key });
|
||||
|
||||
@@ -31,7 +31,7 @@ export class FontPicker {
|
||||
const name = (font.fullName || font.name).normalize("NFKC").toLocaleLowerCase();
|
||||
this.names.set(name, (this.names.get(name) || 0) + 1);
|
||||
}
|
||||
const key = font => font?.id || font?.postscriptName;
|
||||
const key = font => font?.richKey || font?.id || font?.postscriptName;
|
||||
this.value = !fonts.length ? "" : selected === null ? "-1" : String(Math.max(0, fonts.findIndex(font => key(font) === key(selected))));
|
||||
this.restore();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user