Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 20:07 13 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Current Font & Scale

Author Message
MustardMan

Senior Member

Joined: 30/08/2019
Location: Australia
Posts: 175
Posted: 09:14pm 04 May 2020
Copy link to clipboard 
Print this post

Hi,

Is there a function (or peek) that will allow me to retrieve the currently selected font & font scale?

I have a subroutine that needs to use the font of the calling subroutine (this extends about 3 levels deep), but other parts of my program use different fonts and scales.

There are two untidy solutions I see, first create a couple of global variables to hold the current font details (and update them every time I do a font change) and push them onto a stack to restore upon my subroutine exit. The second is to pass the value of local variables down explicitly (as the LOCALs of sub-level-1 are not visible by sub-level-2 or below) but then the function parameter list starts to get really long.

It would be easier to say (at my bottom level): currentfont = CURRENTFONT, do my text, then FONT=currentfont before exit.

Any ideas?

Cheers,
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 1045
Posted: 12:47am 05 May 2020
Copy link to clipboard 
Print this post

Are you aware of the FONT command which sets the default font and scale that is used if they are not specified. You could just leave font and scale out of all text commands and control what is used in each part of program by issuing a new  
FONT fontno,scale

command at each top level as required. The low level subroutine would use whatever is set last.
F4 H7FotSF4xGT
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3308
Posted: 02:07am 05 May 2020
Copy link to clipboard 
Print this post

  MustardMan said  Is there a function (or peek) that will allow me to retrieve the currently selected font & font scale?

No, sorry.

Either of your (untidy) alternatives would work plus, as disco4now suggested, you could just set the font/scaling using the FONT command.
Geoff Graham - http://geoffg.net
 
MustardMan

Senior Member

Joined: 30/08/2019
Location: Australia
Posts: 175
Posted: 04:46am 05 May 2020
Copy link to clipboard 
Print this post

@disco4now
Yes. I am currently using FONT to set a default font, but that changes (depending on user interaction, etc). Depending on other user input I jump into an alternate display routine which uses a different (and also changeable) font, and hence I would like to save the current font so when I pop back out of my routine, I can restore it to what it was.
I can of course use global variables to store what the current font is (save on entry to the alternate display routine, restore on exit), but I dislike racking up global variables unless I really need them.

@Geoffg
Thanks for the confirmation.
I will pass the desired font down the subroutine chain - although it makes the SUB definitions quite long (they are quite long already!), it is easy to do and quick to implement. Having made invaluable use of a stack in assembly I do like the idea of one, but I would only use it quite seldomly. Perhaps I write one in another project...

Thanks!
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025