gimp r27489 - in trunk: . app/text
- From: neo svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r27489 - in trunk: . app/text
- Date: Fri, 31 Oct 2008 07:24:11 +0000 (UTC)
Author: neo
Date: Fri Oct 31 07:24:11 2008
New Revision: 27489
URL: http://svn.gnome.org/viewvc/gimp?rev=27489&view=rev
Log:
2008-10-31 Sven Neumann <sven gimp org>
* app/text/gimpfont.c
* app/text/gimpfontlist.c: render font previews using
PangoCairo.
Modified:
trunk/ChangeLog
trunk/app/text/gimpfont.c
trunk/app/text/gimpfontlist.c
Modified: trunk/app/text/gimpfont.c
==============================================================================
--- trunk/app/text/gimpfont.c (original)
+++ trunk/app/text/gimpfont.c Fri Oct 31 07:24:11 2008
@@ -24,8 +24,7 @@
#include <glib-object.h>
-#define PANGO_ENABLE_BACKEND 1 /* Argh */
-#include <pango/pangoft2.h>
+#include <pango/pangocairo.h>
#define PANGO_ENABLE_ENGINE 1 /* Argh */
#include <pango/pango-ot.h>
@@ -223,6 +222,8 @@
*popup_width = MAX (ink.width, logical.width) + 6;
*popup_height = MAX (ink.height, logical.height) + 6;
+ *popup_width = cairo_format_stride_for_width (CAIRO_FORMAT_A8, *popup_width);
+
font->popup_width = *popup_width;
font->popup_height = *popup_height;
@@ -235,18 +236,18 @@
gint width,
gint height)
{
- GimpFont *font = GIMP_FONT (viewable);
- PangoLayout *layout;
- PangoRectangle ink;
- PangoRectangle logical;
- gint layout_width;
- gint layout_height;
- gint layout_x;
- gint layout_y;
- TempBuf *temp_buf;
- FT_Bitmap bitmap;
- guchar *p;
- guchar black = 0;
+ GimpFont *font = GIMP_FONT (viewable);
+ PangoLayout *layout;
+ PangoRectangle ink;
+ PangoRectangle logical;
+ gint layout_width;
+ gint layout_height;
+ gint layout_x;
+ gint layout_y;
+ TempBuf *temp_buf;
+ cairo_t *cr;
+ cairo_surface_t *surface;
+ guchar white = 255;
if (! font->pango_context)
return NULL;
@@ -282,20 +283,21 @@
layout = g_object_ref (font->popup_layout);
}
- temp_buf = temp_buf_new (width, height, 1, 0, 0, &black);
+ width = cairo_format_stride_for_width (CAIRO_FORMAT_A8, width);
+
+ temp_buf = temp_buf_new (width, height, 1, 0, 0, &white);
- bitmap.width = temp_buf->width;
- bitmap.rows = temp_buf->height;
- bitmap.pitch = temp_buf->width;
- bitmap.buffer = temp_buf_data (temp_buf);
+ surface = cairo_image_surface_create_for_data (temp_buf_data (temp_buf),
+ CAIRO_FORMAT_A8,
+ width, height, width);
pango_layout_get_pixel_extents (layout, &ink, &logical);
layout_width = MAX (ink.width, logical.width);
layout_height = MAX (ink.height, logical.height);
- layout_x = (bitmap.width - layout_width) / 2;
- layout_y = (bitmap.rows - layout_height) / 2;
+ layout_x = (width - layout_width) / 2;
+ layout_y = (height - layout_height) / 2;
if (ink.x < logical.x)
layout_x += logical.x - ink.x;
@@ -303,15 +305,16 @@
if (ink.y < logical.y)
layout_y += logical.y - ink.y;
- pango_ft2_render_layout (&bitmap, layout, layout_x, layout_y);
+ cr = cairo_create (surface);
- g_object_unref (layout);
+ cairo_translate (cr, layout_x, layout_y);
+ cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
+ pango_cairo_show_layout (cr, layout);
- p = temp_buf_data (temp_buf);
+ cairo_destroy (cr);
+ cairo_surface_destroy (surface);
- for (height = temp_buf->height; height; height--)
- for (width = temp_buf->width; width; width--, p++)
- *p = 255 - *p;
+ g_object_unref (layout);
return temp_buf;
}
Modified: trunk/app/text/gimpfontlist.c
==============================================================================
--- trunk/app/text/gimpfontlist.c (original)
+++ trunk/app/text/gimpfontlist.c Fri Oct 31 07:24:11 2008
@@ -26,7 +26,7 @@
#include <string.h>
#include <glib-object.h>
-#include <pango/pangoft2.h>
+#include <pango/pangocairo.h>
#include <pango/pangofc-fontmap.h>
#include "text-types.h"
@@ -44,7 +44,6 @@
#define USE_FONTCONFIG_DIRECTLY
#ifdef USE_FONTCONFIG_DIRECTLY
-/* PangoFT2 is assumed, so we should have this in our cflags */
#include <fontconfig/fontconfig.h>
#endif
@@ -99,8 +98,8 @@
void
gimp_font_list_restore (GimpFontList *list)
{
- PangoFontMap *fontmap;
- PangoContext *context;
+ PangoCairoFontMap *fontmap;
+ PangoContext *context;
g_return_if_fail (GIMP_IS_FONT_LIST (list));
@@ -125,16 +124,14 @@
font_desc_to_string = &pango_font_description_to_string;
}
- 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));
+ fontmap = PANGO_CAIRO_FONT_MAP (pango_cairo_font_map_new ());
+ pango_cairo_font_map_set_resolution (fontmap, list->yresolution);
+ context = pango_cairo_font_map_create_context (fontmap);
g_object_unref (fontmap);
gimp_container_freeze (GIMP_CONTAINER (list));
- gimp_font_list_load_names (list, fontmap, context);
+ gimp_font_list_load_names (list, PANGO_FONT_MAP (fontmap), context);
g_object_unref (context);
gimp_list_sort_by_name (GIMP_LIST (list));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]