Revision 3395

View differences:

src/main.c
467 467
#if defined(G_OS_WIN32) || defined(__APPLE__)
468 468
static void fix_font_setting(void)
469 469
{
470
	const gchar *str = NULL;
470
	gchar *str = NULL;
471
	gchar **strv = NULL;
472
	gchar *style = NULL;
473
	gchar *size = NULL;
474
	gchar *suffix = NULL;
471 475

  
472 476
	if (!conv_is_ja_locale())
473 477
		return;
474 478

  
475 479
	if (prefs_common.textfont &&
476 480
	    strcmp(prefs_common.textfont, DEFAULT_MESSAGE_FONT) != 0) {
481
		guint len;
482

  
477 483
		if (gtkut_font_can_load(prefs_common.textfont)) {
478 484
			debug_print("font '%s' load ok\n", prefs_common.textfont);
479 485
			return;
480 486
		}
481 487
		debug_print("font '%s' load failed\n", prefs_common.textfont);
488
		debug_print("fixing prefs_common.textfont setting\n");
489

  
490
		strv = g_strsplit(prefs_common.textfont, " ", -1);
491
		len = g_strv_length(strv);
492
		if (len > 0) {
493
			if (g_ascii_isdigit(strv[len - 1][0]))
494
				size = g_strdup(strv[len - 1]);
495
			if (len > 2) {
496
				if (g_ascii_strcasecmp(strv[len - 2], "Bold") == 0)
497
					style = g_strdup(strv[len - 2]);
498
			}
499
		}
500
		g_strfreev(strv);
482 501
	}
483 502

  
484
	debug_print("fixing prefs_common.textfont setting\n");
485

  
503
	if (style && size)
504
		suffix = g_strconcat(style, " ", size, NULL);
505
	else if (size)
506
		suffix = g_strdup(size);
507
	else
486 508
#ifdef G_OS_WIN32
487
	str = "MS Gothic 12";
509
		suffix = g_strdup("12");
488 510
#else /* __APPLE__ */
489
	str = "Hiragino Kaku Gothic Pro Light 13";
511
		suffix = g_strdup("13");
490 512
#endif
513
	g_free(style);	
514
	g_free(size);
515
#ifdef G_OS_WIN32
516
	str = g_strconcat("MS Gothic ", suffix, NULL);
517
#else /* __APPLE__ */
518
	str = g_strconcat("Hiragino Kaku Gothic Pro Light ", suffix, NULL);
519
#endif
491 520

  
492 521
	if (!gtkut_font_can_load(str)) {
493 522
#ifdef G_OS_WIN32
494 523
		debug_print("font '%s' load failed\n", str);
495
		str = "\xef\xbc\xad\xef\xbc\xb3 \xe3\x82\xb4\xe3\x82\xb7\xe3\x83\x83\xe3\x82\xaf 12";
524
		g_free(str);
525
		str = g_strconcat("\xef\xbc\xad\xef\xbc\xb3 \xe3\x82\xb4\xe3\x82\xb7\xe3\x83\x83\xe3\x82\xaf ", suffix, NULL);
496 526
		if (!gtkut_font_can_load(str)) {
497 527
			debug_print("font '%s' load failed\n", str);
528
			g_free(str);
498 529
			str = NULL;
499 530
		}
500 531
#else /* __APPLE__ */
501 532
		debug_print("font '%s' load failed\n", str);
533
		g_free(str);
502 534
		str = NULL;
503 535
#endif
504 536
	}
......
507 539
		debug_print("font '%s' load ok\n", str);
508 540
		g_free(prefs_common.textfont);
509 541
		prefs_common.textfont = g_strdup(str);
542
		g_free(str);
510 543
	} else
511 544
		g_warning("failed to load text font!");
545

  
546
	g_free(suffix);
512 547
}
513 548
#endif
514 549

  
ChangeLog
1 1
2014-04-22
2 2

  
3
	* src/main.c: fix_font_setting(): improved font name fixing.
4

  
5
2014-04-22
6

  
3 7
	* makewin32.sh: save build log.
4 8

  
5 9
2014-04-21

Also available in: Unified diff