Recent

Author Topic: ttf under console-graphic fp program ?  (Read 767 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: 1766
  • 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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8496
  • 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: 1766
  • 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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8496
  • 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

  • Hero Member
  • *****
  • Posts: 606
  • KISS principle / Lazarus 2.0.6 / FPC 3.0.4
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
procedure mulu64(a, b: QWORD; out clo, chi: QWORD); assembler;
asm
  mov rax, a
  mov rdx, b
  mul rdx
  mov [clo], rax
  mov [chi], rdx
end;

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: 10213
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 »
I am more like donkey than shrek

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