Recent

Author Topic: Fixed sized text to canvas  (Read 2846 times)

JasonLugg

  • Jr. Member
  • **
  • Posts: 67
Fixed sized text to canvas
« on: May 07, 2017, 10:15:07 pm »
Hi All

As usual, thanks in advance!

I wish to output certain ascii characters to a canvas but need each one to be 64 pixels x 64 pixels using a user chosen font.

So user chooses font Arial, I then want to draw an 'A' using font arial but the 'A' must be 64 pixels by 64 pixels.

any help much appreciated!


balazsszekely

  • Guest
Re: Fixed sized text to canvas
« Reply #1 on: May 07, 2017, 10:37:19 pm »
Hi JasonLugg,

Use the TextWidth and TextHeight functions of the canvas. Increase the font size in a loop until the width or the height is equal or bigger then 64.

Handoko

  • Hero Member
  • *****
  • Posts: 5153
  • My goal: build my own game engine using Lazarus
Re: Fixed sized text to canvas
« Reply #2 on: May 08, 2017, 06:05:48 am »
64 pixels x 64 pixels?

Did you mean you want to stretch the the letter to a perfect square size of 64 x 64? Proportional fonts usually won't looks good if you make all the characters same width, especially for the characters: i, I, l.

Arial is a proportional font, so it won't looks good if you do so. You may consider to use monospace (non-proportional) fonts:
https://en.wikipedia.org/wiki/Monospaced_font

Old era games (DOS) usually use monospaced fonts.

 

TinyPortal © 2005-2018