mkopack73 Senior Member Joined: 03/07/2020 Location: United StatesPosts: 261
Posted: 12:10am 01 Aug 2020
Is there any way to query the height of a given font (assuming that it might not be one of the built in ones).
I know the built in ones are listed in a table in the manual, but I'm looking to see if there's a way to get the size regardless if it's the built in or if it's been replaced... (So I can do some dynamic positioning of text on the screen based on the screen res and the font/scaling chosen).
Thoughts?
mkopack73 Senior Member Joined: 03/07/2020 Location: United StatesPosts: 261
Posted: 12:35am 01 Aug 2020
Also, how does one detect the enter key when using INKEY$ or KEYDOWN() ???
KeepIS Guru Joined: 13/10/2014 Location: AustraliaPosts: 1783
Posted: 12:38am 01 Aug 2020
All in the Manual:
MM.INFO(FONTHEIGHT)
The Enter key is a standard ASCII value of 13 Dec.
capsikin Guru Joined: 30/06/2020 Location: AustraliaPosts: 341
Posted: 12:51am 01 Aug 2020
For KEYDOWN() I got a value of 10, using this program to check one or two keys:
do do loop until keydown(0) > 0 if keydown(0) > 1 then print keydown(2);" and "; print keydown(1) loop
KeepIS Guru Joined: 13/10/2014 Location: AustraliaPosts: 1783
Posted: 01:15am 01 Aug 2020
For some reason the Keydown function is only returning the Linefeed character.
dim KeyStr as string cls do KeyStr=inkey$ If KeyStr <> "" then print KeyStr;:print asc(KeyStr) endif loop until asc(KeyStr)=27 'esc key
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6207
Posted: 01:23am 01 Aug 2020
The enter key is seen as <CR><LF> pair If you are using a terminal program instead of the uSB keyboard, it will depend on the setting of your terminal program.
The differences between Windows, Linux and Mac always make life difficult which is why your program should check for either CR, LF or both
DO k$ = INKEY$ IF LEN(k$) <> 0 THEN PRINT HEX$(ASC(k$),2);" ";k$ LOOP
Jim
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6207
Posted: 01:30am 01 Aug 2020
I expect that it is because the enter key gets mapped to CR LF with the LF last in the list so it is the one 'seen'
Using ctrl-M does give you chr$(13)
Jim
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6207
Posted: 01:48am 01 Aug 2020
The first group of data in a font file gives you the sizes. the order of info is character count, character start, character height, character width, This font
cc = val("&h"+mid$(txt$,1,2)) ' character count cs = val("&h"+mid$(txt$,3,2)) ' character start ch = val("&h"+mid$(txt$,5,2)) ' character height cw = val("&h"+mid$(txt$,7,2)) ' character width
to 1 character, Chr$(32), 60 pixels high and 48 pixels wide
Jim
capsikin Guru Joined: 30/06/2020 Location: AustraliaPosts: 341
Posted: 02:16am 01 Aug 2020
USB keyboard or terminal program?
There's an "OPTION CRLF mode" that's suppose to affect what the USB keyboard sends. I don't know if it changes keydown, maybe only inkey$ Edited 2020-08-01 12:17 by capsikin
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6207
Posted: 02:33am 01 Aug 2020
setting OPTION CRLF LF changes inkey$ to LF only both other options gives the CR LF pair.
I don't know if that is by design or a bug.
Jim
mkopack73 Senior Member Joined: 03/07/2020 Location: United StatesPosts: 261
Posted: 03:03am 01 Aug 2020
Ok, got the keyboard scanning properly...
And thanks, I missed the MM.INFO(FONTHEIGHT)....
Wish there was an MM.INFO(FONTNUMBER) and MM.INFO(FONTSCALE) to get back which font # is currently being used at what scale...
Basically I'm trying to write an include for doing high scores... so I have a function in there for reading the top 10 scores from a sequential file, one for displaying the top 10, a function that determines if a given score is in the top 10, and another for the user to put in their name if it's a top 10 and save the new list to disk.
I am trying to make this universal regardless of the resolution of the screen. I am having parameters to allow the caller to tell it which font and scale to use for displaying the HS screens. But what I'm missing is a way to reset the font back to what it was after it's done doing it's job. There doesn't seem to be a way to ask what font # is currently in use.
I guess I could just leave it up to the parent program to set the font info before calling the high score functions...
KeepIS Guru Joined: 13/10/2014 Location: AustraliaPosts: 1783
Posted: 03:54am 01 Aug 2020
I guess you could interrogate Font width and Height, but Font 1,2 scaling with Font 3 would throw that off, at least they would be the same size, don't know about the rest though, and custom fonts could have the same issue.
KeepIS Guru Joined: 13/10/2014 Location: AustraliaPosts: 1783
Posted: 04:37am 01 Aug 2020
There is a Mode command to return the current Video mode MM.INFO(MODE)