After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 113681 - Support different font backend (e.g. pangowin32)
Support different font backend (e.g. pangowin32)
Status: RESOLVED WONTFIX
Product: GIMP
Classification: Other
Component: General
git master
Other Windows
: Normal normal
: ---
Assigned To: GIMP Bugs
GIMP Bugs
Depends on: 94791
Blocks:
 
 
Reported: 2003-05-25 08:56 UTC by Hans Breuer
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Hans Breuer 2003-05-25 08:56:34 UTC
The state of the pangoft2 (1.2) backend on win32 is broken
by dpendending on fontconfig. Currently The GIMP needs a
render to bitmap facility which is easily done with pangowin32,
too.

More discussion:
http://mail.gnome.org/archives/gtk-devel-list/2001-August/msg00612.html

The patch:
diff --exclude-from=c:\util\tool\diff.ign -u -r
from-cvs/gimp/app/text/gimpfont.c my-gtk/gimp/app/text/gimpfont.c
--- from-cvs/gimp/app/text/gimpfont.c	Tue Apr 01 15:53:44 2003
+++ my-gtk/gimp/app/text/gimpfont.c	Sat May 24 22:00:40 2003
@@ -23,7 +23,12 @@
 #include "config.h"
 
 #include <glib-object.h>
+
+#ifdef USE_PANGO_WIN32
+#include <pango/pangowin32.h>
+#else
 #include <pango/pangoft2.h>
+#endif
 
 #include "text-types.h"
 
@@ -265,7 +270,11 @@
   PangoLayout          *layout;
   PangoRectangle        logical;
   TempBuf              *temp_buf;
+#ifdef USE_PANGO_WIN32
+  PangoBitmap           bitmap;
+#else
   FT_Bitmap             bitmap;
+#endif
   guchar               *p;
   guchar                black = 0;
 
@@ -311,10 +320,18 @@
 
   pango_layout_get_pixel_extents (layout, NULL, &logical);
 
+#ifdef USE_PANGO_WIN32
+  pango_win32_render_layout_to_bitmap (&bitmap,
+                                       layout,
+                                       (bitmap.width - logical.width)  / 2,
+                                       (bitmap.rows  - logical.height) / 2);
+
+#else
   pango_ft2_render_layout (&bitmap,
                            layout,
                            (bitmap.width - logical.width)  / 2,
                            (bitmap.rows  - logical.height) / 2);
+#endif
 
   g_object_unref (layout);
 
diff --exclude-from=c:\util\tool\diff.ign -u -r
from-cvs/gimp/app/text/gimpfontlist.c my-gtk/gimp/app/text/gimpfontlist.c
--- from-cvs/gimp/app/text/gimpfontlist.c	Fri May 02 14:32:20 2003
+++ my-gtk/gimp/app/text/gimpfontlist.c	Sat May 24 23:36:26 2003
@@ -25,7 +25,12 @@
 #include <string.h>
 
 #include <glib-object.h>
+#ifdef USE_PANGO_WIN32
+#include <pango/pangowin32.h>
+#else
 #include <pango/pangoft2.h>
+#define USE_FONTCONFIG_DIRECTLY
+#endif
 
 #include "text-types.h"
 
@@ -38,7 +43,6 @@
 /* Use fontconfig directly for speed. We can use the pango stuff when/if
  * fontconfig/pango get more efficient.
  */
-#define USE_FONTCONFIG_DIRECTLY
 
 #ifdef USE_FONTCONFIG_DIRECTLY
 /* PangoFT2 is assumed, so we should have this in our cflags */
@@ -131,12 +135,17 @@
 
   g_return_if_fail (GIMP_IS_FONT_LIST (list));
 
+#ifdef USE_PANGO_WIN32
+  context = pango_win32_get_context ();
+  fontmap = pango_win32_font_map_for_display ();
+#else
   fontmap = pango_ft2_font_map_new (); 
   pango_ft2_font_map_set_resolution (PANGO_FT2_FONT_MAP (fontmap),
                                      list->xresolution, list->yresolution);
 
   context = pango_ft2_font_map_create_context (PANGO_FT2_FONT_MAP (fontmap));
   g_object_unref (fontmap);
+#endif
 
   gimp_container_freeze (GIMP_CONTAINER (list));
 
diff --exclude-from=c:\util\tool\diff.ign -u -r
from-cvs/gimp/app/text/gimptext-compat.c my-gtk/gimp/app/text/gimptext-compat.c
--- from-cvs/gimp/app/text/gimptext-compat.c	Sat May 24 09:09:34 2003
+++ my-gtk/gimp/app/text/gimptext-compat.c	Sat May 24 21:26:06 2003
@@ -22,7 +22,11 @@
 #include "config.h"
 
 #include <glib-object.h>
+#ifdef USE_PANGO_WIN32
+#include <pango/pangowin32.h>
+#else
 #include <pango/pangoft2.h>
+#endif
 
 #include "libgimpcolor/gimpcolor.h"
 
@@ -146,8 +150,12 @@
   g_return_val_if_fail (fontname != NULL, FALSE);
   g_return_val_if_fail (text != NULL, FALSE);
 
+#ifdef USE_PANGO_WIN32
+  context = pango_win32_get_context ();
+#else
   /* FIXME: resolution */
   context = pango_ft2_get_context (72.0, 72.0);
+#endif
   layout = pango_layout_new (context);
   g_object_unref (context);  
 
diff --exclude-from=c:\util\tool\diff.ign -u -r
from-cvs/gimp/app/text/gimptextlayout.c my-gtk/gimp/app/text/gimptextlayout.c
--- from-cvs/gimp/app/text/gimptextlayout.c	Thu Apr 24 13:39:00 2003
+++ my-gtk/gimp/app/text/gimptextlayout.c	Sat May 24 22:05:00 2003
@@ -22,7 +22,11 @@
 #include "config.h"
 
 #include <glib-object.h>
+#ifdef USE_PANGO_WIN32
+#include <pango/pangowin32.h>
+#else
 #include <pango/pangoft2.h>
+#endif
 
 #include "libgimpbase/gimpbase.h"
 
@@ -267,7 +271,11 @@
                          gint            height)
 {
   TileManager  *mask;
+#ifdef USE_PANGO_WIN32
+  PangoBitmap   bitmap;
+#else
   FT_Bitmap     bitmap;
+#endif
   PixelRegion   maskPR;
   gint          i;
   gint          x, y;
@@ -284,7 +292,11 @@
 
   bitmap.buffer = g_malloc0 (bitmap.rows * bitmap.pitch);
   
+#ifdef USE_PANGO_WIN32
+  pango_win32_render_layout_to_bitmap (&bitmap, layout->layout, x, y);
+#else
   pango_ft2_render_layout (&bitmap, layout->layout, x, y);
+#endif
 
   mask = tile_manager_new (width, height, 1);
   pixel_region_init (&maskPR, mask, 0, 0, width, height, TRUE);
@@ -350,6 +362,7 @@
 }
 
 
+#ifndef USE_PANGO_WIN32
 static void
 gimp_text_ft2_subst_func (FcPattern *pattern,
                           gpointer   data)
@@ -360,6 +373,7 @@
   FcPatternAddBool (pattern, FC_AUTOHINT,  text->autohint);
   FcPatternAddBool (pattern, FC_ANTIALIAS, text->antialias);
 }
+#endif
 
 static PangoContext *
 gimp_text_get_pango_context (GimpText *text,
@@ -367,6 +381,9 @@
                              gdouble   yres)
 {
   PangoContext    *context;
+#ifdef USE_PANGO_WIN32
+  context = pango_win32_get_context ();
+#else
   PangoFT2FontMap *fontmap;
 
   fontmap = PANGO_FT2_FONT_MAP (pango_ft2_font_map_new ());
@@ -380,6 +397,7 @@
 
   context = pango_ft2_font_map_create_context (fontmap);
   g_object_unref (fontmap);
+#endif
 
   if (text->language)
     pango_context_set_language (context,
diff --exclude-from=c:\util\tool\diff.ign -u -r
from-cvs/gimp/app/widgets/gimpfontselection-dialog.c
my-gtk/gimp/app/widgets/gimpfontselection-dialog.c
--- from-cvs/gimp/app/widgets/gimpfontselection-dialog.c	Thu Apr 24
13:39:40 2003
+++ my-gtk/gimp/app/widgets/gimpfontselection-dialog.c	Sat May 24 23:10:10 2003
@@ -27,7 +27,11 @@
 #include <stdlib.h>
 #include <string.h>
 
+#ifdef USE_PANGO_WIN32
+#include <pango/pangowin32.h>
+#else
 #include <pango/pangoft2.h>
+#endif
 
 #include <gtk/gtk.h>
 
@@ -73,7 +77,11 @@
   PangoFontFace        *face;
 
   GtkWidget            *preview;
+#ifdef USE_PANGO_WIN32
+  PangoBitmap           bitmap;
+#else
   FT_Bitmap             bitmap;
+#endif
   PangoLayout          *layout;
 };
 
@@ -686,7 +694,11 @@
       
       memset (dialog->bitmap.buffer, 0,
               dialog->bitmap.rows * dialog->bitmap.pitch);
+#ifdef USE_PANGO_WIN32
+      pango_win32_render_layout_to_bitmap (&dialog->bitmap,
dialog->layout, 2, 2);
+#else
       pango_ft2_render_layout (&dialog->bitmap, dialog->layout, 2, 2);
+#endif
     }
 
   gtk_widget_queue_draw (dialog->preview);
