docbook-apps

  • 1.  embedding fonts in epub? (and docbook for publishers -- hurrah!)

    Posted 11-30-2015 08:32
    I'm at the final stages of making an epub file, and I was wondering if
    there's an easy way to declare a font file for embedding.

    I generally am fine with manually moving over assets into the output
    folder. But apparently a reference appears in the opf manifest file.


    To add the reference you need to declare the location in the css (check!)
    and declare it in the OPF manifest (oops!)

    See
    http://ebooks.stackexchange.com/questions/1037/can-i-make-custom-fonts-show-up-in-ibooks

    When the epub stylesheets were written, support for embedding fonts was
    practically nonexistent, but now I think all the major platforms support
    font-embedding.

    (By the way, a great reference on all aspects of using embedded fonts in
    ebooks is here: https://www.bisg.org/publications/field-guide-fonts-ebooks )

    Perhaps -- if it's not already done, this could be handled as a parameter.
    I'll be happy to write up a feature request.


    Wow, the most recent stylesheets have been written to support Docbook for
    Publishers... That's a big deal for me and greatly appreciated. (I just
    learned this .... 5 minutes ago!) Too bad, because it would have helped
    with my current ebook (whose deadline is rapidly approaching). But I have
    several other ebooks to try it out on over the next few months. In 2013 I
    used Docbook to produce a dramatic text... and some of those elements could
    have come in handy at the time......


    --
    Robert Nagle
    3000 Greenridge Dr #2204, Houston TX 77057-6037
    (Cell) 832-251-7522 Carbon Neutral Since Jan 2010



  • 2.  Re: [docbook-apps] embedding fonts in epub? (and docbook for publishers -- hurrah!)

    Posted 11-30-2015 16:42
    Dne 30.11.2015 v 09:32 Robert Nagle napsal(a):
    > I'm at the final stages of making an epub file, and I was wondering
    > if there's an easy way to declare a font file for embedding.

    Simply add a template like this to your custom XSL file for epub:

    <xsl:template name="manifest.fonts">
    <xsl:element name="item" namespace="{$opf.namespace}">
    <xsl:attribute name="id">some-unique-id</xsl:attribute>
    <xsl:attribute name="href">path/to/font.ttf</xsl:attribute>
    <xsl:attribute name="media-type">application/x-font-ttf</xsl:attribute>
    </xsl:element>
    <xsl:element name="item" namespace="{$opf.namespace}">
    <xsl:attribute name="id">some-unique-id2</xsl:attribute>
    <xsl:attribute name="href">path/to/font2.otf</xsl:attribute>
    <xsl:attribute name="media-type">application/x-font-ttf</xsl:attribute>
    </xsl:element>
    </xsl:template>

    Attribute "id" can contain any string you like, it just needs to be
    unique within the manifest file. Attribute "href" is the path to the
    font file relative to the manifest file. Attribute "media-type" is MIME
    type of the font file. Make sure to set the value correctly if you use
    other font formats than TTF.

    If you'd like to see an example of Epub with embedded fonts:
    https://swarmwise.pirati.cz/swarmwise.epub

    Regards,
    Martin Doucha




  • 3.  Re: [docbook-apps] embedding fonts in epub? (and docbook for publishers -- hurrah!)

    Posted 11-30-2015 16:59
    Oh, right, there is also the 'manifest.fonts' template specifically for
    that.

    Bob Stayton
    Sagehill Enterprises
    bobs@sagehill.net

    On 11/30/2015 8:41 AM, Martin Doucha wrote:
    > Dne 30.11.2015 v 09:32 Robert Nagle napsal(a):
    >> I'm at the final stages of making an epub file, and I was wondering
    >> if there's an easy way to declare a font file for embedding.
    >
    > Simply add a template like this to your custom XSL file for epub:
    >
    > <xsl:template name="manifest.fonts">
    > <xsl:element name="item" namespace="{$opf.namespace}">
    > <xsl:attribute name="id">some-unique-id</xsl:attribute>
    > <xsl:attribute name="href">path/to/font.ttf</xsl:attribute>
    > <xsl:attribute name="media-type">application/x-font-ttf</xsl:attribute>
    > </xsl:element>
    > <xsl:element name="item" namespace="{$opf.namespace}">
    > <xsl:attribute name="id">some-unique-id2</xsl:attribute>
    > <xsl:attribute name="href">path/to/font2.otf</xsl:attribute>
    > <xsl:attribute name="media-type">application/x-font-ttf</xsl:attribute>
    > </xsl:element>
    > </xsl:template>
    >
    > Attribute "id" can contain any string you like, it just needs to be
    > unique within the manifest file. Attribute "href" is the path to the
    > font file relative to the manifest file. Attribute "media-type" is MIME
    > type of the font file. Make sure to set the value correctly if you use
    > other font formats than TTF.
    >
    > If you'd like to see an example of Epub with embedded fonts:
    > https://swarmwise.pirati.cz/swarmwise.epub
    >
    > Regards,
    > Martin Doucha
    >



  • 4.  Re: [docbook-apps] embedding fonts in epub? (and docbook for publishers -- hurrah!)

    Posted 11-30-2015 16:58
    Hi Robert,
    I presume you are using the epub3 stylesheets. There is an empty
    utility template named 'user.manifest.items' that will write custom
    items into the manifest. See epub3/epub3-element-mods.xsl for examples
    of how to write elements in the opf namespace.

    I would be curious to hear how well it works in ereaders. When I was
    preparing the epub for my solar energy book earlier this year, I
    considered using embedded fonts. But the more I read about it, the more
    I learned about the difficulties and inconsistencies, and decided it
    wasn't worth it, at least at that time.

    Bob Stayton
    Sagehill Enterprises
    bobs@sagehill.net

    On 11/30/2015 12:32 AM, Robert Nagle wrote:
    > I'm at the final stages of making an epub file, and I was wondering if
    > there's an easy way to declare a font file for embedding.
    >
    > I generally am fine with manually moving over assets into the output
    > folder. But apparently a reference appears in the opf manifest file.
    >
    >
    > To add the reference you need to declare the location in the css
    > (check!) and declare it in the OPF manifest (oops!)
    >
    > See
    > http://ebooks.stackexchange.com/questions/1037/can-i-make-custom-fonts-show-up-in-ibooks
    >
    > When the epub stylesheets were written, support for embedding fonts was
    > practically nonexistent, but now I think all the major platforms support
    > font-embedding.
    >
    > (By the way, a great reference on all aspects of using embedded fonts in
    > ebooks is here: https://www.bisg.org/publications/field-guide-fonts-ebooks )
    >
    > Perhaps -- if it's not already done, this could be handled as a
    > parameter. I'll be happy to write up a feature request.
    >
    >
    > Wow, the most recent stylesheets have been written to support Docbook
    > for Publishers... That's a big deal for me and greatly appreciated. (I
    > just learned this .... 5 minutes ago!) Too bad, because it would have
    > helped with my current ebook (whose deadline is rapidly approaching).
    > But I have several other ebooks to try it out on over the next few
    > months. In 2013 I used Docbook to produce a dramatic text... and some of
    > those elements could have come in handy at the time......
    >
    >
    > --
    > Robert Nagle
    > 3000 Greenridge Dr #2204, Houston TX 77057-6037
    > (Cell) 832-251-7522 Carbon Neutral Since Jan 2010
    >