Recent

Author Topic: ttf under console-graphic fp program ?  (Read 1733 times)

Magortaltos

  • Newbie
  • Posts: 3
ttf under console-graphic fp program ?
« 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');

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: ttf under console-graphic fp program ?
« Reply #1 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.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11382
  • FPC developer.
Re: ttf under console-graphic fp program ?
« Reply #2 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
« Last Edit: May 28, 2020, 01:17:37 pm by marcov »

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: ttf under console-graphic fp program ?
« Reply #3 on: May 28, 2020, 01:26:27 pm »
I googled a bit, and a ttf to chr converter can be found here

Though that seems to be a tool that needs to be paid for?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11382
  • FPC developer.
Re: ttf under console-graphic fp program ?
« Reply #4 on: May 28, 2020, 02:04:34 pm »
I googled a bit, and a ttf to chr converter can be found here

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.

julkas

  • Guest
Re: ttf under console-graphic fp program ?
« Reply #5 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

Magortaltos

  • Newbie
  • Posts: 3
Re: ttf under console-graphic fp program ?
« Reply #6 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
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

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?

Thaddy

  • Hero Member
  • *****
  • Posts: 14197
  • Probably until I exterminate Putin.
Re: ttf under console-graphic fp program ?
« Reply #7 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.)
« Last Edit: June 01, 2020, 08:05:50 am by Thaddy »
Specialize a type, not a var.

Magortaltos

  • Newbie
  • Posts: 3
Re: ttf under console-graphic fp program ?
« Reply #8 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