Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 19:06 21 Nov 2024 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 : CMM2: Font height?

Author Message
mkopack73
Senior Member

Joined: 03/07/2020
Location: United States
Posts: 261
Posted: 12:10am 01 Aug 2020
Copy link to clipboard 
Print this post

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 States
Posts: 261
Posted: 12:35am 01 Aug 2020
Copy link to clipboard 
Print this post

Also, how does one detect the enter key when using INKEY$ or KEYDOWN() ???
 
KeepIS

Guru

Joined: 13/10/2014
Location: Australia
Posts: 1679
Posted: 12:38am 01 Aug 2020
Copy link to clipboard 
Print this post

All in the Manual:

MM.INFO(FONTHEIGHT)

The Enter key is a standard ASCII value of 13 Dec.
It's all too hard.
Mike.
 
capsikin
Guru

Joined: 30/06/2020
Location: Australia
Posts: 341
Posted: 12:51am 01 Aug 2020
Copy link to clipboard 
Print this post

  mkopack73 said  Also, how does one detect the enter key when using INKEY$ or KEYDOWN() ???


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: Australia
Posts: 1679
Posted: 01:15am 01 Aug 2020
Copy link to clipboard 
Print this post

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

It's all too hard.
Mike.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6089
Posted: 01:23am 01 Aug 2020
Copy link to clipboard 
Print this post

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
VK7JH
MMedit   MMBasic Help
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6089
Posted: 01:30am 01 Aug 2020
Copy link to clipboard 
Print this post

  KeepIS said  For some reason the Keydown function is only returning the Linefeed character.

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
VK7JH
MMedit   MMBasic Help
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6089
Posted: 01:48am 01 Aug 2020
Copy link to clipboard 
Print this post

  mkopack73 said  Is there any way to query the height of a given font (assuming that it might not be one of the built in ones).
Thoughts?


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
DefineFont #8
 01203C30
 00000000 00000000 00002000 F8010000 00000000 0080FF3F FFE30000 010000C0
 00E07FC9 01900300 060000F0 00F80080 00000F00 1E0000FC 007E0000 20001E00
 3C00003E 000F7900 FF0B3C00 7800800F C007FF03 FF0B7800 7800C087 C083FF3F
 3F3FF800 F800E0C3 E063FFFF FF7FF800 F004E0E7 E0FFFFFF FFCB710F E30FE0FF
 E0FF1FC0 0F84E70F E30BE0F1 E0C0CF9F 67D1E30B 430BE018 608E07C0 C3FFC30A
 C100E003 E08983CF 83FFC1F8 41FAE09F E0CFC3FF 83CFB1FB 90FBC0FF C0FFC30F
 071F10FF 90FFC0BF C09F071E 071C36FE 7200C0CF C0C7013D 817F3300 3F00C0E7
 80FBD0FF FDFF77FC 475C80FF 80DF3FF0 0070735C 6758000F 007F43F8 7AF87348
 3BF1007F 00FEF5FA 7FFEF900 3DF800FE 00FC3FBE 03FE0DFF C6FF00F8 00F84FFF
 6F3FF1A7 F84700F0 00E0FF7F FF3FDE1F FF0700C0 0080FF3F FF8FFED3 FEFD0000
 00003F40 3E60FAFF BACF0000 00003C74 1CAEFEFF F6DF0000 00003C3F 9C3FF8FF
 FEFF0000 0000FC4F 00000000
End DefineFont


has 01203C30 which can be expanded using
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
VK7JH
MMedit   MMBasic Help
 
capsikin
Guru

Joined: 30/06/2020
Location: Australia
Posts: 341
Posted: 02:16am 01 Aug 2020
Copy link to clipboard 
Print this post

  KeepIS said  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


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: Australia
Posts: 6089
Posted: 02:33am 01 Aug 2020
Copy link to clipboard 
Print this post

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
VK7JH
MMedit   MMBasic Help
 
mkopack73
Senior Member

Joined: 03/07/2020
Location: United States
Posts: 261
Posted: 03:03am 01 Aug 2020
Copy link to clipboard 
Print this post

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: Australia
Posts: 1679
Posted: 03:54am 01 Aug 2020
Copy link to clipboard 
Print this post

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.
It's all too hard.
Mike.
 
KeepIS

Guru

Joined: 13/10/2014
Location: Australia
Posts: 1679
Posted: 04:37am 01 Aug 2020
Copy link to clipboard 
Print this post

There is a Mode command to return the current Video mode MM.INFO(MODE)

Mike.
It's all too hard.
Mike.
 
Print this page


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

© JAQ Software 2024