| 1866 gboolean italics, |
1868 gboolean italics, |
| 1867 gint fontsize) |
1869 gint fontsize) |
| 1868 { |
1870 { |
| 1869 GdkFont *default_font = imhtml->default_font; |
1871 GdkFont *default_font = imhtml->default_font; |
| 1870 gchar *default_name; |
1872 gchar *default_name; |
| 1871 gchar **xflds; |
1873 gchar **xnames; |
| 1872 |
1874 gchar **pos; |
| 1873 gchar *newvals[16]; |
|
| 1874 gint i; |
|
| 1875 gchar **names; |
|
| 1876 gchar fs[10]; |
|
| 1877 |
|
| 1878 gchar *tmp; |
|
| 1879 GdkFont *ret_font; |
|
| 1880 |
1875 |
| 1881 if (!name && !bold && !italics && !fontsize) |
1876 if (!name && !bold && !italics && !fontsize) |
| 1882 return gdk_font_ref (default_font); |
1877 return gdk_font_ref (default_font); |
| 1883 |
1878 |
| 1884 default_name = gtk_imhtml_get_font_name (default_font); |
1879 default_name = gtk_imhtml_get_font_name (default_font); |
| 1885 xflds = g_strsplit (default_name, "-", -1); |
1880 xnames = g_strsplit (default_name, ",", -1); |
| |
1881 |
| |
1882 for (pos = xnames; pos && *pos; pos++) { |
| |
1883 gchar *xname; |
| |
1884 gchar **xflds; |
| |
1885 |
| |
1886 gchar **newvals; |
| |
1887 gint i; |
| |
1888 gchar **names; |
| |
1889 gchar fs[10]; |
| |
1890 |
| |
1891 gchar *tmp; |
| |
1892 GdkFont *ret_font; |
| |
1893 |
| |
1894 xname = *pos; |
| |
1895 xname = g_strchomp (xname); |
| |
1896 xname = g_strchug (xname); |
| |
1897 |
| |
1898 xflds = g_strsplit (xname, "-", -1); |
| 1886 |
1899 |
| 1887 #define NAME 2 |
1900 #define NAME 2 |
| 1888 #define BOLD 3 |
1901 #define BOLD 3 |
| 1889 #define ITALICS 4 |
1902 #define ITALICS 4 |
| 1890 #define SIZE 6 |
1903 #define SIZE 6 |
| 1891 #define PTSZ 7 |
1904 #define PTSZ 7 |
| 1892 #define END 15 |
1905 |
| 1893 |
1906 for (i = 0; xflds [i]; i++); |
| 1894 if (name) |
1907 newvals = g_memdup (xflds, (i + 1) * sizeof (xflds)); |
| 1895 names = g_strsplit (name, ",", -1); |
1908 |
| 1896 else { |
1909 if (bold) |
| 1897 names = g_new0 (gchar *, 2); |
1910 newvals [BOLD] = "bold"; |
| 1898 names [0] = g_strdup (xflds [NAME]); |
1911 if (italics) |
| 1899 } |
1912 newvals [ITALICS] = "i"; |
| 1900 |
1913 if (fontsize) { |
| 1901 for (i = 0; xflds [i]; i++) |
1914 g_snprintf (fs, sizeof (fs), "%d", font_sizes [MIN (fontsize, MAX_SIZE) - 1]); |
| 1902 newvals [i] = xflds [i]; |
1915 newvals [SIZE] = fs; |
| 1903 |
1916 newvals [PTSZ] = ""; |
| 1904 if (bold) |
1917 } |
| 1905 newvals [BOLD] = "bold"; |
1918 |
| 1906 if (italics) |
1919 if (name) |
| 1907 newvals [ITALICS] = "i"; |
1920 names = g_strsplit (name, ",", -1); |
| 1908 if (fontsize) { |
1921 else { |
| 1909 g_snprintf (fs, sizeof (fs), "%d", font_sizes [MIN (fontsize, MAX_SIZE) - 1]); |
1922 names = g_new0 (gchar *, 2); |
| 1910 newvals [SIZE] = fs; |
1923 names [0] = g_strdup (xflds [NAME]); |
| 1911 newvals [PTSZ] = ""; |
1924 } |
| 1912 } |
1925 |
| 1913 newvals [END] = NULL; |
1926 for (i = 0; names [i]; i++) { |
| 1914 |
1927 newvals [NAME] = names [i]; |
| 1915 TRY_FONT; |
|
| 1916 |
|
| 1917 for (i = 0; italics && names [i]; i++) { |
|
| 1918 newvals [NAME] = names [i]; |
|
| 1919 |
|
| 1920 newvals [ITALICS] = "o"; |
|
| 1921 TRY_FONT; |
|
| 1922 |
|
| 1923 newvals [ITALICS] = xflds [ITALICS]; |
|
| 1924 TRY_FONT; |
|
| 1925 } |
|
| 1926 |
|
| 1927 for (i = 0; fontsize && names [i]; i++) { |
|
| 1928 newvals [NAME] = names [i]; |
|
| 1929 |
|
| 1930 if (xflds [PTSZ][0]) { |
|
| 1931 g_snprintf (fs, sizeof (fs), "%d", |
|
| 1932 font_sizes [MIN (fontsize, MAX_SIZE) - 1] / 10); |
|
| 1933 newvals [PTSZ] = fs; |
|
| 1934 newvals [SIZE] = ""; |
|
| 1935 TRY_FONT; |
1928 TRY_FONT; |
| 1936 |
1929 } |
| 1937 newvals [PTSZ] = xflds [PTSZ]; |
1930 |
| 1938 } else |
1931 for (i = 0; italics && names [i]; i++) { |
| 1939 newvals [SIZE] = xflds [SIZE]; |
1932 newvals [NAME] = names [i]; |
| 1940 TRY_FONT; |
1933 |
| 1941 } |
1934 newvals [ITALICS] = "o"; |
| 1942 |
1935 TRY_FONT; |
| 1943 for (i = 0; bold && names [i]; i++) { |
1936 |
| 1944 newvals [NAME] = names [i]; |
1937 newvals [ITALICS] = xflds [ITALICS]; |
| 1945 |
1938 TRY_FONT; |
| 1946 newvals [BOLD] = xflds [BOLD]; |
1939 } |
| 1947 TRY_FONT; |
1940 |
| 1948 } |
1941 for (i = 0; fontsize && names [i]; i++) { |
| |
1942 newvals [NAME] = names [i]; |
| |
1943 |
| |
1944 if (xflds [PTSZ][0]) { |
| |
1945 g_snprintf (fs, sizeof (fs), "%d", |
| |
1946 font_sizes [MIN (fontsize, MAX_SIZE) - 1] / 10); |
| |
1947 newvals [PTSZ] = fs; |
| |
1948 newvals [SIZE] = ""; |
| |
1949 TRY_FONT; |
| |
1950 |
| |
1951 newvals [PTSZ] = xflds [PTSZ]; |
| |
1952 } else |
| |
1953 newvals [SIZE] = xflds [SIZE]; |
| |
1954 TRY_FONT; |
| |
1955 } |
| |
1956 |
| |
1957 for (i = 0; bold && names [i]; i++) { |
| |
1958 newvals [NAME] = names [i]; |
| |
1959 |
| |
1960 newvals [BOLD] = xflds [BOLD]; |
| |
1961 TRY_FONT; |
| |
1962 } |
| 1949 |
1963 |
| 1950 #undef NAME |
1964 #undef NAME |
| 1951 #undef BOLD |
1965 #undef BOLD |
| 1952 #undef ITALICS |
1966 #undef ITALICS |
| 1953 #undef SIZE |
1967 #undef SIZE |
| 1954 #undef PTSZ |
1968 #undef PTSZ |
| 1955 #undef END |
1969 |
| 1956 |
1970 g_free (newvals); |
| 1957 g_strfreev (xflds); |
1971 g_strfreev (xflds); |
| 1958 g_strfreev (names); |
1972 g_strfreev (names); |
| |
1973 |
| |
1974 } |
| |
1975 |
| |
1976 g_strfreev (xnames); |
| 1959 |
1977 |
| 1960 return gdk_font_ref (default_font); |
1978 return gdk_font_ref (default_font); |
| 1961 } |
1979 } |
| 1962 |
1980 |
| 1963 static void |
1981 static void |