Commit faf90e22 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

app/text/gimptextlayer.c render an empty layer for an empty text layout.

2003-02-07  Sven Neumann  <sven@gimp.org>

	* app/text/gimptextlayer.c
	* app/text/gimptextlayout.[ch]: render an empty layer for an empty
	text layout.
parent 6d827d98
2003-02-07 Sven Neumann <sven@gimp.org>
* app/text/gimptextlayer.c
* app/text/gimptextlayout.[ch]: render an empty layer for an empty
text layout.
2003-02-06 Sven Neumann <sven@gimp.org>
 
* libgimp/gimpui.c
......
......@@ -155,7 +155,7 @@ gimp_text_layer_new (GimpImage *image,
layer->text = g_object_ref (text);
if (!gimp_text_layer_render (layer))
if (! gimp_text_layer_render (layer))
{
g_object_unref (layer);
return NULL;
......@@ -208,7 +208,7 @@ static void
gimp_text_layer_notify_text (GimpTextLayer *layer)
{
if (layer->idle_render_id)
return;
g_source_remove (layer->idle_render_id);
layer->idle_render_id =
g_idle_add_full (G_PRIORITY_LOW,
......@@ -235,38 +235,33 @@ gimp_text_layer_render (GimpTextLayer *layer)
gint width;
gint height;
image = gimp_item_get_image (GIMP_ITEM (layer));
image = gimp_item_get_image (GIMP_ITEM (layer));
drawable = GIMP_DRAWABLE (layer);
layout = gimp_text_layout_new (layer->text, image);
gimp_text_layout_get_size (layout, &width, &height);
if (! gimp_text_layout_get_size (layout, &width, &height))
if (gimp_text_layout_get_size (layout, &width, &height))
{
g_object_unref (layout);
return FALSE;
}
drawable = GIMP_DRAWABLE (layer);
if (width != gimp_drawable_width (drawable) ||
height != gimp_drawable_height (drawable))
{
gimp_drawable_update (GIMP_DRAWABLE (layer),
0, 0,
gimp_drawable_width (drawable),
gimp_drawable_height (drawable));
drawable->width = width;
drawable->height = height;
if (drawable->tiles)
tile_manager_destroy (drawable->tiles);
drawable->tiles = tile_manager_new (width, height, drawable->bytes);
gimp_viewable_size_changed (GIMP_VIEWABLE (layer));
if (width != gimp_drawable_width (drawable) ||
height != gimp_drawable_height (drawable))
{
gimp_drawable_update (drawable,
0, 0,
gimp_drawable_width (drawable),
gimp_drawable_height (drawable));
drawable->width = width;
drawable->height = height;
if (drawable->tiles)
tile_manager_destroy (drawable->tiles);
drawable->tiles = tile_manager_new (width, height, drawable->bytes);
gimp_viewable_size_changed (GIMP_VIEWABLE (layer));
}
}
gimp_object_set_name_safe (GIMP_OBJECT (layer), layer->text->text);
......@@ -274,10 +269,9 @@ gimp_text_layer_render (GimpTextLayer *layer)
gimp_text_layer_render_layout (layer, layout);
g_object_unref (layout);
gimp_drawable_update (drawable, 0, 0, width, height);
gimp_image_flush (image);
return TRUE;
return (width > 0 && height > 0);
}
static void
......@@ -296,14 +290,14 @@ gimp_text_layer_render_layout (GimpTextLayer *layer,
width = gimp_drawable_width (drawable);
height = gimp_drawable_height (drawable);
mask = gimp_text_layout_render (layout);
mask = gimp_text_layout_render (layout, width, height);
pixel_region_init (&textPR,
GIMP_DRAWABLE (layer)->tiles, 0, 0, width, height, TRUE);
pixel_region_init (&maskPR,
mask, 0, 0, width, height, FALSE);
pixel_region_init (&textPR, drawable->tiles, 0, 0, width, height, TRUE);
pixel_region_init (&maskPR, mask, 0, 0, width, height, FALSE);
apply_mask_to_region (&textPR, &maskPR, OPAQUE_OPACITY);
tile_manager_destroy (mask);
gimp_drawable_update (drawable, 0, 0, width, height);
}
......@@ -250,18 +250,18 @@ gimp_text_layout_get_offsets (GimpTextLayout *layout,
}
TileManager *
gimp_text_layout_render (GimpTextLayout *layout)
gimp_text_layout_render (GimpTextLayout *layout,
gint width,
gint height)
{
TileManager *mask;
FT_Bitmap bitmap;
PixelRegion maskPR;
gint i;
gint x, y;
gint width, height;
g_return_val_if_fail (GIMP_IS_TEXT_LAYOUT (layout), NULL);
gimp_text_layout_get_size (layout, &width, &height);
gimp_text_layout_get_offsets (layout, &x, &y);
bitmap.width = width;
......@@ -271,7 +271,7 @@ gimp_text_layout_render (GimpTextLayout *layout)
bitmap.pitch += 4 - (bitmap.pitch & 3);
bitmap.buffer = g_malloc0 (bitmap.rows * bitmap.pitch);
pango_ft2_render_layout (&bitmap, layout->layout, x, y);
mask = tile_manager_new (width, height, 1);
......
......@@ -41,7 +41,9 @@ gboolean gimp_text_layout_get_size (GimpTextLayout *layout,
void gimp_text_layout_get_offsets (GimpTextLayout *layout,
gint *x,
gint *y);
TileManager * gimp_text_layout_render (GimpTextLayout *layout);
TileManager * gimp_text_layout_render (GimpTextLayout *layout,
gint width,
gint height);
#endif /* __GIMP_TEXT_LAYOUT_H__ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment