Make HZK14/HZK16 loadable via config options

This commit is contained in:
Wengier
2021-07-14 05:20:07 -04:00
parent 8b951ca9fd
commit 5e41a63613
7 changed files with 50 additions and 45164 deletions

View File

@@ -21,9 +21,10 @@
- Non-Japanese DOS/V systems will now use 19-pixel
VGA fonts rather than 16-pixel VGA fonts for SBCS
characters to look better. (Wengier)
- Free HZK14/HZK16 fonts (14- and 16-pixel height)
are now included for the Simplified Chinese DOS/V
(dosv=cn) emulation. (Wengier)
- You can now also load HZK14/HZK16 font files (for
14- and 16-pixel height) via the "fontxdbcs" and
"fontxdbcs14" options for the Simplified Chinese
DOS/V (dosv=cn) emulation. (Wengier)
- Improved the DOS/V font acquisition function on
the Linux platform (both SDL1 & SDL2). A config
option "getsysfont" is added which when set to

View File

@@ -672,7 +672,9 @@ pc-98 anex86 font =
#DOSBOX-X-ADV:# fontxsbcs16: FONTX2 file used to rendering SBCS characters (8x16) in DOS/V mode.
#DOSBOX-X-ADV:# fontxsbcs24: FONTX2 file used to rendering SBCS characters (12x24) in DOS/V mode.
# fontxdbcs: FONTX2 file used to rendering DBCS characters (16x16) in DOS/V or JEGA mode. If not specified, the default one will be used.
# Loading the HZK16 font file (https://github.com/aguegu/BitmapFont/tree/master/font) is also supported for Simplified Chinese DOS/V.
#DOSBOX-X-ADV:# fontxdbcs14: FONTX2 file used to rendering SBCS characters (14x14) for the Configuration Tool. If not specified, the default one will be used.
#DOSBOX-X-ADV:# Loading the HZK14 font file (https://github.com/aguegu/BitmapFont/tree/master/font) is also supported for Simplified Chinese DOS/V.
#DOSBOX-X-ADV:# fontxdbcs24: FONTX2 file used to rendering SBCS characters (24x24) in DOS/V mode.
# gbk: Enables the GBK extension (in addition to the standard GB2312 charset) for the Simplified Chinese DOS/V emulation or TTF output.
# yen: Enables the yen symbol (¥) at 5ch if it is found at 7fh in a custom SBCS font for the Japanese DOS/V or JEGA emulation.

View File

@@ -309,6 +309,7 @@ pc-98 anex86 font =
# getsysfont: If enabled, DOSBox-X will try to get and use the system fonts on Windows and Linux platforms for the DOS/V emulation.
# fontxsbcs: FONTX2 file used to rendering SBCS characters (8x19) in DOS/V or JEGA mode. If not specified, the default one will be used.
# fontxdbcs: FONTX2 file used to rendering DBCS characters (16x16) in DOS/V or JEGA mode. If not specified, the default one will be used.
# Loading the HZK16 font file (https://github.com/aguegu/BitmapFont/tree/master/font) is also supported for Simplified Chinese DOS/V.
# gbk: Enables the GBK extension (in addition to the standard GB2312 charset) for the Simplified Chinese DOS/V emulation or TTF output.
# yen: Enables the yen symbol (¥) at 5ch if it is found at 7fh in a custom SBCS font for the Japanese DOS/V or JEGA emulation.
# fepcontrol: FEP control API for the DOS/V emulation.

View File

@@ -652,7 +652,9 @@ pc-98 show graphics layer on initialize = true
# fontxsbcs16: FONTX2 file used to rendering SBCS characters (8x16) in DOS/V mode.
# fontxsbcs24: FONTX2 file used to rendering SBCS characters (12x24) in DOS/V mode.
# fontxdbcs: FONTX2 file used to rendering DBCS characters (16x16) in DOS/V or JEGA mode. If not specified, the default one will be used.
# Loading the HZK16 font file (https://github.com/aguegu/BitmapFont/tree/master/font) is also supported for Simplified Chinese DOS/V.
# fontxdbcs14: FONTX2 file used to rendering SBCS characters (14x14) for the Configuration Tool. If not specified, the default one will be used.
# Loading the HZK14 font file (https://github.com/aguegu/BitmapFont/tree/master/font) is also supported for Simplified Chinese DOS/V.
# fontxdbcs24: FONTX2 file used to rendering SBCS characters (24x24) in DOS/V mode.
# gbk: Enables the GBK extension (in addition to the standard GB2312 charset) for the Simplified Chinese DOS/V emulation or TTF output.
# yen: Enables the yen symbol (¥) at 5ch if it is found at 7fh in a custom SBCS font for the Japanese DOS/V or JEGA emulation.

File diff suppressed because it is too large Load Diff

View File

