Font not getting embedded into a pdf document - backend

Hi,
I am trying to embed fonts into the native PDF export in confluence at backend and not at the UI. I have gone through
https://confluence.atlassian.com/conf76/advanced-pdf-export-customizations-1018768533.html
above link. And it doesn’t seem to do anything.

Here is the code which I have added to the html and which is being returned to confluence native pdf export -

 
  @font-face { src: url('file:///fonts/alegreya.ttf'); -fs-pdf-font-embed: embed }
  @font-face { src: url('file://fonts/alegreya.ttf'); -fs-pdf-font-embed: embed }
  @font-face { src: url('/fonts/alegreya.ttf'); -fs-pdf-font-embed: embed }
  @font-face { src: url('fonts/alegreya.ttf'); -fs-pdf-font-embed: embed }
  @font-face { src: url(file:///Users/saurabh.gupta/workspace/plugin/target/classes/fonts/alegreya.ttf); -fs-pdf-font-embed: embed }
  @font-face { src: url(file://Users/saurabh.gupta/workspace/plugin/target/classes/fonts/alegreya.ttf); -fs-pdf-font-embed: embed }
  @font-face { src: url(/Users/saurabh.gupta/workspace/plugin/target/classes/fonts/alegreya.ttf); -fs-pdf-font-embed: embed }
  @font-face { src: url(Users/saurabh.gupta/workspace/plugin/target/classes/fonts/alegreya.ttf); -fs-pdf-font-embed: embed }
  @font-face { src: url(///Users/saurabh.gupta/workspace/plugin/target/classes/fonts/alegreya.ttf); -fs-pdf-font-embed: embed }

The end result is the same 4 confluence fonts getting embedded. And alegreya.ttf is not added to that list.
I am not able to get the same thing working via the UI. Anyone has any examples which I can use.

For anyone facing the issue here are the top two mistakes i made

  1. When embedding fonts, the text with that font should be present in the html. If not, the flying pdf 3rd party library used by Atlassian excludes the font from getting embedded.
  2. The path is as directed in the Atlassian doc. Although it may not work sometimes so try using something like tmp/. Working example below.
  3. Adding font also works when doing it through a backend plugin.
@font-face { src: url(file:///tmp/alegreya.ttf); -fs-pdf-font-embed: embed }
@font-face { src: url(file:///tmp/alegreya-bold.ttf); -fs-pdf-font-embed: embed }
@font-face { src: url(file:///tmp/arial.ttf); -fs-pdf-font-embed: embed }

Hopefully this helps! Happy coding!