Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

htmlLabel has incorrect font.size

Hello Everyone,

the component THTMLLabel is not working for me.

I use the following caption in a htmlLabel:   
<FONT SIZE="12px"> This is a sentence </FONT>

The Label shows text with a font.size of 7.

What am I doing wrong?

Kind regards,



  • 3 Comments sorted by Votes Date Added
  • Historically, font's SIZE attribute is assigned to TFont.Height internally. As a result you should use negative values like SIZE="-11px" to be consistent with other Delphi controls.
  • When I use the suggested solution:
    <FONT SIZE="-11px"> This is a sentence </FONT>
    the font.size gets ignored.

    Because in LMDHTMLUnit.pas in Line 1174f :

    if (s[1] = TLMDChar('+')) or (s[1] = TLMDChar('-')) then
      FCurFont.Height := LMDSign(FCurFont.Height) * (abs(CurData.FDefaultHeight) + MulDiv(StrToIntDef(S, 0), ScreenPixelsPerInch, 72))           

    StrToIntDef('-11px', 0)      returns 0.

    Also I don't understand the Delphi-consistency-argument.
    Delphi is able to show label.caption in font.size 12 when I set the font.size to 12.
  • Ok, I was wrong about negative values. 
    But, anyway, you cannot specify TFont.Size via HTML, you instead can only specify TFont.Height, which are two different font properties. Despite the fact that the font Height is qual to -11 in default VCL form, positive values can be also specified for font's Height property.
    So, this is how our HTML controls works historically, I can't change this because of backward compatibility.
Sign In or Register to comment.