summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2013-09-07 14:30:42 -0500
committerRobin Watts <robin.watts@artifex.com>2013-09-10 14:14:42 +0100
commita0a92b5cf0fa076c923e7a5aa911dfff28aea351 (patch)
tree61e3c83a558fe7b15cc450d1aee79927c9f20a12 /source
parent455fecd8213201417a75f887349a5c3b75d5f46d (diff)
downloadmupdf-a0a92b5cf0fa076c923e7a5aa911dfff28aea351.tar.xz
Attempt to fix reflow.
Diffstat (limited to 'source')
-rw-r--r--source/fitz/stext-paragraph.c41
1 files changed, 36 insertions, 5 deletions
diff --git a/source/fitz/stext-paragraph.c b/source/fitz/stext-paragraph.c
index 51062938..5704f3cf 100644
--- a/source/fitz/stext-paragraph.c
+++ b/source/fitz/stext-paragraph.c
@@ -988,6 +988,32 @@ dehyphenate(fz_text_span *s1, fz_text_span *s2)
s2->spacing = 0;
}
+#ifdef DEBUG_ALIGN
+static void
+dump_span(fz_text_span *span)
+{
+}
+
+static void
+dump_line(fz_text_line *line)
+{
+ fz_text_span *span;
+
+ if (!line)
+ return;
+ printf("d=%g: ", line->distance);
+
+ span = line->first_span;
+ while (span)
+ {
+ dump_span(span);
+ span = span->next;
+ }
+
+ printf("\n");
+}
+#endif
+
void
fz_analyze_text(fz_context *ctx, fz_text_sheet *sheet, fz_text_page *page)
{
@@ -1042,7 +1068,7 @@ fz_analyze_text(fz_context *ctx, fz_text_sheet *sheet, fz_text_page *page)
/* Have we had this style before? */
int match = 0;
fz_text_span *span2;
- for (span2 = line->first_span; span2; span2 = span2->next)
+ for (span2 = line->first_span; span2 != span; span2 = span2->next)
{
int char_num2;
for (char_num2 = 0; char_num2 < span2->len; char_num2++)
@@ -1107,7 +1133,7 @@ list_entry:
continue;
#ifdef DEBUG_LINE_HEIGHTS
- printf("line height=%g nspans=%d\n", line->distance, line->len);
+ printf("line height=%g\n", line->distance);
#endif
for (span = line->first_span; span; span = span->next)
{
@@ -1388,7 +1414,7 @@ force_paragraph:
int try_dehyphen = -1;
fz_text_span *prev_span = NULL;
span = line->first_span;
- while (span)
+ while (span && *prev_line_span)
{
/* Skip forwards through the original
* line, until we find a place where
@@ -1417,10 +1443,15 @@ force_paragraph:
prev_span = *prev_line_span = span;
span = span->next;
(*prev_line_span)->next = next;
- prev_line_span = &span->next;
+ prev_line_span = &(*prev_line_span)->next;
}
}
- while (span || *prev_line_span);
+ if (span)
+ {
+ *prev_line_span = span;
+ prev_line->last_span = line->last_span;
+ }
+
line->first_span = NULL;
line->last_span = NULL;
}