Know the size of a font selected - Resolved -

Know the size of a font selected - Resolved -

Postby Silvio.Falconi » Thu Oct 29, 2020 9:17 am

I wish Know the size of the font selected and save on aGet[15]
it give me a bad number and then not insert it on get

Image

the test

Code: Select all  Expand view
#include "fivewin.ch"
#include "constant.ch"


Function Test()
Local oDlg,oFont,oBold
Local ObtnSel[10]
Local cFont:=""
Local nSizeFont:=0

       Local nBottom   := 22
       Local nRight    := 102
       Local nWidth :=  Max( nRight * DLG_CHARPIX_W, 180 )
       Local nHeight := nBottom * DLG_CHARPIX_H
       local aGet[20]
       local oSay[10]

    DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
      DEFINE FONT oBold NAME "TAHOMA" SIZE 0,-14 BOLD


DEFINE DIALOG oDlg        ;
   TITLE "test sel  font"     ;
   SIZE nWidth, nHeight   PIXEL  FONT oFont    ;
   STYLE nOr( DS_MODALFRAME, WS_POPUP, WS_CAPTION,  4 ) ;
   COLOR CLR_BLACK,  nRgb( 245,244,234)


   @ 116, 5   SAY oSay[6] Prompt "Carattere"  SIZE 80,14 PIXEL OF oDlg  TRANSPARENT  FONT oBold

   @ 126, 5   GET aGet[14] VAR cFont SIZE 200,12  PIXEL OF oDlg

   @ 126, 208 GET aGet[15] VAR nSizeFont SIZE 18,12  PIXEL OF oDlg

   @ 126, 228 BTNBMP oBtnSel[4]  RESOURCE "font.bmp"  FLAT SIZE 14, 12 OF oDlg PIXEL ;
                  COLOR  nRgb(238,236,219),nRgb(238,236,219) BORDER;
                  ACTION (aFont:=ChooseFont(),;
                     cFont :=aFont[LF_FACENAME],;
                     nSizeFont:= aFont[LF_HEIGHT ],;
                     msginfo( nSizeFont),;
                  aGet[14]:refresh(),aGet[15]:refresh())


ACTIVATE DIALOG oDLG CENTER
RETURN NIL
 
Last edited by Silvio.Falconi on Tue Nov 03, 2020 6:59 pm, edited 1 time in total.
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7053
Joined: Thu Oct 18, 2012 7:17 pm

Re: Know the size of a font selected

Postby Marc Venken » Thu Oct 29, 2020 11:13 pm

If you look into the aFont : there is no correct size from to font ? Strange...

For the save : it seems that the lenght of aGet[15] is to small to see it.
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1429
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Know the size of a font selected

Postby Silvio.Falconi » Fri Oct 30, 2020 7:50 am

I solved it in another way
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7053
Joined: Thu Oct 18, 2012 7:17 pm

Re: Know the size of a font selected

Postby Otto » Fri Oct 30, 2020 8:30 am

Hello Silvio,
would you be so kind to post the solution here.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6330
Joined: Fri Oct 07, 2005 7:07 pm

Re: Know the size of a font selected

Postby Silvio.Falconi » Fri Oct 30, 2020 8:37 am

I made a combobox for the fonts and another for the size from 6 to 99
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7053
Joined: Thu Oct 18, 2012 7:17 pm

Re: Know the size of a font selected

Postby nageswaragunupudi » Sun Nov 01, 2020 5:32 pm

ChooseFont() function of FWH is a straight forward implementation of Windows function ChooseFont().

The font size displayed in the ChooseFont() dialog box is in "Points". This size in points is converted to font height with this formula.
Code: Select all  Expand view

lfHeight = -MulDiv(PointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72)
 


https://docs.microsoft.com/en-us/window ... i-logfonta

To get the size in points, we need to use reverse formula.

Code: Select all  Expand view

function FontHeightInPoints( nHeight )

   local nPoints, hDC

   nPoints := Round( Abs( nHeight ) * 72 / GetDeviceCaps( hDC := GetDC( 0 ), 90 ), 0 )
   ReleaseDC( 0, hDC )

