|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
FLEXPLAN3D
Joined: 25 Feb 2011 Posts: 27
|
Posted: Mon Oct 24, 2011 9:27 am Post subject: clearwin standard font size |
|
|
The height of the standard font used by clearwin depends on the size set in the windows win.ini file, and is set externally from the windows control panel as -small,medium or large.
The value set can be found in a clearwin program by using
clearwin_info@(SYSTEM_FONT_HEIGHT).
Using medium or larger font can cause positional and size problems with the various controls in clearwin windows that are designed with the default 16pixel high font.
Is there any way in which Clearwin can be forced to use the 16pixel high font as its standard font irrespective of the value set in the win.ini file. |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Mon Oct 24, 2011 10:19 pm Post subject: |
|
|
Strictly speaking, this ought to be one for the Clearwin forum.
You may find my thread "DPI Awareness" of some use, although you would be the first - no one has replied!
Eddie |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7924 Location: Salford, UK
|
Posted: Tue Oct 25, 2011 8:26 am Post subject: |
|
|
Try using %fh with CreateFont or similar API function. |
|
Back to top |
|
|
simon
Joined: 05 Jul 2006 Posts: 268
|
Posted: Fri Jun 02, 2017 2:38 am Post subject: |
|
|
Despite trying to follow the advice in the Help pages and in posts such as this, I am having no success in getting the default font size to change in ClearWin+ windows. I offer the following code as an illustration of my failings. It creates 3 separate windows: the first uses the default font; then after a call to a function that tries to increase the default font size by a factor of 20, the second window generates smaller output; the third creates slightly larger text. I have tried with and without local_font, and with and without %fh, and nothing changes.
Code: | Winapp
Program p
Use clrwin, Only: winio@
Integer, Parameter :: iout1 = 11
Integer, Parameter :: iout2 = 12
Integer, Parameter :: iout3 = 13
!
Integer :: iw, ic1, ic2, ic3
!
Integer(Kind=7) :: idfont ! - default font handle -
!
! Window 1
iw = winio@('%ca@&', 'Test1')
iw = winio@('%40.3cw&', iout1)
iw = winio@('%lw', ic1)
Write (Unit=iout1, Fmt='(A)') 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
! Window 2
Call init_font (20)
iw = winio@('%ca@&', 'Test2')
iw = winio@('%fh&', idfont)
iw = winio@('%40.3cw&', iout2)
iw = winio@('%lw', ic2)
Write (Unit=iout2, Fmt='(A)') 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
! Window 3
Call init_font (4)
iw = winio@('%ca@&', 'Test3')
iw = winio@('%fh&', idfont)
iw = winio@('%40.3cw&', iout3)
iw = winio@('%lw', ic3)
Write (Unit=iout3, Fmt='(A)') 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
!
Contains
!
Subroutine init_font (iscale)
Use mswin32, Only: CreateFont
Use clrwin, Only: get_system_font@, set_default_font@, set_default_to_fixed_font@
!
Integer, Intent(In) :: iscale
!
Integer :: ifnt_hght, ifnt_wdth, ifnt_escp, ifnt_ornt, ifnt_wght, ifnt_ital, ifnt_ulin, ifnt_strk, ifnt_cset, &
ifnt_prec, ifnt_clip, ifnt_qual, ifnt_ptch
!
Character(Len=80) :: cdfname
!
! Set default font characteristics
Call set_default_to_fixed_font@ ()
Call get_system_font@ (ifnt_hght, ifnt_wdth, ifnt_escp, ifnt_ornt, ifnt_wght, ifnt_ital, ifnt_ulin, ifnt_strk, ifnt_cset, &
ifnt_prec, ifnt_clip, ifnt_qual, ifnt_ptch, cdfname)
ifnt_hght = ifnt_hght*iscale
ifnt_wdth = ifnt_wdth*iscale
idfont = CreateFont (ifnt_hght, ifnt_wdth, ifnt_escp, ifnt_ornt, ifnt_wght, ifnt_ital, ifnt_ulin, ifnt_strk, ifnt_cset, &
ifnt_prec, ifnt_clip, ifnt_qual, ifnt_ptch, cdfname)
Call set_default_font@ (idfont)
!
Return
End Subroutine init_font
!
End Program p
|
|
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7924 Location: Salford, UK
|
Posted: Fri Jun 02, 2017 7:07 am Post subject: |
|
|
I have not looked at the details but this works OK for me...
Code: | iw = winio@('%ca@&', 'Test2')
iw = winio@('%fn[Courier New]%ts&',2.0d0)
iw = winio@('%40.3cw[local_font]&', iout2)
iw = winio@('%lw', ic2)
|
|
|
Back to top |
|
|
simon
Joined: 05 Jul 2006 Posts: 268
|
Posted: Fri Jun 02, 2017 1:14 pm Post subject: |
|
|
Thanks Paul. That does indeed work, but I was hoping to be able to reset the default font because I am having difficulties trying to calculate the required size of the ClearWin+ window. |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Fri Jun 02, 2017 1:45 pm Post subject: |
|
|
Simon,
Forget the default font and load one of the fonts that is properly scalable. I use Segoe UI, supplied with the last few versions of Windows. Also check the logical dpi settings, which should tell you which font size setting is in use: hint 96,120, 144 dpi are the values you most probably find.
Something like this:
Code: | SUBROUTINE SET_FONT
C -----------------------------
IMPLICIT DOUBLE PRECISION (A-H, O-Z)
COMMON/FOR_NOW/ NSCREEN, IXSCRN, IYSCRN
CHARACTER*(60) COMPUTERNAME
COMMON /MACHINE/ COMPUTERNAME
INCLUDE <WINDOWS.INS>
C ------------------------------------------------------------------
CALL GET_OS_VER@ (ID_Platform, Major, Minor)
IF (Major .LE. 5) THEN ! i.e. XP or earlier
IF (COMPUTERNAME .EQ. 'STANDARD') THEN
IF (IYSCRN .LT. 1000) THEN
FACTOR = 0.8D0
IA=WINIO@('%fn[MS Sans Serif]%ts&',FACTOR)
ELSE IF (IYSCRN .LT. 1050) THEN
FACTOR = 0.9D0
IA=WINIO@('%fn[MS Sans Serif]%ts&',FACTOR)
ENDIF
ELSE
IF (IYSCRN .LT. 1000) THEN
FACTOR = 0.8D0
IA=WINIO@('%fn[MS Sans Serif]%ts&',FACTOR)
ELSE IF (IYSCRN .LE. 1080) THEN
FACTOR = 0.9D0
IA=WINIO@('%fn[MS Sans Serif]%ts&',FACTOR)
ENDIF
ENDIF
ELSE ! i.e. Vista or later
IF (IYSCRN .LT. 1000) THEN
FACTOR = 0.9D0
IA=WINIO@('%fn[Segoe UI]%ts&',FACTOR)
ELSE IF (IYSCRN .LE. 1080) THEN
FACTOR = 1.0D0
IA=WINIO@('%fn[Segoe UI]%ts&',FACTOR)
ENDIF
ENDIF
RETURN
END |
Elsewhere in my program, COMPUTERNAME is set the 'STANDARD' if logical dpi is 96. MS Sans Serif works best with pre-Vista Windows.
Eddie
PS. Slightly larger fonts work better with pop up information dialogs: if you have scaled to 0.8, do them with 0.9. |
|
Back to top |
|
|
simon
Joined: 05 Jul 2006 Posts: 268
|
Posted: Fri Jun 02, 2017 5:02 pm Post subject: |
|
|
Thanks Eddie. Your suggestion is approximately how I scale my fonts for constructing "format windows" (as the help pages call them), and that is working reasonably well. However, where I am experiencing a problem is with formatting within a %cw window. I use some of these to print out some results using WRITE statements, and know exactly the width of the output field in terms of the maximum number of characters. %cw specifies the width in average characters, but for the default font. As soon as I use a local_font (even a fixed-width font), while I do then have the flexibility of scaling, calculating the size of the %cw window gets screwed up. Hence I am hoping to try and set the default font and (hopefully) then it will be easier to match the width of my output field with the width of the window. There is a function for graphics surfaces (get_text_size$) that can be used to calculate how much space a character string will need, but there is no equivalent for other outputs. |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2388 Location: Yateley, Hants, UK
|
Posted: Fri Jun 02, 2017 5:51 pm Post subject: |
|
|
Some time ago there was a thread about fonts in %cw windows, but I couldn't find it.
Item 336 in cwplus.enh covers some of the results from the discussion at that time, notably that routines described in the documentation as obsolete were, in fact, rather useful.
Fonts for %cw Clearwin Windows are adjustable. If you look in the Clearwin Fortran Edition manual online here: http://www.silverfrost.com/manuals/clearwin.pdf
You will find the documentation at around page 302. (My old hardcopy manual has it at p93, so the PDF is much more recent). You can set the font to fixed spacing and to the characer height and width you want, also using escape codes to change its characteristics.
I hope that is more helpful.
Eddie |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7924 Location: Salford, UK
|
Posted: Fri Jun 02, 2017 10:03 pm Post subject: |
|
|
I am not sure how to go forward with this.
You could use %lc to get the HWND for the %cw, use this in GetDC to get the the HDC and then use the HDC in a call to GetTextExtentPoint32 in order to get the size of a string (for a font that is already loaded into the HDC). If you are not happy with the programming then I could add something to ClearWin+ that does this for you.
The default system font is usually Tahoma so you could use this with %cw[local_font]. It doesn't make sense to me to change the default font but perhaps you mean something else. |
|
Back to top |
|
|
simon
Joined: 05 Jul 2006 Posts: 268
|
Posted: Sun Jun 04, 2017 7:34 pm Post subject: |
|
|
Actually, Paul, what might be simpler is to have a function that indicates the font size (height and average width) for a specified font. It would then be possible to calculate the (approximate) size of a string. |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2816 Location: South Pole, Antarctica
|
Posted: Mon Jun 05, 2017 9:46 am Post subject: |
|
|
What's wrong with the get_text_size@ ? |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7924 Location: Salford, UK
|
Posted: Mon Jun 05, 2017 12:05 pm Post subject: |
|
|
Two new routines have now been added and will be available shortly in an upload of DLLs for beta testing.
GETTEXTSIZE@ is like GET_TEXT_SIZE@ but takes an extra argument (the first) and this is the windows handle (HWND) for a control.
GETFONTSIZE@ takes a font handle as input and returns the character width and height. |
|
Back to top |
|
|
simon
Joined: 05 Jul 2006 Posts: 268
|
Posted: Mon Jun 05, 2017 12:14 pm Post subject: |
|
|
Great, thanks Paul.
Dan- get_text_size@ only works for drawing surfaces. |
|
Back to top |
|
|
John-Silver
Joined: 30 Jul 2013 Posts: 1520 Location: Aerospace Valley
|
Posted: Tue Jun 06, 2017 12:11 am Post subject: |
|
|
following up Eddie's hint, I found this:
Quote: | The default font used by a ClearWin window (SYSTEM_FIXED_FONT) can be changed by a call to either set_default_proportional_font@ or to set_default_font@. These routines will alter the default font used by ClearWin+ on all ClearWin windows created subsequent to the call. The original default can be restored by a call to set_default_to_fixed_font@. |
Here ....
http://silverfrost.com/ftn95-help/clearwinp/clearwin/textoutputtoclearwinwindows.aspx
as referenced in this post (which may be the one Eddie remembers) ...
http://forums.silverfrost.com/viewtopic.php?t=1461
where Paul pointed to the documentation.
Also I found this .....
http://forums.silverfrost.com/viewtopic.php?t=1592
- NOTE -
All found using Gooooogle .... which I often find much more useful than the forum search facility !!!
I simply search for silverfrost forum <search strin g> and it usually comes up with the goods (if they exist of course !) |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|