@@ -2048,11 +2048,13 @@ void DOSBOX_SetupConfigSections(void) {
Pstring->Set_help("FONTX2 file used to rendering SBCS characters (12x24) in DOS/V mode.");
Pstring = secprop->Add_path("fontxdbcs",Property::Changeable::OnlyAtStart,"");
Pstring->Set_help("FONTX2 file used to rendering DBCS characters (16x16) in DOS/V or JEGA mode. If not specified, the default one will be used.");
Pstring->Set_help("FONTX2 file used to rendering DBCS characters (16x16) in DOS/V or JEGA mode. If not specified, the default one will be used.\n"
"Loading the HZK16 font file (https://github.com/aguegu/BitmapFont/tree/master/font) is also supported for Simplified Chinese DOS/V.");
Pstring->SetBasic(true);
Pstring = secprop->Add_path("fontxdbcs14",Property::Changeable::OnlyAtStart,"");
Pstring->Set_help("FONTX2 file used to rendering SBCS characters (14x14) for the Configuration Tool. If not specified, the default one will be used.");
Pstring->Set_help("FONTX2 file used to rendering SBCS characters (14x14) for the Configuration Tool. If not specified, the default one will be used.\n"
"Loading the HZK14 font file (https://github.com/aguegu/BitmapFont/tree/master/font) is also supported for Simplified Chinese DOS/V.");
Pstring = secprop->Add_path("fontxdbcs24",Property::Changeable::OnlyAtStart,"");
Pstring->Set_help("FONTX2 file used to rendering SBCS characters (24x24) in DOS/V mode.");

View File

@@ -62,6 +62,8 @@ static XFontSet font_set24;
const char jfont_name[] = "\x082\x06c\x082\x072\x020\x083\x053\x083\x056\x083\x062\x083\x04e";
static uint8_t jfont_dbcs[96];
int fontsize14 = 0, fontsize16 = 0;
uint8_t *fontdata14 = NULL, *fontdata16 = NULL;
uint8_t jfont_sbcs_16[SBCS16_LEN];//256 * 16( * 8)
uint8_t jfont_sbcs_19[SBCS19_LEN];//256 * 19( * 8)
uint8_t jfont_sbcs_24[SBCS24_LEN];//256 * 12 * 2
@@ -188,8 +190,26 @@ static bool LoadFontxFile(const char *fname, int height = 16) {
#endif
}
if (getfontx2header(mfile, &head) != 0) {
if (dos.loaded_codepage == 936) {
fseek(mfile, 0L, SEEK_END);
long int sz = ftell(mfile);
rewind(mfile);
if (height==14) {
fontdata14 = (uint8_t *)malloc(sizeof(uint8_t)*sz);
if (!fontdata14) {fclose(mfile);return false;}
fread(fontdata14, sizeof(uint8_t), sz, mfile);
fontsize14 = sizeof(uint8_t)*sz;
} else if (height==16) {
fontdata16 = (uint8_t *)malloc(sizeof(uint8_t)*sz);
if (!fontdata16) {fclose(mfile);return false;}
fread(fontdata16, sizeof(uint8_t), sz, mfile);
fontsize16 = sizeof(uint8_t)*sz;
}
fclose(mfile);
return true;
}
fclose(mfile);
LOG_MSG("MSG: FONTX2 header is incorrect\n");
LOG_MSG("MSG: no correct FONTX2 header found\n");
return false;
}
// switch whether the font is DBCS or not
@@ -461,10 +481,10 @@ uint8_t *GetDbcsFont(Bitu code)
memcpy(&jfont_dbcs_16[code * 32], jfont_dbcs, 32);
jfont_cache_dbcs_16[code] = 1;
} else {
if (dos.loaded_codepage == 936 && (code/0x100)>0xa0 && (code/0x100)<0xff) {
if (dos.loaded_codepage == 936 && (code/0x100)>0xa0 && (code/0x100)<0xff && fontdata16) {
int offset = (94 * (unsigned int)((code/0x100) - 0xa0 - 1) + ((code%0x100) - 0xa0 - 1)) * 32;
if (offset + 32 <= sizeof(hzk16_data)) {
memcpy(&jfont_dbcs_16[code * 32], hzk16_data+offset, 32);
if (offset + 32 <= fontsize16) {
memcpy(&jfont_dbcs_16[code * 32], fontdata16+offset, 32);
jfont_cache_dbcs_16[code] = 1;
return &jfont_dbcs_16[code * 32];
}
@@ -507,10 +527,10 @@ uint8_t *GetDbcs14Font(Bitu code, bool &is14)
is14 = true;
return jfont_dbcs;
} else {
if (dos.loaded_codepage == 936 && (code/0x100)>0xa0 && (code/0x100)<0xff) {
if (dos.loaded_codepage == 936 && (code/0x100)>0xa0 && (code/0x100)<0xff && fontdata14) {
int offset = (94 * (unsigned int)((code/0x100) - 0xa0 - 1) + ((code%0x100) - 0xa0 - 1)) * 28;
if (offset + 28 <= sizeof(hzk14_data)) {
memcpy(&jfont_dbcs_14[code * 28], hzk14_data+offset, 28);
if (offset + 28 <= fontsize14) {
memcpy(&jfont_dbcs_14[code * 28], fontdata14+offset, 28);
jfont_cache_dbcs_14[code] = 1;
return &jfont_dbcs_14[code * 28];
}
@@ -693,6 +713,16 @@ bool MakeSbcs24Font() {
void JFONT_Init() {
jfont_init = true;
if (fontdata14) {
free(fontdata14);
fontdata14 = NULL;
fontsize14 = 0;
}
if (fontdata16) {
free(fontdata16);
fontdata16 = NULL;
fontsize16 = 0;
}
#if defined(WIN32) && !defined(HX_DOS) && !defined(C_SDL2) && defined(SDL_DOSBOX_X_SPECIAL)
SDL_SetCompositionFontName(jfont_name);
#endif