summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2000-03-07 02:02:15 +0000
committerOwen Taylor <otaylor@src.gnome.org>2000-03-07 02:02:15 +0000
commitdd0b4a5064c6f60adcfd2ea02e2d61fb60254d20 (patch)
tree39a121f4bd40300bcd67521104db86c12bd33165
parent6278d373c1a564ae4233a2e4b6d428a9f6202728 (diff)
downloadpango-dd0b4a5064c6f60adcfd2ea02e2d61fb60254d20.tar.gz
Convert log_clusters[] use from char offsets to byte offset - should make
Mon Mar 6 20:55:32 2000 Owen Taylor <otaylor@redhat.com> * libpango/mapping.c example/viewer.c: * modules/hangul/hangul.c modules/basic/basic.c modules/tamil/tamil.c: Convert log_clusters[] use from char offsets to byte offset - should make it easier to have all interface deal with stuff in byte offsets. * libpango/mapping.c libpango/pango-glyph.h: Rename x_to_cp and cp_to_x to make them "member functions" of glyph_string. * libpango/pango-types.h: Add a rectangle type for use in storing glyph/glyph-string extents, plus macros for extracting ascent/descent. * libpango/fonts.c libpango/pango-font.h libpango/pangox.c: Virtualize glyph extents function into the font. * libpango/pangox.c modules/*/*.c examples/viewer.c: Convert over to new rationalized unit system - everything in 1000ths of a point or 1000ths of a glyph unit. * libpango/pango-glyph.h libpango/glyphstring.c: Add function to get extents of a glyph string. (We may want to fastpath the width in the future, since getting the width seems to be a very common and time-critical operation)
-rw-r--r--ChangeLog26
-rw-r--r--ChangeLog.pre-1-026
-rw-r--r--ChangeLog.pre-1-1026
-rw-r--r--ChangeLog.pre-1-226
-rw-r--r--ChangeLog.pre-1-426
-rw-r--r--ChangeLog.pre-1-626
-rw-r--r--ChangeLog.pre-1-826
-rw-r--r--TODO4
-rw-r--r--docs/pango-docs.sgml4
-rw-r--r--docs/pango-sections.txt37
-rw-r--r--docs/tmpl/fonts.sgml34
-rw-r--r--docs/tmpl/glyphs.sgml69
-rw-r--r--docs/tmpl/main.sgml21
-rw-r--r--docs/tmpl/pango-unused.sgml16
-rw-r--r--examples/viewer.c98
-rw-r--r--modules/basic/basic-x.c15
-rw-r--r--modules/basic/basic.c15
-rw-r--r--modules/hangul/hangul-x.c64
-rw-r--r--modules/hangul/hangul.c64
-rw-r--r--modules/tamil/tamil-x.c19
-rw-r--r--modules/tamil/tamil.c19
-rw-r--r--pango/fonts.c29
-rw-r--r--pango/glyphstring.c97
-rw-r--r--pango/mapping.c171
-rw-r--r--pango/pango-attributes.c4
-rw-r--r--pango/pango-font.h22
-rw-r--r--pango/pango-glyph.h44
-rw-r--r--pango/pango-layout.h58
-rw-r--r--pango/pango-types.h23
-rw-r--r--pango/pangox.c208
30 files changed, 884 insertions, 433 deletions
diff --git a/ChangeLog b/ChangeLog
index 9d4e28a2..c3b78dbf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+Mon Mar 6 20:55:32 2000 Owen Taylor <otaylor@redhat.com>
+
+ * libpango/mapping.c example/viewer.c:
+ * modules/hangul/hangul.c modules/basic/basic.c modules/tamil/tamil.c:
+
+ Convert log_clusters[] use from char offsets to byte offset - should
+ make it easier to have all interface deal with stuff in byte offsets.
+
+ * libpango/mapping.c libpango/pango-glyph.h: Rename x_to_cp and cp_to_x
+ to make them "member functions" of glyph_string.
+
+ * libpango/pango-types.h: Add a rectangle type for use in storing
+ glyph/glyph-string extents, plus macros for extracting ascent/descent.
+
+ * libpango/fonts.c libpango/pango-font.h libpango/pangox.c: Virtualize
+ glyph extents function into the font.
+
+ * libpango/pangox.c modules/*/*.c examples/viewer.c: Convert over to
+ new rationalized unit system - everything in 1000ths of a point
+ or 1000ths of a glyph unit.
+
+ * libpango/pango-glyph.h libpango/glyphstring.c: Add function to get
+ extents of a glyph string. (We may want to fastpath the width in
+ the future, since getting the width seems to be a very common
+ and time-critical operation)
+
Mon Feb 28 19:46:35 2000 Owen Taylor <otaylor@redhat.com>
* libpango/fonts.c libpango/pango-fonts.h: Add functions
diff --git a/ChangeLog.pre-1-0 b/ChangeLog.pre-1-0
index 9d4e28a2..c3b78dbf 100644
--- a/ChangeLog.pre-1-0
+++ b/ChangeLog.pre-1-0
@@ -1,3 +1,29 @@
+Mon Mar 6 20:55:32 2000 Owen Taylor <otaylor@redhat.com>
+
+ * libpango/mapping.c example/viewer.c:
+ * modules/hangul/hangul.c modules/basic/basic.c modules/tamil/tamil.c:
+
+ Convert log_clusters[] use from char offsets to byte offset - should
+ make it easier to have all interface deal with stuff in byte offsets.
+
+ * libpango/mapping.c libpango/pango-glyph.h: Rename x_to_cp and cp_to_x
+ to make them "member functions" of glyph_string.
+
+ * libpango/pango-types.h: Add a rectangle type for use in storing
+ glyph/glyph-string extents, plus macros for extracting ascent/descent.
+
+ * libpango/fonts.c libpango/pango-font.h libpango/pangox.c: Virtualize
+ glyph extents function into the font.
+
+ * libpango/pangox.c modules/*/*.c examples/viewer.c: Convert over to
+ new rationalized unit system - everything in 1000ths of a point
+ or 1000ths of a glyph unit.
+
+ * libpango/pango-glyph.h libpango/glyphstring.c: Add function to get
+ extents of a glyph string. (We may want to fastpath the width in
+ the future, since getting the width seems to be a very common
+ and time-critical operation)
+
Mon Feb 28 19:46:35 2000 Owen Taylor <otaylor@redhat.com>
* libpango/fonts.c libpango/pango-fonts.h: Add functions
diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10
index 9d4e28a2..c3b78dbf 100644
--- a/ChangeLog.pre-1-10
+++ b/ChangeLog.pre-1-10
@@ -1,3 +1,29 @@
+Mon Mar 6 20:55:32 2000 Owen Taylor <otaylor@redhat.com>
+
+ * libpango/mapping.c example/viewer.c:
+ * modules/hangul/hangul.c modules/basic/basic.c modules/tamil/tamil.c:
+
+ Convert log_clusters[] use from char offsets to byte offset - should
+ make it easier to have all interface deal with stuff in byte offsets.
+
+ * libpango/mapping.c libpango/pango-glyph.h: Rename x_to_cp and cp_to_x
+ to make them "member functions" of glyph_string.
+
+ * libpango/pango-types.h: Add a rectangle type for use in storing
+ glyph/glyph-string extents, plus macros for extracting ascent/descent.
+
+ * libpango/fonts.c libpango/pango-font.h libpango/pangox.c: Virtualize
+ glyph extents function into the font.
+
+ * libpango/pangox.c modules/*/*.c examples/viewer.c: Convert over to
+ new rationalized unit system - everything in 1000ths of a point
+ or 1000ths of a glyph unit.
+
+ * libpango/pango-glyph.h libpango/glyphstring.c: Add function to get
+ extents of a glyph string. (We may want to fastpath the width in
+ the future, since getting the width seems to be a very common
+ and time-critical operation)
+
Mon Feb 28 19:46:35 2000 Owen Taylor <otaylor@redhat.com>
* libpango/fonts.c libpango/pango-fonts.h: Add functions
diff --git a/ChangeLog.pre-1-2 b/ChangeLog.pre-1-2
index 9d4e28a2..c3b78dbf 100644
--- a/ChangeLog.pre-1-2
+++ b/ChangeLog.pre-1-2
@@ -1,3 +1,29 @@
+Mon Mar 6 20:55:32 2000 Owen Taylor <otaylor@redhat.com>
+
+ * libpango/mapping.c example/viewer.c:
+ * modules/hangul/hangul.c modules/basic/basic.c modules/tamil/tamil.c:
+
+ Convert log_clusters[] use from char offsets to byte offset - should
+ make it easier to have all interface deal with stuff in byte offsets.
+
+ * libpango/mapping.c libpango/pango-glyph.h: Rename x_to_cp and cp_to_x
+ to make them "member functions" of glyph_string.
+
+ * libpango/pango-types.h: Add a rectangle type for use in storing
+ glyph/glyph-string extents, plus macros for extracting ascent/descent.
+
+ * libpango/fonts.c libpango/pango-font.h libpango/pangox.c: Virtualize
+ glyph extents function into the font.
+
+ * libpango/pangox.c modules/*/*.c examples/viewer.c: Convert over to
+ new rationalized unit system - everything in 1000ths of a point
+ or 1000ths of a glyph unit.
+
+ * libpango/pango-glyph.h libpango/glyphstring.c: Add function to get
+ extents of a glyph string. (We may want to fastpath the width in
+ the future, since getting the width seems to be a very common
+ and time-critical operation)
+
Mon Feb 28 19:46:35 2000 Owen Taylor <otaylor@redhat.com>
* libpango/fonts.c libpango/pango-fonts.h: Add functions
diff --git a/ChangeLog.pre-1-4 b/ChangeLog.pre-1-4
index 9d4e28a2..c3b78dbf 100644
--- a/ChangeLog.pre-1-4
+++ b/ChangeLog.pre-1-4
@@ -1,3 +1,29 @@
+Mon Mar 6 20:55:32 2000 Owen Taylor <otaylor@redhat.com>
+
+ * libpango/mapping.c example/viewer.c:
+ * modules/hangul/hangul.c modules/basic/basic.c modules/tamil/tamil.c:
+
+ Convert log_clusters[] use from char offsets to byte offset - should
+ make it easier to have all interface deal with stuff in byte offsets.
+
+ * libpango/mapping.c libpango/pango-glyph.h: Rename x_to_cp and cp_to_x
+ to make them "member functions" of glyph_string.
+
+ * libpango/pango-types.h: Add a rectangle type for use in storing
+ glyph/glyph-string extents, plus macros for extracting ascent/descent.
+
+ * libpango/fonts.c libpango/pango-font.h libpango/pangox.c: Virtualize
+ glyph extents function into the font.
+
+ * libpango/pangox.c modules/*/*.c examples/viewer.c: Convert over to
+ new rationalized unit system - everything in 1000ths of a point
+ or 1000ths of a glyph unit.
+
+ * libpango/pango-glyph.h libpango/glyphstring.c: Add function to get
+ extents of a glyph string. (We may want to fastpath the width in
+ the future, since getting the width seems to be a very common
+ and time-critical operation)
+
Mon Feb 28 19:46:35 2000 Owen Taylor <otaylor@redhat.com>
* libpango/fonts.c libpango/pango-fonts.h: Add functions
diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6
index 9d4e28a2..c3b78dbf 100644
--- a/ChangeLog.pre-1-6
+++ b/ChangeLog.pre-1-6
@@ -1,3 +1,29 @@
+Mon Mar 6 20:55:32 2000 Owen Taylor <otaylor@redhat.com>
+
+ * libpango/mapping.c example/viewer.c:
+ * modules/hangul/hangul.c modules/basic/basic.c modules/tamil/tamil.c:
+
+ Convert log_clusters[] use from char offsets to byte offset - should
+ make it easier to have all interface deal with stuff in byte offsets.
+
+ * libpango/mapping.c libpango/pango-glyph.h: Rename x_to_cp and cp_to_x
+ to make them "member functions" of glyph_string.
+
+ * libpango/pango-types.h: Add a rectangle type for use in storing
+ glyph/glyph-string extents, plus macros for extracting ascent/descent.
+
+ * libpango/fonts.c libpango/pango-font.h libpango/pangox.c: Virtualize
+ glyph extents function into the font.
+
+ * libpango/pangox.c modules/*/*.c examples/viewer.c: Convert over to
+ new rationalized unit system - everything in 1000ths of a point
+ or 1000ths of a glyph unit.
+
+ * libpango/pango-glyph.h libpango/glyphstring.c: Add function to get
+ extents of a glyph string. (We may want to fastpath the width in
+ the future, since getting the width seems to be a very common
+ and time-critical operation)
+
Mon Feb 28 19:46:35 2000 Owen Taylor <otaylor@redhat.com>
* libpango/fonts.c libpango/pango-fonts.h: Add functions
diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8
index 9d4e28a2..c3b78dbf 100644
--- a/ChangeLog.pre-1-8
+++ b/ChangeLog.pre-1-8
@@ -1,3 +1,29 @@
+Mon Mar 6 20:55:32 2000 Owen Taylor <otaylor@redhat.com>
+
+ * libpango/mapping.c example/viewer.c:
+ * modules/hangul/hangul.c modules/basic/basic.c modules/tamil/tamil.c:
+
+ Convert log_clusters[] use from char offsets to byte offset - should
+ make it easier to have all interface deal with stuff in byte offsets.
+
+ * libpango/mapping.c libpango/pango-glyph.h: Rename x_to_cp and cp_to_x
+ to make them "member functions" of glyph_string.
+
+ * libpango/pango-types.h: Add a rectangle type for use in storing
+ glyph/glyph-string extents, plus macros for extracting ascent/descent.
+
+ * libpango/fonts.c libpango/pango-font.h libpango/pangox.c: Virtualize
+ glyph extents function into the font.
+
+ * libpango/pangox.c modules/*/*.c examples/viewer.c: Convert over to
+ new rationalized unit system - everything in 1000ths of a point
+ or 1000ths of a glyph unit.
+
+ * libpango/pango-glyph.h libpango/glyphstring.c: Add function to get
+ extents of a glyph string. (We may want to fastpath the width in
+ the future, since getting the width seems to be a very common
+ and time-critical operation)
+
Mon Feb 28 19:46:35 2000 Owen Taylor <otaylor@redhat.com>
* libpango/fonts.c libpango/pango-fonts.h: Add functions
diff --git a/TODO b/TODO
index 5e7c03d2..e40dd080 100644
--- a/TODO
+++ b/TODO
@@ -54,6 +54,8 @@ Language Modules
* The clusters set by the current modules need to be set.
+ * Tamil module should be switched over to libunicode from utils.c stuff.
+
Documentation
=============
@@ -100,3 +102,5 @@ General
* Finish coverting over from utils.c to Tom Tromey's libunicode.
Add the remaining useful functions from utils.c into libunicode.
+
+* s/num_chars/n_chars/ etc. (Always use n_ as enumeration prefix) \ No newline at end of file
diff --git a/docs/pango-docs.sgml b/docs/pango-docs.sgml
index a6e75d8c..66fff619 100644
--- a/docs/pango-docs.sgml
+++ b/docs/pango-docs.sgml
@@ -3,6 +3,7 @@
<!entity pango-glyphs SYSTEM "sgml/glyphs.sgml">
<!entity pango-fonts SYSTEM "sgml/fonts.sgml">
<!entity pango-text-attributes SYSTEM "sgml/text-attributes.sgml">
+<!entity pango-layout SYSTEM "sgml/layout.sgml">
<!entity pango-coverage-maps SYSTEM "sgml/coverage-maps.sgml">
<!entity pango-engines SYSTEM "sgml/engines.sgml">
<!entity x-fonts SYSTEM "sgml/x-fonts.sgml">
@@ -19,6 +20,7 @@
&pango-glyphs;
&pango-fonts;
&pango-text-attributes;
+ &pango-layout;
&pango-coverage-maps;
&pango-engines;
</chapter>
@@ -28,4 +30,4 @@
&x-fonts;
&x-rendering;
</chapter>
-</book> \ No newline at end of file
+</book>
diff --git a/docs/pango-sections.txt b/docs/pango-sections.txt
index 251c410e..57809132 100644
--- a/docs/pango-sections.txt
+++ b/docs/pango-sections.txt
@@ -14,8 +14,6 @@ pango_context_new
pango_context_ref
pango_context_unref
pango_context_add_font_map
-pango_context_get_size
-pango_context_set_size
pango_context_get_font_description
pango_context_set_font_description
pango_context_get_base_dir
@@ -39,6 +37,11 @@ pango_x_to_cp
<SECTION>
<TITLE>Glyph Storage</TITLE>
<FILE>glyphs</FILE>
+PangoRectangle
+PANGO_ASCENT
+PANGO_DESCENT
+PANGO_LBEARING
+PANGO_RBEARING
PangoGlyph
PangoGlyphInfo
PangoGlyphGeometry
@@ -48,6 +51,7 @@ PangoGlyphString
pango_glyph_string_new
pango_glyph_string_set_size
pango_glyph_string_free
+pango_glyph_string_extents
</SECTION>
<SECTION>
@@ -77,6 +81,8 @@ pango_font_description_copy
pango_font_description_compare
pango_font_descriptions_free
pango_font_description_free
+pango_font_description_from_string
+pango_font_description_to_string
<SUBSECTION>
PangoFont
PangoFontClass
@@ -86,6 +92,7 @@ pango_font_unref
pango_font_find_shaper
pango_font_describe
pango_font_get_coverage
+pango_font_get_glyph_extents
pango_font_get_data
pango_font_set_data
<SUBSECTION>
@@ -143,6 +150,32 @@ pango_attr_iterator_destroy
</SECTION>
<SECTION>
+<TITLE>Layout Objects</TITLE>
+<FILE>layout</FILE>
+PangoLayout
+PangoLayoutLine
+PangoLayoutRun
+pango_layout_new
+pango_layout_ref
+pango_layout_unref
+
+pango_layout_set_text
+pango_layout_set_attributes
+pango_layout_set_width
+pango_layout_set_first_line_width
+pango_layout_set_justify
+
+pango_layout_cp_to_line_x
+pango_layout_get_line_count
+pango_layout_get_line
+
+pango_layout_line_ref
+pango_layout_line_unref
+pango_layout_line_x_to_cp
+pango_layout_line_get_extents
+</SECTION>
+
+<SECTION>
<TITLE>Engines</TITLE>
<FILE>engines</FILE>
PangoEngineInfo
diff --git a/docs/tmpl/fonts.sgml b/docs/tmpl/fonts.sgml
index 9b6a3f88..0f20836b 100644
--- a/docs/tmpl/fonts.sgml
+++ b/docs/tmpl/fonts.sgml
@@ -32,6 +32,7 @@ the characteristics of a font to load.
@variant: the variant (normal or small caps) of the font.
@weight: the weight (boldness) of the font.
@stretch: the relative width of the font.
+@size:
<!-- ##### ENUM PangoStyle ##### -->
<para>
@@ -112,6 +113,24 @@ within a family.
@desc:
+<!-- ##### FUNCTION pango_font_description_from_string ##### -->
+<para>
+
+</para>
+
+@str:
+@Returns:
+
+
+<!-- ##### FUNCTION pango_font_description_to_string ##### -->
+<para>
+
+</para>
+
+@desc:
+@Returns:
+
+
<!-- ##### STRUCT PangoFont ##### -->
<para>
The #PangoFont structure is used to represent
@@ -159,6 +178,7 @@ It contains the following member:
See pango_font_get_coverage().
@find_shaper: A function to find the shaper for a particular character
point. See pango_font_find_shaper.
+@get_glyph_extents:
<!-- ##### FUNCTION pango_font_init ##### -->
<para>
@@ -216,6 +236,17 @@ It contains the following member:
@Returns:
+<!-- ##### FUNCTION pango_font_get_glyph_extents ##### -->
+<para>
+
+</para>
+
+@font:
+@glyph:
+@ink_rect:
+@logical_rect:
+
+
<!-- ##### FUNCTION pango_font_get_data ##### -->
<para>
@@ -300,8 +331,9 @@ a particular #PangoFontMap implementation.
@fontmap:
@desc:
-@size:
@Returns:
+<!-- # Unused Parameters # -->
+@size:
<!-- ##### FUNCTION pango_font_map_list_families ##### -->
diff --git a/docs/tmpl/glyphs.sgml b/docs/tmpl/glyphs.sgml
index e50472f7..ad3fad44 100644
--- a/docs/tmpl/glyphs.sgml
+++ b/docs/tmpl/glyphs.sgml
@@ -17,6 +17,64 @@ glyphs.
</para>
+<!-- ##### STRUCT PangoRectangle ##### -->
+<para>
+The #PangoRectangle structure represents a rectangle. It is frequently
+used to represent the logical or ink extents of a single glyph or section
+of text. (See, for instance, pango_font_get_glyph_extents())
+</para>
+
+@x: X coordinate of the left side of the rectangle.
+@y: Y coordinate of the the top side of the rectangle.
+@width: width of the rectangle.
+@height: height of the rectangle.
+
+<!-- ##### MACRO PANGO_ASCENT ##### -->
+<para>
+Extracts the <firstterm>ascent</firstterm> from a #PangoRectangle
+representing glyph extents. The ascent is the distance from the
+baseline to the highest point of the character. This is positive if the
+glyph ascends above the baseline.
+</para>
+
+@rect: a #PangoRectangle
+
+
+<!-- ##### MACRO PANGO_DESCENT ##### -->
+<para>
+Extracts the <firstterm>descent</firstterm> from a #PangoRectangle
+representing glyph extents. The descent is the distance from the
+baseline to the lowest point of the character. This is positive if the
+glyph descends below the baseline.
+</para>
+
+@rect: a #PangoRectangle
+
+
+<!-- ##### MACRO PANGO_LBEARING ##### -->
+<para>
+Extracts the <firstterm>left bearing</firstterm> from a #PangoRectangle
+representing glyph extents. The descent is the distance from the
+horizontal origin to the farthest left point of the character.
+This is positive for characters drawn completely to the right of the
+glyph origin.
+</para>
+
+@rect: a #PangoRectangle
+
+
+<!-- ##### MACRO PANGO_RBEARING ##### -->
+<para>
+Extracts the <firstterm>left bearing</firstterm> from a #PangoRectangle
+representing glyph extents. The descent is the distance from the
+horizontal origin to the farthest left point of the character.
+This is positive except for characters drawn completely to the left of the
+horizontal origin.
+</para>
+
+@rect: a #PangoRectangle
+
+
<!-- ##### TYPEDEF PangoGlyph ##### -->
<para>
The #PangoGlyph structure represents a single glyph in the output
@@ -187,3 +245,14 @@ accessible fields
@string:
+<!-- ##### FUNCTION pango_glyph_string_extents ##### -->
+<para>
+
+</para>
+
+@glyphs:
+@font:
+@ink_rect:
+@logical_rect:
+
+
diff --git a/docs/tmpl/main.sgml b/docs/tmpl/main.sgml
index 623fe185..748419c4 100644
--- a/docs/tmpl/main.sgml
+++ b/docs/tmpl/main.sgml
@@ -214,24 +214,6 @@ It contains the following fields:
@font_map:
-<!-- ##### FUNCTION pango_context_get_size ##### -->
-<para>
-
-</para>
-
-@context:
-@Returns:
-
-
-<!-- ##### FUNCTION pango_context_set_size ##### -->
-<para>
-
-</para>
-
-@context:
-@size:
-
-
<!-- ##### FUNCTION pango_context_get_font_description ##### -->
<para>
@@ -293,8 +275,9 @@ It contains the following fields:
@context:
@desc:
-@size:
@Returns:
+<!-- # Unused Parameters # -->
+@size:
<!-- ##### FUNCTION pango_context_list_families ##### -->
diff --git a/docs/tmpl/pango-unused.sgml b/docs/tmpl/pango-unused.sgml
index 0420a65d..376bf35b 100644
--- a/docs/tmpl/pango-unused.sgml
+++ b/docs/tmpl/pango-unused.sgml
@@ -19,6 +19,14 @@ indices.
</para>
+<!-- ##### FUNCTION pango_context_get_size ##### -->
+<para>
+
+</para>
+
+@context:
+@Returns:
+
<!-- ##### FUNCTION pango_x_find_cfont ##### -->
<para>
@@ -85,6 +93,14 @@ Functions for rendering and measuring glyphs on
the X Window system.
+<!-- ##### FUNCTION pango_context_set_size ##### -->
+<para>
+
+</para>
+
+@context:
+@size:
+
<!-- ##### FUNCTION pango_attribute_register_type ##### -->
<para>
diff --git a/examples/viewer.c b/examples/viewer.c
index 9c280d65..832a248b 100644
--- a/examples/viewer.c
+++ b/examples/viewer.c
@@ -165,18 +165,26 @@ get_logical_widths (char *text, PangoItem *item,
int last_cluster = 0;
int width = 0;
int last_cluster_width = 0;
+ char *p = text + item->offset;
for (i=0; i<=glyphs->num_glyphs; i++)
{
int index = (item->analysis.level % 2 == 0) ? i : glyphs->num_glyphs - i;
if (index == glyphs->num_glyphs ||
- glyphs->log_clusters[index] != last_cluster)
+ p != text + item->offset + glyphs->log_clusters[index])
{
gint next_cluster;
if (index < glyphs->num_glyphs)
- next_cluster = glyphs->log_clusters[index];
+ {
+ next_cluster = last_cluster;
+ while (p < text + item->offset + glyphs->log_clusters[index])
+ {
+ next_cluster++;
+ p = unicode_next_utf8 (p);
+ }
+ }
else
next_cluster = item->num_chars;
@@ -199,16 +207,17 @@ get_logical_widths (char *text, PangoItem *item,
*/
gboolean
-break_run (char *text,
+break_run (char *text,
PangoItem *item,
- int *remaining_width,
+ int *remaining_width,
PangoItem **new_item,
- int *logical_ascent,
- int *logical_descent)
+ int *logical_ascent,
+ int *logical_descent)
{
PangoGlyphString *buf;
- int width;
gboolean result;
+ PangoRectangle logical_rect;
+ int width;
/* First try the entire string to see if it fits. If it
* doesn't, call GStringBreak, then chop off pieces
@@ -219,12 +228,13 @@ break_run (char *text,
buf = pango_glyph_string_new();
pango_shape (text + item->offset, item->length, &item->analysis, buf);
- pango_x_extents (item->analysis.font, buf, NULL, NULL, &width, NULL, NULL, logical_ascent, logical_descent);
+ pango_glyph_string_extents (buf, item->analysis.font, NULL, &logical_rect);
+ width = logical_rect.width;
result = FALSE;
*new_item = NULL;
- if (width <= *remaining_width)
+ if (width <= 1000 * *remaining_width)
{
result = TRUE;
}
@@ -246,8 +256,8 @@ break_run (char *text,
{
/* Shorten the item by one line break
*/
- width -= log_widths[num_chars] / 72;
- if (log_attrs[num_chars].is_break && width <= *remaining_width)
+ width -= log_widths[num_chars];
+ if (log_attrs[num_chars].is_break && width <= 1000 * *remaining_width)
break;
}
@@ -281,9 +291,15 @@ break_run (char *text,
g_free (log_attrs);
g_free (log_widths);
}
+
+ pango_shape (text + item->offset, item->length, &item->analysis, buf);
+ pango_glyph_string_extents (buf, item->analysis.font, NULL, &logical_rect);
+
+ *logical_ascent = PANGO_ASCENT (logical_rect) / 1000;
+ *logical_descent = PANGO_DESCENT (logical_rect) / 1000;
if (result)
- *remaining_width -= width;
+ *remaining_width -= logical_rect.width / 1000;
pango_glyph_string_free (buf);
@@ -428,7 +444,6 @@ gboolean
runs_x_to_cp (char *text, GList *runs, int x, int *offset)
{
PangoGlyphString *buf;
- int width;
int pixels = 0;
buf = pango_glyph_string_new();
@@ -436,29 +451,23 @@ runs_x_to_cp (char *text, GList *runs, int x, int *offset)
while (runs)
{
PangoItem *item = runs->data;
+ PangoRectangle logical_rect;
pango_shape (text + item->offset, item->length, &item->analysis, buf);
- pango_x_extents (item->analysis.font, buf, NULL, NULL, &width, NULL, NULL, NULL, NULL);
+ pango_glyph_string_extents (buf, item->analysis.font, NULL, &logical_rect);
- if (x >= pixels && x < pixels + width)
+ if (x >= pixels && x < pixels + logical_rect.width / 1000)
{
- int pos;
- char *p;
-
- pango_x_to_cp (text + item->offset, item->length,
- &item->analysis, buf, (x - pixels) * 72,
- &pos, NULL);
-
- /* Converter the character position to byte offset */
- p = text + item->offset;
- while (pos--)
- p = unicode_next_utf8 (p);
+ pango_glyph_string_x_to_index (buf, text + item->offset, item->length,
+ &item->analysis, (x - pixels) * 1000,
+ offset, NULL);
+ if (offset)
+ *offset += item->offset;
- *offset = p - text;
return TRUE;
}
- pixels += width;
+ pixels += logical_rect.width / 1000;
runs = runs->next;
}
@@ -523,7 +532,6 @@ runs_char_bounds (char *text, GList *runs, int offset, int *x, int *width)
{
int start_x;
int end_x;
- int run_width;
int pixels = 0;
PangoGlyphString *buf = pango_glyph_string_new();
@@ -531,39 +539,35 @@ runs_char_bounds (char *text, GList *runs, int offset, int *x, int *width)
while (runs)
{
PangoItem *item = runs->data;
+ PangoRectangle logical_rect;
pango_shape (text + item->offset, item->length, &item->analysis, buf);
- pango_x_extents (item->analysis.font, buf, NULL, NULL, &run_width, NULL, NULL, NULL, NULL);
if (offset >= item->offset &&
offset < item->offset + item->length)
{
- int char_pos;
-
- /* Convert byte position into character position */
- char_pos = _pango_utf8_len (text + item->offset, offset - item->offset);
-
/* Find bounds */
- pango_cp_to_x (text + item->offset, item->length,
- &item->analysis, buf, char_pos, FALSE, &start_x);
- pango_cp_to_x (text + item->offset, item->length,
- &item->analysis, buf, char_pos, TRUE, &end_x);
+ pango_glyph_string_index_to_x (buf, text + item->offset, item->length,
+ &item->analysis, offset - item->offset, FALSE, &start_x);
+ pango_glyph_string_index_to_x (buf, text + item->offset, item->length,
+ &item->analysis, offset - item->offset, TRUE, &end_x);
if (start_x < end_x)
{
- *x = pixels + start_x / 72;
- *width = (end_x - start_x) / 72;
+ *x = pixels + start_x / 1000;
+ *width = (end_x - start_x) / 1000;
}
else
{
- *x = pixels + end_x / 72;
- *width = (start_x - end_x) / 72;
+ *x = pixels + end_x / 1000;
+ *width = (start_x - end_x) / 1000;
}
break;
}
- pixels += run_width;
+ pango_glyph_string_extents (buf, item->analysis.font, NULL, &logical_rect);
+ pixels += logical_rect.width / 1000;
runs = runs->next;
}
@@ -668,6 +672,7 @@ expose_paragraph (Paragraph *para, GdkDrawable *drawable,
GList *line_list;
GList *run_list;
PangoGlyphString *buf;
+ PangoRectangle logical_rect;
int x_off;
@@ -683,7 +688,6 @@ expose_paragraph (Paragraph *para, GdkDrawable *drawable,
while (run_list)
{
PangoItem *item = run_list->data;
- int width;
/* Convert the item into glyphs */
pango_shape (para->text + item->offset, item->length,
@@ -699,9 +703,9 @@ expose_paragraph (Paragraph *para, GdkDrawable *drawable,
*/
if (run_list->next)
{
- pango_x_extents (item->analysis.font, buf, NULL, NULL, &width, NULL, NULL, NULL, NULL);
+ pango_glyph_string_extents (buf, item->analysis.font, NULL, &logical_rect);
- x_off += width;
+ x_off += logical_rect.width / 1000;
}
run_list = run_list = run_list->next;
diff --git a/modules/basic/basic-x.c b/modules/basic/basic-x.c
index acd4a947..5e524f72 100644
--- a/modules/basic/basic-x.c
+++ b/modules/basic/basic-x.c
@@ -278,20 +278,19 @@ find_char (CharCache *cache, PangoFont *font, GUChar4 wc, const char *input)
}
static void
-set_glyph (PangoFont *font, PangoGlyphString *glyphs, gint i, PangoGlyph glyph)
+set_glyph (PangoFont *font, PangoGlyphString *glyphs, int i, int offset, PangoGlyph glyph)
{
- gint width;
+ PangoRectangle logical_rect;
glyphs->glyphs[i].glyph = glyph;
glyphs->glyphs[i].geometry.x_offset = 0;
glyphs->glyphs[i].geometry.y_offset = 0;
- glyphs->log_clusters[i] = i;
+ glyphs->log_clusters[i] = offset;
- pango_x_glyph_extents (font, glyphs->glyphs[i].glyph,
- NULL, NULL, &width, NULL, NULL, NULL, NULL);
- glyphs->glyphs[i].geometry.width = width * 72;
+ pango_font_get_glyph_extents (font, glyphs->glyphs[i].glyph, NULL, &logical_rect);
+ glyphs->glyphs[i].geometry.width = logical_rect.width;
}
static iconv_t
@@ -445,7 +444,7 @@ basic_engine_shape (PangoFont *font,
index = find_char (cache, font, wc, p);
if (index)
{
- set_glyph (font, glyphs, i, index);
+ set_glyph (font, glyphs, i, p - text, index);
if (unicode_type (wc) == UNICODE_NON_SPACING_MARK)
{
@@ -459,7 +458,7 @@ basic_engine_shape (PangoFont *font,
}
}
else
- set_glyph (font, glyphs, i, pango_x_get_unknown_glyph (font));
+ set_glyph (font, glyphs, i, p - text, pango_x_get_unknown_glyph (font));
p = next;
}
diff --git a/modules/basic/basic.c b/modules/basic/basic.c
index acd4a947..5e524f72 100644
--- a/modules/basic/basic.c
+++ b/modules/basic/basic.c
@@ -278,20 +278,19 @@ find_char (CharCache *cache, PangoFont *font, GUChar4 wc, const char *input)
}
static void
-set_glyph (PangoFont *font, PangoGlyphString *glyphs, gint i, PangoGlyph glyph)
+set_glyph (PangoFont *font, PangoGlyphString *glyphs, int i, int offset, PangoGlyph glyph)
{
- gint width;
+ PangoRectangle logical_rect;
glyphs->glyphs[i].glyph = glyph;
glyphs->glyphs[i].geometry.x_offset = 0;
glyphs->glyphs[i].geometry.y_offset = 0;
- glyphs->log_clusters[i] = i;
+ glyphs->log_clusters[i] = offset;
- pango_x_glyph_extents (font, glyphs->glyphs[i].glyph,
- NULL, NULL, &width, NULL, NULL, NULL, NULL);
- glyphs->glyphs[i].geometry.width = width * 72;
+ pango_font_get_glyph_extents (font, glyphs->glyphs[i].glyph, NULL, &logical_rect);
+ glyphs->glyphs[i].geometry.width = logical_rect.width;
}
static iconv_t
@@ -445,7 +444,7 @@ basic_engine_shape (PangoFont *font,
index = find_char (cache, font, wc, p);
if (index)
{
- set_glyph (font, glyphs, i, index);
+ set_glyph (font, glyphs, i, p - text, index);
if (unicode_type (wc) == UNICODE_NON_SPACING_MARK)
{
@@ -459,7 +458,7 @@ basic_engine_shape (PangoFont *font,
}
}
else
- set_glyph (font, glyphs, i, pango_x_get_unknown_glyph (font));
+ set_glyph (font, glyphs, i, p - text, pango_x_get_unknown_glyph (font));
p = next;
}
diff --git a/modules/hangul/hangul-x.c b/modules/hangul/hangul-x.c
index 8b07f115..4a3aeb96 100644
--- a/modules/hangul/hangul-x.c
+++ b/modules/hangul/hangul-x.c
@@ -87,19 +87,21 @@ hangul_engine_lang_new ()
*/
static void
-set_glyph (PangoGlyphString *glyphs, int i,
- PangoFont *font, PangoXSubfont subfont, guint16 gindex)
+set_glyph (PangoGlyphString *glyphs,
+ int i,
+ PangoFont *font,
+ PangoXSubfont subfont,
+ guint16 gindex)
{
- int width;
+ PangoRectangle logical_rect;
glyphs->glyphs[i].glyph = PANGO_X_MAKE_GLYPH (subfont, gindex);
glyphs->glyphs[i].geometry.x_offset = 0;
glyphs->glyphs[i].geometry.y_offset = 0;
- pango_x_glyph_extents (font, glyphs->glyphs[i].glyph,
- NULL, NULL, &width, NULL, NULL, NULL, NULL);
- glyphs->glyphs[i].geometry.width = width * 72;
+ pango_font_get_glyph_extents (font, glyphs->glyphs[i].glyph, NULL, &logical_rect);
+ glyphs->glyphs[i].geometry.width = logical_rect.width;
}
@@ -134,7 +136,7 @@ set_glyph (PangoGlyphString *glyphs, int i,
typedef void (* RenderSyllableFunc) (PangoFont *font, PangoXSubfont subfont,
GUChar2 *text, int length,
PangoGlyphString *glyphs,
- int *n_glyphs, int n_clusters);
+ int *n_glyphs, int cluster_offset);
@@ -210,7 +212,7 @@ typedef void (* RenderSyllableFunc) (PangoFont *font, PangoXSubfont subfont,
} \
pango_glyph_string_set_size (glyphs, *n_glyphs + 1); \
set_glyph (glyphs, *n_glyphs, font, subfont, gindex); \
- glyphs->log_clusters[*n_glyphs] = n_clusters; \
+ glyphs->log_clusters[*n_glyphs] = cluster_offset; \
(*n_glyphs)++; \
} \
\
@@ -230,7 +232,7 @@ typedef void (* RenderSyllableFunc) (PangoFont *font, PangoXSubfont subfont,
\
pango_glyph_string_set_size (glyphs, *n_glyphs + 1); \
set_glyph (glyphs, *n_glyphs, font, subfont, gindex); \
- glyphs->log_clusters[*n_glyphs] = n_clusters; \
+ glyphs->log_clusters[*n_glyphs] = cluster_offset; \
(*n_glyphs)++; \
} \
\
@@ -240,7 +242,7 @@ typedef void (* RenderSyllableFunc) (PangoFont *font, PangoXSubfont subfont,
__jongseong_map[v - VBASE]; \
pango_glyph_string_set_size (glyphs, *n_glyphs + 1); \
set_glyph (glyphs, *n_glyphs, font, subfont, gindex); \
- glyphs->log_clusters[*n_glyphs] = n_clusters; \
+ glyphs->log_clusters[*n_glyphs] = cluster_offset; \
(*n_glyphs)++; \
} \
\
@@ -248,7 +250,7 @@ typedef void (* RenderSyllableFunc) (PangoFont *font, PangoXSubfont subfont,
{ \
pango_glyph_string_set_size (glyphs, *n_glyphs + 1); \
set_glyph (glyphs, *n_glyphs, font, subfont, JOHAB_FILLER); \
- glyphs->log_clusters[*n_glyphs] = n_clusters; \
+ glyphs->log_clusters[*n_glyphs] = cluster_offset; \
(*n_glyphs)++; \
} \
\
@@ -260,7 +262,7 @@ static void
render_syllable_with_johabs (PangoFont *font, PangoXSubfont subfont,
GUChar2 *text, int length,
PangoGlyphString *glyphs,
- int *n_glyphs, int n_clusters)
+ int *n_glyphs, int cluster_offset)
{
JOHAB_COMMON
@@ -289,7 +291,7 @@ JOHAB_COMMON
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
set_glyph (glyphs, *n_glyphs, font, subfont, gindex);
- glyphs->log_clusters[*n_glyphs] = n_clusters;
+ glyphs->log_clusters[*n_glyphs] = cluster_offset;
(*n_glyphs)++;
}
else
@@ -302,7 +304,7 @@ static void
render_syllable_with_johab (PangoFont *font, PangoXSubfont subfont,
GUChar2 *text, int length,
PangoGlyphString *glyphs,
- int *n_glyphs, int n_clusters)
+ int *n_glyphs, int cluster_offset)
{
JOHAB_COMMON
@@ -318,13 +320,13 @@ JOHAB_COMMON
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
set_glyph (glyphs, *n_glyphs, font, subfont,
__jamo_to_johabfont[wc - LBASE][j]);
- glyphs->log_clusters[*n_glyphs] = n_clusters;
+ glyphs->log_clusters[*n_glyphs] = cluster_offset;
(*n_glyphs)++;
if (IS_L (wc))
{
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
set_glyph (glyphs, *n_glyphs, font, subfont, JOHAB_FILLER);
- glyphs->log_clusters[*n_glyphs] = n_clusters;
+ glyphs->log_clusters[*n_glyphs] = cluster_offset;
(*n_glyphs)++;
}
}
@@ -335,7 +337,7 @@ static void
render_syllable_with_iso10646 (PangoFont *font, PangoXSubfont subfont,
GUChar2 *text, int length,
PangoGlyphString *glyphs,
- int *n_glyphs, int n_clusters)
+ int *n_glyphs, int cluster_offset)
{
guint16 gindex;
int i;
@@ -382,7 +384,7 @@ render_syllable_with_iso10646 (PangoFont *font, PangoXSubfont subfont,
/* easy for composed syllables. */
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
set_glyph (glyphs, *n_glyphs, font, subfont, gindex);
- glyphs->log_clusters[*n_glyphs] = n_clusters;
+ glyphs->log_clusters[*n_glyphs] = cluster_offset;
(*n_glyphs)++;
return;
}
@@ -394,7 +396,7 @@ render_syllable_with_iso10646 (PangoFont *font, PangoXSubfont subfont,
gindex = text[i];
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
set_glyph (glyphs, *n_glyphs, font, subfont, gindex);
- glyphs->log_clusters[*n_glyphs] = n_clusters;
+ glyphs->log_clusters[*n_glyphs] = cluster_offset;
(*n_glyphs)++;
}
}
@@ -403,7 +405,7 @@ static void
render_syllable_with_ksc5601 (PangoFont *font, PangoXSubfont subfont,
GUChar2 *text, int length,
PangoGlyphString *glyphs,
- int *n_glyphs, int n_clusters)
+ int *n_glyphs, int cluster_offset)
{
guint16 sindex;
guint16 gindex;
@@ -468,7 +470,7 @@ render_syllable_with_ksc5601 (PangoFont *font, PangoXSubfont subfont,
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
set_glyph (glyphs, *n_glyphs, font, subfont, gindex);
- glyphs->log_clusters[*n_glyphs] = n_clusters;
+ glyphs->log_clusters[*n_glyphs] = cluster_offset;
(*n_glyphs)++;
return;
}
@@ -486,7 +488,7 @@ render_syllable_with_ksc5601 (PangoFont *font, PangoXSubfont subfont,
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
set_glyph (glyphs, *n_glyphs, font, subfont,
__jamo_to_ksc5601[gindex - LBASE][j]);
- glyphs->log_clusters[*n_glyphs] = n_clusters;
+ glyphs->log_clusters[*n_glyphs] = cluster_offset;
(*n_glyphs)++;
}
}
@@ -589,7 +591,7 @@ hangul_engine_shape (PangoFont *font,
GUChar2 jamos[4];
int n_jamos = 0;
- int n_glyphs = 0, n_clusters = 0;
+ int n_glyphs = 0, cluster_offset = 0;
g_return_if_fail (font != NULL);
g_return_if_fail (text != NULL);
@@ -641,15 +643,15 @@ hangul_engine_shape (PangoFont *font,
if (n_jamos > 0)
{
(*render_func) (font, subfont, jamos, n_jamos,
- glyphs, &n_glyphs, n_clusters);
- n_clusters++;
+ glyphs, &n_glyphs, cluster_offset);
+ cluster_offset = next - text;
n_jamos = 0;
}
/* Draw a syllable. */
(*render_func) (font, subfont, wcs, 3,
- glyphs, &n_glyphs, n_clusters);
- n_clusters++;
+ glyphs, &n_glyphs, cluster_offset);
+ cluster_offset = next - text;
/* Clear. */
}
else if (wc4 >= 0x1100 && wc4 <= 0x11ff)
@@ -669,8 +671,8 @@ hangul_engine_shape (PangoFont *font,
{
/* Draw a syllable. */
(*render_func) (font, subfont, jamos, n_jamos,
- glyphs, &n_glyphs, n_clusters);
- n_clusters++;
+ glyphs, &n_glyphs, cluster_offset);
+ cluster_offset = next - text;
/* Clear. */
n_jamos = 0;
}
@@ -690,8 +692,8 @@ hangul_engine_shape (PangoFont *font,
if (n_jamos > 0)
{
(*render_func) (font, subfont, jamos, n_jamos,
- glyphs, &n_glyphs, n_clusters);
- n_clusters++;
+ glyphs, &n_glyphs, cluster_offset);
+ cluster_offset = next - text;
n_jamos = 0;
}
}
diff --git a/modules/hangul/hangul.c b/modules/hangul/hangul.c
index 8b07f115..4a3aeb96 100644
--- a/modules/hangul/hangul.c
+++ b/modules/hangul/hangul.c
@@ -87,19 +87,21 @@ hangul_engine_lang_new ()
*/
static void
-set_glyph (PangoGlyphString *glyphs, int i,
- PangoFont *font, PangoXSubfont subfont, guint16 gindex)
+set_glyph (PangoGlyphString *glyphs,
+ int i,
+ PangoFont *font,
+ PangoXSubfont subfont,
+ guint16 gindex)
{
- int width;
+ PangoRectangle logical_rect;
glyphs->glyphs[i].glyph = PANGO_X_MAKE_GLYPH (subfont, gindex);
glyphs->glyphs[i].geometry.x_offset = 0;
glyphs->glyphs[i].geometry.y_offset = 0;
- pango_x_glyph_extents (font, glyphs->glyphs[i].glyph,
- NULL, NULL, &width, NULL, NULL, NULL, NULL);
- glyphs->glyphs[i].geometry.width = width * 72;
+ pango_font_get_glyph_extents (font, glyphs->glyphs[i].glyph, NULL, &logical_rect);
+ glyphs->glyphs[i].geometry.width = logical_rect.width;
}
@@ -134,7 +136,7 @@ set_glyph (PangoGlyphString *glyphs, int i,
typedef void (* RenderSyllableFunc) (PangoFont *font, PangoXSubfont subfont,
GUChar2 *text, int length,
PangoGlyphString *glyphs,
- int *n_glyphs, int n_clusters);
+ int *n_glyphs, int cluster_offset);
@@ -210,7 +212,7 @@ typedef void (* RenderSyllableFunc) (PangoFont *font, PangoXSubfont subfont,
} \
pango_glyph_string_set_size (glyphs, *n_glyphs + 1); \
set_glyph (glyphs, *n_glyphs, font, subfont, gindex); \
- glyphs->log_clusters[*n_glyphs] = n_clusters; \
+ glyphs->log_clusters[*n_glyphs] = cluster_offset; \
(*n_glyphs)++; \
} \
\
@@ -230,7 +232,7 @@ typedef void (* RenderSyllableFunc) (PangoFont *font, PangoXSubfont subfont,
\
pango_glyph_string_set_size (glyphs, *n_glyphs + 1); \
set_glyph (glyphs, *n_glyphs, font, subfont, gindex); \
- glyphs->log_clusters[*n_glyphs] = n_clusters; \
+ glyphs->log_clusters[*n_glyphs] = cluster_offset; \
(*n_glyphs)++; \
} \
\
@@ -240,7 +242,7 @@ typedef void (* RenderSyllableFunc) (PangoFont *font, PangoXSubfont subfont,
__jongseong_map[v - VBASE]; \
pango_glyph_string_set_size (glyphs, *n_glyphs + 1); \
set_glyph (glyphs, *n_glyphs, font, subfont, gindex); \
- glyphs->log_clusters[*n_glyphs] = n_clusters; \
+ glyphs->log_clusters[*n_glyphs] = cluster_offset; \
(*n_glyphs)++; \
} \
\
@@ -248,7 +250,7 @@ typedef void (* RenderSyllableFunc) (PangoFont *font, PangoXSubfont subfont,
{ \
pango_glyph_string_set_size (glyphs, *n_glyphs + 1); \
set_glyph (glyphs, *n_glyphs, font, subfont, JOHAB_FILLER); \
- glyphs->log_clusters[*n_glyphs] = n_clusters; \
+ glyphs->log_clusters[*n_glyphs] = cluster_offset; \
(*n_glyphs)++; \
} \
\
@@ -260,7 +262,7 @@ static void
render_syllable_with_johabs (PangoFont *font, PangoXSubfont subfont,
GUChar2 *text, int length,
PangoGlyphString *glyphs,
- int *n_glyphs, int n_clusters)
+ int *n_glyphs, int cluster_offset)
{
JOHAB_COMMON
@@ -289,7 +291,7 @@ JOHAB_COMMON
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
set_glyph (glyphs, *n_glyphs, font, subfont, gindex);
- glyphs->log_clusters[*n_glyphs] = n_clusters;
+ glyphs->log_clusters[*n_glyphs] = cluster_offset;
(*n_glyphs)++;
}
else
@@ -302,7 +304,7 @@ static void
render_syllable_with_johab (PangoFont *font, PangoXSubfont subfont,
GUChar2 *text, int length,
PangoGlyphString *glyphs,
- int *n_glyphs, int n_clusters)
+ int *n_glyphs, int cluster_offset)
{
JOHAB_COMMON
@@ -318,13 +320,13 @@ JOHAB_COMMON
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
set_glyph (glyphs, *n_glyphs, font, subfont,
__jamo_to_johabfont[wc - LBASE][j]);
- glyphs->log_clusters[*n_glyphs] = n_clusters;
+ glyphs->log_clusters[*n_glyphs] = cluster_offset;
(*n_glyphs)++;
if (IS_L (wc))
{
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
set_glyph (glyphs, *n_glyphs, font, subfont, JOHAB_FILLER);
- glyphs->log_clusters[*n_glyphs] = n_clusters;
+ glyphs->log_clusters[*n_glyphs] = cluster_offset;
(*n_glyphs)++;
}
}
@@ -335,7 +337,7 @@ static void
render_syllable_with_iso10646 (PangoFont *font, PangoXSubfont subfont,
GUChar2 *text, int length,
PangoGlyphString *glyphs,
- int *n_glyphs, int n_clusters)
+ int *n_glyphs, int cluster_offset)
{
guint16 gindex;
int i;
@@ -382,7 +384,7 @@ render_syllable_with_iso10646 (PangoFont *font, PangoXSubfont subfont,
/* easy for composed syllables. */
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
set_glyph (glyphs, *n_glyphs, font, subfont, gindex);
- glyphs->log_clusters[*n_glyphs] = n_clusters;
+ glyphs->log_clusters[*n_glyphs] = cluster_offset;
(*n_glyphs)++;
return;
}
@@ -394,7 +396,7 @@ render_syllable_with_iso10646 (PangoFont *font, PangoXSubfont subfont,
gindex = text[i];
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
set_glyph (glyphs, *n_glyphs, font, subfont, gindex);
- glyphs->log_clusters[*n_glyphs] = n_clusters;
+ glyphs->log_clusters[*n_glyphs] = cluster_offset;
(*n_glyphs)++;
}
}
@@ -403,7 +405,7 @@ static void
render_syllable_with_ksc5601 (PangoFont *font, PangoXSubfont subfont,
GUChar2 *text, int length,
PangoGlyphString *glyphs,
- int *n_glyphs, int n_clusters)
+ int *n_glyphs, int cluster_offset)
{
guint16 sindex;
guint16 gindex;
@@ -468,7 +470,7 @@ render_syllable_with_ksc5601 (PangoFont *font, PangoXSubfont subfont,
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
set_glyph (glyphs, *n_glyphs, font, subfont, gindex);
- glyphs->log_clusters[*n_glyphs] = n_clusters;
+ glyphs->log_clusters[*n_glyphs] = cluster_offset;
(*n_glyphs)++;
return;
}
@@ -486,7 +488,7 @@ render_syllable_with_ksc5601 (PangoFont *font, PangoXSubfont subfont,
pango_glyph_string_set_size (glyphs, *n_glyphs + 1);
set_glyph (glyphs, *n_glyphs, font, subfont,
__jamo_to_ksc5601[gindex - LBASE][j]);
- glyphs->log_clusters[*n_glyphs] = n_clusters;
+ glyphs->log_clusters[*n_glyphs] = cluster_offset;
(*n_glyphs)++;
}
}
@@ -589,7 +591,7 @@ hangul_engine_shape (PangoFont *font,
GUChar2 jamos[4];
int n_jamos = 0;
- int n_glyphs = 0, n_clusters = 0;
+ int n_glyphs = 0, cluster_offset = 0;
g_return_if_fail (font != NULL);
g_return_if_fail (text != NULL);
@@ -641,15 +643,15 @@ hangul_engine_shape (PangoFont *font,
if (n_jamos > 0)
{
(*render_func) (font, subfont, jamos, n_jamos,
- glyphs, &n_glyphs, n_clusters);
- n_clusters++;
+ glyphs, &n_glyphs, cluster_offset);
+ cluster_offset = next - text;
n_jamos = 0;
}
/* Draw a syllable. */
(*render_func) (font, subfont, wcs, 3,
- glyphs, &n_glyphs, n_clusters);
- n_clusters++;
+ glyphs, &n_glyphs, cluster_offset);
+ cluster_offset = next - text;
/* Clear. */
}
else if (wc4 >= 0x1100 && wc4 <= 0x11ff)
@@ -669,8 +671,8 @@ hangul_engine_shape (PangoFont *font,
{
/* Draw a syllable. */
(*render_func) (font, subfont, jamos, n_jamos,
- glyphs, &n_glyphs, n_clusters);
- n_clusters++;
+ glyphs, &n_glyphs, cluster_offset);
+ cluster_offset = next - text;
/* Clear. */
n_jamos = 0;
}
@@ -690,8 +692,8 @@ hangul_engine_shape (PangoFont *font,
if (n_jamos > 0)
{
(*render_func) (font, subfont, jamos, n_jamos,
- glyphs, &n_glyphs, n_clusters);
- n_clusters++;
+ glyphs, &n_glyphs, cluster_offset);
+ cluster_offset = next - text;
n_jamos = 0;
}
}
diff --git a/modules/tamil/tamil-x.c b/modules/tamil/tamil-x.c
index 908aaa94..9d7b4e92 100644
--- a/modules/tamil/tamil-x.c
+++ b/modules/tamil/tamil-x.c
@@ -11,6 +11,7 @@
#include "pangox.h"
#include "utils.h"
#include "taconv.h"
+#include <unicode.h>
static PangoEngineRange tamil_range[] = {
{ 0x0b80, 0x0bff, "*" },
@@ -94,21 +95,21 @@ tamil_engine_lang_new ()
* But we can live with this for time being
*/
static void
-set_glyph (PangoGlyphString *glyphs, int i,
+set_glyph (PangoGlyphString *glyphs, int i, int cluster_start,
PangoFont *font, PangoXSubfont subfont, guint16 gindex)
{
int width;
+ PangoRectangle logical_rect;
glyphs->glyphs[i].glyph = PANGO_X_MAKE_GLYPH (subfont, gindex);
glyphs->glyphs[i].geometry.x_offset = 0;
glyphs->glyphs[i].geometry.y_offset = 0;
- glyphs->log_clusters[i] = i;
+ glyphs->log_clusters[i] = cluster_start;
- pango_x_glyph_extents (font, glyphs->glyphs[i].glyph,
- NULL, NULL, &width, NULL, NULL, NULL, NULL);
- glyphs->glyphs[i].geometry.width = width * 72;
+ pango_font_get_glyph_extents (font, glyphs->glyphs[i].glyph, NULL, &logical_rect);
+ glyphs->glyphs[i].geometry.width = logical_rect.width;
}
static PangoXSubfont
@@ -140,6 +141,7 @@ tamil_engine_shape (PangoFont *font,
{
int n_chars, n_glyph;
int i, j;
+ const char *cluster_start;
const char *p;
const char *next;
GUChar4 *wc, *uni_str;
@@ -177,6 +179,7 @@ tamil_engine_shape (PangoFont *font,
n_glyph = 0;
uni_str = wc;
+ cluster_start = text;
j = 0;
while (j < n_chars)
{
@@ -186,17 +189,19 @@ tamil_engine_shape (PangoFont *font,
/* We need to differentiate between different return codes later */
if (res != TA_SUCCESS)
{
- set_glyph (glyphs, n_glyph, font, tscii_font, ' ');
+ set_glyph (glyphs, n_glyph, cluster_start - text, font, tscii_font, ' ');
n_glyph++;
j = j + nuni;
continue;
}
for (i = 0; i < ntsc; i++)
{
- set_glyph (glyphs, n_glyph, font, tscii_font, (PangoGlyph) tsc_str[i]);
+ set_glyph (glyphs, n_glyph, cluster_start - text, font, tscii_font, (PangoGlyph) tsc_str[i]);
n_glyph++;
}
j = j + nuni;
+ while (nuni--)
+ cluster_start = unicode_next_utf8 (cluster_start);
}
pango_glyph_string_set_size (glyphs, n_glyph);
diff --git a/modules/tamil/tamil.c b/modules/tamil/tamil.c
index 908aaa94..9d7b4e92 100644
--- a/modules/tamil/tamil.c
+++ b/modules/tamil/tamil.c
@@ -11,6 +11,7 @@
#include "pangox.h"
#include "utils.h"
#include "taconv.h"
+#include <unicode.h>
static PangoEngineRange tamil_range[] = {
{ 0x0b80, 0x0bff, "*" },
@@ -94,21 +95,21 @@ tamil_engine_lang_new ()
* But we can live with this for time being
*/
static void
-set_glyph (PangoGlyphString *glyphs, int i,
+set_glyph (PangoGlyphString *glyphs, int i, int cluster_start,
PangoFont *font, PangoXSubfont subfont, guint16 gindex)
{
int width;
+ PangoRectangle logical_rect;
glyphs->glyphs[i].glyph = PANGO_X_MAKE_GLYPH (subfont, gindex);
glyphs->glyphs[i].geometry.x_offset = 0;
glyphs->glyphs[i].geometry.y_offset = 0;
- glyphs->log_clusters[i] = i;
+ glyphs->log_clusters[i] = cluster_start;
- pango_x_glyph_extents (font, glyphs->glyphs[i].glyph,
- NULL, NULL, &width, NULL, NULL, NULL, NULL);
- glyphs->glyphs[i].geometry.width = width * 72;
+ pango_font_get_glyph_extents (font, glyphs->glyphs[i].glyph, NULL, &logical_rect);
+ glyphs->glyphs[i].geometry.width = logical_rect.width;
}
static PangoXSubfont
@@ -140,6 +141,7 @@ tamil_engine_shape (PangoFont *font,
{
int n_chars, n_glyph;
int i, j;
+ const char *cluster_start;
const char *p;
const char *next;
GUChar4 *wc, *uni_str;
@@ -177,6 +179,7 @@ tamil_engine_shape (PangoFont *font,
n_glyph = 0;
uni_str = wc;
+ cluster_start = text;
j = 0;
while (j < n_chars)
{
@@ -186,17 +189,19 @@ tamil_engine_shape (PangoFont *font,
/* We need to differentiate between different return codes later */
if (res != TA_SUCCESS)
{
- set_glyph (glyphs, n_glyph, font, tscii_font, ' ');
+ set_glyph (glyphs, n_glyph, cluster_start - text, font, tscii_font, ' ');
n_glyph++;
j = j + nuni;
continue;
}
for (i = 0; i < ntsc; i++)
{
- set_glyph (glyphs, n_glyph, font, tscii_font, (PangoGlyph) tsc_str[i]);
+ set_glyph (glyphs, n_glyph, cluster_start - text, font, tscii_font, (PangoGlyph) tsc_str[i]);
n_glyph++;
}
j = j + nuni;
+ while (nuni--)
+ cluster_start = unicode_next_utf8 (cluster_start);
}
pango_glyph_string_set_size (glyphs, n_glyph);
diff --git a/pango/fonts.c b/pango/fonts.c
index c6e4cbd8..9ff5d7d6 100644
--- a/pango/fonts.c
+++ b/pango/fonts.c
@@ -495,9 +495,36 @@ pango_font_find_shaper (PangoFont *font,
return font->klass->find_shaper (font, lang, ch);
}
-
/**
+ * pango_font_get_glyph_extents:
+ * @font: a #PangoFont
+ * @glyph: the glyph index
+ * @ink_rect: rectangle used to store the extents of the glyph as drawn
+ * or %NULL to indicate that the result is not needed.
+ * @logical_rect: rectangle used to store the logical extents of the glyph
+ * or %NULL to indicate that the result is not needed.
+ *
+ * Get the logical and ink extents of a glyph within a font. The
+ * coordinate system for each rectangle has its origin at the
+ * base line and horizontal origin of the character with increasing
+ * coordinates extending to the right and down. The macros PANGO_ASCENT(),
+ * PANGO_DESCENT(), PANGO_LBEARING(), and PANGO_RBEARING can be used to convert
+ * from the extents rectangle to more traditional font metrics. The units
+ * of the rectangles are in 1000ths of a device unit.
+ **/
+void
+pango_font_get_glyph_extents (PangoFont *font,
+ PangoGlyph glyph,
+ PangoRectangle *ink_rect,
+ PangoRectangle *logical_rect)
+{
+ g_return_if_fail (font != NULL);
+
+ font->klass->get_glyph_extents (font, glyph, ink_rect, logical_rect);
+}
+
+/**
* pango_font_map_init:
* @fontmap: a #PangoFontMap
*
diff --git a/pango/glyphstring.c b/pango/glyphstring.c
index a7cc9cea..b29efe09 100644
--- a/pango/glyphstring.c
+++ b/pango/glyphstring.c
@@ -20,7 +20,8 @@
*/
#include <glib.h>
-#include <pango.h>
+#include <pango-glyph.h>
+#include <pango-font.h>
/**
* pango_glyph_string_new:
@@ -83,3 +84,97 @@ pango_glyph_string_free (PangoGlyphString *string)
g_free (string->log_clusters);
g_free (string);
}
+
+/**
+ * pango_glyph_string_extents:
+ * @glyphs: a #PangoGlyphString
+ * @font: a #PangoFont
+ * @ink_rect: rectangle used to store the extents of the glyph string as drawn
+ * or %NULL to indicate that the result is not needed.
+ * @logical_rect: rectangle used to store the logical extents of the glyph string
+ * or %NULL to indicate that the result is not needed.
+ *
+ * Compute the logical and ink extents of a glyph string. See the documentation
+ * for pango_font_get_glyph_extents() for details about the interpretation
+ * of the rectangles.
+ */
+void
+pango_glyph_string_extents (PangoGlyphString *glyphs,
+ PangoFont *font,
+ PangoRectangle *ink_rect,
+ PangoRectangle *logical_rect)
+{
+ int x_pos = 0;
+ int i;
+
+ if (glyphs->num_glyphs == 0)
+ {
+ if (ink_rect)
+ {
+ ink_rect->x = 0;
+ ink_rect->y = 0;
+ ink_rect->width = 0;
+ ink_rect->height = 0;
+ }
+
+ if (logical_rect)
+ {
+ logical_rect->x = 0;
+ logical_rect->y = 0;
+ logical_rect->width = 0;
+ logical_rect->height = 0;
+ }
+
+ return;
+ }
+
+ for (i=0; i<glyphs->num_glyphs; i++)
+ {
+ PangoRectangle glyph_ink;
+ PangoRectangle glyph_logical;
+
+ PangoGlyphGeometry *geometry = &glyphs->glyphs[i].geometry;
+
+ if (i == 0)
+ {
+ pango_font_get_glyph_extents (font, glyphs->glyphs[i].glyph, ink_rect, logical_rect);
+ }
+ else
+ {
+ int new_pos;
+
+ pango_font_get_glyph_extents (font, glyphs->glyphs[i].glyph,
+ ink_rect ? &glyph_ink : NULL,
+ logical_rect ? &glyph_logical : NULL);
+
+ if (ink_rect)
+ {
+ new_pos = MIN (ink_rect->x, x_pos + glyph_ink.x + geometry->x_offset);
+ ink_rect->width = MAX (ink_rect->x + ink_rect->width,
+ x_pos + glyph_ink.x + glyph_ink.width + geometry->x_offset) - ink_rect->x;
+ ink_rect->x = new_pos;
+
+ new_pos = MIN (ink_rect->y, glyph_ink.y + geometry->y_offset);
+ ink_rect->height = MAX (ink_rect->y + ink_rect->height,
+ glyph_ink.y + glyph_ink.height + geometry->y_offset) - ink_rect->y;
+ ink_rect->y = new_pos;
+ }
+
+ if (logical_rect)
+ {
+ new_pos = MIN (logical_rect->x, x_pos + glyph_logical.x + geometry->x_offset);
+ logical_rect->width = MAX (logical_rect->x + logical_rect->width,
+ x_pos + glyph_logical.x + glyph_logical.width + geometry->x_offset) - logical_rect->x;
+ logical_rect->x = new_pos;
+
+ new_pos = MIN (logical_rect->y, glyph_logical.y + geometry->y_offset);
+ logical_rect->height = MAX (logical_rect->y + logical_rect->height,
+ glyph_logical.y + glyph_logical.height + geometry->y_offset) - logical_rect->y;
+ logical_rect->y = new_pos;
+ }
+ }
+
+ x_pos += geometry->width;
+ }
+}
+
diff --git a/pango/mapping.c b/pango/mapping.c
index 470b2085..d075b9f8 100644
--- a/pango/mapping.c
+++ b/pango/mapping.c
@@ -32,12 +32,12 @@
#include <unicode.h>
/**
- * pango_cp_to_x:
+ * pango_glyph_string_index_to_x:
+ * @glyphs: the glyphs return from pango_shape()
* @text: the text for the run
* @length: the number of bytes (not characters) in @text.
* @analysis: the analysis information return from pango_itemize()
- * @glyphs: the glyphs return from pango_shape()
- * @char_pos: the character position
+ * @index: the byte index within @text
* @trailing: whether we should compute the result for the beginning
* or end of the character (or cluster - the decision
* for which may be script dependent).
@@ -48,22 +48,27 @@
*/
void
-pango_cp_to_x (gchar *text,
- gint length,
- PangoAnalysis *analysis,
- PangoGlyphString *glyphs,
- gint char_pos,
- gboolean trailing,
- gint *x_pos)
+pango_glyph_string_index_to_x (PangoGlyphString *glyphs,
+ char *text,
+ int length,
+ PangoAnalysis *analysis,
+ int index,
+ gboolean trailing,
+ int *x_pos)
{
- gint i;
- gint start_xpos = 0;
- gint end_xpos = 0;
- gint width = 0;
+ int i;
+ int start_xpos = 0;
+ int end_xpos = 0;
+ int width = 0;
+
+ int start_index = -1;
+ int end_index = -1;
- gint start_char = -1;
- gint end_char = -1;
+ int cluster_chars = 0;
+ int cluster_offset = 0;
+ char *p;
+
g_return_if_fail (glyphs != NULL);
g_return_if_fail (length >= 0);
g_return_if_fail (length == 0 || text != NULL);
@@ -87,16 +92,16 @@ pango_cp_to_x (gchar *text,
for (i = glyphs->num_glyphs - 1; i >= 0; i--)
{
- if (glyphs->log_clusters[i] > char_pos)
+ if (glyphs->log_clusters[i] > index)
{
- end_char = glyphs->log_clusters[i];
+ end_index = glyphs->log_clusters[i];
end_xpos = width;
break;
}
- if (start_char == -1 || glyphs->log_clusters[i] != start_char)
+ if (glyphs->log_clusters[i] != start_index)
{
- start_char = glyphs->log_clusters[i];
+ start_index = glyphs->log_clusters[i];
start_xpos = width;
}
@@ -107,16 +112,16 @@ pango_cp_to_x (gchar *text,
{
for (i = 0; i < glyphs->num_glyphs; i++)
{
- if (glyphs->log_clusters[i] > char_pos)
+ if (glyphs->log_clusters[i] > index)
{
- end_char = glyphs->log_clusters[i];
+ end_index = glyphs->log_clusters[i];
end_xpos = width;
break;
}
- if (start_char == -1 || glyphs->log_clusters[i] != start_char)
+ if (glyphs->log_clusters[i] != start_index)
{
- start_char = glyphs->log_clusters[i];
+ start_index = glyphs->log_clusters[i];
start_xpos = width;
}
@@ -124,36 +129,43 @@ pango_cp_to_x (gchar *text,
}
}
- /* We need the character index of one past the end of the
- * string, and so we have to recalculate the entire length
- * of the string...
- */
- if (end_char == -1)
+ if (end_index == -1)
{
- end_char = unicode_strlen (text, length);
+ end_index = length;
end_xpos = (analysis->level % 2) ? 0 : width;
}
+ /* Calculate offset of character within cluster */
+
+ p = text + start_index;
+ while (p < text + end_index)
+ {
+ p = unicode_next_utf8 (p);
+ if (p < text + index)
+ cluster_offset++;
+ cluster_chars++;
+ }
+
/* Now interpolate the result. For South Asian languages
* we actually shouldn't iterpolate
*/
if (trailing)
- char_pos += 1;
+ cluster_offset += 1;
- *x_pos = (((double)(end_char - char_pos)) * start_xpos +
- ((double)(char_pos - start_char)) * end_xpos) /
- (end_char - start_char);
+ *x_pos = (((double)(cluster_chars - cluster_offset)) * start_xpos +
+ ((double)cluster_offset) * end_xpos) /
+ cluster_chars;
}
/**
- * pango_x_to_cp:
+ * pango_glyph_string_x_to_index:
+ * @glyphs: the glyphs return from pango_shape()
* @text: the text for the run
* @length: the number of bytes (not characters) in text.
* @analysis: the analysis information return from pango_itemize()
- * @glyphs: the glyphs return from pango_shape()
- * @x_pos: location to store the returned x character position
- * @char_pos: location to store calculated character position.
+ * @x_pos: the x offset (in thousands of a device unit)
+ * @index: location to store calculated byte index within @text
* @trailing: location to store a integer indicating where
* in the cluster the user clicked. If the script
* allows positioning within the cluster, it is either
@@ -161,25 +173,27 @@ pango_cp_to_x (gchar *text,
* of characters in the cluster. In either case
* 0 represents the trailing edge of the cluster.
*
- * Converts from x position to x character. (X position
- * is measured from the left edge of the run)
+ * Convert from x offset to position.
*/
void
-pango_x_to_cp (gchar *text,
- gint length,
- PangoAnalysis *analysis,
- PangoGlyphString *glyphs,
- gint x_pos,
- gint *char_pos,
- gint *trailing)
+pango_glyph_string_x_to_index (PangoGlyphString *glyphs,
+ char *text,
+ int length,
+ PangoAnalysis *analysis,
+ int x_pos,
+ int *index,
+ int *trailing)
{
- gint i;
- gint start_xpos = 0;
- gint end_xpos = 0;
- gint width = 0;
+ int i;
+ int start_xpos = 0;
+ int end_xpos = 0;
+ int width = 0;
+
+ int start_index = -1;
+ int end_index = -1;
- gint start_char = -1;
- gint end_char = -1;
+ int cluster_chars = 0;
+ char *p;
gboolean found = FALSE;
@@ -194,17 +208,17 @@ pango_x_to_cp (gchar *text,
for (i = glyphs->num_glyphs - 1; i >= 0; i--)
{
- if (start_char == -1 || glyphs->log_clusters[i] != start_char)
+ if (glyphs->log_clusters[i] != start_index)
{
if (found)
{
- end_char = glyphs->log_clusters[i];
+ end_index = glyphs->log_clusters[i];
end_xpos = width;
break;
}
else
{
- start_char = glyphs->log_clusters[i];
+ start_index = glyphs->log_clusters[i];
start_xpos = width;
}
}
@@ -219,17 +233,17 @@ pango_x_to_cp (gchar *text,
{
for (i = 0; i < glyphs->num_glyphs; i++)
{
- if (start_char == -1 || glyphs->log_clusters[i] != start_char)
+ if (glyphs->log_clusters[i] != start_index)
{
if (found)
{
- end_char = glyphs->log_clusters[i];
+ end_index = glyphs->log_clusters[i];
end_xpos = width;
break;
}
else
{
- start_char = glyphs->log_clusters[i];
+ start_index = glyphs->log_clusters[i];
start_xpos = width;
}
}
@@ -241,31 +255,44 @@ pango_x_to_cp (gchar *text,
}
}
- /* We need the character index of one past the end of the
- * string, and so we have to recalculate the entire length
- * of the string...
- */
- if (end_char == -1)
+ if (end_index == -1)
{
- end_char = unicode_strlen (text, length);
+ end_index = length;
end_xpos = (analysis->level % 2) ? 0 : width;
}
+ /* Calculate number of chars within cluster */
+ p = text + start_index;
+ while (p < text + end_index)
+ {
+ p = unicode_next_utf8 (p);
+ cluster_chars++;
+ }
+
if (start_xpos == end_xpos)
{
- if (char_pos)
- *char_pos = start_char;
+ if (index)
+ *index = start_index;
if (trailing)
trailing = 0;
}
else
{
- double cp = (((double)(end_xpos - x_pos)) * start_char +
- ((double)(x_pos - start_xpos)) * end_char) /
- (end_xpos - start_xpos);
+ double cp = ((double)(x_pos - start_xpos) * cluster_chars) / (end_xpos - start_xpos);
- if (char_pos)
- *char_pos = (int)cp;
+ if (index)
+ {
+ char *p = text + start_index;
+ int i = 0;
+
+ while (i + 1 < cp)
+ {
+ p = unicode_next_utf8 (p);
+ i++;
+ }
+
+ *index = (p - text);
+ }
if (trailing)
*trailing = (cp - (int)cp) > 0.5 ? 1 : 0;
}
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c
index e75a56f7..4929dc8a 100644
--- a/pango/pango-attributes.c
+++ b/pango/pango-attributes.c
@@ -513,7 +513,7 @@ pango_attr_list_new (void)
* pango_attr_list_ref:
* @list: a #PangoAttrList
*
- * Increase the reference count on the given attribute list by one.
+ * Increase the reference count of the given attribute list by one.
**/
void
pango_attr_list_ref (PangoAttrList *list)
@@ -527,7 +527,7 @@ pango_attr_list_ref (PangoAttrList *list)
* pango_attr_list_unref:
* @list: a #PangoAttrList
*
- * Decrease the reference count on the given attribute list by one.
+ * Decrease the reference count of the given attribute list by one.
* If the result is zero, free the attribute list and the attributes
* it contains.
**/
diff --git a/pango/pango-font.h b/pango/pango-font.h
index bae83660..1a5d6fd7 100644
--- a/pango/pango-font.h
+++ b/pango/pango-font.h
@@ -98,13 +98,17 @@ struct _PangoFont
struct _PangoFontClass
{
- void (*destroy) (PangoFont *font);
- PangoFontDescription *(*describe) (PangoFont *font);
- PangoCoverage * (*get_coverage) (PangoFont *font,
- const char *lang);
- PangoEngineShape * (*find_shaper) (PangoFont *font,
- const char *lang,
- guint32 ch);
+ void (*destroy) (PangoFont *font);
+ PangoFontDescription *(*describe) (PangoFont *font);
+ PangoCoverage * (*get_coverage) (PangoFont *font,
+ const char *lang);
+ PangoEngineShape * (*find_shaper) (PangoFont *font,
+ const char *lang,
+ guint32 ch);
+ void (*get_glyph_extents) (PangoFont *font,
+ PangoGlyph glyph,
+ PangoRectangle *ink_rect,
+ PangoRectangle *logical_rect);
};
void pango_font_init (PangoFont *font);
@@ -123,6 +127,10 @@ PangoCoverage * pango_font_get_coverage (PangoFont *font,
PangoEngineShape * pango_font_find_shaper (PangoFont *font,
const char *lang,
guint32 ch);
+void pango_font_get_glyph_extents (PangoFont *font,
+ PangoGlyph glyph,
+ PangoRectangle *ink_rect,
+ PangoRectangle *logical_rect);
/*
* Font Map
diff --git a/pango/pango-glyph.h b/pango/pango-glyph.h
index b19cc782..cd9b84f9 100644
--- a/pango/pango-glyph.h
+++ b/pango/pango-glyph.h
@@ -22,6 +22,8 @@
#ifndef __PANGO_GLYPH_H__
#define __PANGO_GLYPH_H__
+#include <pango-types.h>
+
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
@@ -31,12 +33,8 @@ typedef struct _PangoGlyphVisAttr PangoGlyphVisAttr;
typedef struct _PangoGlyphInfo PangoGlyphInfo;
typedef struct _PangoGlyphString PangoGlyphString;
-/* 64'ths of a point - 1/4608 in, 5.51 * 10^-5 in. */
-typedef guint32 PangoGlyphUnit;
-
-/* A index of a glyph into a font. Rendering system dependent
- */
-typedef guint32 PangoGlyph;
+/* 1000ths of a device unit */
+typedef gint32 PangoGlyphUnit;
/* Positioning information about a glyph
*/
@@ -85,21 +83,25 @@ PangoGlyphString *pango_glyph_string_new (void);
void pango_glyph_string_set_size (PangoGlyphString *string,
gint new_len);
void pango_glyph_string_free (PangoGlyphString *string);
-
-void pango_cp_to_x (gchar *text,
- gint length,
- PangoAnalysis *analysis,
- PangoGlyphString *glyphs,
- gint char_pos,
- gboolean trailing,
- gint *x_pos);
-void pango_x_to_cp (gchar *text,
- gint length,
- PangoAnalysis *analysis,
- PangoGlyphString *glyphs,
- gint x_pos,
- gint *char_pos,
- gint *trailing);
+void pango_glyph_string_extents (PangoGlyphString *glyphs,
+ PangoFont *font,
+ PangoRectangle *ink_rect,
+ PangoRectangle *logical_rect);
+
+void pango_glyph_string_index_to_x (PangoGlyphString *glyphs,
+ char *text,
+ int length,
+ PangoAnalysis *analysis,
+ int index,
+ gboolean trailing,
+ int *x_pos);
+void pango_glyph_string_x_to_index (PangoGlyphString *glyphs,
+ char *text,
+ int length,
+ PangoAnalysis *analysis,
+ int x_pos,
+ int *index,
+ int *trailing);
void pango_justify (PangoGlyphString *glyphs,
gint new_line_width,
diff --git a/pango/pango-layout.h b/pango/pango-layout.h
index cdbde021..b9c1ea6f 100644
--- a/pango/pango-layout.h
+++ b/pango/pango-layout.h
@@ -26,15 +26,55 @@
extern "C" {
#endif /* __cplusplus */
-typedef struct _PangoLayout PangoLayout;
-
- /*
- pango_layout_new (char *text, int length);
- pango_layout_get_glyph_strings ();
- pango_layout_cp_to_xy ();
- pango_layout_xy_to_cp ();
- pango_layout_justify ();
- */
+typedef struct _PangoLayout PangoLayout;
+typedef struct _PangoLayoutLine PangoLayoutLine;
+typedef struct _PangoLayoutRun PangoLayoutRun;
+
+struct _PangoLayoutLine
+{
+ PangoLayout *layout;
+ gint n_chars; /* length of line in characters */
+ gint length; /* length of line in bytes*/
+ GSList *runs;
+};
+
+struct _PangoLayoutRun
+{
+ PangoItem *item;
+ PangoGlyphString *glyphs;
+};
+
+PangoLayout * pango_layout_new (void);
+void pango_layout_ref (PangoLayout *layout);
+void pango_layout_unref (PangoLayout *layout);
+void pango_layout_set_width (PangoLayout *layout,
+ int width);
+void pango_layout_set_justify (PangoLayout *layout,
+ gboolean justify);
+void pango_layout_set_first_line_width (PangoLayout *layout,
+ int width);
+void pango_layout_set_attributes (PangoLayout *layout,
+ PangoAttrList *attrs);
+void pango_layout_set_text (char *text,
+ int length);
+int pango_layout_get_line_count (PangoLayout *layout);
+PangoLayoutLine *pango_layout_get_line (PangoLayout *layout,
+ int line);
+void pango_layout_cp_to_line_x (PangoLayout *layout,
+ gint char_pos,
+ gboolean trailing,
+ gint *line,
+ gint *x_pos);
+
+void pango_layout_line_ref (PangoLayoutLine *line);
+void pango_layout_line_unref (PangoLayoutLine *line);
+void pango_layout_line_x_to_cp (PangoLayoutLine *line,
+ gint x_pos,
+ gint *char_pos,
+ gint *trailing);
+void pango_layout_line_get_extents (PangoLayoutLine *line,
+ PangoRectangle *ink_rect,
+ PangoRectangle *logical_rect);
#ifdef __cplusplus
}
diff --git a/pango/pango-types.h b/pango/pango-types.h
index 33ef0195..9d31603c 100644
--- a/pango/pango-types.h
+++ b/pango/pango-types.h
@@ -39,6 +39,29 @@ typedef struct _PangoEngineLang PangoEngineLang;
typedef struct _PangoEngineShape PangoEngineShape;
typedef struct _PangoFont PangoFont;
+typedef struct _PangoRectangle PangoRectangle;
+
+/* 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;
+};
+
+/* Macros to translate from extents rectangles to ascent/descent/lbearing/rbearing
+ */
+#define PANGO_ASCENT(rect) (-(rect).y)
+#define PANGO_DESCENT(rect) ((rect).y + (rect).height)
+#define PANGO_LBEARING(rect) ((rect).x)
+#define PANGO_RBEARING(rect) ((rect).x + (rect).width)
/* Information about a segment of text with a consistent
* shaping/language engine and bidirectional level
diff --git a/pango/pangox.c b/pango/pangox.c
index 203ea5d2..f6a7d142 100644
--- a/pango/pangox.c
+++ b/pango/pangox.c
@@ -174,13 +174,17 @@ static void pango_x_font_map_list_families (PangoFontMap *
int *n_families);
static void pango_x_font_map_read_aliases (PangoXFontMap *xfontmap);
-static void pango_x_font_destroy (PangoFont *font);
-static PangoFontDescription *pango_x_font_describe (PangoFont *font);
-static PangoCoverage * pango_x_font_get_coverage (PangoFont *font,
- const char *lang);
-static PangoEngineShape * pango_x_font_find_shaper (PangoFont *font,
- const char *lang,
- guint32 ch);
+static void pango_x_font_destroy (PangoFont *font);
+static PangoFontDescription *pango_x_font_describe (PangoFont *font);
+static PangoCoverage * pango_x_font_get_coverage (PangoFont *font,
+ const char *lang);
+static PangoEngineShape * pango_x_font_find_shaper (PangoFont *font,
+ const char *lang,
+ guint32 ch);
+static void pango_x_font_get_glyph_extents (PangoFont *font,
+ PangoGlyph glyph,
+ PangoRectangle *ink_rect,
+ PangoRectangle *logical_rect);
static PangoXSubfontInfo * pango_x_find_subfont (PangoFont *font,
PangoXSubfont subfont_index);
@@ -214,7 +218,8 @@ PangoFontClass pango_x_font_class = {
pango_x_font_destroy,
pango_x_font_describe,
pango_x_font_get_coverage,
- pango_x_font_find_shaper
+ pango_x_font_find_shaper,
+ pango_x_font_get_glyph_extents
};
PangoFontMapClass pango_x_font_map_class = {
@@ -1300,8 +1305,8 @@ pango_x_load_font_with_size (Display *display,
* @gc: the graphics context
* @font: the font in which to draw the string
* @glyphs: the glyph string to draw
- * @x: the x position of start of string
- * @y: the y position of baseline
+ * @x: the x position of start of string (in pixels)
+ * @y: the y position of baseline (in pixels)
*
* Render a PangoGlyphString onto an X drawable
*/
@@ -1321,6 +1326,7 @@ pango_x_render (Display *display,
Font old_fid = None;
XFontStruct *fs;
int i;
+ int x_off = 0;
g_return_if_fail (display != NULL);
g_return_if_fail (glyphs != NULL);
@@ -1350,172 +1356,58 @@ pango_x_render (Display *display,
}
XDrawString16 (display, d, gc,
- x + glyphs->glyphs[i].geometry.x_offset / 72,
- y + glyphs->glyphs[i].geometry.y_offset / 72,
+ x + (x_off + glyphs->glyphs[i].geometry.x_offset) / 1000,
+ y + glyphs->glyphs[i].geometry.y_offset / 1000,
&c, 1);
}
- x += glyphs->glyphs[i].geometry.width / 72;
+ x_off += glyphs->glyphs[i].geometry.width;
}
}
-/**
- * pango_x_glyph_extents:
- * @font: a #PangoFont
- * @glyph: the glyph to measure
- * @lbearing: left bearing of glyph (result)
- * @rbearing: right bearing of glyph (result)
- * @width: width of glyph (result)
- * @ascent: ascent of glyph (result)
- * @descent: descent of glyph (result)
- * @logical_ascent: The vertical distance from the baseline to the
- * bottom of the line above.
- * @logical_descent: The vertical distance from the baseline to the
- * top of the line below.
- *
- * Compute the measurements of a single glyph in pixels.
- */
-void
-pango_x_glyph_extents (PangoFont *font,
- PangoGlyph glyph,
- int *lbearing,
- int *rbearing,
- int *width,
- int *ascent,
- int *descent,
- int *logical_ascent,
- int *logical_descent)
+static void
+pango_x_font_get_glyph_extents (PangoFont *font,
+ PangoGlyph glyph,
+ PangoRectangle *ink_rect,
+ PangoRectangle *logical_rect)
{
XCharStruct *cs;
PangoXSubfontInfo *subfont;
if (pango_x_find_glyph (font, glyph, &subfont, &cs))
{
- if (lbearing)
- *lbearing = cs->lbearing;
- if (rbearing)
- *rbearing = cs->rbearing;
- if (width)
- *width = cs->width;
- if (ascent)
- *ascent = cs->ascent;
- if (descent)
- *descent = cs->descent;
- if (logical_ascent)
- *logical_ascent = subfont->font_struct->ascent;
- if (logical_descent)
- *logical_descent = subfont->font_struct->descent;
+ if (ink_rect)
+ {
+ ink_rect->x = 1000 * cs->lbearing;
+ ink_rect->width = 1000 * (cs->rbearing - cs->lbearing);
+ ink_rect->y = 1000 * -cs->ascent;
+ ink_rect->height = cs->ascent + cs->descent;
+ }
+ if (logical_rect)
+ {
+ logical_rect->x = 0;
+ logical_rect->width = 1000 * cs->width;
+ logical_rect->y = - 1000 * subfont->font_struct->ascent;
+ logical_rect->height = 1000 * (subfont->font_struct->ascent + subfont->font_struct->descent);
+ }
}
else
{
- if (lbearing)
- *lbearing = 0;
- if (rbearing)
- *rbearing = 0;
- if (width)
- *width = 0;
- if (ascent)
- *ascent = 0;
- if (descent)
- *descent = 0;
- if (logical_ascent)
- *logical_ascent = 0;
- if (logical_descent)
- *logical_descent = 0;
- }
-}
-
-/**
- * pango_x_extents:
- * @font: a #PangoFont
- * @glyphs: the glyph string to measure
- * @lbearing: left bearing of string (result)
- * @rbearing: right bearing of string (result)
- * @width: width of string (result)
- * @ascent: ascent of string (result)
- * @descent: descent of string (result)
- * @logical_ascent: The vertical distance from the baseline to the
- * bottom of the line above.
- * @logical_descent: The vertical distance from the baseline to the
- * top of the line below.
- *
- * Compute the measurements of a glyph string in pixels.
- * The number of parameters here is clunky - it might be
- * nicer to use structures as in XmbTextExtents.
- */
-void
-pango_x_extents (PangoFont *font,
- PangoGlyphString *glyphs,
- int *lbearing,
- int *rbearing,
- int *width,
- int *ascent,
- int *descent,
- int *logical_ascent,
- int *logical_descent)
-{
- PangoXSubfontInfo *subfont;
- XCharStruct *cs;
-
- int i;
-
- int t_lbearing = 0;
- int t_rbearing = 0;
- int t_ascent = 0;
- int t_descent = 0;
- int t_logical_ascent = 0;
- int t_logical_descent = 0;
- int t_width = 0;
-
- g_return_if_fail (font != NULL);
- g_return_if_fail (glyphs != NULL);
-
- for (i=0; i<glyphs->num_glyphs; i++)
- {
- PangoGlyphGeometry *geometry = &glyphs->glyphs[i].geometry;
-
- if (pango_x_find_glyph (font, glyphs->glyphs[i].glyph, &subfont, &cs))
+ if (ink_rect)
{
- if (i == 0)
- {
- t_lbearing = cs->lbearing - geometry->x_offset / 72;
- t_rbearing = cs->rbearing + geometry->x_offset / 72;
- t_ascent = cs->ascent + geometry->y_offset / 72;
- t_descent = cs->descent - geometry->y_offset / 72;
-
- t_logical_ascent = subfont->font_struct->ascent + geometry->y_offset / 72;
- t_logical_descent = subfont->font_struct->descent - geometry->y_offset / 72;
- }
- else
- {
- t_lbearing = MAX (t_lbearing,
- cs->lbearing - geometry->x_offset / 72 - t_width);
- t_rbearing = MAX (t_rbearing,
- t_width + cs->rbearing + geometry->x_offset / 72);
- t_ascent = MAX (t_ascent, cs->ascent + geometry->y_offset / 72);
- t_descent = MAX (t_descent, cs->descent - geometry->y_offset / 72);
- t_logical_ascent = MAX (t_logical_ascent, subfont->font_struct->ascent + geometry->y_offset / 72);
- t_logical_descent = MAX (t_logical_descent, subfont->font_struct->descent - geometry->y_offset / 72);
- }
+ ink_rect->x = 0;
+ ink_rect->width = 0;
+ ink_rect->y = 0;
+ ink_rect->height = 0;
+ }
+ if (logical_rect)
+ {
+ logical_rect->x = 0;
+ logical_rect->width = 0;
+ logical_rect->y = 0;
+ logical_rect->height = 0;
}
-
- t_width += geometry->width / 72;
}
-
- if (lbearing)
- *lbearing = t_lbearing;
- if (rbearing)
- *rbearing = t_rbearing;
- if (width)
- *width = t_width;
- if (ascent)
- *ascent = t_ascent;
- if (descent)
- *descent = t_descent;
- if (logical_ascent)
- *logical_ascent = t_logical_ascent;
- if (logical_descent)
- *logical_descent = t_logical_descent;
}
/* Compare the tail of a to b */