After Patching, Following Text is Wrong Font Family
ilrein opened this issue · comments
Thank you for raising an issue to docx
Please do not raise an issue unless it is an issue.
I am using patching code
Looks like this:
const textConfig = {
text: value,
font: 'times',
bold: field.bold,
allCaps: field.text_transform === 'uppercase',
size: field.font_size,
color: field.color || "#FF0000",
underline: {
type: field.underlineType || UnderlineType.SINGLE,
color: field.underlineColor || "#FF0000",
},
}
console.log(textConfig)
patches[field.name] = {
type: PatchType.PARAGRAPH,
children: [
new TextRun(textConfig),
],
};
It works well, but I've noticed a problem where some of the text after the patch changes from "times" to "arial" instead, which ruins the output. This doesn't happen for the first 2 instances (on this specific doc, but it does for the next ones).
Has this ever been flagged before? Would love to address this. I can provide code samples with docs if needed.
As for a quick alternative, is there a way to update a document to have the same font used universally in it?
You are supposed to set keepOriginalStyles
to true
In future versions of docx
, this will be set to true by default which makes the most sense. Check out https://github.com/dolanmiu/docx/blob/master/demo/89-template-document.ts, run it, and check the output. Styles, fonts, colors are all preserved