Enhance the handling of symbolic fonts combined with kerning and ligature option (#2143)#2144
Conversation
19f062b to
3bf2ab6
Compare
|
@vk-github18 @speckyspooky I'm a bit worried regarding multi-threading. BIRT is supposed to work in a multi-threading environment. But OpenPDF uses a global LayoutProcessor (a class, with static objects, or a singleton, I don't remember ATM), with some flags. Of course this works in simple test cases, but isn't this going to run into bugs due to race conditions in a MT environement under load? And these kind of bugs are very, very hard to reproduce and to analyze later. Probably this cannot be solved in BIRT at all, but requires a change in OpenPDF? |
|
Why would you change the flags? Can you provide a usecase and example?
|
|
@vk-github18 Regarding "Why would you change the flags?" Because that's what 2aef7c4 does. |
|
LayoutProcessor is ment to be switched on before Processing and not to be
switched on and off
|
|
Let me summarize the situation and please correct me if I'm wrong. Since we updated to OpenPDF 2.0.3, several issues were reported regarding different non-latin fonts and ligatures with the Calibri font (#2143, #2133, #2119, #2058, #2043, #2033). Thomas (with your help) tried his best to fix these issues, which all seem to be related to LayoutProcessor somehow (at least this is my impression). Fixing the latest issue #2143 seems to require switching LayoutProcessor features on and off on a per-font basis before calling According to Volker, this is not really supported. So what can we do now? Note: Even if we had to fiddle with the LayoutProcessor settings only at report level instead of text fragment level, this would not remedy the situation. As long as OpenPDF uses global variables, which have to be set this way or that way for different fonts to achieve correct results, it is not really thread-safe. |
|
If the LayoutProcessor is enabled then the kerning cannot be Set because the processor is already online. Other ways will not work. |
|
The LayoutProcessor is only activated, if you call
LayoutProcessor.enable*(). Otherwise it is not active and can not cause
problems.
Using LayoutProcessor can help for correct rendering of foreign scripts
or of Latin letters with accents, see e.g. DIN 91379.
You changed BIRT, included FOP in your classpath and activated
FOPGlyphProcessor by this.
LayoutProcessor is designed to be called at the start with some options
and not changed afterwards. It works only with OpenType-Fonts.
It should not be necessary to switch it off.
There was a bug with legacy fonts, that is fixed in the trunk of OpenPdf
and in https://github.com/openpdfsaucer/openpdfsaucer 2.0.9.
With this fix legacy processing is always used for legacy fonts.
So to be consistent, either
A: Don't use LayoutProcessor
B: Use LayoutProcessor for all glyph layout and use only OpenType fonts.
Again, LayoutProcessor is about glyph layout, it replaces the legacy
glyph layout using the HarfBuzz layout engine built into recent Java
versions resulting in correct representation of many scripts.
Kerning and ligatures are just minor options that can be switched on per
font. If LayoutProcessor is disabled, these settings have no effect.
See also #2107
|
|
The communication is to long. And I tested a lot of cases. The current way is working for all issues which was addressed. |
|
The sad truth about multi-threading is that race conditions occur in production only. @vk-github18, can you point us to the bug which is fixed in OpenPDF and what change was made in OpenPDFSaucer?
If I understand the issues I mentioned correctly, then for some reports we need to disable the LayoutProcessor, and for others we need to enable it. So we can choose neither A nor B. I still think a clean approach would require that OpenPDF supports different LayoutProcessor objects instead of just a class with static attributes. |
|
There is also e special case where the LayoutProcessor is to be enabled with usage flag "0". Because |
LayoutProcessor should be able to handle all cases. If you can provide an OpenPDF-only example I can have a look. |
You are calling enable(Font.LAYOUT_LEFT_TO_RIGHT), in most circumstances I would just call LayoutProcessor.enable(); And no -- calling |
|
@speckyspooky I think the code from commit 2aef7c4 and other places should be changed in such a way that is uses the same approach as the OpenPDF example, that is, enable or disable the LayoutProcessor only once at the beginning and then enable or disable kerning and/or ligatures using the LayoutProcessor methods @vk-github18 Though I find the API not quite clear: Is it disabled by default? I mean, I would expect a boolean argument as well... |
|
We should take our time to think about a good solution.
The default for Kerning and Ligatures is Off if you call
LayoutProcessor.enable(), and can be enabled with the set...() Methods.
Switching back and forth is not possible.
If you call Layoutprocessor.enableKernLiga()
Kerning and Ligatures are on and can not be switched off.
|
|
Do you need the options Kerning and Ligatures? Or do you just need support
for complex scripts?
In this case just use LayoutProcessor.enable()
Without options.
|
|
|
OK, so, if I understand everything correctly, the best practice would be:
For BIRT, this could be implemented as follows: Have three global properties in fontsConfig.xml:
Document that all other settings only work if this first property is true.
These settings only specify the defaults and can be overridden per font. For each font, optionally override the defaults from 2. and 3. : In the code, when a font is used for the first time (and only then): For ligatures, in the same way, use the values from the properties 5 and 3 and Never call I'm undecided about whether we need a special handling in the code for symbolic fonts. |
|
I don't mind if the default for the LayoutProcessor is enabled or disabled. |
|
Again LayoutProcessor is about glyph layout, substitution etc for complex
scripts, not about Ligatures and Kerning, these are just options that can
be set if LayoutProcessor is enabled.
Kerning and Ligatures can be enabled once per font.
Disable works as expected and switches off LayoutProcessor, then you have
the old Layout of OpenPdf.
LayoutProcessor works with Opentype fonts and ignores other fonts.
Possibly you had a problem with a legacy font because of a bug fixed only
in the trunk but not in the latest release
|
|
@vk-github18 |
|
I am not a maintainer, you should ask asturio or andreasrosdal.
There is also a fork openpdfsaucer maintained by andreasrosdal, where this
bug is fixed
|
|
FYI, the latest BIRT nightly build is using today's release of openpdf: https://repo1.maven.org/maven2/com/github/librepdf/openpdf/2.0.4/ |
|
@hvbtup OpenPdf has a font cache, if you want to load a font more than once with different options, you can switch the cache off for this font. In OpenType there are no symbolic fonts, these are legacy fonts, that should be ignored by LayoutProcessor. |

No description provided.