CatchFont()

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Keya
Addict
Addict
Posts: 1890
Joined: Thu Jun 04, 2015 7:10 am

Re: CatchFont()

Post by Keya »

wilbert wrote:Unfortunately I don't know what function Fred uses to load the font.
my VM is having a hissy fit at the moment so i cant test but i would just create an empty OSX PB binary and then another with a call to LoadFont and check in hex editor which functions are added to the LaodFont one :)
chris319
Enthusiast
Enthusiast
Posts: 782
Joined: Mon Oct 24, 2005 1:05 pm

Re: CatchFont()

Post by chris319 »

In Windows I have found it is not always possible to get the font you want by using the font file name. You have to get the actual font name by going to font file -> properties -> details -> title. Perhaps a CatchFont() function could open fonts by passing the name of a valid font file, be it on the local disk or a network URL.

Under U.S. law, potential copyright issues arise when font data is transferred from one user's computer to another's. Even then, it depends if a font is commercially licensed or has a "libre" license. In any event, under U.S. law the character shapes/letterforms themselves are not protected under copyright.
tj1010
Enthusiast
Enthusiast
Posts: 716
Joined: Mon Feb 25, 2013 5:51 pm

Re: CatchFont()

Post by tj1010 »

chris319 wrote:In Windows I have found it is not always possible to get the font you want by using the font file name. You have to get the actual font name by going to font file -> properties -> details -> title. Perhaps a CatchFont() function could open fonts by passing the name of a valid font file, be it on the local disk or a network URL.

Under U.S. law, potential copyright issues arise when font data is transferred from one user's computer to another's. Even then, it depends if a font is commercially licensed or has a "libre" license. In any event, under U.S. law the character shapes/letterforms themselves are not protected under copyright.
http://www.purebasic.fr/english/viewtop ... 44#p483444

I'll just keep assuming PB team didn't write a font loader and just use the API loader which passes pointer references on all platforms.. No need for reverse engineering..

I always thought fonts were just scaled bitmaps..? I know that's how they are treated in low-level development like with BIOS and other firmware. The Windows TTF loader probably has some fancy raster algorithms for clean curves and scaling.
chris319
Enthusiast
Enthusiast
Posts: 782
Joined: Mon Oct 24, 2005 1:05 pm

Re: CatchFont()

Post by chris319 »

tj1010 wrote:
I always thought fonts were just scaled bitmaps..? I know that's how they are treated in low-level development like with BIOS and other firmware. The Windows TTF loader probably has some fancy raster algorithms for clean curves and scaling.
Truetype and Opentype fonts are very complicated, using cubic and quadratic splines and all kinds of things which are way over my head. In addition to the character outlines there are instructions for placing the glyph on the page/screen in relation to other characters.
User avatar
Keya
Addict
Addict
Posts: 1890
Joined: Thu Jun 04, 2015 7:10 am

Re: CatchFont()

Post by Keya »

if quadratic and bezier curves arent enough it seems TrueType fonts are also semi-programmable... very limited, but has for example conditional branching, variables, loops, and functions...
https://en.wikipedia.org/wiki/TrueType#Technical_notes
TrueType systems include a virtual machine that executes programs inside the font, processing the "hints" of the glyphs. These distort the control points which define the outline, with the intention that the rasterizer produces fewer undesirable features on the glyph. Each glyph's hinting program takes account of the size (in pixels) at which the glyph is to be displayed, as well as other less important factors of the display environment.

Although incapable of receiving input and producing output as normally understood in programming, the TrueType hinting language does offer the other prerequisites of programming languages: conditional branching (IF statements), looping an arbitrary number of times (FOR- and WHILE-type statements), variables (although these are simply numbered slots in an area of memory reserved by the font), and encapsulation of code into functions. Special instructions called delta hints are the lowest level control, moving a control point at just one pixel size.
Post Reply