swftools
swftools copied to clipboard
issues with Ruffle with SWF files from SWFTools
I have reported some issues in Ruffle with SWF files generated with SWFTools (swfc and pdf2swf).
I wonder whether it would be possible to get an explanation of what SWFTools might be doing in a different way, if I reported some issues that I encounter in Ruffle with SWF files that I generated with SWFTools.
Many thanks for your help.
contact Mathias Kramm author of SWFTools
I thought this was the best way to contact him, since this repository belongs to him.
Could you attach some of the SWF files that cause issues in Ruffle?
@matthiaskramm, many thanks for your reply.
Using pdf2swf from SWFTools, I generate both SWF files:
BTW, files aren’t compressed. I only appended the .zip extension to attach them here.
Both files are generated using pdf2swf contained in SWFTools version 0.9.2, from a PDF document with embedded fonts which contains only a subset of used characters.
The file noproblem.swf is displayed fine and it is generated with pdf2swf -f.
The file problem.swf doesn’t have all characters displayed (generated without any -f option).
My question is: which font information is removed when not using pdf2swf -f?
Another issue comes from https://github.com/ruffle-rs/ruffle/issues/1561#issuecomment-748651396.
The loader doesn’t work because it’s located inside a sprite.
My question would be how to use a loader outside the sprite (since Ruffle isn’t able to solve the value inside a sprite).
Sorry, I need to elaborate more on this, but right now I’m afraid I don’t have the time for this.
Many thanks for your help.
Regarding the fonts, I remember that pdf2swf will clear unused glyphs, but leave them in the font table, thus generating empty polygons. Maybe that's what's tripping up Ruffle.
Many thanks for your reply, @matthiaskramm.
The diff from swfdump -D from both files (pdf2swf with and without -f) reads:
--- noproblem.txt 2021-02-06 23:12:51.109524760 +0100
+++ problem.txt 2021-02-06 23:12:42.377470270 +0100
@@ -1,13 +1,13 @@
[HEADER] File version: 6
-[HEADER] File is zlib compressed. Ratio: 92%
-[HEADER] File size: 7136
+[HEADER] File is zlib compressed. Ratio: 93%
+[HEADER] File size: 6927
[HEADER] Frame rate: 0.250000
[HEADER] Frame count: 1
[HEADER] Movie width: 597.00
[HEADER] Movie height: 448.00
[009] 3 SETBACKGROUNDCOLOR (ff/ff/ff)
-[030] 4551 DEFINEFONT2 defines id 0002
-[030] 1901 DEFINEFONT2 defines id 0001
+[030] 4441 DEFINEFONT2 defines id 0002
+[030] 1811 DEFINEFONT2 defines id 0001
[020] 34 DEFINESHAPE3 defines id 0003
| fillstyles(01) linestyles(00)
| 1 ) SOLID 000000ff
@@ -44,23 +44,23 @@
| fill: 01/00 line:00 - lineTo 0.00 0.00
|
[01a] 5 PLACEOBJECT2 places id 0005 at depth 0003
-[021] 73 DEFINETEXT2 defines id 0006
+[021] 71 DEFINETEXT2 defines id 0006
| Matrix
| 1.000 0.000 125.65
| 0.000 1.000 125.50
- <22 glyphs in font 0002 size 35, color #ffffffff at 0.00,0.00> Mejorar presentaciones
+ <21 glyphs in font 0002 size 35, color #ffffffff at 0.00,0.00> Mejorarpresentaciones
[01a] 5 PLACEOBJECT2 places id 0006 at depth 0004
[021] 55 DEFINETEXT2 defines id 0007
| Matrix
| 1.000 0.000 240.45
| 0.000 1.000 194.00
- <15 glyphs in font 0002 size 17, color #ffffffff at 0.00,0.00> Pablo Rodríguez
+ <14 glyphs in font 0002 size 17, color #ffffffff at 0.00,0.00> PabloRodríguez
[01a] 5 PLACEOBJECT2 places id 0007 at depth 0005
-[021] 60 DEFINETEXT2 defines id 0008
+[021] 53 DEFINETEXT2 defines id 0008
| Matrix
| 1.000 0.000 245.00
| 0.000 1.000 259.15
- <18 glyphs in font 0002 size 13, color #ffffffff at 0.00,0.00> 2 de marzo de 2014
+ <14 glyphs in font 0002 size 13, color #ffffffff at 0.00,0.00> 2demarzode2014
[01a] 5 PLACEOBJECT2 places id 0008 at depth 0006
[021] 92 DEFINETEXT2 defines id 0009
| Matrix
It seems to be that pdf2swf -f keeps the space character, while pdf2swf doesn’t.
Or even better, the diff between XML exports from JPEXS:
--- noproblem.xml 2021-02-06 23:21:27.063744452 +0100
+++ problem.xml 2021-02-06 23:20:28.226377298 +0100
@@ -7,12 +7,12 @@
<item type="SetBackgroundColorTag">
<backgroundColor blue="255" green="255" red="255" type="RGB"/>
</item>
- <item fontAscent="14220" fontDescent="3520" fontFlagsANSI="false" fontFlagsBold="false" fontFlagsHasLayout="true" fontFlagsItalic="false" fontFlagsShiftJIS="false" fontFlagsSmallText="true" fontFlagsWideCodes="true" fontFlagsWideOffsets="true" fontID="2" fontLeading="0" fontName="HLQHKK+Carlito-20-0" type="DefineFont2Tag">
+ <item fontAscent="0" fontDescent="0" fontFlagsANSI="false" fontFlagsBold="false" fontFlagsHasLayout="false" fontFlagsItalic="false" fontFlagsShiftJIS="false" fontFlagsSmallText="true" fontFlagsWideCodes="true" fontFlagsWideOffsets="true" fontID="2" fontLeading="0" fontName="" type="DefineFont2Tag">
<languageCode languageCode="0" type="LANGCODE"/>
<glyphShapeTable>
- <item numFillBits="1" numLineBits="0" type="SHAPE">
+ <item numFillBits="0" numLineBits="0" type="SHAPE">
<shapeRecords>
- <item fillStyle0="1" fillStyle1="0" lineStyle="0" moveBits="0" moveDeltaX="0" moveDeltaY="0" numFillBits="0" numLineBits="0" stateFillStyle0="true" stateFillStyle1="false" stateLineStyle="false" stateMoveTo="false" stateNewStyles="false" type="StyleChangeRecord"/>
+ <item fillStyle0="0" fillStyle1="0" lineStyle="0" moveBits="0" moveDeltaX="0" moveDeltaY="0" numFillBits="0" numLineBits="0" stateFillStyle0="false" stateFillStyle1="true" stateLineStyle="false" stateMoveTo="false" stateNewStyles="false" type="StyleChangeRecord"/>
<item endOfShape="0" type="EndShapeRecord"/>
</shapeRecords>
</item>
@@ -1011,7 +1011,7 @@
</item>
</glyphShapeTable>
<codeTable>
- <item>32</item>
+ <item>0</item>
<item>48</item>
<item>49</item>
<item>50</item>
@@ -1039,72 +1039,13 @@
<item>122</item>
<item>237</item>
</codeTable>
- <fontAdvanceTable>
- <item>8192</item>
- <item>10380</item>
- <item>10380</item>
- <item>10380</item>
- <item>10380</item>
- <item>17520</item>
- <item>10580</item>
- <item>11120</item>
- <item>9820</item>
- <item>10760</item>
- <item>8660</item>
- <item>10760</item>
- <item>10200</item>
- <item>9640</item>
- <item>4700</item>
- <item>4900</item>
- <item>4700</item>
- <item>16360</item>
- <item>10760</item>
- <item>10800</item>
- <item>10760</item>
- <item>7140</item>
- <item>8020</item>
- <item>6860</item>
- <item>10760</item>
- <item>8100</item>
- <item>4700</item>
- </fontAdvanceTable>
- <fontBoundsTable>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- </fontBoundsTable>
- <fontKerningTable/>
</item>
- <item fontAscent="14365" fontDescent="3620" fontFlagsANSI="false" fontFlagsBold="false" fontFlagsHasLayout="true" fontFlagsItalic="false" fontFlagsShiftJIS="false" fontFlagsSmallText="true" fontFlagsWideCodes="true" fontFlagsWideOffsets="true" fontID="1" fontLeading="0" fontName="ZVAXWJ+ryt1xbtt-22-0" type="DefineFont2Tag">
+ <item fontAscent="0" fontDescent="0" fontFlagsANSI="false" fontFlagsBold="false" fontFlagsHasLayout="false" fontFlagsItalic="false" fontFlagsShiftJIS="false" fontFlagsSmallText="true" fontFlagsWideCodes="true" fontFlagsWideOffsets="true" fontID="1" fontLeading="0" fontName="" type="DefineFont2Tag">
<languageCode languageCode="0" type="LANGCODE"/>
<glyphShapeTable>
- <item numFillBits="1" numLineBits="0" type="SHAPE">
+ <item numFillBits="0" numLineBits="0" type="SHAPE">
<shapeRecords>
- <item fillStyle0="1" fillStyle1="0" lineStyle="0" moveBits="0" moveDeltaX="0" moveDeltaY="0" numFillBits="0" numLineBits="0" stateFillStyle0="true" stateFillStyle1="false" stateLineStyle="false" stateMoveTo="false" stateNewStyles="false" type="StyleChangeRecord"/>
+ <item fillStyle0="0" fillStyle1="0" lineStyle="0" moveBits="0" moveDeltaX="0" moveDeltaY="0" numFillBits="0" numLineBits="0" stateFillStyle0="false" stateFillStyle1="true" stateLineStyle="false" stateMoveTo="false" stateNewStyles="false" type="StyleChangeRecord"/>
<item endOfShape="0" type="EndShapeRecord"/>
</shapeRecords>
</item>
@@ -1613,7 +1554,7 @@
</item>
</glyphShapeTable>
<codeTable>
- <item>32</item>
+ <item>0</item>
<item>45</item>
<item>46</item>
<item>47</item>
@@ -1634,51 +1575,6 @@
<item>116</item>
<item>119</item>
</codeTable>
- <fontAdvanceTable>
- <item>4380</item>
- <item>10760</item>
- <item>10760</item>
- <item>10760</item>
- <item>10760</item>
- <item>10760</item>
- <item>10760</item>
- <item>10760</item>
- <item>10760</item>
- <item>10760</item>
- <item>10760</item>
- <item>10760</item>
- <item>10760</item>
- <item>10760</item>
- <item>10760</item>
- <item>10760</item>
- <item>10760</item>
- <item>10760</item>
- <item>10760</item>
- <item>10760</item>
- </fontAdvanceTable>
- <fontBoundsTable>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- <item Xmax="0" Xmin="0" Ymax="0" Ymin="0" nbits="0" type="RECT"/>
- </fontBoundsTable>
- <fontKerningTable/>
</item>
<item shapeId="3" type="DefineShape3Tag">
<shapeBounds Xmax="11940" Xmin="0" Ymax="8960" Ymin="0" nbits="15" type="RECT"/>
@@ -1764,7 +1660,7 @@
</item>
<item characterId="5" clipDepth="0" depth="3" placeFlagHasCharacter="true" placeFlagHasClipActions="false" placeFlagHasClipDepth="false" placeFlagHasColorTransform="false" placeFlagHasMatrix="false" placeFlagHasName="false" placeFlagHasRatio="false" placeFlagMove="false" ratio="0" type="PlaceObject2Tag"/>
<item characterID="6" type="DefineText2Tag">
- <textBounds Xmax="9432" Xmin="2550" Ymax="2651" Ymin="2004" nbits="15" type="RECT"/>
+ <textBounds Xmax="9432" Xmin="2550" Ymax="2650" Ymin="2009" nbits="15" type="RECT"/>
<textMatrix hasRotate="false" hasScale="false" nRotateBits="0" nScaleBits="0" nTranslateBits="13" rotateSkew0="0" rotateSkew1="0" scaleX="0" scaleY="0" translateX="2513" translateY="2510" type="MATRIX"/>
<textRecords>
<item fontId="2" styleFlagsHasColor="true" styleFlagsHasFont="true" styleFlagsHasXOffset="false" styleFlagsHasYOffset="false" textHeight="35" type="TEXTRECORD" xOffset="0" yOffset="0">
@@ -1776,8 +1672,7 @@
<item glyphAdvance="379" glyphIndex="19" type="GLYPHENTRY"/>
<item glyphAdvance="235" glyphIndex="21" type="GLYPHENTRY"/>
<item glyphAdvance="344" glyphIndex="8" type="GLYPHENTRY"/>
- <item glyphAdvance="250" glyphIndex="21" type="GLYPHENTRY"/>
- <item glyphAdvance="161" glyphIndex="0" type="GLYPHENTRY"/>
+ <item glyphAdvance="411" glyphIndex="21" type="GLYPHENTRY"/>
<item glyphAdvance="377" glyphIndex="20" type="GLYPHENTRY"/>
<item glyphAdvance="242" glyphIndex="21" type="GLYPHENTRY"/>
<item glyphAdvance="357" glyphIndex="12" type="GLYPHENTRY"/>
@@ -1808,8 +1703,7 @@
<item glyphAdvance="171" glyphIndex="8" type="GLYPHENTRY"/>
<item glyphAdvance="189" glyphIndex="9" type="GLYPHENTRY"/>
<item glyphAdvance="82" glyphIndex="16" type="GLYPHENTRY"/>
- <item glyphAdvance="189" glyphIndex="19" type="GLYPHENTRY"/>
- <item glyphAdvance="81" glyphIndex="0" type="GLYPHENTRY"/>
+ <item glyphAdvance="270" glyphIndex="19" type="GLYPHENTRY"/>
<item glyphAdvance="188" glyphIndex="7" type="GLYPHENTRY"/>
<item glyphAdvance="189" glyphIndex="19" type="GLYPHENTRY"/>
<item glyphAdvance="188" glyphIndex="11" type="GLYPHENTRY"/>
@@ -1825,26 +1719,22 @@
</item>
<item characterId="7" clipDepth="0" depth="5" placeFlagHasCharacter="true" placeFlagHasClipActions="false" placeFlagHasClipDepth="false" placeFlagHasColorTransform="false" placeFlagHasMatrix="false" placeFlagHasName="false" placeFlagHasRatio="false" placeFlagMove="false" ratio="0" type="PlaceObject2Tag"/>
<item characterID="8" type="DefineText2Tag">
- <textBounds Xmax="7066" Xmin="4892" Ymax="5248" Ymin="4983" nbits="14" type="RECT"/>
+ <textBounds Xmax="7066" Xmin="4892" Ymax="5205" Ymin="4983" nbits="14" type="RECT"/>
<textMatrix hasRotate="false" hasScale="false" nRotateBits="0" nScaleBits="0" nTranslateBits="14" rotateSkew0="0" rotateSkew1="0" scaleX="0" scaleY="0" translateX="4900" translateY="5183" type="MATRIX"/>
<textRecords>
<item fontId="2" styleFlagsHasColor="true" styleFlagsHasFont="true" styleFlagsHasXOffset="false" styleFlagsHasYOffset="false" textHeight="13" type="TEXTRECORD" xOffset="0" yOffset="0">
<textColorA alpha="255" blue="255" green="255" red="255" type="RGBA"/>
<glyphEntries>
- <item glyphAdvance="136" glyphIndex="3" type="GLYPHENTRY"/>
- <item glyphAdvance="61" glyphIndex="0" type="GLYPHENTRY"/>
+ <item glyphAdvance="197" glyphIndex="3" type="GLYPHENTRY"/>
<item glyphAdvance="141" glyphIndex="11" type="GLYPHENTRY"/>
- <item glyphAdvance="134" glyphIndex="12" type="GLYPHENTRY"/>
- <item glyphAdvance="61" glyphIndex="0" type="GLYPHENTRY"/>
+ <item glyphAdvance="195" glyphIndex="12" type="GLYPHENTRY"/>
<item glyphAdvance="215" glyphIndex="17" type="GLYPHENTRY"/>
<item glyphAdvance="128" glyphIndex="8" type="GLYPHENTRY"/>
<item glyphAdvance="94" glyphIndex="21" type="GLYPHENTRY"/>
<item glyphAdvance="101" glyphIndex="25" type="GLYPHENTRY"/>
- <item glyphAdvance="142" glyphIndex="19" type="GLYPHENTRY"/>
- <item glyphAdvance="60" glyphIndex="0" type="GLYPHENTRY"/>
+ <item glyphAdvance="202" glyphIndex="19" type="GLYPHENTRY"/>
<item glyphAdvance="141" glyphIndex="11" type="GLYPHENTRY"/>
- <item glyphAdvance="134" glyphIndex="12" type="GLYPHENTRY"/>
- <item glyphAdvance="61" glyphIndex="0" type="GLYPHENTRY"/>
+ <item glyphAdvance="195" glyphIndex="12" type="GLYPHENTRY"/>
<item glyphAdvance="136" glyphIndex="3" type="GLYPHENTRY"/>
<item glyphAdvance="137" glyphIndex="1" type="GLYPHENTRY"/>
<item glyphAdvance="136" glyphIndex="2" type="GLYPHENTRY"/>
Sorry, but I think that pdf2swf removes two tables and other data from the font.
Do you have more information about that?
With https://www.mejorar-presentaciones.tk/mejorar-presentaciones-presentation.swf, the main sans font isn’t displayed at all.
The error message reads:
Error running definition tag: DefineFont3, got Invalid data: Invalid fill style. player.js:1:25123
Fonts in that SWF file are numbered from 2 to 7. The main sans font from the first slide is object 4 and the monospaced font is object 5.
Do you know which fill styles are using font 0004 and font 0005?
Many thanks for your help again.
@matthiaskramm, Ruffle has problems with loading movieclips inside sprites.
I have the following basic swfc source;
.flash filename="box.swf"
.box b1 100 100 color=red fill=yellow
.put b1 pin=center scale=0%
.frame 100
.change b1 pin=center scale=100%
.frame 200
.change b1 pin=center scale=0%
.end
And here you have the loader:
.flash filename="sprite-loader.swf" version=7 fps=12
.box placeholder width=1024 height=768
.frame 1
.box b1 500 500 color=yellow fill=red
.put b1 pin=center scale=100%
.sprite images
.put placeholder alpha=0%
.action:
the_presentation = "box.swf";
first_loading = new Object();
first_loading.onMouseDown = function () {
load_swf = new MovieClipLoader();
load_swf.loadClip(the_presentation, placeholder);
};
Mouse.addListener(first_loading);
.end
.end
.action:
this.attachMovie("images","whatever",this.getNextHighestDepth());
.end
.end
Is there any way to display the movieclip avoiding the sprite? Ruffle has problems to resolve placeholder because of the sprite.
Many thanks for your help.
Sprite is As3, so nothing to do with your code which is in As2. I suggest you open an issue at Ruffle git repo as it's not a swftools issue.
Many thanks for your reply, @ROBERT-MCDOWELL.
I didn’t know that sprites were AS3.
The issue was opened some time ago in Ruffle, but it will take some time to get solved.
I had found another approach to the loader:
.flash filename="sprite-loader.swf" version=7 fps=12
.box placeholder width=1024 height=768 fill=red
.button mybutton
.show placeholder alpha=5%
.on_release inside:
the_presentation = "./box.swf";
this.loadMovie(the_presentation, this.placeholder);
.end
.end
.frame 1
.box b1 500 500 color=yellow fill=red
.put b1 scale=100%
.put placeholder alpha=5%
.put button1=mybutton
.end
Many thanks for your help.
Glad you find a solution!! Ruffle started 2 years ago only, and constantly need developers to join the community to speed up Flash API and AVM covering. Spread the message!