Add support for drawint inverted text. Also cleanup the rendering function

* libnautilus-extensions/nautilus-scalable-font.c:
	(nautilus_scalable_font_measure_text), (invert_glyph),
	(nautilus_scalable_font_draw_text),
	(nautilus_scalable_font_draw_text_lines_with_dimensions),
	(nautilus_scalable_font_draw_text_lines),
	(nautilus_text_layout_paint):
	* libnautilus-extensions/nautilus-scalable-font.h:
	Add support for drawint inverted text.  Also cleanup the rendering
	function a bit.

	* libnautilus-extensions/nautilus-icon-factory.c: (embed_text):
	* libnautilus-extensions/nautilus-label.c: (render_buffer_pixbuf):
	* src/nautilus-about.c: (draw_aa_string):
	* src/nautilus-sidebar-tabs.c: (draw_one_tab_plain),
	(draw_one_tab_themed):
	Update all these for the new inverted scalable font api.

	* test/test-nautilus-font.c: (main):
	Add a inverted text test.
This commit is contained in:
Ramiro Estrugo 2000-09-07 11:11:14 +00:00
parent 0b47962ead
commit 897a33ffe9
12 changed files with 387 additions and 162 deletions

View file

@ -1,3 +1,25 @@
2000-09-07 Ramiro Estrugo <ramiro@eazel.com>
* libnautilus-extensions/nautilus-scalable-font.c:
(nautilus_scalable_font_measure_text), (invert_glyph),
(nautilus_scalable_font_draw_text),
(nautilus_scalable_font_draw_text_lines_with_dimensions),
(nautilus_scalable_font_draw_text_lines),
(nautilus_text_layout_paint):
* libnautilus-extensions/nautilus-scalable-font.h:
Add support for drawint inverted text. Also cleanup the rendering
function a bit.
* libnautilus-extensions/nautilus-icon-factory.c: (embed_text):
* libnautilus-extensions/nautilus-label.c: (render_buffer_pixbuf):
* src/nautilus-about.c: (draw_aa_string):
* src/nautilus-sidebar-tabs.c: (draw_one_tab_plain),
(draw_one_tab_themed):
Update all these for the new inverted scalable font api.
* test/test-nautilus-font.c: (main):
Add a inverted text test.
2000-09-07 Eskil Heyn Olsen <eskil@eazel.com>
* nautilus-installer/src/Makefile:

View file

@ -2261,7 +2261,8 @@ embed_text (GdkPixbuf *pixbuf_without_text,
line_offset,
empty_line_height,
NAUTILUS_RGB_COLOR_BLACK,
255);
255,
FALSE);
gtk_object_unref (GTK_OBJECT (font));

View file

@ -363,7 +363,8 @@ render_buffer_pixbuf (NautilusBufferedWidget *buffered_widget,
label->detail->line_offset,
label_get_empty_line_height (label),
label->detail->drop_shadow_color,
label->detail->text_alpha);
label->detail->text_alpha,
FALSE);
text_x -= label->detail->drop_shadow_offset;
text_y -= label->detail->drop_shadow_offset;
@ -384,7 +385,8 @@ render_buffer_pixbuf (NautilusBufferedWidget *buffered_widget,
label->detail->line_offset,
label_get_empty_line_height (label),
label->detail->text_color,
label->detail->text_alpha);
label->detail->text_alpha,
FALSE);
}
}

View file

@ -644,6 +644,7 @@ nautilus_scalable_font_measure_text (const NautilusScalableFont *font,
font_height,
affine,
glyph_xy);
g_assert (glyph != NULL);
*text_width_out = glyph->width;
*text_height_out = glyph->height;
@ -682,6 +683,40 @@ nautilus_scalable_font_text_width (const NautilusScalableFont *font,
return text_width;
}
/* Lifted from Raph's test-ft-gtk.c sample program */
static void
invert_glyph (guchar *buf, int rowstride, int width, int height)
{
int x, y;
int first;
int n_words;
int last;
guint32 *middle;
if (width >= 8 && ((rowstride & 3) == 0)) {
first = (-(int)buf) & 3;
n_words = (width - first) >> 2;
last = first + (n_words << 2);
for (y = 0; y < height; y++) {
middle = (guint32 *)(buf + first);
for (x = 0; x < first; x++)
buf[x] = ~buf[x];
for (x = 0; x < n_words; x++)
middle[x] = ~middle[x];
for (x = last; x < width; x++)
buf[x] = ~buf[x];
buf += rowstride;
}
} else {
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++)
buf[x] = ~buf[x];
buf += rowstride;
}
}
}
void
nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
GdkPixbuf *destination_pixbuf,
@ -693,21 +728,13 @@ nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
const char *text,
guint text_length,
guint32 color,
guchar overall_alpha)
guchar overall_alpha,
gboolean inverted)
{
RsvgFTGlyph *glyph;
double affine[6];
int glyph_xy[2];
guint pixbuf_width;
guint pixbuf_height;
guint pixbuf_rowstride;
guchar *pixbuf_pixels;
ArtRender *art_render;
ArtPixMaxDepth art_color_array[3];
ArtAlphaType alpha_type;
ArtIRect area;
ArtIRect render_area;
ArtIRect glyph_area;
g_return_if_fail (NAUTILUS_IS_SCALABLE_FONT (font));
@ -728,6 +755,7 @@ nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
art_affine_identity (affine);
/* Make a glyph for the given string */
glyph = rsvg_ft_render_string (global_rsvg_ft_context,
font->detail->font_handle,
text,
@ -736,64 +764,112 @@ nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
font_height,
affine,
glyph_xy);
pixbuf_width = gdk_pixbuf_get_width (destination_pixbuf);
pixbuf_height = gdk_pixbuf_get_height (destination_pixbuf);
pixbuf_rowstride = gdk_pixbuf_get_rowstride (destination_pixbuf);
pixbuf_pixels = gdk_pixbuf_get_pixels (destination_pixbuf);
g_assert (glyph != NULL);
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,
pixbuf_height,
pixbuf_pixels,
pixbuf_rowstride,
3,
8,
alpha_type,
NULL);
art_color_array[0] = ART_PIX_MAX_FROM_8 (NAUTILUS_RGBA_COLOR_GET_R (color));
art_color_array[1] = ART_PIX_MAX_FROM_8 (NAUTILUS_RGBA_COLOR_GET_G (color));
art_color_array[2] = ART_PIX_MAX_FROM_8 (NAUTILUS_RGBA_COLOR_GET_B (color));
art_render_image_solid (art_render, art_color_array);
glyph_area.x0 = glyph_xy[0] + x;
glyph_area.y0 = glyph_xy[1] + y;
glyph_area.x0 = glyph_xy[0];
glyph_area.y0 = glyph_xy[1];
glyph_area.x1 = glyph_area.x0 + glyph->width;
glyph_area.y1 = glyph_area.y0 + glyph->height;
/* Invert the glyph if needed */
if (inverted) {
ArtIRect invert_area;
if (clip_area != NULL) {
art_irect_intersect (&invert_area, &glyph_area, clip_area);
}
else {
invert_area = glyph_area;
}
//if (!art_irect_empty (&invert_area)) {
{
guchar *glyph_pixels;
guint glyph_rowstride;
glyph_rowstride = glyph->rowstride;
glyph_pixels = glyph->buf;
glyph_pixels =
glyph->buf +
(invert_area.x0 - glyph_area.x0) +
glyph_rowstride * (invert_area.y0 - glyph_area.y0);
invert_glyph (glyph_pixels,
glyph_rowstride,
invert_area.x1 - invert_area.x0,
invert_area.y1 - invert_area.y0);
}
}
/* Translate the glyph area to the (x,y) where its to be rendered */
glyph_area.x0 += x;
glyph_area.y0 += y;
glyph_area.x1 += x;
glyph_area.y1 += y;
/* Clip the glyph_area against the clip_area if needed */
if (clip_area != NULL) {
art_irect_intersect (&area, &glyph_area, clip_area);
art_irect_intersect (&render_area, &glyph_area, clip_area);
}
else {
area = glyph_area;
render_area = glyph_area;
}
/* glyph_xy[0] += destination_point->x; */
/* glyph_xy[1] += destination_point->y; */
art_render_mask (art_render,
area.x0,
area.y0,
area.x1,
area.y1,
glyph->buf,
glyph->rowstride);
art_render_invoke (art_render);
/* Render the glyph */
if (!art_irect_empty (&render_area)) {
guint pixbuf_width;
guint pixbuf_height;
guint pixbuf_rowstride;
guchar *pixbuf_pixels;
ArtRender *art_render;
ArtPixMaxDepth art_color_array[3];
ArtAlphaType alpha_type;
pixbuf_width = gdk_pixbuf_get_width (destination_pixbuf);
pixbuf_height = gdk_pixbuf_get_height (destination_pixbuf);
pixbuf_rowstride = gdk_pixbuf_get_rowstride (destination_pixbuf);
pixbuf_pixels = gdk_pixbuf_get_pixels (destination_pixbuf);
alpha_type = gdk_pixbuf_get_has_alpha (destination_pixbuf) ?
ART_ALPHA_SEPARATE :
ART_ALPHA_NONE;
art_render = art_render_new (0,
0,
pixbuf_width,
pixbuf_height,
pixbuf_pixels,
pixbuf_rowstride,
3,
8,
alpha_type,
NULL);
art_color_array[0] = ART_PIX_MAX_FROM_8 (NAUTILUS_RGBA_COLOR_GET_R (color));
art_color_array[1] = ART_PIX_MAX_FROM_8 (NAUTILUS_RGBA_COLOR_GET_G (color));
art_color_array[2] = ART_PIX_MAX_FROM_8 (NAUTILUS_RGBA_COLOR_GET_B (color));
art_render_image_solid (art_render, art_color_array);
art_render_mask (art_render,
render_area.x0,
render_area.y0,
render_area.x1,
render_area.y1,
glyph->buf,
glyph->rowstride);
art_render_invoke (art_render);
}
rsvg_ft_glyph_unref (glyph);
}
}
void
nautilus_scalable_font_measure_text_lines (const NautilusScalableFont *font,
@ -899,7 +975,8 @@ nautilus_scalable_font_draw_text_lines_with_dimensions (const NautilusScalableFo
guint line_offset,
double empty_line_height,
guint32 color,
guchar overall_alpha)
guchar overall_alpha,
gboolean inverted)
{
guint i;
const char *line;
@ -992,7 +1069,8 @@ nautilus_scalable_font_draw_text_lines_with_dimensions (const NautilusScalableFo
line,
length,
color,
overall_alpha);
overall_alpha,
inverted);
y += (line_offset + text_line_heights[i]);
}
@ -1019,7 +1097,8 @@ nautilus_scalable_font_draw_text_lines (const NautilusScalableFont *font,
guint line_offset,
double empty_line_height,
guint32 color,
guchar overall_alpha)
guchar overall_alpha,
gboolean inverted)
{
guint num_text_lines;
guint *text_line_widths;
@ -1073,7 +1152,8 @@ nautilus_scalable_font_draw_text_lines (const NautilusScalableFont *font,
line_offset,
empty_line_height,
color,
overall_alpha);
overall_alpha,
inverted);
g_free (text_line_widths);
g_free (text_line_heights);
@ -1576,7 +1656,8 @@ nautilus_text_layout_paint (const NautilusTextLayout *text_info,
int x,
int y,
GtkJustification just,
guint32 color)
guint32 color,
gboolean inverted)
{
GList *item;
const NautilusTextLayoutRow *row;
@ -1621,7 +1702,8 @@ nautilus_text_layout_paint (const NautilusTextLayout *text_info,
row->text,
row->text_length,
color,
255);
255,
inverted);
y += text_info->baseline_skip;
} else

View file

@ -99,7 +99,8 @@ void nautilus_scalable_font_draw_text (c
const char *text,
guint text_length,
guint32 color,
guchar overall_alpha);
guchar overall_alpha,
gboolean inverted);
void nautilus_scalable_font_measure_text_lines (const NautilusScalableFont *font,
guint font_width,
guint font_height,
@ -125,7 +126,8 @@ void nautilus_scalable_font_draw_text_lines_with_dimensions (c
guint line_offset,
double empty_line_height,
guint32 color,
guchar overall_alpha);
guchar overall_alpha,
gboolean inverted);
void nautilus_scalable_font_draw_text_lines (const NautilusScalableFont *font,
GdkPixbuf *destination_pixbuf,
int x,
@ -138,7 +140,8 @@ void nautilus_scalable_font_draw_text_lines (c
guint line_offset,
double empty_line_height,
guint32 color,
guchar overall_alpha);
guchar overall_alpha,
gboolean inverted);
guint nautilus_scalable_font_largest_fitting_font_size (const NautilusScalableFont *font,
const char *text,
guint available_width,
@ -196,7 +199,8 @@ void nautilus_text_layout_paint (const NautilusTextLayout *text
int x,
int y,
GtkJustification just,
guint32 color);
guint32 color,
gboolean inverted);
void nautilus_text_layout_free (NautilusTextLayout *text_info);

View file

@ -2261,7 +2261,8 @@ embed_text (GdkPixbuf *pixbuf_without_text,
line_offset,
empty_line_height,
NAUTILUS_RGB_COLOR_BLACK,
255);
255,
FALSE);
gtk_object_unref (GTK_OBJECT (font));

View file

@ -363,7 +363,8 @@ render_buffer_pixbuf (NautilusBufferedWidget *buffered_widget,
label->detail->line_offset,
label_get_empty_line_height (label),
label->detail->drop_shadow_color,
label->detail->text_alpha);
label->detail->text_alpha,
FALSE);
text_x -= label->detail->drop_shadow_offset;
text_y -= label->detail->drop_shadow_offset;
@ -384,7 +385,8 @@ render_buffer_pixbuf (NautilusBufferedWidget *buffered_widget,
label->detail->line_offset,
label_get_empty_line_height (label),
label->detail->text_color,
label->detail->text_alpha);
label->detail->text_alpha,
FALSE);
}
}

View file

@ -644,6 +644,7 @@ nautilus_scalable_font_measure_text (const NautilusScalableFont *font,
font_height,
affine,
glyph_xy);
g_assert (glyph != NULL);
*text_width_out = glyph->width;
*text_height_out = glyph->height;
@ -682,6 +683,40 @@ nautilus_scalable_font_text_width (const NautilusScalableFont *font,
return text_width;
}
/* Lifted from Raph's test-ft-gtk.c sample program */
static void
invert_glyph (guchar *buf, int rowstride, int width, int height)
{
int x, y;
int first;
int n_words;
int last;
guint32 *middle;
if (width >= 8 && ((rowstride & 3) == 0)) {
first = (-(int)buf) & 3;
n_words = (width - first) >> 2;
last = first + (n_words << 2);
for (y = 0; y < height; y++) {
middle = (guint32 *)(buf + first);
for (x = 0; x < first; x++)
buf[x] = ~buf[x];
for (x = 0; x < n_words; x++)
middle[x] = ~middle[x];
for (x = last; x < width; x++)
buf[x] = ~buf[x];
buf += rowstride;
}
} else {
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++)
buf[x] = ~buf[x];
buf += rowstride;
}
}
}
void
nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
GdkPixbuf *destination_pixbuf,
@ -693,21 +728,13 @@ nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
const char *text,
guint text_length,
guint32 color,
guchar overall_alpha)
guchar overall_alpha,
gboolean inverted)
{
RsvgFTGlyph *glyph;
double affine[6];
int glyph_xy[2];
guint pixbuf_width;
guint pixbuf_height;
guint pixbuf_rowstride;
guchar *pixbuf_pixels;
ArtRender *art_render;
ArtPixMaxDepth art_color_array[3];
ArtAlphaType alpha_type;
ArtIRect area;
ArtIRect render_area;
ArtIRect glyph_area;
g_return_if_fail (NAUTILUS_IS_SCALABLE_FONT (font));
@ -728,6 +755,7 @@ nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
art_affine_identity (affine);
/* Make a glyph for the given string */
glyph = rsvg_ft_render_string (global_rsvg_ft_context,
font->detail->font_handle,
text,
@ -736,64 +764,112 @@ nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
font_height,
affine,
glyph_xy);
pixbuf_width = gdk_pixbuf_get_width (destination_pixbuf);
pixbuf_height = gdk_pixbuf_get_height (destination_pixbuf);
pixbuf_rowstride = gdk_pixbuf_get_rowstride (destination_pixbuf);
pixbuf_pixels = gdk_pixbuf_get_pixels (destination_pixbuf);
g_assert (glyph != NULL);
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,
pixbuf_height,
pixbuf_pixels,
pixbuf_rowstride,
3,
8,
alpha_type,
NULL);
art_color_array[0] = ART_PIX_MAX_FROM_8 (NAUTILUS_RGBA_COLOR_GET_R (color));
art_color_array[1] = ART_PIX_MAX_FROM_8 (NAUTILUS_RGBA_COLOR_GET_G (color));
art_color_array[2] = ART_PIX_MAX_FROM_8 (NAUTILUS_RGBA_COLOR_GET_B (color));
art_render_image_solid (art_render, art_color_array);
glyph_area.x0 = glyph_xy[0] + x;
glyph_area.y0 = glyph_xy[1] + y;
glyph_area.x0 = glyph_xy[0];
glyph_area.y0 = glyph_xy[1];
glyph_area.x1 = glyph_area.x0 + glyph->width;
glyph_area.y1 = glyph_area.y0 + glyph->height;
/* Invert the glyph if needed */
if (inverted) {
ArtIRect invert_area;
if (clip_area != NULL) {
art_irect_intersect (&invert_area, &glyph_area, clip_area);
}
else {
invert_area = glyph_area;
}
//if (!art_irect_empty (&invert_area)) {
{
guchar *glyph_pixels;
guint glyph_rowstride;
glyph_rowstride = glyph->rowstride;
glyph_pixels = glyph->buf;
glyph_pixels =
glyph->buf +
(invert_area.x0 - glyph_area.x0) +
glyph_rowstride * (invert_area.y0 - glyph_area.y0);
invert_glyph (glyph_pixels,
glyph_rowstride,
invert_area.x1 - invert_area.x0,
invert_area.y1 - invert_area.y0);
}
}
/* Translate the glyph area to the (x,y) where its to be rendered */
glyph_area.x0 += x;
glyph_area.y0 += y;
glyph_area.x1 += x;
glyph_area.y1 += y;
/* Clip the glyph_area against the clip_area if needed */
if (clip_area != NULL) {
art_irect_intersect (&area, &glyph_area, clip_area);
art_irect_intersect (&render_area, &glyph_area, clip_area);
}
else {
area = glyph_area;
render_area = glyph_area;
}
/* glyph_xy[0] += destination_point->x; */
/* glyph_xy[1] += destination_point->y; */
art_render_mask (art_render,
area.x0,
area.y0,
area.x1,
area.y1,
glyph->buf,
glyph->rowstride);
art_render_invoke (art_render);
/* Render the glyph */
if (!art_irect_empty (&render_area)) {
guint pixbuf_width;
guint pixbuf_height;
guint pixbuf_rowstride;
guchar *pixbuf_pixels;
ArtRender *art_render;
ArtPixMaxDepth art_color_array[3];
ArtAlphaType alpha_type;
pixbuf_width = gdk_pixbuf_get_width (destination_pixbuf);
pixbuf_height = gdk_pixbuf_get_height (destination_pixbuf);
pixbuf_rowstride = gdk_pixbuf_get_rowstride (destination_pixbuf);
pixbuf_pixels = gdk_pixbuf_get_pixels (destination_pixbuf);
alpha_type = gdk_pixbuf_get_has_alpha (destination_pixbuf) ?
ART_ALPHA_SEPARATE :
ART_ALPHA_NONE;
art_render = art_render_new (0,
0,
pixbuf_width,
pixbuf_height,
pixbuf_pixels,
pixbuf_rowstride,
3,
8,
alpha_type,
NULL);
art_color_array[0] = ART_PIX_MAX_FROM_8 (NAUTILUS_RGBA_COLOR_GET_R (color));
art_color_array[1] = ART_PIX_MAX_FROM_8 (NAUTILUS_RGBA_COLOR_GET_G (color));
art_color_array[2] = ART_PIX_MAX_FROM_8 (NAUTILUS_RGBA_COLOR_GET_B (color));
art_render_image_solid (art_render, art_color_array);
art_render_mask (art_render,
render_area.x0,
render_area.y0,
render_area.x1,
render_area.y1,
glyph->buf,
glyph->rowstride);
art_render_invoke (art_render);
}
rsvg_ft_glyph_unref (glyph);
}
}
void
nautilus_scalable_font_measure_text_lines (const NautilusScalableFont *font,
@ -899,7 +975,8 @@ nautilus_scalable_font_draw_text_lines_with_dimensions (const NautilusScalableFo
guint line_offset,
double empty_line_height,
guint32 color,
guchar overall_alpha)
guchar overall_alpha,
gboolean inverted)
{
guint i;
const char *line;
@ -992,7 +1069,8 @@ nautilus_scalable_font_draw_text_lines_with_dimensions (const NautilusScalableFo
line,
length,
color,
overall_alpha);
overall_alpha,
inverted);
y += (line_offset + text_line_heights[i]);
}
@ -1019,7 +1097,8 @@ nautilus_scalable_font_draw_text_lines (const NautilusScalableFont *font,
guint line_offset,
double empty_line_height,
guint32 color,
guchar overall_alpha)
guchar overall_alpha,
gboolean inverted)
{
guint num_text_lines;
guint *text_line_widths;
@ -1073,7 +1152,8 @@ nautilus_scalable_font_draw_text_lines (const NautilusScalableFont *font,
line_offset,
empty_line_height,
color,
overall_alpha);
overall_alpha,
inverted);
g_free (text_line_widths);
g_free (text_line_heights);
@ -1576,7 +1656,8 @@ nautilus_text_layout_paint (const NautilusTextLayout *text_info,
int x,
int y,
GtkJustification just,
guint32 color)
guint32 color,
gboolean inverted)
{
GList *item;
const NautilusTextLayoutRow *row;
@ -1621,7 +1702,8 @@ nautilus_text_layout_paint (const NautilusTextLayout *text_info,
row->text,
row->text_length,
color,
255);
255,
inverted);
y += text_info->baseline_skip;
} else

