Discussions related to Visual Prolog
User avatar
Ferenc Nagy
VIP Member
Posts: 215
Joined: 24 Apr 2007 12:26

The procedure fontCreateByName does not set some bytes of the font structure

Unread post by Ferenc Nagy »

I tried to extract from the font structure whether the font is monospace or proportional.
I could do it based on descriptions of the LOGFONT structure only if the font was selected by vpiCommonDialogs::getFont. The procedure fontCreateByName does not set some bytes of the font structure. Here are the differences

Code: Select all

The message font is Andale Mono. Byte      Source    FontGetByCommonDial   FontCreatedByName Difference v- Index  Size ->                    92                  92          0   23                        255         y        1 special  Different 24                          1 special          0 special  Different 25                          2 special          0 special  Different 26                          1 special          0 special  Different 27                         49         1        0 special  Different
Sorry to say, according to http://msdn.microsoft.com/en-us/library ... 22837.aspx byte 27 contains the required info.
typedef struct tagLOGFONT {
00-03 LONG lfHeight;
04-07 LONG lfWidth;
08-11 LONG lfEscapement;
12-15 LONG lfOrientation;
16-19 LONG lfWeight;
20 BYTE lfItalic;
21 BYTE lfUnderline;
22 BYTE lfStrikeOut;
23 BYTE lfCharSet;
24 BYTE lfOutPrecision;
25 BYTE lfClipPrecision;
26 BYTE lfQuality;
27 BYTE lfPitchAndFamily;
28-... TCHAR lfFaceName[LF_FACESIZE];
} LOGFONT;
Member Value Description
FamilyDecorative 80 Specifies a novelty font; for example, Old English.
FamilyScript 64 Specifies a font that is designed to look like handwriting; for example, Script and Cursive.
FamilyModern 48 Specifies a monospace font with or without serifs. Monospace fonts are usually modern; examples include Pica, Elite, and Courier New.
FamilySwiss 32 Specifies a proportional font without serifs; for example, Arial.
FamilyRoman 16 Specifies a proportional font with serifs; for example, Times New Roman.
FamilyDoNotCare 0 Specifies a generic family name, which is used when information about a font does not exist or does not matter. The default font is used.
MonoFont 8 Specifies a monospace font.
VariablePitch 2 Specifies a variable-pitch font.
FixedPitch 1 Specifies a fixed-pitch font.
DefaultPitch 0 Specifies default pitch.

Code: Select all

predicates   % 2014.10.22. Is the font monospace or proportional?     fontClass:() -> font_class procedure.       fontClassAux:(unsigned8 PitchAndFamily, unsigned8 Eigth) -> font_class procedure.   clauses     fontClass()=fontClassAux(PitchAndFamily,PitchAndFamily div 8) :-          F=selectedFont,          PitchAndFamily=binary::getIndexed_unsigned8(F,27),          succeed().       fontClassAux(0,_)=fontClassFromCreation :-          !.     fontClassAux(_,1)=monospace :-          !.     fontClassAux(_,6)=monospace :-          !.     fontClassAux(_,_)=proportional.  
Here fontClassFromCreation is a fact set by a constructor

Code: Select all

new_by_other_font_descriptor(fo(FontName,SSName,FontClass,IsBold,IsUnderlined,IsItalic,Size)) :-         fontClassFromCreation:=FontClass,
TIA, Regards,
Frank Nagy
User avatar
Thomas Linder Puls
VIP Member
Posts: 1400
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

The LOGFONT structure specifies a logical font, not a physical font.

The LOGFONT is a "query" for a font. Windows will attempt to find a Physical font that matches the LOGFONT.

The getFont dialog look at physical fonts that installed on the computer and creates a LOGFONT structure that contains all the properties derived from the physical font.

createFontByName just creates a LOGFONT structure with name and size.
Regards Thomas Linder Puls
PDC
Post Reply