Foobler notes - 2

Slow day and I felt like seeing if I could convert another Letter Spirit font into PicoCalc format.

I found some graph paper, made multiple 8x12 boxes, added guide lines for the pokey-up and droopy down parts of lowercase letters, then filled in boxes to match the printed example of the font “Sluice”.

The left and right sides made nibbles (term for 4 bit number, a half byte, right?) and I jotted those down into 24 bytes for each glyph, then happily entered them into the program.

I’d hoped that the font could live off in a file of its own, but maybe FONT LOAD is no longer a command in MMBasic version 6? If so, too bad.

That does bring up a question: Is it possible to include another file in one’s program?

'sluice font, Letter Spirit project
DefineFont 9
1a610c08
78000000 24790204 00000f12 'a
48404000 25494a4c 00000913 'b
48000000 20495264 00000f10 'c
09010100 52492919 00004864 'd
78000000 204f1224 00000f10 'e
490a0c00 08091224 00000808 'f
09000000 51492919 3c124961 'g
49404000 09496553 00000909 'h
09040200 08080402 00000808 'i
09040200 08080402 20100808 'j
49404000 14486452 00004122 'k
08080800 24480808 00000912 'l
09000000 49492513 00004949 'm
49000000 09496553 00000909 'n
09000000 0a492513 0000080c 'o
09000000 4a492513 4040484c 'p
48000000 29495264 01010919 'q
09000000 40492513 00004040 'r
0f000000 024f2010 00007804 's
09080800 0a492412 0000080c 't
48000000 53494848 00004965 '
41000000 22491422 00000814 'v
49000000 25494949 00000913 'w
49000000 1a496452 0000482c 'x
49000000 51494949 3c124961 'y
0f000000 12492412 00004f24 'z
End DefineFont
Font 9,2
'For i = 32 To 127
'  If i Mod 16 = 0 Then
'    'Print
'  EndIf
'  Print Chr$(i);
'Next i

CLS

Print "there will be times"
Print " when the struggle"
Print "  seems impossible"
Print
Print "   alone unsure"
Print "dwarfed by the scale"
Print "   of the enemy"

Print            
Print "   remember this"
Print
Print "   freedom is a"
Print "    pure idea"

4 Likes

Box of goodies came from Adafruit last night, including a few Pico 2W boards.

I looked at the 2W for a bit, thinking, “I got the realtime clock, maybe I should solder thin wires over to the Pico 2W board?”, then decided against it. One thing at a time!

Removed the batteries. Opened the back of the case. Unlatched the connector to the screen, by carefully flipping up the movable black latch. Not at all obvious when I first saw it.

Once the main board was loose, I lifted it off the front of the case and sat it by itself. I removed the Pico H board. Before I inserted the Pico 2W board, I cabled the 2W to my computer’s micro-USB cable, holding down the “bootsel” button as I connected the cable. The 2W showed up as a tiny USB drive, to which I copied the latest Webmite,WebMite_WEBRP2350_V6.00.02_PicoCalc_RC1.uf2

When the 2W rebooted and the LED started the PicoCalc heartbeat blink, I detached it from the cable and inserted it into the PicoCalc’s socket.

I took a few minutes to remove the LCD from the front of the case and used glass cleaner to get the smudges from my original assembly off the screen and protective cover glass. Reassembled, using blue “painter’s tape” to center and hold the LCD, put screws back in.

Powered it up and it works!

Next? Maybe those network commands.



4 Likes

FONT LOAD is not a command in PicoMite. (I don’t think it ever has been?) There’s a lot of stuff in MMBasic that isn’t in PicoMite, and this happens to be one of those things.

Some versions of MMBasic have the #include preprocessor directive and it can be used to include other files. But PicoMite doesn’t have that ability either.

So for PicoMite you pretty much have to just copy all the code you need into a single .bas file, including any font(s) you have defined.

Another option is to use the LIBRARY feature, as described in the manual. There are some caveats to it though. And it uses some flash space that would need to be managed and saved to SD if you want to restore it after flashing an update, etc. It also doesn’t seem like the easiest thing to actively edit and maintain, although it does provide an option for sharing code across multiple programs.

For maintaining (and sharing, or backing up) an applicaiton though, it probably makes more sense to just keep it all in one really large file.

1 Like

Also, for anyone else that might be scratching their heads wondering what “Letter Spirit” is, I did some digging out of curiosity and found this:

Kind of interesting and cool, I guess, but not exactly legible. Hehe. :slight_smile:

3 Likes

This pleases me in ways I didnt know were possible.

2 Likes

Once I finish up my font color palette generator program (pretty much done, but working on some of the last few bells and whistles), and up my skill set (need to learn saving & loading to files, working with arrays, subs, and such) I wanted to make a program to draw characters that could be used towards building a font. If I can make the drawing tool and save the pixels on / off into an array, would it be difficult convert to the hex necessary for a character to use with DefineFont ?

2 Likes

It should be possible (and probably not too difficult) to convert to the hex needed to define the fonts. There’s some extra hex at the top in a header line that defines the width and height of the font and number of characters.

For a given character, like this little guy from the Pico-8 font:
image
it’s represented as:
0x44,0x40,0x40, // Chr$(33) !

In binary that’s:
01000100,01000000,01000000

Which if we break it up to look like the actual font width and height, looks like this:
0100
0100
0100
0000
0100
0000

So you’d end up running through your array, and taking each set of 8 bits and converting them to the corresponding hex value. Repeat that across all the characters, take care of the header and other little formatting details, and optionally add some auto-generated comments if your editor allows for naming the font, etc.

I haven’t used these myself, but it looks like
num = VAL("&B" + binarystring$)
would give the numerical value. And then that could be sent to
hex$(num,2)
to get the two character hex value.

A font editor on the PicoCalc would be really cool. That’s a great idea. :slight_smile:

3 Likes

Thank you. I’ve just started on the gui/drawing tool and this will be very helpful once I start moving around the data. Do you know of any hard or practical limits on pixel size for characters or total font data size?

1 Like

I’m not aware of any hard limits on the pixel size or total font data size, but I took a look at the built in fonts that are included in PicoMite. Interestingly, there are source files for 9 different fonts, even though the manual only lists 8 fonts that are built in. (There’s also a duplicate version for font #6 that appears to be older and unused and only has characters 0-9 defined. I didn’t list it here.) The last font in the table is the unmapped one.

Hopefully this gives an idea of the currently used limits, although I’m pretty sure you can define fonts that use even more bytes. I think the only limit on that might be available memory. What I’d be more worried about is a limit on the actual characters defined – the only examples I’ve ever seen use at most 223 characters, and I’m not sure if a font can be defined using characters outside of that range. You can definitely define a font using fewer characters, possibly even down to a single character. I’m not sure it would actually be useful for anything, but you might be able to define a font with a single character that’s 320x320. :laughing:

Font Number Source Size (W x H) Data Size Character Set Description
1 font1.h 8x12 2680 bytes 223 ASCII characters (including 7F to FF hex) Standard font (default on start-up)
2 Misc_12x20_LE.h 12x20 2854 bytes 95 ASCII characters Medium sized font.
3 arial_bold.h 16x16 3044 bytes 95 ASCII characters A large font for VGA versions. NOT IN PICOCALC BUILD.
3 Hom_16x24_LE.h 16x24 4564 bytes 95 ASCII characters A large font for HDMI versions and LCD panels.
4 Fnt_10x16.h 10x16 4484 bytes 223 ASCII characters (including 7F to FF hex) A font with extended graphic characters. Suitable for high resolution displays.
5 Inconsola.h 24x32 9124 bytes 95 ASCII characters Extra large font, very clear.
6 ArialNumFontPlus.h 32x50 2204 bytes 11 characters (0 to 9 and colon) Numbers plus decimal point, positive, negative, equals, degree and colon symbols. Very clear.
7 Font_8x6.h 6x8 580 bytes 95 ASCII characters A small font useful when low resolutions are used.
8 tinyfont.h 4x6 292 bytes 95 ASCII characters An even smaller font.
N/A X_8x13_LE.h 8x13 1239 bytes 95 ASCII characters Included in source, but not not used or given a font number.

Since the largest default font was 50px, I made that my target max, which is close to the max that would be usable in my editor’s gui. So far I’ve got drawing > screen reading >binary string > a hex value.

I drew the “!” and was able to get “444040” in return from my program. Looking at your pico8.bas I see 440, but not pick out the exact sequence and I think the first 4 is declaring the number of x pixels. Is the whole character set treated like a single binary string converted to hex or something like that?

DefineFont #10
60200604 44000000 00AA4040 A0AEAE00 A2406EEC

Update: I see I need make sure to break up into 8 bit sections (as advised), and my results are changing on larger character sets, but I still get 444040 for the ! character in pico8. I need to read up more on working with binary & hex.