killercup / trpl-ebook

UNMAINTAINED
http://killercup.github.io/trpl-ebook/
478 stars 56 forks source link

Unicode rendering omission #16

Open mcast opened 9 years ago

mcast commented 9 years ago

Hi again,

Possibly related to #6, I'm looking at

let x = 'x';
let two_hearts = '💕';

in the pdf derived from trpl-2015-05-24.md (monster page!) in 9e6b8c05 and the \u1f495 renders as zero width nothing. (Mind you, my font in Emacs only renders it as wide nothing).

In the official copy it is at http://doc.rust-lang.org/book/primitive-types.html#char

This doesn't trouble me too much as it is, though a missing-glyph box might at least avoid some confusion about the meaning of the Rust demonstration.

Thanks,

killercup commented 9 years ago

Orr, Steve, why did you use freaking emoticons in your book?

@mcast, there are some chapters that use emoticons inside the text, but they offer no real value to the content except for… well, showing some emotion and looking good in color? Since I couldn't find a LaTeX font to add support for those characters, I simply remove them from the text. In that context, a 'missing-glyph' glyph would just annoy people.

Inside code, I don't know what to do with them. If that is the only case, and the page already talks about chars, I might just be inclined to (a) add a sentence that explains that the character might not be rendered correctly in every context, r (b) replace this emoticon with some LaTeX glyph that also shows hearts. Or (c) replace all emoticons in code (I have the regex!) with the same character, e.g. \boxtimes (which renders as box with diagonal lines, see here on page 9).

What do you think?

mcast commented 9 years ago

On Tue, Jun 09, 2015 at 12:43:08AM -0700, Pascal Hertleif wrote:

Orr, Steve, why did you use freaking emoticons in your book?

In this case it's demonstrating the width of char, so it needed to a "clearly non-ASCII" glyph.

@mcast, there are some chapters that use emoticons inside the text, but they offer no real value to the content except for… well, showing some emotion and looking good in color?

I agree the value is low, once the capability of the language is shown and it's obvious there is just a doc rendering problem.

Since I couldn't find a LaTeX font to add support for those characters, I simply remove them from the text. In that context, a 'missing-glyph' glyph would just annoy people.

Ah!

Well in this case, the missing-glyph glyph would have suited me better than let foo = ''; which is invalid. http://is.gd/OpV7HW => playground.

Does pandoc (?) throw an error if it tries to use a glyph that's not in the font it was given?

Inside code, I don't know what to do with them. If that is the only case, [...]

Haven't looked for others, but... it'll change anyway.

(a) add a sentence [...]

Text patches seem like a brittle solution which will make more work for you, and so discourage updates.

Or (c) replace all emoticons in code (I have the regex!) with the same character, e.g. \boxtimes (which renders as box with diagonal lines, see here on page 9).

What do you think?

I think c) is good enough.

d) Detect missing glyphs during render, find a font that supplies them, build a table of Unicode to fontname and insert font changes as needed. Ugh, bad idea.

e) Use the same font as on the web page.

"Source Code Pro",Menlo,Monaco,Consolas,"DejaVu Sans Mono",monospace

I doubt a generic monospace font will have it, but the CSS is loading "Source Code Pro" and others.

https://github.com/rust-lang/rust/blob/9f8226a9/src/doc/rust.css#L43-L48 -> https://github.com/rust-lang/rust/tree/master/src/librustdoc/html/static

Perhaps that would banish all similar problems. Might bring the need to attach a font licence addendum where it's embedded? I can't tell.

Matthew

The Wellcome Trust Sanger Institute is operated by Genome Research Limited, a charity registered in England with number 1021457 and a company registered in England with number 2742969, whose registered office is 215 Euston Road, London, NW1 2BE.

killercup commented 9 years ago

In this case it's demonstrating the width of char, so it needed to a "clearly non-ASCII" glyph.

What's wrong with good old →? :)

e) Use the same font as on the web page.

Won't work, the font that actually contains the colored glyphs is 'Apple Color Emoji' (on my machine). There are some other fonts, but LaTeX seems to have problems with those.

But I'm stupid. I've been searching for 'latex emoticon', when I of course meant to search for 'emoji' support (emojis are the cool, new unicode variant in color). And there seems to be a package that supports emoji by embedding images into the PDF file, https://github.com/alecjacobson/coloremoji.sty. Let's hope it works with XeLaTex (which I need because of other stuff…).