@@ -737,7 +749,11 @@
                                            gpointer       data)
 {
   GimpFontSelectionDialog *dialog = (GimpFontSelectionDialog *) data;
+#ifdef USE_PANGO_WIN32
+  PangoBitmap *bitmap;
+#else
   FT_Bitmap *bitmap;
+#endif
   
   bitmap = &dialog->bitmap;
   if (bitmap->buffer)
diff --exclude-from=c:\util\tool\diff.ign -u -r
from-cvs/gimp/app/widgets/gimpfontselection.c
my-gtk/gimp/app/widgets/gimpfontselection.c
--- from-cvs/gimp/app/widgets/gimpfontselection.c	Thu Apr 24 13:39:42 2003
+++ my-gtk/gimp/app/widgets/gimpfontselection.c	Sat May 24 23:06:44 2003
@@ -28,7 +28,12 @@
 #include <string.h>
 
 #include <gtk/gtk.h>
+
+#ifdef USE_PANGO_WIN32
+#include <pango/pangowin32.h>
+#else
 #include <pango/pangoft2.h>
+#endif
 
 #include "libgimpwidgets/gimpwidgets.h"
 
@@ -375,7 +380,11 @@
   if (default_context)
     return default_context;
 
+#ifdef USE_PANGO_WIN32
+  default_context = pango_win32_get_context ();
+#else
   default_context = pango_ft2_get_context (72.0, 72.0);
+#endif
 
   g_object_add_weak_pointer (G_OBJECT (default_context),
                              (gpointer *) &default_context);
Only in my-gtk/gimp/app/xcf: xcf.def
Only in my-gtk/gimp: config.guess
diff --exclude-from=c:\util\tool\diff.ign -u -r
from-cvs/gimp/config.h.win32 my-gtk/gimp/config.h.win32
--- from-cvs/gimp/config.h.win32	Sun Mar 24 18:11:58 2002
+++ my-gtk/gimp/config.h.win32	Sat May 24 21:58:12 2003
@@ -1,4 +1,6 @@
 /* config.h.win32. Hand-generated */
+#define USE_PANGO_WIN32 1
+
 #define GETTEXT_PACKAGE "gimp14"
 
 /* Define if using alloca.c.  */
Comment 1 Michael Natterer 2003-05-25 13:30:44 UTC
Does PangoWin32 produce the *exactly* same results as PangoFT2?

It is an absolute requirement of the next GIMP release to get
exactly the same font bitmaps rendered on all platforms because
of the new dynamic text layers which have to render the same
on all platforms.

Also, PangoWin32 would have to deliver font outline vectors
the same way as we can get them from FreeType. I doubt this is
the case.

Having deterministic font rendering regardless of the used
platform is a must for the new font stuff to work.

Fontconfig is just as independent from Win32 as it is independent
from X, which is a good thing, because that's exactly what we
need.

I propose closing this bug as WONTFIX.
Comment 2 Sven Neumann 2003-05-25 14:19:20 UTC
Sorry, but I don't think we want to special-case font-handling on
Win32. At some point I want to add full support for affine
transformations and things like that. Doing that in two backends would
be a major pain in the ass. We choose PangoFT2 and fontconfig because
it is not X11 dependant and works on Win32 as well. Tor's download
page already has fontconfig binaries for Win32.
Comment 3 Hans Breuer 2003-05-25 18:26:18 UTC
Flogging Dead Horses :
http://lists.xcf.berkeley.edu/lists/gimp-developer/2003-May/008589.html
Comment 4 Sven Neumann 2003-05-28 00:44:09 UTC
Bug #107668 proposes a nicer API. We should try to develop such an API
and make sure that it fits our needs. Once that abstraction is in
place, GIMP can be converted to use it instead of calling PangoFT2
functions.