NetBSD Problem Report #53730

From www@NetBSD.org  Sun Nov 18 00:11:41 2018
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id BB5D77A111
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 18 Nov 2018 00:11:41 +0000 (UTC)
Message-Id: <20181118001138.906AA7A1D7@mollari.NetBSD.org>
Date: Sun, 18 Nov 2018 00:11:38 +0000 (UTC)
From: js-pkgsrc@heap.zone
Reply-To: js-pkgsrc@heap.zone
To: gnats-bugs@NetBSD.org
Subject: [devel/pangp] Font scaling is broken on macOS
X-Send-Pr-Version: www-1.0

>Number:         53730
>Category:       pkg
>Synopsis:       [devel/pangp] Font scaling is broken on macOS
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    macos-pkg-people
>State:          feedback
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Nov 18 00:15:00 +0000 2018
>Closed-Date:    
>Last-Modified:  Fri Sep 04 11:15:01 +0000 2020
>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>
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>
+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>
+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>
+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>
+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>
+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>
+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);

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: pkg-manager->macos-pkg-people
Responsible-Changed-By: leot@NetBSD.org
Responsible-Changed-When: Sun, 18 Nov 2018 09:52:08 +0000
Responsible-Changed-Why:
macOS problem


From: "Maya Rashish" <maya@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/53730 CVS commit: pkgsrc/devel/pango
Date: Tue, 20 Nov 2018 08:34:43 +0000

 Module Name:	pkgsrc
 Committed By:	maya
 Date:		Tue Nov 20 08:34:43 UTC 2018

 Modified Files:
 	pkgsrc/devel/pango: Makefile distinfo
 Added Files:
 	pkgsrc/devel/pango/patches: patch-pango_pangocairo-coretextfont.c
 	    patch-pango_pangocairo-coretextfontmap.c
 	    patch-pango_pangocoretext-fontmap.c
 	    patch-pango_pangocoretext-private.h patch-pango_pangocoretext.c

 Log Message:
 pango: backport upstream commit (revert) to fix font scaling
 with (Apple's) CoreText fonts.

 Bump PKGREVISION.

 From Jonathan Schleifer in PR pkg/53730


 To generate a diff of this commit:
 cvs rdiff -u -r1.216 -r1.217 pkgsrc/devel/pango/Makefile
 cvs rdiff -u -r1.117 -r1.118 pkgsrc/devel/pango/distinfo
 cvs rdiff -u -r0 -r1.1 \
     pkgsrc/devel/pango/patches/patch-pango_pangocairo-coretextfont.c \
     pkgsrc/devel/pango/patches/patch-pango_pangocairo-coretextfontmap.c \
     pkgsrc/devel/pango/patches/patch-pango_pangocoretext-fontmap.c \
     pkgsrc/devel/pango/patches/patch-pango_pangocoretext-private.h \
     pkgsrc/devel/pango/patches/patch-pango_pangocoretext.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: maya@NetBSD.org
State-Changed-When: Tue, 20 Nov 2018 08:35:40 +0000
State-Changed-Why:
Applied, thanks for the patch!


State-Changed-From-To: closed->feedback
State-Changed-By: prlw1@NetBSD.org
State-Changed-When: Tue, 25 Aug 2020 14:31:39 +0000
State-Changed-Why:
The pkgsrc commit message says "backport upstream commit (revert)", but
AFAICT upstream did not revert f661cdbf8cf. Looking at

https://bugzilla.gnome.org/show_bug.cgi?id=787867

it seems that things should look sensible after gtk 3.24.2. We are now
on 3.24.22, so are these pkgsrc patches still necessary?


From: "Patrick Welche" <prlw1@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/53730 CVS commit: pkgsrc/devel/pango
Date: Fri, 4 Sep 2020 11:14:08 +0000

 Module Name:	pkgsrc
 Committed By:	prlw1
 Date:		Fri Sep  4 11:14:08 UTC 2020

 Modified Files:
 	pkgsrc/devel/pango: Makefile PLIST distinfo

 Log Message:
 Update pango to 1.46.1

 XXX Are the CoreText patches still necessary? (c.f. PR pkg/53730)

 Overview of changes in 1.46.1
 =============================
 - Revert an unintentional PangoRenderer abi break in 1.46.0
 - Various small fixes

 Overview of changes in 1.46.0
 =============================
 - Bump version to 1.46

 Overview of changes in 1.45.5
 =============================
 - Export pango_color_parse_with_alpha
 - Stop using hb-glib

 Overview of changes in 1.45.4
 =============================
 - Fix build on Windows
 - Fix a pidgin crash
 - fc: Always reject unsupported font formats
 - coretext: Fix cairo scaling

 Overview of changes in 1.45.3
 =============================
 - Fix pango_attr_list_change
 - Fix crashes with empty attribute lists

 Overview of changes in 1.45.2
 =============================
 - Fix several crashes in gtk2 applications
 - Revert an unintentional introspection API change
 - Include HarfBuzz when igenerating introspection data

 Overview of changes in 1.45.1
 =============================
 - Undo PangoFontsetSimple deprecation
 - Annotation fixes for various apis
 - Add api to compare attribute lists
 - Update data tables to Unicode 13.0
 - Various test improvements
 - Require GLib 2.60

 Overview of changes in 1.45.0
 =============================
 - Some new font enumeration apis:
   pango_font_map_get_family
   pango_font_family_get_face
   pango_font_face_get_family
   pango_font_get_face
 - Support for line-wide underlines
 - Support for overlines


 To generate a diff of this commit:
 cvs rdiff -u -r1.234 -r1.235 pkgsrc/devel/pango/Makefile
 cvs rdiff -u -r1.73 -r1.74 pkgsrc/devel/pango/PLIST
 cvs rdiff -u -r1.124 -r1.125 pkgsrc/devel/pango/distinfo

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.