Font Binary as Constant in code

Discussions related to Visual Prolog
Harrison Pratt
VIP Member
Posts: 285
Joined: 5 Nov 2000 0:01

Font Binary as Constant in code

Unread post by Harrison Pratt » 23 Jan 2016 0:21

Is it possible to include a font binary in VIP source code in a way analogous to that below? This approach causes syntax errors.

Code: Select all

constants       defaultGraphWinFont : font = $[F0,FF,FF,FF,00,00,00,00,00,00,00,00,00,         00,00,00,90,01,00,00,00,00,00,00,03,02,01,31,41,00,6E,00,64,00,61,         00,6C,00,65,00,20,00,4D,00,6F,00,6E,00,6F,00,00,00,00,00,00,00,00,         00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,         00,00,00,00,00,00,00,00,00,00,00,00,00].         % Font Name: Andale Mono        Flags: []       Size: 12

User avatar
Ferenc Nagy
VIP Member
Posts: 289
Joined: 24 Apr 2007 12:26

Possible but not recommended

Unread post by Ferenc Nagy » 23 Jan 2016 13:07

I think you'd better define default_font_name, default_font_size, ... constants and define the default font using fontCreate() and fontSetAttrs() commands.
TIA, Regards,
Frank Nagy

User avatar
Thomas Linder Puls
VIP Member
Posts: 1624
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls » 23 Jan 2016 14:50

A vpiDomains::font (binary) is the same as a Windows LOGFONT and a gui_native::logfont:

Code: Select all

domains     logfont =         logfont(             integer Height,             integer Width,             integer Escapement,             integer Orientation,             integer Weight,             unsigned8 Italic,             unsigned8 Underline,             unsigned8 StrikeOut,             unsigned8 CharSet,             unsigned8 OutPrecision,             unsigned8 ClipPrecision,             unsigned8 Quality,             unsigned8 PitchAndFamily,             string FaceName [inline(lf_facesize)]).     % @short See LOGFONT in MSDN.     % @end
With the small but important difference that it is a binary (meaning that a vpiDomains::font must have a length field just before the actual LOGFONT structure (because a binary must have such one)).

There is nothing wrong with creating these directly or saving/restoring them from files, registry, etc.

Also notice the vpiDomains functions:

Code: Select all

predicates     toFont_logfont : (gui_native::logfont Logfont) -> font Font.     % @short Converts logfont #Logfont to font #Font (only creates a copy if necessary).     % @end   predicates     fromFont_logfont : (font Font) -> gui_native::logfont Logfont.     % @short Converts a font #Font to logfont #Logfont.     % @end
Regards Thomas Linder Puls
PDC

Harrison Pratt
VIP Member
Posts: 285
Joined: 5 Nov 2000 0:01

Unread post by Harrison Pratt » 24 Jan 2016 14:40

Thank you for the explanation, Thomas!

Post Reply