Skip to content

Allow DefineFont without DefineFontInfo#36

Open
tuomassalo wants to merge 1 commit intotimknip:masterfrom
tuomassalo:font-info-fix
Open

Allow DefineFont without DefineFontInfo#36
tuomassalo wants to merge 1 commit intotimknip:masterfrom
tuomassalo:font-info-fix

Conversation

@tuomassalo
Copy link
Contributor

Some .swf files seem to have DefineFont tags without corresponding DefineFontInfo a tag. This results in an error:

$ python bin/swf2svg.py --swf test.swf --svg test.svg
Traceback (most recent call last):
  File "bin/swf2svg.py", line 21, in <module>
    svg = swf.export(svg_exporter)
  File "/usr/local/lib/python2.7/site-packages/swf/movie.py", line 132, in export
    return exporter.export(self, force_stroke)
  File "/usr/local/lib/python2.7/site-packages/swf/export.py", line 531, in export
    super(SVGExporter, self).export(swf, force_stroke)
  File "/usr/local/lib/python2.7/site-packages/swf/export.py", line 404, in export
    self.export_define_shapes(swf.tags)
  File "/usr/local/lib/python2.7/site-packages/swf/export.py", line 474, in export_define_shapes
    self.export_define_font(tag)
  File "/usr/local/lib/python2.7/site-packages/swf/export.py", line 559, in export_define_font
    fontInfo = self.fontInfos[tag.characterId]
KeyError: 3

This PR aims to add a fontInfos entry even if the DefineFontInfo is missing. TBH, I haven't done much research on why the format is different in some files, but this patch should be quite safe anyway, since the new code is only run in case of missing tags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments