joncampbell123 / dosbox-x

DOSBox-X fork of the DOSBox project
GNU General Public License v2.0
2.66k stars 378 forks source link

Long-term-future wishlist: scalable TrueType font for text modes? #754

Open emendelson opened 6 years ago

emendelson commented 6 years ago

This is simply a wish for the distant future. Is there any hope that DOSBox-X might someday have an option to use a scalable TrueType font (like Consolas or one of the free Google monospace fonts) for text-only modes like mode 3 and 7, and VESA-style modes that allow for 43- or 50-line text? That would make it possible to scale text-mode screens without compromise and make it possible to use (for example) a 43-line mode without squashed text.

At the moment, the excellent vDos emulator (very distantly derived from DOSBox) does this, but vDos supports only VGA graphics and includes many deliberate limitations. I use vDos every day for various purposes, but vDos will never run on a Mac, because it's tightly linked to Windows. (And it probably won't be possible to run vDos under Wine on a Mac a year from now when the macOS enforces 64-bit software.)

I know perfectly well that this isn't precise emulation, which is the goal of DOSBox-X, but it could be very useful for anyone working in text-only modes.

EDIT: It might also make it feasible to emulate Hercules Graphics Card Plus modes like italics, etc., which DOSBox SVN has never tried to match.

joncampbell123 commented 6 years ago

I've thought of that, yes.

If I implemented it, it would have some specific limitations, such as reverting back to bitmap rendering for any character who's bitmap was changed by the DOS program.

I've also envisioned doing this for the PC-98 mode since the extra resolution would benefit the readability of the kanji text and NO method is provided to change it from software.

emendelson commented 6 years ago

I'm delighted to hear that - and I'd thought about that same limitation. One thing that may be impossible is supporting the second VGA font bank. vDos now does that for the 512-character font in WordPerfect, but that requires a specific map of which unicode characters to use, which makes things impractical (except of course if the user has a way of creating a second-font-bank map....)

Anyway, I'm very glad to hear that this might happen someday!

joncampbell123 commented 6 years ago

@emendelson I can't emulate Hercules plus extensions because I have no documentation or hardware on that card.

emendelson commented 6 years ago

I don't think I have an actual card (of course I threw mine out years ago), but if you'll send me a mailing address, I'll gladly have this sent to you:

https://pay.ebay.com/rxo?action=view&sessionid=889277919018

If there's no way to send me an e-mail directly through GitHub, there's an address here:

http://wpdos.org/feedback.html

emendelson commented 5 years ago

DOSBox-X is in such an excellent state right now that I wonder if there's any chance of implementing TrueType fonts instead of bitmaps. I realize that this would be a major undertaking. In my own project, I've added a completely separate screen font that uses the euro symbol at ASCII 128, and it would be nice to be able to accomplish this with a simple substitution in a TrueType table. I know I'm asking a lot...!

joncampbell123 commented 5 years ago

It depends on the mode.

In PC-98 mode, that would be easy enough (except for the user-definable range) since most of the font is in ROM and unchangeable in software.

EDIT: The code would have to map Shift-JIS to unicode for the font rendering to work properly, which is easy enough since there are already translation tables for that.

For MDA, CGA, MCGA, Tandy and PCjr that could be doable for the same reason: the font is in ROM and not changable.

The problem is EGA/VGA emulation. Software is allowed to change the font RAM at any time. So code will have to be added that can identify per-character whether the font bitmap was the one intended by the BIOS or changed by the software. If it was changed by software then it has to revert to the VGA font rendering it has now for that character.

The other problem is KEYB.COM and locale changes, which affect the font as well.

emendelson commented 5 years ago

Well, this sounds like a major operation, so I won't keep pestering you about it. If this is possible in MDA (etc.) mode, that would be excellent, and more than enough for many DOS applications.

Speaking entirely selfishly, I found that I could change mode 7 (mode mono) to use a 43-line screen, which makes many DOS applications (WordPerfect, etc.) much more usable. If that could use a TrueType font, that would very good to have, even while waiting a lot longer for EGA/VGA support.

About KEYB.COM - I wouldn't know where to begin guessing about this...!

joncampbell123 commented 5 years ago

Well while this is still on the back burner... can you think of a good monospace font to use for this feature?

For Linux and Mac OS X a good one might be the Ubuntu Mono font, rendered with FreeType. Not sure what would be a good one on Windows.

DOSBox-X could have platform dependent code to render a bitmap of the font to a bitmap cache, and then have platform independent code just draw that bitmap as part of rendering.

Using:

joncampbell123 commented 5 years ago

The bitmaps will just be standard 8-bit grayscale, which FreeType is good at generating.

I don't think the Windows GDI will render to a grayscale DIB surface, but you can give it a RGBA surface to draw to and convert to monochrome anyway. I think there's a way as well to ask it NOT to do the LCD subpixel thing.

EDIT: Welllllll..... actually.... perhaps you might want the crisp LCD subpixel rendering for your DOS prompt, in which case, DOSBox-X only has to modulate the RGBA according to what the VGA palette is trying to do.

I have no experience with font rendering to bitmaps or font anything in Mac OS X.

emendelson commented 5 years ago

Windows font: Consolas (ships with all recent versions) is very good. Lucida Console is an alternative; ships with all versions as far back as anyone can remember.

Interesting - what you say about subpixel rendering...

ThePillenwerfer commented 5 years ago

I use Nouveau IBM with VDOS Plus and that looks fine.

Wengier commented 3 years ago

Just want to add that this is already implemented in DOSBox-X version 0.83.8 (with output=ttf).

Wengier commented 3 years ago

I have written a Wiki guide page which explains how to use the TrueType font output in DOSBox-X:

https://dosbox-x.com/wiki/Guide%3AUsing-TrueType-font-output-in-DOSBox%E2%80%90X.html