Forum > General

How to render a TTF to a Bitmap

(1/1)

MMarie:
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?

jamie:
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.

MMarie:

--- Quote from: jamie 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.

--- End quote ---

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.


--- Quote from: jamie on September 06, 2024, 10:38:28 pm ---At least that would be cross platform!

--- End quote ---

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?

axel18:
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.

Navigation

[0] Message Index

Go to full version