|
|
@@ -36,7 +36,11 @@ struct br_font_def {
|
|
|
char family[BR_FACE_FAMILY];
|
|
|
char url[BR_FACE_URL];
|
|
|
char base[192];
|
|
|
- unsigned char used;
|
|
|
+ unsigned short wmin, wmax; /* font-weight descriptor (a range for
|
|
|
+ * variable fonts) */
|
|
|
+ unsigned char italic; /* font-style italic/oblique */
|
|
|
+ unsigned char family_id; /* first entry of the same family */
|
|
|
+ unsigned char used; /* a font-family declaration names it */
|
|
|
};
|
|
|
static struct br_font_def font_defs[BR_MAX_FACES];
|
|
|
static int font_face_count;
|
|
|
@@ -89,6 +93,21 @@ const char *br_font_face_family(int id)
|
|
|
return font_defs[id - 1].family;
|
|
|
}
|
|
|
|
|
|
+int br_font_face_info(int id, struct br_font_face_info *out)
|
|
|
+{
|
|
|
+ const struct br_font_def *f;
|
|
|
+
|
|
|
+ if (id < 1 || id > font_face_count || !out)
|
|
|
+ return -1;
|
|
|
+ f = &font_defs[id - 1];
|
|
|
+ out->family_id = f->family_id;
|
|
|
+ out->wmin = f->wmin;
|
|
|
+ out->wmax = f->wmax;
|
|
|
+ out->italic = f->italic;
|
|
|
+ out->used = f->used;
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
const char *br_bg_image_url(unsigned int idx)
|
|
|
{
|
|
|
if (idx >= bg_url_count)
|
|
|
@@ -4431,72 +4450,91 @@ static void font_trim(const char **sp, unsigned int *len)
|
|
|
*len = n;
|
|
|
}
|
|
|
|
|
|
+static int font_name_eq(const char *a, const char *b, unsigned int blen)
|
|
|
+{
|
|
|
+ unsigned int k;
|
|
|
+
|
|
|
+ if (s_len(a) != blen)
|
|
|
+ return 0;
|
|
|
+ for (k = 0; k < blen; k++) {
|
|
|
+ char x = a[k], y = b[k];
|
|
|
+
|
|
|
+ if (x >= 'A' && x <= 'Z')
|
|
|
+ x = (char)(x - 'A' + 'a');
|
|
|
+ if (y >= 'A' && y <= 'Z')
|
|
|
+ y = (char)(y - 'A' + 'a');
|
|
|
+ if (x != y)
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ return 1;
|
|
|
+}
|
|
|
+
|
|
|
+static void font_copy(char *dst, unsigned int cap, const char *src,
|
|
|
+ unsigned int n)
|
|
|
+{
|
|
|
+ unsigned int k;
|
|
|
+
|
|
|
+ for (k = 0; k < n && src[k] && k + 1 < cap; k++)
|
|
|
+ dst[k] = src[k];
|
|
|
+ dst[k] = '\0';
|
|
|
+}
|
|
|
+
|
|
|
+/* Register one @font-face. Every (family, weight range, style) is its own
|
|
|
+ * entry; a later rule with the same triple replaces the URL, as the CSS
|
|
|
+ * font-face collection does. family_id is the 1-based id of the family's
|
|
|
+ * first entry, which is what font-family declarations store. */
|
|
|
static void font_add(const char *family, unsigned int flen,
|
|
|
- const char *url, unsigned int ulen)
|
|
|
+ const char *url, unsigned int ulen,
|
|
|
+ unsigned int wmin, unsigned int wmax, int italic)
|
|
|
{
|
|
|
- unsigned int i, n = 0, k;
|
|
|
+ unsigned int i;
|
|
|
+ int fam = 0;
|
|
|
+ struct br_font_def *f;
|
|
|
|
|
|
font_trim(&family, &flen);
|
|
|
font_trim(&url, &ulen);
|
|
|
if (!flen || !ulen || flen >= BR_FACE_FAMILY || ulen >= BR_FACE_URL)
|
|
|
return;
|
|
|
for (i = 0; i < (unsigned int)font_face_count; i++) {
|
|
|
- struct br_font_def *f = &font_defs[i];
|
|
|
-
|
|
|
- if (s_len(f->family) != flen)
|
|
|
+ f = &font_defs[i];
|
|
|
+ if (!font_name_eq(f->family, family, flen))
|
|
|
continue;
|
|
|
- for (k = 0; k < flen; k++) {
|
|
|
- char a = f->family[k], b = family[k];
|
|
|
-
|
|
|
- if (a >= 'A' && a <= 'Z')
|
|
|
- a = (char)(a - 'A' + 'a');
|
|
|
- if (b >= 'A' && b <= 'Z')
|
|
|
- b = (char)(b - 'A' + 'a');
|
|
|
- if (a != b)
|
|
|
- break;
|
|
|
- }
|
|
|
- if (k != flen)
|
|
|
+ if (!fam)
|
|
|
+ fam = f->family_id;
|
|
|
+ if (f->wmin != wmin || f->wmax != wmax ||
|
|
|
+ f->italic != (unsigned char)italic)
|
|
|
continue;
|
|
|
- n = 0;
|
|
|
- while (url[n] && n + 1 < sizeof(f->url)) {
|
|
|
- f->url[n] = url[n];
|
|
|
- n++;
|
|
|
- }
|
|
|
- f->url[n] = '\0';
|
|
|
- n = 0;
|
|
|
- while (font_base[n] && n + 1 < sizeof(f->base)) {
|
|
|
- f->base[n] = font_base[n];
|
|
|
- n++;
|
|
|
- }
|
|
|
- f->base[n] = '\0';
|
|
|
+ font_copy(f->url, sizeof(f->url), url, ulen);
|
|
|
+ font_copy(f->base, sizeof(f->base), font_base, s_len(font_base));
|
|
|
return;
|
|
|
}
|
|
|
if (font_face_count >= BR_MAX_FACES)
|
|
|
return;
|
|
|
- {
|
|
|
- struct br_font_def *f = &font_defs[font_face_count];
|
|
|
-
|
|
|
- for (n = 0; n < flen; n++)
|
|
|
- f->family[n] = family[n];
|
|
|
- f->family[n] = '\0';
|
|
|
- for (n = 0; n < ulen; n++)
|
|
|
- f->url[n] = url[n];
|
|
|
- f->url[n] = '\0';
|
|
|
- for (n = 0; font_base[n] && n + 1 < sizeof(f->base); n++)
|
|
|
- f->base[n] = font_base[n];
|
|
|
- f->base[n] = '\0';
|
|
|
+ f = &font_defs[font_face_count];
|
|
|
+ font_copy(f->family, sizeof(f->family), family, flen);
|
|
|
+ font_copy(f->url, sizeof(f->url), url, ulen);
|
|
|
+ font_copy(f->base, sizeof(f->base), font_base, s_len(font_base));
|
|
|
+ f->wmin = (unsigned short)wmin;
|
|
|
+ f->wmax = (unsigned short)wmax;
|
|
|
+ f->italic = (unsigned char)italic;
|
|
|
+ f->used = 0;
|
|
|
+ font_face_count++;
|
|
|
+ f->family_id = (unsigned char)(fam ? fam : font_face_count);
|
|
|
+ /* A family that a font-family declaration already resolved (an
|
|
|
+ * earlier @font-face of it) stays wanted for its new variants. */
|
|
|
+ if (fam && font_defs[fam - 1].used)
|
|
|
f->used = 1;
|
|
|
- font_face_count++;
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
-/* Look up the first name in a font-family list that has an @font-face. */
|
|
|
+/* Look up the first name in a font-family list that has an @font-face and
|
|
|
+ * mark that family as used, so the browser only downloads faces the page
|
|
|
+ * refers to. */
|
|
|
static int font_family_id(const char *s, unsigned int len)
|
|
|
{
|
|
|
unsigned int i = 0;
|
|
|
|
|
|
while (i < len) {
|
|
|
- unsigned int start, end, q = 0;
|
|
|
+ unsigned int start, end, q;
|
|
|
|
|
|
while (i < len && (is_space(s[i]) || s[i] == ','))
|
|
|
i++;
|
|
|
@@ -4519,27 +4557,213 @@ static int font_family_id(const char *s, unsigned int len)
|
|
|
while (end > start && is_space(s[end - 1]))
|
|
|
end--;
|
|
|
}
|
|
|
- if (end > start) {
|
|
|
- for (q = 0; q < (unsigned int)font_face_count; q++) {
|
|
|
- const char *f = font_defs[q].family;
|
|
|
- unsigned int fl = s_len(f), k;
|
|
|
+ if (end <= start)
|
|
|
+ continue;
|
|
|
+ for (q = 0; q < (unsigned int)font_face_count; q++) {
|
|
|
+ int fam;
|
|
|
+ unsigned int k;
|
|
|
+
|
|
|
+ if (!font_name_eq(font_defs[q].family, s + start,
|
|
|
+ end - start))
|
|
|
+ continue;
|
|
|
+ fam = font_defs[q].family_id;
|
|
|
+ for (k = 0; k < (unsigned int)font_face_count; k++)
|
|
|
+ if (font_defs[k].family_id == fam)
|
|
|
+ font_defs[k].used = 1;
|
|
|
+ return fam;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
|
|
|
- if (fl != end - start)
|
|
|
- continue;
|
|
|
- for (k = 0; k < fl; k++) {
|
|
|
- char a = f[k], b = s[start + k];
|
|
|
-
|
|
|
- if (a >= 'A' && a <= 'Z')
|
|
|
- a = (char)(a - 'A' + 'a');
|
|
|
- if (b >= 'A' && b <= 'Z')
|
|
|
- b = (char)(b - 'A' + 'a');
|
|
|
- if (a != b)
|
|
|
- break;
|
|
|
- }
|
|
|
- if (k == fl)
|
|
|
- return (int)q + 1;
|
|
|
+/* font-weight descriptor: `normal`, `bold`, a number, or a variable font's
|
|
|
+ * `100 900` range. */
|
|
|
+static void font_parse_weight(const char *s, unsigned int len,
|
|
|
+ unsigned int *wmin, unsigned int *wmax)
|
|
|
+{
|
|
|
+ unsigned int i = 0, n = 0, w[2] = { 400, 400 };
|
|
|
+
|
|
|
+ while (i < len && n < 2) {
|
|
|
+ unsigned int v = 0, st;
|
|
|
+
|
|
|
+ while (i < len && is_space(s[i]))
|
|
|
+ i++;
|
|
|
+ st = i;
|
|
|
+ while (i < len && !is_space(s[i]))
|
|
|
+ i++;
|
|
|
+ if (i == st)
|
|
|
+ break;
|
|
|
+ if (i - st == 4 && ci_eq_n(s + st, "bold", 4)) {
|
|
|
+ v = 700;
|
|
|
+ } else if (i - st == 6 && ci_eq_n(s + st, "bolder", 6)) {
|
|
|
+ v = 700;
|
|
|
+ } else if (i - st == 7 && ci_eq_n(s + st, "lighter", 7)) {
|
|
|
+ v = 300;
|
|
|
+ } else if (s[st] >= '0' && s[st] <= '9') {
|
|
|
+ unsigned int k;
|
|
|
+
|
|
|
+ for (k = st; k < i && s[k] >= '0' && s[k] <= '9'; k++)
|
|
|
+ v = v * 10 + (unsigned int)(s[k] - '0');
|
|
|
+ } else {
|
|
|
+ v = 400;
|
|
|
+ }
|
|
|
+ if (v < 1)
|
|
|
+ v = 1;
|
|
|
+ if (v > 1000)
|
|
|
+ v = 1000;
|
|
|
+ w[n++] = v;
|
|
|
+ }
|
|
|
+ if (n == 1)
|
|
|
+ w[1] = w[0];
|
|
|
+ if (w[0] > w[1]) {
|
|
|
+ unsigned int t = w[0];
|
|
|
+
|
|
|
+ w[0] = w[1];
|
|
|
+ w[1] = t;
|
|
|
+ }
|
|
|
+ *wmin = w[0];
|
|
|
+ *wmax = w[1];
|
|
|
+}
|
|
|
+
|
|
|
+static int font_hex(char c)
|
|
|
+{
|
|
|
+ if (c >= '0' && c <= '9')
|
|
|
+ return c - '0';
|
|
|
+ if (c >= 'a' && c <= 'f')
|
|
|
+ return c - 'a' + 10;
|
|
|
+ if (c >= 'A' && c <= 'F')
|
|
|
+ return c - 'A' + 10;
|
|
|
+ return -1;
|
|
|
+}
|
|
|
+
|
|
|
+/* Whether a unicode-range list covers basic Latin. Google Fonts splits a
|
|
|
+ * family into per-script subsets with the same family/weight/style; only
|
|
|
+ * the one holding ASCII is useful here (the text path is Latin-1). */
|
|
|
+static int font_range_has_latin(const char *s, unsigned int len)
|
|
|
+{
|
|
|
+ unsigned int i = 0;
|
|
|
+
|
|
|
+ while (i < len) {
|
|
|
+ unsigned int lo = 0, hi, digits = 0, wild = 0;
|
|
|
+
|
|
|
+ while (i < len && (is_space(s[i]) || s[i] == ','))
|
|
|
+ i++;
|
|
|
+ if (i + 2 > len || (s[i] != 'U' && s[i] != 'u') ||
|
|
|
+ s[i + 1] != '+') {
|
|
|
+ while (i < len && s[i] != ',')
|
|
|
+ i++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ i += 2;
|
|
|
+ while (i < len && digits < 6 &&
|
|
|
+ (font_hex(s[i]) >= 0 || s[i] == '?')) {
|
|
|
+ if (s[i] == '?') {
|
|
|
+ lo <<= 4;
|
|
|
+ wild++;
|
|
|
+ } else {
|
|
|
+ lo = (lo << 4) | (unsigned int)font_hex(s[i]);
|
|
|
}
|
|
|
+ digits++;
|
|
|
+ i++;
|
|
|
}
|
|
|
+ hi = lo | ((1u << (wild * 4)) - 1u);
|
|
|
+ if (!wild && i < len && s[i] == '-') {
|
|
|
+ hi = 0;
|
|
|
+ i++;
|
|
|
+ while (i < len && font_hex(s[i]) >= 0) {
|
|
|
+ hi = (hi << 4) | (unsigned int)font_hex(s[i]);
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (digits && lo <= 'a' && hi >= 'a')
|
|
|
+ return 1;
|
|
|
+ while (i < len && s[i] != ',')
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+/* Pick the first `src` entry the text engine can load: a TrueType/OpenType
|
|
|
+ * file or WOFF 1.0, by its format() hint or, without one, by its
|
|
|
+ * extension. local() names, WOFF2, EOT, SVG fonts and data: URLs (they do
|
|
|
+ * not fit BR_FACE_URL) are skipped. */
|
|
|
+static int font_pick_src(const char *s, unsigned int len, char *url,
|
|
|
+ unsigned int cap, unsigned int *ulen)
|
|
|
+{
|
|
|
+ unsigned int i = 0;
|
|
|
+
|
|
|
+ while (i < len) {
|
|
|
+ unsigned int is_ = i, ie, us = 0, ue = 0, q, depth = 0;
|
|
|
+ int quote = 0, ok;
|
|
|
+ const char *up;
|
|
|
+ unsigned int un;
|
|
|
+
|
|
|
+ /* One comma-separated item, commas inside url()/quotes kept. */
|
|
|
+ while (i < len) {
|
|
|
+ char c = s[i];
|
|
|
+
|
|
|
+ if (quote) {
|
|
|
+ if (c == quote)
|
|
|
+ quote = 0;
|
|
|
+ } else if (c == '"' || c == '\'') {
|
|
|
+ quote = c;
|
|
|
+ } else if (c == '(') {
|
|
|
+ depth++;
|
|
|
+ } else if (c == ')') {
|
|
|
+ if (depth)
|
|
|
+ depth--;
|
|
|
+ } else if (c == ',' && !depth) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ ie = i;
|
|
|
+ i++;
|
|
|
+ for (q = is_; q + 4 <= ie; q++)
|
|
|
+ if (ci_eq_n(s + q, "url(", 4))
|
|
|
+ break;
|
|
|
+ if (q + 4 > ie)
|
|
|
+ continue;
|
|
|
+ us = q + 4;
|
|
|
+ for (ue = us; ue < ie && s[ue] != ')'; ue++)
|
|
|
+ if (s[ue] == '"' || s[ue] == '\'') {
|
|
|
+ char qc = s[ue++];
|
|
|
+
|
|
|
+ while (ue < ie && s[ue] != qc)
|
|
|
+ ue++;
|
|
|
+ }
|
|
|
+ up = s + us;
|
|
|
+ un = ue - us;
|
|
|
+ font_trim(&up, &un);
|
|
|
+ if (!un || un >= cap || (un >= 5 && ci_eq_n(up, "data:", 5)))
|
|
|
+ continue;
|
|
|
+ ok = 1;
|
|
|
+ if (contains_ci_len(s + ue, ie - ue, "format(")) {
|
|
|
+ const char *fp = s + ue;
|
|
|
+ unsigned int fn = ie - ue;
|
|
|
+
|
|
|
+ ok = (contains_ci_len(fp, fn, "truetype") ||
|
|
|
+ contains_ci_len(fp, fn, "opentype") ||
|
|
|
+ contains_ci_len(fp, fn, "woff")) &&
|
|
|
+ !contains_ci_len(fp, fn, "woff2") &&
|
|
|
+ !contains_ci_len(fp, fn, "embedded");
|
|
|
+ } else {
|
|
|
+ unsigned int e = 0;
|
|
|
+
|
|
|
+ while (e < un && up[e] != '?' && up[e] != '#')
|
|
|
+ e++;
|
|
|
+ if ((e >= 6 && ci_eq_n(up + e - 6, ".woff2", 6)) ||
|
|
|
+ (e >= 4 && ci_eq_n(up + e - 4, ".eot", 4)) ||
|
|
|
+ (e >= 4 && ci_eq_n(up + e - 4, ".svg", 4)))
|
|
|
+ ok = 0;
|
|
|
+ }
|
|
|
+ if (!ok)
|
|
|
+ continue;
|
|
|
+ for (q = 0; q < un; q++)
|
|
|
+ url[q] = up[q];
|
|
|
+ url[un] = '\0';
|
|
|
+ *ulen = un;
|
|
|
+ return 1;
|
|
|
}
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -4555,7 +4779,8 @@ static void scan_font_faces(const char *s, unsigned int len)
|
|
|
unsigned int j, end;
|
|
|
char family[BR_FACE_FAMILY], url[BR_FACE_URL];
|
|
|
unsigned int flen = 0, ulen = 0, p;
|
|
|
- int have_family = 0, have_url = 0;
|
|
|
+ unsigned int wmin = 400, wmax = 400;
|
|
|
+ int have_family = 0, have_url = 0, italic = 0, latin = 1;
|
|
|
|
|
|
if (s[i] != '@' || !ci_eq_n(s + i, "@font-face", 10)) {
|
|
|
i++;
|
|
|
@@ -4571,14 +4796,15 @@ static void scan_font_faces(const char *s, unsigned int len)
|
|
|
end = css_skip_nested(s, len, j + 1);
|
|
|
p = j + 1;
|
|
|
while (p < end) {
|
|
|
- unsigned int ds, de, vs, ve;
|
|
|
+ unsigned int ds, de, vs, ve, quote = 0;
|
|
|
|
|
|
while (p < end && (is_space(s[p]) || s[p] == ';'))
|
|
|
p++;
|
|
|
if (p >= end)
|
|
|
break;
|
|
|
ds = p;
|
|
|
- while (p < end && s[p] != ':' && s[p] != ';')
|
|
|
+ while (p < end && s[p] != ':' && s[p] != ';' &&
|
|
|
+ s[p] != '}')
|
|
|
p++;
|
|
|
de = p;
|
|
|
if (p >= end || s[p] != ':') {
|
|
|
@@ -4588,8 +4814,15 @@ static void scan_font_faces(const char *s, unsigned int len)
|
|
|
}
|
|
|
p++;
|
|
|
vs = p;
|
|
|
- while (p < end && s[p] != ';')
|
|
|
+ /* A quoted URL may contain ';' (data: URLs do). */
|
|
|
+ while (p < end && (quote || (s[p] != ';' &&
|
|
|
+ s[p] != '}'))) {
|
|
|
+ if (quote && s[p] == (char)quote)
|
|
|
+ quote = 0;
|
|
|
+ else if (!quote && (s[p] == '"' || s[p] == '\''))
|
|
|
+ quote = (unsigned char)s[p];
|
|
|
p++;
|
|
|
+ }
|
|
|
ve = p;
|
|
|
while (ds < de && is_space(s[ds]))
|
|
|
ds++;
|
|
|
@@ -4616,43 +4849,29 @@ static void scan_font_faces(const char *s, unsigned int len)
|
|
|
}
|
|
|
} else if (de - ds == 3 &&
|
|
|
ci_eq_n(s + ds, "src", 3)) {
|
|
|
- unsigned int q = vs;
|
|
|
-
|
|
|
- while (q + 4 <= ve) {
|
|
|
- unsigned int us, ue;
|
|
|
-
|
|
|
- if (!ci_eq_n(s + q, "url(", 4)) {
|
|
|
- q++;
|
|
|
- continue;
|
|
|
- }
|
|
|
- q += 4;
|
|
|
- us = q;
|
|
|
- while (q < ve && s[q] != ')')
|
|
|
- q++;
|
|
|
- ue = q;
|
|
|
- {
|
|
|
- const char *up = s + us;
|
|
|
- unsigned int un = ue - us;
|
|
|
-
|
|
|
- font_trim(&up, &un);
|
|
|
- if (un && un < sizeof(url) &&
|
|
|
- !contains_ci_len(up, un,
|
|
|
- "woff")) {
|
|
|
- unsigned int k;
|
|
|
-
|
|
|
- for (k = 0; k < un; k++)
|
|
|
- url[k] = up[k];
|
|
|
- url[un] = '\0';
|
|
|
- ulen = un;
|
|
|
- have_url = 1;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ /* A later src (the old IE `src: eot;` hack
|
|
|
+ * is followed by the real list) wins when
|
|
|
+ * it has a usable entry. */
|
|
|
+ if (font_pick_src(s + vs, ve - vs, url,
|
|
|
+ sizeof(url), &ulen))
|
|
|
+ have_url = 1;
|
|
|
+ } else if (de - ds == 11 &&
|
|
|
+ ci_eq_n(s + ds, "font-weight", 11)) {
|
|
|
+ font_parse_weight(s + vs, ve - vs, &wmin,
|
|
|
+ &wmax);
|
|
|
+ } else if (de - ds == 10 &&
|
|
|
+ ci_eq_n(s + ds, "font-style", 10)) {
|
|
|
+ italic = contains_ci_len(s + vs, ve - vs,
|
|
|
+ "italic") ||
|
|
|
+ contains_ci_len(s + vs, ve - vs,
|
|
|
+ "oblique");
|
|
|
+ } else if (de - ds == 13 &&
|
|
|
+ ci_eq_n(s + ds, "unicode-range", 13)) {
|
|
|
+ latin = font_range_has_latin(s + vs, ve - vs);
|
|
|
}
|
|
|
}
|
|
|
- if (have_family && have_url)
|
|
|
- font_add(family, flen, url, ulen);
|
|
|
+ if (have_family && have_url && latin)
|
|
|
+ font_add(family, flen, url, ulen, wmin, wmax, italic);
|
|
|
i = end;
|
|
|
}
|
|
|
}
|
|
|
@@ -4730,7 +4949,8 @@ static void add_font_shorthand(struct br_decl *out, unsigned int *nout,
|
|
|
unsigned char size_unit = 0;
|
|
|
int have_size = 0;
|
|
|
int bold = 0, italic = 0;
|
|
|
- int lh_px = 0, lh_pct = 0, mono = 0;
|
|
|
+ int lh_px = 0, lh_pct = 0, mono = 0, face;
|
|
|
+ unsigned int fam_at = len;
|
|
|
|
|
|
while (next_token(v, len, &pos, &ts, &te)) {
|
|
|
unsigned int tl = te - ts;
|
|
|
@@ -4779,6 +4999,8 @@ static void add_font_shorthand(struct br_decl *out, unsigned int *nout,
|
|
|
size_raw = raw;
|
|
|
size_unit = unit;
|
|
|
}
|
|
|
+ if (!have_size)
|
|
|
+ fam_at = te; /* the family list follows the size */
|
|
|
have_size = 1;
|
|
|
if (slash < tl) {
|
|
|
unsigned int lstart = ts + slash + 1;
|
|
|
@@ -4798,12 +5020,13 @@ static void add_font_shorthand(struct br_decl *out, unsigned int *nout,
|
|
|
if (!have_size)
|
|
|
return;
|
|
|
mono = contains_ci_len(v, len, "mono");
|
|
|
+ face = font_family_id(v + fam_at, len - fam_at);
|
|
|
decl_add(out, nout, PROP_FONT_PX, size_raw, important);
|
|
|
decl_add(out, nout, PROP_FONT_UNIT, size_unit, important);
|
|
|
decl_add(out, nout, PROP_BOLD, bold, important);
|
|
|
decl_add(out, nout, PROP_ITALIC, italic, important);
|
|
|
decl_add(out, nout, PROP_MONO, mono, important);
|
|
|
- decl_add(out, nout, PROP_FONT_FACE, 0, important);
|
|
|
+ decl_add(out, nout, PROP_FONT_FACE, face, important);
|
|
|
decl_add(out, nout, PROP_LH_PX, lh_px, important);
|
|
|
decl_add(out, nout, PROP_LH_PCT, lh_pct, important);
|
|
|
}
|