Jagged fonts in HTML5 (DEF-2396)(SOLVED)

I’m getting an extremely jagged font render in HTML5 compared to a normal desktop build. Any suggestion?

jagged_font

For reference, in the font properties antialias is on and I’m using the label material.

Hmm, is it a bitmap or distance field font?

@AGulev, any idea?

Could you please upload a project with minimal repo case?

2 Likes

Thanks for the repo case (in PM).

This is DEF-2396 issue:

I fixed this bug in your repository by adding logic that takes into account devicePixelRatio (method resize_game_canvas):

	function resize_game_canvas() {
		var app_container = document.getElementById('app-container');
		var game_canvas = document.getElementById('canvas');

		var dpi = window.devicePixelRatio || 1;

		var width = {{display.width}};
		var height = {{display.height}};

		app_container.style.width = width+"px";
		app_container.style.height = height+"px";
		game_canvas.width = width*dpi;
		game_canvas.height = height*dpi;
	}

	function load_engine() {
		resize_game_canvas();
         ...

Also, this issue solved in FBInstant games template:

7 Likes

Thanks a lot! This is why this community is awesome.

5 Likes

Any chance of also adding this to the main HTML5 template? When I do a copy paste botch, there is a border and you don’t see all of the game area for some reason.

2 Likes

We will update the default template soon and this will be included.

4 Likes

Solved in Defold 1.2.160 has been released

3 Likes