aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog6
-rw-r--r--src/xfaces.c68
2 files changed, 66 insertions, 8 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 998434080f7..0995e0907f6 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
12001-05-14 Gerd Moellmann <gerd@gnu.org>
2
3 * xfaces.c (split_font_name): Handle matrix transformations
4 in the pixel and point size fields of XLFD font names.
5 (xlfd_point_size): Likewise.
6
12001-05-12 Eli Zaretskii <eliz@is.elta.co.il> 72001-05-12 Eli Zaretskii <eliz@is.elta.co.il>
2 8
3 * w32fns.c (w32_to_x_font): Change prototype to fit the 9 * w32fns.c (w32_to_x_font): Change prototype to fit the
diff --git a/src/xfaces.c b/src/xfaces.c
index 610c34465ea..a50ec9ae2a9 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -2122,13 +2122,41 @@ xlfd_point_size (f, font)
2122 struct font_name *font; 2122 struct font_name *font;
2123{ 2123{
2124 double resy = FRAME_X_DISPLAY_INFO (f)->resy; 2124 double resy = FRAME_X_DISPLAY_INFO (f)->resy;
2125 double font_pixel = atoi (font->fields[XLFD_PIXEL_SIZE]); 2125 char *pixel_field = font->fields[XLFD_PIXEL_SIZE];
2126 double pixel;
2126 int real_pt; 2127 int real_pt;
2127 2128
2128 if (font_pixel == 0) 2129 if (*pixel_field == '[')
2130 {
2131 /* The pixel size field is `[A B C D]' which specifies
2132 a transformation matrix.
2133
2134 A B 0
2135 C D 0
2136 0 0 1
2137
2138 by which all glyphs of the font are transformed. The spec
2139 says that s scalar value N for the pixel size is equivalent
2140 to A = N * resx/resy, B = C = 0, D = N. */
2141 char *start = pixel_field + 1, *end;
2142 double matrix[4];
2143 int i;
2144
2145 for (i = 0; i < 4; ++i)
2146 {
2147 matrix[i] = strtod (start, &end);
2148 start = end;
2149 }
2150
2151 pixel = matrix[3] / 10.0;
2152 }
2153 else
2154 pixel = atoi (pixel_field);
2155
2156 if (pixel == 0)
2129 real_pt = 0; 2157 real_pt = 0;
2130 else 2158 else
2131 real_pt = PT_PER_INCH * 10.0 * font_pixel / resy + 0.5; 2159 real_pt = PT_PER_INCH * 10.0 * pixel / resy + 0.5;
2132 2160
2133 return real_pt; 2161 return real_pt;
2134} 2162}
@@ -2162,9 +2190,7 @@ pixel_point_size (f, pixel)
2162 XLFD_RESY, XLFD_SLANT, and XLFD_WEIGHT in FONT->numeric. Value is 2190 XLFD_RESY, XLFD_SLANT, and XLFD_WEIGHT in FONT->numeric. Value is
2163 zero if the font name doesn't have the format we expect. The 2191 zero if the font name doesn't have the format we expect. The
2164 expected format is a font name that starts with a `-' and has 2192 expected format is a font name that starts with a `-' and has
2165 XLFD_LAST fields separated by `-'. (The XLFD specification allows 2193 XLFD_LAST fields separated by `-'. */
2166 forms of font names where certain field contents are enclosed in
2167 square brackets. We don't support that, for now. */
2168 2194
2169static int 2195static int
2170split_font_name (f, font, numeric_p) 2196split_font_name (f, font, numeric_p)
@@ -2179,10 +2205,36 @@ split_font_name (f, font, numeric_p)
2179 { 2205 {
2180 char *p = xstrlwr (font->name) + 1; 2206 char *p = xstrlwr (font->name) + 1;
2181 2207
2182 while (i < XLFD_LAST) 2208 for (; i < XLFD_LAST; ++i)
2183 { 2209 {
2184 font->fields[i] = p; 2210 font->fields[i] = p;
2185 ++i; 2211
2212 /* Pixel and point size may be of the form `[....]'. For
2213 BNF, see XLFD spec, chapter 4. Negative values are
2214 indicated by tilde characters which we replace with
2215 `-' characters, here. */
2216 if (*p == '['
2217 && (i == XLFD_PIXEL_SIZE
2218 || i == XLFD_POINT_SIZE))
2219 {
2220 char *start, *end;
2221 int j;
2222
2223 for (++p; *p && *p != ']'; ++p)
2224 if (*p == '~')
2225 *p = '-';
2226
2227 /* Check that the matrix contains 4 floating point
2228 numbers. */
2229 for (j = 0, start = font->fields[i] + 1;
2230 j < 4;
2231 ++j, start = end)
2232 if (strtod (start, &end) == 0 && start == end)
2233 break;
2234
2235 if (j < 4)
2236 break;
2237 }
2186 2238
2187 while (*p && *p != '-') 2239 while (*p && *p != '-')
2188 ++p; 2240 ++p;