2017-12-30 20:25:16 +00:00
|
|
|
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
2016-05-21 00:02:46 +01:00
|
|
|
|
2020-06-07 12:38:03 +08:00
|
|
|
export interface IFontAttributesProperties {
|
|
|
|
readonly ascii?: string;
|
|
|
|
readonly cs?: string;
|
|
|
|
readonly eastAsia?: string;
|
|
|
|
readonly hAnsi?: string;
|
2018-11-02 02:51:57 +00:00
|
|
|
readonly hint?: string;
|
2016-05-21 00:02:46 +01:00
|
|
|
}
|
|
|
|
|
2020-06-07 12:38:03 +08:00
|
|
|
class RunFontAttributes extends XmlAttributeComponent<IFontAttributesProperties> {
|
2018-11-02 02:51:57 +00:00
|
|
|
protected readonly xmlKeys = {
|
2017-03-10 10:42:24 +01:00
|
|
|
ascii: "w:ascii",
|
2018-07-24 12:24:26 +08:00
|
|
|
cs: "w:cs",
|
|
|
|
eastAsia: "w:eastAsia",
|
2017-03-10 10:42:24 +01:00
|
|
|
hAnsi: "w:hAnsi",
|
|
|
|
hint: "w:hint",
|
|
|
|
};
|
2016-05-21 00:02:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export class RunFonts extends XmlComponent {
|
2020-06-07 12:38:03 +08:00
|
|
|
constructor(name: string, hint?: string);
|
|
|
|
constructor(attrs: string | IFontAttributesProperties);
|
|
|
|
constructor(nameOrAttrs: string | IFontAttributesProperties, hint?: string) {
|
2017-03-08 17:08:44 +01:00
|
|
|
super("w:rFonts");
|
2020-06-07 12:38:03 +08:00
|
|
|
if (typeof nameOrAttrs === "string") {
|
|
|
|
// use constructor(name: string, hint?: string);
|
|
|
|
const name = nameOrAttrs;
|
|
|
|
this.root.push(
|
|
|
|
new RunFontAttributes({
|
|
|
|
ascii: name,
|
|
|
|
cs: name,
|
|
|
|
eastAsia: name,
|
|
|
|
hAnsi: name,
|
|
|
|
hint: hint,
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
// use constructor(attrs: IRunFontAttributesProperties);
|
|
|
|
const attrs = nameOrAttrs;
|
|
|
|
this.root.push(new RunFontAttributes(attrs));
|
|
|
|
}
|
2016-05-21 00:02:46 +01:00
|
|
|
}
|
2017-03-08 17:08:44 +01:00
|
|
|
}
|