diff options
author | Owen Taylor <otaylor@redhat.com> | 2005-02-07 05:15:50 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2005-02-07 05:15:50 +0000 |
commit | d52f78b10b8c1f29f04877d9e6e6635613f0653e (patch) | |
tree | 0c9a65265ef0d2069981eaed22572dedaa16192f | |
parent | 69f1774a7df9f7f20564d4f14ff08508d9399133 (diff) | |
download | pango-d52f78b10b8c1f29f04877d9e6e6635613f0653e.tar.gz |
Rename pango_cairo_show_glyphs() to pango_cairo_show_glyph_string(). Add
2005-02-06 Owen Taylor <otaylor@redhat.com>
* pango/pangocairo.h pango/pangocairo-render.c docs/pango-sections.txt:
Rename pango_cairo_show_glyphs() to pango_cairo_show_glyph_string().
Add pango_cairo_{glyph_string,layout_line,layout}_path()
* docs/Makefile.am (INCLUDES): Add CAIRO_CFLAGS.
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | ChangeLog.pre-1-10 | 8 | ||||
-rw-r--r-- | configure.in | 8 | ||||
-rw-r--r-- | docs/Makefile.am | 1 | ||||
-rw-r--r-- | docs/pango-sections.txt | 5 | ||||
-rw-r--r-- | docs/tmpl/pangocairo.sgml | 30 | ||||
-rw-r--r-- | modules/Makefile.am | 1 | ||||
-rw-r--r-- | modules/makefile.msc | 6 | ||||
-rw-r--r-- | pango/pangocairo-render.c | 229 | ||||
-rw-r--r-- | pango/pangocairo.h | 25 |
10 files changed, 273 insertions, 48 deletions
@@ -1,3 +1,11 @@ +2005-02-06 Owen Taylor <otaylor@redhat.com> + + * pango/pangocairo.h pango/pangocairo-render.c docs/pango-sections.txt: + Rename pango_cairo_show_glyphs() to pango_cairo_show_glyph_string(). + Add pango_cairo_{glyph_string,layout_line,layout}_path() + + * docs/Makefile.am (INCLUDES): Add CAIRO_CFLAGS. + 2005-02-06 Hans Breuer <hans@breuer.org> * pango/makefile.msc pango/*.def pango/pangocairo.def : updated to diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10 index f104e7d3..565fc3e7 100644 --- a/ChangeLog.pre-1-10 +++ b/ChangeLog.pre-1-10 @@ -1,3 +1,11 @@ +2005-02-06 Owen Taylor <otaylor@redhat.com> + + * pango/pangocairo.h pango/pangocairo-render.c docs/pango-sections.txt: + Rename pango_cairo_show_glyphs() to pango_cairo_show_glyph_string(). + Add pango_cairo_{glyph_string,layout_line,layout}_path() + + * docs/Makefile.am (INCLUDES): Add CAIRO_CFLAGS. + 2005-02-06 Hans Breuer <hans@breuer.org> * pango/makefile.msc pango/*.def pango/pangocairo.def : updated to diff --git a/configure.in b/configure.in index 4380202a..aceb8270 100644 --- a/configure.in +++ b/configure.in @@ -360,11 +360,12 @@ basic_modules="basic-fc,basic-win32,basic-x" hangul_modules="hangul-fc" hebrew_modules="hebrew-fc" indic_modules="indic-fc" +khmer_modules="khmer-fc" syriac_modules="syriac-fc" thai_modules="thai-fc" tibetan_modules="tibetan-fc" -all_modules="$arabic_modules,$basic_modules,$hangul_modules,$hebrew_modules,$indic_modules,$syriac_modules,$thai_modules,$tibetan_modules" +all_modules="$arabic_modules,$basic_modules,$hangul_modules,$hebrew_modules,$indic_modules,$khmer_modules,$syriac_modules,$thai_modules,$tibetan_modules" included_modules="" if test "x$with_included_modules" != xno || test "x$with_included_modules" = x ; then @@ -418,7 +419,9 @@ AM_CONDITIONAL(INCLUDE_HANGUL_FC,echo $included_modules | egrep '(^|,)hangul-fc( AM_CONDITIONAL(INCLUDE_HEBREW_FC,echo $included_modules | egrep '(^|,)hebrew-fc($|,)' > /dev/null) AM_CONDITIONAL(INCLUDE_INDIC_FC,echo $included_modules | egrep '(^|,)indic-fc($|,)' > /dev/null) - + +AM_CONDITIONAL(INCLUDE_KHMER_FC,echo $included_modules | grep '(^|,)khmer-fc($|,)' > /dev/null) + AM_CONDITIONAL(INCLUDE_SYRIAC_FC,echo $included_modules | egrep '(^|,)syriac-fc($|,)' > /dev/null) AM_CONDITIONAL(INCLUDE_THAI_FC,echo $included_modules | egrep '(^|,)thai-fc($|,)' > /dev/null) @@ -688,6 +691,7 @@ modules/basic/Makefile modules/hangul/Makefile modules/hebrew/Makefile modules/indic/Makefile +modules/khmer/Makefile modules/syriac/Makefile modules/thai/Makefile modules/tibetan/Makefile diff --git a/docs/Makefile.am b/docs/Makefile.am index 6d55e7f3..21b2da15 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -45,6 +45,7 @@ INCLUDES = \ -DPANGO_ENABLE_BACKEND \ -DPANGO_ENABLE_ENGINE \ -I$(top_srcdir) \ + $(CAIRO_CFLAGS) \ $(GLIB_CFLAGS) \ $(XFT_CFLAGS) \ $(FREETYPE_CFLAGS) \ diff --git a/docs/pango-sections.txt b/docs/pango-sections.txt index 1972e9b7..7ebd1991 100644 --- a/docs/pango-sections.txt +++ b/docs/pango-sections.txt @@ -780,9 +780,12 @@ pango_cairo_font_map_create_context pango_cairo_update_context pango_cairo_create_layout pango_cairo_update_layout -pango_cairo_show_glyphs +pango_cairo_show_glyph_string pango_cairo_show_layout_line pango_cairo_show_layout +pango_cairo_glyph_string_path +pango_cairo_layout_line_path +pango_cairo_layout_path <SUBSECTION Standard> PANGO_CAIRO_FONT_MAP PANGO_IS_CAIRO_FONT_MAP diff --git a/docs/tmpl/pangocairo.sgml b/docs/tmpl/pangocairo.sgml index 723a4a09..9223957a 100644 --- a/docs/tmpl/pangocairo.sgml +++ b/docs/tmpl/pangocairo.sgml @@ -218,7 +218,7 @@ int main (int argc, char **argv) @layout: -<!-- ##### FUNCTION pango_cairo_show_glyphs ##### --> +<!-- ##### FUNCTION pango_cairo_show_glyph_string ##### --> <para> </para> @@ -246,3 +246,31 @@ int main (int argc, char **argv) @layout: +<!-- ##### FUNCTION pango_cairo_glyph_string_path ##### --> +<para> + +</para> + +@cr: +@font: +@glyphs: + + +<!-- ##### FUNCTION pango_cairo_layout_line_path ##### --> +<para> + +</para> + +@cr: +@line: + + +<!-- ##### FUNCTION pango_cairo_layout_path ##### --> +<para> + +</para> + +@cr: +@layout: + + diff --git a/modules/Makefile.am b/modules/Makefile.am index f1ff5d30..39cc6ff7 100644 --- a/modules/Makefile.am +++ b/modules/Makefile.am @@ -6,6 +6,7 @@ SUBDIRS = \ hangul \ hebrew \ indic \ + khmer \ syriac \ thai \ tibetan diff --git a/modules/makefile.msc b/modules/makefile.msc index e56edf6a..5d5786f0 100644 --- a/modules/makefile.msc +++ b/modules/makefile.msc @@ -1,6 +1,6 @@ # modles for the ft2 backend, don't include 'basic' # here it is built-in pangoft.dll, see ../pango/makefile.msc -MODULES = arabic hangul hebrew indic syriac thai +MODULES = arabic hangul hebrew indic syriac thai khmer !IFNDEF MODULE @@ -43,6 +43,10 @@ OBJECTS = syriac-fc.obj syriac-ot.obj OBJECTS = thai-fc.obj thai-shaper.obj !ENDIF +!IFDEF OBJ_khmer +OBJECTS = khmer_fc.obj +!ENDIF + !IFNDEF OBJECTS OBJECTS = $(MODULE)-fc.obj !ENDIF diff --git a/pango/pangocairo-render.c b/pango/pangocairo-render.c index 5264131d..a6c5a214 100644 --- a/pango/pangocairo-render.c +++ b/pango/pangocairo-render.c @@ -32,6 +32,8 @@ struct _PangoCairoRenderer PangoRenderer parent_instance; cairo_t *cr; + gboolean do_path; + double x_offset, y_offset; }; struct _PangoCairoRendererClass @@ -46,7 +48,7 @@ set_color (PangoCairoRenderer *crenderer, PangoRenderPart part) { PangoColor *color = pango_renderer_get_color (PANGO_RENDERER (crenderer), part); - + if (color) cairo_set_rgb_color (crenderer->cr, color->red / 65535., @@ -71,9 +73,12 @@ pango_cairo_renderer_draw_glyphs (PangoRenderer *renderer, cairo_glyph_t *cairo_glyphs; cairo_glyph_t stack_glyphs[MAX_STACK]; - cairo_save (crenderer->cr); + if (!crenderer->do_path) + { + cairo_save (crenderer->cr); - set_color (crenderer, PANGO_RENDER_PART_FOREGROUND); + set_color (crenderer, PANGO_RENDER_PART_FOREGROUND); + } if (glyphs->num_glyphs > MAX_STACK) cairo_glyphs = g_new (cairo_glyph_t, glyphs->num_glyphs); @@ -85,20 +90,25 @@ pango_cairo_renderer_draw_glyphs (PangoRenderer *renderer, PangoGlyphInfo *gi = &glyphs->glyphs[i]; cairo_glyphs[i].index = gi->glyph; - cairo_glyphs[i].x = (double)(x + x_position + gi->geometry.x_offset) / PANGO_SCALE; - cairo_glyphs[i].y = (double)(y + gi->geometry.y_offset) / PANGO_SCALE; + cairo_glyphs[i].x = crenderer->x_offset + (double)(x + x_position + gi->geometry.x_offset) / PANGO_SCALE; + cairo_glyphs[i].y = crenderer->y_offset + (double)(y + gi->geometry.y_offset) / PANGO_SCALE; x_position += gi->geometry.width; } cairo_set_font (crenderer->cr, _pango_cairo_font_get_cairo_font (PANGO_CAIRO_FONT (font))); - cairo_show_glyphs (crenderer->cr, cairo_glyphs, glyphs->num_glyphs); + + if (crenderer->do_path) + cairo_glyph_path (crenderer->cr, cairo_glyphs, glyphs->num_glyphs); + else + cairo_show_glyphs (crenderer->cr, cairo_glyphs, glyphs->num_glyphs); if (glyphs->num_glyphs > MAX_STACK) g_free (cairo_glyphs); - cairo_restore (crenderer->cr); + if (!crenderer->do_path) + cairo_restore (crenderer->cr); #undef MAX_STACK } @@ -113,16 +123,22 @@ pango_cairo_renderer_draw_rectangle (PangoRenderer *renderer, { PangoCairoRenderer *crenderer = PANGO_CAIRO_RENDERER (renderer); - cairo_save (crenderer->cr); + if (!crenderer->do_path) + { + cairo_save (crenderer->cr); - set_color (crenderer, part); + set_color (crenderer, part); + } cairo_rectangle (crenderer->cr, - (double)x / PANGO_SCALE, (double)y / PANGO_SCALE, + crenderer->x_offset + (double)x / PANGO_SCALE, + crenderer->y_offset + (double)y / PANGO_SCALE, (double)width / PANGO_SCALE, (double)height / PANGO_SCALE); - cairo_fill (crenderer->cr); + if (!crenderer->do_path) + cairo_fill (crenderer->cr); - cairo_restore (crenderer->cr); + if (!crenderer->do_path) + cairo_restore (crenderer->cr); } /* Draws an error underline that looks like one of: @@ -160,16 +176,19 @@ pango_cairo_renderer_draw_error_underline (PangoRenderer *renderer, int width_units = (width + unit_width / 2) / unit_width; double y_top, y_bottom; int i; - - cairo_save (cr); - set_color (crenderer, PANGO_RENDER_PART_UNDERLINE); + if (!crenderer->do_path) + { + cairo_save (cr); + + set_color (crenderer, PANGO_RENDER_PART_UNDERLINE); + + cairo_new_path (cr); + } x += (width - width_units * unit_width); width = width_units * unit_width; - - cairo_new_path (cr); - + y_top = y + height; y_bottom = y; @@ -210,9 +229,13 @@ pango_cairo_renderer_draw_error_underline (PangoRenderer *renderer, } cairo_close_path (cr); - cairo_fill (cr); + + if (!crenderer->do_path) + { + cairo_fill (cr); - cairo_restore (cr); + cairo_restore (cr); + } } static void @@ -230,17 +253,8 @@ pango_cairo_renderer_class_init (PangoCairoRendererClass *klass) renderer_class->draw_error_underline = pango_cairo_renderer_draw_error_underline; } -static void -current_point_to_origin (cairo_t *cr) -{ - double x, y; - - cairo_current_point (cr, &x, &y); - cairo_translate (cr, x, y); -} - /** - * pango_cairo_show_glyphs: + * pango_cairo_show_glyph_string: * @cr: a Cairo context * @font: a #PangoFont * @glyphs: a #PangoGlyphString @@ -252,9 +266,9 @@ current_point_to_origin (cairo_t *cr) * Since: 1.10 **/ void -pango_cairo_show_glyphs (cairo_t *cr, - PangoFont *font, - PangoGlyphString *glyphs) +pango_cairo_show_glyph_string (cairo_t *cr, + PangoFont *font, + PangoGlyphString *glyphs) { PangoFontMap *fontmap; PangoCairoRenderer *crenderer; @@ -269,11 +283,16 @@ pango_cairo_show_glyphs (cairo_t *cr, crenderer = PANGO_CAIRO_RENDERER (renderer); cairo_save (cr); - current_point_to_origin (cr); crenderer->cr = cr; + crenderer->do_path = FALSE; + cairo_current_point (cr, &crenderer->x_offset, &crenderer->y_offset); + pango_renderer_draw_glyphs (renderer, font, glyphs, 0, 0); + crenderer->cr = NULL; + crenderer->x_offset = 0.; + crenderer->y_offset = 0.; cairo_restore (cr); } @@ -307,11 +326,16 @@ pango_cairo_show_layout_line (cairo_t *cr, crenderer = PANGO_CAIRO_RENDERER (renderer); cairo_save (cr); - current_point_to_origin (cr); crenderer->cr = cr; + crenderer->do_path = FALSE; + cairo_current_point (cr, &crenderer->x_offset, &crenderer->y_offset); + pango_renderer_draw_layout_line (renderer, line, 0, 0); + crenderer->cr = NULL; + crenderer->x_offset = 0.; + crenderer->y_offset = 0.; cairo_restore (cr); } @@ -345,11 +369,144 @@ pango_cairo_show_layout (cairo_t *cr, crenderer = PANGO_CAIRO_RENDERER (renderer); cairo_save (cr); - current_point_to_origin (cr); crenderer->cr = cr; + crenderer->do_path = FALSE; + cairo_current_point (cr, &crenderer->x_offset, &crenderer->y_offset); + pango_renderer_draw_layout (renderer, layout, 0, 0); + crenderer->cr = NULL; + crenderer->x_offset = 0.; + crenderer->y_offset = 0.; cairo_restore (cr); } + +/** + * pango_cairo_glyph_string_path + * @cr: a Cairo context + * @font: a #PangoFont + * @glyphs: a #PangoGlyphString + * + * Adds the glyphs in @glyphs to the current path in the specified + * cairo context. The origin of the glyphs (the left edge of the baseline) + * will be at the current point of the cairo context. + * + * Since: 1.10 + **/ +void +pango_cairo_glyph_string_path (cairo_t *cr, + PangoFont *font, + PangoGlyphString *glyphs) +{ + PangoFontMap *fontmap; + PangoCairoRenderer *crenderer; + PangoRenderer *renderer; + + g_return_if_fail (cr != NULL); + g_return_if_fail (PANGO_IS_CAIRO_FONT (font)); + g_return_if_fail (glyphs != NULL); + + fontmap = PANGO_FC_FONT (font)->fontmap; + renderer = _pango_cairo_font_map_get_renderer (PANGO_CAIRO_FONT_MAP (fontmap)); + crenderer = PANGO_CAIRO_RENDERER (renderer); + + crenderer->cr = cr; + crenderer->do_path = TRUE; + cairo_current_point (cr, &crenderer->x_offset, &crenderer->y_offset); + + pango_renderer_draw_glyphs (renderer, font, glyphs, 0, 0); + + crenderer->cr = NULL; + crenderer->do_path = FALSE; + crenderer->x_offset = 0.; + crenderer->y_offset = 0.; + + cairo_set_font (cr, NULL); +} + +/** + * pango_cairo_layout_line_path: + * @cr: a Cairo context + * @line: a #PangoLayoutLine + * + * Adds the text in #PangoLayoutLine to the current path in the + * specified cairo context. The origin of the glyphs (the left edge + * of the line) will be at the current point of the cairo context. + * + * Since: 1.10 + **/ +void +pango_cairo_layout_line_path (cairo_t *cr, + PangoLayoutLine *line) +{ + PangoContext *context; + PangoFontMap *fontmap; + PangoRenderer *renderer; + PangoCairoRenderer *crenderer; + + g_return_if_fail (cr != NULL); + g_return_if_fail (line != NULL); + + context = pango_layout_get_context (line->layout); + fontmap = pango_context_get_font_map (context); + renderer = _pango_cairo_font_map_get_renderer (PANGO_CAIRO_FONT_MAP (fontmap)); + crenderer = PANGO_CAIRO_RENDERER (renderer); + + crenderer->cr = cr; + crenderer->do_path = TRUE; + cairo_current_point (cr, &crenderer->x_offset, &crenderer->y_offset); + + pango_renderer_draw_layout_line (renderer, line, 0, 0); + + crenderer->cr = NULL; + crenderer->do_path = FALSE; + crenderer->x_offset = 0.; + crenderer->y_offset = 0.; + + cairo_set_font (cr, NULL); +} + +/** + * pango_cairo_layout_path: + * @cr: a Cairo context + * @layout: a Pango layout + * + * Adds the text in a #PangoLayoutLine to the current path in the + * specified cairo context. The top-left corner of the #PangoLayout + * will be at the current point of the cairo context. + * + * Since: 1.10 + **/ +void +pango_cairo_layout_path (cairo_t *cr, + PangoLayout *layout) +{ + PangoContext *context; + PangoFontMap *fontmap; + PangoRenderer *renderer; + PangoCairoRenderer *crenderer; + + g_return_if_fail (cr != NULL); + g_return_if_fail (PANGO_IS_LAYOUT (layout)); + + context = pango_layout_get_context (layout); + fontmap = pango_context_get_font_map (context); + renderer = _pango_cairo_font_map_get_renderer (PANGO_CAIRO_FONT_MAP (fontmap)); + crenderer = PANGO_CAIRO_RENDERER (renderer); + + crenderer->cr = cr; + crenderer->do_path = TRUE; + cairo_current_point (cr, &crenderer->x_offset, &crenderer->y_offset); + + pango_renderer_draw_layout (renderer, layout, 0, 0); + + crenderer->cr = NULL; + crenderer->do_path = FALSE; + crenderer->x_offset = 0.; + crenderer->y_offset = 0.; + + cairo_set_font (cr, NULL); +} + diff --git a/pango/pangocairo.h b/pango/pangocairo.h index f46987a0..dbaff5fe 100644 --- a/pango/pangocairo.h +++ b/pango/pangocairo.h @@ -71,13 +71,24 @@ void pango_cairo_update_layout (cairo_t *cr, /* * Rendering */ -void pango_cairo_show_glyphs (cairo_t *cr, - PangoFont *font, - PangoGlyphString *glyphs); -void pango_cairo_show_layout_line (cairo_t *cr, - PangoLayoutLine *line); -void pango_cairo_show_layout (cairo_t *cr, - PangoLayout *layout); +void pango_cairo_show_glyph_string (cairo_t *cr, + PangoFont *font, + PangoGlyphString *glyphs); +void pango_cairo_show_layout_line (cairo_t *cr, + PangoLayoutLine *line); +void pango_cairo_show_layout (cairo_t *cr, + PangoLayout *layout); + +/* + * Rendering to a path + */ +void pango_cairo_glyph_string_path (cairo_t *cr, + PangoFont *font, + PangoGlyphString *glyphs); +void pango_cairo_layout_line_path (cairo_t *cr, + PangoLayoutLine *line); +void pango_cairo_layout_path (cairo_t *cr, + PangoLayout *layout); G_END_DECLS |