GLBasic forum

Main forum => GLBasic - en => Topic started by: Drex on 2021-Jun-27

Title: True Type Fonts
Post by: Drex on 2021-Jun-27
Hi,

Have been using the trial version of GLbasic for about a year, so have been loading fonts, in the .png format.

I have just purchased the steam version, which says, it supports .ttf fonts, but I can't get them to load.

Can anyone, point me in the right direction ?

Thanks.
Title: Re: True Type Fonts
Post by: Qedo on 2021-Jun-27
I confirm I tried it but it doesn't work
Title: Re: True Type Fonts
Post by: Drex on 2021-Jun-27
Thanks for the reply……

I don’t understand, as it’s advertised, as supported in version 1.6 ?

Oh well, back to steam for a refund, what a waste of time.
Title: Re: True Type Fonts
Post by: Qedo on 2021-Jun-27
if I were you I would wait. Surely the GLB update will come out in a while. Somewhere in the forum I read that there will be and then ..... an excellent language like GLB cannot be discarded for a lack, even if temporary. I'm having a lot of fun with this language
Title: Re: True Type Fonts
Post by: Drex on 2021-Jun-27
I'm  having fun too, with GLbasic.....

I tried Python for a little while, but found it too slow, so I am switching between GLbasic & Javascript\p5.js.

The one downside to using Javascript is, that everything has to be done in the browser window, which can get annoying
at times, but it does support .ttf fonts :)

Hopefully they will implement .ttf in GLbasic soon, still can't understand why it is advertised as being in version 1.6 though  ::)

Title: Re: True Type Fonts
Post by: Qedo on 2021-Jun-28
Counterorder ..... :S

tried with GLB 16,793 and it works.

LOADFONT "FORTE_system.TTF", 1
SETFONT 1.3
PRINT "Print TTF font", 0,0,1 // GLBasic IDE, Version: 16,793
SHOWSCREEN
MOUSEWAIT
END

only it seems with other zoon values, in example 3, the quality is not high

ad maiora
Title: Re: True Type Fonts
Post by: Qedo on 2021-Jun-28
and also works with the third color parameter.
Great
 =D
Title: Re: True Type Fonts
Post by: dreamerman on 2021-Oct-21
Please dont get me wrong but bug happens to everyone, or I would quote now popular catch phrase "mistakes were made" :-)
If you see that something isn't working as it should/feature isn't complete or something post it on forum, such things could get unnoticed. TTF or custom font face swapping is nice but for simpler multi-language support I'm sticking to sprite fonts - much easier to prepare let's say Chinese buttons for small games without messing with Unicode. TTF also has its place and it's own strength.
One good thing in JS is no compilation time, and instant preview for small things, good way is to write small parts of code in JS to check everything and later translate that to final programming language.
Title: Re: True Type Fonts
Post by: dreamerman on 2022-Jan-20
Recently I checked few standard TTF font's and they are working properly, higher scale value shows not highest quality (as Qedo mentioned) but it's sufficient for most use cases. Didn't check some more artistic fonts from web, so maybe there are additional limits, but can't say that.

But I'm bumping this from other TTF related reason. Is there a 'simple' way to display/render UTF8 text with use of TTF fonts (or some other trick) in GLB? Standard bitmap font is limited to 128/256 characters, and TTF font's also have such 256 char limit.
For static/predefined text (like menu, buttons, labels) I'm using auto-generated earlier bitmaps, so I can have any language versions that I want.
The deal is to display runtime defined text, like user nicknames from for example Steam Leaderboards where entries are encoded in UTF8 and can contain national specific characters (like Chinese, Russian and so on). Simplest thing will be just replace any-non-standard-char with '?' but this may look bad :D Is there any work around for that, anyone has some clever function that will convert UTF8 to ASCII using extended 256 character set, so at least west Europe languages would be covered by it?

There are some crazy workarounds but all have some negatives:
- use php server to generate bitmap with proper coding/charset, based on input UTF8 string, GLB would download such bitmap and display it, this would increase server load and take some from transfer limit,
- include small local native app, that would do same as above script, but it's solution only for Windows,
- port FreeType (https://freetype.org) lib (that's powering SDL_ttf) to GLB, quite big task just to have nice highscores in a game,
- or maybe something smaller like this lib: Font Stash (https://github.com/akrinke/Font-Stash),
Most likely if there will be no simple solution I will stick to '?' replacement, hopefully with adding player avatars to mitigate the issue.