pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg/53730: [devel/pangp] Font scaling is broken on macOS



>Number:         53730
>Category:       pkg
>Synopsis:       [devel/pangp] Font scaling is broken on macOS
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Nov 18 00:15:00 +0000 2018
>Originator:     Jonathan Schleifer
>Release:        HEAD
>Organization:
>Environment:
macOS Mojave
>Description:
Font scaling in devel/pango is broken on macOS, resulting in all fonts in Gtk+3 applications being extremely huge. The attached patch fixes this.
>How-To-Repeat:
Buld x11/gtk+3. Launch gtk3-demo. All fonts are gigantic.
>Fix:
commit 2bdce1da9a900ba188fa77e9171aeb9560d34975
Author: Jonathan Schleifer <js%heap.zone@localhost>
Date:   Sun Nov 18 01:10:44 2018 +0100

    pango: Fix gigantic fonts on macOS

diff --git a/devel/pango/Makefile b/devel/pango/Makefile
index 089f52ad12c..381f87fd4b6 100644
--- a/devel/pango/Makefile
+++ b/devel/pango/Makefile
@@ -1,7 +1,7 @@
 # $NetBSD: Makefile,v 1.216 2018/11/14 22:21:19 kleink Exp $
 
 DISTNAME=	pango-1.42.4
-PKGREVISION=	2
+PKGREVISION=	3
 CATEGORIES=	devel fonts
 MASTER_SITES=	${MASTER_SITE_GNOME:=sources/pango/${PKGVERSION_NOREV:R}/}
 EXTRACT_SUFX=	.tar.xz
diff --git a/devel/pango/distinfo b/devel/pango/distinfo
index 31c56264b9e..4ddab0e4bea 100644
--- a/devel/pango/distinfo
+++ b/devel/pango/distinfo
@@ -4,5 +4,11 @@ SHA1 (pango-1.42.4.tar.xz) = 240942b1307eaa3819e6e534596271c57cd75457
 RMD160 (pango-1.42.4.tar.xz) = e91880e0e9a459bbc2c280ac747ab31f80352000
 SHA512 (pango-1.42.4.tar.xz) = 993e97f647eba0c5ed90bcfcb8228bf67fa3f20b1f4331e4e40a30788d7c3ac55eee1209471bf21df125cb8fc6121acc8062a9da2f8a7d6cbe8e9ad13a9320dc
 Size (pango-1.42.4.tar.xz) = 833876 bytes
+SHA1 (patch-pango_pangocairo-coretextfont.c) = 6e5cd190656367edcdc4b30d9700379be1323f2e
+SHA1 (patch-pango_pangocairo-coretextfontmap.c) = ef69512b89306c29c070028c71a5898299102b0b
+SHA1 (patch-pango_pangocoretext-fontmap.c) = 53d00ffbf6fbf2bdf6f0e3c010658211d8408032
+SHA1 (patch-pango_pangocoretext-private.h) = 7a1ca4a46bf8e55f37d56ac65aa3469943744342
+SHA1 (patch-pango_pangocoretext.c) = 6fadefa3fb9fa219333168abad32a20f63142ef0
 SHA1 (patch-pango_pangocoretext.h) = d6817eb02f0020c102ab95d63202f9508a70e647
 SHA1 (patch-pangocairo-coretext.h) = 2f7c8efad48b58398070f48e71c16d99d3d59f57
