Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest Lime 2.0.0-alpha6 doesn't render text on Android #256

Closed
lmartinking opened this issue Oct 31, 2014 · 20 comments
Closed

Latest Lime 2.0.0-alpha6 doesn't render text on Android #256

lmartinking opened this issue Oct 31, 2014 · 20 comments

Comments

@lmartinking
Copy link

I've just updated my OpenFL to 2.1.4 and Lime to 2.0.0-alpha6, now text rendering is broken in Android.
Previously I was using OpenFL 2.1.3 and Lime-2.0.0-alpha. Downgrading my Lime build appears to solved the issue.

I'm not able to give a really detailed report, but I am using HaxeFlixel and all FlxText no longer appears.

Update: Issue is still present on alpha 5, but alpha 2, 3 and 4 are okay.

@jgranick
Copy link
Member

jgranick commented Nov 1, 2014

I have just released new Lime and OpenFL releases, which make changes to how font names are handled.

In the past, the font name depended on the target platform. On some, it would expect a file path, on others (like Flash) it would expect the font name. Now, it should expect the font name everywhere.

I did some tests with Flixel, and the fonts were working properly with this release. Please let me know if you have issues, and if you do, whether it occurs with specific Flixel projects, or on specific platforms

@KodeIn
Copy link

KodeIn commented Nov 2, 2014

I've made some test with the latest HaxeFlixel and Lime (alpha 6).
The "default" font in flixel (nokiafc22.ttf) don't seem to be included at compilation time, so the default splash screen is kinda broken at the moment. (only the animated logo and the jingle play, no changing color HaxeFlixel text)
If you add a ttf font to the assets and use it with FlxText.setFormat, text get rendered in your software. But that doesn't fix the splash screen.

@lmartinking
Copy link
Author

From what I can see, HaxeFlixel is embedding its default font, ie: a @:font() macro embeds it as a binary asset (the FlxAssets.FontDefault class). There is no need to have it as an external asset. That font class is then registered, and the name is available for lookup externally (via FlxAssets.FONT_DEFAULT).

The FlxText class sets the font via the name (not path), and this issue only appears on Android (NekoVM/Linux targets are fine).

Note: I have tried again with Alpha 7, problem still persists. Maybe font registration via class is broken?

@jgranick
Copy link
Member

jgranick commented Nov 3, 2014

Interesting that it occurs only on Android. If you include the font manually, does looking up the font by name work on Android?

@mbalestrini
Copy link
Contributor

