Recent

Author Topic: How to render a TTF to a Bitmap  (Read 489 times)

MMarie

  • New Member
  • *
  • Posts: 37
  • Right, lets bodge this pisspot
    • Homepage
How to render a TTF to a Bitmap
« on: September 06, 2024, 01:56:40 pm »
Hey,
I'm currently trying to render some text using OpenGL and without any LCL components or similar (under Linux). I have already found out about the "fpttf" unit but I can't figure out how (if it even supports it) I can actually use it to do something with the Font besides get some info about it.

As the title of my post says, I ideally want to convert the characters I need to a single or multiple Bitmaps. Can anyone provide me with some starting points?
i use arch btw

jamie

  • Hero Member
  • *****
  • Posts: 6550
Re: How to render a TTF to a Bitmap
« Reply #1 on: September 06, 2024, 10:38:28 pm »
why can't you measure the size of each character using the TextExtent functions and then form a Bitmap to that size and Canvas.TextOut the single chars?

You can do a Transparent apply to whatever surface you need.

At least that would be cross platform!

 You can save those images and load them later as bitmaps.
« Last Edit: September 06, 2024, 10:39:59 pm by jamie »
The only true wisdom is knowing you know nothing

MMarie

  • New Member
  • *
  • Posts: 37
  • Right, lets bodge this pisspot
    • Homepage
Re: How to render a TTF to a Bitmap
« Reply #2 on: September 08, 2024, 05:17:50 pm »
why can't you measure the size of each character using the TextExtent functions and then form a Bitmap to that size and Canvas.TextOut the single chars?

You can do a Transparent apply to whatever surface you need.

That is a good idea (and probably less annoying than what I ended up doing), but I saw this reply way to late and already built what I need using freetype2  %)

Depending on how things shake out, I might switch over to that.

At least that would be cross platform!

In this project I don't care about cross platform at all, the whole shtick of it is to be a Linux-only equivalent of demoscene shitpost which was previously only "possible" under windows  :D.
(See the jumalauta färjanmaker: https://www.pouet.net/prod.php?which=77751)

EDIT: On that note, how would people feel about being greeted in the first release using this brand-new-state-of-the-art demotool?
i use arch btw

axel18

  • Newbie
  • Posts: 4
Re: How to render a TTF to a Bitmap
« Reply #3 on: September 08, 2024, 07:31:04 pm »
hi,

you can use a game engine (raylib engine). you can load and write all ttf in the image screen and after you can use all tools of this engine  to create and save what you want in bitmap.

 

TinyPortal © 2005-2018