diff --git a/Cargo.lock b/Cargo.lock index caa77c6..4717403 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -193,7 +193,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "docx-rs" -version = "0.2.2" +version = "0.2.3" dependencies = [ "image 0.23.4 (registry+https://github.com/rust-lang/crates.io-index)", "insta 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -210,7 +210,7 @@ dependencies = [ name = "docx-wasm" version = "0.1.0" dependencies = [ - "docx-rs 0.2.2", + "docx-rs 0.2.3", "wasm-bindgen 0.2.53 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-test 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/docx-core/Cargo.toml b/docx-core/Cargo.toml index 99217da..f23ac70 100644 --- a/docx-core/Cargo.toml +++ b/docx-core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "docx-rs" -version = "0.2.2" +version = "0.2.3" authors = ["bokuweb "] repository = "https://github.com/bokuweb/docx-rs" edition = "2018" diff --git a/docx-wasm/js/index.ts b/docx-wasm/js/index.ts index 0d81473..d07d887 100644 --- a/docx-wasm/js/index.ts +++ b/docx-wasm/js/index.ts @@ -126,6 +126,21 @@ export class Docx { run = run.vanish(); } + let f = wasm.createRunFonts(); + if (r.property.fonts?._ascii) { + f = f.ascii(r.property.fonts._ascii); + } + if (r.property.fonts?._hiAnsi) { + f = f.hi_ansi(r.property.fonts._hiAnsi); + } + if (r.property.fonts?._cs) { + f = f.cs(r.property.fonts._cs); + } + if (r.property.fonts?._eastAsia) { + f = f.east_asia(r.property.fonts._eastAsia); + } + run = run.fonts(f); + return run; } @@ -253,17 +268,17 @@ export class Docx { if (p.property.runProperty.fonts) { let f = wasm.createRunFonts(); - if (p.property.runProperty.fonts.ascii) { - f = f.ascii(p.property.runProperty.fonts.ascii); + if (p.property.runProperty.fonts._ascii) { + f = f.ascii(p.property.runProperty.fonts._ascii); } - if (p.property.runProperty.fonts.hiAnsi) { - f = f.hi_ansi(p.property.runProperty.fonts.hiAnsi); + if (p.property.runProperty.fonts._hiAnsi) { + f = f.hi_ansi(p.property.runProperty.fonts._hiAnsi); } - if (p.property.runProperty.fonts.cs) { - f = f.cs(p.property.runProperty.fonts.cs); + if (p.property.runProperty.fonts._cs) { + f = f.cs(p.property.runProperty.fonts._cs); } - if (p.property.runProperty.fonts.eastAsia) { - f = f.east_asia(p.property.runProperty.fonts.eastAsia); + if (p.property.runProperty.fonts._eastAsia) { + f = f.east_asia(p.property.runProperty.fonts._eastAsia); } paragraph = paragraph.fonts(f); } diff --git a/docx-wasm/js/run.ts b/docx-wasm/js/run.ts index c8048bb..729d704 100644 --- a/docx-wasm/js/run.ts +++ b/docx-wasm/js/run.ts @@ -16,12 +16,32 @@ export type RunProperty = { fonts?: RunFonts; }; -export type RunFonts = { - ascii?: string; - hiAnsi?: string; - eastAsia?: string; - cs?: string; -}; +export class RunFonts { + _ascii?: string; + _hiAnsi?: string; + _eastAsia?: string; + _cs?: string; + + ascii(f: string) { + this._ascii = f; + return this; + } + + hiAnsi(f: string) { + this._hiAnsi = f; + return this; + } + + cs(f: string) { + this._cs = f; + return this; + } + + eastAsia(f: string) { + this._eastAsia = f; + return this; + } +} export class Run { children: RunChild[] = []; diff --git a/docx-wasm/package.json b/docx-wasm/package.json index 4b1e3b2..d415c4d 100644 --- a/docx-wasm/package.json +++ b/docx-wasm/package.json @@ -1,6 +1,6 @@ { "name": "docx-wasm", - "version": "0.0.77", + "version": "0.0.80", "main": "dist/node/index.js", "browser": "dist/web/index.js", "author": "bokuweb ",