Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Read ttf table data error at 2.11.0 #202

Closed
b6pzeusbc54tvhw5jgpyw8pwz2x6gs opened this issue Jan 21, 2020 · 22 comments · Fixed by #278
Closed

Error: Read ttf table data error at 2.11.0 #202

b6pzeusbc54tvhw5jgpyw8pwz2x6gs opened this issue Jan 21, 2020 · 22 comments · Fixed by #278
Labels

Comments

@b6pzeusbc54tvhw5jgpyw8pwz2x6gs
Copy link

$ npx decktape remark index.html slide.pdf --chrome-arg=--disable-web-security
Loading page file:///Users/myid/slide/index.html ...
800 600
{ skip... }
0
[ 'page-10' ]
Loading page finished with status: 0
Remark JS plugin activated
Printing slide #1       ( 1/33) ...{ skip... }
...skip...
Printing slide #7       ( 7/33) ...
Error: Read ttf table data error
Time: 0h:00m:10s

Above example, decktape latest version 2.11.0 is used.
But When I fix the decktape version to 2.10.0, it works well.

$ yarn add decktape@2.10.0
$ npx decktape remark index.html slide.pdf --chrome-arg=--disable-web-security
@astefanutti
Copy link
Owner

Thanks for the report. It's likely related to the fonteditor-core upgrade done in 2.11.0.

Would you be able to share a presentation so that we can reproduce?

@b6pzeusbc54tvhw5jgpyw8pwz2x6gs
Copy link
Author

Yes. It will take about two days. :)

@b6pzeusbc54tvhw5jgpyw8pwz2x6gs
Copy link
Author

I found the point where the problem occurs. If I remove setTimeout execution of user.js part, no error occurs.

index.html:

<!DOCTYPE html>
<html>
  <head>
    <title>title</title>
    <meta charset="utf-8">
  </head>
  <body>
    <textarea id="source">

layout: false

# title

- item

---

class: scroll

# Tite

- item1
- item2

    </textarea>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/remark/0.14.0/remark.js"></script>
    <script src="./user.js"></script>
  </body>
</html>

user.js

const option = { ratio: '16:9', navigation: { scroll: false }}
const slideshow = remark.create(option)
const handleScroll = (e) => { /* change some dom element style */ }
const handleScrollClass = (slide) => {
  const classArr = (slide.properties.class || '').split(',').map( str => str.trim() )
  if (classArr.includes('scroll')) {
    setTimeout( () => {
      const elPageNumber = document.querySelector('body > div.remark-slides-area > div.remark-slide-container.remark-visible > div.remark-slide-scaler .remark-slide-number')
      elPageNumber.innerText = elPageNumber.innerText.replace(/⬇️$/,'') + ' ⬇️'

      const el = document.querySelector('body > div.remark-slides-area > div.remark-slide-container.remark-visible > div.remark-slide-scaler')
      el.style.overflowY = 'scroll'
      el.removeEventListener('scroll', handleScroll)
      el.addEventListener('scroll', handleScroll)
    })
  }
}

const startIdx = slideshow.getCurrentSlideIndex()
const slide = slideshow.getSlides()[startIdx]
handleScrollClass(slide)
slideshow.on('showSlide', handleScrollClass)

package.json:

{
  "devDependencies": {
    "decktape": "2.11.0"
  }
}

@i-walker
Copy link

2.10.0 works for me, but 2.11.0 throws the same error as in the title. I wish I could help more, but I am not very familiar with JS to debug the problem.

@jmuheim
Copy link

jmuheim commented May 13, 2020

This still seems to be a problem. Any news? I downgraded to 2.10 to work around the problem for now.

@astefanutti
Copy link
Owner

We are currently working on #201, that may move us away from fonteditor-core. Hopefully the new library used to parse fonts will address that issue.

@peterj
Copy link

peterj commented Aug 6, 2020

In my case, the same error was caused because I had emojis on the slide. I removed the emojis and I was able to generate a PDF.

@astefanutti
Copy link
Owner

@peterj thanks for the feedback. That seems indeed related to emoji support. Could you confirm you still face the issue with version 3.0.0?

@peterj
Copy link

peterj commented Aug 6, 2020

@astefanutti yes, still repros with 3.0.0.

Here's the full stack trace:

Loading page file:///Users/peterj/projects/slides/emoji.html ...
Loading page finished with status: 0
No supported DeckTape plugin detected, falling back to generic plugin
Generic plugin activated
Printing slide #1       (  1/ ?) ...Error: Read ttf table data error
    at Object.raise (/usr/local/lib/node_modules/decktape/node_modules/fonteditor-core/lib/ttf/error.js:52:17)
    at TTFReader.readBuffer (/usr/local/lib/node_modules/decktape/node_modules/fonteditor-core/lib/ttf/ttfreader.js:88:27)
    at TTFReader.read (/usr/local/lib/node_modules/decktape/node_modules/fonteditor-core/lib/ttf/ttfreader.js:232:23)
    at Font.read (/usr/local/lib/node_modules/decktape/node_modules/fonteditor-core/lib/ttf/font.js:135:56)
    at new Font (/usr/local/lib/node_modules/decktape/node_modules/fonteditor-core/lib/ttf/font.js:86:14)
    at Function.Font.create (/usr/local/lib/node_modules/decktape/node_modules/fonteditor-core/lib/ttf/font.js:390:10)
    at parseFont (/usr/local/lib/node_modules/decktape/decktape.js:413:27)
    at Array.forEach (<anonymous>)
    at parseResources (/usr/local/lib/node_modules/decktape/decktape.js:377:45)
    at printSlide (/usr/local/lib/node_modules/decktape/decktape.js:368:3)

@astefanutti
Copy link
Owner

@peterj ok, thanks. I’ll work on it ASAP.

@astefanutti astefanutti added the bug label Aug 6, 2020
@guillaume-fr
Copy link

Working around this issue might not be easy as 2.10 comes with dead dependencies.

Might be useful if someone stuck on this:
#201 (comment)

@astefanutti
Copy link
Owner

One alternative is to use the 2.10.0 container image. I still need to find some time to analyse the issue. Otherwise, I'll consider downgrading the fonteditor-core dependency.

@b-v
Copy link

b-v commented Oct 11, 2021

I had a similar error message with decktape 3.2.0. By just starting the Chromium browser on its own an authorization request was made to use the Chromium Safe Storage in the Mac Keychain. Deleting this Chromium Safe Storage entry in the keychain (used to store passwords) resolved it for me.

@D063520
Copy link

D063520 commented Apr 11, 2022

This still happens for me. Here the presentation:

https://the-qa-company.github.io/2022-04-12-SEMIC-Workshop/

@kcarnold
Copy link

kcarnold commented May 6, 2022

The problem occurs reliably with Helvetica Neue, perhaps the specific ttf distributed with macOS.

This in a presentation suffices to trigger the problem:

<div style="font-family: 'Helvetica Neue';">crash</div>

(I discovered this by trying to include https://www.tmwr.org/premade/modeling-process.svg in a presentation.)

@WadeWaldron
Copy link

Similar to @kcarnold. When including Helvetica Neue in an SVG image, it crashes every time. Switching to an alternative font (Montserrat in my case) the problem goes away.

@NMarkgraf
Copy link

As far as I can see, and that is not much, the problem is the fonteditor-core which might not handle the "Helvetica Neue" because it is a .ttc and not a .ttf.
The problem is, that .ttc are a collection of .ttf files and not a single .fft file. And as far I can see, the current font editor-core might not read that.

@NMarkgraf
Copy link

Well, it is definitely a ttc problem. The question is, how to fix it? Anybody willing and able to do something in this direction? A (maybe) helpful tester is here and stands up! ;-)

@astefanutti
Copy link
Owner

@NMarkgraf thanks for the analysis.

Ideally fonteditor-core would provide support for parsing font collection files. Alternatively, it may be possible to do the extraction to single font just before calling fonteditor-core. Another alternative might be to use another font library, like https://github.com/foliojs/fontkit, that supports .ttc files already.

@NMarkgraf
Copy link

Well, I asked for support for changing fonteditor-core on GitHub, but ....

The real problem is, that on Apple macOS the font "Helvetica Neue" (for example) is a system font, which can not be removed or disabled, so you just can not unpack the ttc-files and uses them separately. :-(

So maybe fontkit is the way to fix this all, but I am not a JS programmer and don't know how the implement this in decktape. :-(

@astefanutti
Copy link
Owner

Decktape reads the fonts from the PDF stream returned by Puppeteer, directly in memory.

I've just given it a deeper look, and it turns out the font written in the PDF, in the Helvetica Neue case, does not have a cmap table, which prevent fonteditor-core (or any other libraries I've tested, e.g., fontkit, opentype.js) from being able to parse it.

My current understanding is that the root cause lies in Puppeteer > Chromium > Skia. In the meantime, I've created #278 as a work-around, that simply skips font compression for such ill-formed fonts.

@NMarkgraf
Copy link

Thank you very much for you support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.