Fonts Explanation
Fonts Explanation
DEFINE FONT oFont NAME "Aerial" SIZE 0, - 8 OF oPrn
I understand the above line to be Font size 8.
oFont:nSize() tells me 50
oFont:nWidth() tells me 29.3333
oFont:nHeight() tells me 66.67
but if I :
DEFINE FONT oFont NAME "Aerial" SIZE 29.3333, 66.67 OF oPrn
oFont:nSize() tells me -416.44
oFont:nWidth() tells me 29.3333
oFont:nHeight() tells me 555.5833
Why is that?
I want to store the font (name, size, bold etc) in a DBF file. What am I doing wrong?
I understand the above line to be Font size 8.
oFont:nSize() tells me 50
oFont:nWidth() tells me 29.3333
oFont:nHeight() tells me 66.67
but if I :
DEFINE FONT oFont NAME "Aerial" SIZE 29.3333, 66.67 OF oPrn
oFont:nSize() tells me -416.44
oFont:nWidth() tells me 29.3333
oFont:nHeight() tells me 555.5833
Why is that?
I want to store the font (name, size, bold etc) in a DBF file. What am I doing wrong?
Many thanks
Ollie.
Using:
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)
Borland C++ 5.5.1
FWH 9.04 (2009 Apr)
Ollie.
Using:
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)
Borland C++ 5.5.1
FWH 9.04 (2009 Apr)
- James Bott
- Posts: 4840
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Ollie,
I think there may be some bugs in the font class.
If you do this:
DEFINE FONT oFont NAME "Aerial" SIZE 29.3333, 66.67 OF oPrn
Followed by this:
oFont:nHeight:= 66.67
Which theoretically should have no effect.
Then you get these:
oFont:nSize() returns -49.75
oFont:nWidth() returns 29.3333
oFont:nHeight() returns 66.67
I note that the nSize method is subtracting -.25 under some circumstances, which would account for the 49.75. Also it is multiplying by -1 under some circumstances.
Oh, and to add to the confusion, there are also oFont:nInpWidth and oFont:nInpHeight vars. I assume these are supposed to hold the values input via the New(), nWidth(), and nHeight() methods, but the values I find in them only adds to the confusion.
Perhaps this all has to do with the difference between size in points (a physical size) and size in pixels or dots per inch (size relative to the device).
However, I think Ollie wants to save a user defined font and restore it. I'm not sure we can do this.
Antonio, Enrico, any comments?
James
I think there may be some bugs in the font class.
If you do this:
DEFINE FONT oFont NAME "Aerial" SIZE 29.3333, 66.67 OF oPrn
Followed by this:
oFont:nHeight:= 66.67
Which theoretically should have no effect.
Then you get these:
oFont:nSize() returns -49.75
oFont:nWidth() returns 29.3333
oFont:nHeight() returns 66.67
I note that the nSize method is subtracting -.25 under some circumstances, which would account for the 49.75. Also it is multiplying by -1 under some circumstances.
Oh, and to add to the confusion, there are also oFont:nInpWidth and oFont:nInpHeight vars. I assume these are supposed to hold the values input via the New(), nWidth(), and nHeight() methods, but the values I find in them only adds to the confusion.
Perhaps this all has to do with the difference between size in points (a physical size) and size in pixels or dots per inch (size relative to the device).
However, I think Ollie wants to save a user defined font and restore it. I'm not sure we can do this.
Antonio, Enrico, any comments?
James
- Enrico Maria Giordano
- Posts: 8770
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Has thanked: 1 time
- Been thanked: 7 times
- Contact:
It sure would be.
I let the user select a font fontselect()
And then I want to save it, however, if the User chooses Arial 8 point,
I don't find that when I query the Font object. I get the heights and widths shown above.
If you can show me where the 0 amd -8 is found, that would be great.
I let the user select a font fontselect()
And then I want to save it, however, if the User chooses Arial 8 point,
I don't find that when I query the Font object. I get the heights and widths shown above.
If you can show me where the 0 amd -8 is found, that would be great.
Many thanks
Ollie.
Using:
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)
Borland C++ 5.5.1
FWH 9.04 (2009 Apr)
Ollie.
Using:
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)
Borland C++ 5.5.1
FWH 9.04 (2009 Apr)
- Enrico Maria Giordano
- Posts: 8770
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Has thanked: 1 time
- Been thanked: 7 times
- Contact:
I can't see the Size setting:
aFont := Choosefont()
IF EMPTY( aFont[ 14 ] )
aFont[ LF_HEIGHT ] := - 13
aFont[ LF_WIDTH ] := 0
aFont[ LF_ESCAPEMENT ] := 0
aFont[ LF_ORIENTATION ] := 0
aFont[ LF_WEIGHT ] := 400
aFont[ LF_ITALIC ] := .F.
aFont[ LF_UNDERLINE ] := .F.
aFont[ LF_STRIKEOUT ] := .F.
aFont[ LF_CHARSET ] := 0
aFont[ LF_OUTPRECISION ] := 3
aFont[ LF_CLIPPRECISION ] := 2
aFont[ LF_QUALITY ] := 1
aFont[ LF_PITCHANDFAMILY ] := 34
aFont[ LF_FACENAME ] := 'Arial'
is there a better way.
aFont := Choosefont()
IF EMPTY( aFont[ 14 ] )
aFont[ LF_HEIGHT ] := - 13
aFont[ LF_WIDTH ] := 0
aFont[ LF_ESCAPEMENT ] := 0
aFont[ LF_ORIENTATION ] := 0
aFont[ LF_WEIGHT ] := 400
aFont[ LF_ITALIC ] := .F.
aFont[ LF_UNDERLINE ] := .F.
aFont[ LF_STRIKEOUT ] := .F.
aFont[ LF_CHARSET ] := 0
aFont[ LF_OUTPRECISION ] := 3
aFont[ LF_CLIPPRECISION ] := 2
aFont[ LF_QUALITY ] := 1
aFont[ LF_PITCHANDFAMILY ] := 34
aFont[ LF_FACENAME ] := 'Arial'
is there a better way.
Many thanks
Ollie.
Using:
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)
Borland C++ 5.5.1
FWH 9.04 (2009 Apr)
Ollie.
Using:
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)
Borland C++ 5.5.1
FWH 9.04 (2009 Apr)
- Antonio Linares
- Site Admin
- Posts: 42655
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 67 times
- Been thanked: 96 times
- Contact:
- James Bott
- Posts: 4840
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Enrico and Antonio,
The problem is that he has a user created font and he needs to find the face name and point size. oFont:cFaceName works OK, but oFont:nSize() returns 50 for a point size of 8. What units is this 50? Is it a physical size or a device size (pixels or dots per inch). Can it be translated back to points? It would be better if it just returned the point size or if there was another method that did.
James
The problem is that he has a user created font and he needs to find the face name and point size. oFont:cFaceName works OK, but oFont:nSize() returns 50 for a point size of 8. What units is this 50? Is it a physical size or a device size (pixels or dots per inch). Can it be translated back to points? It would be better if it just returned the point size or if there was another method that did.
James
- Enrico Maria Giordano
- Posts: 8770
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Has thanked: 1 time
- Been thanked: 7 times
- Contact:
oFont:nSize() returns the expected value for me. Try this sample:
EMG
Code: Select all | Expand
#include "Fivewin.ch"
FUNCTION MAIN()
LOCAL oWnd
LOCAL cVar := "This is a test"
DEFINE WINDOW oWnd
@ 1, 1 SAY "This is a test";
COLOR CLR_BLACK
@ 3, 1 GET cVar;
SIZE 100, 20
@ 5, 1 BUTTON "Change font";
SIZE 100, 20;
ACTION CHANGEFONT( oWnd )
ACTIVATE WINDOW oWnd
RETURN NIL
STATIC FUNCTION CHANGEFONT( oWnd )
LOCAL oFont := oWnd:GetFont():Choose()
LOCAL i
? oFont:nSize()
oWnd:SetFont( oFont )
FOR i = 1 TO LEN( oWnd:aControls )
oWnd:aControls[ i ]:SetFont( oFont )
oWnd:aControls[ i ]:Refresh()
NEXT
RETURN NIL
EMG
- James Bott
- Posts: 4840
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Enrico,
Yes, your example does seem to work, but this example really adds to the confusion. If you select Arial, 8pt, then aFont contains nWidth=0, nHeight=-11. It seems to be returning an 11pt font. Then when you create a font using these parameters, then oFont:nSize returns 8 not 11 as expected.
So, it seems the user selected size being returned by chooseFont() is incorrect. It is also confusing since nWidth contains zero and nHeight is really supposed to be the point size, but it is incorrect.
Also, if you build a font using the SIZE clause with a point size, then nSize is not returning the correct point size (assuming that is what nSize is supposed to do).
James
Yes, your example does seem to work, but this example really adds to the confusion. If you select Arial, 8pt, then aFont contains nWidth=0, nHeight=-11. It seems to be returning an 11pt font. Then when you create a font using these parameters, then oFont:nSize returns 8 not 11 as expected.
So, it seems the user selected size being returned by chooseFont() is incorrect. It is also confusing since nWidth contains zero and nHeight is really supposed to be the point size, but it is incorrect.
Also, if you build a font using the SIZE clause with a point size, then nSize is not returning the correct point size (assuming that is what nSize is supposed to do).
James
Code: Select all | Expand
#include "fivewin.ch"
function main()
local oFont,aFont,oWnd, cFacename
define window oWnd
aFont:= chooseFont() // select Arial, 8pt
cFaceName:= aFont[LF_FACENAME]
nWidth:= aFont[LF_WIDTH]
nHeight:= aFont[LF_HEIGHT]
// msgInfo( aFont[LF_FACENAME])
msgInfo( nWidth ) // returns 0
msgInfo( nHeight ) // returns -11
DEFINE font oFont name cFaceName size nWidth, nHeight
activate window oWnd on init msgInfo( oFont:nSize )
return nil
- Enrico Maria Giordano
- Posts: 8770
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Has thanked: 1 time
- Been thanked: 7 times
- Contact:
- James Bott
- Posts: 4840
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Enrico,
>I think that you are confusing points with pixels.
Well, I mentioned that it is confusing since the docs don't state what units each of the methods is returning.
But, if you get back 0,-11 as the sizes when you choose an 8pt font, what does it mean? Is 11 the size in pixels? If so, for what device since no device was specified? Also, then how can you use this information to create an 8pt font?
What is useful is to use points since they are independent of the display device. If you saved the pixel dimensions from one device then tried to restore them for use on a different device you would, obviously, not get the same size font. Conversely, if you save the font size in points and then restore it in points, it will be the same size regardless of the display device.
James
>I think that you are confusing points with pixels.
Well, I mentioned that it is confusing since the docs don't state what units each of the methods is returning.
But, if you get back 0,-11 as the sizes when you choose an 8pt font, what does it mean? Is 11 the size in pixels? If so, for what device since no device was specified? Also, then how can you use this information to create an 8pt font?
What is useful is to use points since they are independent of the display device. If you saved the pixel dimensions from one device then tried to restore them for use on a different device you would, obviously, not get the same size font. Conversely, if you save the font size in points and then restore it in points, it will be the same size regardless of the display device.
James
- Enrico Maria Giordano
- Posts: 8770
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Has thanked: 1 time
- Been thanked: 7 times
- Contact:
- James Bott
- Posts: 4840
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
- Antonio Linares
- Site Admin
- Posts: 42655
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 67 times
- Been thanked: 96 times
- Contact: