Disabling fancy fonts

In Familiar Problems, I added an interpreter option to disable custom fonts. That game uses a bunch of different fonts for a bunch of different purposes, and it seemed reasonable to let people turn them off.

I’m now considering making it a standard feature of the interpreter. Since people can now embed any fonts they want, it seems like a fair precaution.

But…

Sometimes the choice of font matters: specifically, monospace fonts are needed for maps, ASCII art, and so on. (This matters to me specifically!) So in Familiar Problems, checking the “disable fonts” checkbox applies font-family: monospace !important; to the body of the document.

This works, but it’s pretty ugly. Monospace fonts are not great for reading large amounts of text at a time.

But, I don’t know how else to disable all fonts in the document, while leaving the monospace ones as monospace. Dialog specifically checks for monospace fonts in style classes when compiling, so I could set a special CSS property on any style classes that have a monospace font…but then what could I do with it?

Is this worth doing? And is there a better way to do it?

1 Like

I do think this is worth doing. Are “style classes” the same as the CSS class selector, or a Dialog specific feature? If it’s a CSS selector, then you could do something like:

*:not(.monospace) {
  font-family: sans-serif;
}

(not tested)

If it’s a Dialog specific thing I can’t help >_>

3 Likes

Yeah, Dialog “style classes” are basically just CSS rules applied to HTML classes, but implemented in a way that works on the Z-machine as well. You write standard CSS and Dialog analyzes it to figure out what parts should work on Z-machine (or C64, or terminal, or…). On the web, it just uses that CSS directly.

Which means authors can potentially include a dozen different classes with a dozen different fonts, some of which are monospace, some of which aren’t.

The only way I can think of is to generate two CSS classes for each style class in the source code, one which honors the font setting, and one which only honors it when it is monospace. At run time, select which one of the pair to use based on the user’s current preference.

Then my solution or something else using :not() should work :slight_smile: test it though of course.

This seems to be working. We’ll see if users report any bugs! When it’s building the stylesheet, it looks for “monospace” included anywhere in a font-family property; if found, it adds a second rule that reads .nofont .whateverclass { font-family: monospace, monospace; }.

1 Like

“Disable fonts” also sounds kind of weird as an option, so I added tooltips to the options menu. That way I can include a full sentence on what they mean.