summaryrefslogtreecommitdiff
path: root/pango/glyphstring.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2000-03-08 18:39:49 +0000
committerOwen Taylor <otaylor@src.gnome.org>2000-03-08 18:39:49 +0000
commit773bc55fc9e344f8040809ba8796b0ba2805e4c9 (patch)
tree89e900594294e87b4a4de8f71571762d6ccc8871 /pango/glyphstring.c
parentdd0b4a5064c6f60adcfd2ea02e2d61fb60254d20 (diff)
downloadpango-773bc55fc9e344f8040809ba8796b0ba2805e4c9.tar.gz
First draft of highlevel driver. It currently only handles a paragraph as
Wed Mar 8 13:34:57 2000 Owen Taylor <otaylor@redhat.com> * libpango/pango-layout.[ch]: First draft of highlevel driver. It currently only handles a paragraph as a list of lines, but it is probably necessary to make it handle 2D layout for a paragraph as well * examples/viewer.c: Move over to new layout driver (much of the code moved into pango-layout.c) * libpango/glyphs.c libpango/pango-glyphs.h: Fixes to get_extents(), add pango_glyph_string_get_logical_widths. * libpango/pango-itemize.c: Handle 0-length text properly. * libpango/pangox.c: When loading particular sized fonts, use the original XLFD, since XFree86 doesn't handle wildcards in aliases properly. * libpango/pangox.[ch] (pango_x_render_layout_line): Add function to render an entire PangoLayoutLine. * libpango/reorder-items.c: Add a note to the effect that pango_reorder_items() is basically replaced by a similar function in PangoLayout. Wed Mar 8 10:58:56 2000 Owen Taylor <otaylor@redhat.com> * modules/arabic/arconv.c (shapecount): Fix from Karl Koehler to joining behavior. * modules/Makefile.am modules/arabic/*: Added arabic shaper from Karl Koehler <koehler@or.uni-bonn.de> * modules/basic/tables-{small,big}.i: Remove arabic from the ranges that the basic shaper marks as "exact". * examples/HELLO.utf8: Partially alphabetize, add arabic.
Diffstat (limited to 'pango/glyphstring.c')
-rw-r--r--pango/glyphstring.c73
1 files changed, 69 insertions, 4 deletions
diff --git a/pango/glyphstring.c b/pango/glyphstring.c
index b29efe09..d3030e39 100644
--- a/pango/glyphstring.c
+++ b/pango/glyphstring.c
@@ -22,6 +22,7 @@
#include <glib.h>
#include <pango-glyph.h>
#include <pango-font.h>
+#include <unicode.h>
/**
* pango_glyph_string_new:
@@ -151,12 +152,12 @@ pango_glyph_string_extents (PangoGlyphString *glyphs,
{
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;
+ x_pos + glyph_ink.x + glyph_ink.width + geometry->x_offset) - new_pos;
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;
+ glyph_ink.y + glyph_ink.height + geometry->y_offset) - new_pos;
ink_rect->y = new_pos;
}
@@ -164,12 +165,12 @@ pango_glyph_string_extents (PangoGlyphString *glyphs,
{
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;
+ x_pos + glyph_logical.x + glyph_logical.width + geometry->x_offset) - new_pos;
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;
+ glyph_logical.y + glyph_logical.height + geometry->y_offset) - new_pos;
logical_rect->y = new_pos;
}
}
@@ -178,3 +179,67 @@ pango_glyph_string_extents (PangoGlyphString *glyphs,
}
}
+/**
+ * pango_glyph_string_get_logical_widths:
+ * @glyphs: a #PangoGlyphString
+ * @text: the text corresponding to the glyphs
+ * @length: the length of @text, in bytes
+ * @embedding_level: the embedding level of the string
+ * @logical_widths: an array whose length is unicode_strlen (text, length)
+ * to be filled in with the resulting character widths.
+ *
+ * Given a #PangoGlyphString resulting from pango_shape() and the corresponding
+ * text, determine the screen width corresponding to each character. When
+ * multiple characters compose a single cluster, the width of the entire
+ * cluster is divided equally among the characters.
+ **/
+void
+pango_glyph_string_get_logical_widths (PangoGlyphString *glyphs,
+ char *text,
+ int length,
+ int embedding_level,
+ int *logical_widths)
+{
+ int i, j;
+ int last_cluster = 0;
+ int width = 0;
+ int last_cluster_width = 0;
+ char *p = text;
+
+ for (i=0; i<=glyphs->num_glyphs; i++)
+ {
+ int glyph_index = (embedding_level % 2 == 0) ? i : glyphs->num_glyphs - i - 1;
+
+ if (i == glyphs->num_glyphs || p != text + glyphs->log_clusters[glyph_index])
+ {
+ int next_cluster = last_cluster;
+
+ if (glyph_index < glyphs->num_glyphs)
+ {
+ while (p < text + glyphs->log_clusters[glyph_index])
+ {
+ next_cluster++;
+ p = unicode_next_utf8 (p);
+ }
+ }
+ else
+ {
+ while (p < text + length)
+ {
+ next_cluster++;
+ p = unicode_next_utf8 (p);
+ }
+ }
+
+ for (j = last_cluster; j < next_cluster; j++)
+ logical_widths[j] = (width - last_cluster_width) / (next_cluster - last_cluster);
+
+ last_cluster = next_cluster;
+ last_cluster_width = width;
+ }
+
+ if (i < glyphs->num_glyphs)
+ width += glyphs->glyphs[i].geometry.width;
+ }
+}
+