Step by step guide
Adding fonts to an ODF document is actually very easy and it takes just four simple steps. You can even do it by hand. If you have edited an ODF document before, this is the fast explanation (if this is entirely new to you, don't worry, there is a fully detailed description available below as well. If you are a professional font user and want more detail, that is available as well):
1) Create a folder named Fonts inside the ODF zip container and add the font file to it. You can use software like Jzip, Winzip, StuffIt if you want. Or if you want to use the classical console terminal:
prompt> mkdir /tmp/Fonts && cd /tmp prompt> cp yourfontname.ttf /tmp/Fonts prompt> zip path/to/filename.odp Fonts/yourfontname.ttf
2) extract the file META-INF/manifest.xml ((which is like the 'index' in a book) from inside the ZIP package and open it in an editor.
- After the element <manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0" manifest:version="1.3"> add a new line identifying the location of the font in the package: <manifest:file-entry manifest:full-path="Fonts/yourfontname.ttf" manifest:media-type="application/x-font-ttf" /> If you are embedding different font formats like OpenType or type1 fonts, note that these have another media-type. For complete description see [footnote 1]
3) extract the file styles.xml from inside the ZIP package and open it in an editor.
- Search for <office:font-face-decls>. At the root level of that section (so immediately following that tag) include the following: <style:font-face style:name="Your Font Name"> <svg:font-face-src> <svg:font-face-uri xlink:href="yourfontname.ttf"> <svg:font-face-format svg:string="truetype"/> </svg:font-face-uri> </svg:font-face-src> </style:font-face> - Now search for <office:styles>. At the root level of that section (so immediately following that tag) include the following: <style:style style:name="Self-made Style" style:family="paragraph"> <style:text-properties style:font-name="Your Font Name" fo:font-size="12pt" style:letter-kerning="true" fo:color="#000000"/> </style:style>
4) Put the styles.xml and META-INF/manifest.xml files back in the ODF package (i.e. the zip container).
[footnote 1] Note that there are other optional attributes you can add to tell the application a lot more about the fonts you are embedding. These are probably only relevant for professional font users, and include the Font Family (svg:font-family), as well as the font style (svg:font-style), variant (svg:font-variant), weight (svg:font-weight), font-stretch (svg:font-stretch) etc.
[footnote 2] Note that the so called attribute for manifest:media-type officially depends on the font format you will be including. You should be including the media-type as registered at IANA:
https://www.iana.org/assignments/media-types However, not many too many font formats have a formally registered media-type at IANA as of the time of writing. application/font-tdpfr (for the Bitstream PFR font format) application/vnd.font-fontforge-sfd (for the Fontforge SFD font format) application/vnd.ms-fontobject (for Microsoft .eos font files) application/font-woff (pending) application/x-font-ttf (Truetype) application/x-font-type1 (type 1) application/x-font-otf application/x-font-bdf
In a Flat XML ODF the font is embedded as data uri in xlink:href.