I am embedding a font in my software and situating the .tff file in my source folder as I don't want the .tff files to be distributed with my software, like so:
[Embed(source='..//..//..//assets//fonts//CustomFont.ttf', fontName='_Cust开发者_运维技巧omFont', advancedAntiAliasing="true", embedAsCFF="false")]
This path seems a bit cumbersome, does anyone know of a more elegant way to reach this asset?
Thanks
Chris
The /
character used as the first on a URL means the root of your project. For fonts, I like to have a folder named fonts, under assets. So the path will be.
[Embed(source='/assets/fonts/CustomFont.ttf', fontName='_CustomFont', advancedAntiAliasing="true", embedAsCFF="false")]
Hope this helps.
Usually for embedded assets, I have a static class that holds them. I don't remember the exact syntax off of the top of my head, but it goes something like this.
public class EmbeddedAssets
{
[Embed(source="myfont.tff")]
private static const superFont:WhateverAFontObjectIs;
}
And then you put EmbeddedAssets in a directory closer to the top of your directory heirarchy. This allows you to only have the "Embed" metadata in one place in your application making it easier to change as well as not littering the rest of your code with temporal asset locations.
精彩评论