mirror of
https://github.com/xiaoqidun/ofdgo.git
synced 2026-10-29 08:46:55 +08:00
1 parent
e5d7f577c7
commit
4320b53d4a
1 file changed
+6
-5
@@ -4353,15 +4353,15 @@ async function validateRichText(item, model, width, fonts = []) {
|
|||||||
attempted.add(id);
|
attempted.add(id);
|
||||||
const original = (await callWASM("ofdgoEditorFont", id)).bytes;
|
const original = (await callWASM("ofdgoEditorFont", id)).bytes;
|
||||||
const [source] = await callWASM("ofdgoFontFaces", original);
|
const [source] = await callWASM("ofdgoFontFaces", original);
|
||||||
if (!source?.postscriptName) throw error;
|
if (!source?.postscriptName || !source.familyKey) throw error;
|
||||||
await fontManager.loadFaces(data => callWASM("ofdgoFontFaces", data));
|
await fontManager.loadFaces(data => callWASM("ofdgoFontFaces", data));
|
||||||
const candidates = fontManager.editorFonts().filter(font => !font.disabled && font.postscriptName === source.postscriptName);
|
const candidates = fontManager.editorFonts().filter(font => !font.disabled && font.postscriptName === source.postscriptName && font.familyKey === source.familyKey);
|
||||||
let recovered;
|
let recovered;
|
||||||
for (const choice of candidates) {
|
for (const choice of candidates) {
|
||||||
try {
|
try {
|
||||||
const data = await readTextFont(choice, tab);
|
const data = await readTextFont(choice, tab);
|
||||||
const [face] = await callWASM("ofdgoFontFaces", data);
|
const [face] = await callWASM("ofdgoFontFaces", data);
|
||||||
if (face?.postscriptName !== source.postscriptName) continue;
|
if (face?.postscriptName !== source.postscriptName || face.familyKey !== source.familyKey) continue;
|
||||||
await callWASM("ofdgoCheckTextFont", data, model.runs.filter(run => run.format.font === id).map(run => run.text).join(""));
|
await callWASM("ofdgoCheckTextFont", data, model.runs.filter(run => run.format.font === id).map(run => run.text).join(""));
|
||||||
recovered = { key: id, data, choice };
|
recovered = { key: id, data, choice };
|
||||||
break;
|
break;
|
||||||
@@ -4376,8 +4376,9 @@ async function validateRichText(item, model, width, fonts = []) {
|
|||||||
rich.imports.set(id, recovered.data);
|
rich.imports.set(id, recovered.data);
|
||||||
rich.choices.set(id, recovered.choice);
|
rich.choices.set(id, recovered.choice);
|
||||||
const previous = rich.faces.get(id);
|
const previous = rich.faces.get(id);
|
||||||
if (previous) document.fonts.delete(previous);
|
rich.faces.set(id, face);
|
||||||
rich.faces.set(id, face); document.fonts.add(face);
|
if (previous && ![...rich.faces.values()].includes(previous)) document.fonts.delete(previous);
|
||||||
|
document.fonts.add(face);
|
||||||
if (!editing.composing && !editing.saving) { rich.selection(); rich.render(); updateObjectControls(canvasEditor.selected); }
|
if (!editing.composing && !editing.saving) { rich.selection(); rich.render(); updateObjectControls(canvasEditor.selected); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user