summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoah Levitt <nlevitt@columbia.edu>2003-11-25 21:28:13 +0000
committerNoah Levitt <nlevitt@src.gnome.org>2003-11-25 21:28:13 +0000
commit3293fbd32eb9a024b05dee32dcaf1fc175546bc6 (patch)
tree77c10d8b21ebb32830cb49699c25218282c008ae
parent6495fbc14fe9a55d540a21c578e7f067b2edbe6b (diff)
downloadpango-3293fbd32eb9a024b05dee32dcaf1fc175546bc6.tar.gz
Add --indent=n option.
2003-11-25 Noah Levitt <nlevitt@columbia.edu> * examples/pangoft2topgm.c: Add --indent=n option. * pango/pango-layout.[ch]: Indent the first line of every paragraph, not just the first line in the layout. (#66626)
-rw-r--r--ChangeLog7
-rw-r--r--ChangeLog.pre-1-107
-rw-r--r--ChangeLog.pre-1-47
-rw-r--r--ChangeLog.pre-1-67
-rw-r--r--ChangeLog.pre-1-87
-rw-r--r--examples/pangoft2topgm.c6
-rw-r--r--examples/renderdemo.c6
-rw-r--r--pango/pango-layout.c17
-rw-r--r--pango/pango-layout.h1
9 files changed, 56 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 9f2cbba1..1377d7a7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2003-11-25 Noah Levitt <nlevitt@columbia.edu>
+ * examples/pangoft2topgm.c: Add --indent=n option.
+
+ * pango/pango-layout.[ch]: Indent the first line of every paragraph,
+ not just the first line in the layout. (#66626)
+
+2003-11-25 Noah Levitt <nlevitt@columbia.edu>
+
* pango-utils.c (lang_texts[]): Italian is "it"; "iw" is deprecated
for Hebrew, should be "he".
diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10
index 9f2cbba1..1377d7a7 100644
--- a/ChangeLog.pre-1-10
+++ b/ChangeLog.pre-1-10
@@ -1,5 +1,12 @@
2003-11-25 Noah Levitt <nlevitt@columbia.edu>
+ * examples/pangoft2topgm.c: Add --indent=n option.
+
+ * pango/pango-layout.[ch]: Indent the first line of every paragraph,
+ not just the first line in the layout. (#66626)
+
+2003-11-25 Noah Levitt <nlevitt@columbia.edu>
+
* pango-utils.c (lang_texts[]): Italian is "it"; "iw" is deprecated
for Hebrew, should be "he".
diff --git a/ChangeLog.pre-1-4 b/ChangeLog.pre-1-4
index 9f2cbba1..1377d7a7 100644
--- a/ChangeLog.pre-1-4
+++ b/ChangeLog.pre-1-4
@@ -1,5 +1,12 @@
2003-11-25 Noah Levitt <nlevitt@columbia.edu>
+ * examples/pangoft2topgm.c: Add --indent=n option.
+
+ * pango/pango-layout.[ch]: Indent the first line of every paragraph,
+ not just the first line in the layout. (#66626)
+
+2003-11-25 Noah Levitt <nlevitt@columbia.edu>
+
* pango-utils.c (lang_texts[]): Italian is "it"; "iw" is deprecated
for Hebrew, should be "he".
diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6
index 9f2cbba1..1377d7a7 100644
--- a/ChangeLog.pre-1-6
+++ b/ChangeLog.pre-1-6
@@ -1,5 +1,12 @@
2003-11-25 Noah Levitt <nlevitt@columbia.edu>
+ * examples/pangoft2topgm.c: Add --indent=n option.
+
+ * pango/pango-layout.[ch]: Indent the first line of every paragraph,
+ not just the first line in the layout. (#66626)
+
+2003-11-25 Noah Levitt <nlevitt@columbia.edu>
+
* pango-utils.c (lang_texts[]): Italian is "it"; "iw" is deprecated
for Hebrew, should be "he".
diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8
index 9f2cbba1..1377d7a7 100644
--- a/ChangeLog.pre-1-8
+++ b/ChangeLog.pre-1-8
@@ -1,5 +1,12 @@
2003-11-25 Noah Levitt <nlevitt@columbia.edu>
+ * examples/pangoft2topgm.c: Add --indent=n option.
+
+ * pango/pango-layout.[ch]: Indent the first line of every paragraph,
+ not just the first line in the layout. (#66626)
+
+2003-11-25 Noah Levitt <nlevitt@columbia.edu>
+
* pango-utils.c (lang_texts[]): Italian is "it"; "iw" is deprecated
for Hebrew, should be "he".
diff --git a/examples/pangoft2topgm.c b/examples/pangoft2topgm.c
index f223f89e..60f93468 100644
--- a/examples/pangoft2topgm.c
+++ b/examples/pangoft2topgm.c
@@ -57,6 +57,7 @@ static gboolean opt_rtl = FALSE;
static char *opt_text = NULL;
static gboolean opt_waterfall = FALSE;
static int opt_width = -1;
+static int opt_indent = 0;
static void fail (const char *format, ...) G_GNUC_PRINTF (1, 2);
@@ -112,6 +113,9 @@ make_layout(PangoContext *context,
if (opt_width > 0)
pango_layout_set_width (layout, (opt_width * opt_dpi * PANGO_SCALE + 32) / 72);
+ if (opt_indent != 0)
+ pango_layout_set_indent (layout, (opt_indent * opt_dpi * PANGO_SCALE + 32) / 72);
+
base_dir = pango_context_get_base_dir (context);
pango_layout_set_alignment (layout,
base_dir == PANGO_DIRECTION_LTR ? PANGO_ALIGN_LEFT : PANGO_ALIGN_RIGHT);
@@ -260,6 +264,8 @@ int main(int argc, char *argv[])
ARG_BOOL, &opt_waterfall },
{ "width", "Width in points to which to wrap output",
ARG_INT, &opt_width },
+ { "indent", "Width in points to indent paragraphs",
+ ARG_INT, &opt_indent },
{ NULL }
};
diff --git a/examples/renderdemo.c b/examples/renderdemo.c
index f223f89e..60f93468 100644
--- a/examples/renderdemo.c
+++ b/examples/renderdemo.c
@@ -57,6 +57,7 @@ static gboolean opt_rtl = FALSE;
static char *opt_text = NULL;
static gboolean opt_waterfall = FALSE;
static int opt_width = -1;
+static int opt_indent = 0;
static void fail (const char *format, ...) G_GNUC_PRINTF (1, 2);
@@ -112,6 +113,9 @@ make_layout(PangoContext *context,
if (opt_width > 0)
pango_layout_set_width (layout, (opt_width * opt_dpi * PANGO_SCALE + 32) / 72);
+ if (opt_indent != 0)
+ pango_layout_set_indent (layout, (opt_indent * opt_dpi * PANGO_SCALE + 32) / 72);
+
base_dir = pango_context_get_base_dir (context);
pango_layout_set_alignment (layout,
base_dir == PANGO_DIRECTION_LTR ? PANGO_ALIGN_LEFT : PANGO_ALIGN_RIGHT);
@@ -260,6 +264,8 @@ int main(int argc, char *argv[])
ARG_BOOL, &opt_waterfall },
{ "width", "Width in points to which to wrap output",
ARG_INT, &opt_width },
+ { "indent", "Width in points to indent paragraphs",
+ ARG_INT, &opt_indent },
{ NULL }
};
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 0d5c501a..445caa1f 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -414,11 +414,10 @@ pango_layout_get_wrap (PangoLayout *layout)
* @layout: a #PangoLayout.
* @indent: the amount by which to indentset
*
- * Sets the amount by which the first line should be shorter than the
- * rest of the lines. This may be negative, in which case
- * the subsequent lines will be shorter than the first line. (However,
- * in either case, the entire width of the layout will be given by
- * the value.)
+ * Sets the width in pango units to indent each paragraph. A negative value
+ * of @indent will produce a hanging indent. That is, the first line will
+ * have the full width, and subsequent lines will be indented by the
+ * absolute value of @indent.
**/
void
pango_layout_set_indent (PangoLayout *layout,
@@ -437,8 +436,8 @@ pango_layout_set_indent (PangoLayout *layout,
* pango_layout_get_indent:
* @layout: a #PangoLayout
*
- * Gets the amount by which the first line should be shorter than the
- * rest of the lines.
+ * Gets the paragraph indent width in pango units. A negative value
+ * indicates a hanging indent.
*
* Return value: the indent
**/
@@ -1808,9 +1807,8 @@ get_x_offset (PangoLayout *layout,
if (layout->alignment == PANGO_ALIGN_CENTER)
return;
- if (line == layout->lines->data)
+ if (line->is_paragraph_start)
{
- /* First line */
if (layout->indent > 0)
{
if (layout->alignment == PANGO_ALIGN_LEFT)
@@ -2719,6 +2717,7 @@ process_line (PangoLayout *layout,
line = pango_layout_line_new (layout);
line->start_index = state->line_start_index;
+ line->is_paragraph_start = state->first_line;
if (state->first_line)
state->remaining_width = (layout->indent >= 0) ? layout->width - layout->indent : layout->width;
diff --git a/pango/pango-layout.h b/pango/pango-layout.h
index f3c8dfce..b490cedd 100644
--- a/pango/pango-layout.h
+++ b/pango/pango-layout.h
@@ -54,6 +54,7 @@ struct _PangoLayoutLine
gint start_index; /* start of line as byte index into layout->text */
gint length; /* length of line in bytes */
GSList *runs;
+ guint is_paragraph_start : 1; /* TRUE if this is the first line of the paragraph */
};
#define PANGO_TYPE_LAYOUT (pango_layout_get_type ())