|
Forum Index : Microcontroller and PC projects : Current Font & Scale
| Author | Message | ||||
| MustardMan Senior Member Joined: 30/08/2019 Location: AustraliaPosts: 175 |
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: AustraliaPosts: 1045 |
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: AustraliaPosts: 3308 |
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: AustraliaPosts: 175 |
@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! |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |