Make label text wider? lazarus / 31-LCL ---------------------------------------------------------------------- lainz · 2018-03-27 14:28 There is a way to make text of TLabel wider, there is an option or I just need to change the font? ---------------------------------------------------------------------- taazz · 2018-03-27 14:39 wider how? like bold? or bigger gap between the letters? ---------------------------------------------------------------------- lainz · 2018-03-27 14:48 Quote from: taazz on March 27, 2018, 04:39:09 pmwider how? like bold? or bigger gap between the letters? Hi, like this attached image. Height is the same in both characters, the width is doubled in the second one. ---------------------------------------------------------------------- taazz · 2018-03-27 15:10 looks like bold to me ee label.font.style := [fsBold]; EDIT: If I'm off then the only way to accomplish that is either change the font size or use your own "painter" to stretch the letters. The default os API (textout etc) does not provide any abilities to arbitrary manipulate width of a sentence. ---------------------------------------------------------------------- lainz · 2018-03-27 18:07 Hi, thanks. Seems that by default is not possible. And no, is not bold, I stretched it to double width on a graphic design software, I think it was possible here too. Maybe I need to use bitmaps for some glyphs instead of text. ---------------------------------------------------------------------- jamie · 2018-03-27 21:13 Write to a Tbitmap that is smaller than the destination, then use the Canvas.StretchDraw..... ---------------------------------------------------------------------- taazz · 2018-03-27 22:56 Quote from: lainz on March 27, 2018, 08:07:18 pmHi, thanks. Seems that by default is not possible. And no, is not bold, I stretched it to double width on a graphic design software, I think it was possible here too. Maybe I need to use bitmaps for some glyphs instead of text. well in order to avoid writing a ttf/oft renderer the only two options that I know of are 1) draw to bitmap and stretchblt it to the required width somepixelation is expected 2) add the appropriate width of outline (has too many irregularities) 3) create an svg/emf imagelist that can be used to transform the images to anything with out pixelation   sorry sorry got carried away a bit ---------------------------------------------------------------------- lainz · 2018-03-28 01:01 I already built an SVG viewer with BGRABitmap but is not retina display ready. Like almost all TBitmap TBGRABitmap or similar. For that I was looking for another option. But maybe you are right with the image list. I'm aware of the high DPI image list. That maybe can help me with this. ---------------------------------------------------------------------- engkin · 2018-03-28 19:05 Quote from: lainz on March 28, 2018, 03:01:09 amFor that I was looking for another option. Try CreateFontIndirect: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses  LCLIntf;... procedure TForm1.FormPaint(Sender: TObject);var  ALogFont: TLogFont;  OldFont, OldMode: Integer;  WiderFont: HFONT;  s: string;  w: integer;begin  OldMode := SetBkMode(Canvas.Handle, TRANSPARENT);   s := 'Some Text';  TextOut(Canvas.Handle, 10, 10, pchar(s), Length(s));   OldFont := 0;   if GetObject(Canvas.Font.Reference.Handle, SizeOf(ALogFont), @ALogFont) <> 0 then  begin    for w := 10 to 15 do    begin      ALogFont.lfWidth:=w;      WiderFont := CreateFontIndirect(ALogFont);    if WiderFont <> 0 then      begin        OldFont := SelectObject(Canvas.Handle, WiderFont);        s := Format('Some Text - %d ',[w]);        TextOut(Canvas.Handle, 10, 40+20*(w-10), pchar(s), Length(s));        if OldFont <> 0 then          DeleteObject(SelectObject(Canvas.Handle, OldFont));      end;    end;  end;   SetBkMode(Canvas.Handle, OldMode);end; ---------------------------------------------------------------------- Blaazen · 2018-03-28 19:15 Unfortunately, it does not work on Qt. ---------------------------------------------------------------------- kupferstecher · 2018-03-28 20:31 Instead of writing in a bitmap and stretching to the desired length, it could be written in the correct length and then compressed to the correct height. The pixelisation should be much better this way. ---------------------------------------------------------------------- rvk · 2018-03-28 21:13 Quote from: Blaazen on March 28, 2018, 09:15:50 pmUnfortunately, it does not work on Qt. Yes, but LCLIntf also holds CreateFont() which should be cross- platform. http://wiki.lazarus.freepascal.org/lclintf No idea if the width parameter really does something on Qt. On Win32 it redirects to CreateFontIndirect. ---------------------------------------------------------------------- engkin · 2018-03-29 04:19 Quote from: Blaazen on March 28, 2018, 09:15:50 pmUnfortunately, it does not work on Qt. QT has setStretch: QuoteSets the stretch factor for the font. The stretch factor changes the width of all characters in the font by factor percent. For example, setting factor to 150 results in all characters in the font being 1.5 times (ie. 150%) wider. The default stretch factor is 100. The minimum stretch factor is 1, and the maximum stretch factor is 4000. Someone needs to add it to QFont class and use it in CreateFontIndirect. Or QFont_setStretch could be used directly.