Author Topic: TTF - True Type Fonts  (Read 8733 times)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10859
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
TTF - True Type Fonts
« on: 2018-Mar-24 »
The attached library can load converted TTF fonts and render them in real time. This gives the option to dynamically scale fonts and use colours.
I've not done any performance tests on mobile devices, yet.

I also attached a tiny command line program that generates the font from your installed ttf files in windows.
Just run:
TTF-create.exe arial
and it will create an arial.glbvf file (GLBasic Vector Font).
Characters 33 to 255 are supported. The font must be available as C:\Windows\Fonts\****.ttf


Offline erico

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 4453
    • View Profile
    • FUED
Re: TTF - True Type Fonts
« Reply #1 on: 2018-Mar-24 »
Nice! Thanks Kitty! :good:
I´m sure going to give a go with it as soon as I finish current project.

Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4176
  • On the shoulders of giants.
    • View Profile
    • My Apps
Re: TTF - True Type Fonts
« Reply #2 on: 2018-Mar-27 »
Thanks Gernot :)
I came. I saw. I played.

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2795
    • View Profile
Re: TTF - True Type Fonts
« Reply #3 on: 2018-Mar-28 »
Thank you Gernot. Very timely as I was current pondering how to support foreign fonts in my game. The answer, not easily. This should give me a decent option.  :good:
Cheers,

Ian.

“It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration.”
(E. W. Dijkstra)

Offline adaz

  • Mc. Print
  • *
  • Posts: 48
    • View Profile
Re: TTF - True Type Fonts
« Reply #4 on: 2018-Apr-03 »
Thanks Gernot! Probably it's worth rewriting my font engine in my upcoming game.

Offline Qedo

  • Dr. Type
  • ****
  • Posts: 389
  • to program what I have do how should programming?
    • View Profile
Re: TTF - True Type Fonts
« Reply #5 on: 2018-Jul-07 »
Thanks Gernot for this font engine.
I ask you if you can increase the font resolution that seems very low as you can see from the image. For example, the letter "g" is not rounded as it should be. Is it possible to work on generating the glbvf file?

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5116
  • O Rly?
    • View Profile
Re: TTF - True Type Fonts
« Reply #6 on: 2018-Jul-09 »
in TTF.gbas:

Code: (glbasic) [Select]
FUNCTION pt2px: pt
// points = pixels * 72 / dpi
STATIC dpi = PLATFORMINFO$("DPI")
RETURN pt / 72.0 * dpi  * 50.0 // this factor is by try/error
ENDFUNCTION

I guess you have to change the DPI in the Editor itself?
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline Qedo

  • Dr. Type
  • ****
  • Posts: 389
  • to program what I have do how should programming?
    • View Profile
Re: TTF - True Type Fonts
« Reply #7 on: 2018-Jul-10 »
It does not work.
I think it depends on how the font was triagolarized previously in the glbvf file

Offline MrPlow

  • Prof. Inline
  • *****
  • Posts: 1826
    • View Profile
Re: TTF - True Type Fonts
« Reply #8 on: 2018-Nov-20 »
I haven't tried this yet - but could be very useful for a game I am planning.
On this font system - can the fonts be relocated to the media/fonts/ ?
That way its isn't dependant on the windows setup of the machine?
Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

Offline Schranz0r

  • Premium User :)
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 5116
  • O Rly?
    • View Profile
Re: TTF - True Type Fonts
« Reply #9 on: 2018-Nov-21 »
I guess Gernot use SDL_TTF for it.
He need to change the

Code: (glbasic) [Select]
ttf_rendertext_solid
to

Code: (glbasic) [Select]
ttf_rendertext_shaded
then it's smooth :)
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10859
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: TTF - True Type Fonts
« Reply #10 on: 2019-Jul-04 »
I must use finer resolution internally. And I also must pre-render the glyphs to a bitmap. It is just to slow in real time.