CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum
Deutsche Version English version russian version 
It is currently Tue Apr 25, 2017 5:24 pm

All times are UTC+01:00

Post new topic  Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Fri Feb 10, 2017 9:59 am 

Joined: Wed Feb 24, 2016 3:25 pm
Posts: 2
Hello, I have a problem with the property 'Size' of a Codesys rectangle.

If I create a rectangle and set properties into the 'Text properties' group (ex: Font=Arial; 12), I have a rectangle with the text in Arial and the size 12 ==> OK
But if I set properties into the 'Font variables' group with global variables, I don't have the expected result. For the 'Font name', no problem but the size of the text doesn't correspond to my global variable.
If my global variable is 12, the height of text is 9. Why ?

Moreover, I noticed that the result was different with different fonts.

The first rectangle uses global variables CS_Font_Name='Arial' and CI_Font_Size=12

Another example where the size starts at 1 and ends at 16:

The height of the last line is 12 pixels but it should be 16 pixels



You do not have the required permissions to view the files attached to this post.

Last edited by maxime.quidousse on Wed Feb 15, 2017 2:42 pm, edited 1 time in total.

PostPosted: Wed Feb 15, 2017 2:41 pm 

Joined: Wed Feb 24, 2016 3:25 pm
Posts: 2
I found the answer.

When I set the property 'Font' (group 'Text properties'), Codesys proposes a list of size in point (pt). But, the real value behind is in pixel (px).
Unfortunately, Codesys doesn't show the unity of the size. And we can see a different value of the size thanks to the tooltip (16px == 12pt,


The property 'Size' (group 'Font variables') wants a value in px. But the wanted height is expressed in point (pt).
There is a conversion between pixel and point depending of the DPI of the device.

Moreover, the size in pixel corresponds to an abstract square (EM) where each characters of the font is designed. So, I can't be sure that the text has a height equals to my input size.

Thanks to the FreeType library FAQ:

I set the pixel size to 8×8, but the resulting glyphs are larger (or smaller) than that. Why?

A lot of people have difficulties to understand this topic, because they think of glyphs as fixed-width or fixed-height ‘cells’, like those of fonts used in terminals/consoles. This assumption is not valid with most ‘modern’ font formats, even for bitmapped-based ones like PCF or BDF.

Be aware that the character size that is set either through FT_Set_Char_Size() or FT_Set_Pixel_Sizes() isn't directly related to the dimension of the generated glyph bitmaps!

Rather, the character size is indeed the size of an abstract square, called the EM, used by typographers to design fonts. Scaling two distinct fonts to the same character size, be it expressed in points or pixels, generally results in bitmaps with distinct dimensions!

Note that historically, the EM corresponded to the width of a capital ‘M’ in Latin typefaces. However, later improvements in typography led to designs that greatly deviate from this rule. Today, it is not possible to connect the EM size to a specific font ‘feature’ in a reliable way.

This topic can be closed.

You do not have the required permissions to view the files attached to this post.

Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 2 posts ] 

All times are UTC+01:00

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited