Lazarus

Free Pascal => Beginners => Topic started by: Magortaltos on May 27, 2020, 10:43:43 pm

Title: ttf under console-graphic fp program ?
Post 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');
Title: Re: ttf under console-graphic fp program ?
Post by: PascalDragon on May 28, 2020, 12:08:23 pm
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.
Title: Re: ttf under console-graphic fp program ?
Post by: marcov on May 28, 2020, 12:33:17 pm
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/)
Title: Re: ttf under console-graphic fp program ?
Post by: PascalDragon on May 28, 2020, 01:26:27 pm
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?
Title: Re: ttf under console-graphic fp program ?
Post by: marcov on May 28, 2020, 02:04:34 pm
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.
Title: Re: ttf under console-graphic fp program ?
Post by: julkas on May 28, 2020, 02:54:57 pm
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
Title: Re: ttf under console-graphic fp program ?
Post by: Magortaltos on May 31, 2020, 11:32:57 pm
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?
Title: Re: ttf under console-graphic fp program ?
Post by: Thaddy on June 01, 2020, 08:02:18 am
Your best bet is to simply use opengl. (opengl can be configured to run from a terminal and even without any x renderer.)
Title: Re: ttf under console-graphic fp program ?
Post by: Magortaltos on June 01, 2020, 04:29:59 pm
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.
TinyPortal © 2005-2018