Text objects misplaced in browser

Get help using Construct 2

Post » Thu Aug 24, 2017 7:59 am

I'm using Web Fonts in my game and I have problems with positioning of text objects.
For some reason all text objects are shifted a few pixels down when rendered, and the offset is different in different browsers.

See this image - same text in C2 editor, Chrome and Firefox:
Image

I did some tests today and looks like not just Web Fonts are affected, the same problem is happening with system fonts too (for example Arial).
Changing Vertical Alignment property doesn't help.

Is there a way to fix this without converting all text to sprite fonts?

Here is the CSS
Code: Select all
@font-face {
    font-family: 'luckiest_guyregular';
    src: url('luckiestguy-webfont.woff2') format('woff2'),
         url('luckiestguy-webfont.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}
Check out my awesome game Doptrix
B
17
S
9
G
10
Posts: 239
Reputation: 7,021

Post » Thu Aug 31, 2017 6:58 am

Am I the only one having this problem? :(
Check out my awesome game Doptrix
B
17
S
9
G
10
Posts: 239
Reputation: 7,021

Post » Thu Aug 31, 2017 10:22 am

You are not alone - this is a known issue with the text object:

viewtopic.php?f=147&t=180869&p=1062819&hilit=text+position#p1062819
viewtopic.php?f=147&t=178670&p=1051717&hilit=text+position#p1051717
viewtopic.php?f=147&t=168857&p=1016304&hilit=text+position#p1016304

You'd hope at least that centering the alignment and hotspot would position the text accurately, but alas not.

The only solution for accurate positioning (as far as I'm aware) is sprite fonts but this isn't ideal in all circumstances - sprite fonts don't scale well, you can't add bold/italicised formatting without adding a whole new font set and new object, and it can be a hassle getting the kerning and line spacing correct.
B
19
S
8
G
3
Posts: 432
Reputation: 3,978

Post » Thu Aug 31, 2017 1:49 pm

Thanks, mekonbekon!
I tried searching the forum for this problem but somehow missed those posts.

I guess I'll have to use sprite fonts then..
spritefont+ plugin and SpriteFontGenerator tool help with some of the issues you mentioned.
Check out my awesome game Doptrix
B
17
S
9
G
10
Posts: 239
Reputation: 7,021


Return to How do I....?

Who is online

Users browsing this forum: David181, NECRONOMICRON, Yahoo [Bot] and 25 guests