joncampbell123 / dosbox-x

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

Printer Font Location — Linux. #2106

Open ThePillenwerfer opened 3 years ago

ThePillenwerfer commented 3 years ago

Just a quick point to those in charge of documentation.

The Wiki currently states that on Linux the recommended fonts are in /usr/share/fonts/liberation-<whatever>. However on my Debian system they are all (except the OCR and Script ones) in /usr/share/fonts/truetype/liberation. Maybe a note could be added saying what distro the instructions refer to and advising people with different ones to check and make appropriate links to them in ~/.config/dosbox-x/FONTS'

I make no claims to be a programmer, and certainly don't speak C, but looking at the code of printer.ccp it looks as though at one time it could read font_path from the .conf file but it has been commented out. If that could be restored without messing anything up the line basedir = "/usr/share/fonts/"; could be changed to basedir = font_path and the individual fonts changed from the likes of fontName = basedir + "liberation-serif/LiberationSerif-Regular.ttf"; to fontName = basedir + LiberationSerif-Regular.ttf";

joncampbell123 commented 3 years ago

DOSBox-X could automatically use whatever the host system uses if it linked to and used the fontconfig libraries to enumerate them. That way it's entirely up to the font configuration file everybody else on the same system uses.

Wengier commented 3 years ago

The current printer code will read /usr/share/fonts/liberation in addition to /usr/share/fonts/liberation-<whatever>. I added /usr/share/fonts/liberation earlier in the code as an alternative path (not yet mentioned in the Wiki) but it should be changed to /usr/share/fonts/truetype/liberation instead. (if font paths are more complicated than this then a library like fontconfig may be used instead).

The printer code will also try to read fonts from the FONTS directory, and I am not sure why the fontpath option was commented out in the code. I think this option can be reactivated to allow the user to specify a custom path.

ThePillenwerfer commented 3 years ago

2132 has made me aware that there's a TTF in the source code. Would it be possible to use this as a fallback of last resort, ie the times DOSBox-X currently displays an error saying it can't find FONTS/courier.ttf? It would also need to be copied over along with the binary when that's installed.

It certainly wouldn't be my choice of printing font, though it could be argued that it has a certain retro dot-matrix appeal, but would be better than nothing.

I think this change would be within my limited capabilities but I don't know how to do Pull Requests nor if such use is permitted by the font's licence.

Wengier commented 3 years ago

@ThePillenwerfer Yes, perhaps the TTF font (or unifont_jp-13.0.05.ttf) can be bundled with the DOSBox-X package similar to FREECG98.BMP, and used as the last resort for the purpose of printing etc.

Wengier commented 3 years ago

@ThePillenwerfer I think the main problem for bundling this TTF font is its size - the file is certainly not small so it will increase the package size. Instead, I think using the internal TTF font used by the TTF output as the last resort is probably better, as it won’t increase the package size at all. In any case, thanks for the suggestion.

ThePillenwerfer commented 3 years ago

I hadn't checked the size of unifont and agree it's stupidly big. The internal font has the other advantage of looking better too.

Wengier commented 3 years ago

@ThePillenwerfer This is now done in #2135.

Wengier commented 3 years ago

With the latest code the printing function will use the same TTF font as the current TTF font for the TTF output (if TTF output is active) by default, including support for both SBCS and DBCS (Chinese/Japanese/Korean) languages. This function can be disabled with either ttf.printfont=false config option or unchecking the "Use current TTF font for printing" menu option ("Video" => "TTF options"), or if you use a non-TTF output. So basically WYSIWYG (What You See Is What You Get) in such case.

Wengier commented 3 years ago

There is now also TTF font SarasaGothicFixed.ttf in the repository, which supports CJK characters and I believe it certainly looks better than the Unifont TTF font. It is free and comes originally from https://github.com/be5invis/Sarasa-Gothic. A screenshot:

image

image

Wengier commented 3 years ago

A screenshot using the SarasaGothicFixed TTF font with the default code page (437):

image