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

Can't run asciidoctor-pdf 1.5.0.beta.3 in asciidoctorj-pdf #1250

Closed
robertpanzer opened this issue Sep 3, 2019 · 12 comments
Closed

Can't run asciidoctor-pdf 1.5.0.beta.3 in asciidoctorj-pdf #1250

robertpanzer opened this issue Sep 3, 2019 · 12 comments
Assignees
Labels
Milestone

Comments

@robertpanzer
Copy link
Member

I am currently trying to bring asciidoctor-pdf 1.5.0.beta.3 to asciidoctorj-pdf.
However the tests currently fail here in Converter#register_fonts:

raise ::Errno::ENOENT, %(#{path} not found in #{fonts_dir}) unless found

This seems to be because fonts_dir is a URI to an internal resource that is retrieved via the Ruby classloader here:

dirs = (fonts_dir.split ::File::PATH_SEPARATOR, -1).map do |dir|
dir.empty? || dir == 'GEM_FONTS_DIR' ? ThemeLoader::FontsDir : dir
end

Using my puts debugging superpowers I figured out that dirs resolves to this:

["uri", "classloader", "/gems/asciidoctor-pdf-1.5.0.beta.3/data/fonts"]

(As it splits on the system path separator – which is : on my machine – I can imagine that this even runs on Windows :-D)

@mojavelinux
Copy link
Member

As it splits on the system path separator – which is : on my machine – I can imagine that this even runs on Windows :-D

Dang it. Windows is suppose to be using ; as the path separator (not the file separator). But on JRuby, this doesn't seem to be the case. And then there are JAR paths, which further complicate the matter.

@mojavelinux
Copy link
Member

I verified that on CRuby on Windows, File::PATH_SEPARATOR is ;. So JRuby is incorrect here.

However, there is still the large issue of the JAR filename in JRuby, which would certainly break JRuby on non-Windows.

@robertpanzer
Copy link
Member Author

My last comment was probably misleading, sorry about this ;-)

It doesn't run on my Mac, and I suppose it will also fail on Linux, because without any further customization fonts-dir is uri:classloader:/gems/asciidoctor-pdf-1.5.0.beta.3/data/fonts.
This is split to the 3 elements of dirs usr, class loader and /gems/asciidoctor-pdf-1.5.0.beta.3/data/fonts.
And neither of these 3 elements is a path that exists in the filesystem,.

@mojavelinux
Copy link
Member

Yes, that's what I suspected. The JAR paths are interfering with the assumption that we can separate entries using the path separator. Back to the drawing board.

@mojavelinux
Copy link
Member

We'll just change it to always be semicolon. That seems safe.

@mojavelinux
Copy link
Member

Another option is to detect uri:classloader: and skip it. I'm going to try it both ways and see which one feels better.

@mojavelinux
Copy link
Member

What's interesting is that now we see how to load fonts out of a JAR.

-a pdf-fontsdir=uri:classloader:/gems/asciidoctor-epub3-1.5.0.alpha.9/data/fonts

That makes me think that just standardizing on the ; as a separator is the way to go.

@robertpanzer
Copy link
Member Author

robertpanzer commented Sep 3, 2019

👍
I liked the approach of treating uri:classloader: specially, but then I was thinking that it might also be possible to load fonts from URLs. (If I understood correctly what the open-uri gem does).
So a ; is probably better.

@mojavelinux
Copy link
Member

Yeah. And it seems like Java uses ; in a lot of places for this very purpose...so it seems like a reasonable and safe thing to do.

@mojavelinux mojavelinux self-assigned this Sep 3, 2019
@mojavelinux mojavelinux added the bug label Sep 3, 2019
@mojavelinux mojavelinux added this to the v1.5.0.beta.4 milestone Sep 3, 2019
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue Sep 3, 2019
…ple font dirs to be compatible with JAR paths
@mojavelinux
Copy link
Member

Thanks for the heads up on this and good detective work. 🕵️‍♂️

@robertpanzer
Copy link
Member Author

Thanks! ☺️

mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue Sep 3, 2019
…ple font dirs to be compatible with JAR paths
@mojavelinux
Copy link
Member

Keep in mind that when specifying multiple font dirs on the CLI, it's necessary to either escape the semi-colon or enclose the value in double quotes. Otherwise, the shell will interpret it as a command separator.

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

No branches or pull requests

2 participants