Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
generate multiple size fixed-width fonts on the fly (no editor needed)
#11
Also @madscijr I thought this was pretty cool.

vscode shows minimap with the characters pretty well!

[Image: bdf-multifont-5.png]

Do you have a tool to create the BDF arrays? so we wouldn't have to use arrTileText(nn) for example?
grymmjack (gj!)
GitHubYouTube | Soundcloud | 16colo.rs
Reply
#12
Heh, thanks. The only spec I had was what I read on Wikipedia & whatever links I put in the source code. For the larger characters, all I did was write some utility to "upsize" the fonts to the bigger sizes, I figured I can edit the higher res fonts later as I have the time / need. For now it just looks like old 8-bit or Atari graphics. 

When I tried generating the bigger fonts, it didn't work, so I scoured the web looking for example BDF fonts at bigger resolutions and just compared the values to see what I had gotten wrong, and came up with enough basic understanding of the parameters that I finally could generate upto 64x64 characters. I considered 128x128 or bigger but don't have any need for that right now. 64x64 is big enough for title screens or to use as "sprites" for any old school type video games. 

Those are all based on the C64 CMBSCII charset, but for some reason some of the characters have duplicates. I did write another utility that prints out a character sheet with the associated ASCII values, and lists which are duplicates, so I know which can be overwritten for adding additional characters. I plan on adding the duplicate finder to a future revision, or better yet to the character editor based on @bplus's skeleton code. 

Anyway it's nice someone finally noticed this program, hopefully it will come in handy for someone.

PS no tools really, I just wrote some quick utility to generate the initial 8x8 code years ago (but back then it was used to draw a tilesheet image, not a font file), and then wrote some quick utility to take the 8x8 array and magnify it and generate the larger source code as a text file which I just pasted into my program. I think at some point I generated some of the code using Excel formulas. Whatever works. If I have time I'll post the upsizing utility code later.
Reply
#13
thank you for this example.  job well done!

but how many times did you have to compile this program?  on my computer.  the 3.8mib file took a few minutes to complete.  yes it works on linux without modification.

i don't think it's a "standard" c64 character set.  it has some weird characters.  which don't follow a certain order.  such as the four to create a circle in 2x2 grid.  also there is no "open" trebol.  the other "open" playing card symbols were consecutive.  but then suddenly the filled-in trebol with them.  (eh maybe that should be "club".  "trebol" is what it's called in spanish.)

it's odd that you demonstrated an example of a font.  which is taller in pixels than it is wide.  it would have been better.  for example in my toshiba laptop which could only run windowsxp.  before "service pack 2".  that was the last computer i've ever had.  which had a screen that wasn't much wider than it was tall.  sadly that screen leaked.  which was the reason why i had to stop using that computer.

i have a sprite sheet somewhere i used in a few programs.  sadly it's for 12x12 glyphs.  for this scheme to work well.  it seems to want powers of two.  what i wanted from it.  was "cool numbers" like what used to be seen in newspapers.  in other words.  numbers written like lowercase letters.  that is 3, 4, 5, 7, 9 dipping below.  6 and 8 like capital letters.  and 0 and 1 written the smallest.  in most of the fonts.  the two was also written smallest.  but i prefer it like capital letter.

i made a variation.  where i tried to replicate the trs-80 model iii 2x3 graphic blocks.  but it had a major problem.  it bit into the original ibm pc character set.  beginning with the shaded blocks at chr$(176) and the line-drawing glyphs.  so for the last wave of 16 characters.  instead it went into chr$(224) to start.  but it was clumsy making calculations for it.  to take a picture.  originally to be drawn only with chr$(219) blocks.  into those 2x3 graphic blocks.
Reply
#14
(07-21-2025, 11:39 AM)hsiangch_ong Wrote: thank you for this example.  job well done!

Thank you!

(07-21-2025, 11:39 AM)hsiangch_ong Wrote: but how many times did you have to compile this program?  on my computer.  the 3.8mib file took a few minutes to complete.  yes it works on linux without modification.

As is, the program is over 67,000 lines long, so it can take a while to compile.
This is only because the font definitions are in the source code.
This can be modified to instead have the font definitions saved in one or more separate files, 
either as a text file or a binary format.
For an example of binary, see bplus's character editor example:
https://qb64phoenix.com/forum/showthread...h+Ascii%22

(07-21-2025, 11:39 AM)hsiangch_ong Wrote: i don't think it's a "standard" c64 character set.  it has some weird characters.  which don't follow a certain order.  such as the four to create a circle in 2x2 grid.  also there is no "open" trebol.  the other "open" playing card symbols were consecutive.  but then suddenly the filled-in trebol with them.  (eh maybe that should be "club".  "trebol" is what it's called in spanish.)

I said it was -based on- the C64 PETSCII character set, it's not an exact reproduction. If you want that, you'll need to edit the characters to match the ASCII order and all that of the real CBM character set.

(07-21-2025, 11:39 AM)hsiangch_ong Wrote: it's odd that you demonstrated an example of a font.  which is taller in pixels than it is wide.

The default font in DOS and QB64/QB64PE screen 0 text mode is 8 pixels wide x 16 pixels high. The default font on the C64 is 8 pixels wide by 8 pixels high.
So this example has both kinds of those, from 8 pixels wide up to 64 pixels wide (the biggest 1:2 ration font is 32x64 pixels).
If you don't want to use the 1:2 ration fonts, you can just remove them and modify the code to just use the 1:1 ratio fonts.
You will need to modify Function GetTiles$ to comment out the portions in the If/Then that handle the 1:2 ration fonts, these lines:

Code: (Select All)
ElseIf iFontWidth% = 8 And iFontHeight% = 16 Then
    sCode = "GetTileText8x16"
    GetTileText8x16 arrTileText()
    iBytesPerLine = 1
...
ElseIf iFontWidth% = 16 And iFontHeight% = 32 Then
    sCode = "GetTileText16x32"
    GetTileText16x32 arrTileText()
    iBytesPerLine = 2
...
ElseIf iFontWidth% = 32 And iFontHeight% = 64 Then
    sCode = "GetTileText32x64"
    GetTileText32x64 arrTileText()
    iBytesPerLine = 8
and add your own portion for 12x12, like:

Code: (Select All)
ElseIf iFontWidth% = 12 And iFontHeight% = 12 Then
    sCode = "GetTileText12x12"
    GetTileText12x12 arrTileText()
    iBytesPerLine = 2
If you just want 12x12, then you should comment out all those except for the 12x12 block you add. 

Then you need to add your own tile definition function
Code: (Select All)
Sub GetTileText12x12 (arrTileText() As String)

(07-21-2025, 11:39 AM)hsiangch_ong Wrote: i have a sprite sheet somewhere i used in a few programs.  sadly it's for 12x12 glyphs.  for this scheme to work well.  it seems to want powers of two.
This can be made to work with 12x12 glyphs, you just need to make a copy of the 16x16 font, and edit it to be 12x12.
You can write a program to generate it - read in the image file containing the font, use the point(x,y) command to look at each 12x12 glyph, and output the source code, or a file, that contains the font definition.
Then you need to modify the code to generate a 12x12 BDF file from the data.

Read the comments in Function SaveBDF$ which explain the parameters for the BDF file, so you know what values to set.

It may take some trial and error - go online and search for one or more examples of a 12x12 BDF font, and use a program like Beyond Compare to compare it against the font the program generates, and you will see if there are any values which need to be different.

(07-21-2025, 11:39 AM)hsiangch_ong Wrote: what i wanted from it.  was "cool numbers" like what used to be seen in newspapers.
You can do it, but you will need to modify the program. Again, Function SaveBDF$ is probably the starting point for getting it to work with a 12x12 font.

Good luck!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Digit II level editor in progress pmackay 0 335 07-19-2025, 04:03 AM
Last Post: pmackay
  SAM native QB64PE speech synthesizer, port from C (v0.2.1), fixed design-time errors madscijr 5 954 04-09-2025, 03:55 PM
Last Post: madscijr
  ImageGrid (combine multiple image files into one giant poster) madscijr 2 725 12-17-2024, 03:59 AM
Last Post: madscijr
  seperate input from multiple mice v0.54 graphic demo madscijr 1 695 06-21-2024, 01:12 PM
Last Post: madscijr
  IT'S ALIVE! reading seperate input from multiple mice plugged into one PC v0.30 madscijr 1 784 05-26-2024, 04:14 PM
Last Post: madscijr

Forum Jump:


Users browsing this thread: 1 Guest(s)