How to replace fonts in Flash movies using SWF Scout and its SWF2XML/XML2SWF interfaces
This tutorial demonstrates how to use SWF2XML and XML2SWF to replace font in existing SWF flash movie using SWF Scout SDK.
IMPORTANT NOTE: to use SWF2XML and XML2SWF objects you should have Expert Edition of the SDK.
Source flash movie with Arial font:
Produced flash movie (font has been replaced from Arial to Impact):
1. Source code (converting SWF with Arial to XML):
Set SWF2XML = CreateObject("SWFScout.SWF2XML") SWF2XML.InitLibrary "demo", "demo" SWF2XML.LoadSWFFromFile "TestWithArialFont.swf" SWF2XML.FontsAsExternalFiles = true SWF2XML.SaveToFile "TestWithArialFont.xml"
2. Source code (converting SWF with Impact to XML in order to extract font0.dat for Impact font):
Set SWF2XML = CreateObject("SWFScout.SWF2XML") SWF2XML.InitLibrary "demo","demo" SWF2XML.LoadSWFFromFile "TestWithImpactFont.swf" ' SWF2XML.FontsAsExternalFiles = true SWF2XML.SaveToFile "TestWithImpactFont.xml"
Now we are replacing font0.dat from (1) with font0.dat from (2) so we replace Arial font data with Impact font data:
<?xml version="1.0" encoding="UTF-8"?> <SWF XMax="12800" YMax="9600" FPS="12" Version="8" SystemCoord="Twips" Compressed="True"> <SetBackgroundColor Color="#FFFFFF"/> <DefineFont2 File="Impact_font0.dat" FileType="bytecode" ID="1" Name="Arial" SmallText="True" ShiftJIS="False" ANSI="True" Italic="False" Bold="True" LanguageCode="0" Ascent="927" Descent="217" Leading="120"/> <DefineEditText ID="2" XMin="200" YMin="3000" XMax="12800" YMax="8000" AutoSize="False" WordWrap="True" ReadOnly="True" NoSelect="True" UseOutlines="True" FontID="1" Height="640" Color="#FF787878" Variable="EditText"> <Value> <![CDATA[This is a test text!]]> </Value> </DefineEditText> <PlaceObject2 ID="2" Depth="2"/> <ShowFrame/> <End/> </SWF>
3. Finally compile XML back to SWF to get SWF with Arial to Impact replaced:
Set XML2SWF = CreateObject("SWFScout.XML2SWF") XML2SWF.InitLibrary "demo", "demo" XML2SWF.LoadXMLFromFile "TestWithArialFontWithFontNameReplacedToImpact.xml", true XML2SWF.Compile XML2SWF.SaveToFile "TestWithArialFontWithFontNameReplacedToImpact.swf"
Download source code: