Lazarus
Free Pascal => Beginners => Topic started by: Magortaltos on May 27, 2020, 10:43:43 pm
-
I working console-graphic fp program under Linux.
How can I use ttf fonts instead chr?
Like this:
Uses ptcgraph;
...
InitGraph(gd, gm, '');
OutTextXY(100,100,'Test Text');
-
The Graph units only support the CHR format. You'll either have to find a converter from TTF to CHR or you'll need to draw the fonts yourself.
-
Or maybe use fcl-image (which contains freetype?) to render bmps of the texts you want to show. Showing fancy rendered text like that is often used in game menus.
chr files are stroked fonts, which are basically vector fonts using straight lines only. TTF are afaik based on bezier splines.
I googled a bit, and a ttf to chr converter can be found here (https://digilander.libero.it/pnavato/EasyFonts/)
-
I googled a bit, and a ttf to chr converter can be found here (https://digilander.libero.it/pnavato/EasyFonts/)
Though that seems to be a tool that needs to be paid for?
-
I googled a bit, and a ttf to chr converter can be found here (https://digilander.libero.it/pnavato/EasyFonts/)
Though that seems to be a tool that needs to be paid for?
It seems to be shareware. So you could at least try it. But anyway, the clue is that CHR are stroked fonts or stroke-based fonts (which should not be confused with so called stroked TTF fonts). Searching on stroked fonts and or ".chr " and or "BGI" makes you find things like it.
I converted the few GRAPH applications I had to Opengl a couple of years ago. There I now use signed distance fonts.
-
I working console-graphic fp program under Linux.
How can I use ttf fonts instead chr?
Alternative - ttf to Pascal arrays - https://github.com/JulStrat/ttf2ugui
-
Or maybe use fcl-image (which contains freetype?) to render bmps of the texts you want to show. Showing fancy rendered text like that is often used in game menus.
chr files are stroked fonts, which are basically vector fonts using straight lines only. TTF are afaik based on bezier splines.
I googled a bit, and a ttf to chr converter can be found here (https://digilander.libero.it/pnavato/EasyFonts/)
Or maybe use fcl-image (which contains freetype?) to render bmps of the texts you want to show. Showing fancy rendered text like that is often used in game menus.
chr files are stroked fonts, which are basically vector fonts using straight lines only. TTF are afaik based on bezier splines.
I googled a bit, and a ttf to chr converter can be found here (https://digilander.libero.it/pnavato/EasyFonts/)
Thank you very much!
Okay, I'd like to switch to fcl graphics. I want to write, draw on the screen, use a mouse, save a screen like with the ptcgraph unit...
I can see that the two don't like each other:
uses FPCanvas, ptcgraph;
Ok.
But the flc does not print anything to the screen. Just save to a file:
https://wiki.freepascal.org/fcl-image
Can I draw and write on the screen with fcl?
-
Your best bet is to simply use opengl. (opengl can be configured to run from a terminal and even without any x renderer.)
-
Your best bet is to simply use opengl. (opengl can be configured to run from a terminal and even without any x renderer.)
Excellen! Let's opengl...
What do I need to write into this program to see the circle as well?
{$mode objfpc}{$h+}
program demo;
uses classes, sysutils,
FPImage, FPCanvas, FPImgCanv;
var canvas : TFPcustomCanvas;
image : TFPCustomImage;
begin
image := TFPMemoryImage.Create (100,100);
Canvas := TFPImageCanvas.Create (image);
{ Draw a circle }
canvas.Ellipse (10,10, 90,90);
{ Clean up! }
Canvas.Free;
image.Free;
end.