-
Notifications
You must be signed in to change notification settings - Fork 399
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
Enhance the PDF glyph handling to handle advanced kerning and ligatures (#2058) #2059
Enhance the PDF glyph handling to handle advanced kerning and ligatures (#2058) #2059
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may feel like nit-picking, but enabling kerning and ligatures involves a little overhead and of course it changes the width of text, thus possibly resulting in different line-breaking.
There is probably a reason why this is not enabled by default in OpenPDF.
So I think it should not be enabled by default in BIRT, instead it should be an option for the PDF emitter.
Ok, make sense, so I will take a look into the emitter configuration. |
Furthermore, enabling kerning and ligatures must be considered in the font width calculation. I don't know if OpenPDF takes this into account. Besides, it is somewhat strange that OpenPDF has a LayoutProcessor class with static methods. Decades ago I added kerning and ligature support for the ReportLab Python PDF creation library in my "wordaxe" repo https://deco-cow.sourceforge.net/. However, I only ever tested this for latin languages. |
I wouldn't see it to negative with the handling of openPDF. The according article/reference-document of openPDF explain the topic and reference to different examples. Please be aware the font handling of BIRT isn't easy too and I invested lot of time to figure out why the config-switch wasn't working. |
@hvbtup So if we would need a kind of configuration switch we cannot use a user-property/PDF-renderer-config @wimjongman & @merks
|
If we change things here, we should at least:
I don't say that all of this must work, but we should at least know what works and what not. |
There are mixed some details, the copy of text to editor is only a hint of text display but isn't a test case. |
I agree with Thomas insofar as it it impossible to change the setting per font. |
Guys, I am just baffled with your knowledge about this topic. 🙏 Reading you comments, I think the logical thing to do is to make it a global switch which is off by default. Great work!! ⭐⭐⭐⭐⭐ |
So, I figured out an alternative instead of a global switch with a system property. This switch can be configured at every font-xml because it is for all setups/configurations the same internal logic, Let me know I can add in addition a system property but I think the config solution should be good enough. |
How do people set this property? Does it have easy access? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove your personal directories from the config file.
I think the wording should be improved.
Apart from that:
The overall code looks good to me and I like the idea of configuring this in fontsConfig.xml.
engine/org.eclipse.birt.report.engine.fonts/fontsConfig_pdf.xml
Outdated
Show resolved
Hide resolved
The fontsConfig.xml file is supposed to be editable, e.g. to add custom TTF font paths, so I would say: Yes, easy enough. |
0f2bc1f
to
401bfcd
Compare
@@ -54,10 +63,14 @@ public class FontMappingManager { | |||
this.fontAliases.putAll(parent.getFontAliases()); | |||
this.fontEncodings.putAll(parent.getFontEncodings()); | |||
this.compositeFonts.putAll(parent.getCompositeFonts()); | |||
if (!this.fontKerningAdvancedUsage) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what you mean is: if it is not explicitly defined, get it from parent.
But then the variable should probably be a Boolean
object and the test should be fontKerningAdvancedUsae == null
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The property is not the Object Boolaen
it is the type boolean
which is also located at parent side therefore this compare (and without null)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the point is that you can't distinguish the three states:
- Explicitly set to false.
- Explicitly set to true.
- Not set at all.
with a boolean value that can only have two states...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, may be I'm really slowly today, my property definition is done with an initial value and this is "false".
and a boolean (type) must have a value so which moment should switch false to "null". (I try only to understand this point.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 66:
My first thought that your intention was "the property should inherit from parent only if not set explicitly".
Then the case "this should not use advanced kerning, even though the parent does" cannot work.
But now I wonder if the condition is necessary at all?
In lines 62 .. 65 the other properties are copied from parent without a condition. So why do you use a condition in line 66?
} | ||
this.fontEncodings.putAll(config.fontEncodings); | ||
this.searchSequences.putAll(config.searchSequences); | ||
this.fontAliases.putAll(config.fontAliases); | ||
if (!this.fontKerningAdvancedUsage) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above
...irt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/font/FontMappingManager.java
Outdated
Show resolved
Hide resolved
...irt.report.engine/src/org/eclipse/birt/report/engine/layout/pdf/font/FontMappingManager.java
Outdated
Show resolved
Hide resolved
...e.birt.report.engine.emitter.pdf/src/org/eclipse/birt/report/engine/emitter/pdf/PDFPage.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In PdfPage.java, if I understand it correctly, the LayoutProcessor.enableKernLiga() is called without checking the option in fontsConfig.xml.
This makes the option pointless!?
And since the LayoutProcessor is basically a singleton, I think it makes sense to enable it (or not, depending on the option) at best exactly once, and not inside a frequently called method like PdfPage.drawText
.
401bfcd
to
57fb373
Compare
ligatures (default: unused/off)
57fb373
to
05bdc9d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't understand the two if statements in FontMappingManager.java, but if it works, so what...
No description provided.