summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2001-01-22 23:08:10 +0000
committerHavoc Pennington <hp@src.gnome.org>2001-01-22 23:08:10 +0000
commitf685b8e639f4c28c49be358b62f85d0ccfa1415f (patch)
tree7f3320a119817e256f25537266b9582328f32386
parentb425950b463041cb7ed58367507f1ca528535a12 (diff)
downloadpango-f685b8e639f4c28c49be358b62f85d0ccfa1415f.tar.gz
s/is_break/is_line_break/g;
2001-01-22 Havoc Pennington <hp@redhat.com> * tests/testboundaries.c (check_line_char): s/is_break/is_line_break/g; * pango/pango-layout.c, pango/pango-layout.h: Add PangoWrapMode for PangoLayout * pango/break.c (pango_default_break): implement char break log attr * pango/pango-break.h (struct _PangoLogAttr): rename is_break is_line_break, add is_char_break field
-rw-r--r--ChangeLog13
-rw-r--r--ChangeLog.pre-1-013
-rw-r--r--ChangeLog.pre-1-1013
-rw-r--r--ChangeLog.pre-1-213
-rw-r--r--ChangeLog.pre-1-413
-rw-r--r--ChangeLog.pre-1-613
-rw-r--r--ChangeLog.pre-1-813
-rw-r--r--pango/break.c23
-rw-r--r--pango/pango-break.h4
-rw-r--r--pango/pango-layout.c55
-rw-r--r--pango/pango-layout.h8
-rw-r--r--tests/testboundaries.c16
12 files changed, 177 insertions, 20 deletions
diff --git a/ChangeLog b/ChangeLog
index 0998a64d..e6ad7579 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2001-01-22 Havoc Pennington <hp@redhat.com>
+
+ * tests/testboundaries.c (check_line_char): s/is_break/is_line_break/g;
+
+ * pango/pango-layout.c, pango/pango-layout.h: Add PangoWrapMode
+ for PangoLayout
+
+ * pango/break.c (pango_default_break): implement char break log
+ attr
+
+ * pango/pango-break.h (struct _PangoLogAttr): rename is_break
+ is_line_break, add is_char_break field
+
2001-01-18 <alla@lysator.liu.se>
* pango/pangoft2.c (get_font_metrics_from_subfonts):
diff --git a/ChangeLog.pre-1-0 b/ChangeLog.pre-1-0
index 0998a64d..e6ad7579 100644
--- a/ChangeLog.pre-1-0
+++ b/ChangeLog.pre-1-0
@@ -1,3 +1,16 @@
+2001-01-22 Havoc Pennington <hp@redhat.com>
+
+ * tests/testboundaries.c (check_line_char): s/is_break/is_line_break/g;
+
+ * pango/pango-layout.c, pango/pango-layout.h: Add PangoWrapMode
+ for PangoLayout
+
+ * pango/break.c (pango_default_break): implement char break log
+ attr
+
+ * pango/pango-break.h (struct _PangoLogAttr): rename is_break
+ is_line_break, add is_char_break field
+
2001-01-18 <alla@lysator.liu.se>
* pango/pangoft2.c (get_font_metrics_from_subfonts):
diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10
index 0998a64d..e6ad7579 100644
--- a/ChangeLog.pre-1-10
+++ b/ChangeLog.pre-1-10
@@ -1,3 +1,16 @@
+2001-01-22 Havoc Pennington <hp@redhat.com>
+
+ * tests/testboundaries.c (check_line_char): s/is_break/is_line_break/g;
+
+ * pango/pango-layout.c, pango/pango-layout.h: Add PangoWrapMode
+ for PangoLayout
+
+ * pango/break.c (pango_default_break): implement char break log
+ attr
+
+ * pango/pango-break.h (struct _PangoLogAttr): rename is_break
+ is_line_break, add is_char_break field
+
2001-01-18 <alla@lysator.liu.se>
* pango/pangoft2.c (get_font_metrics_from_subfonts):
diff --git a/ChangeLog.pre-1-2 b/ChangeLog.pre-1-2
index 0998a64d..e6ad7579 100644
--- a/ChangeLog.pre-1-2
+++ b/ChangeLog.pre-1-2
@@ -1,3 +1,16 @@
+2001-01-22 Havoc Pennington <hp@redhat.com>
+
+ * tests/testboundaries.c (check_line_char): s/is_break/is_line_break/g;
+
+ * pango/pango-layout.c, pango/pango-layout.h: Add PangoWrapMode
+ for PangoLayout
+
+ * pango/break.c (pango_default_break): implement char break log
+ attr
+
+ * pango/pango-break.h (struct _PangoLogAttr): rename is_break
+ is_line_break, add is_char_break field
+
2001-01-18 <alla@lysator.liu.se>
* pango/pangoft2.c (get_font_metrics_from_subfonts):
diff --git a/ChangeLog.pre-1-4 b/ChangeLog.pre-1-4
index 0998a64d..e6ad7579 100644
--- a/ChangeLog.pre-1-4
+++ b/ChangeLog.pre-1-4
@@ -1,3 +1,16 @@
+2001-01-22 Havoc Pennington <hp@redhat.com>
+
+ * tests/testboundaries.c (check_line_char): s/is_break/is_line_break/g;
+
+ * pango/pango-layout.c, pango/pango-layout.h: Add PangoWrapMode
+ for PangoLayout
+
+ * pango/break.c (pango_default_break): implement char break log
+ attr
+
+ * pango/pango-break.h (struct _PangoLogAttr): rename is_break
+ is_line_break, add is_char_break field
+
2001-01-18 <alla@lysator.liu.se>
* pango/pangoft2.c (get_font_metrics_from_subfonts):
diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6
index 0998a64d..e6ad7579 100644
--- a/ChangeLog.pre-1-6
+++ b/ChangeLog.pre-1-6
@@ -1,3 +1,16 @@
+2001-01-22 Havoc Pennington <hp@redhat.com>
+
+ * tests/testboundaries.c (check_line_char): s/is_break/is_line_break/g;
+
+ * pango/pango-layout.c, pango/pango-layout.h: Add PangoWrapMode
+ for PangoLayout
+
+ * pango/break.c (pango_default_break): implement char break log
+ attr
+
+ * pango/pango-break.h (struct _PangoLogAttr): rename is_break
+ is_line_break, add is_char_break field
+
2001-01-18 <alla@lysator.liu.se>
* pango/pangoft2.c (get_font_metrics_from_subfonts):
diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8
index 0998a64d..e6ad7579 100644
--- a/ChangeLog.pre-1-8
+++ b/ChangeLog.pre-1-8
@@ -1,3 +1,16 @@
+2001-01-22 Havoc Pennington <hp@redhat.com>
+
+ * tests/testboundaries.c (check_line_char): s/is_break/is_line_break/g;
+
+ * pango/pango-layout.c, pango/pango-layout.h: Add PangoWrapMode
+ for PangoLayout
+
+ * pango/break.c (pango_default_break): implement char break log
+ attr
+
+ * pango/pango-break.h (struct _PangoLogAttr): rename is_break
+ is_line_break, add is_char_break field
+
2001-01-18 <alla@lysator.liu.se>
* pango/pangoft2.c (get_font_metrics_from_subfonts):
diff --git a/pango/break.c b/pango/break.c
index e27d9980..baf1ed86 100644
--- a/pango/break.c
+++ b/pango/break.c
@@ -573,25 +573,31 @@ pango_default_break (const gchar *text,
g_assert (prev_break_type != G_UNICODE_BREAK_SPACE);
- attrs[i].is_break = FALSE;
+ attrs[i].is_line_break = FALSE;
attrs[i].is_mandatory_break = FALSE;
-
+
if (attrs[i].is_cursor_position) /* If it's not a grapheme boundary,
* it's not a line break either
*/
{
+ /* Unicode doesn't specify char wrap; we wrap around all chars
+ * except where a line break is prohibited, which means we
+ * effectively break everywhere except inside runs of spaces.
+ */
+ attrs[i].is_char_break = TRUE;
+
switch (prev_break_type)
{
case G_UNICODE_BREAK_MANDATORY:
case G_UNICODE_BREAK_LINE_FEED:
- attrs[i].is_break = TRUE;
+ attrs[i].is_line_break = TRUE;
attrs[i].is_mandatory_break = TRUE;
break;
case G_UNICODE_BREAK_CARRIAGE_RETURN:
if (wc != '\n')
{
- attrs[i].is_break = TRUE;
+ attrs[i].is_line_break = TRUE;
attrs[i].is_mandatory_break = TRUE;
}
break;
@@ -686,17 +692,18 @@ pango_default_break (const gchar *text,
switch (break_op)
{
case BREAK_PROHIBITED:
- /* nothing, can't break here */
+ /* can't break here */
+ attrs[i].is_char_break = FALSE;
break;
case BREAK_IF_SPACES:
/* break if prev char was space */
- if (prev_was_break_space)
- attrs[i].is_break = TRUE;
+ if (prev_was_break_space)
+ attrs[i].is_line_break = TRUE;
break;
case BREAK_ALLOWED:
- attrs[i].is_break = TRUE;
+ attrs[i].is_line_break = TRUE;
break;
default:
diff --git a/pango/pango-break.h b/pango/pango-break.h
index 74bdda00..527a7cf5 100644
--- a/pango/pango-break.h
+++ b/pango/pango-break.h
@@ -34,9 +34,11 @@ extern "C" {
*/
struct _PangoLogAttr
{
- guint is_break : 1; /* Can break line in front of character */
+ guint is_line_break : 1; /* Can break line in front of character */
guint is_mandatory_break : 1; /* Must break line in front of character */
+
+ guint is_char_break : 1; /* Can break here when doing char wrap */
guint is_white : 1; /* Whitespace character */
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 4a3315bc..aae3c4a3 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -120,6 +120,8 @@ struct _PangoLayout
PangoTabArray *tabs;
GSList *lines;
+
+ PangoWrapMode wrap;
};
struct _PangoLayoutClass
@@ -197,7 +199,9 @@ pango_layout_init (PangoLayout *layout)
layout->log_attrs = NULL;
layout->lines = NULL;
- layout->tab_width = -1;
+ layout->tab_width = -1;
+
+ layout->wrap = PANGO_WRAP_WORD;
}
static void
@@ -316,6 +320,44 @@ pango_layout_get_width (PangoLayout *layout)
}
/**
+ * pango_layout_set_wrap:
+ * @layout: a #PangoLayout
+ * @wrap: wrap mode
+ *
+ * Sets the wrap style; the wrap style only has an effect if a width
+ * is set on the layout with pango_layout_set_width(). To turn off wrapping,
+ * set the width to -1.
+ **/
+void
+pango_layout_set_wrap (PangoLayout *layout,
+ PangoWrapMode wrap)
+{
+ g_return_if_fail (PANGO_IS_LAYOUT (layout));
+
+ if (layout->wrap != wrap)
+ {
+ pango_layout_clear_lines (layout);
+ layout->wrap = wrap;
+ }
+}
+
+/**
+ * pango_layout_get_wrap:
+ * @layout: a #PangoLayout
+ *
+ * Get the wrap mode for the layout.
+ *
+ * Return value: Active wrap mode.
+ **/
+PangoWrapMode
+pango_layout_get_wrap (PangoLayout *layout)
+{
+ g_return_val_if_fail (PANGO_IS_LAYOUT (layout), 0);
+
+ return layout->wrap;
+}
+
+/**
* pango_layout_set_indent
* @layout: a #PangoLayout.
* @indent: the amount by which to indent
@@ -2183,13 +2225,20 @@ can_break_at (PangoLayout *layout,
gint offset)
{
/* We probably should have a mode where we treat all white-space as
- * of fungeable width - appropriate for typography but not for
+ * of fungible width - appropriate for typography but not for
* editing.
*/
if (offset == layout->n_chars)
return TRUE;
+ else if (layout->wrap == PANGO_WRAP_WORD)
+ return layout->log_attrs[offset].is_line_break;
+ else if (layout->wrap == PANGO_WRAP_CHAR)
+ return layout->log_attrs[offset].is_char_break;
else
- return layout->log_attrs[offset].is_break;
+ {
+ g_warning (G_STRLOC": broken PangoLayout");
+ return TRUE;
+ }
}
static inline gboolean
diff --git a/pango/pango-layout.h b/pango/pango-layout.h
index ef87869d..6cef7cf4 100644
--- a/pango/pango-layout.h
+++ b/pango/pango-layout.h
@@ -42,6 +42,11 @@ typedef enum {
PANGO_ALIGN_RIGHT
} PangoAlignment;
+typedef enum {
+ PANGO_WRAP_WORD,
+ PANGO_WRAP_CHAR
+} PangoWrapMode;
+
struct _PangoLayoutLine
{
PangoLayout *layout;
@@ -97,6 +102,9 @@ void pango_layout_set_font_description (PangoLayout *la
void pango_layout_set_width (PangoLayout *layout,
int width);
int pango_layout_get_width (PangoLayout *layout);
+void pango_layout_set_wrap (PangoLayout *layout,
+ PangoWrapMode wrap);
+PangoWrapMode pango_layout_get_wrap (PangoLayout *layout);
void pango_layout_set_indent (PangoLayout *layout,
int indent);
int pango_layout_get_indent (PangoLayout *layout);
diff --git a/tests/testboundaries.c b/tests/testboundaries.c
index c05bc837..895231ae 100644
--- a/tests/testboundaries.c
+++ b/tests/testboundaries.c
@@ -202,25 +202,25 @@ check_line_char (gunichar wc,
{
if (prev_wc == '\r')
{
- if (attr->is_break)
+ if (attr->is_line_break)
fail ("line break between \\r and \\n");
}
- if (next_attr && !next_attr->is_break)
+ if (next_attr && !next_attr->is_line_break)
fail ("no line break after \\n");
}
- if (attr->is_break && prev_wc == 0)
+ if (attr->is_line_break && prev_wc == 0)
fail ("first char in string should not be marked as a line break");
if (break_type == G_UNICODE_BREAK_SPACE)
{
- if (attr->is_break && prev_attr != NULL &&
+ if (attr->is_line_break && prev_attr != NULL &&
!attr->is_mandatory_break)
fail ("can't break lines before a space unless a mandatory break char precedes it; prev char was " CHFORMAT, prev_wc);
}
- if (attr->is_mandatory_break && !attr->is_break)
+ if (attr->is_mandatory_break && !attr->is_line_break)
fail ("mandatory breaks must also be marked as regular breaks");
@@ -232,19 +232,19 @@ check_line_char (gunichar wc,
if (break_type == G_UNICODE_BREAK_OPEN_PUNCTUATION &&
prev_break_type == G_UNICODE_BREAK_OPEN_PUNCTUATION &&
- attr->is_break &&
+ attr->is_line_break &&
!attr->is_mandatory_break)
fail ("can't break between two open punctuation chars");
if (break_type == G_UNICODE_BREAK_CLOSE_PUNCTUATION &&
prev_break_type == G_UNICODE_BREAK_CLOSE_PUNCTUATION &&
- attr->is_break &&
+ attr->is_line_break &&
!attr->is_mandatory_break)
fail ("can't break between two close punctuation chars");
if (break_type == G_UNICODE_BREAK_QUOTATION &&
prev_break_type == G_UNICODE_BREAK_ALPHABETIC &&
- attr->is_break &&
+ attr->is_line_break &&
!attr->is_mandatory_break)
fail ("can't break letter-quotemark sequence");
}