diff options
author | Behdad Esfahbod <behdad@gnome.org> | 2006-08-16 07:23:08 +0000 |
---|---|---|
committer | Behdad Esfahbod <behdad@src.gnome.org> | 2006-08-16 07:23:08 +0000 |
commit | bb26941a468b994331286a55d41447cc2ef9326f (patch) | |
tree | 7e38be8a1800f49aeed0e0b54e8e74524124a46c /pango | |
parent | 292545e94970319545d1a2d8a5ebb700ade67565 (diff) | |
download | pango-bb26941a468b994331286a55d41447cc2ef9326f.tar.gz |
Render block progression and line direction arrows, and a base gravity
2006-08-16 Behdad Esfahbod <behdad@gnome.org>
* examples/viewer-pangocairo.c (render_callback): Render block
progression and line direction arrows, and a base gravity roof-top.
* pango/pango-matrix.c (pango_matrix_to_gravity): New function.
* pango/pango-utils.c (pango_gravity_to_rotation): New function.
* pango/pangocairo-fcfont.c (_pango_cairo_fc_font_new): Use
pango_gravity_to_rotation().
* pango/pango-utils.h:
* pango/pango-types.h:
Reorder a bit.
* examples/Makefile.am:
* examples/test-chinese.txt: New test text for Chinese.
* pango/check.defs: New script that checks that all the exported
symbols are listed in the respective .def file. (only checks the
libraries actually built. No win32 for example.)
* pango/Makefile.am: Hook check.defs as a 'make check' test.
* pango/pango.def:
* pango/pangoft2.def:
* pango/pangocairo.def:
Update.
* docs/tmpl/glyphs.sgml:
* docs/tmpl/main.sgml:
* docs/pango-sections.txt:
Update.
Diffstat (limited to 'pango')
-rw-r--r-- | pango/Makefile.am | 2 | ||||
-rwxr-xr-x | pango/check.defs | 23 | ||||
-rw-r--r-- | pango/pango-context.c | 4 | ||||
-rw-r--r-- | pango/pango-matrix.c | 28 | ||||
-rw-r--r-- | pango/pango-types.h | 216 | ||||
-rw-r--r-- | pango/pango-utils.c | 31 | ||||
-rw-r--r-- | pango/pango-utils.h | 7 | ||||
-rw-r--r-- | pango/pango.def | 9 | ||||
-rw-r--r-- | pango/pangocairo-fcfont.c | 13 | ||||
-rw-r--r-- | pango/pangocairo.def | 3 | ||||
-rw-r--r-- | pango/pangoft2.def | 3 |
11 files changed, 223 insertions, 116 deletions
diff --git a/pango/Makefile.am b/pango/Makefile.am index e2b9bd11..728b2fe1 100644 --- a/pango/Makefile.am +++ b/pango/Makefile.am @@ -481,3 +481,5 @@ if DISABLE_EXPLICIT_DEPS endif uninstall-local: uninstall-ms-lib uninstall-def-files + +TESTS = check.defs diff --git a/pango/check.defs b/pango/check.defs new file mode 100755 index 00000000..a4d0a67f --- /dev/null +++ b/pango/check.defs @@ -0,0 +1,23 @@ +#!/bin/bash + +LANG=C + +test -z "$srcdir" && srcdir=. +status=0 + +for def in $srcdir/*.def; do + lib=${def%.def} + lib=${lib##*/} + so=.libs/lib${lib}-1.0.so + + test -f $so || continue + echo Checking $def + + nm $so | grep ' T ' | cut -d' ' -f3 | sort -u > NM + cut -f 2 $def | grep -v '^EXPORTS$' > DEF + + diff DEF NM || status=1 + rm -f DEF NM +done + +exit $status diff --git a/pango/pango-context.c b/pango/pango-context.c index 31953c71..48c6980b 100644 --- a/pango/pango-context.c +++ b/pango/pango-context.c @@ -413,6 +413,8 @@ pango_context_get_base_dir (PangoContext *context) * Sets the base gravity for the context. * * The base gravity is used in laying vertical text out. + * + * Since: 1.16 **/ void pango_context_set_base_gravity (PangoContext *context, @@ -431,6 +433,8 @@ pango_context_set_base_gravity (PangoContext *context, * pango_context_set_base_gravity(). * * Return value: the base gravity for the context. + * + * Since: 1.16 **/ PangoGravity pango_context_get_base_gravity (PangoContext *context) diff --git a/pango/pango-matrix.c b/pango/pango-matrix.c index 58be83e1..322a4931 100644 --- a/pango/pango-matrix.c +++ b/pango/pango-matrix.c @@ -20,6 +20,7 @@ */ #include <config.h> +#include <stdlib.h> #include <math.h> #include "pango-types.h" @@ -248,3 +249,30 @@ pango_matrix_get_font_scale_factor (const PangoMatrix *matrix) return minor; } } + +/** + * pango_matrix_to_gravity: + * @matrix: a #PangoMatrix + * + * Finds the gravity that best matches the rotation component + * in a #PangoMatrix. + * + * Return value: the gravity of @matrix, which will never be + * %PANGO_GRAVITY_AUTO + * + * Since: 1.16 + */ +PangoGravity +pango_matrix_to_gravity (const PangoMatrix *matrix) +{ + PangoGravity gravity; + double x = matrix->xy; + double y = matrix->yy; + + if (abs (x) > abs (y)) + gravity = x < 0 ? PANGO_GRAVITY_WEST : PANGO_GRAVITY_EAST; + else + gravity = y < 0 ? PANGO_GRAVITY_NORTH : PANGO_GRAVITY_SOUTH; + + return gravity; +} diff --git a/pango/pango-types.h b/pango/pango-types.h index 3c8233d5..9d4caba6 100644 --- a/pango/pango-types.h +++ b/pango/pango-types.h @@ -38,92 +38,12 @@ typedef struct _PangoFontMap PangoFontMap; typedef struct _PangoMatrix PangoMatrix; typedef struct _PangoRectangle PangoRectangle; -/* Dummy typedef - internally it's a 'const char *' */ -typedef struct _PangoLanguage PangoLanguage; - -/* A index of a glyph into a font. Rendering system dependent - */ -typedef guint32 PangoGlyph; - -/* A rectangle. Used to store logical and physical extents of glyphs, - * runs, strings, etc. - */ -struct _PangoRectangle -{ - int x; - int y; - int width; - int height; -}; - -/** - * PangoMatrix: - * @xx: 1st component of the transformation matrix - * @xy: 2nd component of the transformation matrix - * @yx: 3rd component of the transformation matrix - * @yy: 4th component of the transformation matrix - * @x0: x translation - * @y0: y translation - * - * A structure specifying a transformation between user-space - * coordinates and device coordinates. The transformation - * is given by - * - * <programlisting> - * x_device = x_user * matrix->xx + y_user * matrix->xy + matrix->x0; - * y_device = x_user * matrix->yx + y_user * matrix->yy + matrix->y0; - * </programlisting> - * - * Since: 1.6 - **/ -struct _PangoMatrix -{ - double xx; - double xy; - double yx; - double yy; - double x0; - double y0; -}; - -/** - * PANGO_TYPE_MATRIX - * - * The GObject type for #PangoMatrix - **/ -#define PANGO_TYPE_MATRIX (pango_matrix_get_type ()) -/** - * PANGO_MATRIX_INIT - * - * Constant that can be used to initialize a PangoMatrix to - * the identity transform. - * - * <informalexample><programlisting> - * PangoMatrix matrix = PANGO_MATRIX_INIT; - * pango_matrix_rotate (&matrix, 45.); - * </programlisting></informalexample> - * - * Since: 1.6 - **/ -#define PANGO_MATRIX_INIT { 1., 0., 0., 1., 0., 0. } -GType pango_matrix_get_type (void); +/* A index of a glyph into a font. Rendering system dependent */ +typedef guint32 PangoGlyph; -PangoMatrix *pango_matrix_copy (const PangoMatrix *matrix); -void pango_matrix_free (PangoMatrix *matrix); -void pango_matrix_translate (PangoMatrix *matrix, - double tx, - double ty); -void pango_matrix_scale (PangoMatrix *matrix, - double scale_x, - double scale_y); -void pango_matrix_rotate (PangoMatrix *matrix, - double degrees); -void pango_matrix_concat (PangoMatrix *matrix, - const PangoMatrix *new_matrix); -double pango_matrix_get_font_scale_factor (const PangoMatrix *matrix); #define PANGO_SCALE 1024 #define PANGO_PIXELS(d) (((int)(d) + 512) >> 10) @@ -136,6 +56,40 @@ double pango_matrix_get_font_scale_factor (const PangoMatrix *matrix); * integers and floating point. */ +/* Hint line position and thickness. + */ +void pango_quantize_line_geometry (int *thickness, + int *position); + + + +/* Dummy typedef - internally it's a 'const char *' */ +typedef struct _PangoLanguage PangoLanguage; + +#define PANGO_TYPE_LANGUAGE (pango_language_get_type ()) + +GType pango_language_get_type (void); +PangoLanguage *pango_language_from_string (const char *language); +#define pango_language_to_string(language) ((const char *)language) + +G_CONST_RETURN char *pango_language_get_sample_string (PangoLanguage *language); + +gboolean pango_language_matches (PangoLanguage *language, + const char *range_list); + + + +/* A rectangle. Used to store logical and physical extents of glyphs, + * runs, strings, etc. + */ +struct _PangoRectangle +{ + int x; + int y; + int width; + int height; +}; + /* Macros to translate from extents rectangles to ascent/descent/lbearing/rbearing */ #define PANGO_ASCENT(rect) (-(rect).y) @@ -143,6 +97,8 @@ double pango_matrix_get_font_scale_factor (const PangoMatrix *matrix); #define PANGO_LBEARING(rect) ((rect).x) #define PANGO_RBEARING(rect) ((rect).x + (rect).width) + + /** * PangoDirection: * @PANGO_DIRECTION_LTR: A strong left-to-right direction @@ -181,6 +137,17 @@ typedef enum { PANGO_DIRECTION_NEUTRAL } PangoDirection; +PangoDirection pango_unichar_direction (gunichar ch); +PangoDirection pango_find_base_dir (const gchar *text, + gint length); + +#ifndef PANGO_DISABLE_DEPRECATED +gboolean pango_get_mirror_char (gunichar ch, + gunichar *mirrored_ch); +#endif + + + /** * PangoGravity: * @PANGO_GRAVITY_SOUTH: Glyphs stand upright (default) @@ -192,6 +159,8 @@ typedef enum { * of text. This is useful when rendering vertical text layouts. In * those situations, the layout is rotated using a non-identity PangoMatrix, * and then glyph orientation is controlled using #PangoGravity. + * + * Since: 1.16 **/ typedef enum { PANGO_GRAVITY_SOUTH, @@ -200,24 +169,81 @@ typedef enum { PANGO_GRAVITY_WEST } PangoGravity; -#define PANGO_TYPE_LANGUAGE (pango_language_get_type ()) +double pango_gravity_to_rotation (PangoGravity gravity); -GType pango_language_get_type (void); -PangoLanguage *pango_language_from_string (const char *language); -#define pango_language_to_string(language) ((const char *)language) -gboolean pango_language_matches (PangoLanguage *language, - const char *range_list); -#ifndef PANGO_DISABLE_DEPRECATED -gboolean pango_get_mirror_char (gunichar ch, - gunichar *mirrored_ch); -#endif +/** + * PangoMatrix: + * @xx: 1st component of the transformation matrix + * @xy: 2nd component of the transformation matrix + * @yx: 3rd component of the transformation matrix + * @yy: 4th component of the transformation matrix + * @x0: x translation + * @y0: y translation + * + * A structure specifying a transformation between user-space + * coordinates and device coordinates. The transformation + * is given by + * + * <programlisting> + * x_device = x_user * matrix->xx + y_user * matrix->xy + matrix->x0; + * y_device = x_user * matrix->yx + y_user * matrix->yy + matrix->y0; + * </programlisting> + * + * Since: 1.6 + **/ +struct _PangoMatrix +{ + double xx; + double xy; + double yx; + double yy; + double x0; + double y0; +}; + +/** + * PANGO_TYPE_MATRIX + * + * The GObject type for #PangoMatrix + **/ +#define PANGO_TYPE_MATRIX (pango_matrix_get_type ()) + +/** + * PANGO_MATRIX_INIT + * + * Constant that can be used to initialize a PangoMatrix to + * the identity transform. + * + * <informalexample><programlisting> + * PangoMatrix matrix = PANGO_MATRIX_INIT; + * pango_matrix_rotate (&matrix, 45.); + * </programlisting></informalexample> + * + * Since: 1.6 + **/ +#define PANGO_MATRIX_INIT { 1., 0., 0., 1., 0., 0. } + +GType pango_matrix_get_type (void); + +PangoMatrix *pango_matrix_copy (const PangoMatrix *matrix); +void pango_matrix_free (PangoMatrix *matrix); + +void pango_matrix_translate (PangoMatrix *matrix, + double tx, + double ty); +void pango_matrix_scale (PangoMatrix *matrix, + double scale_x, + double scale_y); +void pango_matrix_rotate (PangoMatrix *matrix, + double degrees); +void pango_matrix_concat (PangoMatrix *matrix, + const PangoMatrix *new_matrix); +double pango_matrix_get_font_scale_factor (const PangoMatrix *matrix); +PangoGravity pango_matrix_to_gravity (const PangoMatrix *matrix); -PangoDirection pango_unichar_direction (gunichar ch); -PangoDirection pango_find_base_dir (const gchar *text, - gint length); G_END_DECLS diff --git a/pango/pango-utils.c b/pango/pango-utils.c index 63976aed..5e1fccdc 100644 --- a/pango/pango-utils.c +++ b/pango/pango-utils.c @@ -1,4 +1,4 @@ -/* Pango + /* Pango * pango-utils.c: Utilities for internal functions and modules * * Copyright (C) 2000 Red Hat Software @@ -23,6 +23,7 @@ #include <errno.h> #include <string.h> #include <stdlib.h> +#include <math.h> #include "pango-font.h" #include "pango-impl-utils.h" @@ -1625,3 +1626,31 @@ pango_quantize_line_geometry (int *thickness, *thickness = thickness_pixels * PANGO_SCALE; } + +/** + * pango_gravity_to_rotation: + * @gravity: gravity to query + * + * Converts a #PangoGravity value to its rotation value. + * + * Return value: the rotation value corresponding to @gravity, + * or zero if @gravity is #PANGO_GRAVITY_AUTO + * + * Since: 1.16 + */ +double +pango_gravity_to_rotation (PangoGravity gravity) +{ + double rotation; + + switch (gravity) + { + default: + case PANGO_GRAVITY_SOUTH: rotation = 0; break; + case PANGO_GRAVITY_NORTH: rotation = M_PI; break; + case PANGO_GRAVITY_EAST: rotation = -M_PI_2; break; + case PANGO_GRAVITY_WEST: rotation = +M_PI_2; break; + } + + return rotation; +} diff --git a/pango/pango-utils.h b/pango/pango-utils.h index 13df824c..f0392f72 100644 --- a/pango/pango-utils.h +++ b/pango/pango-utils.h @@ -92,18 +92,11 @@ guint8 * pango_log2vis_get_embedding_levels (const gchar *text, int length, PangoDirection *pbase_dir); -G_CONST_RETURN char *pango_language_get_sample_string (PangoLanguage *language); - /* Unicode characters that are zero-width and should not be rendered * normally. */ gboolean pango_is_zero_width (gunichar ch) G_GNUC_CONST; -/* Hint line position and thickness. - */ -void pango_quantize_line_geometry (int *thickness, - int *position); - G_END_DECLS #endif /* __PANGO_UTILS_H__ */ diff --git a/pango/pango.def b/pango/pango.def index d39b1805..32576db6 100644 --- a/pango/pango.def +++ b/pango/pango.def @@ -51,9 +51,9 @@ EXPORTS pango_color_parse pango_config_key_get pango_context_get_base_dir + pango_context_get_base_gravity pango_context_get_font_description pango_context_get_font_map - pango_context_get_gravity pango_context_get_language pango_context_get_matrix pango_context_get_metrics @@ -63,9 +63,9 @@ EXPORTS pango_context_load_fontset pango_context_new pango_context_set_base_dir + pango_context_set_base_gravity pango_context_set_font_description pango_context_set_font_map - pango_context_set_gravity pango_context_set_language pango_context_set_matrix pango_coverage_copy @@ -179,6 +179,8 @@ EXPORTS pango_glyph_string_new pango_glyph_string_set_size pango_glyph_string_x_to_index + pango_gravity_get_type + pango_gravity_to_rotation pango_is_zero_width pango_item_copy pango_item_free @@ -275,6 +277,7 @@ EXPORTS pango_matrix_get_type pango_matrix_rotate pango_matrix_scale + pango_matrix_to_gravity pango_matrix_translate pango_module_register pango_parse_markup @@ -309,7 +312,7 @@ EXPORTS pango_script_get_type pango_script_iter_free pango_script_iter_get_range - pango_script_iter_new + pango_script_iter_new pango_script_iter_next pango_shape pango_skip_space diff --git a/pango/pangocairo-fcfont.c b/pango/pangocairo-fcfont.c index 0e503061..a0dec5c6 100644 --- a/pango/pangocairo-fcfont.c +++ b/pango/pangocairo-fcfont.c @@ -496,7 +496,7 @@ _pango_cairo_fc_font_new (PangoCairoFcFontMap *cffontmap, PangoCairoFcFont *cffont; const PangoMatrix *pango_ctm; FcMatrix *fc_matrix; - double size, rotation; + double size; g_return_val_if_fail (PANGO_IS_CAIRO_FC_FONT_MAP (cffontmap), NULL); g_return_val_if_fail (pattern != NULL, NULL); @@ -521,15 +521,8 @@ _pango_cairo_fc_font_new (PangoCairoFcFontMap *cffontmap, else cairo_matrix_init_identity (&cffont->font_matrix); - switch (cffont->gravity) - { - default: - case PANGO_GRAVITY_SOUTH: rotation = 0; break; - case PANGO_GRAVITY_NORTH: rotation = M_PI; break; - case PANGO_GRAVITY_EAST: rotation = -M_PI_2; break; - case PANGO_GRAVITY_WEST: rotation = +M_PI_2; break; - } - cairo_matrix_rotate(&cffont->font_matrix, rotation); + cairo_matrix_rotate(&cffont->font_matrix, + pango_gravity_to_rotation (cffont->gravity)); pango_ctm = pango_context_get_matrix (context); diff --git a/pango/pangocairo.def b/pango/pangocairo.def index 2b635888..f5e5af32 100644 --- a/pango/pangocairo.def +++ b/pango/pangocairo.def @@ -5,6 +5,8 @@ EXPORTS pango_cairo_context_set_resolution pango_cairo_create_layout pango_cairo_error_underline_path + pango_cairo_fc_font_get_type + pango_cairo_fc_font_map_get_type pango_cairo_font_get_type pango_cairo_font_map_create_context pango_cairo_font_map_get_default @@ -15,6 +17,7 @@ EXPORTS pango_cairo_glyph_string_path pango_cairo_layout_line_path pango_cairo_layout_path + pango_cairo_renderer_get_type pango_cairo_show_error_underline pango_cairo_show_glyph_string pango_cairo_show_layout diff --git a/pango/pangoft2.def b/pango/pangoft2.def index b559627a..100909b7 100644 --- a/pango/pangoft2.def +++ b/pango/pangoft2.def @@ -1,6 +1,7 @@ EXPORTS pango_fc_decoder_get_charset pango_fc_decoder_get_glyph + pango_fc_decoder_get_type pango_fc_font_create_metrics_for_context pango_fc_font_description_from_pattern pango_fc_font_get_glyph @@ -19,6 +20,7 @@ EXPORTS pango_ft2_font_get_coverage pango_ft2_font_get_face pango_ft2_font_get_kerning + pango_ft2_font_get_type pango_ft2_font_map_create_context pango_ft2_font_map_for_display pango_ft2_font_map_get_type @@ -34,6 +36,7 @@ EXPORTS pango_ft2_render_layout_line_subpixel pango_ft2_render_layout_subpixel pango_ft2_render_transformed + pango_ft2_renderer_get_type pango_ft2_shutdown_display pango_ot_buffer_add_glyph pango_ot_buffer_clear |