Gamua / Starling-Framework

The Cross Platform Game Engine
http://www.starling-framework.org
Other
2.84k stars 819 forks source link

embedded fonts don't appear to work by default #938

Closed sumowrestler closed 7 years ago

sumowrestler commented 7 years ago

Embedded TTF not working after upgrade to starling 2.1.

TTF is embedded as per below:

public class Fonts {
    [Embed(source="../../../../../../resources/fonts/truetype/JandaManateeSolid.ttf", embedAsCFF="false", fontFamily="JandaManateeSolid")]
    public static const JandaManateeSolid:Class;
}

Used in code as:

const textFormat : TextFormat= new starling.text.TextFormat("JandaManateeSolid", 42);
textFormat.color = 0xfca40c;
textFormat.italic = true;
messageText = new TextField(400, 90, messageTitle, textFormat);
messageText.autoSize = TextFieldAutoSize.BOTH_DIRECTIONS;
addChild(messageText);

Works from Feathers if I define a defaultTextRendererFactory as per discussion fonts suggests the font is embedded ok.

Tracing the font name shows it is registered as expected:

        const font:Font = new Fonts.JandaManateeSolid;
        trace(font.fontName)

=> [trace] JandaManateeSolid

Library versions:

    <properties>
        <flex.version>4.15.0</flex.version>
        <air.version>23.0</air.version>
        <flexmojos.version>7.1.0</flexmojos.version>
        <flash.version>20.0</flash.version>
        <flexunit.version>4.0-rc-1</flexunit.version>
        <starling.version>2.1.0-SNAPSHOT</starling.version>
    </properties>

Any help appreciated.

PrimaryFeather commented 7 years ago

One quick test: when you set textFormat.italic to false, does it work? In that case, you'd need to set fontStyle = "italic" in the embed statement.

Otherwise, please check out the result of Font.enumerateFonts(false) — is your font part of that list?

sumowrestler commented 7 years ago

You are spot on @PrimaryFeather, thanks for your quick reply and help!.

Setting textFormat.italic=false worked as did adding fontStyle = "italic" in the embed statement.

Very cool framework btw.

PrimaryFeather commented 7 years ago

Perfect! I'm glad I could help!

And thanks for the nice words! :smile: