スペシャルフォントのパス長の上限をなくした
@@ -53,6 +53,8 @@ | ||
53 | 53 | #include "teraterml.h" |
54 | 54 | #include "sendmem.h" |
55 | 55 | #include "ttdebug.h" |
56 | +#include "win32helper.h" | |
57 | +#include "asprintf.h" | |
56 | 58 | |
57 | 59 | #if defined(_DEBUG) && defined(_MSC_VER) |
58 | 60 | #define new ::new(_NORMAL_BLOCK, __FILE__, __LINE__) |
@@ -59,23 +61,25 @@ | ||
59 | 61 | #endif |
60 | 62 | |
61 | 63 | static BOOL AddFontFlag; |
62 | -static wchar_t TSpecialFont[MAX_PATH]; | |
64 | +static wchar_t *TSpecialFont; | |
63 | 65 | static CVTWindow* pVTWin; |
64 | 66 | static DWORD HtmlHelpCookie; |
65 | 67 | |
66 | 68 | static void LoadSpecialFont(void) |
67 | 69 | { |
70 | + wchar_t *mod_path; | |
68 | 71 | if (IsExistFontW(L"Tera Special", SYMBOL_CHARSET, TRUE)) { |
69 | 72 | // すでに存在するのでロードしない |
70 | 73 | return; |
71 | 74 | } |
72 | 75 | |
73 | - if (GetModuleFileNameW(NULL, TSpecialFont, _countof(TSpecialFont)) == 0) { | |
76 | + if (hGetModuleFileNameW(NULL, &mod_path) != 0) { | |
74 | 77 | AddFontFlag = FALSE; |
75 | 78 | return; |
76 | 79 | } |
77 | - *wcsrchr(TSpecialFont, L'\\') = 0; | |
78 | - wcscat_s(TSpecialFont, L"\\TSPECIAL1.TTF"); | |
80 | + *wcsrchr(mod_path, L'\\') = 0; | |
81 | + aswprintf(&TSpecialFont, L"%s\\TSPECIAL1.TTF", mod_path); | |
82 | + free(mod_path); | |
79 | 83 | |
80 | 84 | // teraterm.exeのみで有効なフォントとなる。 |
81 | 85 | // removeしなくても終了するとOSからなくなる |
@@ -368,6 +372,8 @@ | ||
368 | 372 | _HtmlHelpW(NULL, NULL, HH_CLOSE_ALL, 0); |
369 | 373 | _HtmlHelpW(NULL, NULL, HH_UNINITIALIZE, HtmlHelpCookie); |
370 | 374 | |
375 | + free(TSpecialFont); | |
376 | + TSpecialFont = NULL; | |
371 | 377 | UnloadSpecialFont(); |
372 | 378 | DLLExit(); |
373 | 379 |