I'll repost a comment I've made in another Issue (I should've posted here in the first place):

Ok... I've done some testing on the font issue... without any clear results, but I'll try to explain what I did to give you some hints.
I started with the AddingText OpenFL sample and changed it to embed the font and using Font.registerFont. The first time I opened the app it worked, but after killing it and open it again the text didn't render. After many tries (cleaning, rebuilding, etc) I moved all the code inside new to some MouseEvent.CLICK event.
Now the first few clicks don't work either, but after several times the text appears on the screen.

Here's the code:

@:font("assets/KatamotzIkasi-2.ttf") class RondaSevenFont extends Font {}

...

stage.addEventListener(flash.events.MouseEvent.CLICK, function (event:flash.events.MouseEvent) {            
            Font.registerFont (RondaSevenFont);
            var font = new RondaSevenFont ();
            var format = new TextFormat (font.fontName, 30, 0x7A0026);
            var textField = new TextField ();
            trace(font.fontName);
...

trace(font.fontName) gave me different results:

  • On neko and android, if I use Asset.getFont(...) instead of embedding, I get the asset name: "assets/KatamotzIkasi-2.ttf"
  • On neko if I embed the font, I get the real font name: "Katamotz Ikasi"
  • On android if I embed the font I get garbage on the terminal (on every click something different, even when it suddenly renders the text) like: ????????????楳

Ok. Hope it helps.

@bguiz
Copy link

bguiz commented Dec 6, 2014

Yep, I'm facing this issue with the android target too. FlxText totally does not gets rendered. FlxButtons get rendered, but without their text inside.

The "default" font in flixel (nokiafc22.ttf) don't seem to be included at compilation time

Can we please get this back by default for the android target?

If you add a ttf font to the assets and use it with FlxText.setFormat, text get rendered in your software.

This workaround does not appear to work for me.

@bguiz
Copy link

bguiz commented Dec 6, 2014

Newer versions, lime 2.0.1 still has this font problem

$ haxelib list
actuate: [1.7.5]
flixel-addons: [1.1.0]
flixel-demos: [1.1.1]
flixel-templates: [1.0.2]
flixel-tools: [1.0.2]
flixel-ui: [1.0.2]
flixel: 3.3.5 [3.3.6]
hxcpp: [3.1.39]
lime: [2.0.1] 2.0.0-alpha.7 2.0.0
openfl-bitfive: 2.0.1 [2.1.6]
openfl-samples: [2.1.0]
openfl: [2.1.7] 2.1.5 2.1.6
swf: [1.7.0] 1.6.9 1.6.7

@madz7z
Copy link

madz7z commented Dec 7, 2014

Same problem here.

actuate: [1.7.5]
flixel-addons: [1.1.0]
flixel-demos: [1.1.1]
flixel-templates: [1.0.2]
flixel-tools: [1.0.2]
flixel-ui: [1.0.2]
flixel: 3.3.5 [3.3.6]
hxcpp: [3.1.39]
lime: [2.0.0-beta] 2.0.1
monax: [1.4.0]
nape-hacks: [2.0.1]
nape-symbolic: [2.0.1]
nape: [2.0.16]
openfl-samples: [2.1.0]
openfl: 2.1.5 [2.1.7]
Parsex: [1.4.0]
swf: [1.6.8]

@jgranick
Copy link
Member

I'm having trouble differentiating between what might be a Flixel-specific issue, and what generally occurs, say, in AddingText.

I just resolved an issue with AddingText on HTML5, it works properly on the deskop, and when last tested, worked in Android, but I can test there again

@jgranick
Copy link
Member

I just tried a vanilla AddingText sample on Android, working fine, so I'm going to go ahead and close the issue. Please feel free to open a new issue if there is a specific case that fails in a vanilla OpenFL project

@mbalestrini
Copy link
Contributor

I don't think it's a Flixel-specific issue (I don't use Flixel). I think is something that happens when you embed fonts with @:font and then use Font.registerFont
In my previous comment there's some explanation of the tests I've done, to try to give you some clue.

Basically, if you change Main.hx of AddingText for this code, text doesn't render on android. You have to click several times for the text to appear, and trace(font.fontName) always returns garbage:

package;

import flash.display.Sprite;
import flash.text.Font;
import flash.text.TextField;
import flash.text.TextFormat;
import openfl.Assets;

@:font("assets/KatamotzIkasi-2.ttf") class EmeddedFont extends Font {}

class Main extends Sprite { 
    public function new () {        
        super ();
        stage.addEventListener(flash.events.MouseEvent.CLICK, function (event:flash.events.MouseEvent) {            
            Font.registerFont (EmeddedFont);
            var font = new EmeddedFont ();
            // var font = Assets.getFont("assets/KatamotzIkasi-2.ttf");
            var format = new TextFormat (font.fontName, 30, 0x7A0026);
            var textField = new TextField ();
            trace(font.fontName);

            textField.defaultTextFormat = format;
            textField.embedFonts = true;
            textField.selectable = false;           
            textField.x = 50;
            textField.y = 50;
            textField.width = 200;          
            textField.text = "Hello World";         
            addChild (textField);
        });     
    }
}

@kevinresol
Copy link

I suppose this has to be reopened ....

@jgranick
Copy link
Member

This is working for me, but maybe it was related to a later commit

@jgranick
Copy link
Member

I just needed to make sure that I used a path that existed, for example, I copied the font file to "KatamotzIkasi-2.ttf" (outside the Assets directory, to be sure it wasn't using the copied file reference) and used that for the path. If it is in the Assets directory, it should be capitalized since the Haxe macros use exact file paths, not "rename" paths from the XML (that won't affect Windows machines, but would Mac or Linux systems that are case-sensitive)

@ubald
Copy link

ubald commented Jan 19, 2015

I started having problems on cpp/mac with some fonts at specific sizes and just setting embedFonts to false got rid of my problems. I know it's not a solution but maybe a clue as to what is going on deeper inside of lime.

@jgranick
Copy link
Member

I recently pulled a new TextField implementation from the NME project, perhaps that fixed it (or it was still font related), it used to use the "renderBitmap" C++ call to render, but now uses drawTiles internally, which fixed rotation and maybe this type of issue

@mbalestrini
Copy link
Contributor

Still happening to me with:
hxcpp: 3.1.39 [3.1.48]
hxlibc: [1.1.4]
hxtools: [1.1.6]
lime-tools: 1.3.2 [1.5.7]
lime: 0.9.6 1.0.1 2.0.0 2.0.0-alpha.7 2.0.0-alpha.8 2.0.0-beta 2.0.4 [2.0.5]
nme-dev: [1.3.5]
nme: [5.2.13]
openfl-native: 1.3.0 [1.4.0]
openfl: 1.3.0 2.1.5 2.1.6 2.2.1 [2.2.3]

I tested it on a Samsung Galaxy Note 10.1 2014 and Galaxy S2.

Here's my sample project with font embedding if anyone wants to try it. The idea is that the text should appear once you click on the screen the first time. On some rare cases that happens, but normally you have to click a lot of times before the text appears (remember to close the app between tries). Also, if you test it with "lime test....", you can see on the console output that every time you click, instead of seeing the name of the font, this kind of string gets printed: ????????????楳
Sample project: http://www.videogamo.com/tmp/AddingText-embed.zip

@DanielUranga
Copy link
Contributor

Im getting this issue too on latest Lime + Openfl from haxelib. fontName prints "????????????󇉡????????????󆺐????"

@jgranick
Copy link
Member

@DanielUranga Does the same font work on the desktop? Is it all fonts, or only a specific one that has this behavior?

@DanielUranga
Copy link
Contributor

Same font works on desktop. The problem occurs when using StablexUI with the Android4 theme, or when trying to load a custom ttf with the @:font metadata + fontName.

Using font "Arial" works both in desktop and Android.

Related: RealyUniqueName/StablexUI#176

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants