as it so often is, it's time to do crimes against typography with pixel fonts

I need to copy a font off my windows 98 machine to my Raspberry Pi's framebuffer application.

obviously the way to do this is to just render out every character the font supports to bitmaps and then import those as spritesheet

based on file metadata, I've been trying to do this since April, and I think every time I've opened a text editor to write the simple python script I need, someone has messaged me on discord

fine I'll close discord and just be offline for an hour

and someone walks into my bedroom asking about help finding a cable

okay I generated it

and the part from April is wrong, and I need to fix it on Windows 98. DAMN IT

I'm glad Pillow now has .get_flattened_data to match .getdata, especially since neither of them do what I want, and have never done what I want

future foone:

it's Image.tobytes() that you want

okay I have the font imported and a very simple (no wrapping or newline handling) text engine:
THIS IS THE WRONG FONT (SIZE)
I've extracted MS Sans Serif 10 point. I need MS Sans Serif 8 point.
every day is a good day to pull out Visual C++ 6.0!
just kidding, I've already crashed the OS in that screenshot. The cursor switched to the text cursor and is stuck that way, you can't click anything

oh no, I need unicode support
in windows 98

I need unicows

oh good there's an open source replacement, OpenCow:
https://opencow.sourceforge.net/
Opencow

I do not recall how you do ASCII/Unicode dual-use source code. There's some macro you gotta wrap around your string literals, I seem to remember
MSLU: Develop Unicode Applications for Windows 9x Platforms with the Microsoft Layer for Unicode

the secret macro is _T("foobar") which'll do nothing in ASCII mode, but if _UNICODE is defined, it turns "foobar" into "unicode", by which they mean UCS-2
I copy-pasted UNICOWS.DLL into C:\WINDOWS\SYSTEM which of course crashed Explorer, because Windows 98
I still don't have UNICOWS.LIB and it may be a pain to get it
I think I can maybe get it from the Windows XP Platform SDK? Lets see if I can still get to it on a Windows 98 system.
oh goody you have to install everything and win98 can't run the MSIs
I do not currently have a local XP VM
okay it won't work. I think the API I'm using is not supported on win9x. I could check the docs but they pretend XP was the first windows
ok I went and remoted into another computer and used the XP compiler over there and got it done. I could have done this at the beginning but I was stubborn

ugh except this is ALMOST right.
The problem is: this is XP's MS Sans Serif, not Windows 98's.

Yeah they changed it a lot, mainly adding a bunch more characters for better language support.

I wonder if anyone has done a page showing
1. which fonts are included on windows
2. how they've changed over time

okay so the function call that I need that's missing from Windows 98 is called GetFontUnicodeRanges.

And the MSDN docs on my visual studio 6.0 discs does talk about it, but this is neat: it's a preliminary doc!

And here's the compatibility matrix!
NT needs 5.0, Windows 9x/me is unsupported, and CE is unsupported. You can't do this on your HP Jornada 720.
This is Visual Studio 6.0, which came out in 1998, so Windows 2000 and Windows XP don't exist yet. The latest available NT is NT4.
I love the 90s-ness of "here's system call: you can't use this for two more years"
so, which will be less pain: hacking a replacement for this function call, or fucking up an XP machine's fonts by overwriting its copy of MS Sans Serif with the Windows 98 one?
lets fuck up an XP VM! that might be amusing to see

okay wait, I'm a fool: The font isn't different, this is a different font.

"Microsoft Sans Serif" and "MS Sans Serif" are two different fonts. obviously.

Got it. I now have MS Sans Serif 8pt as a pseudo-deathgenerator font, and it's pixel identical to the Windows 98 text renderer.
see?
now... wordwrapping...

the last 4 hours may have been a diversion to not have to think about wordwrapping.

I mean, I guess python has a wordwrap module built in I can just use that, it'll be decent-enough.

no I can't use it because it assumes fixed width characters!

I could modify the built in python module wordwrap:
https://github.com/python/cpython/blob/main/Lib/textwrap.py

or I could port the JS/TS algorithm I already have in the Death Generator.

but that one is, uh, Not Simple.

but it's definitely too late to do either of those things today.
I lied. textwrap2 now supports variable width fonts:
although I punted on _handle_long_word
And yep it works on the current prototype, the HAMBOG12

@foone You need to count pixels. It is an absolute bear I've been avoiding for ages in mine. You could probably do it as a Dictionary and define whatever exceptions you need and then fail to the most common value, but...

We'll just say I've limited myself to fixed-width fonts and used tiles as exceptions. XD

@foone It was almost 10 years ago since I implemented my own font rendering in Android. Iirc, for word wrapping you will have to read-ahead each symbol, accumulating the width as you go, only set it to stone when you reach a whitespace, and move it down if you reach the max width.

You could easily do it with an O(n) algorithm, and optimize with dynamic programming if you group each word in beforehand.

@foone I fail to see the point of this point, but also WHAT ARE YOU HIDING with that blurred icon?
@redrummy if I wanted you to know what it was, it wouldn't be blurry!
@foone ahaha i forgot about that

@foone

....and this is the point at which I saw the thread, clearly indicating that something truly bizarre is going on in here.

@foone brb replacing Sans Undertale's dialog with MS Sans Serif
@foone feels extremely true to form to Microsoft to have two sans serif fonts with nearly the same (very generic) name.
@foone VMs are like sims, sure you could build a good life for them but they exist primarily to torture and murder for amusement

@foone VM snapshots are free*, I'd go with the latter

(*ok technically not but it's an XP VM, what's the snapshot gonna consume, 100MB?)

@foone When I was taught C++ in the University, we were told about exceptions, they were in the specification.

But we still checked for null pointers because AIUI no compiler supported exceptions back then.

@foone I still have my Visual Studio 6 CD case around here somewhere....
@gloriouscow a good programmer always keeps their visual studio 6.0, just in case
@foone I got it through my Dad's job at the time - I think it was $5. Worth it.
@gloriouscow oh absolutely

@foone I appreciate that MSVC is like, mostly unchanged still from a UI perspective. You still go in and set your include directories in the exact same way you did in 6.0.

I'm sure they'll fuck it up with AI at some point in a few years or something though.

@foone Depends on how you count. Windows 2000 is actually NT, Version 5.0. And Windows XP is 5.1. So the internal version is not the same as the consumer one.