VolodymyrBaydalka/docxjs

fix Some fonts are not applied to tags

Opened this issue · 0 comments

Describe the bug
When my document uses certain fonts, the font is not being applied to the span tags in the generated document. Specifically, the font-family property is not added to the span tags as expected, and the font is not displayed correctly.

Document
file.docx

Expected behavior
The custom font should be applied to the font-family property in the span tags and reflected in the generated .docx file.

Screenshots
截屏2024-12-11 10 56 54
截屏2024-12-11 10 58 24

Desktop (please complete the following information):

  • OS: ios
  • Browser chrome - Version
  • 109

Additional context

Modified code

path:src/html-renderer.ts
Original Code:

	renderSymbol(elem: WmlSymbol) {
		var span = this.createElement("span");
		span.style.fontFamily = elem.font;
		span.innerHTML = `&#x${elem.char};`
		return span;
	}

Modified Code:

	renderSymbol(elem: WmlSymbol) {
		var span = this.createElement("span");
		span.style.fontFamily = `'${elem.font}'`;
		span.innerHTML = `&#x${elem.char};`
		return span;
	}