axmolengine / axmol

Axmol Engine – A Multi-platform Engine for Desktop, XBOX (UWP) and Mobile games. (A fork of Cocos2d-x-4.0)
https://axmol.dev
MIT License
868 stars 195 forks source link

Font rendered as white boxes #2003

Closed j-jorge closed 3 months ago

j-jorge commented 3 months ago

Since commit 74612ef29662b4be72ebb50f9234b4d519fa992e the labels rendered without effect are incorrectly displayed.

  1. Create a label with no effect:
ax::TTFConfig ttf_config;

ttf_config.fontFilePath = "some-font.ttf";
ttf_config.fontSize = 12;
ttf_config.outlineSize = 0;
ttf_config.italics = false;
ttf_config.bold = false;
ttf_config.underline = false;
ttf_config.strikethrough = false;

ax::TextHAlignment horizontal_align = ax::TextHAlignment::LEFT;

ax::Label* label =  ax::Label::createWithTTF(ttf_config, "…", horizontal_align);
  1. Display the label: image

Note that the labels are displayed correctly if I set an outline.

Regarding the problematic commit, I guess the following is also important here: I build the app with AX_GLES_PROFILE=200 and link with GLESv2.

halx99 commented 3 months ago

Download cpp-test apk https://github.com/axmolengine/axmol/actions/runs/9623334152/artifacts/1627192539 and run on your device check 31:Node: Label -New API/32, does it have same issue on your device?

on my device, works fine

image

j-jorge commented 3 months ago

This one works as expected. Was there a fix between the faulty commit and this build? or is it a problem on my side?

j-jorge commented 3 months ago

I still have the issue on the current dev branch, so I guess the problem is in my compilation flags.

halx99 commented 3 months ago

not sure, by default the github ci also build apk with AX_GLES_PROFILE=200

halx99 commented 3 months ago

I can't reproduce with your code

j-jorge commented 3 months ago

I am closing this issue since it seems to be an issue on my side. I'll come back to it if I find something useful for Axmol. Thanks.

smilediver commented 3 months ago

Any errors in console? Try checking what kind of texture is being used for that configuration (is it simple alpha mask or SDF?) and which shader. And then check if the shader matches texture type, and if the final shader in the apk is correct.

Also, does your project build and run on other platforms? Could you check if those work correctly?

j-jorge commented 3 months ago

There are no error in the logs and the shader seems to be correct (label_normal.frag and positionTextureColor.vert). I don't get what could be wrong. If I set a transparent outline to use label_outline.frag then the rendering is ok, yet the code from this shader, when effectType == 0, is almost exactly the code from the former.

I managed to get the correct rendering by patching line 1299 of Label.cpp, changing the last argument from true to false.

setFontAtlas(newAtlas, _fontConfig.distanceFieldEnabled, /* useA8Shader = */ false);

I don't know why there is no problem in CppTests though. Anyway, since the intent of commit 74612ef29662b4be72ebb50f9234b4d519fa992e is to remove deprecated pixel formats, including A8, does it make sense to keep Label::_useA8Shader?

halx99 commented 3 months ago

reproduce sample please, I use your code not cpp-tests, also cann't reproduce

j-jorge commented 3 months ago

Hey, I have good news :) My build directory was in a bad shape and the shaders from Axmol v2.1.0 were used, instead of the new ones. Everything works after proper clean-up and fix-up on my side. My apologies, and sorry for the noise.