summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Hertzfeld <andy@src.gnome.org>2000-08-05 19:53:18 +0000
committerAndy Hertzfeld <andy@src.gnome.org>2000-08-05 19:53:18 +0000
commit64e7b04f00af2c4e68f231531efba6d9f6980a1c (patch)
tree0bbff5c058819cf493b5192606b6b19e423c278e
parentcb36670cefe21c96ef82f5d8c5ab9160daaf862b (diff)
downloadnautilus-64e7b04f00af2c4e68f231531efba6d9f6980a1c.tar.gz
fixed embedded icon text clarity (we were using helvetica 9, which wasn't
fixed embedded icon text clarity (we were using helvetica 9, which wasn't installed on many machines, and the scaled version looked hideous). Fixed by using the bigger, more commonly installed helvetica 24 font, then scaling it down using the gdk_pixbuf compositing routines, which exploit the gray-scale.
-rw-r--r--ChangeLog20
-rw-r--r--libnautilus-extensions/nautilus-gdk-pixbuf-extensions.c20
-rw-r--r--libnautilus-extensions/nautilus-gdk-pixbuf-extensions.h1
-rw-r--r--libnautilus-extensions/nautilus-icon-factory.c7
-rw-r--r--libnautilus-extensions/nautilus-image.c1
-rw-r--r--libnautilus-private/nautilus-gdk-pixbuf-extensions.c20
-rw-r--r--libnautilus-private/nautilus-gdk-pixbuf-extensions.h1
-rw-r--r--libnautilus-private/nautilus-icon-factory.c7
-rw-r--r--libnautilus-private/nautilus-image.c1
9 files changed, 58 insertions, 20 deletions
diff --git a/ChangeLog b/ChangeLog
index b42ee3d79..5bc890854 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2000-08-05 Andy Hertzfeld <andy@eazel.com>
+
+ fixed embedded icon text clarity (we were using helvetica 9, which wasn't installed
+ on many machines, and the scaled version looked hideous). Fixed by using the
+ bigger, more commonly installed helvetica 24 font, then scaling it down using the
+ gdk_pixbuf compositing routines, which exploit the gray-scale.
+
+ * libnautilus-extensions/nautilus-gdk-pixbuf-extensions.h:
+ added a "font_scale" parameter
+ * libnautilus-extensions/nautilus-gdk-pixbuf-extensions.c:
+ (nautilus_gdk_pixbuf_draw_text):
+ used the font scale parameter to scale up the buffer, and scale it down when
+ compositing
+ * libnautilus-extensions/nautilus-icon-factory.c: (embed_text):
+ change the default size to 24 pt, and used a scale factor of .333 for the
+ equivalent of an 8 point font
+ * libnautilus-extensions/nautilus-image.c:
+ (nautilus_image_size_allocate):
+ added a font scale parameter of 1.0.
+
2000-08-05 Gene Z. Ragan <gzr@eazel.com>
* libnautilus-extensions/nautilus-undo-manager.c: (corba_append),
diff --git a/libnautilus-extensions/nautilus-gdk-pixbuf-extensions.c b/libnautilus-extensions/nautilus-gdk-pixbuf-extensions.c
index 13ae46520..f751b4d74 100644
--- a/libnautilus-extensions/nautilus-gdk-pixbuf-extensions.c
+++ b/libnautilus-extensions/nautilus-gdk-pixbuf-extensions.c
@@ -423,12 +423,14 @@ nautilus_gdk_pixbuf_scale_to_fit (GdkPixbuf *pixbuf, int max_width, int max_heig
void
nautilus_gdk_pixbuf_draw_text (GdkPixbuf *pixbuf,
const GdkFont *font,
+ const double font_scale,
const ArtIRect *destination_rect,
const char *text,
guint overall_alpha)
{
ArtIRect pixbuf_rect;
ArtIRect text_rect;
+ int dest_width, dest_height;
int width, height;
GdkVisual *visual;
GdkPixmap *pixmap;
@@ -441,7 +443,7 @@ nautilus_gdk_pixbuf_draw_text (GdkPixbuf *pixbuf,
GdkPixbuf *text_pixbuf;
GdkPixbuf *text_pixbuf_with_alpha;
guchar *pixels;
-
+
g_return_if_fail (pixbuf != NULL);
g_return_if_fail (font != NULL);
g_return_if_fail (destination_rect != NULL);
@@ -465,8 +467,11 @@ nautilus_gdk_pixbuf_draw_text (GdkPixbuf *pixbuf,
visual = gdk_visual_get_system ();
/* Allocate a GdkPixmap of the appropriate size. */
- width = text_rect.x1 - text_rect.x0;
- height = text_rect.y1 - text_rect.y0;
+ dest_width = text_rect.x1 - text_rect.x0;
+ dest_height = text_rect.y1 - text_rect.y0;
+ width = dest_width / font_scale;
+ height = dest_height / font_scale;
+
pixmap = gdk_pixmap_new (NULL, width, height, visual->depth);
gc = gdk_gc_new (pixmap);
@@ -519,22 +524,23 @@ nautilus_gdk_pixbuf_draw_text (GdkPixbuf *pixbuf,
0, 0, width, height);
gdk_colormap_unref (colormap);
gdk_pixmap_unref (pixmap);
-
+
/* White is not always FF FF FF. So we get the top left corner pixel. */
pixels = gdk_pixbuf_get_pixels (text_pixbuf);
text_pixbuf_with_alpha = gdk_pixbuf_add_alpha
(text_pixbuf,
TRUE, pixels[0], pixels[1], pixels[2]);
gdk_pixbuf_unref (text_pixbuf);
-
+
+ /* composite using scale factor */
gdk_pixbuf_composite (text_pixbuf_with_alpha,
pixbuf,
text_rect.x0,
text_rect.y0,
- width, height,
+ dest_width, dest_height,
text_rect.x0,
text_rect.y0,
- 1, 1,
+ font_scale, font_scale,
GDK_INTERP_BILINEAR,
overall_alpha);
diff --git a/libnautilus-extensions/nautilus-gdk-pixbuf-extensions.h b/libnautilus-extensions/nautilus-gdk-pixbuf-extensions.h
index da80055a7..e37e4104a 100644
--- a/libnautilus-extensions/nautilus-gdk-pixbuf-extensions.h
+++ b/libnautilus-extensions/nautilus-gdk-pixbuf-extensions.h
@@ -70,6 +70,7 @@ void nautilus_gdk_pixbuf_average_value (GdkPixbu
/* Draw text onto a GdkPixbuf using the given font and rect */
void nautilus_gdk_pixbuf_draw_text (GdkPixbuf *pixbuf,
const GdkFont *font,
+ const double font_scale,
const ArtIRect *destination_rect,
const char *text,
guint overall_alpha);
diff --git a/libnautilus-extensions/nautilus-icon-factory.c b/libnautilus-extensions/nautilus-icon-factory.c
index ba8cb225e..1f556170e 100644
--- a/libnautilus-extensions/nautilus-icon-factory.c
+++ b/libnautilus-extensions/nautilus-icon-factory.c
@@ -2209,7 +2209,9 @@ embed_text (GdkPixbuf *pixbuf_without_text,
/* FIXME bugzilla.eazel.com 1102: Embedded text should use preferences to determine
* the font it uses
*/
- font = gdk_font_load ("-*-helvetica-medium-r-normal-*-9-*-*-*-*-*-*-*");
+
+ /* for anti-aliased text, we choose a large font and scale it down */
+ font = gdk_font_load ("-*-helvetica-medium-r-normal-*-24-*-*-*-*-*-*-*");
g_return_val_if_fail (font != NULL, gdk_pixbuf_ref (pixbuf_without_text));
}
@@ -2222,8 +2224,7 @@ embed_text (GdkPixbuf *pixbuf_without_text,
pixbuf_with_text = gdk_pixbuf_copy (pixbuf_without_text);
- nautilus_gdk_pixbuf_draw_text (pixbuf_with_text, font, embedded_text_rect, text, 0xFF);
-
+ nautilus_gdk_pixbuf_draw_text (pixbuf_with_text, font, .3333, embedded_text_rect, text, 0xFF);
return pixbuf_with_text;
}
diff --git a/libnautilus-extensions/nautilus-image.c b/libnautilus-extensions/nautilus-image.c
index f47194d17..209cbbbd5 100644
--- a/libnautilus-extensions/nautilus-image.c
+++ b/libnautilus-extensions/nautilus-image.c
@@ -603,6 +603,7 @@ nautilus_image_size_allocate (GtkWidget *widget, GtkAllocation* allocation)
*/
nautilus_gdk_pixbuf_draw_text (image->detail->buffer,
image->detail->label_font,
+ 1.0,
&text_rect,
image->detail->label_text,
image->detail->overall_alpha);
diff --git a/libnautilus-private/nautilus-gdk-pixbuf-extensions.c b/libnautilus-private/nautilus-gdk-pixbuf-extensions.c
index 13ae46520..f751b4d74 100644
--- a/libnautilus-private/nautilus-gdk-pixbuf-extensions.c
+++ b/libnautilus-private/nautilus-gdk-pixbuf-extensions.c
@@ -423,12 +423,14 @@ nautilus_gdk_pixbuf_scale_to_fit (GdkPixbuf *pixbuf, int max_width, int max_heig
void
nautilus_gdk_pixbuf_draw_text (GdkPixbuf *pixbuf,
const GdkFont *font,
+ const double font_scale,
const ArtIRect *destination_rect,
const char *text,
guint overall_alpha)
{
ArtIRect pixbuf_rect;
ArtIRect text_rect;
+ int dest_width, dest_height;
int width, height;
GdkVisual *visual;
GdkPixmap *pixmap;
@@ -441,7 +443,7 @@ nautilus_gdk_pixbuf_draw_text (GdkPixbuf *pixbuf,
GdkPixbuf *text_pixbuf;
GdkPixbuf *text_pixbuf_with_alpha;
guchar *pixels;
-
+
g_return_if_fail (pixbuf != NULL);
g_return_if_fail (font != NULL);
g_return_if_fail (destination_rect != NULL);
@@ -465,8 +467,11 @@ nautilus_gdk_pixbuf_draw_text (GdkPixbuf *pixbuf,
visual = gdk_visual_get_system ();
/* Allocate a GdkPixmap of the appropriate size. */
- width = text_rect.x1 - text_rect.x0;
- height = text_rect.y1 - text_rect.y0;
+ dest_width = text_rect.x1 - text_rect.x0;
+ dest_height = text_rect.y1 - text_rect.y0;
+ width = dest_width / font_scale;
+ height = dest_height / font_scale;
+
pixmap = gdk_pixmap_new (NULL, width, height, visual->depth);
gc = gdk_gc_new (pixmap);
@@ -519,22 +524,23 @@ nautilus_gdk_pixbuf_draw_text (GdkPixbuf *pixbuf,
0, 0, width, height);
gdk_colormap_unref (colormap);
gdk_pixmap_unref (pixmap);
-
+
/* White is not always FF FF FF. So we get the top left corner pixel. */
pixels = gdk_pixbuf_get_pixels (text_pixbuf);
text_pixbuf_with_alpha = gdk_pixbuf_add_alpha
(text_pixbuf,
TRUE, pixels[0], pixels[1], pixels[2]);
gdk_pixbuf_unref (text_pixbuf);
-
+
+ /* composite using scale factor */
gdk_pixbuf_composite (text_pixbuf_with_alpha,
pixbuf,
text_rect.x0,
text_rect.y0,
- width, height,
+ dest_width, dest_height,
text_rect.x0,
text_rect.y0,
- 1, 1,
+ font_scale, font_scale,
GDK_INTERP_BILINEAR,
overall_alpha);
diff --git a/libnautilus-private/nautilus-gdk-pixbuf-extensions.h b/libnautilus-private/nautilus-gdk-pixbuf-extensions.h
index da80055a7..e37e4104a 100644
--- a/libnautilus-private/nautilus-gdk-pixbuf-extensions.h
+++ b/libnautilus-private/nautilus-gdk-pixbuf-extensions.h
@@ -70,6 +70,7 @@ void nautilus_gdk_pixbuf_average_value (GdkPixbu
/* Draw text onto a GdkPixbuf using the given font and rect */
void nautilus_gdk_pixbuf_draw_text (GdkPixbuf *pixbuf,
const GdkFont *font,
+ const double font_scale,
const ArtIRect *destination_rect,
const char *text,
guint overall_alpha);
diff --git a/libnautilus-private/nautilus-icon-factory.c b/libnautilus-private/nautilus-icon-factory.c
index ba8cb225e..1f556170e 100644
--- a/libnautilus-private/nautilus-icon-factory.c
+++ b/libnautilus-private/nautilus-icon-factory.c
@@ -2209,7 +2209,9 @@ embed_text (GdkPixbuf *pixbuf_without_text,
/* FIXME bugzilla.eazel.com 1102: Embedded text should use preferences to determine
* the font it uses
*/
- font = gdk_font_load ("-*-helvetica-medium-r-normal-*-9-*-*-*-*-*-*-*");
+
+ /* for anti-aliased text, we choose a large font and scale it down */
+ font = gdk_font_load ("-*-helvetica-medium-r-normal-*-24-*-*-*-*-*-*-*");
g_return_val_if_fail (font != NULL, gdk_pixbuf_ref (pixbuf_without_text));
}
@@ -2222,8 +2224,7 @@ embed_text (GdkPixbuf *pixbuf_without_text,
pixbuf_with_text = gdk_pixbuf_copy (pixbuf_without_text);
- nautilus_gdk_pixbuf_draw_text (pixbuf_with_text, font, embedded_text_rect, text, 0xFF);
-
+ nautilus_gdk_pixbuf_draw_text (pixbuf_with_text, font, .3333, embedded_text_rect, text, 0xFF);
return pixbuf_with_text;
}
diff --git a/libnautilus-private/nautilus-image.c b/libnautilus-private/nautilus-image.c
index f47194d17..209cbbbd5 100644
--- a/libnautilus-private/nautilus-image.c
+++ b/libnautilus-private/nautilus-image.c
@@ -603,6 +603,7 @@ nautilus_image_size_allocate (GtkWidget *widget, GtkAllocation* allocation)
*/
nautilus_gdk_pixbuf_draw_text (image->detail->buffer,
image->detail->label_font,
+ 1.0,
&text_rect,
image->detail->label_text,
image->detail->overall_alpha);