Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 00:56 27 Apr 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 : MicroMite and Proportional Fonts

     Page 1 of 2    
Author Message
MustardMan

Senior Member

Joined: 30/08/2019
Location: Australia
Posts: 175
Posted: 04:14am 20 Mar 2020
Copy link to clipboard 
Print this post

Hi,
From my understanding the MicroMite can only deal with fixed-width fonts (similar to Courier New on 'doze).

Has anyone done anything with proportional fonts on the MicroMite?

My specific application has to do with displaying a whole stack of temperatures (to one decimal place) on the screen with a graphical schematic of the system. Problem is I want the numbers large (viewable from a reasonable distance) and when I do that the space taken up by the "." is enormous!

A simple (for me) solution would be a proportional font.

A hacky solution would be to split the number into the 'whole part' and the 'decimal part', drop down a decimal point manually and do some horrible (messy) code to squash the two remaining numerals back together around the point...

Any suggestions?
 
goc30

Guru

Joined: 12/04/2017
Location: France
Posts: 425
Posted: 04:25am 20 Mar 2020
Copy link to clipboard 
Print this post

Hi

  MustardMan said  Hi,

A hacky solution would be to split the number into the 'whole part' and the 'decimal part', drop down a decimal point manually and do some horrible (messy) code to squash the two remaining numerals back together around the point...

Any suggestions?


I have same problem with clock (space between hours, minuts and seconds)
and for that, I write first 2x ":" (only in setup), and after numbers 2 by 2
 
Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1032
Posted: 12:18pm 20 Mar 2020
Copy link to clipboard 
Print this post

Hi

I did something similar to goc30 for a time display.

I separated the Hrs, Min & Secs, but I made my own high, narrow font for the ":" using Tassie Jim's FontTweak.exe prog'

(I also modified the 7 segment font for the digits).

Code snippets below.

You've got me thinking that I should do the same for the temperature displays on the panel. The "." does take up a lot of wasted space

I don't think there are other methods that don't involve splitting up the temperature string.

I wouldn't say it was horrible or messy, just not ideal


HH$ = left$(TIME$, 2)      'get Hours digits of TIME$
MM$ = mid$(TIME$, 4, 2)    'Get Mins
SS$ = right$(TIME$, 2)     'Get Secs

 text 5, 35, HH$, lm, 7, 1, rgb(GREEN), rgb(BLUE)         'Print Hrs font 7
 text 70, 35, chr$(58), lm, 6, 1, rgb(GREEN), rgb(BLUE)   'Print ":" font 6
 text 90, 35, MM$, lm, 7, 1, rgb(GREEN), rgb(BLUE)        'Print Mins font 7
 text 155, 35, chr$(58), lm, 6, 1, rgb(GREEN), rgb(BLUE)  'Print ":" font 6
 text 170, 35, SS$, lm, 7, 1, rgb(GREEN), rgb(BLUE)       'Print Sec font 7

'LIBRARY FONT
  ' Colon_02#6.bas
  ' Font type    : 1 character ":" CHR$(58)
  ' Font size    : 16x50 pixels
  ' Memory usage : 104 bytes
  ' Font adapted BY BDP


Brian
ChopperP
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1664
Posted: 08:22pm 20 Mar 2020
Copy link to clipboard 
Print this post

  MustardMan said  A hacky solution would be to split the number into the 'whole part' and the 'decimal part', drop down a decimal point manually and do some horrible (messy) code to squash the two remaining numerals back together around the point...


What about instead the decimal point draw a dot with the circle command.

Most of the parameters could be put in a function called Dot, to which you could pass just the numbers required; X,Y & Colour.


Function Dot (dpx,dpy,dpcol)

CIRCLE x, y, r [,lw] [, a] [,c] [, fill]

etc.


You could include pixel offsets to reference the location in the same way as fonts...
(Top Left from memory).

Then your Text line for 35.9 could look like this...


Text x,y,"35", dadada…. : Dot x,y,col : Text x,y,"9", dadada….


Might be more elegant & workable.

Phil.
 
Andrew_G
Guru

Joined: 18/10/2016
Location: Australia
Posts: 840
Posted: 11:26pm 20 Mar 2020
Copy link to clipboard 
Print this post

Hi all,

+1 for splitting the text and using a circle for "." and two for ":" (L "justified" for the text left of the dot(s) and R for that to the right).

Cheers,

Andrew

Phil -   there is a MM function for your Dot function. Its called "CIRCLE" and you can even pass a radius and an aspect ratio to it too  
 
Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1032
Posted: 03:01am 21 Mar 2020
Copy link to clipboard 
Print this post

Circle idea works great!!

Brian
ChopperP
 
zeitfest
Guru

Joined: 31/07/2019
Location: Australia
Posts: 379
Posted: 07:06am 21 Mar 2020
Copy link to clipboard 
Print this post

There are a few gotchas for graphic LCDs.
A proportional font works fine. Often the actual numerals in the font are still deliberately regular spaced, so columns and lists line up, otherwise they look ragged. The downside is that when standalone number fields are displayed they can look a bit unpolished, and the large characters chew up memory. But they are OK I think. (apart from my crap photo    )


tft.print("1234.5");







[ edit - Jaycar parallel lcd 2.8", arduino uno driving it. The font is 36 point and I had to hack it a bit to save memory ]
Edited 2020-03-21 17:15 by zeitfest
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1664
Posted: 09:08am 21 Mar 2020
Copy link to clipboard 
Print this post

  Andrew_G said  
Phil -   there is a MM function for your Dot function. Its called "CIRCLE" and you can even pass a radius and an aspect ratio to it too  


You've lost me?

What the Dot function I was suggesting was just a function containing the Circle command inside it, but fiddling the parameters a bit to make it more workable with the text command.

just to help make it easier to position.

Maybe it could also use mm.fontsize?? (if that's the right variable; think maybe height or width....), so there is no need to pass it a radius etc.

Phil.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8579
Posted: 09:20am 21 Mar 2020
Copy link to clipboard 
Print this post

I can envisage a way of making a truly proportional font work with a minor firmware tweak but someone would need to design a test font.

The font itself would need to be fixed size and as big as the biggest character as well as following the usual restriction that w*h must be divisible by 8

All characters should be left justified with as many blank columns after the character as required to fill out the format.

Then the firmware would need a small modification to output the first blank column only skipping the rest.

This would then output as a properly proportional font
 
kiiid

Guru

Joined: 11/05/2013
Location: United Kingdom
Posts: 671
Posted: 09:25am 21 Mar 2020
Copy link to clipboard 
Print this post

You could try in a way similar to what I did in Rittle. Here is an explanation
Probably firmware mods would be needed, though
Edited 2020-03-21 19:26 by kiiid
http://rittle.org

--------------
 
Quazee137

Guru

Joined: 07/08/2016
Location: United States
Posts: 522
Posted: 11:51am 21 Mar 2020
Copy link to clipboard 
Print this post

How about a cfunction Ptext where when these characters !',.:; are encountered

it would remove two dot spaces at each side of them.

would use the same format as text.
 
Andrew_G
Guru

Joined: 18/10/2016
Location: Australia
Posts: 840
Posted: 12:24am 22 Mar 2020
Copy link to clipboard 
Print this post

Hi Phil,
Sorry if I caused confusion, or even offended - not my intention.  
I was having a little joke along the lines that the Dot function was almost the same as the Circle function - minus a couple of parameters.
The main import of my post was +1 to splitting the text - in the absence of anything better.

Cheers,

Andrew
 
Chopperp

Guru

Joined: 03/01/2018
Location: Australia
Posts: 1032
Posted: 01:48pm 22 Mar 2020
Copy link to clipboard 
Print this post

On reading Andrew's post above on the DOT function (which I didn't really take any notice of), I went back up & had a look at it in Phil's post.

I then read up on functions in the manual to try to understand them but I couldn't really work how to use one in this context.

I then noticed that Geoff had an example of using a SUB for the same thing & that worked brilliantly.

sub Dot dpx, dpy, dpcol
 circle dpx, dpy, 3, 1, 1, dpcol, dpcol '3mm radius
end sub

& is called by

Dot dpx, dpy, dpcol


I didn't realise you could do that with a SUB.

I had spent a fair bit of time yesterday converting "."s to circles on a couple of programs which wasn't that hard with Cut & Pasting.

Just went back & changed one lot with the Dot SUB. Much easier.

Thanks guys for the comments & tips etc

Brian
ChopperP
 
MustardMan

Senior Member

Joined: 30/08/2019
Location: Australia
Posts: 175
Posted: 02:56am 17 Apr 2020
Copy link to clipboard 
Print this post

@matherp

I do like that idea of creating a 'proportional' font. The idea put forward by quazee137 is good, but it would not be truly universal... I'm thinking that in a "proportional" font the "w" would be the widest character and your proposal would simply squash anything that was smaller (with blank columns), like an "l" or "i". One problem... how would you handle a 'space', which is all blanks!?

PS: Sorry about the delayed reply!

Cheers,
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1593
Posted: 10:03pm 17 Apr 2020
Copy link to clipboard 
Print this post

I like matherp's idea of a 'proportional font' also.

Maybe it could be used with an associated 'offset' lookup table. Each character of the string could be printed individually in a loop using the TEXT command with the next character printed at x plus one character width Minus the lookup offset of the previous character.

W i d e s p a c e d text could be handled by adding a fixed additional offset.

It should be pretty fast in MMBasic because each character doesn't have to be analysed to work out the offset and spaces would be catered for.

I think you could forget automatic alignment though.

Just a thought.

Bill
Edited 2020-04-19 05:50 by Turbo46
Keep safe. Live long and prosper.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5903
Posted: 07:55am 20 Apr 2020
Copy link to clipboard 
Print this post

I have updated 'fonttweak" so that you can shift a font to the left and save the width of each character as DATA statements.

Simply load you font and select "Save as BAS (Proportional)" and you will end up with something like the one in this program.

It is then easy enough to print each character in turn at the correct position.
The last character might overwrite anything immediately to the right of the text.

It should work on all platforms.

 ' proportional fonts demo
 
 ' fill the array with character widths
 DIM fontwidths(256)
 RESTORE FONT_WIDTH
 READ fontstart , fontcount
 FOR n = fontstart TO fontstart + fontcount-1
   READ fontwidths(n)
 NEXT n
 
 CLS
 pro_txt 10,100,"This is IT!!", "L"
 pro_txt 10,120,"WWW is wide", "L"
 pro_txt 10,140,"III is not", "L"
 
 pro_txt 200,100,"This is IT!!", "C"
 pro_txt 200,120,"WWW is wide", "C"
 pro_txt 200,140,"III is not", "C"
 
 pro_txt 390,100,"This is IT!!", "R"
 pro_txt 390,120,"WWW is wide", "R"
 pro_txt 390,140,"III is not", "R"
 
 PRINT
 
SUB pro_txt(x,y,txt$,just$)
 LOCAL AS INTEGER txtwidth, n, px
 
 FOR n = 1 TO LEN(txt$)
   txtwidth = txtwidth + fontwidths(ASC(MID$(txt$,n)))+1
 NEXT n
 SELECT CASE just$
   CASE "C","c"
     px = x - txtwidth/2
   CASE "R", "r"
     px = x - txtwidth
   CASE ELSE ' "L", "l"
     px = x
 END SELECT
 FOR n = 1 TO LEN(txt$)
   TEXT px,y,MID$(txt$,n,1), L,8,1
   px = px + fontwidths(ASC(MID$(txt$,n)))+1
 NEXT n
 
END SUB
 
 
DEFINEFONT #8
 5F201010 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00C000C0 00C000C0 00C000C0 00C000C0 000000C0 00C000C0
 00000000 00000000 00D800D8 00D800D8 000000D8 00000000 00000000 00000000
 00000000 00000000 80198019 C07F8019 0033C07F 80FF0033 006680FF 00660066
 00000000 00000000 003E0008 0068006B 00780068 000F003E 00CB000B 003E006B
 00000008 00000000 3066183C 60666066 803DC066 6603BC01 66066606 3C18660C
 00000000 00000000 007E003C 00660066 C03C003C C0C6C06C 80E380C7 C03CC07F
 00000000 00000000 00C000C0 00C000C0 000000C0 00000000 00000000 00000000
 00000000 00000000 00600030 00C00060 00C000C0 00C000C0 00600060 00000030
 00000000 00000000 006000C0 00300060 00300030 00300030 00600060 000000C0
 00000000 00000000 00060006 70E60006 801FF0FF 8019000F 8010C039 00000000
 00000000 00000000 00000000 00180018 00180018 00FF00FF 00180018 00180018
 00000000 00000000 00000000 00000000 00000000 00000000 00C000C0 00800040
 00000000 00000000 00000000 00000000 00F00000 000000F0 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00C00000 000000C0
 00000000 00010000 00020002 00040004 00080008 00100010 00200020 00400040
 00800080 00000000 007E003C 00C30066 00C300C3 00C300C3 006600C3 003C007E
 00000000 00000000 00380018 00D80078 00180098 00180018 00180018 00FF00FF
 00000000 00000000 007E003C 00C300E7 00070003 001C000E 00700038 00FF00FF
 00000000 00000000 007E003C 00C300E3 001E0003 0003001E 00E300C3 003C007E
 00000000 00000000 000E000E 0036001E 00660036 80FF00C6 000680FF 00060006
 00000000 00000000 00FE00FE 00C000C0 00FE00DC 000300E7 00C70003 003C00FE
 00000000 00000000 007F003E 00C00063 00FE00DC 00C300E7 006700C3 003C007E
 00000000 00000000 00FF00FF 00060006 0018000C 00180018 00300030 00300030
 00000000 00000000 007E003C 00C300C3 007E00C3 00C3007E 00C300C3 003C007E
 00000000 00000000 007E003C 00C300E6 00E700C3 003B007F 00C60003 0038007E
 00000000 00000000 00000000 00C000C0 00000000 00000000 00C000C0 00000000
 00000000 00000000 00000000 00C000C0 00000000 00000000 00C000C0 00800040
 00000000 00000000 00000000 00070001 0078001E 007800E0 0007001E 00000001
 00000000 00000000 00000000 00FF0000 000000FF 00FF00FF 00000000 00000000
 00000000 00000000 00000000 00E00080 001E0078 001E0007 00E00078 00000080
 00000000 00000000 007E003C 00C300C7 00060003 0018000C 00000018 00180018
 00000000 00000000 001F0000 C0408021 40A2409E 80A640A2 00400099 001F8020
 00000000 00000000 000E000E 001B001F 803B001B 803F8031 C071C071 E0E0C060
 00000000 00000000 00FE00FC 00C300C3 00FE00C3 00C300FE 00C300C3 00FC00FE
 00000000 00000000 007F001E 80E18061 00C000C0 00C000C0 806180E1 001E007F
 00000000 00000000 00FE00FC 80C300C7 80C180C1 80C180C1 00C780C3 00FC00FE
 00000000 00000000 00FE00FE 00C000C0 00FC00C0 00C000FC 00C000C0 00FE00FE
 00000000 00000000 00FE00FE 00C000C0 00FC00C0 00C000FC 00C000C0 00C000C0
 00000000 00000000 007F001E 80C18063 00C000C0 80C780C7 806380C1 801C807F
 00000000 00000000 00C300C3 00C300C3 00FF00C3 00C300FF 00C300C3 00C300C3
 00000000 00000000 00C000C0 00C000C0 00C000C0 00C000C0 00C000C0 00C000C0
 00000000 00000000 00300030 00300030 00300030 00300030 00300030 00E000F0
 00000000 00000000 00C600C3 00CC00CC 00D800D8 00EC00FC 00C600C6 00C300C3
 00000000 00000000 00C000C0 00C000C0 00C000C0 00C000C0 00C000C0 00FC00FC
 00000000 00000000 E0E0E0E0 E0F1E0F1 60DB60D1 60CA60DB 60CE60CE 60C460C4
 00000000 00000000 00E300C3 00F300E3 00DB00F3 00CF00DB 00C700CF 00C300C7
 00000000 00000000 003F001E C0C08061 C0C0C0C0 C0C0C0C0 8061C0C0 001E003F
 00000000 00000000 00FE00FC 00C300C3 00FE00C3 00C000FC 00C000C0 00C000C0
 00000000 00000000 807F001E C0C08061 C0C0C0C0 C0C0C0C0 8061C0C0 001E007F
 C001C003 00000000 00FF00FE 80C180C1 00FF80C1 00C600FE 00C300C6 80C100C3
 00000000 00000000 003F001E 00608071 003E0078 8003000F 80E380C1 003E007F
 00000000 00000000 00FF00FF 00180018 00180018 00180018 00180018 00180018
 00000000 00000000 00C600C6 00C600C6 00C600C6 00C600C6 00C600C6 0038007C
 00000000 00000000 00C600C6 006C00C6 006C006C 006C006C 00380038 00380038
 00000000 00000000 18C718C7 18C718C7 B06DB06D B06DB06D E038E038 E038E038
 00000000 00000000 006380C1 00360063 001C001C 0036001C 00630036 80C10063
 00000000 00000000 00C300C3 00660066 003C003C 00180018 00180018 00180018
 00000000 00000000 00FF00FF 00060006 0018000C 00300018 00600060 00FF00FF
 00000000 00E00000 00C000C0 00C000C0 00C000C0 00C000C0 00C000C0 00C000C0
 000000E0 00800000 00400080 00200040 00100020 00080010 00040008 00020004
 00010002 00E00000 00600060 00600060 00600060 00600060 00600060 00600060
 000000E0 001C0000 0036001C 00630036 000080C1 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 FFFF0000
 0000FFFF 00000000 00900060 00900090 00000060 00000000 00000000 00000000
 00000000 00000000 00000000 00FE007C 001E00C6 00C6007E 00FE00C6 00000076
 00000000 00C00000 00C000C0 00FC00D8 00C600C6 00C600C6 00FC00C6 000000B8
 00000000 00000000 00000000 007E003C 00C000E6 00C000C0 007E00E6 0000003C
 00000000 00060000 00060006 007E0036 00C600C6 00C600C6 007E00C6 00000036
 00000000 00000000 00000000 007C0038 00FE00C6 00C000FE 007C00C6 00000038
 00000000 00380000 00600078 00F800F8 00600060 00600060 00600060 00000060
 00000000 00000000 003E8003 0063007F 007F0063 0060003E 807F007F 00FF80C1
 0000007E 00C00000 00C000C0 00FE00DC 00C600E6 00C600C6 00C600C6 000000C6
 00000000 00000000 00C000C0 00C00000 00C000C0 00C000C0 00C000C0 000000C0
 00000000 00000000 00300030 00300000 00300030 00300030 00300030 00300030
 00E00030 00C00000 00C000C0 00CC00C6 00D800CC 00F800F8 00CC00CC 000000C6
 00000000 00C00000 00C000C0 00C000C0 00C000C0 00C000C0 00C000C0 000000C0
 00000000 00000000 00000000 F0FFE0DC 30C630E7 30C630C6 30C630C6 000030C6
 00000000 00000000 00000000 00FE00DC 00C600E6 00C600C6 00C600C6 000000C6
 00000000 00000000 00000000 007C0038 00C600C6 00C600C6 007C00C6 00000038
 00000000 00000000 00000000 00FC00D8 00C600C6 00C600C6 00FC00C6 00C000D8
 00C000C0 00000000 00000000 007E003A 00C600C6 00C600C6 007E00C6 00060036
 00060006 00000000 00000000 00F800D8 00C000E0 00C000C0 00C000C0 000000C0
 00000000 00000000 00000000 00FC0078 00E000CC 001C0078 00FC00CC 00000078
 00000000 00000000 00600060 00F800F8 00600060 00600060 00780060 00000038
 00000000 00000000 00000000 00C600C6 00C600C6 00C600C6 00FE00CE 00000076
 00000000 00000000 00000000 00C600C6 006C006C 0038006C 00380038 00000010
 00000000 00000000 00000000 30C630C6 606F6066 6069606F C039C039 0000C030
 00000000 00000000 00000000 006C00C6 0038006C 00380038 006C006C 000000C6
 00000000 00000000 00000000 00C600C6 006C006C 006C006C 00380038 00300038
 00600070 00000000 00000000 00F800F8 00300018 00600020 00F800C0 000000F8
 00000000 00380000 00600060 00600060 00800060 00600060 00600060 00600060
 00000038 00C000C0 00C000C0 00C000C0 00C000C0 00C000C0 00C000C0 00C000C0
 000000C0 00E00000 00300030 00300030 00080030 00300030 00300030 00300030
 000000E0 00000000 00FF0073 000000DE 00000000 00000000 00000000 00000000
 00000000 00000000
End DefineFont
 '
 ' font widths
FONT_WIDTH:
 DATA  32, 95 ' fontstart, fontcount
 DATA  1,2,5
 DATA  10,8,15,10,2,4,4,12
 DATA  8,2,4,2,8,8,8,8
 DATA  8,9,8,8,8,8,8,2
 DATA  2,8,8,8,8,10,11,8
 DATA  9,9,7,7,9,8,2,4
 DATA  8,6,11,8,10,8,10,9
 DATA  9,8,7,7,13,9,8,8
 DATA  3,8,3,9,16,4,7,7
 DATA  7,7,7,5,9,7,2,4
 DATA  7,2,12,7,7,7,7,5
 DATA  6,5,7,7,12,7,7,5
 DATA  5,2,5,8
 


I haven't added any colour but that is easy enough to do.

The font included is Franklin Gothic and you will need the latest font tweak to roll your own font.




Jim
Edited 2020-04-20 19:50 by TassyJim
VK7JH
MMedit   MMBasic Help
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1593
Posted: 10:52pm 20 Apr 2020
Copy link to clipboard 
Print this post

  Bill said  I think you could forget automatic alignment though.

Of course I could be wrong.

Jim, That is brilliant! I'm surprised that the others above haven't commented yet. I considered trying to produce the font and font width table myself But I would have had to do it all manually and I don't really have a use for it at the moment. All too hard.

Thank you.

Bill
Keep safe. Live long and prosper.
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 844
Posted: 12:51am 21 Apr 2020
Copy link to clipboard 
Print this post

Good one Jim, I have booked marked it.

Regards
Gerry
Latest F4 Latest H7
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5903
Posted: 02:16am 21 Apr 2020
Copy link to clipboard 
Print this post

My next exercise will be 'justify'. That might be more useful.

Just have a few/lot domestic chores to see to first.

Jim
VK7JH
MMedit   MMBasic Help
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5903
Posted: 06:59am 21 Apr 2020
Copy link to clipboard 
Print this post

Update. Now does full justify and colour.



 ' proportional fonts demo
 ' tassyjim April 2020
 OPTION EXPLICIT
 
 DIM INTEGER fontwidths(256) ' width of each character
 DIM INTEGER txtW(80) ' with of each char in the string to be printed
 DIM INTEGER fontstart, fontcount, n
 
 ' fill the array with character widths
 RESTORE FONT_WIDTH
 READ fontstart , fontcount
 FOR n = fontstart TO fontstart + fontcount-1
   READ fontwidths(n)
 NEXT n
 
 CLS
 kern_txt 10,100,"This is IT!!", "L",,RGB(GREEN)
 kern_txt 10,120,"WWW is wide", "L",,RGB(GREEN)
 kern_txt 10,140,"III is not", "L",,RGB(GREEN)
 
 kern_txt 200,100,"This is IT!!", "C",,RGB(CYAN)
 kern_txt 200,120,"WWW is wide", "C",,RGB(CYAN)
 kern_txt 200,140,"III is not", "C",,RGB(CYAN)
 
 kern_txt 390,100,"This is IT!!", "R",,RGB(GREEN)
 kern_txt 390,120,"WWW is wide", "R",,RGB(GREEN)
 kern_txt 390,140,"III is not", "R",,RGB(GREEN)
 
 kern_txt 110,200,"Stay home", "j", 180,RGB(RED)
 kern_txt 110,220,"Stay safe", "j", 180,RGB(RED)
 kern_txt 110,240,"Save lots of lives!!", "j", 180,RGB(RED)
 
 PRINT
 PRINT
 
SUB kern_txt(x AS INTEGER,y AS INTEGER,txt$,just$,maxW AS INTEGER,c AS INTEGER,bc AS INTEGER)
 ' maxW = maximum width of text in pixels to justify to.
 ' just$: C = centre, L = left, R = right, J = justify to width maxW
 ' background colour may extend to the right of the last character.
 LOCAL AS INTEGER txtwidth, n, k, px
 FOR n = 1 TO LEN(txt$) ' fill char width array and find total width
   txtW(n) = fontwidths(ASC(MID$(txt$,n,1)))+1
   txtwidth = txtwidth + txtW(n)
 NEXT n
 SELECT CASE just$
   CASE "C","c"
     px = x - txtwidth/2
   CASE "R", "r"
     px = x - txtwidth
   CASE "J", "j" ' justify
     px = x
     IF txtwidth < maxW THEN ' if text width is less than maxW add extra pixel spaces
       k = 0
       FOR n = 1 TO LEN(txt$)
         IF MID$(txt$,n,1)=" " THEN txtW(n)= txtW(n) + 1 ' increase space characters first
         k = k + 1
         IF (k + txtwidth) >= maxW THEN EXIT FOR
       NEXT n
       DO
         FOR n = 1 TO LEN(txt$)
           txtW(n)= txtW(n) + 1 ' increase all characters
           k = k + 1
           IF (k + txtwidth) >= maxW THEN EXIT FOR
         NEXT n
       LOOP UNTIL (k + txtwidth) >= maxW
     ENDIF
   CASE ELSE ' "L", "l"
     px = x
 END SELECT
 FOR n = 1 TO LEN(txt$)
   TEXT px,y,MID$(txt$,n,1), L,8,1,c,bc
   px = px + txtW(n)
 NEXT n
END SUB
 
DEFINEFONT #8
 5F201010 00000000 00000000 00000000 00000000 00000000 00000000 00000000
 00000000 00000000 00C000C0 00C000C0 00C000C0 00C000C0 000000C0 00C000C0
 00000000 00000000 00D800D8 00D800D8 000000D8 00000000 00000000 00000000
 00000000 00000000 80198019 C07F8019 0033C07F 80FF0033 006680FF 00660066
 00000000 00000000 003E0008 0068006B 00780068 000F003E 00CB000B 003E006B
 00000008 00000000 3066183C 60666066 803DC066 6603BC01 66066606 3C18660C
 00000000 00000000 007E003C 00660066 C03C003C C0C6C06C 80E380C7 C03CC07F
 00000000 00000000 00C000C0 00C000C0 000000C0 00000000 00000000 00000000
 00000000 00000000 00600030 00C00060 00C000C0 00C000C0 00600060 00000030
 00000000 00000000 006000C0 00300060 00300030 00300030 00600060 000000C0
 00000000 00000000 00060006 70E60006 801FF0FF 8019000F 8010C039 00000000
 00000000 00000000 00000000 00180018 00180018 00FF00FF 00180018 00180018
 00000000 00000000 00000000 00000000 00000000 00000000 00C000C0 00800040
 00000000 00000000 00000000 00000000 00F00000 000000F0 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00C00000 000000C0
 00000000 00010000 00020002 00040004 00080008 00100010 00200020 00400040
 00800080 00000000 007E003C 00C30066 00C300C3 00C300C3 006600C3 003C007E
 00000000 00000000 00380018 00D80078 00180098 00180018 00180018 00FF00FF
 00000000 00000000 007E003C 00C300E7 00070003 001C000E 00700038 00FF00FF
 00000000 00000000 007E003C 00C300E3 001E0003 0003001E 00E300C3 003C007E
 00000000 00000000 000E000E 0036001E 00660036 80FF00C6 000680FF 00060006
 00000000 00000000 00FE00FE 00C000C0 00FE00DC 000300E7 00C70003 003C00FE
 00000000 00000000 007F003E 00C00063 00FE00DC 00C300E7 006700C3 003C007E
 00000000 00000000 00FF00FF 00060006 0018000C 00180018 00300030 00300030
 00000000 00000000 007E003C 00C300C3 007E00C3 00C3007E 00C300C3 003C007E
 00000000 00000000 007E003C 00C300E6 00E700C3 003B007F 00C60003 0038007E
 00000000 00000000 00000000 00C000C0 00000000 00000000 00C000C0 00000000
 00000000 00000000 00000000 00C000C0 00000000 00000000 00C000C0 00800040
 00000000 00000000 00000000 00070001 0078001E 007800E0 0007001E 00000001
 00000000 00000000 00000000 00FF0000 000000FF 00FF00FF 00000000 00000000
 00000000 00000000 00000000 00E00080 001E0078 001E0007 00E00078 00000080
 00000000 00000000 007E003C 00C300C7 00060003 0018000C 00000018 00180018
 00000000 00000000 001F0000 C0408021 40A2409E 80A640A2 00400099 001F8020
 00000000 00000000 000E000E 001B001F 803B001B 803F8031 C071C071 E0E0C060
 00000000 00000000 00FE00FC 00C300C3 00FE00C3 00C300FE 00C300C3 00FC00FE
 00000000 00000000 007F001E 80E18061 00C000C0 00C000C0 806180E1 001E007F
 00000000 00000000 00FE00FC 80C300C7 80C180C1 80C180C1 00C780C3 00FC00FE
 00000000 00000000 00FE00FE 00C000C0 00FC00C0 00C000FC 00C000C0 00FE00FE
 00000000 00000000 00FE00FE 00C000C0 00FC00C0 00C000FC 00C000C0 00C000C0
 00000000 00000000 007F001E 80C18063 00C000C0 80C780C7 806380C1 801C807F
 00000000 00000000 00C300C3 00C300C3 00FF00C3 00C300FF 00C300C3 00C300C3
 00000000 00000000 00C000C0 00C000C0 00C000C0 00C000C0 00C000C0 00C000C0
 00000000 00000000 00300030 00300030 00300030 00300030 00300030 00E000F0
 00000000 00000000 00C600C3 00CC00CC 00D800D8 00EC00FC 00C600C6 00C300C3
 00000000 00000000 00C000C0 00C000C0 00C000C0 00C000C0 00C000C0 00FC00FC
 00000000 00000000 E0E0E0E0 E0F1E0F1 60DB60D1 60CA60DB 60CE60CE 60C460C4
 00000000 00000000 00E300C3 00F300E3 00DB00F3 00CF00DB 00C700CF 00C300C7
 00000000 00000000 003F001E C0C08061 C0C0C0C0 C0C0C0C0 8061C0C0 001E003F
 00000000 00000000 00FE00FC 00C300C3 00FE00C3 00C000FC 00C000C0 00C000C0
 00000000 00000000 807F001E C0C08061 C0C0C0C0 C0C0C0C0 8061C0C0 001E007F
 C001C003 00000000 00FF00FE 80C180C1 00FF80C1 00C600FE 00C300C6 80C100C3
 00000000 00000000 003F001E 00608071 003E0078 8003000F 80E380C1 003E007F
 00000000 00000000 00FF00FF 00180018 00180018 00180018 00180018 00180018
 00000000 00000000 00C600C6 00C600C6 00C600C6 00C600C6 00C600C6 0038007C
 00000000 00000000 00C600C6 006C00C6 006C006C 006C006C 00380038 00380038
 00000000 00000000 18C718C7 18C718C7 B06DB06D B06DB06D E038E038 E038E038
 00000000 00000000 006380C1 00360063 001C001C 0036001C 00630036 80C10063
 00000000 00000000 00C300C3 00660066 003C003C 00180018 00180018 00180018
 00000000 00000000 00FF00FF 00060006 0018000C 00300018 00600060 00FF00FF
 00000000 00E00000 00C000C0 00C000C0 00C000C0 00C000C0 00C000C0 00C000C0
 000000E0 00800000 00400080 00200040 00100020 00080010 00040008 00020004
 00010002 00E00000 00600060 00600060 00600060 00600060 00600060 00600060
 000000E0 001C0000 0036001C 00630036 000080C1 00000000 00000000 00000000
 00000000 00000000 00000000 00000000 00000000 00000000 00000000 FFFF0000
 0000FFFF 00000000 00900060 00900090 00000060 00000000 00000000 00000000
 00000000 00000000 00000000 00FE007C 001E00C6 00C6007E 00FE00C6 00000076
 00000000 00C00000 00C000C0 00FC00D8 00C600C6 00C600C6 00FC00C6 000000B8
 00000000 00000000 00000000 007E003C 00C000E6 00C000C0 007E00E6 0000003C
 00000000 00060000 00060006 007E0036 00C600C6 00C600C6 007E00C6 00000036
 00000000 00000000 00000000 007C0038 00FE00C6 00C000FE 007C00C6 00000038
 00000000 00380000 00600078 00F800F8 00600060 00600060 00600060 00000060
 00000000 00000000 003E8003 0063007F 007F0063 0060003E 807F007F 00FF80C1
 0000007E 00C00000 00C000C0 00FE00DC 00C600E6 00C600C6 00C600C6 000000C6
 00000000 00000000 00C000C0 00C00000 00C000C0 00C000C0 00C000C0 000000C0
 00000000 00000000 00300030 00300000 00300030 00300030 00300030 00300030
 00E00030 00C00000 00C000C0 00CC00C6 00D800CC 00F800F8 00CC00CC 000000C6
 00000000 00C00000 00C000C0 00C000C0 00C000C0 00C000C0 00C000C0 000000C0
 00000000 00000000 00000000 F0FFE0DC 30C630E7 30C630C6 30C630C6 000030C6
 00000000 00000000 00000000 00FE00DC 00C600E6 00C600C6 00C600C6 000000C6
 00000000 00000000 00000000 007C0038 00C600C6 00C600C6 007C00C6 00000038
 00000000 00000000 00000000 00FC00D8 00C600C6 00C600C6 00FC00C6 00C000D8
 00C000C0 00000000 00000000 007E003A 00C600C6 00C600C6 007E00C6 00060036
 00060006 00000000 00000000 00F800D8 00C000E0 00C000C0 00C000C0 000000C0
 00000000 00000000 00000000 00FC0078 00E000CC 001C0078 00FC00CC 00000078
 00000000 00000000 00600060 00F800F8 00600060 00600060 00780060 00000038
 00000000 00000000 00000000 00C600C6 00C600C6 00C600C6 00FE00CE 00000076
 00000000 00000000 00000000 00C600C6 006C006C 0038006C 00380038 00000010
 00000000 00000000 00000000 30C630C6 606F6066 6069606F C039C039 0000C030
 00000000 00000000 00000000 006C00C6 0038006C 00380038 006C006C 000000C6
 00000000 00000000 00000000 00C600C6 006C006C 006C006C 00380038 00300038
 00600070 00000000 00000000 00F800F8 00300018 00600020 00F800C0 000000F8
 00000000 00380000 00600060 00600060 00800060 00600060 00600060 00600060
 00000038 00C000C0 00C000C0 00C000C0 00C000C0 00C000C0 00C000C0 00C000C0
 000000C0 00E00000 00300030 00300030 00080030 00300030 00300030 00300030
 000000E0 00000000 00FF0073 000000DE 00000000 00000000 00000000 00000000
 00000000 00000000
END DEFINEFONT
 '
 ' font widths
FONT_WIDTH:
 DATA  32, 95 ' fontstart, fontcount
 DATA  1,2,5
 DATA  10,8,15,10,2,4,4,12
 DATA  8,2,4,2,8,8,8,8
 DATA  8,9,8,8,8,8,8,2
 DATA  2,8,8,8,8,10,11,8
 DATA  9,9,7,7,9,8,2,4
 DATA  8,6,11,8,10,8,10,9
 DATA  9,8,7,7,13,9,8,8
 DATA  3,8,3,9,16,4,7,7
 DATA  7,7,7,5,9,7,2,4
 DATA  7,2,12,7,7,7,7,5
 DATA  6,5,7,7,12,7,7,5
 DATA  5,2,5,8
 


Enjoy
Jim
Edited 2020-04-21 17:00 by TassyJim
VK7JH
MMedit   MMBasic Help
 
     Page 1 of 2    
Print this page
© JAQ Software 2024