FBTrueType static Win/Lin 32/64-bit

Headers, Bindings, Libraries for use with FreeBASIC, Please include example of use to help ensure they are tested and usable.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

FBTrueType static Win/Lin 32/64-bit

Post by D.J.Peters »

preview of FBTrueType ASCII and Unicode (no dependencies too Freetype6 or other dynamic libraries)

This version used the original stb_truetype.h it's public domain and I added FBGFX image functionality.

download: FBTrueType.zip from: Oct 27, 2022
download: FBTrueType-src.zip

NOTE: Don't open/edit TTPrintWString.bas with FBIde you need an editor that can work with Unicode strings like geany or others !

Joshy
Image
Image
Last edited by D.J.Peters on Oct 27, 2022 5:38, edited 16 times in total.
srvaldez
Posts: 3373
Joined: Sep 25, 2005 21:54

Re: preview: FBTrueType Windows and Linux (32/64-bit)

Post by srvaldez »

hi Joshy
that looks really good, thanks for sharing :)
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: preview: FBTrueType Windows and Linux (32/64-bit)

Post by D.J.Peters »

I'm really happy about the quality and speed.

Joshy

Test of height = 800 pixels:
Image
Image
Last edited by D.J.Peters on Oct 12, 2022 18:12, edited 2 times in total.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FBTrueType Windows and Linux (32/64-bit)

Post by D.J.Peters »

I switched to stb_truetype.h the quality are the same but it's faster then my try and I added FBGFX image functionality. (see first post)

I added TTPrint()

Joshy
Image
Last edited by D.J.Peters on Oct 12, 2022 18:12, edited 9 times in total.
St_W
Posts: 1619
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: FBTrueType Windows and Linux (32/64-bit)

Post by St_W »

With source now, great! (btw the source-package link in the first post points to the wrong file)
Font rendering always has been a major weakness of fbgfx2, so this is a great contribution.
Thank you for sharing!

I'll give it a try on the weekend.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FBTrueType Windows and Linux (32/64-bit)

Post by D.J.Peters »

@St_W thank you.

The link to source code should work now

Joshy
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FBTrueType Windows and Linux (32/64-bit)

Post by D.J.Peters »

I fixed a small bug in test04.bas it's in the new zip file.

Joshy
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FBTrueType Windows and Linux (32/64-bit)

Post by D.J.Peters »

here are TTPrint overloaded with wstring

note: FBIDE doesn't support unicode strings I used geany for "TTPrintWString.bas".

The russian and greek "hello world" wstrings comes from FreeBASIC unicode examples.

Joshy
Image
Last edited by D.J.Peters on Oct 12, 2022 18:12, edited 4 times in total.
St_W
Posts: 1619
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: FBTrueType Windows and Linux (32/64-bit)

Post by St_W »

I took a quick look into the stb_truetype.h you're using and saw that e.g. hinting is still on the TODO list, which may be a problem when using small font sizes and/or small (display) resolutions.

As an external library ist still required (linked statically, only at compile time) I asked myself what are the pros/cons of using e.g. FreeType as a "backend" for your library instead of stb_truetype.h (because FreeType supports e.g. hinting and many other features). Maybe you could give a short explanation? Is this even possible?
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FBTrueType Windows and Linux (32/64-bit)

Post by D.J.Peters »

St_W wrote:... because FreeType supports e.g. hinting and many other features ...
To place glyphs on the right position I need only ascend, descend, linegap and kerning
italic and bold comes from the font self what is "hinting" and which other feature do you need ?

If you remove all unsed parts (the backed OpenGL quad rendering stuff, and codepoint calls) from stb_truetype.h it's only 6 KB that grows up the *.exe.

Joshy
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FBTrueType Windows and Linux (32/64-bit)

Post by D.J.Peters »

I found "font hinting" never heard before:-)

https://en.wikipedia.org/wiki/Font_hinting
https://www.microsoft.com/typography/Tr ... gWhat.mspx

May be you need it for high quality desktop publishing or word processor but for other apps or GUI's I personaly don't need it.

joshy
Image
Last edited by D.J.Peters on Oct 12, 2022 18:12, edited 2 times in total.
Roland Chastain
Posts: 993
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: FBTrueType Windows and Linux (32/64-bit)

Post by Roland Chastain »

Great! Thank you for that library.

There is a typo in the name of the FontProperties() function (and also, by the way, in the name of the file pocketcalculator.ttf).
Roland Chastain
Posts: 993
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: FBTrueType Windows and Linux (32/64-bit)

Post by Roland Chastain »

I have a problem with test05.bas. It's under Windows 10. I saved the code in Notepad++ with default encoding (UTF-8 without BOM).
Last edited by Roland Chastain on Oct 06, 2016 7:49, edited 1 time in total.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: FBTrueType Windows and Linux (32/64-bit)

Post by D.J.Peters »

@Roland the FreeBASIC wstring is unicode 2 bytes per char on windows 4 bytes on linux not UTF8 (so far I know) may be i'm wrong
I'm a german and never used wstring before ASCII codes only :-)

Joshy

How this two lines looks in notepad ?

Code: Select all

dim as wstring * 20 russian = "Привет, мир!"
dim as wstring * 20 greek   = "Καλημέρα κόσμε!"
Roland Chastain
Posts: 993
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: FBTrueType Windows and Linux (32/64-bit)

Post by Roland Chastain »

The two lines look correct in Notepad++ (I can see the russian and greek characters).

After I read your message, I tried to convert my file (using Notepad++) to UTF-16BE, and now the the program display correctly the characters. I also tried UTF-16LE, and it works too. Why is there no difference between UTF-16BE and UTF16-LE?
Post Reply