Page 1 of 1

Font Binary as Constant in code

Posted: 23 Jan 2016 0:21
by Harrison Pratt
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

Possible but not recommended

Posted: 23 Jan 2016 13:07
by Ferenc Nagy
I think you'd better define default_font_name, default_font_size, ... constants and define the default font using fontCreate() and fontSetAttrs() commands.

Posted: 23 Jan 2016 14:50
by Thomas Linder Puls
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

Posted: 24 Jan 2016 14:40
by Harrison Pratt
Thank you for the explanation, Thomas!