[
https://issues.apache.org/jira/browse/PDFBOX-3759?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15973098#comment-15973098
]
Tilman Hausherr commented on PDFBOX-3759:
-----------------------------------------
There's this code in writeToStream():
{code}
// copy all other tables
for (Map.Entry<String, TTFTable> entry : ttf.getTableMap().entrySet())
{
String tag = entry.getKey();
TTFTable table = entry.getValue();
if (!tables.containsKey(tag) && (keepTables == null ||
keepTables.contains(tag)))
{
tables.put(tag, ttf.getTableBytes(table));
}
}
{code}
so we just copy source to destination. Because of the GID changes, this looks
like a bad idea. My thought is to remove the copying of all the tables that
you've mentioned (and probably others as well). Implementation of a general
subsetter might be tricky and we can't even test it properly because it
wouldn't be used by PDFBox.
> TTFSubsetter scrambles OpenType ligature and kerning tables (and probably
> others as well)
> -----------------------------------------------------------------------------------------
>
> Key: PDFBOX-3759
> URL: https://issues.apache.org/jira/browse/PDFBOX-3759
> Project: PDFBox
> Issue Type: Bug
> Components: FontBox
> Affects Versions: 2.0.5
> Reporter: Tobias Fischer
> Priority: Critical
> Attachments:
> fontbox-2.0.5-ttfsubsetter_scrambled-OpenType-kerning.png,
> fontbox-2.0.5-ttfsubsetter_scrambled-OpenType-ligatures.png,
> Subset-DejaVuSans_scrambled-OpenType-tables.ttf
>
>
> When using the TTFSubsetter as standalone software and subsetting an
> OpenType/TrueType font, the {{liga}} OpenType ligature table gets scrambled
> "randomly".
> E.g. when viewing the source font "DejaVuSans.ttf" in FontLab Studio, the
> OpenType {{liga}} table is shown as follows:
> {code}
> feature liga {
> script arab;
> lookup liga33 {
> lookupflag IgnoreMarks RightToLeft;
> sub uniFEDF uniFE88 by uniFEF9;
> sub uniFEDF uniFE84 by uniFEF7;
> sub uniFEDF uniFE82 by uniFEF5;
> sub uniFEE0 uniFE88 by uniFEFA;
> sub uniFEE0 uniFE84 by uniFEF8;
> sub uniFEE0 uniFE82 by uniFEF6;
> } liga33;
> lookup liga35 {
> lookupflag RightToLeft;
> sub space uni0652 by uniFE7E;
> sub space uni0651 by uniFE7C;
> sub space uni0650 by uniFE7A;
> sub space uni064F by uniFE78;
> sub space uni064E by uniFE76;
> sub space uni064D by uniFE74;
> sub space uni064C by uniFE72;
> sub space uni064B by uniFE70;
> sub uni0627 uni0655 by uni0625;
> sub uni0627 uni0654 by uni0623;
> sub uni0627 uni0653 by uni0622;
> sub uni0640 uni0652 by uniFE7F;
> sub uni0640 uni0651 by uniFE7D;
> sub uni0640 uni0650 by uniFE7B;
> sub uni0640 uni064F by uniFE79;
> sub uni0640 uni064E by uniFE77;
> sub uni0640 uni064B by uniFE71;
> sub uni0648 uni0654 by uni0624;
> sub uni064A uni0654 by uni0626;
> } liga35;
> language SND ;
> language URD ;
> language KUR ;
> script latn;
> sub f f l by uniFB04;
> sub f f i by uniFB03;
> sub f l by fl;
> sub f i by fi;
> sub f f by uniFB00;
> language MOL ;
> language ROM ;
> language ISM ;
> language KSM ;
> language LSM ;
> language NSM ;
> language SSM ;
> language SKS ;
> } liga;
> {code}
> This ligature table shows for example, in the {{latn}} section, the {{ffl}}
> substitution with the ffl ligature {{\uFB04}}.
> However, when viewing a subsetted version of the font (like the one
> attached), the {{liga}} table is scrambled:
> {code}
> feature liga {
> script arab;
> lookup liga33 {
> lookupflag IgnoreMarks RightToLeft;
> sub _5337 _5250 by _5363;
> sub _5337 _5246 by _5361;
> sub _5337 _5244 by _5359;
> sub _5338 _5250 by _5364;
> sub _5338 _5246 by _5362;
> sub _5338 _5244 by _5360;
> } liga33;
> lookup liga35 {
> lookupflag RightToLeft;
> sub numbersign _1403 by _5240;
> sub numbersign _1402 by _5238;
> sub numbersign _1401 by _5236;
> sub numbersign _1400 by _5234;
> sub numbersign _1399 by _5232;
> sub numbersign _1398 by _5231;
> sub numbersign _1397 by _5229;
> sub numbersign _1396 by _5227;
> sub _1365 _1406 by _1363;
> sub _1365 _1405 by _1361;
> sub _1365 _1404 by _1360;
> sub _1385 _1403 by _5241;
> sub _1385 _1402 by _5239;
> sub _1385 _1401 by _5237;
> sub _1385 _1400 by _5235;
> sub _1385 _1399 by _5233;
> sub _1385 _1396 by _5228;
> sub _1393 _1405 by _1362;
> sub _1395 _1405 by _1364;
> } liga35;
> language SND ;
> language URD ;
> language KUR ;
> script latn;
> sub o o u by _5045;
> sub o o r by _5044;
> sub o u by _5043;
> sub o r by _5042;
> sub o o by _5041;
> language MOL ;
> language ROM ;
> language ISM ;
> language KSM ;
> language LSM ;
> language NSM ;
> language SSM ;
> language SKS ;
> } liga;
> {code}
> The {{liga}} table of the subsetted font now want's to replace "oou" instead
> of "ffl".
> The result, for example in InDesign, is devastating:
> !fontbox-2.0.5-ttfsubsetter_scrambled-OpenType-ligatures.png!
> The subsetted font indeed tries to replace "oou" with a non-existing glyph
> and scrambles the whole text in the rendering. The font subset is unusable.
> I know that it's hard to maintain OpenType features in a font subset, but I
> would at least expect that the OpenType tables are kept "as-is"...
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]