GemBox Support Forum

How to set FontsBaseUri


We want to be able to use a web font in our document.
We can see that there is a FontsBaseUri property but no example of how to set it.

The font we want to use is Tangerine from Google https://fonts.google.com/specimen/Tangerine
The font resource is https://fonts.gstatic.com/s/tangerine/v17/IurY6Y5j_oScZZow4VOxCZZM.woff2

We want to be able to update all the fonts used in a document with this Tangerine font e.g.

GemBox.Document.FontSettings.FontsBaseUri = New Uri("https://fonts.gstatic.com/s/tangerine/v17/IurY6Y5j_oScZZow4VOxCZZM.woff2")
document = DocumentModel.Load("Account_Letter.docx")
    For Each DocumentRun In document.GetChildElements(True, ElementType.Run)
      DocumentRun.CharacterFormat.FontName = "Tangerine"

Thank you in advance

Hi Gavin,

I’m afraid you cannot use the FontsBaseUri property like that.

You can set this property to the directory path (“file:///…”) or to the resource location (“pack://application:…”). You see, both FontsBaseDirectory and FontsBaseResourceLocation set the FontsBaseUri to desired value.

Anyway, to use that font you’ll need to download it and either place it inside some folder or embed it inside your application. However, you should not use the “.woff2” format, you should use the “.ttf”.


Thanks for the clarification Mario.