Recent

Author Topic: FontSize Height?  (Read 3537 times)

odvesims

  • Full Member
  • ***
  • Posts: 176
FontSize Height?
« on: July 01, 2015, 05:20:36 pm »
Hey There!

Is there a way to enlarge the fonts vertically only? Im printing a receipt using the Printer unit, and it all works fine but i want to enlarge a font but only vertically while keeping the same horizontal base. What'd be the best approach to achieve this?

Thanks in advance!

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: FontSize Height?
« Reply #1 on: July 01, 2015, 05:23:36 pm »
You could StretchDraw a bit, but the result is not so good.

odvesims

  • Full Member
  • ***
  • Posts: 176
Re: FontSize Height?
« Reply #2 on: July 01, 2015, 05:24:57 pm »
Would you mind elaborating on it typo? I'm literally out of options here, so anything would be greatly appreciated.

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: FontSize Height?
« Reply #3 on: July 01, 2015, 05:32:43 pm »
You could write the text to a bitmap and StretchDraw the bitmap to the desired Canvas.

odvesims

  • Full Member
  • ***
  • Posts: 176
Re: FontSize Height?
« Reply #4 on: July 01, 2015, 05:47:19 pm »
I dont want to sound demanding or anything, but could you point me to some example or something? Im fairly new to free pascal  :-\

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: FontSize Height?
« Reply #5 on: July 01, 2015, 06:06:18 pm »
Code: [Select]
var
  bmp: Graphics.TBitmap;
  s: string = 'abc';
begin
  bmp := TBitmap.Create;
  try
    bmp.Width := Canvas.TextWidth(s);
    bmp.Height := Canvas.TextHeight(s);
    bmp.Canvas.Font.Color := clBlack;
    bmp.Canvas.Brush.Color := clWindow;
    bmp.Canvas.FillRect(0, 0,bmp.Width, bmp.Height);
    bmp.Canvas.TextOut(0, 0, s);
    Canvas.StretchDraw(Rect(0, 0, bmp.Width, bmp.Height + 20), bmp);
  finally
    bmp.Free;
  end;
end;           
« Last Edit: July 01, 2015, 06:14:28 pm by typo »

odvesims

  • Full Member
  • ***
  • Posts: 176
Re: FontSize Height?
« Reply #6 on: July 01, 2015, 08:10:47 pm »
Thanks typo, i tried it and though it "worked" the final result wasn't desirable, as you stated. Im going to move on and try with different font types, styles, etc. Thanks though ^_^

 

TinyPortal © 2005-2018