You know those lovely font embedding options?
Wouldn’t it be great if you could make your own character sets?
As great as the default options are (All, Uppercase, Lowercase, Numerals) the latter 3 combined don’t contain all of the visible characters - and the ‘All’ option embeds thousands of other useless characters. So how about this?
If you are bored with Flash taking ages to publish because you have (rather lazily!) embeded the full Unicode font set (I really have no idea what embedding 39477 characters achieves, Verdana - in the Windows Character map on my PC - only lists 665 chars) then this is a little bit of code I knocked up this morning that might help (someone could turn it into a class pretty application if they want!)
What do you need to do?
This technique reduced my project publish time from 85 seconds to 22.
var myString:String = " **!"#\$%&'()\*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNO**
PQRSTUVWXYZ\[\\\]^\_`abcdefghijklmnopqrstuvwxyz{|}~¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹
º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿAa
AaAaCcCcCcCcDdÐdEeEeEeEeEeGgGgGgGgHhHhIiIiIiIiIi??JjKk?LlLlLl??LlNnNnNn?
??OoOoOoŒœRrRrRrSsSsSsŠšTtTtTtUuUuUuUuUuUuWwYyŸZzZzŽž?ƒOoUu??????ˆ?¯??°?
˜?`´~??;?????????????G????T?????????S??F??O???????aß?de??????µ???p??st?f
????????????????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????????????????
??????????????????????????????????????????????????????–—?=‘’‚?“”„†‡•…‰'?
‹›??/n?£P?€?l?™?e???????-/·v8?˜?==????????"
var nameOfFontSet:String = "**My Character Set**"var fontSetID:Number = **50**
generateCharSet( nameOfFontSet, fontSetID, myString);
function generateCharSet (setName, setID, chars) {
var outputXML:String = "<glyphRange name="" + setName + "" id="" +
setID + "">n"
var numberOfChars:Number = chars.length;
for (var i:Number=0; i<=numberOfChars-1; i++) {
var charCode:Number = chars.charCodeAt(i)
var hexCode:String = convertTo4DigitHexValue(charCode.toString(16))
outputXML += "t<range min="0x" + hexCode + "" max="0x" +
hexCode + "" />n"
}
outputXML += "</glyphRange>"
trace("outputXML:n" + outputXML);
}
function convertTo4DigitHexValue (hexValue:String):String {
var hexLength:Number = hexValue.length;
var numberOfLeadingZerosRequired:Number = 4 - hexLength;
for (var i:Number=0; i<=numberOfLeadingZerosRequired-1; i++) {
hexValue = "0" + hexValue;
}
return hexValue
}