View file

@ -99,7 +99,8 @@ void nautilus_scalable_font_draw_text (c
const char *text,
guint text_length,
guint32 color,
guchar overall_alpha);
guchar overall_alpha,
gboolean inverted);
void nautilus_scalable_font_measure_text_lines (const NautilusScalableFont *font,
guint font_width,
guint font_height,
@ -125,7 +126,8 @@ void nautilus_scalable_font_draw_text_lines_with_dimensions (c
guint line_offset,
double empty_line_height,
guint32 color,
guchar overall_alpha);
guchar overall_alpha,
gboolean inverted);
void nautilus_scalable_font_draw_text_lines (const NautilusScalableFont *font,
GdkPixbuf *destination_pixbuf,
int x,
@ -138,7 +140,8 @@ void nautilus_scalable_font_draw_text_lines (c
guint line_offset,
double empty_line_height,
guint32 color,
guchar overall_alpha);
guchar overall_alpha,
gboolean inverted);
guint nautilus_scalable_font_largest_fitting_font_size (const NautilusScalableFont *font,
const char *text,
guint available_width,
@ -196,7 +199,8 @@ void nautilus_text_layout_paint (const NautilusTextLayout *text
int x,
int y,
GtkJustification just,
guint32 color);
guint32 color,
gboolean inverted);
void nautilus_text_layout_free (NautilusTextLayout *text_info);

