prawnpdf / prawn

Fast, Nimble PDF Writer for Ruby
https://prawnpdf.org
Other
4.67k stars 688 forks source link

[FR] OpenType Support, Enable/Disable Ligatures and Multiple weight settings #1337

Closed jyxjjj closed 8 months ago

jyxjjj commented 8 months ago

From #1295, JetBriansMono#19 and JetBrainsMono#496 I am using JetBrains Mono. I don't know anything about fonts, I am actually a PHP developer. I cannot even understand what are these issues saying. When I generating PDF with prawn, I always need to use JetBrains Mono NL instead of JetBrians Mono Variable. Like this(I used ruby script as php blade template): image It needs a very lot of lines to add fonts in prawn. But when i am using CSS: image image So I want a feature to add ligature disabling and Multiple weight settings.

jyxjjj commented 8 months ago

I just read Discussions#1315 Really hard for me to understand. I think these are all one thing. I want to know, if some software/library don't support ligatures, it will not support "multiple weight in one file" too?

pointlessone commented 8 months ago

OK. So…

  1. Many lines is just the API choice we made. This is not going to change at least until the next major version. I'm afraid you'll have to live with this for a while.
  2. Prawn does't implement CSS. You should not assume that anything you know about CSS (or HTML for that matter) applies to Prawn.
  3. Prawn doesn't support variable fonts (multiple weights in one file). You'll have to use more traditional static fonts with Prawn. This is a different and independent font feature to ligatures.
  4. Prawn doesn't support any OpenType feature settings. Only default glyphs are rendered so you can assume both ligatures (liga) and contextual alternatives (calt) are disabled.

I'm not exactly sure what the issue though. You have fonts defined for different weights and styles you can use those with Prawn (read the manual for examples). And ligatures are effectively disabled with Prawn. It doesn't look to me like there's anything to do here so I'm closing this issue. Feel free to reopen with clarification what you're trying to achieve if you feel your issue is not resolved.

jyxjjj commented 8 months ago

Prawn doesn't support variable fonts (multiple weights in one file). You'll have to use more traditional static fonts with Prawn. This is a different and independent font feature to ligatures. Prawn doesn't support any OpenType feature settings. Only default glyphs are rendered so you can assume both ligatures (liga) and contextual alternatives (calt) are disabled.

Yeah that is what i want... I just asked more offtopic to understand what and why. I have no permission to re-open it...

jyxjjj commented 8 months ago

Actually prawn has already met my needs. But I continuing think it's necessary to support. Sorry I don't know a lot about it, only as a feature request, i don't have permission to re-open and i don't know if it's necessary to re-open. You can continue what you want.

pointlessone commented 8 months ago

I'm glad that Prawn met your needs.

As for variable fonts, I guess it'd be nice to support. However, at the moment I don't even know whether PDF as a format supports variable fonts. I might look into it at some point.

gettalong commented 8 months ago

FYI: The latest PDF specification 2.0 doesn't include support for embedding variable fonts. So a PDF writer would need to transform a variable font into a normal font. Currently only Type1, TrueType and CFF type fonts are supported (as well as Type 3 fonts but those are PDF specific).

jyxjjj commented 8 months ago

Oh, Okay, So i need give up all other fonts and only use JetBrains Mono NL at all places, not only in PDF. Until all things i need are supported.

gettalong commented 8 months ago

@jyxjjj No, you can use variable fonts wherever they are supported but you need to use standard TrueType/OpenType fonts when working with PDF.