primeau / Larn

A JavaScript port of Larn and Ularn available on larn.org
https://larn.org
MIT License
37 stars 6 forks source link

Feature request: allow user-specified font strings #4

Closed athompso closed 2 years ago

athompso commented 2 years ago

It's great that I can flip between dos437 and ... eh, whatever "Modern" was, I've already forgotten, but neither of them look good on my screen. I can use my browser's developer tools to change the font, but it doesn't seem to persist through a game. I would like to be able to just enter the font string directly. Not sure what the best way to do this would be, and I can't write JS so am not able to try implementing it myself.

primeau commented 2 years ago

Aww, no love for the classic "Courier New"? :)

What's your preferred font? I'd be happy to give it a try and see how it looks.

In the meantime, your best bet would be to do a search-and-replace on "dos437" in the code (display.js and larn.css) with your font and re-build. I know you said you're not a JS dev but the build instructions in the readme should just work. I can't stand the JS ecosystem so I made this project as bare bones as possible. Let me know if you have any trouble and I'd be happy to help you out.

athompso commented 2 years ago

I will need to spin up a dedicated VM if I have to install npm, in order to keep it quarantined. Oh, well, that's not impossible.

Part of my specific issue is that I'm running under Windows on a 4k monitor with scaling set to 125% so some fonts just render strangely, and on the 55" monitor in front of me it's really glaringly obvious when it happens.

The "Modern" mode (Courier New?) doesn't work at all for me - the "@" to indicate the player character vanishes! I guess I should open a separate issue for that one of these days...

I've tried Hack, Consolas, the set of { Lucida Sans Typewriter, Bitstream Vera Sans Mono, DejaVu Sans Mono, Liberation Mono, Ubuntu Mono - they're all basically the same}, Droid Sans Mono, Lucida Console, Noto Mono, OCR A, Source Code Pro, and several others I don't currently have installed, for both Nethack and [U]Larn over the years.

As much as I hate to admit it, Microsoft's Consolas actually works quite well for roguelikes. It's got far too short a height to be pleasant to read text, but its squarer aspect ratio works better than e.g. the Bitstream Vera or Lucida fonts which although otherwise pleasant, are too tall and skinny to render a dungeon very convincingly. Hack works reasonably well, too.

(Yes, I'm a typography snob, in case that wasn't immediately obvious.)

athompso commented 2 years ago

Oh, if you want a real "retro" feel, I might suggest VT323 or ModeSeven, although I don't know if their glyph coverage will be adequate - both are pretty small.

primeau commented 2 years ago

Bummer, they actually both look great on the intro screen, but totally fall apart after that...

VT323 intro: image

ModeSeven intro: image

VT323 maze: image

ModeSeven maze: image

Even with some tweaks VT323 is probably too narrow. I think ModeSeven might be fixed by making the '.' the same width as everything else, but I'm hopeless at editing fonts and have burned many, many hours failing to fix a few other fonts while I was adding the DOS and Amiga font options (Safari is still broken), so I have to bow out of trying again for my own sanity.

athompso commented 2 years ago

Wait, you're editing fonts??? Holy crap, dude. But what you're seeing is also very strange... Ever thought about re-implementing [n]curses in JS instead? :-D

athompso commented 2 years ago

Well, here's Hack, which looks OK: image

primeau commented 2 years ago

Well, I tried to edit the DOS font so it would look 100% correct on Safari, but failed after many hours of effort so I gave up...

The problem you're seeing is that the dot char isn't actually monospaced so the rows are getting compressed. There's not much I can do about that without a bunch of effort to change the rendering engine, or successfully editing the effing fonts :)

I have to say I actually prefer the non-serif look of the Hack font over Courier in Modern mode, but the dots are a bit big for my liking. Have you got any other suggestions for non-serif monospaced fonts?

athompso commented 2 years ago

So far, I have a short-list of fonts that are known to be Monospaced, Sans-Serif, and have at least the wall and dot glyphs. The vast majority of sans-serif monospace fonts are all just about clones of each other (and in many cases they are literally based off the earlier font). I haven't gone through the list and tested them all on dungeon level 1, yet. And as you can see it's not a fully-complete dataset, either.

Now I need to dive down a different rabbit hole for a while, but I'll get back to this - it involves FONTS!

Name License Serif Designer Foundry Distributor Family Metric-compatible with Availability Supports LARN?
Actual Mono Light Sans Frutitype https://www.myfonts.com/fonts/frutitype/actual-mono/ Y
Code New Roman Sans Sam Radian Y
Cousine Ascender Google Croscore Courier New Chrome OS Y
DejaVu Sans Mono - - - Deja Vu Bitstream Vera Sans Mono https://dejavu-fonts.github.io/ Y
Fantasque Sans Mono Sans Jany Belluz - - - - https://github.com/belluzj/fantasque-sans Y
Fira Mono Sans Erik Spiekermann et al. Monotype bBox Type Fira - https://bboxtype.com/typefaces/FiraMono Y
Hack Sans SourceFoundry SourceFoundry - https://sourcefoundry.org/hack/ Y
Inconsolata Sans Raph Levien - - - Consolas https://levien.com/type/myfonts/inconsolata.html Y
JetBrains Mono Sans JetBrains - - https://www.jetbrains.com/lp/mono/ Y
Liberation Mono Sans Steve Matteson Ascender Red Hat Liberation Croscore/Cousine/Courier New https://github.com/liberationfonts Y
Monofur Sans Tobias Kohler (unci narynin) euroference http://luc.devroye.org/fonts-24320.html Y
Monospaceland Extra Light Sans https://www.myfonts.com/fonts/pepper-type/monospaceland/ Y
NK57 Monospace Sans Typpodermic Y
NK57 Monospace Semicondensed Sans Typpodermic Y
Noto Sans Mono Demi Google Google Noto https://fonts.google.com/noto Y
Pexico Regular Sans Ondrej Job Setup Type/URTD MyFonts https://www.myfonts.com/fonts/urtd/pexico/ Y
ProFont ? Tobias Jung et al. Monaco https://tobiasjung.name/profont/ Y
PT Mono SIL OFL Sans Alexandra Korolkova ParaType Rospechat Public Type https://www.paratype.com/fonts/pt/pt-mono Y
Source Code Pro SIL OFL Sans Paul D. Hunt Adobe https://fonts.adobe.com/fonts/source-code-pro Y
Ubuntu Mono Dalton Maag Ltd. Canonical Y
Fira Code Sans Erik Spiekermann et al. Monotype bBox Type Fira - https://github.com/bBoxType/FiraSans Y?
athompso commented 2 years ago

Oh, also, do you need a font in WOFF format? I can't tell for sure here.

If you need webfonts especially, I would probably just pick from one of the ones that render properly here: https://fonts.google.com/?category=Monospace&preview.text=a%E2%96%92%E2%96%92%E2%96%92%C2%B7@%C2%B7%E2%96%92%C2%B7%E2%96%92A&preview.text_type=custom

primeau commented 2 years ago

Check out the latest beta -- I went down my own Google Font rabbit hole a few days ago and thought Noto Sans looked really good so I went ahead and changed the modern font to that on Chrome. PT-Mono also looked good too. Thanks for the inspiration!

I still need to make something other than Courier work on Firefox and Safari, but that's a project for another day. Including the problematic characters would have saved me a ton of time!