mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-08-25 02:36:07 +00:00
Add support for rendering text on pixbufs without alpha channels.
* libnautilus-extensions/nautilus-scalable-font.c: (nautilus_scalable_font_draw_text), (nautilus_scalable_font_draw_text_lines_with_dimensions), (nautilus_scalable_font_draw_text_lines), (initialize_global_stuff_if_needed): Add support for rendering text on pixbufs without alpha channels. * libnautilus-extensions/nautilus-icon-factory.c: (embed_text): No longer need to create a pixbuf with alpha channel duplicate. * test/test-nautilus-font.c: (main): Paint the pixbuf white before drawing stuff to it.
This commit is contained in:
parent
f1d24775e2
commit
2be9f8a68e
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
|||
2000-09-05 Ramiro Estrugo <ramiro@eazel.com>
|
||||
|
||||
* libnautilus-extensions/nautilus-scalable-font.c:
|
||||
(nautilus_scalable_font_draw_text),
|
||||
(nautilus_scalable_font_draw_text_lines_with_dimensions),
|
||||
(nautilus_scalable_font_draw_text_lines),
|
||||
(initialize_global_stuff_if_needed):
|
||||
Add support for rendering text on pixbufs without alpha channels.
|
||||
|
||||
* libnautilus-extensions/nautilus-icon-factory.c: (embed_text):
|
||||
No longer need to create a pixbuf with alpha channel duplicate.
|
||||
|
||||
* test/test-nautilus-font.c: (main):
|
||||
Paint the pixbuf white before drawing stuff to it.
|
||||
|
||||
2000-09-05 Andy Hertzfeld <andy@eazel.com>
|
||||
|
||||
* icons/arlo/sidebar_tab_pieces/Makefile.am:
|
||||
|
|
|
@ -2245,19 +2245,7 @@ embed_text (GdkPixbuf *pixbuf_without_text,
|
|||
*/
|
||||
font = NAUTILUS_SCALABLE_FONT (nautilus_scalable_font_new ("helvetica", "medium", NULL, NULL));
|
||||
|
||||
/* We need to feed NautilusScalableFont a pixbuf with alpha */
|
||||
if (gdk_pixbuf_get_has_alpha (pixbuf_without_text)) {
|
||||
pixbuf_with_text = gdk_pixbuf_copy (pixbuf_without_text);
|
||||
}
|
||||
else {
|
||||
GdkPixbuf *copy_without_alpha;
|
||||
|
||||
copy_without_alpha = gdk_pixbuf_copy (pixbuf_without_text);
|
||||
|
||||
pixbuf_with_text = gdk_pixbuf_add_alpha (copy_without_alpha, FALSE, 0, 0, 0);
|
||||
|
||||
gdk_pixbuf_unref (copy_without_alpha);
|
||||
}
|
||||
pixbuf_with_text = gdk_pixbuf_copy (pixbuf_without_text);
|
||||
|
||||
nautilus_scalable_font_draw_text_lines (font,
|
||||
pixbuf_with_text,
|
||||
|
|
|
@ -706,13 +706,12 @@ nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
|
|||
|
||||
ArtRender *art_render;
|
||||
ArtPixMaxDepth art_color_array[3];
|
||||
|
||||
ArtAlphaType alpha_type;
|
||||
ArtIRect area;
|
||||
ArtIRect glyph_area;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_SCALABLE_FONT (font));
|
||||
g_return_if_fail (destination_pixbuf != NULL);
|
||||
g_return_if_fail (gdk_pixbuf_get_has_alpha (destination_pixbuf));
|
||||
g_return_if_fail (font_width > 0);
|
||||
g_return_if_fail (font_height > 0);
|
||||
|
||||
|
@ -746,6 +745,10 @@ nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
|
|||
glyph_xy[0] = 0;
|
||||
glyph_xy[1] = 0;
|
||||
|
||||
alpha_type = gdk_pixbuf_get_has_alpha (destination_pixbuf) ?
|
||||
ART_ALPHA_SEPARATE :
|
||||
ART_ALPHA_NONE;
|
||||
|
||||
art_render = art_render_new (0,
|
||||
0,
|
||||
pixbuf_width,
|
||||
|
@ -754,7 +757,7 @@ nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
|
|||
pixbuf_rowstride,
|
||||
3,
|
||||
8,
|
||||
ART_ALPHA_SEPARATE,
|
||||
alpha_type,
|
||||
NULL);
|
||||
|
||||
art_color_array[0] = ART_PIX_MAX_FROM_8 (NAUTILUS_RGBA_COLOR_GET_R (color));
|
||||
|
@ -905,7 +908,6 @@ nautilus_scalable_font_draw_text_lines_with_dimensions (const NautilusScalableFo
|
|||
|
||||
g_return_if_fail (NAUTILUS_IS_SCALABLE_FONT (font));
|
||||
g_return_if_fail (destination_pixbuf != NULL);
|
||||
g_return_if_fail (gdk_pixbuf_get_has_alpha (destination_pixbuf));
|
||||
g_return_if_fail (clip_area != NULL);
|
||||
g_return_if_fail (font_width > 0);
|
||||
g_return_if_fail (font_height > 0);
|
||||
|
@ -1022,7 +1024,6 @@ nautilus_scalable_font_draw_text_lines (const NautilusScalableFont *font,
|
|||
|
||||
g_return_if_fail (NAUTILUS_IS_SCALABLE_FONT (font));
|
||||
g_return_if_fail (destination_pixbuf != NULL);
|
||||
g_return_if_fail (gdk_pixbuf_get_has_alpha (destination_pixbuf));
|
||||
g_return_if_fail (clip_area != NULL);
|
||||
g_return_if_fail (font_width > 0);
|
||||
g_return_if_fail (font_height > 0);
|
||||
|
@ -1308,6 +1309,7 @@ initialize_global_stuff_if_needed (void)
|
|||
if (fonts_initialized == FALSE) {
|
||||
fonts_initialized = TRUE;
|
||||
global_font_family_table = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
|
||||
font_family_table_add_fonts (global_font_family_table, "/usr/share/fonts/default/Type1");
|
||||
|
||||
g_atexit (font_family_table_at_exit_destructor);
|
||||
|
|
|
@ -2245,19 +2245,7 @@ embed_text (GdkPixbuf *pixbuf_without_text,
|
|||
*/
|
||||
font = NAUTILUS_SCALABLE_FONT (nautilus_scalable_font_new ("helvetica", "medium", NULL, NULL));
|
||||
|
||||
/* We need to feed NautilusScalableFont a pixbuf with alpha */
|
||||
if (gdk_pixbuf_get_has_alpha (pixbuf_without_text)) {
|
||||
pixbuf_with_text = gdk_pixbuf_copy (pixbuf_without_text);
|
||||
}
|
||||
else {
|
||||
GdkPixbuf *copy_without_alpha;
|
||||
|
||||
copy_without_alpha = gdk_pixbuf_copy (pixbuf_without_text);
|
||||
|
||||
pixbuf_with_text = gdk_pixbuf_add_alpha (copy_without_alpha, FALSE, 0, 0, 0);
|
||||
|
||||
gdk_pixbuf_unref (copy_without_alpha);
|
||||
}
|
||||
pixbuf_with_text = gdk_pixbuf_copy (pixbuf_without_text);
|
||||
|
||||
nautilus_scalable_font_draw_text_lines (font,
|
||||
pixbuf_with_text,
|
||||
|
|
|
@ -706,13 +706,12 @@ nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
|
|||
|
||||
ArtRender *art_render;
|
||||
ArtPixMaxDepth art_color_array[3];
|
||||
|
||||
ArtAlphaType alpha_type;
|
||||
ArtIRect area;
|
||||
ArtIRect glyph_area;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_SCALABLE_FONT (font));
|
||||
g_return_if_fail (destination_pixbuf != NULL);
|
||||
g_return_if_fail (gdk_pixbuf_get_has_alpha (destination_pixbuf));
|
||||
g_return_if_fail (font_width > 0);
|
||||
g_return_if_fail (font_height > 0);
|
||||
|
||||
|
@ -746,6 +745,10 @@ nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
|
|||
glyph_xy[0] = 0;
|
||||
glyph_xy[1] = 0;
|
||||
|
||||
alpha_type = gdk_pixbuf_get_has_alpha (destination_pixbuf) ?
|
||||
ART_ALPHA_SEPARATE :
|
||||
ART_ALPHA_NONE;
|
||||
|
||||
art_render = art_render_new (0,
|
||||
0,
|
||||
pixbuf_width,
|
||||
|
@ -754,7 +757,7 @@ nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
|
|||
pixbuf_rowstride,
|
||||
3,
|
||||
8,
|
||||
ART_ALPHA_SEPARATE,
|
||||
alpha_type,
|
||||
NULL);
|
||||
|
||||
art_color_array[0] = ART_PIX_MAX_FROM_8 (NAUTILUS_RGBA_COLOR_GET_R (color));
|
||||
|
@ -905,7 +908,6 @@ nautilus_scalable_font_draw_text_lines_with_dimensions (const NautilusScalableFo
|
|||
|
||||
g_return_if_fail (NAUTILUS_IS_SCALABLE_FONT (font));
|
||||
g_return_if_fail (destination_pixbuf != NULL);
|
||||
g_return_if_fail (gdk_pixbuf_get_has_alpha (destination_pixbuf));
|
||||
g_return_if_fail (clip_area != NULL);
|
||||
g_return_if_fail (font_width > 0);
|
||||
g_return_if_fail (font_height > 0);
|
||||
|
@ -1022,7 +1024,6 @@ nautilus_scalable_font_draw_text_lines (const NautilusScalableFont *font,
|
|||
|
||||
g_return_if_fail (NAUTILUS_IS_SCALABLE_FONT (font));
|
||||
g_return_if_fail (destination_pixbuf != NULL);
|
||||
g_return_if_fail (gdk_pixbuf_get_has_alpha (destination_pixbuf));
|
||||
g_return_if_fail (clip_area != NULL);
|
||||
g_return_if_fail (font_width > 0);
|
||||
g_return_if_fail (font_height > 0);
|
||||
|
@ -1308,6 +1309,7 @@ initialize_global_stuff_if_needed (void)
|
|||
if (fonts_initialized == FALSE) {
|
||||
fonts_initialized = TRUE;
|
||||
global_font_family_table = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
|
||||
font_family_table_add_fonts (global_font_family_table, "/usr/share/fonts/default/Type1");
|
||||
|
||||
g_atexit (font_family_table_at_exit_destructor);
|
||||
|
|
|
@ -46,6 +46,8 @@ main (int argc, char* argv[])
|
|||
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, pixbuf_width, pixbuf_height);
|
||||
g_assert (pixbuf != NULL);
|
||||
|
||||
nautilus_gdk_pixbuf_fill_rectangle_with_color (pixbuf, NULL, NAUTILUS_RGBA_COLOR_PACK (255, 255, 255, 0));
|
||||
|
||||
/* Measure some text lines */
|
||||
{
|
||||
guint num_text_lines;
|
||||
|
|
Loading…
Reference in a new issue