[Ttssh2-commit] [7705] teraterm.iniからフォント設定を読み込む関数を追加

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2019年 5月 22日 (水) 00:20:38 JST


Revision: 7705
          https://osdn.net/projects/ttssh2/scm/svn/commits/7705
Author:   zmatsuo
Date:     2019-05-22 00:20:38 +0900 (Wed, 22 May 2019)
Log Message:
-----------
teraterm.iniからフォント設定を読み込む関数を追加

Modified Paths:
--------------
    trunk/teraterm/ttpset/ttset.c

-------------- next part --------------
Modified: trunk/teraterm/ttpset/ttset.c
===================================================================
--- trunk/teraterm/ttpset/ttset.c	2019-05-21 14:27:41 UTC (rev 7704)
+++ trunk/teraterm/ttpset/ttset.c	2019-05-21 15:20:38 UTC (rev 7705)
@@ -224,8 +224,9 @@
 	WritePrivateProfileString(Sect, Key, Temp, FName);
 }
 
-void WriteFont(PCHAR Sect, PCHAR Key, PCHAR FName,
-			   PCHAR Name, int x, int y, int charset)
+// \x83t\x83H\x83\x93\x83g\x8F\xEE\x95񏑂\xAB\x8D\x9E\x82݁A4\x83p\x83\x89\x83\x81\x81[\x83^\x94\xC5
+static void WriteFont(PCHAR Sect, PCHAR Key, PCHAR FName,
+					  PCHAR Name, int x, int y, int charset)
 {
 	char Temp[80];
 	if (Name[0] != 0)
@@ -236,8 +237,28 @@
 	WritePrivateProfileString(Sect, Key, Temp, FName);
 }
 
+// \x83t\x83H\x83\x93\x83g\x8F\xEE\x95\xF1\x93ǂݍ\x9E\x82݁A4\x83p\x83\x89\x83\x81\x81[\x83^\x94\xC5
+static void ReadFont(
+	const char *Sect, const char *Key, const char *Default, const char *FName,
+	char *FontName, size_t FontNameLen, POINT *FontSize, int *FontCharSet)
+{
+	char Temp[MAX_PATH];
+	GetPrivateProfileString(Sect, Key, Default,
+	                        Temp, _countof(Temp), FName);
+	if (Temp[0] == 0) {
+		// \x83f\x83t\x83H\x83\x8B\x83g\x82\xAA\x83Z\x83b\x83g\x82\xB3\x82\xEA\x82Ă\xA2\x82Ȃ\xA2 & ini\x82ɃG\x83\x93\x83g\x83\x8A\x81[\x82\xAA\x82Ȃ\xA2\x8Fꍇ
+		FontName[0] = 0;
+		FontSize->x = 0;
+		FontSize->y = 0;
+		FontCharSet = 0;
+	} else {
+		GetNthString(Temp, 1, FontNameLen, FontName);
+		GetNthNum(Temp, 2, &(FontSize->x));
+		GetNthNum(Temp, 3, &(FontSize->y));
+		GetNthNum(Temp, 4, FontCharSet);
+	}
+}
 
-
 #define CYGTERM_FILE "cygterm.cfg"  // CygTerm configuration file
 #define CYGTERM_FILE_MAXLINE 100
 
@@ -925,12 +946,9 @@
 	ts->TEKColorEmu = GetOnOff(Section, "TEKColorEmulation", FName, FALSE);
 
 	/* VT Font */
-	GetPrivateProfileString(Section, "VTFont", "Terminal,0,-13,1",
-	                        Temp, sizeof(Temp), FName);
-	GetNthString(Temp, 1, sizeof(ts->VTFont), ts->VTFont);
-	GetNthNum(Temp, 2, (int far *) &(ts->VTFontSize.x));
-	GetNthNum(Temp, 3, (int far *) &(ts->VTFontSize.y));
-	GetNthNum(Temp, 4, &(ts->VTFontCharSet));
+	ReadFont(Section, "VTFont", "Terminal,0,-13,1", FName,
+			 ts->VTFont, _countof(ts->VTFont),
+			 &ts->VTFontSize, &(ts->VTFontCharSet));
 
 	/* Bold font flag */
 	if (GetOnOff(Section, "EnableBold", FName, TRUE))
@@ -942,12 +960,9 @@
 	ts->RussFont = str2id(RussList, Temp, IdWindows);
 
 	/* TEK Font */
-	GetPrivateProfileString(Section, "TEKFont", "Courier,0,-13,0",
-	                        Temp, sizeof(Temp), FName);
-	GetNthString(Temp, 1, sizeof(ts->TEKFont), ts->TEKFont);
-	GetNthNum(Temp, 2, (int far *) &(ts->TEKFontSize.x));
-	GetNthNum(Temp, 3, (int far *) &(ts->TEKFontSize.y));
-	GetNthNum(Temp, 4, &(ts->TEKFontCharSet));
+	ReadFont(Section, "TEKFont", "Courier,0,-13,0", FName,
+			 ts->TEKFont, _countof(ts->TEKFont),
+			 &ts->TEKFontSize, &(ts->TEKFontCharSet));
 
 	/* BS key */
 	GetPrivateProfileString(Section, "BSKey", "",
@@ -1332,20 +1347,9 @@
 		ts->TermFlag |= TF_PRINTERCTRL;
 
 	/* Printer Font --- special option */
-	GetPrivateProfileString(Section, "PrnFont", "",
-	                        Temp, sizeof(Temp), FName);
-	if (strlen(Temp) == 0) {
-		ts->PrnFont[0] = 0;
-		ts->PrnFontSize.x = 0;
-		ts->PrnFontSize.y = 0;
-		ts->PrnFontCharSet = 0;
-	}
-	else {
-		GetNthString(Temp, 1, sizeof(ts->PrnFont), ts->PrnFont);
-		GetNthNum(Temp, 2, (int far *) &(ts->PrnFontSize.x));
-		GetNthNum(Temp, 3, (int far *) &(ts->PrnFontSize.y));
-		GetNthNum(Temp, 4, &(ts->PrnFontCharSet));
-	}
+	ReadFont(Section, "PrnFont", NULL, FName,
+			 ts->PrnFont, _countof(ts->PrnFont),
+			 &ts->PrnFontSize, &(ts->PrnFontCharSet));
 
 	// Page margins (left, right, top, bottom) for printing
 	//    -- special option


Ttssh2-commit メーリングリストの案内
Back to archive index