[
https://issues.apache.org/jira/browse/FOP-3343?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18124653#comment-18124653
]
Jason Harrop commented on FOP-3343:
-----------------------------------
An FO with a font from the test tree: attached FOP-3343-kerning-flag.fo and
fop-test-fonts.xconf, which declares DejaVuLGCSerif.ttf twice, once as
DejaVuLGCSerif-nokern with {{kerning="false"}}. Copy the config to the root of
a checkout and run from there:
{noformat}
fop -c fop-test-fonts.xconf -fo FOP-3343-kerning-flag.fo -pdf out.pdf
pdftotext -bbox out.pdf -
{noformat}
Two blocks of {{AVATAR}} at 12pt, one in each declaration, both with
{{language="az"}} (DejaVuLGCSerif has a latn/AZE language system, so GPOS
kerning applies on main independently of FOP-3341 and FOP-3342). The bare
advances are 51.70pt; the GPOS pairs AV -102, VA -139, AT -112, TA -112 make
the kerned word 48.98pt.
On main at 5be8c69b6 both blocks are 48.98pt: the font declared with
kerning="false" is kerned through GPOS exactly as the other.
With the pull request's change the kerning="true" block is 48.98pt and the
kerning="false" block 51.67pt.
> A font configured with kerning="false" is still kerned through GPOS; the flag
> disables only the legacy kern table
> -----------------------------------------------------------------------------------------------------------------
>
> Key: FOP-3343
> URL: https://issues.apache.org/jira/browse/FOP-3343
> Project: FOP
> Issue Type: Bug
> Components: font/opentype
> Affects Versions: 2.11
> Reporter: Jason Harrop
> Priority: Minor
> Attachments: FOP-3343-kerning-flag.fo, fop-test-fonts.xconf
>
>
> The font configuration's kerning attribute is documented as enabling or
> disabling kerning for the font (default true). It does so only for the legacy
> kern table: OFFontLoader skips copyKerning when it is false, and
> GlyphMapping.useKerningAdjustments then finds no kerning info. GPOS
> positioning is independent of it: MultiByteFont.performPositioning runs
> whenever the font has a GPOS table, and every script processor's positioning
> feature list carries kern. So an OpenType font with a GPOS kern feature,
> which is nearly every modern font, is kerned regardless of the flag.
> Two things underneath: the loader never records the flag on the font object,
> so CustomFont.isKerningEnabled() is true for every TrueType font whatever the
> configuration says (only the XML-metrics path sets it); and a producer that
> declares a font twice, once with kerning off and once on, to kern only where
> its source document kerns, gets kerning in both.
> Measured, 2.11 command line, Carlito, "AVATAR" at 14pt, language="en" (with
> the lookup fallback fixed so that GPOS applies to this font at all; see
> FOP-3341):
> {noformat}
> kerning="true" AVATAR 43.19 pt wide
> kerning="false" AVATAR 43.19 pt wide
> {noformat}
> h3. Fix
> # OFFontLoader.buildFont: returnFont.setKerningEnabled(useKerning).
> # MultiByteFont.performPositioning: when kerning is disabled, position with
> the kern feature removed from the script processor's positioning list; mark
> and mkmk still apply, since they are not kerning. Done as a feature delta
> ("-kern") through new overloads of GlyphPositioningTable.position and
> ScriptProcessor.position, the same mechanism as the gsub-features delta.
> After the fix, same sample: kerning="true" 43.19 pt, kerning="false" 46.62
> pt; ligatures (GSUB) unaffected either way.
> Tests: LanguageSystemTestCase (the flag reaches the font),
> MultiByteFontTestCase (the delta reaches positioning), GsubDeltaTestCase (the
> delta on a positioning list).
--
This message was sent by Atlassian Jira
(v8.20.10#820010)