DEFINE FONT vs TFont()

Re: DEFINE FONT vs TFont()

Postby karinha » Mon Dec 18, 2017 1:10 pm

Se comprendo...

Code: Select all  Expand view  RUN

// Some tests with fonts capabilities

#include "FiveWin.ch"

Function Main()

   LOCAL oWnd, oSay, oSay2
   Local oFontCalibri12

   DEFINE FONT oFontCalibri12 NAME "Calibri" SIZE 0, -12

   DEFINE WINDOW oWnd FROM 1,5 TO 20,65 ;
       TITLE "Test font. oSay:oFont:lBold is always .t.!"

   @ 11.5,10 SAY oSay PROMPT "Is this bold... Font Calibri12 ?" // FONT oFontCalibri12

   @ 10,10 SAY oSay2 ;
           PROMPT "Is this bold now?" OF oWnd

  @ 2,10 BUTTON "Change Font";
         SIZE 100,50;
         ACTION ( ( oSay2:SelFont() ), oSay2:Refresh() ) OF oWnd

   @ 2,40 BUTTON "Bold?" SIZE 100,50;
          ACTION MsgInfo(If(oSay:oFont:lBold,"Yes, oSay:oFont:lBold says it's BOLD!","NOT BOLD, OK?")) OF oWnd

   SET FONT OF oSay TO oFontCalibri12

   ACTIVATE WINDOW oWnd

   oFontCalibri12:End()

RETURN NIL
 


Saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7835
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: DEFINE FONT vs TFont()

Postby nageswaragunupudi » Mon Dec 18, 2017 3:07 pm

Es una inquietud que tengo... y viene de la primera vez que probé FW, que los trazos de letra no estan bien trazados por decirlo de una manera, la definicion es mas 'basta'. Es como si FW utilizara un 'pinzel' y dibujara la letra en lugar de coger la fuente en si.

Fonts are not generated by FWH. FWH calls Windows API CreateFont( <params> ) and Windows creates the fonts.
FWH does not draw fonts on the screen, it is Windows OS that draws the font on the screen.
What we see on the screen is what is rendered by Windows.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10656
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: DEFINE FONT vs TFont()

Postby hmpaquito » Mon Dec 18, 2017 3:27 pm

is fwh using newer CreateFontIndirectEx which includes additional parameters ?
hmpaquito
 
Posts: 1482
Joined: Thu Oct 30, 2008 2:37 pm

Re: DEFINE FONT vs TFont()

Postby nageswaragunupudi » Mon Dec 18, 2017 4:08 pm

CreateFontIndirect() uses LOGFONT structure.
CreateFontIndirectEx() uses ENUMLOGFONTEX structure. This structure basically contains LOGFONT structure and in addition 3 members:
TCHAR elfFullName[LF_FULLFACESIZE];
TCHAR elfStyle[LF_FACESIZE];
TCHAR elfScript[LF_FACESIZE];
You can read more in the documentation.
May we know what are the additional members you propose to use and what purpose and then we see how to accommodate your requirement.
In our opinion all the important specifications of a font are already covered by LOGFONT structure.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10656
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: DEFINE FONT vs TFont()

Postby nageswaragunupudi » Tue Dec 19, 2017 1:58 am

Mr Karinha

In the sample you posted, the font of oSay2 is changed.
So, in the next button action you should write If( oSay2:oFont:lBold but not If( oSay:oFont:lBold
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10656
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: DEFINE FONT vs TFont()

Postby nageswaragunupudi » Tue Dec 19, 2017 7:49 am

TFont():New( cFaceName, nWidth, nHeight, lFromUser, lBold,;
nEscapement, nOrientation, nWeight, lItalic, lUnderline,;
lStrikeOut, nCharSet, nOutPrecision, nClipPrecision,;
nQuality, oDevice, nPitchFamily )


creates a font with exactly the same parameters using Windows function CreateFont().
CreateFontIndirect() uses LOGFONT structure with the same values to create a font. Both functions result in the same font. TFont class constructor is a wrapper to the CreateFont() function.

So the font created by using TFont():New() can not be different from any font created by any other library using the same values.

Recommended reading:
https://msdn.microsoft.com/en-us/librar ... 83499.aspx

In particular, please also read about the usage of positive and negative values for the height while creating the fonts.

Creation of font of the same size as in MS Office:
In Excel, MSWord, etc, the font sizes are specified in Points. These sizes need to converted into pixels by multiplying by -4/3 for specifying the height in function CreateFont() or TFont():New().

To get equivalent of Calibri(12) of Excel, use DEFINE FONT NAME "Calibri" SIZE 0,-16.

Code: Select all  Expand view  RUN
plf->lfHeight = -MulDiv (nPtSize, GetDeviceCaps (hdc, LOGPIXELSY), 72);


To be precise: GetDeviceCaps( GetDC(0), LOGPIXELSY )/ 72
This is equal to 96/72 --> 4/3.

Recommended reading to understand this logic well:
https://support.microsoft.com/en-in/hel ... -of-a-font
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10656
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Previous

Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 35 guests