Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextRun fonts do not work in Word Online #2704

Open
dan-cooke opened this issue Jul 25, 2024 · 5 comments
Open

TextRun fonts do not work in Word Online #2704

dan-cooke opened this issue Jul 25, 2024 · 5 comments

Comments

@dan-cooke
Copy link

dan-cooke commented Jul 25, 2024

Description

When using the TextRun property font to set a font family. The docx just uses the default Aptos font.

Reproduction code

      new TextRun({ text: 'hello world', font: 'Comic Sans MS' })

apologies this is taken from a larger library that I am working on for prosemirror. I can supply a fully working example if required, but its a pretty simple bug to reproduce.

If I generate a docx using this font property.

  • I can successfully open it in Google Docs and everything is in Comic Sans MS
  • I can open it in MS Word Desktop just fine
  • MS Word web does not apply the Comic Sans MS font

Edit

  • I can succesfully set Comic Sans MS font via the Paragraph node and th is works on Web - so this hints that its not an issue with MS Word itself, but seemingly something I am doing / docx is doing
@anti-the-social
Copy link
Contributor

That's probably need to be reported to Microsoft, not here. To make license more flexible, you know.
I would guess its about licensing of the Comic Sans MS and absence of it in Chrome.
If you open it in IE or Edge it might work for you since Microsoft invented that font.

@dan-cooke
Copy link
Author

dan-cooke commented Jul 25, 2024

@anti-the-social I don't think thats quite right, correct me if I'm wrong - but if you have Comic Sans MS installed as a System Font on a Windows machine. You own a license to that font.

See Windows 10 font list

The browser should render that font.

If you open it in IE or Edge it might work for you since Microsoft invented that font.

That is not how fonts work on the web, browsers do not ship any fonts, they just use your system fonts. And websites can load additional fonts, the onus of licensing is on the website author. If every visitor to your site had to own a license to view your fonts that would be a pretty poor experience right?

The issue here is not to do with licensing its seemingly a bug in docx, the reason I am so sure about this?

The font property works when used in a Paragraph on Word Online.

There is probably more to this issue however, as I have uncovered some cases where the font property does work on Word Online, I suspect it could be another styling property I am setting that is conflicting with it.

@anti-the-social
Copy link
Contributor

@dan-cooke I tend to disagree here :)
Neither my mac nor windows are not having Comic Sans font available in Chrome as a font-family.
But my windows machine has Comic Sans at C:/Windows/Fonts
In other words, font is not attached to browser Chrome as you said.

And yes, Word document is zip file and it can include custom fonts in it.
And probably Word in Web does that - attaches Comic Sans if you chose it for some Paragraph.

@anti-the-social
Copy link
Contributor

anti-the-social commented Jul 25, 2024

BTW, here is an example how to attach custom font to the document
https://github.com/dolanmiu/docx/blob/962795743c4f21d84c52e47e4f82dcf4ca536dc3/demo/91-custom-fonts.ts

Highly advice you to read Comic Sans license before attaching and/or using in your commercial or not products.

@dan-cooke
Copy link
Author

dan-cooke commented Jul 25, 2024

@anti-the-social I think we are getting our wires crossed here.

I am not distributing the Comic Sans Font. I am simply setting a CSS variable font-family: 'Comic Sans'

But my windows machine has Comic Sans at C:/Windows/Fonts
In other words, font is not attached to browser Chrome as you said.

That is not what I said :) ... I said Browsers do not package any fonts, however they are capable of reading your OS System fonts.

I highly advise for you to read up on how fonts work on the web, here is a quick primer on safe web fonts as you can see Comic Sans MS is listed here (because every windows and mac user in the world have this font in their system fonts)

Here is a simple example for you:

  1. Right click some text in this github thread > Inspect
  2. Attach a css property font-family: 'Comic Sans MS'
  3. Boom

image

You see that right? Github did not "distribute" the Comic Sans MS font to you, the browser read it from your system fonts

Anyway. This issue is being derailed - this is not about licensing of Comic Sans. You are talking about a completely unrelated circumstance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants