Trying to customize toolchain. PDF is going wrong

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Trying to customize toolchain. PDF is going wrong

kwoot
Hi,

So I am trying to migrate from Asciidoc to Asciidoctor.
I want to use a custom pdf font.
I make a custom theme file, I downloaded some ttf's in a fonts dir, both theme file and font dir are defined in commandline. But whatever I try, it doesn't run. I get the following error.
Anybody any clue? I'm just not seeing it.

Kind regards,
Jeroen

$ asciidoctor-pdf --trace -v   -a pdf-style=cvs-theme.yml -a pdf-fontsdir=/home/jeroen/Cursus_voor_starters/fonts  cvs-lesboek.txt
/usr/lib/ruby/vendor_ruby/ttfunk/table.rb:25: warning: instance variable @offset not initialized
/usr/lib/ruby/vendor_ruby/ttfunk/table.rb:25: warning: instance variable @offset not initialized
/usr/lib/ruby/vendor_ruby/ttfunk/table.rb:25: warning: instance variable @offset not initialized
/usr/lib/ruby/vendor_ruby/ttfunk/table/glyf.rb:30: warning: instance variable @cache not initialized
/usr/lib/ruby/vendor_ruby/ttfunk/table/glyf.rb:30:in `for': undefined method `key?' for nil:NilClass (NoMethodError)
        from /usr/lib/ruby/vendor_ruby/ttfunk/subset/base.rb:132:in `block in collect_glyphs'
        from /usr/lib/ruby/vendor_ruby/ttfunk/subset/base.rb:132:in `each'
        from /usr/lib/ruby/vendor_ruby/ttfunk/subset/base.rb:132:in `inject'
        from /usr/lib/ruby/vendor_ruby/ttfunk/subset/base.rb:132:in `collect_glyphs'
        from /usr/lib/ruby/vendor_ruby/ttfunk/subset/base.rb:32:in `encode'
        from /usr/lib/ruby/vendor_ruby/prawn/font/ttf.rb:261:in `embed'
        from /usr/lib/ruby/vendor_ruby/prawn/font/ttf.rb:255:in `block in register'
        from /usr/lib/ruby/vendor_ruby/pdf/core/document_state.rb:60:in `block in before_render_actions'
        from /usr/lib/ruby/vendor_ruby/pdf/core/document_state.rb:60:in `each'
        from /usr/lib/ruby/vendor_ruby/pdf/core/document_state.rb:60:in `before_render_actions'
        from /usr/lib/ruby/vendor_ruby/pdf/core/renderer.rb:181:in `render_header'
        from /usr/lib/ruby/vendor_ruby/pdf/core/renderer.rb:157:in `render'
        from /usr/lib/ruby/vendor_ruby/prawn/document.rb:359:in `render'
        from /usr/lib/ruby/vendor_ruby/prawn/document.rb:367:in `block in render_file'
        from /usr/lib/ruby/vendor_ruby/prawn/document.rb:367:in `open'
        from /usr/lib/ruby/vendor_ruby/prawn/document.rb:367:in `render_file'
        from /var/lib/gems/2.3.0/gems/asciidoctor-pdf-1.5.0.alpha.15/lib/asciidoctor-pdf/converter.rb:2822:in `write'
        from /usr/lib/ruby/vendor_ruby/asciidoctor/document.rb:1067:in `write'
        from /usr/lib/ruby/vendor_ruby/asciidoctor.rb:1508:in `convert'
        from /usr/lib/ruby/vendor_ruby/asciidoctor/cli/invoker.rb:94:in `block in invoke!'
        from /usr/lib/ruby/vendor_ruby/asciidoctor/cli/invoker.rb:86:in `each'
        from /usr/lib/ruby/vendor_ruby/asciidoctor/cli/invoker.rb:86:in `invoke!'
        from /var/lib/gems/2.3.0/gems/asciidoctor-pdf-1.5.0.alpha.15/bin/asciidoctor-pdf:31:in `<top (required)>'
        from /usr/local/bin/asciidoctor-pdf:23:in `load'
        from /usr/local/bin/asciidoctor-pdf:23:in `<main>'

Custom theme file is:
$ cat cvs-theme.yml
font:
  catalog:
    CaslonPro:
      normal: adobe-caslon-pro-normal.ttf
      italic: adobe-caslon-pro-italic.ttf
      bold: adobe-caslon-pro-bold.ttf
      bold_italic: adobe-caslon-pro-bold_italic.ttf
    DroidSansFallback:
      normal: droid-sans-fallback.ttf
      italic: droid-sans-fallback.ttf
      bold: droid-sans-fallback.ttf
      bold_italic: droid-sans-fallback.ttf
  fallbacks:
    - DroidSansFallback
base:
  font_family: CaslonPro
Reply | Threaded
Open this post in threaded view
|

Re: Trying to customize toolchain. PDF is going wrong

mojavelinux
Administrator
I'm sorry to hear that you are having trouble with fonts.

It's important to understand that most fonts are broken in some way (in my experience). Sometimes, that doesn't matter and ttfunk can handle it. Other times, it causes ttfunk to crash, as with one of your fonts.

I always recommend opening the fonts in fontforge {1} and saving them using that program. fontforge does an amazing job of fixing known errors by rebuilding internal tables and such. That's the workflow I follow.

If the font is corrupt in some way, there's not much Asciidoctor PDF can do. That's why I always recommend letting fontforge validate and clean up the font as a first step.

Experience with fontforge is good to have in general. It also gives you the power of adding missing glyphs to a font or making small modification to characters that are out of place.

Cheers,

-Dan


On Mon, Jun 12, 2017 at 7:04 AM, kwoot [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Hi,

So I am trying to migrate from Asciidoc to Asciidoctor.
I want to use a custom pdf font.
I make a custom theme file, I downloaded some ttf's in a fonts dir, both theme file and font dir are defined in commandline. But whatever I try, it doesn't run. I get the following error.
Anybody any clue? I'm just not seeing it.

Kind regards,
Jeroen

$ asciidoctor-pdf --trace -v   -a pdf-style=cvs-theme.yml -a pdf-fontsdir=/home/jeroen/Cursus_voor_starters/fonts  cvs-lesboek.txt
/usr/lib/ruby/vendor_ruby/ttfunk/table.rb:25: warning: instance variable @offset not initialized
/usr/lib/ruby/vendor_ruby/ttfunk/table.rb:25: warning: instance variable @offset not initialized
/usr/lib/ruby/vendor_ruby/ttfunk/table.rb:25: warning: instance variable @offset not initialized
/usr/lib/ruby/vendor_ruby/ttfunk/table/glyf.rb:30: warning: instance variable @cache not initialized
/usr/lib/ruby/vendor_ruby/ttfunk/table/glyf.rb:30:in `for': undefined method `key?' for nil:NilClass (NoMethodError)
        from /usr/lib/ruby/vendor_ruby/ttfunk/subset/base.rb:132:in `block in collect_glyphs'
        from /usr/lib/ruby/vendor_ruby/ttfunk/subset/base.rb:132:in `each'
        from /usr/lib/ruby/vendor_ruby/ttfunk/subset/base.rb:132:in `inject'
        from /usr/lib/ruby/vendor_ruby/ttfunk/subset/base.rb:132:in `collect_glyphs'
        from /usr/lib/ruby/vendor_ruby/ttfunk/subset/base.rb:32:in `encode'
        from /usr/lib/ruby/vendor_ruby/prawn/font/ttf.rb:261:in `embed'
        from /usr/lib/ruby/vendor_ruby/prawn/font/ttf.rb:255:in `block in register'
        from /usr/lib/ruby/vendor_ruby/pdf/core/document_state.rb:60:in `block in before_render_actions'
        from /usr/lib/ruby/vendor_ruby/pdf/core/document_state.rb:60:in `each'
        from /usr/lib/ruby/vendor_ruby/pdf/core/document_state.rb:60:in `before_render_actions'
        from /usr/lib/ruby/vendor_ruby/pdf/core/renderer.rb:181:in `render_header'
        from /usr/lib/ruby/vendor_ruby/pdf/core/renderer.rb:157:in `render'
        from /usr/lib/ruby/vendor_ruby/prawn/document.rb:359:in `render'
        from /usr/lib/ruby/vendor_ruby/prawn/document.rb:367:in `block in render_file'
        from /usr/lib/ruby/vendor_ruby/prawn/document.rb:367:in `open'
        from /usr/lib/ruby/vendor_ruby/prawn/document.rb:367:in `render_file'
        from /var/lib/gems/2.3.0/gems/asciidoctor-pdf-1.5.0.alpha.15/lib/asciidoctor-pdf/converter.rb:2822:in `write'
        from /usr/lib/ruby/vendor_ruby/asciidoctor/document.rb:1067:in `write'
        from /usr/lib/ruby/vendor_ruby/asciidoctor.rb:1508:in `convert'
        from /usr/lib/ruby/vendor_ruby/asciidoctor/cli/invoker.rb:94:in `block in invoke!'
        from /usr/lib/ruby/vendor_ruby/asciidoctor/cli/invoker.rb:86:in `each'
        from /usr/lib/ruby/vendor_ruby/asciidoctor/cli/invoker.rb:86:in `invoke!'
        from /var/lib/gems/2.3.0/gems/asciidoctor-pdf-1.5.0.alpha.15/bin/asciidoctor-pdf:31:in `<top (required)>'
        from /usr/local/bin/asciidoctor-pdf:23:in `load'
        from /usr/local/bin/asciidoctor-pdf:23:in `<main>'

Custom theme file is:
$ cat cvs-theme.yml
font:
  catalog:
    CaslonPro:
      normal: adobe-caslon-pro-normal.ttf
      italic: adobe-caslon-pro-italic.ttf
      bold: adobe-caslon-pro-bold.ttf
      bold_italic: adobe-caslon-pro-bold_italic.ttf
    DroidSansFallback:
      normal: droid-sans-fallback.ttf
      italic: droid-sans-fallback.ttf
      bold: droid-sans-fallback.ttf
      bold_italic: droid-sans-fallback.ttf
  fallbacks:
    - DroidSansFallback
base:
  font_family: CaslonPro



If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Trying-to-customize-toolchain-PDF-is-going-wrong-tp5652.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: Trying to customize toolchain. PDF is going wrong

kwoot
Thanks so much for the heads-up regarding FontForge.
I know it well and it has saved me some time in the past.
Not so much this time. After some fidling and tweaking and generating fonts I got it working,  aaand decided to keep using the default font.
Maybe in a later stage I will retry this.
Again, thanks for the pointer.

Regards, Jeroen
Reply | Threaded
Open this post in threaded view
|

Re: Trying to customize toolchain. PDF is going wrong

mojavelinux
Administrator
Sure thing. Glad to hear you got it working. You got me thinking that perhaps we should provide a font tester script to validate whether it's usable with Asciidoctor PDF or whether it needs some massaging.

-Dan

On Tue, Jun 13, 2017 at 8:09 AM, kwoot [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Thanks so much for the heads-up regarding FontForge.
I know it well and it has saved me some time in the past.
Not so much this time. After some fidling and tweaking and generating fonts I got it working,  aaand decided to keep using the default font.
Maybe in a later stage I will retry this.
Again, thanks for the pointer.

Regards, Jeroen


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Trying-to-customize-toolchain-PDF-is-going-wrong-tp5652p5656.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux