aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStanislav Yaglo2023-06-12 11:56:37 +0100
committerEli Zaretskii2024-02-01 12:18:50 +0200
commitff63da26b6b00fd0e2ba04239b56b385bd83b53a (patch)
tree130d6e8aff3e84f3d1ab202b79ec3315ad447199
parent169c704d74747d411a545eff9c497ddafb9c886c (diff)
downloademacs-ff63da26b6b00fd0e2ba04239b56b385bd83b53a.tar.gz
emacs-ff63da26b6b00fd0e2ba04239b56b385bd83b53a.zip
macfont.m: Fix values for font widths and weights on macOS
* src/macfont.m (mac_font_get_glyphs_for_variants) (macfont_variation_glyphs): Fix width values. (Bug#64013)
-rw-r--r--src/macfont.m96
1 files changed, 68 insertions, 28 deletions
diff --git a/src/macfont.m b/src/macfont.m
index 6f192b00f1b..e3b3d40df43 100644
--- a/src/macfont.m
+++ b/src/macfont.m
@@ -855,21 +855,42 @@ macfont_store_descriptor_attributes (CTFontDescriptorRef desc,
855 struct { 855 struct {
856 enum font_property_index index; 856 enum font_property_index index;
857 CFStringRef trait; 857 CFStringRef trait;
858 CGPoint points[6]; 858 CGPoint points[12];
859 CGFloat (*adjust_func) (CTFontDescriptorRef, CGFloat); 859 CGFloat (*adjust_func) (CTFontDescriptorRef, CGFloat);
860 } numeric_traits[] = 860 } numeric_traits[] = {
861 {{FONT_WEIGHT_INDEX, kCTFontWeightTrait, 861 { FONT_WEIGHT_INDEX,
862 {{-0.4, 50}, /* light */ 862 kCTFontWeightTrait,
863 {-0.24, 87.5}, /* (semi-light + normal) / 2 */ 863 { { -0.6, 0 }, /* thin */
864 {0, 80}, /* normal */ 864 { -0.4, 40 }, /* ultra-light, ultralight, extra-light, extralight */
865 {0.24, 140}, /* (semi-bold + normal) / 2 */ 865 { -0.23, 50 }, /* light */
866 {0.4, 200}, /* bold */ 866 { -0.115, 55 }, /* semi-light, semilight, demilight */
867 {CGFLOAT_MAX, CGFLOAT_MAX}}, 867 { 0, 80 }, /* regular, normal, unspecified, book */
868 mac_font_descriptor_get_adjusted_weight}, 868 { 0.2, 100 }, /* medium */
869 {FONT_SLANT_INDEX, kCTFontSlantTrait, 869 { 0.3, 180 }, /* semi-bold, semibold, demibold, demi-bold, demi */
870 {{0, 100}, {0.1, 200}, {CGFLOAT_MAX, CGFLOAT_MAX}}, NULL}, 870 { 0.4, 200 }, /* bold */
871 {FONT_WIDTH_INDEX, kCTFontWidthTrait, 871 { 0.6, 205 }, /* extra-bold, extrabold, ultra-bold, ultrabold */
872 {{0, 100}, {1, 200}, {CGFLOAT_MAX, CGFLOAT_MAX}}, NULL}}; 872 { 0.8, 210 }, /* black, heavy */
873 { 1, 250 }, /* ultra-heavy, ultraheavy */
874 { CGFLOAT_MAX, CGFLOAT_MAX } },
875 mac_font_descriptor_get_adjusted_weight },
876 { FONT_SLANT_INDEX,
877 kCTFontSlantTrait,
878 { { 0, 100 }, { 0.1, 200 }, { CGFLOAT_MAX, CGFLOAT_MAX } },
879 NULL },
880 { FONT_WIDTH_INDEX,
881 kCTFontWidthTrait,
882 { { -0.4, 50 }, /* ultra-condensed, ultracondensed */
883 { -0.3, 63 }, /* extra-condensed, extracondensed */
884 { -0.2, 75 }, /* condensed, compressed, narrow */
885 { -0.1, 87 }, /* semi-condensed, semicondensed, demicondensed */
886 { 0, 100 }, /* normal, medium, regular, unspecified */
887 { 0.1, 113 }, /* semi-expanded, semiexpanded, demiexpanded */
888 { 0.2, 125 }, /* expanded */
889 { 0.3, 150 }, /* extra-expanded, extraexpanded */
890 { 0.4, 200 }, /* ultra-expanded, ultraexpanded, wide */
891 { CGFLOAT_MAX, CGFLOAT_MAX } },
892 NULL }
893 };
873 int i; 894 int i;
874 895
875 for (i = 0; i < ARRAYELTS (numeric_traits); i++) 896 for (i = 0; i < ARRAYELTS (numeric_traits); i++)
@@ -1941,19 +1962,38 @@ macfont_create_attributes_with_spec (Lisp_Object spec)
1941 struct { 1962 struct {
1942 enum font_property_index index; 1963 enum font_property_index index;
1943 CFStringRef trait; 1964 CFStringRef trait;
1944 CGPoint points[6]; 1965 CGPoint points[12];
1945 } numeric_traits[] = 1966 } numeric_traits[] = {
1946 {{FONT_WEIGHT_INDEX, kCTFontWeightTrait, 1967 { FONT_WEIGHT_INDEX,
1947 {{-0.4, 50}, /* light */ 1968 kCTFontWeightTrait,
1948 {-0.24, 87.5}, /* (semi-light + normal) / 2 */ 1969 { { -0.6, 0 }, /* thin */
1949 {0, 100}, /* normal */ 1970 { -0.4, 40 }, /* ultra-light, ultralight, extra-light, extralight */
1950 {0.24, 140}, /* (semi-bold + normal) / 2 */ 1971 { -0.23, 50 }, /* light */
1951 {0.4, 200}, /* bold */ 1972 { -0.115, 55 }, /* semi-light, semilight, demilight */
1952 {CGFLOAT_MAX, CGFLOAT_MAX}}}, 1973 { 0, 80 }, /* regular, normal, unspecified, book */
1953 {FONT_SLANT_INDEX, kCTFontSlantTrait, 1974 { 0.2, 100 }, /* medium */
1954 {{0, 100}, {0.1, 200}, {CGFLOAT_MAX, CGFLOAT_MAX}}}, 1975 { 0.3, 180 }, /* semi-bold, semibold, demibold, demi-bold, demi */
1955 {FONT_WIDTH_INDEX, kCTFontWidthTrait, 1976 { 0.4, 200 }, /* bold */
1956 {{0, 100}, {1, 200}, {CGFLOAT_MAX, CGFLOAT_MAX}}}}; 1977 { 0.6, 205 }, /* extra-bold, extrabold, ultra-bold, ultrabold */
1978 { 0.8, 210 }, /* black, heavy */
1979 { 1, 250 }, /* ultra-heavy, ultraheavy */
1980 { CGFLOAT_MAX, CGFLOAT_MAX } } },
1981 { FONT_SLANT_INDEX,
1982 kCTFontSlantTrait,
1983 { { 0, 100 }, { 0.1, 200 }, { CGFLOAT_MAX, CGFLOAT_MAX } } },
1984 { FONT_WIDTH_INDEX,
1985 kCTFontWidthTrait,
1986 { { -0.4, 50 }, /* ultra-condensed, ultracondensed */
1987 { -0.3, 63 }, /* extra-condensed, extracondensed */
1988 { -0.2, 75 }, /* condensed, compressed, narrow */
1989 { -0.1, 87 }, /* semi-condensed, semicondensed, demicondensed */
1990 { 0, 100 }, /* normal, medium, regular, unspecified */
1991 { 0.1, 113 }, /* semi-expanded, semiexpanded, demiexpanded */
1992 { 0.2, 125 }, /* expanded */
1993 { 0.3, 150 }, /* extra-expanded, extraexpanded */
1994 { 0.4, 200 }, /* ultra-expanded, ultraexpanded, wide */
1995 { CGFLOAT_MAX, CGFLOAT_MAX } } }
1996 };
1957 1997
1958 registry = AREF (spec, FONT_REGISTRY_INDEX); 1998 registry = AREF (spec, FONT_REGISTRY_INDEX);
1959 if (NILP (registry) 1999 if (NILP (registry)