The font rendering is not uniform for HTML5 Canvas string display.

What does it mean?

Chrome and Firefox have inconsistent behaviors when it comes to display text.

For e.g when you display a rectangle at position 10,10 and width=50 and height=50 then both the browsers does it exactly you tell them.

But when you tell them draw the text "Hello" at 10,10 and the font-size is 14 then the results are so different.

Chrome might show at 10,7 and Firefox might show at 10,12.

There is always a difference of few pixels up or down and this varied a lot if the font size changed and worse, when you choose a different Font-family.

This problem became more apparent when MockupTiger allowed multiple Font faces and particularly for showing the underlines and the strikethrough styling.

How to Change Fonts

Click on your User name at the top, Select "Personal Settings".

Image

How did we fix the issue of inconsistency accross browsers?

We had the choice to limit to just one font face, i.e Arial in our case but that seemed too restricted. So we applied a brute force method.

Now, technically this is what happens.

When you change the font or font size, the UI actually writes a dummy text somewhere hidden from the user to a hidden canvas. Does some "Black Majick Imagery" brute force calculations, calculate the top pixel location, actual height of the font in pixels etc. It builds a custom font metrics that is then used for rendering the text.

We have not tested with any other fonts other than the ones listed here.

But if you want to test it with other fonts here is what you can do.

How to add new Fonts

1. In your downloaded version, go to the "system" directory

(e.g mockuptiger/tiger/base/system)

2. create a copy of the file property_definition.php

3.Edit the property_definition.php file and find the line that says

$property['personal']['font_name']

4. Image

5. In the array, add a new entry at the bottom

Helvetica:Helvetica

NOTE: There needs to be ":" in between, one is the display name and the other is actual font name.

Image

6. Save the file and then refresh your MockupTiger URL. The new font will be available in your menu.

The font you add should be part of your installed fonts.

Related posts:

  1. How to build Table Grids

Posted in Internals