mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-08-25 02:36:07 +00:00
Work on task 1588.
* libnautilus-extensions/nautilus-scalable-font.c: (nautilus_scalable_font_measure_text), (nautilus_scalable_font_draw_text), (nautilus_scalable_font_measure_text_lines), (nautilus_scalable_font_draw_text_lines), (nautilus_scalable_font_measure_text_lines), (nautilus_scalable_font_draw_text_lines), (nautilus_scalable_font_largest_fitting_font_size): * libnautilus-extensions/nautilus-scalable-font.h: Change api to accept a string with embedded new lines instead of an array of strings. This simplifies many things. * libnautilus-extensions/nautilus-label.c: (nautilus_label_initialize), (nautilus_label_destroy), (render_buffer_pixbuf), (label_recompute_line_geometries): Update for NautilusScalalbleFont api changes. No longer need to tokenize the text string. we can feed the string to the rendering api as is. * librsvg/rsvg-ft.c: (rsvg_ft_render_string): * librsvg/rsvg-ft.h: Change the string to glyph rendering api to accept the string length rather than computing it. This makes it possible to feed it arbitrary lengths. * librsvg/rsvg.c: (rsvg_text_handler_characters): * librsvg/test-ft-gtk.c: (draw_line): * librsvg/test-ft.c: (main): Update for api changes. * src/nautilus-about.c: (draw_aa_string): * src/nautilus-sidebar-tabs.c: (draw_one_tab_plain), (draw_one_tab_themed), (get_tab_width): * test/test-nautilus-font.c: (main): Update test to use text lines drawing api. * test/test-nautilus-label.c: (alpha_background_color_value_changed_callback), (main): Update test for 2 new lines in a row.
This commit is contained in:
parent
31cb07f67a
commit
93861b3494
44
ChangeLog
44
ChangeLog
|
@ -1,3 +1,47 @@
|
|||
2000-09-04 Ramiro Estrugo <ramiro@eazel.com>
|
||||
|
||||
Work on task 1588.
|
||||
|
||||
* libnautilus-extensions/nautilus-scalable-font.c:
|
||||
(nautilus_scalable_font_measure_text),
|
||||
(nautilus_scalable_font_draw_text),
|
||||
(nautilus_scalable_font_measure_text_lines),
|
||||
(nautilus_scalable_font_draw_text_lines),
|
||||
(nautilus_scalable_font_measure_text_lines),
|
||||
(nautilus_scalable_font_draw_text_lines),
|
||||
(nautilus_scalable_font_largest_fitting_font_size):
|
||||
* libnautilus-extensions/nautilus-scalable-font.h:
|
||||
Change api to accept a string with embedded new lines instead of
|
||||
an array of strings. This simplifies many things.
|
||||
|
||||
* libnautilus-extensions/nautilus-label.c:
|
||||
(nautilus_label_initialize), (nautilus_label_destroy),
|
||||
(render_buffer_pixbuf), (label_recompute_line_geometries):
|
||||
Update for NautilusScalalbleFont api changes. No longer need to
|
||||
tokenize the text string. we can feed the string to the rendering
|
||||
api as is.
|
||||
|
||||
* librsvg/rsvg-ft.c: (rsvg_ft_render_string):
|
||||
* librsvg/rsvg-ft.h:
|
||||
Change the string to glyph rendering api to accept the string
|
||||
length rather than computing it. This makes it possible to feed
|
||||
it arbitrary lengths.
|
||||
|
||||
* librsvg/rsvg.c: (rsvg_text_handler_characters):
|
||||
* librsvg/test-ft-gtk.c: (draw_line):
|
||||
* librsvg/test-ft.c: (main):
|
||||
Update for api changes.
|
||||
|
||||
* src/nautilus-about.c: (draw_aa_string):
|
||||
* src/nautilus-sidebar-tabs.c: (draw_one_tab_plain),
|
||||
(draw_one_tab_themed), (get_tab_width):
|
||||
* test/test-nautilus-font.c: (main):
|
||||
Update test to use text lines drawing api.
|
||||
|
||||
* test/test-nautilus-label.c:
|
||||
(alpha_background_color_value_changed_callback), (main):
|
||||
Update test for 2 new lines in a row.
|
||||
|
||||
2000-09-04 Ramiro Estrugo <ramiro@eazel.com>
|
||||
|
||||
* libnautilus-extensions/nautilus-string-list.c:
|
||||
|
|
|
@ -61,7 +61,6 @@ struct _NautilusLabelDetail
|
|||
guint font_size;
|
||||
|
||||
/* Text lines */
|
||||
char **text_lines;
|
||||
guint *text_line_widths;
|
||||
guint *text_line_heights;
|
||||
guint num_text_lines;
|
||||
|
@ -159,7 +158,6 @@ nautilus_label_initialize (NautilusLabel *label)
|
|||
label->detail->num_text_lines = 0;
|
||||
label->detail->max_text_line_width = 0;
|
||||
label->detail->total_text_line_height = 0;
|
||||
label->detail->text_lines = NULL;
|
||||
label->detail->text_line_widths = NULL;
|
||||
label->detail->text_line_heights = NULL;
|
||||
|
||||
|
@ -180,7 +178,6 @@ nautilus_label_destroy (GtkObject *object)
|
|||
|
||||
g_free (label->detail->text);
|
||||
|
||||
g_strfreev (label->detail->text_lines);
|
||||
g_free (label->detail->text_line_widths);
|
||||
g_free (label->detail->text_line_heights);
|
||||
|
||||
|
@ -358,11 +355,11 @@ render_buffer_pixbuf (NautilusBufferedWidget *buffered_widget,
|
|||
&area,
|
||||
label->detail->font_size,
|
||||
label->detail->font_size,
|
||||
(const char **) label->detail->text_lines,
|
||||
label->detail->text,
|
||||
label->detail->num_text_lines,
|
||||
label->detail->text_line_widths,
|
||||
label->detail->text_line_heights,
|
||||
label->detail->text_justification,
|
||||
label->detail->num_text_lines,
|
||||
label->detail->line_offset,
|
||||
label->detail->drop_shadow_color,
|
||||
label->detail->text_alpha);
|
||||
|
@ -379,11 +376,11 @@ render_buffer_pixbuf (NautilusBufferedWidget *buffered_widget,
|
|||
&area,
|
||||
label->detail->font_size,
|
||||
label->detail->font_size,
|
||||
(const char **) label->detail->text_lines,
|
||||
label->detail->text,
|
||||
label->detail->num_text_lines,
|
||||
label->detail->text_line_widths,
|
||||
label->detail->text_line_heights,
|
||||
label->detail->text_justification,
|
||||
label->detail->num_text_lines,
|
||||
label->detail->line_offset,
|
||||
label->detail->text_color,
|
||||
label->detail->text_alpha);
|
||||
|
@ -396,10 +393,8 @@ label_recompute_line_geometries (NautilusLabel *label)
|
|||
{
|
||||
g_return_if_fail (NAUTILUS_IS_LABEL (label));
|
||||
|
||||
g_strfreev (label->detail->text_lines);
|
||||
g_free (label->detail->text_line_widths);
|
||||
g_free (label->detail->text_line_heights);
|
||||
label->detail->text_lines = NULL;
|
||||
label->detail->text_line_widths = NULL;
|
||||
label->detail->text_line_heights = NULL;
|
||||
|
||||
|
@ -408,20 +403,16 @@ label_recompute_line_geometries (NautilusLabel *label)
|
|||
label->detail->max_text_line_width = 0;
|
||||
label->detail->total_text_line_height = 0;
|
||||
|
||||
label->detail->text_lines = NULL;
|
||||
|
||||
if (nautilus_strlen (label->detail->text) > 0) {
|
||||
label->detail->num_text_lines = nautilus_str_count_characters (label->detail->text, '\n') + 1;
|
||||
|
||||
label->detail->text_lines = g_strsplit (label->detail->text, "\n", -1);
|
||||
|
||||
label->detail->text_line_widths = g_new (guint, label->detail->num_text_lines);
|
||||
label->detail->text_line_heights = g_new (guint, label->detail->num_text_lines);
|
||||
|
||||
nautilus_scalable_font_measure_text_lines (label->detail->font,
|
||||
label->detail->font_size,
|
||||
label->detail->font_size,
|
||||
(const char **) label->detail->text_lines,
|
||||
label->detail->text,
|
||||
label->detail->num_text_lines,
|
||||
label->detail->text_line_widths,
|
||||
label->detail->text_line_heights,
|
||||
|
|
|
@ -606,6 +606,7 @@ nautilus_scalable_font_measure_text (const NautilusScalableFont *font,
|
|||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text,
|
||||
guint text_length,
|
||||
guint *text_width_out,
|
||||
guint *text_height_out)
|
||||
{
|
||||
|
@ -622,10 +623,12 @@ nautilus_scalable_font_measure_text (const NautilusScalableFont *font,
|
|||
*text_width_out = 0;
|
||||
*text_height_out = 0;
|
||||
|
||||
if (text == NULL) {
|
||||
if (text == NULL || text[0] == '\0' || text_length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
g_return_if_fail (text_length <= strlen (text));
|
||||
|
||||
art_affine_identity (affine);
|
||||
|
||||
/* FIXME bugzilla.eazel.com 2544: We need to change rsvg_ft_render_string() to accept
|
||||
|
@ -635,6 +638,7 @@ nautilus_scalable_font_measure_text (const NautilusScalableFont *font,
|
|||
glyph = rsvg_ft_render_string (global_rsvg_ft_context,
|
||||
font->detail->font_handle,
|
||||
text,
|
||||
text_length,
|
||||
font_width,
|
||||
font_height,
|
||||
affine,
|
||||
|
@ -646,101 +650,6 @@ nautilus_scalable_font_measure_text (const NautilusScalableFont *font,
|
|||
rsvg_ft_glyph_unref (glyph);
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_scalable_font_measure_text_lines (NautilusScalableFont *font,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text_lines[],
|
||||
guint num_text_lines,
|
||||
guint text_line_widths[],
|
||||
guint text_line_heights[],
|
||||
guint *max_width_out,
|
||||
guint *total_height_out)
|
||||
{
|
||||
guint i;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_SCALABLE_FONT (font));
|
||||
g_return_if_fail (font_width > 0);
|
||||
g_return_if_fail (font_height > 0);
|
||||
g_return_if_fail (text_lines != NULL);
|
||||
g_return_if_fail (text_line_widths != NULL);
|
||||
g_return_if_fail (text_line_heights != NULL);
|
||||
g_return_if_fail (num_text_lines > 0);
|
||||
|
||||
if (max_width_out != NULL) {
|
||||
*max_width_out = 0;
|
||||
}
|
||||
|
||||
if (total_height_out != NULL) {
|
||||
*total_height_out = 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < num_text_lines; i++) {
|
||||
g_assert (text_lines[i] != NULL);
|
||||
|
||||
nautilus_scalable_font_measure_text (font,
|
||||
font_width,
|
||||
font_height,
|
||||
text_lines[i],
|
||||
&text_line_widths[i],
|
||||
&text_line_heights[i]);
|
||||
|
||||
if (total_height_out != NULL) {
|
||||
*total_height_out += text_line_heights[i];
|
||||
}
|
||||
|
||||
if ((max_width_out != NULL) && (text_line_widths[i] > *max_width_out)) {
|
||||
*max_width_out = text_line_widths[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
guint
|
||||
nautilus_scalable_font_largest_fitting_font_size (const NautilusScalableFont *font,
|
||||
const char *text,
|
||||
guint available_width,
|
||||
const guint font_sizes[],
|
||||
guint num_font_sizes)
|
||||
{
|
||||
NautilusStringList *tokenized_string;
|
||||
guint i;
|
||||
char *longest_string;
|
||||
|
||||
g_return_val_if_fail (NAUTILUS_IS_SCALABLE_FONT (font), 0);
|
||||
g_return_val_if_fail (font_sizes != NULL, 0);
|
||||
g_return_val_if_fail (num_font_sizes > 0, 0);
|
||||
|
||||
if (text == NULL || text[0] == '\0' || available_width < 1) {
|
||||
return font_sizes[num_font_sizes - 1];
|
||||
}
|
||||
|
||||
tokenized_string = nautilus_string_list_new_from_tokens (text, "\n", FALSE);
|
||||
longest_string = nautilus_string_list_get_longest_string (tokenized_string);
|
||||
g_assert (longest_string != NULL);
|
||||
nautilus_string_list_free (tokenized_string);
|
||||
|
||||
for (i = 0; i < num_font_sizes; i++) {
|
||||
guint text_width;
|
||||
guint text_height;
|
||||
|
||||
nautilus_scalable_font_measure_text (font,
|
||||
font_sizes[i],
|
||||
font_sizes[i],
|
||||
longest_string,
|
||||
&text_width,
|
||||
&text_height);
|
||||
|
||||
if (text_width <= available_width) {
|
||||
g_free (longest_string);
|
||||
return font_sizes[i];
|
||||
}
|
||||
}
|
||||
|
||||
g_free (longest_string);
|
||||
|
||||
return font_sizes[num_font_sizes - 1];
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
|
||||
GdkPixbuf *destination_pixbuf,
|
||||
|
@ -748,6 +657,7 @@ nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
|
|||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text,
|
||||
guint text_length,
|
||||
guint32 color,
|
||||
guchar overall_alpha)
|
||||
{
|
||||
|
@ -774,15 +684,18 @@ nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
|
|||
g_return_if_fail (font_width > 0);
|
||||
g_return_if_fail (font_height > 0);
|
||||
|
||||
if (text == NULL) {
|
||||
if (text == NULL || text[0] == '\0' || text_length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
g_return_if_fail (text_length <= strlen (text));
|
||||
|
||||
art_affine_identity (affine);
|
||||
|
||||
glyph = rsvg_ft_render_string (global_rsvg_ft_context,
|
||||
font->detail->font_handle,
|
||||
text,
|
||||
text_length,
|
||||
font_width,
|
||||
font_height,
|
||||
affine,
|
||||
|
@ -837,6 +750,57 @@ nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
|
|||
rsvg_ft_glyph_unref (glyph);
|
||||
}
|
||||
|
||||
#if 0
|
||||
void
|
||||
nautilus_scalable_font_measure_text_lines (NautilusScalableFont *font,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text_lines[],
|
||||
guint num_text_lines,
|
||||
guint text_line_widths[],
|
||||
guint text_line_heights[],
|
||||
guint *max_width_out,
|
||||
guint *total_height_out)
|
||||
{
|
||||
guint i;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_SCALABLE_FONT (font));
|
||||
g_return_if_fail (font_width > 0);
|
||||
g_return_if_fail (font_height > 0);
|
||||
g_return_if_fail (text_lines != NULL);
|
||||
g_return_if_fail (text_line_widths != NULL);
|
||||
g_return_if_fail (text_line_heights != NULL);
|
||||
g_return_if_fail (num_text_lines > 0);
|
||||
|
||||
if (max_width_out != NULL) {
|
||||
*max_width_out = 0;
|
||||
}
|
||||
|
||||
if (total_height_out != NULL) {
|
||||
*total_height_out = 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < num_text_lines; i++) {
|
||||
g_assert (text_lines[i] != NULL);
|
||||
|
||||
nautilus_scalable_font_measure_text (font,
|
||||
font_width,
|
||||
font_height,
|
||||
text_lines[i],
|
||||
strlen (text_lines[i]),
|
||||
&text_line_widths[i],
|
||||
&text_line_heights[i]);
|
||||
|
||||
if (total_height_out != NULL) {
|
||||
*total_height_out += text_line_heights[i];
|
||||
}
|
||||
|
||||
if ((max_width_out != NULL) && (text_line_widths[i] > *max_width_out)) {
|
||||
*max_width_out = text_line_widths[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_scalable_font_draw_text_lines (const NautilusScalableFont *font,
|
||||
GdkPixbuf *destination_pixbuf,
|
||||
|
@ -883,48 +847,310 @@ nautilus_scalable_font_draw_text_lines (const NautilusScalableFont *font,
|
|||
ArtIRect area;
|
||||
|
||||
g_assert (text_lines[i] != NULL);
|
||||
g_assert (text_line_widths[i] > 0);
|
||||
g_assert (text_line_heights[i] > 0);
|
||||
|
||||
switch (justification) {
|
||||
case GTK_JUSTIFY_LEFT:
|
||||
area.x0 = x;
|
||||
break;
|
||||
|
||||
case GTK_JUSTIFY_CENTER:
|
||||
case GTK_JUSTIFY_FILL:
|
||||
if (text_line_widths[i] <= available_width) {
|
||||
area.x0 = x + ((available_width - text_line_widths[i]) / 2);
|
||||
}
|
||||
else {
|
||||
area.x0 = x - ((text_line_widths[i] - available_width) / 2);
|
||||
}
|
||||
break;
|
||||
|
||||
case GTK_JUSTIFY_RIGHT:
|
||||
area.x0 = x + available_width - text_line_widths[i];
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
if (text_line_widths[i] == 0 && text_line_heights[i] == 0) {
|
||||
y += font_height;
|
||||
}
|
||||
else {
|
||||
switch (justification) {
|
||||
case GTK_JUSTIFY_LEFT:
|
||||
area.x0 = x;
|
||||
break;
|
||||
|
||||
case GTK_JUSTIFY_CENTER:
|
||||
case GTK_JUSTIFY_FILL:
|
||||
if (text_line_widths[i] <= available_width) {
|
||||
area.x0 = x + ((available_width - text_line_widths[i]) / 2);
|
||||
}
|
||||
else {
|
||||
area.x0 = x - ((text_line_widths[i] - available_width) / 2);
|
||||
}
|
||||
break;
|
||||
|
||||
area.x1 = area.x0 + text_line_widths[i];
|
||||
area.y0 = y;
|
||||
area.y1 = area.y0 + text_line_heights[i];
|
||||
|
||||
nautilus_scalable_font_draw_text (font,
|
||||
destination_pixbuf,
|
||||
&area,
|
||||
font_width,
|
||||
font_height,
|
||||
text_lines[i],
|
||||
color,
|
||||
overall_alpha);
|
||||
|
||||
y += (line_offset + text_line_heights[i]);
|
||||
case GTK_JUSTIFY_RIGHT:
|
||||
area.x0 = x + available_width - text_line_widths[i];
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
area.x1 = area.x0 + text_line_widths[i];
|
||||
area.y0 = y;
|
||||
area.y1 = area.y0 + text_line_heights[i];
|
||||
|
||||
nautilus_scalable_font_draw_text (font,
|
||||
destination_pixbuf,
|
||||
&area,
|
||||
font_width,
|
||||
font_height,
|
||||
text_lines[i],
|
||||
strlen (text_lines[i]),
|
||||
color,
|
||||
overall_alpha);
|
||||
|
||||
y += (line_offset + text_line_heights[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
void
|
||||
nautilus_scalable_font_measure_text_lines (NautilusScalableFont *font,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text,
|
||||
guint num_text_lines,
|
||||
guint text_line_widths[],
|
||||
guint text_line_heights[],
|
||||
guint *max_width_out,
|
||||
guint *total_height_out)
|
||||
{
|
||||
guint i;
|
||||
const char *line;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_SCALABLE_FONT (font));
|
||||
g_return_if_fail (font_width > 0);
|
||||
g_return_if_fail (font_height > 0);
|
||||
g_return_if_fail (text != NULL);
|
||||
g_return_if_fail (text_line_widths != NULL);
|
||||
g_return_if_fail (text_line_heights != NULL);
|
||||
g_return_if_fail (num_text_lines > 0);
|
||||
g_return_if_fail (num_text_lines <= (nautilus_str_count_characters (text, '\n') + 1));
|
||||
|
||||
if (max_width_out != NULL) {
|
||||
*max_width_out = 0;
|
||||
}
|
||||
|
||||
if (total_height_out != NULL) {
|
||||
*total_height_out = 0;
|
||||
}
|
||||
|
||||
line = text;
|
||||
|
||||
/*
|
||||
* We can safely iterate for 'num_text_lines' since we already checked that the
|
||||
* string does indeed contain as many lines.
|
||||
*/
|
||||
for (i = 0; i < num_text_lines; i++) {
|
||||
const char *next_new_line;
|
||||
guint length;
|
||||
|
||||
g_assert (line != NULL);
|
||||
|
||||
/* Look for the next new line */
|
||||
next_new_line = strchr (line, '\n');
|
||||
|
||||
if (next_new_line != NULL) {
|
||||
length = (next_new_line - line);
|
||||
}
|
||||
else {
|
||||
length = strlen (line);
|
||||
}
|
||||
|
||||
/* Deal with empty lines */
|
||||
if (length == 0) {
|
||||
text_line_widths[i] = 0;
|
||||
text_line_heights[i] = font_height;
|
||||
}
|
||||
else {
|
||||
nautilus_scalable_font_measure_text (font,
|
||||
font_width,
|
||||
font_height,
|
||||
line,
|
||||
length,
|
||||
&text_line_widths[i],
|
||||
&text_line_heights[i]);
|
||||
}
|
||||
|
||||
if (next_new_line != NULL) {
|
||||
line = next_new_line + 1;
|
||||
}
|
||||
else {
|
||||
line = NULL;
|
||||
}
|
||||
|
||||
/* Keep track of total height */
|
||||
if (total_height_out != NULL) {
|
||||
*total_height_out += text_line_heights[i];
|
||||
}
|
||||
|
||||
/* Keep track of max width */
|
||||
if ((max_width_out != NULL) && (text_line_widths[i] > *max_width_out)) {
|
||||
*max_width_out = text_line_widths[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_scalable_font_draw_text_lines (const NautilusScalableFont *font,
|
||||
GdkPixbuf *destination_pixbuf,
|
||||
const ArtIRect *destination_area,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text,
|
||||
guint num_text_lines,
|
||||
const guint text_line_widths[],
|
||||
const guint text_line_heights[],
|
||||
GtkJustification justification,
|
||||
guint line_offset,
|
||||
guint32 color,
|
||||
guchar overall_alpha)
|
||||
{
|
||||
guint i;
|
||||
const char *line;
|
||||
|
||||
gint x;
|
||||
gint y;
|
||||
|
||||
guint available_width;
|
||||
guint available_height;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_SCALABLE_FONT (font));
|
||||
g_return_if_fail (destination_pixbuf != NULL);
|
||||
g_return_if_fail (destination_area != NULL);
|
||||
g_return_if_fail (font_width > 0);
|
||||
g_return_if_fail (font_height > 0);
|
||||
g_return_if_fail (text_line_widths != NULL);
|
||||
g_return_if_fail (text_line_heights != NULL);
|
||||
g_return_if_fail (justification >= GTK_JUSTIFY_LEFT && justification <= GTK_JUSTIFY_FILL);
|
||||
g_return_if_fail (destination_area->x1 > destination_area->x0);
|
||||
g_return_if_fail (destination_area->y1 > destination_area->y0);
|
||||
g_return_if_fail (num_text_lines > 0);
|
||||
g_return_if_fail (num_text_lines <= (nautilus_str_count_characters (text, '\n') + 1));
|
||||
|
||||
x = destination_area->x0;
|
||||
y = destination_area->y0;
|
||||
|
||||
available_width = destination_area->x1 - destination_area->x0;
|
||||
available_height = destination_area->y1 - destination_area->y0;
|
||||
|
||||
line = text;
|
||||
|
||||
/*
|
||||
* We can safely iterate for 'num_text_lines' since we already checked that the
|
||||
* string does indeed contain as many lines.
|
||||
*/
|
||||
for (i = 0; i < num_text_lines; i++) {
|
||||
const char *next_new_line;
|
||||
guint length;
|
||||
|
||||
g_assert (line != NULL);
|
||||
|
||||
/* Look for the next new line */
|
||||
next_new_line = strchr (line, '\n');
|
||||
|
||||
if (next_new_line != NULL) {
|
||||
length = (next_new_line - line);
|
||||
}
|
||||
else {
|
||||
length = strlen (line);
|
||||
}
|
||||
|
||||
/* Deal with empty lines */
|
||||
if (length == 0) {
|
||||
y += font_height;
|
||||
}
|
||||
else {
|
||||
ArtIRect area;
|
||||
|
||||
switch (justification) {
|
||||
case GTK_JUSTIFY_LEFT:
|
||||
area.x0 = x;
|
||||
break;
|
||||
|
||||
case GTK_JUSTIFY_CENTER:
|
||||
case GTK_JUSTIFY_FILL:
|
||||
if (text_line_widths[i] <= available_width) {
|
||||
area.x0 = x + ((available_width - text_line_widths[i]) / 2);
|
||||
}
|
||||
else {
|
||||
area.x0 = x - ((text_line_widths[i] - available_width) / 2);
|
||||
}
|
||||
break;
|
||||
|
||||
case GTK_JUSTIFY_RIGHT:
|
||||
area.x0 = x + available_width - text_line_widths[i];
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
area.x1 = area.x0 + text_line_widths[i];
|
||||
area.y0 = y;
|
||||
area.y1 = area.y0 + text_line_heights[i];
|
||||
|
||||
nautilus_scalable_font_draw_text (font,
|
||||
destination_pixbuf,
|
||||
&area,
|
||||
font_width,
|
||||
font_height,
|
||||
line,
|
||||
length,
|
||||
color,
|
||||
overall_alpha);
|
||||
|
||||
y += (line_offset + text_line_heights[i]);
|
||||
}
|
||||
|
||||
if (next_new_line != NULL) {
|
||||
line = next_new_line + 1;
|
||||
}
|
||||
else {
|
||||
line = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
guint
|
||||
nautilus_scalable_font_largest_fitting_font_size (const NautilusScalableFont *font,
|
||||
const char *text,
|
||||
guint available_width,
|
||||
const guint font_sizes[],
|
||||
guint num_font_sizes)
|
||||
{
|
||||
NautilusStringList *tokenized_string;
|
||||
guint i;
|
||||
char *longest_string;
|
||||
guint longest_string_length;
|
||||
|
||||
g_return_val_if_fail (NAUTILUS_IS_SCALABLE_FONT (font), 0);
|
||||
g_return_val_if_fail (font_sizes != NULL, 0);
|
||||
g_return_val_if_fail (num_font_sizes > 0, 0);
|
||||
|
||||
if (text == NULL || text[0] == '\0' || available_width < 1) {
|
||||
return font_sizes[num_font_sizes - 1];
|
||||
}
|
||||
|
||||
tokenized_string = nautilus_string_list_new_from_tokens (text, "\n", FALSE);
|
||||
longest_string = nautilus_string_list_get_longest_string (tokenized_string);
|
||||
g_assert (longest_string != NULL);
|
||||
nautilus_string_list_free (tokenized_string);
|
||||
longest_string_length = strlen (longest_string);
|
||||
|
||||
for (i = 0; i < num_font_sizes; i++) {
|
||||
guint text_width;
|
||||
guint text_height;
|
||||
|
||||
nautilus_scalable_font_measure_text (font,
|
||||
font_sizes[i],
|
||||
font_sizes[i],
|
||||
longest_string,
|
||||
longest_string_length,
|
||||
&text_width,
|
||||
&text_height);
|
||||
|
||||
if (text_width <= available_width) {
|
||||
g_free (longest_string);
|
||||
return font_sizes[i];
|
||||
}
|
||||
}
|
||||
|
||||
g_free (longest_string);
|
||||
|
||||
return font_sizes[num_font_sizes - 1];
|
||||
}
|
||||
|
||||
NautilusScalableFont *
|
||||
nautilus_scalable_font_get_default_font (void)
|
||||
|
|
|
@ -81,35 +81,37 @@ void nautilus_scalable_font_measure_text (const N
|
|||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text,
|
||||
guint text_length,
|
||||
guint *text_width_out,
|
||||
guint *text_height_out);
|
||||
void nautilus_scalable_font_measure_text_lines (NautilusScalableFont *font,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text_lines[],
|
||||
guint num_text_lines,
|
||||
guint text_line_widths[],
|
||||
guint text_line_heights[],
|
||||
guint *max_width_out,
|
||||
guint *total_height_out);
|
||||
void nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
|
||||
GdkPixbuf *destination_pixbuf,
|
||||
const ArtIRect *destination_area,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text,
|
||||
guint text_length,
|
||||
guint32 color,
|
||||
guchar overall_alpha);
|
||||
void nautilus_scalable_font_measure_text_lines (NautilusScalableFont *font,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text,
|
||||
guint num_text_lines,
|
||||
guint text_line_widths[],
|
||||
guint text_line_heights[],
|
||||
guint *max_width_out,
|
||||
guint *total_height_out);
|
||||
void nautilus_scalable_font_draw_text_lines (const NautilusScalableFont *font,
|
||||
GdkPixbuf *destination_pixbuf,
|
||||
const ArtIRect *destination_area,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text_lines[],
|
||||
const char *text,
|
||||
guint num_text_lines,
|
||||
const guint text_line_widths[],
|
||||
const guint text_line_heights[],
|
||||
GtkJustification justification,
|
||||
const guint num_lines,
|
||||
guint line_offset,
|
||||
guint32 color,
|
||||
guchar overall_alpha);
|
||||
|
|
|
@ -61,7 +61,6 @@ struct _NautilusLabelDetail
|
|||
guint font_size;
|
||||
|
||||
/* Text lines */
|
||||
char **text_lines;
|
||||
guint *text_line_widths;
|
||||
guint *text_line_heights;
|
||||
guint num_text_lines;
|
||||
|
@ -159,7 +158,6 @@ nautilus_label_initialize (NautilusLabel *label)
|
|||
label->detail->num_text_lines = 0;
|
||||
label->detail->max_text_line_width = 0;
|
||||
label->detail->total_text_line_height = 0;
|
||||
label->detail->text_lines = NULL;
|
||||
label->detail->text_line_widths = NULL;
|
||||
label->detail->text_line_heights = NULL;
|
||||
|
||||
|
@ -180,7 +178,6 @@ nautilus_label_destroy (GtkObject *object)
|
|||
|
||||
g_free (label->detail->text);
|
||||
|
||||
g_strfreev (label->detail->text_lines);
|
||||
g_free (label->detail->text_line_widths);
|
||||
g_free (label->detail->text_line_heights);
|
||||
|
||||
|
@ -358,11 +355,11 @@ render_buffer_pixbuf (NautilusBufferedWidget *buffered_widget,
|
|||
&area,
|
||||
label->detail->font_size,
|
||||
label->detail->font_size,
|
||||
(const char **) label->detail->text_lines,
|
||||
label->detail->text,
|
||||
label->detail->num_text_lines,
|
||||
label->detail->text_line_widths,
|
||||
label->detail->text_line_heights,
|
||||
label->detail->text_justification,
|
||||
label->detail->num_text_lines,
|
||||
label->detail->line_offset,
|
||||
label->detail->drop_shadow_color,
|
||||
label->detail->text_alpha);
|
||||
|
@ -379,11 +376,11 @@ render_buffer_pixbuf (NautilusBufferedWidget *buffered_widget,
|
|||
&area,
|
||||
label->detail->font_size,
|
||||
label->detail->font_size,
|
||||
(const char **) label->detail->text_lines,
|
||||
label->detail->text,
|
||||
label->detail->num_text_lines,
|
||||
label->detail->text_line_widths,
|
||||
label->detail->text_line_heights,
|
||||
label->detail->text_justification,
|
||||
label->detail->num_text_lines,
|
||||
label->detail->line_offset,
|
||||
label->detail->text_color,
|
||||
label->detail->text_alpha);
|
||||
|
@ -396,10 +393,8 @@ label_recompute_line_geometries (NautilusLabel *label)
|
|||
{
|
||||
g_return_if_fail (NAUTILUS_IS_LABEL (label));
|
||||
|
||||
g_strfreev (label->detail->text_lines);
|
||||
g_free (label->detail->text_line_widths);
|
||||
g_free (label->detail->text_line_heights);
|
||||
label->detail->text_lines = NULL;
|
||||
label->detail->text_line_widths = NULL;
|
||||
label->detail->text_line_heights = NULL;
|
||||
|
||||
|
@ -408,20 +403,16 @@ label_recompute_line_geometries (NautilusLabel *label)
|
|||
label->detail->max_text_line_width = 0;
|
||||
label->detail->total_text_line_height = 0;
|
||||
|
||||
label->detail->text_lines = NULL;
|
||||
|
||||
if (nautilus_strlen (label->detail->text) > 0) {
|
||||
label->detail->num_text_lines = nautilus_str_count_characters (label->detail->text, '\n') + 1;
|
||||
|
||||
label->detail->text_lines = g_strsplit (label->detail->text, "\n", -1);
|
||||
|
||||
label->detail->text_line_widths = g_new (guint, label->detail->num_text_lines);
|
||||
label->detail->text_line_heights = g_new (guint, label->detail->num_text_lines);
|
||||
|
||||
nautilus_scalable_font_measure_text_lines (label->detail->font,
|
||||
label->detail->font_size,
|
||||
label->detail->font_size,
|
||||
(const char **) label->detail->text_lines,
|
||||
label->detail->text,
|
||||
label->detail->num_text_lines,
|
||||
label->detail->text_line_widths,
|
||||
label->detail->text_line_heights,
|
||||
|
|
|
@ -606,6 +606,7 @@ nautilus_scalable_font_measure_text (const NautilusScalableFont *font,
|
|||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text,
|
||||
guint text_length,
|
||||
guint *text_width_out,
|
||||
guint *text_height_out)
|
||||
{
|
||||
|
@ -622,10 +623,12 @@ nautilus_scalable_font_measure_text (const NautilusScalableFont *font,
|
|||
*text_width_out = 0;
|
||||
*text_height_out = 0;
|
||||
|
||||
if (text == NULL) {
|
||||
if (text == NULL || text[0] == '\0' || text_length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
g_return_if_fail (text_length <= strlen (text));
|
||||
|
||||
art_affine_identity (affine);
|
||||
|
||||
/* FIXME bugzilla.eazel.com 2544: We need to change rsvg_ft_render_string() to accept
|
||||
|
@ -635,6 +638,7 @@ nautilus_scalable_font_measure_text (const NautilusScalableFont *font,
|
|||
glyph = rsvg_ft_render_string (global_rsvg_ft_context,
|
||||
font->detail->font_handle,
|
||||
text,
|
||||
text_length,
|
||||
font_width,
|
||||
font_height,
|
||||
affine,
|
||||
|
@ -646,101 +650,6 @@ nautilus_scalable_font_measure_text (const NautilusScalableFont *font,
|
|||
rsvg_ft_glyph_unref (glyph);
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_scalable_font_measure_text_lines (NautilusScalableFont *font,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text_lines[],
|
||||
guint num_text_lines,
|
||||
guint text_line_widths[],
|
||||
guint text_line_heights[],
|
||||
guint *max_width_out,
|
||||
guint *total_height_out)
|
||||
{
|
||||
guint i;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_SCALABLE_FONT (font));
|
||||
g_return_if_fail (font_width > 0);
|
||||
g_return_if_fail (font_height > 0);
|
||||
g_return_if_fail (text_lines != NULL);
|
||||
g_return_if_fail (text_line_widths != NULL);
|
||||
g_return_if_fail (text_line_heights != NULL);
|
||||
g_return_if_fail (num_text_lines > 0);
|
||||
|
||||
if (max_width_out != NULL) {
|
||||
*max_width_out = 0;
|
||||
}
|
||||
|
||||
if (total_height_out != NULL) {
|
||||
*total_height_out = 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < num_text_lines; i++) {
|
||||
g_assert (text_lines[i] != NULL);
|
||||
|
||||
nautilus_scalable_font_measure_text (font,
|
||||
font_width,
|
||||
font_height,
|
||||
text_lines[i],
|
||||
&text_line_widths[i],
|
||||
&text_line_heights[i]);
|
||||
|
||||
if (total_height_out != NULL) {
|
||||
*total_height_out += text_line_heights[i];
|
||||
}
|
||||
|
||||
if ((max_width_out != NULL) && (text_line_widths[i] > *max_width_out)) {
|
||||
*max_width_out = text_line_widths[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
guint
|
||||
nautilus_scalable_font_largest_fitting_font_size (const NautilusScalableFont *font,
|
||||
const char *text,
|
||||
guint available_width,
|
||||
const guint font_sizes[],
|
||||
guint num_font_sizes)
|
||||
{
|
||||
NautilusStringList *tokenized_string;
|
||||
guint i;
|
||||
char *longest_string;
|
||||
|
||||
g_return_val_if_fail (NAUTILUS_IS_SCALABLE_FONT (font), 0);
|
||||
g_return_val_if_fail (font_sizes != NULL, 0);
|
||||
g_return_val_if_fail (num_font_sizes > 0, 0);
|
||||
|
||||
if (text == NULL || text[0] == '\0' || available_width < 1) {
|
||||
return font_sizes[num_font_sizes - 1];
|
||||
}
|
||||
|
||||
tokenized_string = nautilus_string_list_new_from_tokens (text, "\n", FALSE);
|
||||
longest_string = nautilus_string_list_get_longest_string (tokenized_string);
|
||||
g_assert (longest_string != NULL);
|
||||
nautilus_string_list_free (tokenized_string);
|
||||
|
||||
for (i = 0; i < num_font_sizes; i++) {
|
||||
guint text_width;
|
||||
guint text_height;
|
||||
|
||||
nautilus_scalable_font_measure_text (font,
|
||||
font_sizes[i],
|
||||
font_sizes[i],
|
||||
longest_string,
|
||||
&text_width,
|
||||
&text_height);
|
||||
|
||||
if (text_width <= available_width) {
|
||||
g_free (longest_string);
|
||||
return font_sizes[i];
|
||||
}
|
||||
}
|
||||
|
||||
g_free (longest_string);
|
||||
|
||||
return font_sizes[num_font_sizes - 1];
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
|
||||
GdkPixbuf *destination_pixbuf,
|
||||
|
@ -748,6 +657,7 @@ nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
|
|||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text,
|
||||
guint text_length,
|
||||
guint32 color,
|
||||
guchar overall_alpha)
|
||||
{
|
||||
|
@ -774,15 +684,18 @@ nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
|
|||
g_return_if_fail (font_width > 0);
|
||||
g_return_if_fail (font_height > 0);
|
||||
|
||||
if (text == NULL) {
|
||||
if (text == NULL || text[0] == '\0' || text_length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
g_return_if_fail (text_length <= strlen (text));
|
||||
|
||||
art_affine_identity (affine);
|
||||
|
||||
glyph = rsvg_ft_render_string (global_rsvg_ft_context,
|
||||
font->detail->font_handle,
|
||||
text,
|
||||
text_length,
|
||||
font_width,
|
||||
font_height,
|
||||
affine,
|
||||
|
@ -837,6 +750,57 @@ nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
|
|||
rsvg_ft_glyph_unref (glyph);
|
||||
}
|
||||
|
||||
#if 0
|
||||
void
|
||||
nautilus_scalable_font_measure_text_lines (NautilusScalableFont *font,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text_lines[],
|
||||
guint num_text_lines,
|
||||
guint text_line_widths[],
|
||||
guint text_line_heights[],
|
||||
guint *max_width_out,
|
||||
guint *total_height_out)
|
||||
{
|
||||
guint i;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_SCALABLE_FONT (font));
|
||||
g_return_if_fail (font_width > 0);
|
||||
g_return_if_fail (font_height > 0);
|
||||
g_return_if_fail (text_lines != NULL);
|
||||
g_return_if_fail (text_line_widths != NULL);
|
||||
g_return_if_fail (text_line_heights != NULL);
|
||||
g_return_if_fail (num_text_lines > 0);
|
||||
|
||||
if (max_width_out != NULL) {
|
||||
*max_width_out = 0;
|
||||
}
|
||||
|
||||
if (total_height_out != NULL) {
|
||||
*total_height_out = 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < num_text_lines; i++) {
|
||||
g_assert (text_lines[i] != NULL);
|
||||
|
||||
nautilus_scalable_font_measure_text (font,
|
||||
font_width,
|
||||
font_height,
|
||||
text_lines[i],
|
||||
strlen (text_lines[i]),
|
||||
&text_line_widths[i],
|
||||
&text_line_heights[i]);
|
||||
|
||||
if (total_height_out != NULL) {
|
||||
*total_height_out += text_line_heights[i];
|
||||
}
|
||||
|
||||
if ((max_width_out != NULL) && (text_line_widths[i] > *max_width_out)) {
|
||||
*max_width_out = text_line_widths[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_scalable_font_draw_text_lines (const NautilusScalableFont *font,
|
||||
GdkPixbuf *destination_pixbuf,
|
||||
|
@ -883,48 +847,310 @@ nautilus_scalable_font_draw_text_lines (const NautilusScalableFont *font,
|
|||
ArtIRect area;
|
||||
|
||||
g_assert (text_lines[i] != NULL);
|
||||
g_assert (text_line_widths[i] > 0);
|
||||
g_assert (text_line_heights[i] > 0);
|
||||
|
||||
switch (justification) {
|
||||
case GTK_JUSTIFY_LEFT:
|
||||
area.x0 = x;
|
||||
break;
|
||||
|
||||
case GTK_JUSTIFY_CENTER:
|
||||
case GTK_JUSTIFY_FILL:
|
||||
if (text_line_widths[i] <= available_width) {
|
||||
area.x0 = x + ((available_width - text_line_widths[i]) / 2);
|
||||
}
|
||||
else {
|
||||
area.x0 = x - ((text_line_widths[i] - available_width) / 2);
|
||||
}
|
||||
break;
|
||||
|
||||
case GTK_JUSTIFY_RIGHT:
|
||||
area.x0 = x + available_width - text_line_widths[i];
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
if (text_line_widths[i] == 0 && text_line_heights[i] == 0) {
|
||||
y += font_height;
|
||||
}
|
||||
else {
|
||||
switch (justification) {
|
||||
case GTK_JUSTIFY_LEFT:
|
||||
area.x0 = x;
|
||||
break;
|
||||
|
||||
case GTK_JUSTIFY_CENTER:
|
||||
case GTK_JUSTIFY_FILL:
|
||||
if (text_line_widths[i] <= available_width) {
|
||||
area.x0 = x + ((available_width - text_line_widths[i]) / 2);
|
||||
}
|
||||
else {
|
||||
area.x0 = x - ((text_line_widths[i] - available_width) / 2);
|
||||
}
|
||||
break;
|
||||
|
||||
area.x1 = area.x0 + text_line_widths[i];
|
||||
area.y0 = y;
|
||||
area.y1 = area.y0 + text_line_heights[i];
|
||||
|
||||
nautilus_scalable_font_draw_text (font,
|
||||
destination_pixbuf,
|
||||
&area,
|
||||
font_width,
|
||||
font_height,
|
||||
text_lines[i],
|
||||
color,
|
||||
overall_alpha);
|
||||
|
||||
y += (line_offset + text_line_heights[i]);
|
||||
case GTK_JUSTIFY_RIGHT:
|
||||
area.x0 = x + available_width - text_line_widths[i];
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
area.x1 = area.x0 + text_line_widths[i];
|
||||
area.y0 = y;
|
||||
area.y1 = area.y0 + text_line_heights[i];
|
||||
|
||||
nautilus_scalable_font_draw_text (font,
|
||||
destination_pixbuf,
|
||||
&area,
|
||||
font_width,
|
||||
font_height,
|
||||
text_lines[i],
|
||||
strlen (text_lines[i]),
|
||||
color,
|
||||
overall_alpha);
|
||||
|
||||
y += (line_offset + text_line_heights[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
void
|
||||
nautilus_scalable_font_measure_text_lines (NautilusScalableFont *font,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text,
|
||||
guint num_text_lines,
|
||||
guint text_line_widths[],
|
||||
guint text_line_heights[],
|
||||
guint *max_width_out,
|
||||
guint *total_height_out)
|
||||
{
|
||||
guint i;
|
||||
const char *line;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_SCALABLE_FONT (font));
|
||||
g_return_if_fail (font_width > 0);
|
||||
g_return_if_fail (font_height > 0);
|
||||
g_return_if_fail (text != NULL);
|
||||
g_return_if_fail (text_line_widths != NULL);
|
||||
g_return_if_fail (text_line_heights != NULL);
|
||||
g_return_if_fail (num_text_lines > 0);
|
||||
g_return_if_fail (num_text_lines <= (nautilus_str_count_characters (text, '\n') + 1));
|
||||
|
||||
if (max_width_out != NULL) {
|
||||
*max_width_out = 0;
|
||||
}
|
||||
|
||||
if (total_height_out != NULL) {
|
||||
*total_height_out = 0;
|
||||
}
|
||||
|
||||
line = text;
|
||||
|
||||
/*
|
||||
* We can safely iterate for 'num_text_lines' since we already checked that the
|
||||
* string does indeed contain as many lines.
|
||||
*/
|
||||
for (i = 0; i < num_text_lines; i++) {
|
||||
const char *next_new_line;
|
||||
guint length;
|
||||
|
||||
g_assert (line != NULL);
|
||||
|
||||
/* Look for the next new line */
|
||||
next_new_line = strchr (line, '\n');
|
||||
|
||||
if (next_new_line != NULL) {
|
||||
length = (next_new_line - line);
|
||||
}
|
||||
else {
|
||||
length = strlen (line);
|
||||
}
|
||||
|
||||
/* Deal with empty lines */
|
||||
if (length == 0) {
|
||||
text_line_widths[i] = 0;
|
||||
text_line_heights[i] = font_height;
|
||||
}
|
||||
else {
|
||||
nautilus_scalable_font_measure_text (font,
|
||||
font_width,
|
||||
font_height,
|
||||
line,
|
||||
length,
|
||||
&text_line_widths[i],
|
||||
&text_line_heights[i]);
|
||||
}
|
||||
|
||||
if (next_new_line != NULL) {
|
||||
line = next_new_line + 1;
|
||||
}
|
||||
else {
|
||||
line = NULL;
|
||||
}
|
||||
|
||||
/* Keep track of total height */
|
||||
if (total_height_out != NULL) {
|
||||
*total_height_out += text_line_heights[i];
|
||||
}
|
||||
|
||||
/* Keep track of max width */
|
||||
if ((max_width_out != NULL) && (text_line_widths[i] > *max_width_out)) {
|
||||
*max_width_out = text_line_widths[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_scalable_font_draw_text_lines (const NautilusScalableFont *font,
|
||||
GdkPixbuf *destination_pixbuf,
|
||||
const ArtIRect *destination_area,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text,
|
||||
guint num_text_lines,
|
||||
const guint text_line_widths[],
|
||||
const guint text_line_heights[],
|
||||
GtkJustification justification,
|
||||
guint line_offset,
|
||||
guint32 color,
|
||||
guchar overall_alpha)
|
||||
{
|
||||
guint i;
|
||||
const char *line;
|
||||
|
||||
gint x;
|
||||
gint y;
|
||||
|
||||
guint available_width;
|
||||
guint available_height;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_SCALABLE_FONT (font));
|
||||
g_return_if_fail (destination_pixbuf != NULL);
|
||||
g_return_if_fail (destination_area != NULL);
|
||||
g_return_if_fail (font_width > 0);
|
||||
g_return_if_fail (font_height > 0);
|
||||
g_return_if_fail (text_line_widths != NULL);
|
||||
g_return_if_fail (text_line_heights != NULL);
|
||||
g_return_if_fail (justification >= GTK_JUSTIFY_LEFT && justification <= GTK_JUSTIFY_FILL);
|
||||
g_return_if_fail (destination_area->x1 > destination_area->x0);
|
||||
g_return_if_fail (destination_area->y1 > destination_area->y0);
|
||||
g_return_if_fail (num_text_lines > 0);
|
||||
g_return_if_fail (num_text_lines <= (nautilus_str_count_characters (text, '\n') + 1));
|
||||
|
||||
x = destination_area->x0;
|
||||
y = destination_area->y0;
|
||||
|
||||
available_width = destination_area->x1 - destination_area->x0;
|
||||
available_height = destination_area->y1 - destination_area->y0;
|
||||
|
||||
line = text;
|
||||
|
||||
/*
|
||||
* We can safely iterate for 'num_text_lines' since we already checked that the
|
||||
* string does indeed contain as many lines.
|
||||
*/
|
||||
for (i = 0; i < num_text_lines; i++) {
|
||||
const char *next_new_line;
|
||||
guint length;
|
||||
|
||||
g_assert (line != NULL);
|
||||
|
||||
/* Look for the next new line */
|
||||
next_new_line = strchr (line, '\n');
|
||||
|
||||
if (next_new_line != NULL) {
|
||||
length = (next_new_line - line);
|
||||
}
|
||||
else {
|
||||
length = strlen (line);
|
||||
}
|
||||
|
||||
/* Deal with empty lines */
|
||||
if (length == 0) {
|
||||
y += font_height;
|
||||
}
|
||||
else {
|
||||
ArtIRect area;
|
||||
|
||||
switch (justification) {
|
||||
case GTK_JUSTIFY_LEFT:
|
||||
area.x0 = x;
|
||||
break;
|
||||
|
||||
case GTK_JUSTIFY_CENTER:
|
||||
case GTK_JUSTIFY_FILL:
|
||||
if (text_line_widths[i] <= available_width) {
|
||||
area.x0 = x + ((available_width - text_line_widths[i]) / 2);
|
||||
}
|
||||
else {
|
||||
area.x0 = x - ((text_line_widths[i] - available_width) / 2);
|
||||
}
|
||||
break;
|
||||
|
||||
case GTK_JUSTIFY_RIGHT:
|
||||
area.x0 = x + available_width - text_line_widths[i];
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
area.x1 = area.x0 + text_line_widths[i];
|
||||
area.y0 = y;
|
||||
area.y1 = area.y0 + text_line_heights[i];
|
||||
|
||||
nautilus_scalable_font_draw_text (font,
|
||||
destination_pixbuf,
|
||||
&area,
|
||||
font_width,
|
||||
font_height,
|
||||
line,
|
||||
length,
|
||||
color,
|
||||
overall_alpha);
|
||||
|
||||
y += (line_offset + text_line_heights[i]);
|
||||
}
|
||||
|
||||
if (next_new_line != NULL) {
|
||||
line = next_new_line + 1;
|
||||
}
|
||||
else {
|
||||
line = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
guint
|
||||
nautilus_scalable_font_largest_fitting_font_size (const NautilusScalableFont *font,
|
||||
const char *text,
|
||||
guint available_width,
|
||||
const guint font_sizes[],
|
||||
guint num_font_sizes)
|
||||
{
|
||||
NautilusStringList *tokenized_string;
|
||||
guint i;
|
||||
char *longest_string;
|
||||
guint longest_string_length;
|
||||
|
||||
g_return_val_if_fail (NAUTILUS_IS_SCALABLE_FONT (font), 0);
|
||||
g_return_val_if_fail (font_sizes != NULL, 0);
|
||||
g_return_val_if_fail (num_font_sizes > 0, 0);
|
||||
|
||||
if (text == NULL || text[0] == '\0' || available_width < 1) {
|
||||
return font_sizes[num_font_sizes - 1];
|
||||
}
|
||||
|
||||
tokenized_string = nautilus_string_list_new_from_tokens (text, "\n", FALSE);
|
||||
longest_string = nautilus_string_list_get_longest_string (tokenized_string);
|
||||
g_assert (longest_string != NULL);
|
||||
nautilus_string_list_free (tokenized_string);
|
||||
longest_string_length = strlen (longest_string);
|
||||
|
||||
for (i = 0; i < num_font_sizes; i++) {
|
||||
guint text_width;
|
||||
guint text_height;
|
||||
|
||||
nautilus_scalable_font_measure_text (font,
|
||||
font_sizes[i],
|
||||
font_sizes[i],
|
||||
longest_string,
|
||||
longest_string_length,
|
||||
&text_width,
|
||||
&text_height);
|
||||
|
||||
if (text_width <= available_width) {
|
||||
g_free (longest_string);
|
||||
return font_sizes[i];
|
||||
}
|
||||
}
|
||||
|
||||
g_free (longest_string);
|
||||
|
||||
return font_sizes[num_font_sizes - 1];
|
||||
}
|
||||
|
||||
NautilusScalableFont *
|
||||
nautilus_scalable_font_get_default_font (void)
|
||||
|
|
|
@ -81,35 +81,37 @@ void nautilus_scalable_font_measure_text (const N
|
|||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text,
|
||||
guint text_length,
|
||||
guint *text_width_out,
|
||||
guint *text_height_out);
|
||||
void nautilus_scalable_font_measure_text_lines (NautilusScalableFont *font,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text_lines[],
|
||||
guint num_text_lines,
|
||||
guint text_line_widths[],
|
||||
guint text_line_heights[],
|
||||
guint *max_width_out,
|
||||
guint *total_height_out);
|
||||
void nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
|
||||
GdkPixbuf *destination_pixbuf,
|
||||
const ArtIRect *destination_area,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text,
|
||||
guint text_length,
|
||||
guint32 color,
|
||||
guchar overall_alpha);
|
||||
void nautilus_scalable_font_measure_text_lines (NautilusScalableFont *font,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text,
|
||||
guint num_text_lines,
|
||||
guint text_line_widths[],
|
||||
guint text_line_heights[],
|
||||
guint *max_width_out,
|
||||
guint *total_height_out);
|
||||
void nautilus_scalable_font_draw_text_lines (const NautilusScalableFont *font,
|
||||
GdkPixbuf *destination_pixbuf,
|
||||
const ArtIRect *destination_area,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text_lines[],
|
||||
const char *text,
|
||||
guint num_text_lines,
|
||||
const guint text_line_widths[],
|
||||
const guint text_line_heights[],
|
||||
GtkJustification justification,
|
||||
const guint num_lines,
|
||||
guint line_offset,
|
||||
guint32 color,
|
||||
guchar overall_alpha);
|
||||
|
|
|
@ -618,12 +618,13 @@ rsvg_ft_get_glyph_cached (RsvgFTCtx *ctx, RsvgFTFontHandle fh,
|
|||
**/
|
||||
RsvgFTGlyph *
|
||||
rsvg_ft_render_string (RsvgFTCtx *ctx, RsvgFTFontHandle fh,
|
||||
const char *str, double sx, double sy,
|
||||
const char *str,
|
||||
unsigned int length,
|
||||
double sx, double sy,
|
||||
const double affine[6], int xy[2])
|
||||
{
|
||||
RsvgFTFont *font;
|
||||
RsvgFTGlyph *result;
|
||||
const int len = strlen (str);
|
||||
RsvgFTGlyph **glyphs;
|
||||
int *glyph_xy;
|
||||
int i, j;
|
||||
|
@ -636,14 +637,18 @@ rsvg_ft_render_string (RsvgFTCtx *ctx, RsvgFTFontHandle fh,
|
|||
int n_glyphs;
|
||||
double init_x, init_y;
|
||||
|
||||
g_return_val_if_fail (ctx != NULL, NULL);
|
||||
g_return_val_if_fail (str != NULL, NULL);
|
||||
g_return_val_if_fail (length <= strlen (str), NULL);
|
||||
|
||||
font = rsvg_ft_font_resolve (ctx, fh);
|
||||
if (font == NULL)
|
||||
return NULL;
|
||||
|
||||
bbox.x0 = bbox.x1 = 0;
|
||||
|
||||
glyphs = g_new (RsvgFTGlyph *, len);
|
||||
glyph_xy = g_new (int, len * 2);
|
||||
glyphs = g_new (RsvgFTGlyph *, length);
|
||||
glyph_xy = g_new (int, length * 2);
|
||||
|
||||
for (j = 0; j < 6; j++)
|
||||
glyph_affine[j] = affine[j];
|
||||
|
@ -651,7 +656,7 @@ rsvg_ft_render_string (RsvgFTCtx *ctx, RsvgFTFontHandle fh,
|
|||
init_x = affine[4];
|
||||
init_y = affine[5];
|
||||
n_glyphs = 0;
|
||||
for (i = 0; i < len; i++) {
|
||||
for (i = 0; i < length; i++) {
|
||||
RsvgFTGlyph *glyph;
|
||||
|
||||
glyph_index = FT_Get_Char_Index (font->face,
|
||||
|
|
|
@ -34,7 +34,9 @@ rsvg_ft_font_unref (RsvgFTFont *font);
|
|||
|
||||
RsvgFTGlyph *
|
||||
rsvg_ft_render_string (RsvgFTCtx *ctx, RsvgFTFontHandle fh,
|
||||
const char *str, double sx, double sy,
|
||||
const char *str,
|
||||
unsigned int length,
|
||||
double sx, double sy,
|
||||
const double affine[6], int xy[2]);
|
||||
|
||||
void
|
||||
|
|
|
@ -803,7 +803,9 @@ rsvg_text_handler_characters (RsvgSaxHandler *self, const xmlChar *ch, int len)
|
|||
has_alpha ? ART_ALPHA_SEPARATE : ART_ALPHA_NONE,
|
||||
NULL);
|
||||
|
||||
glyph = rsvg_ft_render_string (ctx->ft_ctx, fh, string,
|
||||
glyph = rsvg_ft_render_string (ctx->ft_ctx, fh,
|
||||
string,
|
||||
strlen (string),
|
||||
state->font_size, state->font_size,
|
||||
state->affine, glyph_xy);
|
||||
|
||||
|
|
|
@ -132,6 +132,7 @@ static void draw_line (TestCtx *ctx, int line_num, ArtIRect *rect)
|
|||
|
||||
glyph = rsvg_ft_render_string (ctx->ctx, ctx->fh,
|
||||
ctx->lines[line_num],
|
||||
strlen (ctx->lines[line_num]),
|
||||
14, 14,
|
||||
affine,
|
||||
glyph_xy);
|
||||
|
|
|
@ -377,6 +377,7 @@ int main(int argc, char **argv)
|
|||
|
||||
glyph = rsvg_ft_render_string (ctx, fh,
|
||||
"graphic(s)",
|
||||
strlen ("graphic(s)"),
|
||||
font_width,
|
||||
font_height,
|
||||
affine,
|
||||
|
|
|
@ -192,7 +192,7 @@ draw_aa_string (NautilusScalableFont *font, GdkPixbuf *pixbuf, int font_size, in
|
|||
ArtIRect dest_rect;
|
||||
int text_width, text_height;
|
||||
|
||||
nautilus_scalable_font_measure_text (font, font_size, font_size, text, &text_width, &text_height);
|
||||
nautilus_scalable_font_measure_text (font, font_size, font_size, text, strlen (text), &text_width, &text_height);
|
||||
|
||||
/* draw the title in shadowed text*/
|
||||
|
||||
|
@ -204,13 +204,13 @@ draw_aa_string (NautilusScalableFont *font, GdkPixbuf *pixbuf, int font_size, in
|
|||
if (shadow_offset) {
|
||||
dest_rect.x0 += shadow_offset;
|
||||
dest_rect.y0 += shadow_offset;
|
||||
nautilus_scalable_font_draw_text (font, pixbuf, &dest_rect, font_size, font_size, text, shadow_color, 255);
|
||||
nautilus_scalable_font_draw_text (font, pixbuf, &dest_rect, font_size, font_size, text, strlen (text), shadow_color, 255);
|
||||
|
||||
dest_rect.x0 -= shadow_offset;
|
||||
dest_rect.y0 -= shadow_offset;
|
||||
}
|
||||
|
||||
nautilus_scalable_font_draw_text (font, pixbuf, &dest_rect, font_size, font_size, text, color, 255);
|
||||
nautilus_scalable_font_draw_text (font, pixbuf, &dest_rect, font_size, font_size, text, strlen (text), color, 255);
|
||||
}
|
||||
|
||||
/* draw the information onto the pixbuf */
|
||||
|
|
|
@ -489,8 +489,13 @@ draw_one_tab_plain (NautilusSidebarTabs *sidebar_tabs, GdkGC *gc,
|
|||
g_assert (NAUTILUS_IS_SIDEBAR_TABS (sidebar_tabs));
|
||||
|
||||
/* measure the name and compute the bounding box */
|
||||
nautilus_scalable_font_measure_text (sidebar_tabs->details->tab_font, sidebar_tabs->details->font_size, sidebar_tabs->details->font_size,
|
||||
tab_name, &name_width, &name_height);
|
||||
nautilus_scalable_font_measure_text (sidebar_tabs->details->tab_font,
|
||||
sidebar_tabs->details->font_size,
|
||||
sidebar_tabs->details->font_size,
|
||||
tab_name,
|
||||
strlen (tab_name),
|
||||
&name_width,
|
||||
&name_height);
|
||||
|
||||
total_width = name_width + 2*TAB_MARGIN;
|
||||
|
||||
|
@ -535,13 +540,15 @@ draw_one_tab_plain (NautilusSidebarTabs *sidebar_tabs, GdkGC *gc,
|
|||
|
||||
nautilus_scalable_font_draw_text (sidebar_tabs->details->tab_font, temp_pixbuf, &text_rect,
|
||||
sidebar_tabs->details->font_size, sidebar_tabs->details->font_size,
|
||||
tab_name, prelight_flag ? NAUTILUS_RGB_COLOR_WHITE : NAUTILUS_RGB_COLOR_BLACK, 255);
|
||||
tab_name, strlen (tab_name),
|
||||
prelight_flag ? NAUTILUS_RGB_COLOR_WHITE : NAUTILUS_RGB_COLOR_BLACK, 255);
|
||||
|
||||
text_rect.x0 -= 1;
|
||||
text_rect.y0 -= 1;
|
||||
nautilus_scalable_font_draw_text (sidebar_tabs->details->tab_font, temp_pixbuf, &text_rect,
|
||||
sidebar_tabs->details->font_size, sidebar_tabs->details->font_size,
|
||||
tab_name, prelight_flag ? NAUTILUS_RGB_COLOR_BLACK : NAUTILUS_RGB_COLOR_WHITE, 255);
|
||||
tab_name, strlen (tab_name),
|
||||
prelight_flag ? NAUTILUS_RGB_COLOR_BLACK : NAUTILUS_RGB_COLOR_WHITE, 255);
|
||||
|
||||
/* blit the pixbuf to the drawable, then release it */
|
||||
|
||||
|
@ -642,8 +649,13 @@ draw_one_tab_themed (NautilusSidebarTabs *sidebar_tabs, GdkPixbuf *tab_pixbuf,
|
|||
}
|
||||
|
||||
/* measure the size of the name */
|
||||
nautilus_scalable_font_measure_text (sidebar_tabs->details->tab_font, sidebar_tabs->details->font_size, sidebar_tabs->details->font_size,
|
||||
tab_name, &name_width, &name_height);
|
||||
nautilus_scalable_font_measure_text (sidebar_tabs->details->tab_font,
|
||||
sidebar_tabs->details->font_size,
|
||||
sidebar_tabs->details->font_size,
|
||||
tab_name,
|
||||
strlen (tab_name),
|
||||
&name_width,
|
||||
&name_height);
|
||||
|
||||
/* draw the left edge piece */
|
||||
current_pos = x - widget->allocation.x;
|
||||
|
@ -673,12 +685,14 @@ draw_one_tab_themed (NautilusSidebarTabs *sidebar_tabs, GdkPixbuf *tab_pixbuf,
|
|||
|
||||
nautilus_scalable_font_draw_text (sidebar_tabs->details->tab_font, tab_pixbuf, &text_rect,
|
||||
sidebar_tabs->details->font_size, sidebar_tabs->details->font_size,
|
||||
tab_name, NAUTILUS_RGB_COLOR_BLACK, 255);
|
||||
tab_name, strlen (tab_name),
|
||||
NAUTILUS_RGB_COLOR_BLACK, 255);
|
||||
text_rect.x0 -= 1;
|
||||
text_rect.y0 -= 1;
|
||||
nautilus_scalable_font_draw_text (sidebar_tabs->details->tab_font, tab_pixbuf, &text_rect,
|
||||
sidebar_tabs->details->font_size, sidebar_tabs->details->font_size,
|
||||
tab_name, NAUTILUS_RGB_COLOR_WHITE, 255);
|
||||
tab_name, strlen (tab_name),
|
||||
NAUTILUS_RGB_COLOR_WHITE, 255);
|
||||
|
||||
/* set up the bounds rectangle for later hit-testing */
|
||||
if (tab_rect) {
|
||||
|
@ -725,8 +739,13 @@ get_tab_width (NautilusSidebarTabs *sidebar_tabs, TabItem *this_tab, gboolean is
|
|||
edge_width = gdk_pixbuf_get_width (sidebar_tabs->details->tab_piece_images[TAB_NORMAL_LEFT]);
|
||||
else
|
||||
edge_width = 0;
|
||||
nautilus_scalable_font_measure_text (sidebar_tabs->details->tab_font, sidebar_tabs->details->font_size, sidebar_tabs->details->font_size,
|
||||
this_tab->tab_text, &name_width, &name_height);
|
||||
nautilus_scalable_font_measure_text (sidebar_tabs->details->tab_font,
|
||||
sidebar_tabs->details->font_size,
|
||||
sidebar_tabs->details->font_size,
|
||||
this_tab->tab_text,
|
||||
strlen (this_tab->tab_text),
|
||||
&name_width,
|
||||
&name_height);
|
||||
|
||||
} else {
|
||||
edge_width = 2 * TAB_MARGIN;
|
||||
|
|
|
@ -18,55 +18,76 @@
|
|||
#include <libnautilus-extensions/nautilus-scalable-font.h>
|
||||
#include <libnautilus-extensions/nautilus-label.h>
|
||||
#include <libnautilus-extensions/nautilus-image.h>
|
||||
#include <libnautilus-extensions/nautilus-string.h>
|
||||
|
||||
int
|
||||
main (int argc, char* argv[])
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
guint text_width;
|
||||
guint text_height;
|
||||
ArtIRect area;
|
||||
NautilusScalableFont *font;
|
||||
guint num_text_lines;
|
||||
char **text_lines;
|
||||
guint *text_line_widths;
|
||||
guint *text_line_heights;
|
||||
guint max_width_out;
|
||||
guint total_height_out;
|
||||
|
||||
const char *text = "Something";
|
||||
const guint font_width = 64;
|
||||
const guint font_height = 64;
|
||||
const char *text = "\nLine Two\n\nLine Four\n\n\nLine Seven\n";
|
||||
const guint font_width = 48;
|
||||
const guint font_height = 48;
|
||||
|
||||
const guint pixbuf_width = 500;
|
||||
const guint pixbuf_height = 700;
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
gdk_rgb_init ();
|
||||
|
||||
font = NAUTILUS_SCALABLE_FONT (nautilus_scalable_font_new ("Nimbus Sans L", NULL, NULL, NULL));
|
||||
g_assert (font != NULL);
|
||||
|
||||
nautilus_scalable_font_measure_text (font,
|
||||
font_width,
|
||||
font_height,
|
||||
text,
|
||||
&text_width,
|
||||
&text_height);
|
||||
|
||||
g_print ("size of '%s' = (%d,%d)\n", text, text_width, text_height);
|
||||
|
||||
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, 512, 256);
|
||||
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, pixbuf_width, pixbuf_height);
|
||||
g_assert (pixbuf != NULL);
|
||||
|
||||
area.x0 = 0;
|
||||
area.y0 = 0;
|
||||
|
||||
area.x1 = 512;
|
||||
area.y1 = 256;
|
||||
area.x1 = pixbuf_width;
|
||||
area.y1 = pixbuf_height;
|
||||
|
||||
nautilus_scalable_font_draw_text (font,
|
||||
pixbuf,
|
||||
&area,
|
||||
font_width,
|
||||
font_height,
|
||||
text,
|
||||
NAUTILUS_RGB_COLOR_RED,
|
||||
255);
|
||||
num_text_lines = nautilus_str_count_characters (text, '\n') + 1;
|
||||
|
||||
g_assert (pixbuf != NULL);
|
||||
text_lines = g_strsplit (text, "\n", -1);
|
||||
|
||||
text_line_widths = g_new (guint, num_text_lines);
|
||||
text_line_heights = g_new (guint, num_text_lines);
|
||||
|
||||
nautilus_scalable_font_measure_text_lines (font,
|
||||
font_width,
|
||||
font_height,
|
||||
text,
|
||||
num_text_lines,
|
||||
text_line_widths,
|
||||
text_line_heights,
|
||||
&max_width_out,
|
||||
&total_height_out);
|
||||
|
||||
g_print ("max_width = %d, total_height = %d\n", max_width_out, total_height_out);
|
||||
|
||||
nautilus_scalable_font_draw_text_lines (font,
|
||||
pixbuf,
|
||||
&area,
|
||||
font_width,
|
||||
font_height,
|
||||
text,
|
||||
num_text_lines,
|
||||
text_line_widths,
|
||||
text_line_heights,
|
||||
GTK_JUSTIFY_LEFT,
|
||||
2,
|
||||
NAUTILUS_RGB_COLOR_RED,
|
||||
255);
|
||||
|
||||
nautilus_gdk_pixbuf_save_to_file (pixbuf, "font_test.png");
|
||||
|
||||
g_print ("saving test png file to font_test.png\n");
|
||||
|
|
|
@ -196,7 +196,7 @@ alpha_background_color_value_changed_callback (GtkAdjustment *adjustment, gpoint
|
|||
|
||||
g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment));
|
||||
g_return_if_fail (NAUTILUS_IS_LABEL (client_data));
|
||||
|
||||
|
||||
label = NAUTILUS_LABEL (client_data);
|
||||
|
||||
nautilus_label_set_text_alpha (NAUTILUS_LABEL (label), (guchar) adjustment->value);
|
||||
|
@ -753,7 +753,7 @@ main (int argc, char* argv[])
|
|||
main_box = gtk_vbox_new (FALSE, 0);
|
||||
gtk_container_add (GTK_CONTAINER (window), main_box);
|
||||
|
||||
label = nautilus_label_new ("Label that \ndoesn't suck\nFoo\nBar");
|
||||
label = nautilus_label_new ("Label that\n\ndoesn't\n\nsuck");
|
||||
|
||||
bottom_box = gtk_vbox_new (FALSE, 4);
|
||||
|
||||
|
|
Loading…
Reference in a new issue