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

Problem with NFD normalized Unicode #1154

Closed
tebeka opened this issue Mar 25, 2020 · 7 comments
Closed

Problem with NFD normalized Unicode #1154

tebeka opened this issue Mar 25, 2020 · 7 comments

Comments

@tebeka
Copy link

tebeka commented Mar 25, 2020

I'm writing a book on programming and want to show NFC & NFD normalized Unicode. The NFD version is not rendered well on PDF.

Here's a short example:

I once went to Kraków, it's a nice city. (NFC)

I once went to Kraków, it's a nice city. (NFD)

Here's the output (note the second line)
adoc-nfd

Original discussion here

@gettalong
Copy link
Member

Tl;dr: This is to be expected due to the current implementation of ttfunk.

NFD represents composed characters with multiple Unicode code points. This means that the application doing the rendering needs to understand that. Since PDF is, so to say, pre-rendered by the application creating the PDF, this work falls to Prawn and ttfunk.

Normally there is some information in the font file that allows an application to correctly place multiple glyphs representing a single character correctly. So to render such a character the application has to make use of this information which ttfunk currently doesn't. However, there is currently work going on to support more of the OpenType standard and then this might work.

@gettalong
Copy link
Member

@tebeka
Copy link
Author

tebeka commented Mar 26, 2020

Thanks!

@tebeka
Copy link
Author

tebeka commented Mar 26, 2020

When using Libertine font, the output is OK but the code doesn't render that great in non monospace font
city-2

I've tried to use LibertinusMono as the code font. It shows the umlaut but not on top of the o
city-1

Any idea for a monospaced font that will work?

@tebeka
Copy link
Author

tebeka commented Mar 26, 2020

FWIW: IBM Plex Mono (almost) does the job

city-3

@gettalong
Copy link
Member

@tebeka As mentioned in the link I posted, the behaviour depends entirely on the font. Each glyph defines a horizontal offset. For LibertinusMono that seems to be the "standard" offset whereas Plex Mono defines a negative offset so that the apostrophe overlaps the previous character.

In both cases no additional information from the font is used by Prawn/ttfunk. So this will probably never work with current versions of Prawn/ttfunk since the horizontal offset of the apostrophe has to vary based on the previous character. Such information is available in additional data structures inside the font but the library needs to understand that.

@pointlessone
Copy link
Member

Prawn implement a very basic text layout algorithm. It basically takes individual glyphs and draws them one by one. This is why decomposed graphemes are rendered the way they are.

I'm closing this in favour of #1295 as it's basically what would take to resolve this.

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

No branches or pull requests

3 participants