浏览代码

Add separate font flavors for Simplified Chinese, Traditional Chinese and Japanese

Font flavor may be specified in Language File. If language file does not exist, Simp./Trad. Chinese fonts will be selected automatically based on the version of the game proper. If lauguage file exists but no font flavor is specified in language file, Unifont will be used.
Wei Mingzhi 7 年之前
父节点
当前提交
36bcfd96a8
共有 6 个文件被更改,包括 29752 次插入2 次删除
  1. 92 0
      font.c
  2. 8871 0
      fontglyph_cn.h
  3. 6893 0
      fontglyph_jp.h
  4. 13857 0
      fontglyph_tw.h
  5. 29 2
      text.c
  6. 10 0
      text.h

+ 92 - 0
font.c

@@ -27,6 +27,9 @@
 #define _FONT_C
 
 #include "fontglyph.h"
+#include "fontglyph_cn.h"
+#include "fontglyph_tw.h"
+#include "fontglyph_jp.h"
 #include "ascii.h"
 
 static int _font_height = 16;
@@ -91,6 +94,58 @@ static void PAL_LoadISOFont(void)
     }
 }
 
+static void PAL_LoadCNFont(void)
+{
+	int         i;
+
+	for (i = 0; i < sizeof(fontglyph_cn) / sizeof(fontglyph_cn[0]); i++)
+	{
+		wchar_t w = fontglyph_cn[i].code;
+		w = (w >= unicode_upper_base) ? (w - unicode_upper_base + unicode_lower_top) : w;
+		if (w < sizeof(unicode_font) / sizeof(unicode_font[0]))
+		{
+			memcpy(unicode_font[w], fontglyph_cn[i].data, 32);
+			font_width[w] = 32;
+		}
+	}
+}
+
+static void PAL_LoadTWFont(void)
+{
+	int         i;
+
+	for (i = 0; i < sizeof(fontglyph_tw) / sizeof(fontglyph_tw[0]); i++)
+	{
+		wchar_t w = fontglyph_tw[i].code;
+		w = (w >= unicode_upper_base) ? (w - unicode_upper_base + unicode_lower_top) : w;
+		if (w < sizeof(unicode_font) / sizeof(unicode_font[0]))
+		{
+			memcpy(unicode_font[w], fontglyph_tw[i].data, 32);
+			font_width[w] = 32;
+		}
+	}
+
+	_font_height = 15;
+}
+
+static void PAL_LoadJPFont(void)
+{
+	int         i;
+
+	for (i = 0; i < sizeof(fontglyph_jp) / sizeof(fontglyph_jp[0]); i++)
+	{
+		wchar_t w = fontglyph_jp[i].code;
+		w = (w >= unicode_upper_base) ? (w - unicode_upper_base + unicode_lower_top) : w;
+		if (w < sizeof(unicode_font) / sizeof(unicode_font[0]))
+		{
+			memcpy(unicode_font[w], fontglyph_jp[i].data, 32);
+			font_width[w] = 32;
+		}
+	}
+
+	_font_height = 16;
+}
+
 static void PAL_LoadEmbeddedFont(void)
 {
 	FILE *fp;
@@ -378,6 +433,43 @@ PAL_InitFont(
    {
       PAL_LoadUserFont(cfg->pszFontFile);
    }
+   else
+   {
+      switch (g_TextLib.iFontFlavor)
+      {
+      case kFontFlavorAuto:
+         switch (PAL_GetCodePage())
+         {
+         case CP_GBK:
+            PAL_LoadCNFont();
+            break;
+
+         case CP_BIG5:
+            PAL_LoadTWFont();
+            break;
+
+         default:
+            break;
+         }
+         break;
+
+      case kFontFlavorSimpChin:
+         PAL_LoadCNFont();
+         break;
+
+      case kFontFlavorTradChin:
+         PAL_LoadTWFont();
+         break;
+
+      case kFontFlavorJapanese:
+         PAL_LoadJPFont();
+         break;
+
+      case kFontFlavorUnifont:
+      default:
+         break;  
+      }
+   }
 
    return 0;
 }

文件差异内容过多而无法显示
+ 8871 - 0
fontglyph_cn.h


文件差异内容过多而无法显示
+ 6893 - 0
fontglyph_jp.h


文件差异内容过多而无法显示
+ 13857 - 0
fontglyph_tw.h


+ 29 - 2
text.c

@@ -421,9 +421,33 @@ PAL_ReadMessageFile(
 							//
 							// Parse the index and pass out value
 							//
-							if (sscanf(line, "%s", index) == 1 && strncasecmp(index, "UseISOFont", 10) == 0 )
+							if (sscanf(line, "%s", index) == 1)
 							{
-								g_TextLib.fUseISOFont = atoi(val + 1) == 1;
+								if (strncasecmp(index, "UseISOFont", 10) == 0)
+								{
+									g_TextLib.fUseISOFont = atoi(val + 1) == 1;
+								}
+								else if (strncasecmp(index, "FontFlavor", 10) == 0)
+								{
+									const char *szFontFlavors[] = {
+										"Unifont",
+										"SimpChin",
+										"TradChin",
+										"Japanese",
+										NULL
+									};
+
+									int i = 1;
+									while (szFontFlavors[i - 1] != NULL)
+									{
+										if (strcmp(val + 1, szFontFlavors[i - 1]) == 0)
+										{
+											g_TextLib.iFontFlavor = i;
+											break;
+										}
+										i++;
+									}
+								}
 							}
 						}
 					}
@@ -604,6 +628,7 @@ PAL_InitText(
 --*/
 {
    g_TextLib.fUseISOFont = TRUE;
+   g_TextLib.iFontFlavor = kFontFlavorUnifont;
 
    if (gConfig.pszMsgFile)
    {
@@ -811,6 +836,8 @@ PAL_InitText(
 #ifndef PAL_CLASSIC
 	   memcpy(g_TextLib.lpWordBuf + SYSMENU_LABEL_BATTLEMODE, gc_rgszAdditionalWords[PAL_GetCodePage()], ATB_WORD_COUNT * sizeof(LPCWSTR));
 #endif
+
+       g_TextLib.iFontFlavor = kFontFlavorAuto;
    }
 
    g_TextLib.bCurrentFontColor = FONT_COLOR_DEFAULT;

+ 10 - 0
text.h

@@ -33,6 +33,15 @@ typedef enum tagDIALOGPOSITION
    kDialogCenterWindow
 } DIALOGLOCATION;
 
+typedef enum tagFONTFLAVOR
+{
+   kFontFlavorAuto     = 0,
+   kFontFlavorUnifont,
+   kFontFlavorSimpChin,
+   kFontFlavorTradChin,
+   kFontFlavorJapanese,
+} FONTFLAVOR;
+
 PAL_C_LINKAGE_BEGIN
 
 typedef struct tagTEXTLIB
@@ -41,6 +50,7 @@ typedef struct tagTEXTLIB
     LPWSTR         *lpMsgBuf;
     int           **lpIndexBuf;
     BOOL            fUseISOFont;
+	int             iFontFlavor;
 
     int             nWords;
     int             nMsgs;