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

Myanmar font is not being rendered correctly #1125

Closed
pmverma opened this issue Sep 2, 2019 · 17 comments
Closed

Myanmar font is not being rendered correctly #1125

pmverma opened this issue Sep 2, 2019 · 17 comments

Comments

@pmverma
Copy link

pmverma commented Sep 2, 2019

Hi,

I have following text.

require "prawn"

Prawn::Document.generate("hello.pdf") do
  font("PYIDAUNGSU-2.5_REGULAR.TTF") do
    text "ပြည်ထောင်စု သမ္မတ မြန်မာနိုင်ငံတော်‌ - Republic of the Union of Myanmar"
  end
end

Following is the rendered pdf which is not correct.

image

I have attached the font I used.
PYIDAUNGSU-2.5_REGULAR.TTF.zip

Let me know what can I help you more.

Regards,
Mohan

@pmverma pmverma changed the title Myanmar font not being rendered correctly Myanmar font is not being rendered correctly Sep 2, 2019
@pmverma
Copy link
Author

pmverma commented Sep 2, 2019

Note: The result is same with Noto Serif Myanmar fonts.
https://www.google.com/get/noto/#serif-mymr

@pointlessone
Copy link
Member

Could you please confirm, that incorrect rendering can be caused by the lack of ligatures?

@pmverma
Copy link
Author

pmverma commented Sep 3, 2019

Thanks @pointlessone for your response.
Sorry for stupid question, but how can I confirm that ligatures is lacking?

Generally in the text editors or word processors, the combination happens automatically.
For eg, from the above example, first letter.

To get ပြည်, there sequence goes like ပ ြ ည ် and the word processors automatically adjusts them.

  1. ပ => ပ
  2. ပ + ြ => ပြ
  3. ပြ + ည => ပြည
  4. ပြည + ် => ပြည်

Regards,
Mohan

@pmverma
Copy link
Author

pmverma commented Apr 10, 2020

Hi @pointlessone , I raised an issue to one of the font developer, however, they think that this might be a problem with library/platform I am using, the library/platform might not be reordering or resolving viramas, etc.

Please see more at silnrsi/font-padauk#30 (comment)

I am having this same problem with all Unicode fonts we have for our language. Some fonts have more rendering issue while some have with less.
I really need this to be fixed.

I just do not know where to start, and how to further this thing.
Can you please help with this?

@gettalong
Copy link
Member

@pmverma In the link you referenced is the mention of font shaping. Prawn doesn't do font shaping since that is quite a complex topic. So if the combination is done through font shaping and not through simple ligatures, you won't get correct results in Prawn, for no font.

However, there is ongoing work to bring OTF support to the library "ttfunk" Prawn is using for fonts. Once this has landed it might be easier to implement font shaping in Prawn. But for now this won't work.

@pointlessone
Copy link
Member

Even if it's done with ligatures it won't work either. TTFunk strips all ligature glyphs during subsetting.

@gettalong
Copy link
Member

@pointlessone Really? But how does it do ligatures like 'll' then?

@pointlessone
Copy link
Member

IIRC, TTFunk doesn't touch kerning tables, if you're referring to those. I was speaking of typographic ligatures:
Typographic ligatures

These take a few characters and display them with a single glyph. TTFunk doesn't properly handle that (yet?). It only leaves glyphs for individual characters during subsetting. This results in a less fancy typography in western/Cyrillic scripts but is an issue for scripts that heavily rely on ligatures, like Arabic, or Myanmar.

@gettalong
Copy link
Member

Ah, you are right, I thought about kerning which Prawn supports. The standard 14 PDF fonts partially support ligatures, e.g. Times-Roman supports f i -> fi, and I thought that this was implemented. And similarly for TrueType fonts.

@pointlessone
Copy link
Member

Standard fonts are just the ones Adobe promised to always have with their software installed. Since they're pre-installed and not processed by TTFunk they might have all sorts of ligatures and not suffer from subsetting issues.

@pmverma
Copy link
Author

pmverma commented Apr 13, 2020

Thanks both @gettalong & @gettalong for your inputs.

Basically I am generating pdf using https://github.com/asciidoctor/asciidoctor-pdf which depends on prawnpdf.

Now I understand I am out of luck here.
Is there any plan to add a support for fonts like Myanmar, in prawn?
Since you are experts here, what will be your suggestions on this?

Regards,
Mohan

@pointlessone
Copy link
Member

There's a consensus that this feature is desired but no concrete plans for the implementation that I'm aware of. I'll be happy to accept a contribution.

@pmverma
Copy link
Author

pmverma commented Apr 13, 2020

Thanks @pointlessone .
I think this will be very broad thing to understand and implement.
My current level in this domain is "zero".

However, can you please let me know some resources to understand the issue?

  • basic & essentials things to understand
  • after that where & how to start

Regards,
Mohan

@odrotbohm
Copy link

Ended up here using Asciidoctor, too, and realizing the lack of ligatures available in the TTF Font (Vollkorn via Google Fonts) not being used. Just as @pmverma, I'd be happy to help but without a few initial pointers it's gonna be hard for me to actually get started.

@pmverma
Copy link
Author

pmverma commented Jun 2, 2021

@odrotbohm, Can you please let me know what was your workaround? Or did you stop using this library?

For me, Here is what I have been doing,

  • Build only the html5 backend then
  • Open it in the browser and save as PDF because they render correctly (Chrome/Edge is better than other browsers).

However, with this approach, I lose all the asciidoctor-pdf features such as generating TOC with link, page number, etc.
But I believe, I can automate some of those, header & footers using pdfbox (not tried yet)

Regards,
Mohan

@odrotbohm
Copy link

There was no workaround for me. Combinations like "fi" are just rendered as two separate letters, not the corresponding ligature.

@PhilippePerret
Copy link

@odrotbohm, Can you please let me know what was your workaround?

My workaround is to build a new fonte without ligatures… For instance, in this new fonte, let's say "Ligaturae.ttf", I build the "F" glyph with the well-known ligatured "fi". Then, in Prawn:

pdf.update do
  text("<font name="Ligaturae">F</font>", 
          **{inline_format: true})
  # write ligatured "fi" in the pdf document
end

Of course, with a lot of ligatures, it's a lot of work…

FYI, l use the very nice Glyph Mini app to build my fonts.

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

5 participants