diff options
Diffstat (limited to 'demos')
-rw-r--r-- | demos/gtk-demo/fontify.c | 8 | ||||
-rw-r--r-- | demos/gtk-demo/fontrendering.c | 12 | ||||
-rw-r--r-- | demos/gtk-demo/printing.c | 17 | ||||
-rw-r--r-- | demos/gtk-demo/rotated_text.c | 7 | ||||
-rw-r--r-- | demos/print-editor/print-editor.c | 14 |
5 files changed, 37 insertions, 21 deletions
diff --git a/demos/gtk-demo/fontify.c b/demos/gtk-demo/fontify.c index cdbdf654d3..888890e194 100644 --- a/demos/gtk-demo/fontify.c +++ b/demos/gtk-demo/fontify.c @@ -275,6 +275,10 @@ insert_tags_for_attributes (GtkTextBuffer *buffer, case PANGO_ATTR_ABSOLUTE_LINE_HEIGHT: break; + case PANGO_ATTR_LINE_SPACING: + INT_ATTR (pixels_inside_wrap); + break; + case PANGO_ATTR_WORD: VOID_ATTR (word); break; @@ -283,6 +287,10 @@ insert_tags_for_attributes (GtkTextBuffer *buffer, VOID_ATTR (sentence); break; + case PANGO_ATTR_PARAGRAPH: + VOID_ATTR (paragraph); + break; + case PANGO_ATTR_BASELINE_SHIFT: INT_ATTR (baseline_shift); break; diff --git a/demos/gtk-demo/fontrendering.c b/demos/gtk-demo/fontrendering.c index 283523f481..410ca3fe3d 100644 --- a/demos/gtk-demo/fontrendering.c +++ b/demos/gtk-demo/fontrendering.c @@ -95,8 +95,8 @@ update_image (void) layout = pango_layout_new (context); pango_layout_set_font_description (layout, desc); pango_layout_set_text (layout, text, -1); - pango_layout_get_extents (layout, &ink, &logical); - baseline = pango_layout_get_baseline (layout); + pango_lines_get_extents (pango_layout_get_lines (layout), &ink, &logical); + baseline = pango_lines_get_baseline (pango_layout_get_lines (layout)); pango_extents_to_pixels (&ink, NULL); @@ -208,6 +208,7 @@ update_image (void) { PangoLayoutIter *iter; PangoLayoutRun *run; + PangoGlyphString *glyphs; PangoGlyphInfo *g; int i, j; GString *str; @@ -230,7 +231,7 @@ update_image (void) pango_layout_set_font_description (layout, desc); pango_layout_set_text (layout, str->str, -1); g_string_free (str, TRUE); - pango_layout_get_extents (layout, &ink, &logical); + pango_lines_get_extents (pango_layout_get_lines (layout), &ink, &logical); pango_extents_to_pixels (&logical, NULL); surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, logical.width * 3 / 2, 4*logical.height); @@ -240,11 +241,12 @@ update_image (void) iter = pango_layout_get_iter (layout); run = pango_layout_iter_get_run (iter); + glyphs = pango_layout_run_get_glyphs (run); cairo_set_source_rgb (cr, 0, 0, 0); for (i = 0; i < 4; i++) { - g = &(run->glyphs->glyphs[2*i]); + g = &(glyphs->glyphs[2*i]); g->geometry.width = PANGO_UNITS_ROUND (g->geometry.width * 3 / 2); } @@ -252,7 +254,7 @@ update_image (void) { for (i = 0; i < 4; i++) { - g = &(run->glyphs->glyphs[2*i]); + g = &(glyphs->glyphs[2*i]); g->geometry.x_offset = i * (PANGO_SCALE / 4); g->geometry.y_offset = j * (PANGO_SCALE / 4); } diff --git a/demos/gtk-demo/printing.c b/demos/gtk-demo/printing.c index beef569f25..2633f8a3aa 100644 --- a/demos/gtk-demo/printing.c +++ b/demos/gtk-demo/printing.c @@ -60,7 +60,7 @@ draw_page (GtkPrintOperation *operation, PrintData *data = (PrintData *)user_data; cairo_t *cr; PangoLayout *layout; - int text_width, text_height; + PangoRectangle ext; double width; int line, i; PangoFontDescription *desc; @@ -85,16 +85,18 @@ draw_page (GtkPrintOperation *operation, pango_font_description_free (desc); pango_layout_set_text (layout, data->resourcename, -1); - pango_layout_get_pixel_size (layout, &text_width, &text_height); + pango_lines_get_extents (pango_layout_get_lines (layout), NULL, &ext); + pango_extents_to_pixels (&ext, NULL); - if (text_width > width) + if (ext.width > width) { pango_layout_set_width (layout, width); pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_START); - pango_layout_get_pixel_size (layout, &text_width, &text_height); + pango_lines_get_extents (pango_layout_get_lines (layout), NULL, &ext); + pango_extents_to_pixels (&ext, NULL); } - cairo_move_to (cr, (width - text_width) / 2, (HEADER_HEIGHT - text_height) / 2); + cairo_move_to (cr, (width - ext.width) / 2, (HEADER_HEIGHT - ext.height) / 2); pango_cairo_show_layout (cr, layout); page_str = g_strdup_printf ("%d/%d", page_nr + 1, data->num_pages); @@ -102,8 +104,9 @@ draw_page (GtkPrintOperation *operation, g_free (page_str); pango_layout_set_width (layout, -1); - pango_layout_get_pixel_size (layout, &text_width, &text_height); - cairo_move_to (cr, width - text_width - 4, (HEADER_HEIGHT - text_height) / 2); + pango_lines_get_extents (pango_layout_get_lines (layout), NULL, &ext); + pango_extents_to_pixels (&ext, NULL); + cairo_move_to (cr, width - ext.width - 4, (HEADER_HEIGHT - ext.height) / 2); pango_cairo_show_layout (cr, layout); g_object_unref (layout); diff --git a/demos/gtk-demo/rotated_text.c b/demos/gtk-demo/rotated_text.c index 4f2c3f9513..16a7131705 100644 --- a/demos/gtk-demo/rotated_text.c +++ b/demos/gtk-demo/rotated_text.c @@ -142,13 +142,14 @@ rotated_text_draw (GtkDrawingArea *da, /* Draw the layout N_WORDS times in a circle */ for (i = 0; i < N_WORDS; i++) { - int layout_width, layout_height; + PangoRectangle ext; /* Inform Pango to re-layout the text with the new transformation matrix */ pango_cairo_update_layout (cr, layout); - pango_layout_get_pixel_size (layout, &layout_width, &layout_height); - cairo_move_to (cr, - layout_width / 2, - RADIUS * .9); + pango_lines_get_extents (pango_layout_get_lines (layout), NULL, &ext); + pango_extents_to_pixels (&ext, NULL); + cairo_move_to (cr, - ext.width / 2, - RADIUS * .9); pango_cairo_show_layout (cr, layout); /* Rotate for the next turn */ diff --git a/demos/print-editor/print-editor.c b/demos/print-editor/print-editor.c index bfadd5e494..6282a4178a 100644 --- a/demos/print-editor/print-editor.c +++ b/demos/print-editor/print-editor.c @@ -212,6 +212,7 @@ begin_print (GtkPrintOperation *operation, PrintData *print_data) { PangoFontDescription *desc; + PangoLines *lines; PangoLayoutLine *layout_line; double width, height; double page_height; @@ -232,18 +233,19 @@ begin_print (GtkPrintOperation *operation, pango_layout_set_text (print_data->layout, print_data->text, -1); - num_lines = pango_layout_get_line_count (print_data->layout); + lines = pango_layout_get_lines (print_data->layout); + num_lines = pango_lines_get_line_count (lines); page_breaks = NULL; page_height = 0; for (line = 0; line < num_lines; line++) { - PangoRectangle ink_rect, logical_rect; + PangoRectangle logical_rect; double line_height; - layout_line = pango_layout_get_line (print_data->layout, line); - pango_layout_line_get_extents (layout_line, &ink_rect, &logical_rect); + layout_line = pango_lines_get_line (lines, line, NULL, NULL); + pango_layout_line_get_extents (layout_line, NULL, &logical_rect); line_height = logical_rect.height / 1024.0; @@ -284,7 +286,7 @@ draw_page (GtkPrintOperation *operation, pagebreak = g_list_nth (print_data->page_breaks, page_nr); if (pagebreak == NULL) - end = pango_layout_get_line_count (print_data->layout); + end = pango_lines_get_line_count (pango_layout_get_lines (print_data->layout)); else end = GPOINTER_TO_INT (pagebreak->data); @@ -306,7 +308,7 @@ draw_page (GtkPrintOperation *operation, line = pango_layout_iter_get_line (iter); pango_layout_iter_get_line_extents (iter, NULL, &logical_rect); - baseline = pango_layout_iter_get_baseline (iter); + baseline = pango_layout_iter_get_line_baseline (iter); if (i == start) start_pos = logical_rect.y / 1024.0; |