comparison src/gtkimhtml.c @ 2761:367d19133917

[gaim-migrate @ 2774] decklin's patch committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Mon, 19 Nov 2001 11:14:55 +0000
parents 9fc65bb80596
children 6fab04e257a5
comparison
equal deleted inserted replaced
2760:72272d43e265 2761:367d19133917
57 #include "pixmaps/think.xpm" 57 #include "pixmaps/think.xpm"
58 #include "pixmaps/tongue.xpm" 58 #include "pixmaps/tongue.xpm"
59 #include "pixmaps/wink.xpm" 59 #include "pixmaps/wink.xpm"
60 #include "pixmaps/yell.xpm" 60 #include "pixmaps/yell.xpm"
61 61
62 #define MAX_SIZE 7 62 #define MAX_FONT_SIZE 7
63 63 #define DEFAULT_FONT_SIZE 3
64 gint font_sizes [] = { 80, 100, 120, 140, 200, 300, 400 }; 64
65 gint _point_sizes [] = { 80, 100, 120, 140, 200, 300, 400 };
66
67 #define DEFAULT_PRE_FACE "courier"
65 68
66 #define BORDER_SIZE 2 69 #define BORDER_SIZE 2
67 #define TOP_BORDER 10 70 #define TOP_BORDER 10
68 #define MIN_HEIGHT 20 71 #define MIN_HEIGHT 20
69 #define HR_HEIGHT 2 72 #define HR_HEIGHT 2
1925 if (bold) 1928 if (bold)
1926 newvals [WGHT] = "bold"; 1929 newvals [WGHT] = "bold";
1927 if (italics) 1930 if (italics)
1928 newvals [SLANT] = "i"; 1931 newvals [SLANT] = "i";
1929 if (fontsize) { 1932 if (fontsize) {
1930 g_snprintf (fs, sizeof (fs), "%d", font_sizes [MIN (fontsize, MAX_SIZE) - 1]); 1933 g_snprintf (fs, sizeof (fs), "%d", _point_sizes [MIN (fontsize, MAX_FONT_SIZE) - 1]);
1931 newvals [PXLSZ] = "*"; 1934 newvals [PXLSZ] = "*";
1932 newvals [PTSZ] = fs; 1935 newvals [PTSZ] = fs;
1933 } 1936 }
1934 1937
1935 if (name) 1938 if (name)
1956 1959
1957 for (i = 0; fontsize && names [i]; i++) { 1960 for (i = 0; fontsize && names [i]; i++) {
1958 newvals [FMLY] = names [i]; 1961 newvals [FMLY] = names [i];
1959 1962
1960 g_snprintf (fs, sizeof (fs), "%d", 1963 g_snprintf (fs, sizeof (fs), "%d",
1961 font_sizes [MIN (fontsize, MAX_SIZE) - 1] / 10); 1964 _point_sizes [MIN (fontsize, MAX_FONT_SIZE) - 1] / 10);
1962 newvals [PXLSZ] = fs; 1965 newvals [PXLSZ] = fs;
1963 newvals [PTSZ] = "*"; 1966 newvals [PTSZ] = "*";
1964 1967
1965 TRY_FONT; 1968 TRY_FONT;
1966 1969
2499 bit->text = g_strdup (text); 2502 bit->text = g_strdup (text);
2500 2503
2501 if ((font != NULL) || bold || italics || pre) { 2504 if ((font != NULL) || bold || italics || pre) {
2502 if (font && (bold || italics || font->size || font->face || pre)) { 2505 if (font && (bold || italics || font->size || font->face || pre)) {
2503 if (pre) { 2506 if (pre) {
2504 bit->font = gtk_imhtml_font_load (imhtml, "courier", bold, italics, font->size); 2507 bit->font = gtk_imhtml_font_load (imhtml, DEFAULT_PRE_FACE, bold, italics, font->size);
2505 } else { 2508 } else {
2506 bit->font = gtk_imhtml_font_load (imhtml, font->face, bold, italics, font->size); 2509 bit->font = gtk_imhtml_font_load (imhtml, font->face, bold, italics, font->size);
2507 } 2510 }
2508 } else if (bold || italics || pre) { 2511 } else if (bold || italics || pre) {
2509 if (pre) { 2512 if (pre) {
2510 bit->font = gtk_imhtml_font_load (imhtml, "courier", bold, italics, 0); 2513 bit->font = gtk_imhtml_font_load (imhtml, DEFAULT_PRE_FACE, bold, italics, 0);
2511 } else { 2514 } else {
2512 bit->font = gtk_imhtml_font_load (imhtml, NULL, bold, italics, 0); 2515 bit->font = gtk_imhtml_font_load (imhtml, NULL, bold, italics, 0);
2513 } 2516 }
2514 } 2517 }
2515 2518
2990 break; 2993 break;
2991 if (i != strlen (value)) 2994 if (i != strlen (value))
2992 break; 2995 break;
2993 2996
2994 sscanf (value + 1, "%hd", &font->size); 2997 sscanf (value + 1, "%hd", &font->size);
2995 font->size += 3; 2998 font->size += DEFAULT_FONT_SIZE;
2996 break; 2999 break;
2997 } 3000 }
2998 3001
2999 if ((value [0] == '-') && (value [1] != '\0')) { 3002 if ((value [0] == '-') && (value [1] != '\0')) {
3000 for (i = 1; i < strlen (value); i++) 3003 for (i = 1; i < strlen (value); i++)
3003 if (i != strlen (value)) 3006 if (i != strlen (value))
3004 break; 3007 break;
3005 3008
3006 sscanf (value + 1, "%hd", &font->size); 3009 sscanf (value + 1, "%hd", &font->size);
3007 font->size = MIN (font->size, 2); 3010 font->size = MIN (font->size, 2);
3008 font->size = 3 - font->size; 3011 font->size = DEFAULT_FONT_SIZE - font->size;
3009 break; 3012 break;
3010 } 3013 }
3011 3014
3012 break; 3015 break;
3013 } 3016 }
3034 font->fore = gdk_color_copy (oldfont->fore); 3037 font->fore = gdk_color_copy (oldfont->fore);
3035 if (!font->back && oldfont->back) 3038 if (!font->back && oldfont->back)
3036 font->back = gdk_color_copy (oldfont->back); 3039 font->back = gdk_color_copy (oldfont->back);
3037 } else { 3040 } else {
3038 if (!font->size) 3041 if (!font->size)
3039 font->size = 3; 3042 font->size = DEFAULT_FONT_SIZE;
3040 } 3043 }
3041 3044
3042 fonts = g_slist_prepend (fonts, font); 3045 fonts = g_slist_prepend (fonts, font);
3043 got_tag = TRUE; 3046 got_tag = TRUE;
3044 } else if (!g_strcasecmp (tag, "</FONT>")) { 3047 } else if (!g_strcasecmp (tag, "</FONT>")) {