Let fonts suit for more characters

This commit is contained in:
巴里切罗
2018-07-24 12:24:26 +08:00
parent ee048968cc
commit 1fad9a666e
5 changed files with 12 additions and 6 deletions

View File

@ -8,14 +8,14 @@ describe("RunFonts", () => {
it("uses the font name for both ascii and hAnsi", () => {
const tree = new Formatter().format(new RunFonts("Times"));
expect(tree).to.deep.equal({
"w:rFonts": [{ _attr: { "w:ascii": "Times", "w:hAnsi": "Times" } }],
"w:rFonts": [{ _attr: { "w:ascii": "Times", "w:cs": "Times", "w:eastAsia": "Times", "w:hAnsi": "Times" } }],
});
});
it("uses hint if given", () => {
const tree = new Formatter().format(new RunFonts("Times", "default"));
expect(tree).to.deep.equal({
"w:rFonts": [{ _attr: { "w:ascii": "Times", "w:hAnsi": "Times", "w:hint": "default" } }],
"w:rFonts": [{ _attr: { "w:ascii": "Times", "w:cs": "Times", "w:eastAsia": "Times", "w:hAnsi": "Times", "w:hint": "default" } }],
});
});
});

View File

@ -2,6 +2,8 @@ import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
interface IRunFontAttributesProperties {
ascii: string;
cs: string;
eastAsia: string;
hAnsi: string;
hint?: string;
}
@ -9,6 +11,8 @@ interface IRunFontAttributesProperties {
class RunFontAttributes extends XmlAttributeComponent<IRunFontAttributesProperties> {
protected xmlKeys = {
ascii: "w:ascii",
cs: "w:cs",
eastAsia: "w:eastAsia",
hAnsi: "w:hAnsi",
hint: "w:hint",
};
@ -20,6 +24,8 @@ export class RunFonts extends XmlComponent {
this.root.push(
new RunFontAttributes({
ascii: ascii,
cs: ascii,
eastAsia: ascii,
hAnsi: ascii,
hint: hint,
}),

View File

@ -108,7 +108,7 @@ describe("Run", () => {
run.font("Times");
const tree = new Formatter().format(run);
expect(tree).to.deep.equal({
"w:r": [{ "w:rPr": [{ "w:rFonts": [{ _attr: { "w:ascii": "Times", "w:hAnsi": "Times" } }] }] }],
"w:r": [{ "w:rPr": [{ "w:rFonts": [{ _attr: { "w:ascii": "Times", "w:cs": "Times", "w:eastAsia": "Times", "w:hAnsi": "Times" } }] }] }],
});
});
});