aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcorvid <corvid@lavabit.com>2009-09-03 03:03:06 +0000
committercorvid <corvid@lavabit.com>2009-09-03 03:03:06 +0000
commit5231f9206c6c31ae0d53a5c52d6bb75d3d3b3a9e (patch)
treed53f0f6200a0fb538c4c80ceef3632248577dccc
parentbaa36e7fcb271838f2696232b513bf54df4b6d0a (diff)
TextblockIterator::getAllocation: use start & end args rather than entire Word.
This matters for the case of plain text, where an entire line is currently passed to dw as one very long Word.
-rw-r--r--dw/textblock.cc18
1 files changed, 18 insertions, 0 deletions
diff --git a/dw/textblock.cc b/dw/textblock.cc
index 0ba6439f..25ff750c 100644
--- a/dw/textblock.cc
+++ b/dw/textblock.cc
@@ -2159,14 +2159,32 @@ void Textblock::TextblockIterator::getAllocation (int start, int end,
allocation->x =
textblock->allocation.x + textblock->lineXOffsetWidget (line);
+
for (int i = line->firstWord; i < index; i++) {
Word *w = textblock->words->getRef(i);
allocation->x += w->size.width + w->effSpace;
}
+ if (start > 0 && word->content.type == core::Content::TEXT) {
+ allocation->x += textblock->layout->textWidth (word->style->font,
+ word->content.text,
+ start);
+ }
allocation->y =
textblock->allocation.y
+ textblock->lineYOffsetWidget (line) + line->ascent - word->size.ascent;
+
allocation->width = word->size.width;
+ if (word->content.type == core::Content::TEXT) {
+ int wordEnd = strlen(word->content.text);
+
+ if (start > 0 || end < wordEnd) {
+ end = misc::min(end, wordEnd); /* end could be INT_MAX */
+ allocation->width =
+ textblock->layout->textWidth (word->style->font,
+ word->content.text + start,
+ end - start);
+ }
+ }
allocation->ascent = word->size.ascent;
allocation->descent = word->size.descent;
}