Add a flag for subsetting inline fonts down to characters used

Registered by Johan Sundström

An SVG with one or more inline font definitions can be shrunk a lot by subsetting which glyph definitions (and kerning pair defs!) it ships, down to the ones used in the file. The hard part here is to track down which fonts are being used, rather than making a naïve assumption of "one font is used everywhere in the file".

With --subset-fonts, a file embedding all of the font Delius (http://www.dafont.com/delius.font, converted to SVG with http://font2web.com/), and using only the letters "oe", would strip off all <hkern> tags, as it has no special kerning info (see also https://blueprints.launchpad.net/scour/+spec/optimize-kerning) and most glyphs, ending up:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 121 106">
  <defs><font id="delius" horiz-adv-x="448">
    <font-face font-family="f2w" alphabetic="0" ascent="986" descent="-270"
               panose-1="2 0 6 3 0 0 0 0 0 0" units-per-em="1000"/>
    <glyph glyph-name="e" unicode="e" horiz-adv-x="539" d="M378.5 292c27 15.333 40.501 36 40.501 62s-8.83301 48.5 -26.5 67.5s-42.834 28.5 -75.501 28.5c-44 0 -81 -16.5 -111 -49.5s-49.333 -71.5 -58 -115.5c36.667 -10.667 77.5 -16 122.5 -16s81 7.66699 108 23zM439.501 470c33.667 -30 50.5 -68.999 50.5 -116.999 s-20.833 -84.5 -62.5 -109.5s-92.834 -37.5 -153.501 -37.5c-34.667 0 -77 5 -127 15c4 -46.667 21.5 -86.834 52.5 -120.501s65.5 -50.5 103.5 -50.5c22.667 0 43.667 3.16699 63 9.5s34 13.166 44 20.499c26.667 20.667 44.167 31 52.5 31s15 -2.5 20 -7.5 s7.5 -11.167 7.5 -18.5c0 -18.667 -19.167 -40 -57.5 -64s-79.833 -36 -124.5 -36c-69.333 0 -124.333 24.333 -165 73s-62.667 107.334 -66 176.001c-35.333 10.667 -53 28 -53 52c0 10 2.83301 17.833 8.5 23.5s12.5 8.5 20.5 8.5s18 -3 30 -9 c14.667 60 42.5 109.333 83.5 148s88.333 58 142 58s97.334 -15 131.001 -45z"/>
    <glyph glyph-name="o" unicode="o" horiz-adv-x="562" d="M445 251c0 55.333 -15.5 102.333 -46.5 141s-69.5 58 -115.5 58s-85.167 -19.667 -117.5 -59s-48.5 -86.666 -48.5 -141.999s15.5 -102.333 46.5 -141s69.5 -58 115.5 -58s85.167 19.667 117.5 59s48.5 86.666 48.5 141.999zM450 438.5 c44 -51 66.001 -113.5 66.001 -187.5s-22.333 -136.833 -67 -188.5s-101 -77.5 -169 -77.5s-124 25.5 -168 76.5s-66 113.5 -66 187.5s22.167 136.833 66.5 188.5s100.666 77.5 168.999 77.5s124.5 -25.5 168.5 -76.5z"/>
  </font></defs>
  <g transform="translate(0,96)" font-family="f2w" font-size="96" fill="#000">
    <text>oe</text>
  </g>
</svg>

Blueprint information

Status:
Not started
Approver:
None
Priority:
Undefined
Drafter:
None
Direction:
Needs approval
Assignee:
None
Definition:
New
Series goal:
None
Implementation:
Unknown
Milestone target:
None

Related branches

Sprints

Whiteboard

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.