Skip to content
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

Add support for subsetting OT-SVG table #2452

Merged
merged 22 commits into from
Nov 16, 2021
Merged

Add support for subsetting OT-SVG table #2452

merged 22 commits into from
Nov 16, 2021

Commits on Nov 15, 2021

  1. Configuration menu
    Copy the full SHA
    425e1af View commit details
    Browse the repository at this point in the history
  2. subset: don't drop SVG table, add WIP subset/svg.py stub

    simply  pass-through for now
    anthrotype committed Nov 15, 2021
    Configuration menu
    Copy the full SHA
    bd47bda View commit details
    Browse the repository at this point in the history
  3. subset: store original glyphOrder and map from old to new indexes in …

    …Subsetter instance
    
    so that SVG tables' subset_glyphs method can use it to get glyph names from GISs and to remap from old to new GIDs
    anthrotype committed Nov 15, 2021
    Configuration menu
    Copy the full SHA
    16249d1 View commit details
    Browse the repository at this point in the history
  4. basic subset.svg impl that simply remaps id='glyphXXX'

    this drops svg document records when they no longer intersect the subset. It keeps them in their entirety (for now) when they still intersect the subset, only renaming all the id='glyphXXX' to point to the new glyph indices after subsetting. Unused, unreferenced elements are not pruned yet.
    anthrotype committed Nov 15, 2021
    Configuration menu
    Copy the full SHA
    d44af9f View commit details
    Browse the repository at this point in the history
  5. require lxml to subset SVG

    support for namespaces and xpath is insufficient in built-in ElementTree; supporting both lxml and ElementTree is too complicated, let's simply require lxml to be able to subset SVG for now
    anthrotype committed Nov 15, 2021
    Configuration menu
    Copy the full SHA
    0dc2be3 View commit details
    Browse the repository at this point in the history
  6. subset: add --pretty-svg option to enable lxml pretty_print

    False (more compact) by default
    anthrotype committed Nov 15, 2021
    Configuration menu
    Copy the full SHA
    05e6d57 View commit details
    Browse the repository at this point in the history
  7. subset/svg: support resolving cross-references and pruning elements

    With this I can finally follow xlink:href and url(#...) sort of
    references within the SVG doc and subset the elements accordingly so
    that only those that are reachable from the initial set of glyph
    elements are kept.
    anthrotype committed Nov 15, 2021
    Configuration menu
    Copy the full SHA
    a4df567 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    a79106d View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    361544f View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    d1f2481 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    a7216ae View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    863c9de View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    92470ea View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    12ed8b7 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    1d19cc6 View commit details
    Browse the repository at this point in the history
  16. encode bytes before fromstring; decode to str after tostring

    when decompiled from binary, the SVG.docList contains (unicode) strings, decoded as UTF-8. lxml fromstring accepts either bytes or str, but when given str with the xml header declaring an explicit encoding, it rejects them (since the header is lying). So we encode to bytes before calling fromstring in case the SVG contains an explicit encoding (UTF-8 is the only one allowed anyway). When serializing to XML with tostring, we similarly decode to str as UTF-8. Not only to match SVG decompile (which gives us str), but if we didn't do that, then attempting to dump to XML would fail, because XMLWriter.writecdata expects str, not bytes.
    anthrotype committed Nov 15, 2021
    Configuration menu
    Copy the full SHA
    27e4052 View commit details
    Browse the repository at this point in the history

Commits on Nov 16, 2021

  1. Configuration menu
    Copy the full SHA
    d45da5d View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    66ec30c View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    0745579 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    dbcb9d6 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    155ff60 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    247fa84 View commit details
    Browse the repository at this point in the history