I want to create some html output from .fo
file and I wrote myself some xsl templates to get the desired output.
For the styling of the html
-elements, each element has a class
attribute with the matching css
-class.
That looks like the following:
.page_2_text_3 {
transform: translate(0pt, 82.96pt);
font-family: ITCFranklinGothicStd-Book;
font-style: normal;
font-weight: 400;
font-variant: normal;
font-size: 10pt;
color: #000000;
}
The problem here is that the font ITCFranklinGothicStd-Book
can't be found and is substituted by some other font.
Is there any way to export the font as base64 in a template, so i can add a @font-face
to my css like so:
<xsl:template name="fontexport">
<xsl:param name="font"/>
<xsl:param name="fontname"/>
@font-face {
font-family: "<xsl:value-of select="$fontname"/>";
src: url("<xsl:value-of select="$font" mode="base64"/>")<!-- convert the $font into base64 -->
}
</xsl:template>
this should create the following output when calling call-template
with font and fontname as parameter
@font-face {
font-family: "ITCFranklinGothicStd-Book";
src: url("data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAB...)
}
Is that possible somehow?
If you move to an XSLT processor that supports the EXPath file module, such as Saxon-PE, then you can read the font file using file:read-binary()
, which returns an xs:base64Binary
value, and the string()
function applied to this value gives you the Base64 representation.