View file

@ -195,10 +195,10 @@ draw_aa_string (NautilusScalableFont *font, GdkPixbuf *pixbuf, int font_size, in
NULL,
font_size, font_size,
text, strlen (text),
shadow_color, 255);
shadow_color, 255, FALSE);
}
nautilus_scalable_font_draw_text (font, pixbuf, x_pos, y_pos, NULL, font_size, font_size, text, strlen (text), color, 255);
nautilus_scalable_font_draw_text (font, pixbuf, x_pos, y_pos, NULL, font_size, font_size, text, strlen (text), color, 255, FALSE);
}
/* draw the information onto the pixbuf */

View file

@ -546,14 +546,14 @@ draw_one_tab_plain (NautilusSidebarTabs *sidebar_tabs, GdkGC *gc,
NULL,
sidebar_tabs->details->font_size, sidebar_tabs->details->font_size,
tab_name, strlen (tab_name),
prelight_flag ? NAUTILUS_RGB_COLOR_WHITE : NAUTILUS_RGB_COLOR_BLACK, 255);
prelight_flag ? NAUTILUS_RGB_COLOR_WHITE : NAUTILUS_RGB_COLOR_BLACK, 255, FALSE);
nautilus_scalable_font_draw_text (sidebar_tabs->details->tab_font, temp_pixbuf,
0, 0,
NULL,
sidebar_tabs->details->font_size, sidebar_tabs->details->font_size,
tab_name, strlen (tab_name),
prelight_flag ? NAUTILUS_RGB_COLOR_BLACK : NAUTILUS_RGB_COLOR_WHITE, 255);
prelight_flag ? NAUTILUS_RGB_COLOR_BLACK : NAUTILUS_RGB_COLOR_WHITE, 255, FALSE);
/* blit the pixbuf to the drawable, then release it */
@ -696,7 +696,7 @@ draw_one_tab_themed (NautilusSidebarTabs *sidebar_tabs, GdkPixbuf *tab_pixbuf,
NULL,
sidebar_tabs->details->font_size, sidebar_tabs->details->font_size,
tab_name, strlen (tab_name),
NAUTILUS_RGB_COLOR_BLACK, 255);
NAUTILUS_RGB_COLOR_BLACK, 255, FALSE);
text_x -= 1;
text_y -= 1;
@ -705,7 +705,7 @@ draw_one_tab_themed (NautilusSidebarTabs *sidebar_tabs, GdkPixbuf *tab_pixbuf,
NULL,
sidebar_tabs->details->font_size, sidebar_tabs->details->font_size,
tab_name, strlen (tab_name),
NAUTILUS_RGB_COLOR_WHITE, 255);
NAUTILUS_RGB_COLOR_WHITE, 255, FALSE);
/* set up the bounds rectangle for later hit-testing */
if (tab_rect) {

View file

@ -141,7 +141,6 @@ main (int argc, char* argv[])
{
GdkPixbuf *pixbuf;
NautilusScalableFont *font;
GdkRectangle blue_area;
ArtIRect clip_area;
ArtIRect whole_area;
ArtIRect multi_lines_area;
@ -209,15 +208,10 @@ main (int argc, char* argv[])
g_free (text_line_heights);
}
blue_area.x = 300;
blue_area.y = 20;
blue_area.width = 100;
blue_area.height = 30;
clip_area.x0 = blue_area.x;
clip_area.y0 = blue_area.y;
clip_area.x1 = blue_area.x + blue_area.width;
clip_area.y1 = blue_area.y + blue_area.height;
clip_area.x0 = 300;
clip_area.y0 = 20;
clip_area.x1 = clip_area.x0 + 100;
clip_area.y1 = clip_area.y0 + 30;
draw_rectangle_around (pixbuf, &clip_area, RED);
@ -228,7 +222,9 @@ main (int argc, char* argv[])
draw_rectangle_around (pixbuf, &multi_lines_area, RED);
/* Draw some green text clipped by the whole pixbuf area */
/*
* Multiple text lines test.
*/
nautilus_scalable_font_draw_text_lines (font,
pixbuf,
multi_line_x,
@ -241,9 +237,16 @@ main (int argc, char* argv[])
line_offset,
empty_line_height,
BLUE,
255);
255,
FALSE);
/* Draw some red text clipped by the blue area */
/*
* Clipped text test. The "Something" string should be clipped such
* that horizontally you can only see "Som" and a tiny fraction of
* the "e".
*
* Vertically, you should see about 90% of the "Som"
*/
nautilus_scalable_font_draw_text (font,
pixbuf,
clip_area.x0,
@ -254,8 +257,28 @@ main (int argc, char* argv[])
"Something",
strlen ("Something"),
GREEN,
255);
255,
FALSE);
/*
* Inverted text test.
*/
nautilus_scalable_font_draw_text (font,
pixbuf,
50,
350,
NULL,
50,
50,
"This text is inverted",
strlen ("This text is inverted"),
GREEN,
255,
TRUE);
/*
* Text layout test.
*/
{
NautilusTextLayout *text_info;
const guint max_text_width = 100;
@ -284,7 +307,8 @@ main (int argc, char* argv[])
layout_area.x0,
layout_area.y0,
GTK_JUSTIFY_LEFT,
BLACK);
BLACK,
FALSE);
layout_area.x0 += (max_text_width + 20);
layout_area.x1 += (max_text_width + 20);
@ -296,8 +320,8 @@ main (int argc, char* argv[])
layout_area.x0,
layout_area.y0,
GTK_JUSTIFY_CENTER,
BLACK);
BLACK,
FALSE);
layout_area.x0 += (max_text_width + 20);
layout_area.x1 += (max_text_width + 20);
@ -309,7 +333,8 @@ main (int argc, char* argv[])
layout_area.x0,
layout_area.y0,
GTK_JUSTIFY_RIGHT,
BLACK);
BLACK,
FALSE);
nautilus_text_layout_free (text_info);
}