+SHA1 (patch-tets_test-layout.c) = f9e978f49225e18d23264ab05afb75b90db9cd83
diff --git a/devel/pango/patches/patch-pango_pangocairo-coretextfont.c b/devel/pango/patches/patch-pango_pangocairo-coretextfont.c
new file mode 100644
index 00000000000..cb72fb05782
--- /dev/null
+++ b/devel/pango/patches/patch-pango_pangocairo-coretextfont.c
@@ -0,0 +1,57 @@
+$NetBSD$
+From 60df2b006e5d4553abc7bb5fe9a99539c91b0022 Mon Sep 17 00:00:00 2001
+From: Tom Schoonjans <Tom.Schoonjans%diamond.ac.uk@localhost>
+Date: Fri, 20 Jul 2018 12:30:34 +0100
+Subject: [PATCH] Revert "Restore scaling of CoreText fonts."
+
+This reverts commit f661cdbf8cfbdb2ba7241d8dfa4a579c6dfe0a94.
+
+--- pango/pangocairo-coretextfont.c.orig	2018-07-16 00:50:43.000000000 +0000
++++ pango/pangocairo-coretextfont.c
+@@ -36,7 +36,6 @@ struct _PangoCairoCoreTextFont
+ {
+   PangoCoreTextFont font;
+   PangoCairoFontPrivate cf_priv;
+-  int abs_size;
+ };
+ 
+ struct _PangoCairoCoreTextFontClass
+@@ -163,17 +162,6 @@ pango_cairo_core_text_font_create_base_m
+   return metrics;
+ }
+ 
+-static PangoFontDescription *
+-pango_cairo_core_text_font_describe_absolute (PangoFont *font)
+-{
+-  PangoCairoCoreTextFont *cafont = (PangoCairoCoreTextFont *)font;
+-  PangoFontDescription *desc = pango_font_describe (font);
+-  
+-  pango_font_description_set_absolute_size (desc, cafont->abs_size);
+-
+-  return desc;
+-}
+-
+ static void
+ pango_cairo_core_text_font_finalize (GObject *object)
+ {
+@@ -191,10 +179,9 @@ pango_cairo_core_text_font_class_init (P
+   PangoFontClass *font_class = PANGO_FONT_CLASS (class);
+ 
+   object_class->finalize = pango_cairo_core_text_font_finalize;
+-  /* font_class->describe defined by parent class PangoCoreTextFont. */
++
+   font_class->get_glyph_extents = pango_cairo_core_text_font_get_glyph_extents;
+   font_class->get_metrics = _pango_cairo_font_get_metrics;
+-  font_class->describe_absolute = pango_cairo_core_text_font_describe_absolute;
+ }
+ 
+ static void
+@@ -232,8 +219,6 @@ _pango_cairo_core_text_font_new (PangoCa
+   cafont = g_object_new (PANGO_TYPE_CAIRO_CORE_TEXT_FONT, NULL);
+   cfont = PANGO_CORE_TEXT_FONT (cafont);
+ 
+-  cafont->abs_size = pango_core_text_font_key_get_size (key);
+-
+   _pango_core_text_font_set_ctfont (cfont, font_ref);
+ 
+   if (synthesize_italic)
diff --git a/devel/pango/patches/patch-pango_pangocairo-coretextfontmap.c b/devel/pango/patches/patch-pango_pangocairo-coretextfontmap.c
new file mode 100644
index 00000000000..cdfc216e59d
--- /dev/null
+++ b/devel/pango/patches/patch-pango_pangocairo-coretextfontmap.c
@@ -0,0 +1,17 @@
+$NetBSD$
+From 60df2b006e5d4553abc7bb5fe9a99539c91b0022 Mon Sep 17 00:00:00 2001
+From: Tom Schoonjans <Tom.Schoonjans%diamond.ac.uk@localhost>
+Date: Fri, 20 Jul 2018 12:30:34 +0100
+Subject: [PATCH] Revert "Restore scaling of CoreText fonts."
+
+This reverts commit f661cdbf8cfbdb2ba7241d8dfa4a579c6dfe0a94.
+
+--- pango/pangocairo-coretextfontmap.c.orig	2018-07-16 00:50:43.000000000 +0000
++++ pango/pangocairo-coretextfontmap.c
+@@ -186,5 +186,5 @@ static void
+ pango_cairo_core_text_font_map_init (PangoCairoCoreTextFontMap *cafontmap)
+ {
+   cafontmap->serial = 1;
+-  cafontmap->dpi = 96.;
++  cafontmap->dpi = 72.;
+ }
diff --git a/devel/pango/patches/patch-pango_pangocoretext-fontmap.c b/devel/pango/patches/patch-pango_pangocoretext-fontmap.c
new file mode 100644
index 00000000000..48e153ecf58
--- /dev/null
+++ b/devel/pango/patches/patch-pango_pangocoretext-fontmap.c
@@ -0,0 +1,45 @@
+$NetBSD$
+From 60df2b006e5d4553abc7bb5fe9a99539c91b0022 Mon Sep 17 00:00:00 2001
+From: Tom Schoonjans <Tom.Schoonjans%diamond.ac.uk@localhost>
+Date: Fri, 20 Jul 2018 12:30:34 +0100
+Subject: [PATCH] Revert "Restore scaling of CoreText fonts."
+
+This reverts commit f661cdbf8cfbdb2ba7241d8dfa4a579c6dfe0a94.
+
+--- pango/pangocoretext-fontmap.c.orig	2018-08-06 02:47:22.000000000 +0000
++++ pango/pangocoretext-fontmap.c
+@@ -806,7 +806,6 @@ get_context_matrix (PangoContext *contex
+ /*
+  * Helper functions for PangoCoreTextFontsetKey
+  */
+-static const double ppi = 72.0; /* typographic points per inch */
+ 
+ static double
+ pango_core_text_font_map_get_resolution (PangoCoreTextFontMap *fontmap,
+@@ -818,7 +817,7 @@ pango_core_text_font_map_get_resolution 
+   /* FIXME: acquire DPI from CoreText using some deafault font */
+   g_warning ("FIXME: returning default DPI");
+ 
+-  return ppi;
++  return 72.0;
+ }
+ 
+ static int
+@@ -827,16 +826,8 @@ get_scaled_size (PangoCoreTextFontMap   
+                  const PangoFontDescription *desc)
+ {
+   double size = pango_font_description_get_size (desc);
+-  PangoMatrix *matrix = pango_context_get_matrix (context);
+-  double scale_factor = pango_matrix_get_font_scale_factor (matrix);
+-  
+-  if (!pango_font_description_get_size_is_absolute(desc))
+-  {
+-    double dpi = pango_core_text_font_map_get_resolution (fontmap, context);
+-    size *= (dpi/ppi);
+-  }
+ 
+-  return .5 +  scale_factor * size;
++  return .5 + pango_matrix_get_font_scale_factor (pango_context_get_matrix (context)) * size;
+ }
+ 
+ 
diff --git a/devel/pango/patches/patch-pango_pangocoretext-private.h b/devel/pango/patches/patch-pango_pangocoretext-private.h
new file mode 100644
index 00000000000..7d820bd9d2d
--- /dev/null
+++ b/devel/pango/patches/patch-pango_pangocoretext-private.h
@@ -0,0 +1,19 @@
+$NetBSD$
+From 60df2b006e5d4553abc7bb5fe9a99539c91b0022 Mon Sep 17 00:00:00 2001
+From: Tom Schoonjans <Tom.Schoonjans%diamond.ac.uk@localhost>
+Date: Fri, 20 Jul 2018 12:30:34 +0100
+Subject: [PATCH] Revert "Restore scaling of CoreText fonts."
+
+This reverts commit f661cdbf8cfbdb2ba7241d8dfa4a579c6dfe0a94.
+
+--- pango/pangocoretext-private.h.orig	2018-07-16 00:50:43.000000000 +0000
++++ pango/pangocoretext-private.h
+@@ -99,8 +99,6 @@ void                  _pango_core_text_f
+ PangoFontDescription *_pango_core_text_font_description_from_ct_font_descriptor (CTFontDescriptorRef desc);
+ 
+ _PANGO_EXTERN
+-int                   pango_core_text_font_key_get_size             (const PangoCoreTextFontKey *key);
+-_PANGO_EXTERN
+ int                   pango_core_text_font_key_get_size    (const PangoCoreTextFontKey *key);
+ _PANGO_EXTERN
+ double                pango_core_text_font_key_get_resolution       (const PangoCoreTextFontKey *key);
diff --git a/devel/pango/patches/patch-pango_pangocoretext.c b/devel/pango/patches/patch-pango_pangocoretext.c
new file mode 100644
index 00000000000..d33e9b97950
--- /dev/null
+++ b/devel/pango/patches/patch-pango_pangocoretext.c
@@ -0,0 +1,22 @@
+$NetBSD$
+From 60df2b006e5d4553abc7bb5fe9a99539c91b0022 Mon Sep 17 00:00:00 2001
+From: Tom Schoonjans <Tom.Schoonjans%diamond.ac.uk@localhost>
+Date: Fri, 20 Jul 2018 12:30:34 +0100
+Subject: [PATCH] Revert "Restore scaling of CoreText fonts."
+
+This reverts commit f661cdbf8cfbdb2ba7241d8dfa4a579c6dfe0a94.
+
+--- pango/pangocoretext.c.orig	2018-07-16 00:50:43.000000000 +0000
++++ pango/pangocoretext.c
+@@ -225,7 +225,10 @@ pango_core_text_font_class_init (PangoCo
+   object_class->finalize = pango_core_text_font_finalize;
+ 
+   font_class->describe = pango_core_text_font_describe;
+-  /* font_class->describe_absolute is left virtual for PangoCairoCoreTextFont. */
++  /* In CoreText the device unit is points so describe_absoulute and
++   * describe are the same.
++   */
++  font_class->describe_absolute = pango_core_text_font_describe;
+   font_class->get_coverage = pango_core_text_font_get_coverage;
+   font_class->find_shaper = pango_core_text_font_find_shaper;
+   font_class->get_font_map = pango_core_text_font_get_font_map;
diff --git a/devel/pango/patches/patch-tets_test-layout.c b/devel/pango/patches/patch-tets_test-layout.c
new file mode 100644
index 00000000000..15c9377b153
--- /dev/null
+++ b/devel/pango/patches/patch-tets_test-layout.c
@@ -0,0 +1,30 @@
+$NetBSD$
+From 60df2b006e5d4553abc7bb5fe9a99539c91b0022 Mon Sep 17 00:00:00 2001
+From: Tom Schoonjans <Tom.Schoonjans%diamond.ac.uk@localhost>
+Date: Fri, 20 Jul 2018 12:30:34 +0100
+Subject: [PATCH] Revert "Restore scaling of CoreText fonts."
+
+This reverts commit f661cdbf8cfbdb2ba7241d8dfa4a579c6dfe0a94.
+
+--- tests/test-layout.c.orig	2018-07-16 00:50:43.000000000 +0000
++++ tests/test-layout.c
+@@ -265,9 +265,18 @@ test_file (const gchar *filename, GStrin
+   parse_params (contents, &width, &ellipsize_at, &ellipsize, &wrap);
+ 
+   layout = pango_layout_new (context);
++/* The layout tests are predicated on scaling fonts to 90 DPI, but
++ * Apple's font APIs (CoreText and CoreGraphics) don't work that way
++ * so we have to use a bigger font to get the results to agree with
++ * the expected values.
++ */
++#if defined (HAVE_CORE_TEXT) && defined (HAVE_CAIRO_QUARTZ)
++  desc = pango_font_description_from_string ("Cantarell 14.5");
++#else
+   desc = pango_font_description_from_string ("Cantarell 11");
++#endif
+   pango_layout_set_font_description (layout, desc);
+-  pango_font_description_free (desc);
++  pango_font_description_free (desc); 
+ 
+   pango_layout_set_markup (layout, markup, length);
+   g_free (contents);



Home | Main Index | Thread Index | Old Index