swftools-common
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Swftools-common] Dynamic HTML Text


From: Neal Murphy
Subject: Re: [Swftools-common] Dynamic HTML Text
Date: Thu, 20 Apr 2006 23:29:05 -0400
User-agent: KMail/1.8.3

On Thursday 20 April 2006 15:17, Garth Patil wrote:
> thanks. that seems to work pretty well, although, i can't really
> reduce the size of the font that much, because i'm building the text
> on the fly based on a response from a web service. most of the glyphs
> could potentially be used.
> one thing i tried was simply not specifying a "font=" parameter in my
> .edittext. it seems to use a default serif font, and the resulting
> .swf file was 300 times smaller than importing a full font.
> 180KB = with full Arial.ttf imported
> 120KB = with reduced Arial.ttf imported
> 626B = with no font imported
> this seems like the best solution for me, but i'm worried that i may
> be creating a file that will not render properly in all cases. does
> anyone have experience with this method? are there any pitfalls with
> using it?
> thanks,
> /garth

I RTFMed. Below is a fontforge script that will delete all characters not 
specified on the command line of the script and generate a new font file.

This is a truly rudimentary example script. It needs a lot more work to be 
generally useful. But it does illustrate how to use fontforge to subset fonts 
on the fly, which will result in smaller SWFs. Selecting the glyphs to save 
is left as an exercise for the student. :) So fontforge can be used to subset 
fonts on-the-fly.

Perhaps Matthias could (someday) integrate fontforge into swftools. Like he 
doesn't have enough to do already. LOL

I don't know if there's any way around your problem. If your SWF uses a 
significant portion of a font, it is going to be large. Subsetting fonts is 
really only useful for SWFs that use small portions of fonts. But then, 
subsetted TTFs should almost always be much smaller, because documents rarely 
use much of a font, and TTFs can contain thousands of glyphs. At least I 
haven't seen many documents that use, at one time, much of the Roman, Greek, 
Chinese, Korean, Arabian, box drawing and symbol glyphs, all of which (and 
more) are available in the Arial_Black TTF file.


--------------
#! /usr/bin/fontforge

# Usage statement
if ($argc < 3)
  Print()
  Print("Usage:")
  Print($argv[0]+" font-name char [char ...]")
  Print("  font-name could be Arial_Black or Arial or Helvetica")
  Print("  char is a glyph in the font, such as a, b, Y, Z, ...")
  Quit()
endif

# Fetch the first two args (font name and first glyph to keep)
font = $1
first_glyph = $2

# Dump them in the bit bucket
shift; shift

# Build the font file names
font_src = "/usr/share/fonts/truetype/msttcorefonts/" + font + ".ttf"
font_dst = "./" + font + ".ttf"

# Open the source font
Open(font_src)

# select the first glyph to save
Select(first_glyph)

# select the rest of the glyphs
i = 1
while (i<$argc)
  SelectMore($argv[i])
  i += 1
endloop

# Invert the selection and cut the other glyphs
SelectInvert()
Cut()

# Generate the new font
Generate("./"+font_dst)
--------------


-- 
Neal P. Murphy; Website & Information Systems
  Diesel Hot Rod Association, Inc.
  540-384-6159; 540-312-6159 (mobile)
  http://www.dhraonline.com/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]