Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 09:02 01 Aug 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 : PropText for CMM2, simple library for proportional text output

     Page 1 of 2    
Author Message
jirsoft

Guru

Joined: 18/09/2020
Location: Czech Republic
Posts: 533
Posted: 01:57pm 11 Jul 2021
Copy link to clipboard 
Print this post

Hi,
I have put on my GitHub very simple library for outputting of proportional text. It can be used with either built-in or user fonts on CMM2, simply call text.PROP instead of TEXT command...
The best use case can be text adventures (Hi Tom  ), because of better readability of the texts in proportional font.

PropText


Jiri
Napoleon Commander and SimplEd for CMM2 (GitHub),  CMM2.fun
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 02:24pm 11 Jul 2021
Copy link to clipboard 
Print this post

  jirsoft said  Hi Tom [;)


Hi Jiri, very nice . If I ever decide to port the Magnetic Scrolls engine I will certainly take a closer look. For the Infocom and Scott Adams games I feel a monospace font is more authentic ... and you may not have noticed but everything I've done for the CMM2 actually outputs to the Serial Console (no possibility of proportional spacing there) - even The Welcome Tape menu system echos to the Serial Console even though most of the tape requires a VGA display.

Best wishes,

Tom
Edited 2021-07-12 00:24 by thwill
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 10:57pm 11 Jul 2021
Copy link to clipboard 
Print this post

An alternative if you are willing to pre-prepare the font:
https://www.thebackshed.com/forum/ViewTopic.php?TID=12021&P=1#145429

Jim
VK7JH
MMedit
 
jirsoft

Guru

Joined: 18/09/2020
Location: Czech Republic
Posts: 533
Posted: 08:41am 12 Jul 2021
Copy link to clipboard 
Print this post

  TassyJim said  An alternative if you are willing to pre-prepare the font:
https://www.thebackshed.com/forum/ViewTopic.php?TID=12021&P=1#145429

Jim

Hi Jim,
yes, this was also my first thought to extend SimplEd and generate the data for the font. It's nice implementation, but it has (from my point of view) just one plus and more minuses:
+  speed on init (but it can be also massive improved with CSUB)
-  can't be used universally for existing fonts
-  in your implementation with just width, you can't use font as monospaced (TEXT and PRINT commands) when needed (I'm using also offsets...)


Right now I would like just improve the initialization speed and to add some PRINT-like SUB, so it can be used more wide...
Jiri
Napoleon Commander and SimplEd for CMM2 (GitHub),  CMM2.fun
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1132
Posted: 04:42pm 12 Jul 2021
Copy link to clipboard 
Print this post

  jirsoft said  Right now I would like just improve the initialization speed and to add some PRINT-like SUB, so it can be used more wide...

Fonts 1 to 7 don't change (potentially dangerous assumption) so perhaps you could pre-measure character width and offset and store those strings in the INC file. Since strings can't be stored in a program with ascii less than 32 (?) or greater than 127, you would need to add an offset to each value.
Visit Vegipete's *Mite Library for cool programs.
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1593
Posted: 04:56pm 12 Jul 2021
Copy link to clipboard 
Print this post

  Quote  When logic and proportion have fallen sloppy dead ...


Thanks! I think this is a valuable addition.

Regards
Michael
causality ≠ correlation ≠ coincidence
 
jirsoft

Guru

Joined: 18/09/2020
Location: Czech Republic
Posts: 533
Posted: 07:09pm 12 Jul 2021
Copy link to clipboard 
Print this post

  vegipete said  Fonts 1 to 7 don't change (potentially dangerous assumpion) so perhaps you could pre-measure character width and offset and store those strings in the INC file. Since strings can't be stored in a program with ascii less than 32 (?) or greater than 127, you would need to add an offset to each value.

Hi Pete,
yes, that's good idea. And for width + offset of built-in fonts is enough 50, so it can be easily put to ASCII.

For the potentially dangerous assumption: I will initialise strings with precalculated values, but it can be recalculated with the SUB call anytime later...
Jiri
Napoleon Commander and SimplEd for CMM2 (GitHub),  CMM2.fun
 
jirsoft

Guru

Joined: 18/09/2020
Location: Czech Republic
Posts: 533
Posted: 09:33pm 15 Jul 2021
Copy link to clipboard 
Print this post

Hi all,
I have updated this library to version 0.02:
massive speedup because of precalculation of offsets and widths of built-in fonts (thanks Pete  ), so initAll.PROP takes no time.

PRINT like commands:
print.PROP(txt$), printLn.PROP(txt$) and wrap.PROP(txt$)
 all can be mixed with standard PRINT, they use just strings as parameter, last one is word wrapped (can be useful)

color.PROP(front%, back%) is like COLOR, but sets parallel intern variables (because I can't read the environment), so use simply this instead of COLOR
font.PROP(fnt%) the same for FONT

Enjoy!

Edited 2021-07-16 07:36 by jirsoft
Jiri
Napoleon Commander and SimplEd for CMM2 (GitHub),  CMM2.fun
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 10:07pm 15 Jul 2021
Copy link to clipboard 
Print this post

  vegipete said  
  jirsoft said  Right now I would like just improve the initialization speed and to add some PRINT-like SUB, so it can be used more wide...

Fonts 1 to 7 don't change (potentially dangerous assumption) so perhaps you could pre-measure character width and offset and store those strings in the INC file. Since strings can't be stored in a program with ascii less than 32 (?) or greater than 127, you would need to add an offset to each value.


Fonts 1, 6 and 7 can't be changed in a program but the other builtin ones can be substituted.

Jim
VK7JH
MMedit
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1132
Posted: 11:33pm 15 Jul 2021
Copy link to clipboard 
Print this post

How weird that the wrap.PROP sample resulted in that vertical gap in the text.

For your next trick, could you force the printed line of (wrapped) text to be a specific number of pixels wide? Then a column of text would be left AND right justified.
Visit Vegipete's *Mite Library for cool programs.
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3378
Posted: 12:16am 16 Jul 2021
Copy link to clipboard 
Print this post

  vegipete said  For your next trick, could you force the printed line of (wrapped) text to be a specific number of pixels wide? Then a column of text would be left AND right justified.

Variable-width spaces to right and left justify proportional text--I did that back in 1982--in Fortran.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
jirsoft

Guru

Joined: 18/09/2020
Location: Czech Republic
Posts: 533
Posted: 07:46am 16 Jul 2021
Copy link to clipboard 
Print this post

  vegipete said  How weird that the wrap.PROP sample resulted in that vertical gap in the text.

I think this is just because of repeated text else it will not happen (hopefully  )

  vegipete said  For your next trick, could you force the printed line of (wrapped) text to be a specific number of pixels wide? Then a column of text would be left AND right justified.

I can, but I need to study the typography a little bit... When you can fit more words into set space, it's OK, because you can do it by changing of inter-word spaces. When you fit just one word, can be adjusted inter-char spaces and it looks UGLY   Finally what to do, if you can't fit the longer word into set space at all???
Jiri
Napoleon Commander and SimplEd for CMM2 (GitHub),  CMM2.fun
 
jirsoft

Guru

Joined: 18/09/2020
Location: Czech Republic
Posts: 533
Posted: 02:21pm 17 Jul 2021
Copy link to clipboard 
Print this post

  vegipete said  For your next trick, could you force the printed line of (wrapped) text to be a specific number of pixels wide? Then a column of text would be left AND right justified.

Added justify.PROP(txt$, txtWidth%, dx%)...full jutified left and right word wrapped proportional text with size txtWidth% written to offset dx%

Also added one parameter to print.Prop and printLn.Prop:
print.PROP(txt$, addSpace$)...prints proportional txt$ on current position, wraps character to next line, without line feed
If the string addSpace$ is not empty, then to N-th SPACE (" ") in txt$ is added PX pixels, where PX=ASC(MID$(addSpace$, N, 1))print.PROP(txt$, addSpace$)

Usually when the text will be full justified, should be also possibly hyphenated - this wii bring massive amount of work, which I don't think make sense. So if the word not fit into set space, then is simply printed out (and will be wider), in the code is prepared ERROR for this situation when needed.

I'm also not adjust inter-letter space, as I don't like it and inter-word space could be just expanded not compressed (again, when used not so nice and code is much simpler)...
Enjoy!


Edited 2021-07-18 00:35 by jirsoft
Jiri
Napoleon Commander and SimplEd for CMM2 (GitHub),  CMM2.fun
 
jirsoft

Guru

Joined: 18/09/2020
Location: Czech Republic
Posts: 533
Posted: 02:38pm 17 Jul 2021
Copy link to clipboard 
Print this post

  TassyJim said  Fonts 1, 6 and 7 can't be changed in a program but the other builtin ones can be substituted.

Then can be simply called initFont.PROP(font%) for the specific font after the substitution  and it will work OK again...
Jiri
Napoleon Commander and SimplEd for CMM2 (GitHub),  CMM2.fun
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3378
Posted: 02:44pm 17 Jul 2021
Copy link to clipboard 
Print this post

Full justified proportional text on the CMM2--a decidedly non-trivial task--nice.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
knivd

Regular Member

Joined: 07/09/2014
Location: United Kingdom
Posts: 72
Posted: 07:59am 18 Jul 2021
Copy link to clipboard 
Print this post

You could have used the drawChar() function from my C interpreter. It is quite simple and natively supports proportional fonts. Available on Github: https://github.com/knivd/C.impl/blob/main/RIDE/graphics.c
 
jirsoft

Guru

Joined: 18/09/2020
Location: Czech Republic
Posts: 533
Posted: 10:55am 18 Jul 2021
Copy link to clipboard 
Print this post

  knivd said  You could have used the drawChar() function from my C interpreter. It is quite simple and natively supports proportional fonts. Available on Github: https://github.com/knivd/C.impl/blob/main/RIDE/graphics.c

Maybe I'm wrong, but I don't see any intersections between you code and PropText library...

Your code is maybe superior to mine, but it simply outputs text in your special formatted font. They are many such routines and they can for sure be easily adapted to MMBasic, but:
1. I need to rewrite it from C (that I hate or at least dislike)
2. Need to use some special fonts

The target for PropText library is totally different:
1. use standard fonts on CMM2, without modification. Those fonts could be either taken directly from FW, or edited/imported direct on CMM2 (SimplEd) or converted/download from internet... (FontTweak etc.)
2. calculate offsets and widths from those fonts and use them as proportional ones
3. because the points 1 and 2, you can mix proportional and fixed-size fonts, I'm using TEXT command for outputting one char

But anyway thanks for this offer and for your interpreter as whole. For somebody who likes the C-like languages it's very nice and useful work  
Jiri
Napoleon Commander and SimplEd for CMM2 (GitHub),  CMM2.fun
 
knivd

Regular Member

Joined: 07/09/2014
Location: United Kingdom
Posts: 72
Posted: 02:24pm 18 Jul 2021
Copy link to clipboard 
Print this post

  jirsoft said  
1. use standard fonts on CMM2, without modification. Those fonts could be either taken directly from FW, or edited/imported direct on CMM2 (SimplEd) or converted/download from internet... (FontTweak etc.)


Oh, sorry. I must have misunderstood the goal
 
jirsoft

Guru

Joined: 18/09/2020
Location: Czech Republic
Posts: 533
Posted: 08:56pm 23 Jul 2021
Copy link to clipboard 
Print this post

Hi all,
PropText library was updated to v0.04. Main news are support for TAB and LF charecters in print.PROP command, because of it printLn.PROP is simpler now and it was added command tab.PROP(t%), where with t% are set TAB positions to every t% pixels.

I have added Test2.BAS for test...

Enjoy!


Jiri
Napoleon Commander and SimplEd for CMM2 (GitHub),  CMM2.fun
 
jirsoft

Guru

Joined: 18/09/2020
Location: Czech Republic
Posts: 533
Posted: 02:38pm 07 Nov 2021
Copy link to clipboard 
Print this post

Hi all,
in v0.05 I have added justifyLine.PROP SUB, that works similary to justify.PROP, but prints out just ONE line and returns in txt$ non printed rest of text.

Enjoy!
Jiri
Napoleon Commander and SimplEd for CMM2 (GitHub),  CMM2.fun
 
     Page 1 of 2    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025