aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2021-11-14 15:02:39 +0200
committerEli Zaretskii2021-11-14 15:02:40 +0200
commit96806a22fbb54573053fdb796ebde4b6284b98ae (patch)
tree64b4454e78224b267173f64957ce917e606db350 /src
parentc3f53d26043a4e4a91a3f1d140f080b6c8d190d2 (diff)
parenta56dd60d2fba9d873748ca3831ba61711628f698 (diff)
downloademacs-96806a22fbb54573053fdb796ebde4b6284b98ae.tar.gz
emacs-96806a22fbb54573053fdb796ebde4b6284b98ae.zip
Merge from origin/emacs-28
a56dd60 Improve style and comments in font-related sources
Diffstat (limited to 'src')
-rw-r--r--src/font.c25
-rw-r--r--src/font.h7
-rw-r--r--src/w32font.c8
3 files changed, 28 insertions, 12 deletions
diff --git a/src/font.c b/src/font.c
index 420a4f8e70e..b503123b96e 100644
--- a/src/font.c
+++ b/src/font.c
@@ -3183,8 +3183,9 @@ font_clear_prop (Lisp_Object *attrs, enum font_property_index prop)
3183 attrs[LFACE_FONT_INDEX] = font; 3183 attrs[LFACE_FONT_INDEX] = font;
3184} 3184}
3185 3185
3186/* Select a font from ENTITIES (list of font-entity vectors) that 3186/* Select a font from ENTITIES (list of one or more font-entity
3187 supports C and is the best match for ATTRS and PIXEL_SIZE. */ 3187 vectors) that supports the character C (if non-negative) and is the
3188 best match for ATTRS and PIXEL_SIZE. */
3188 3189
3189static Lisp_Object 3190static Lisp_Object
3190font_select_entity (struct frame *f, Lisp_Object entities, 3191font_select_entity (struct frame *f, Lisp_Object entities,
@@ -3194,6 +3195,7 @@ font_select_entity (struct frame *f, Lisp_Object entities,
3194 Lisp_Object prefer; 3195 Lisp_Object prefer;
3195 int i; 3196 int i;
3196 3197
3198 /* If we have a single candidate, return it if it supports C. */
3197 if (NILP (XCDR (entities)) 3199 if (NILP (XCDR (entities))
3198 && ASIZE (XCAR (entities)) == 1) 3200 && ASIZE (XCAR (entities)) == 1)
3199 { 3201 {
@@ -3203,7 +3205,10 @@ font_select_entity (struct frame *f, Lisp_Object entities,
3203 return Qnil; 3205 return Qnil;
3204 } 3206 }
3205 3207
3206 /* Sort fonts by properties specified in ATTRS. */ 3208 /* If we have several candidates, find the best match by sorting
3209 them by properties specified in ATTRS. Style attributes (weight,
3210 slant, width, and size) are taken from the font spec in ATTRS (if
3211 that is non-nil), or from ATTRS, or left as nil. */
3207 prefer = scratch_font_prefer; 3212 prefer = scratch_font_prefer;
3208 3213
3209 for (i = FONT_WEIGHT_INDEX; i <= FONT_SIZE_INDEX; i++) 3214 for (i = FONT_WEIGHT_INDEX; i <= FONT_SIZE_INDEX; i++)
@@ -3240,6 +3245,8 @@ font_find_for_lface (struct frame *f, Lisp_Object *attrs, Lisp_Object spec, int
3240 int i, j, k, l; 3245 int i, j, k, l;
3241 USE_SAFE_ALLOCA; 3246 USE_SAFE_ALLOCA;
3242 3247
3248 /* Registry specification alternatives: from the most specific to
3249 the least specific and finally an unspecified one. */
3243 registry[0] = AREF (spec, FONT_REGISTRY_INDEX); 3250 registry[0] = AREF (spec, FONT_REGISTRY_INDEX);
3244 if (NILP (registry[0])) 3251 if (NILP (registry[0]))
3245 { 3252 {
@@ -3276,6 +3283,9 @@ font_find_for_lface (struct frame *f, Lisp_Object *attrs, Lisp_Object spec, int
3276 pixel_size = 1; 3283 pixel_size = 1;
3277 } 3284 }
3278 ASET (work, FONT_SIZE_INDEX, Qnil); 3285 ASET (work, FONT_SIZE_INDEX, Qnil);
3286
3287 /* Foundry specification alternatives: from the most specific to the
3288 least specific and finally an unspecified one. */
3279 foundry[0] = AREF (work, FONT_FOUNDRY_INDEX); 3289 foundry[0] = AREF (work, FONT_FOUNDRY_INDEX);
3280 if (! NILP (foundry[0])) 3290 if (! NILP (foundry[0]))
3281 foundry[1] = zero_vector; 3291 foundry[1] = zero_vector;
@@ -3289,6 +3299,8 @@ font_find_for_lface (struct frame *f, Lisp_Object *attrs, Lisp_Object spec, int
3289 else 3299 else
3290 foundry[0] = Qnil, foundry[1] = zero_vector; 3300 foundry[0] = Qnil, foundry[1] = zero_vector;
3291 3301
3302 /* Additional style specification alternatives: from the most
3303 specific to the least specific and finally an unspecified one. */
3292 adstyle[0] = AREF (work, FONT_ADSTYLE_INDEX); 3304 adstyle[0] = AREF (work, FONT_ADSTYLE_INDEX);
3293 if (! NILP (adstyle[0])) 3305 if (! NILP (adstyle[0]))
3294 adstyle[1] = zero_vector; 3306 adstyle[1] = zero_vector;
@@ -3309,6 +3321,8 @@ font_find_for_lface (struct frame *f, Lisp_Object *attrs, Lisp_Object spec, int
3309 adstyle[0] = Qnil, adstyle[1] = zero_vector; 3321 adstyle[0] = Qnil, adstyle[1] = zero_vector;
3310 3322
3311 3323
3324 /* Family specification alternatives: from the most specific to
3325 the least specific and finally an unspecified one. */
3312 val = AREF (work, FONT_FAMILY_INDEX); 3326 val = AREF (work, FONT_FAMILY_INDEX);
3313 if (NILP (val) && STRINGP (attrs[LFACE_FAMILY_INDEX])) 3327 if (NILP (val) && STRINGP (attrs[LFACE_FAMILY_INDEX]))
3314 { 3328 {
@@ -3348,6 +3362,8 @@ font_find_for_lface (struct frame *f, Lisp_Object *attrs, Lisp_Object spec, int
3348 } 3362 }
3349 } 3363 }
3350 3364
3365 /* Now look up suitable fonts, from the most specific spec to the
3366 least specific spec. Accept the first one that matches. */
3351 for (i = 0; SYMBOLP (family[i]); i++) 3367 for (i = 0; SYMBOLP (family[i]); i++)
3352 { 3368 {
3353 ASET (work, FONT_FAMILY_INDEX, family[i]); 3369 ASET (work, FONT_FAMILY_INDEX, family[i]);
@@ -3360,9 +3376,12 @@ font_find_for_lface (struct frame *f, Lisp_Object *attrs, Lisp_Object spec, int
3360 for (l = 0; SYMBOLP (adstyle[l]); l++) 3376 for (l = 0; SYMBOLP (adstyle[l]); l++)
3361 { 3377 {
3362 ASET (work, FONT_ADSTYLE_INDEX, adstyle[l]); 3378 ASET (work, FONT_ADSTYLE_INDEX, adstyle[l]);
3379 /* Produce the list of candidates for the spec in WORK. */
3363 entities = font_list_entities (f, work); 3380 entities = font_list_entities (f, work);
3364 if (! NILP (entities)) 3381 if (! NILP (entities))
3365 { 3382 {
3383 /* If there are several candidates, select the
3384 best match for PIXEL_SIZE and attributes in ATTRS. */
3366 val = font_select_entity (f, entities, 3385 val = font_select_entity (f, entities,
3367 attrs, pixel_size, c); 3386 attrs, pixel_size, c);
3368 if (! NILP (val)) 3387 if (! NILP (val))
diff --git a/src/font.h b/src/font.h
index 1da72cca079..6694164e09b 100644
--- a/src/font.h
+++ b/src/font.h
@@ -69,9 +69,10 @@ INLINE_HEADER_BEGIN
69 69
70enum font_property_index 70enum font_property_index
71 { 71 {
72 /* FONT-TYPE is a symbol indicating a font backend; currently `x' 72 /* FONT-TYPE is a symbol indicating a font backend; currently `x',
73 and `xft' are available on X, `uniscribe' and `gdi' on 73 `xft', `xfthb', `ftrc', and `ftcrhb' are available on X;
74 Windows, and `ns' under Cocoa / GNUstep. */ 74 `harfbuzz', `uniscribe', and `gdi' on Windows, and `ns' under
75 Cocoa / GNUstep. */
75 FONT_TYPE_INDEX, 76 FONT_TYPE_INDEX,
76 77
77 /* FONT-FOUNDRY is a foundry name (symbol). */ 78 /* FONT-FOUNDRY is a foundry name (symbol). */
diff --git a/src/w32font.c b/src/w32font.c
index 752acdc9048..2d09f459f89 100644
--- a/src/w32font.c
+++ b/src/w32font.c
@@ -2022,13 +2022,9 @@ fill_in_logfont (struct frame *f, LOGFONT *logfont, Lisp_Object font_spec)
2022 2022
2023 tmp = AREF (font_spec, FONT_DPI_INDEX); 2023 tmp = AREF (font_spec, FONT_DPI_INDEX);
2024 if (FIXNUMP (tmp)) 2024 if (FIXNUMP (tmp))
2025 { 2025 dpi = XFIXNUM (tmp);
2026 dpi = XFIXNUM (tmp);
2027 }
2028 else if (FLOATP (tmp)) 2026 else if (FLOATP (tmp))
2029 { 2027 dpi = (int) (XFLOAT_DATA (tmp) + 0.5);
2030 dpi = (int) (XFLOAT_DATA (tmp) + 0.5);
2031 }
2032 2028
2033 /* Height */ 2029 /* Height */
2034 tmp = AREF (font_spec, FONT_SIZE_INDEX); 2030 tmp = AREF (font_spec, FONT_SIZE_INDEX);