return nPoints
 
Regards

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

Re: Know the size of a font selected

Postby Silvio.Falconi » Tue Nov 03, 2020 9:58 am

nageswaragunupudi wrote:ChooseFont() function of FWH is a straight forward implementation of Windows function ChooseFont().

The font size displayed in the ChooseFont() dialog box is in "Points". This size in points is converted to font height with this formula.
Code: Select all  Expand view

lfHeight = -MulDiv(PointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72)
 


https://docs.microsoft.com/en-us/window ... i-logfonta

To get the size in points, we need to use reverse formula.

Code: Select all  Expand view

function FontHeightInPoints( nHeight )

   local nPoints, hDC

   nPoints := Round( Abs( nHeight ) * 72 / GetDeviceCaps( hDC := GetDC( 0 ), 90 ), 0 )
   ReleaseDC( 0, hDC )

return nPoints
 


Thanks Rao
But I not understood How call that function

ACTION (aFont:=ChooseFont(),;
cFont :=aFont[LF_FACENAME],;
nSizeFont:=FontHeightInPoints( aFont[LF_HEIGHT ]),;
aGet[14]:refresh(),aGet[15]:refresh())

run ok


I need also to Know these parameters

Font name
Font size
Color
Bold
Italic
Underlined
Strikethrough


why I not see the color of the font ????

Image
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7053
Joined: Thu Oct 18, 2012 7:17 pm

Re: Know the size of a font selected

Postby Otto » Tue Nov 03, 2020 10:56 am

Hello Silvio, please look into EasyReport. Here you see how to do. You have to change the pen before printing.

Best regards,
Otto


METHOD Say( nRow, nCol, cText, oFont, nWidth, nClrText, nBkMode, nPad ) CLASS VRD

IF ::oPrn:hDC = 0
RETURN NIL
ENDIF

DEFAULT oFont := ::oPrn:oFont
DEFAULT nBkMode := 1
DEFAULT nPad := 0

IF oFont != nil
oFont:Activate( ::oPrn:hDCOut )
ENDIF

// 1,2 transparent or Opaque
SetbkMode( ::oPrn:hDCOut, nBkMode )

IF nClrText != NIL
#IFDEF __HARBOUR__
SetTextColor( ::oPrn:hDCOut, nClrText )
#ELSE
SetTextCol( ::oPrn:hDCOut, nClrText )
#ENDIF
ENDIF

DO CASE
CASE nPad == 1 // right
nCol := Max( 0, nCol - ::GetTextWidth( cText, oFont ) )
CASE nPad == 2 // center
nCol := Max( 0, nCol - ( ::GetTextWidth( cText, oFont ) / 2 ) )
ENDCASE

TextOut( ::oPrn:hDCOut, nRow, nCol, cText )

IF oFont != nil
oFont:DeActivate( ::oPrn:hDCOut )
ENDIF

IF nClrText != NIL
#IFDEF __HARBOUR__
SetTextColor( ::oPrn:hDCOut, 0 )
#ELSE
SetTextCol( ::oPrn:hDCOut, 0 )
#ENDIF
ENDIF

RETURN ( NIL )
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6330
Joined: Fri Oct 07, 2005 7:07 pm

Re: Know the size of a font selected

Postby Silvio.Falconi » Tue Nov 03, 2020 12:44 pm

Otto wrote:Hello Silvio, please look into EasyReport. Here you see how to do. You have to change the pen before printing.

Best regards,
Otto




Perhaps you not understood what I mean

this Image is from web

Image

here , I not see bold... and color

when you make choosefont you must have

Font name
Font size
Color
Bold
Italic
Underlined
Strikethrough

I remember EasyReport save 20 type of font with 20 type of colors and it no good ( error )
on my app you can select any font you want and then it build a font when it print the text
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7053
Joined: Thu Oct 18, 2012 7:17 pm

Re: Know the size of a font selected

Postby Silvio.Falconi » Tue Nov 03, 2020 6:58 pm

resolved!!!
see the topic viewtopic.php?f=3&t=39554&start=0
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7053
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 90 guests