aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/shape
diff options
context:
space:
mode:
Diffstat (limited to 'tools/shape')
-rw-r--r--tools/shape/using_skia_and_harfbuzz.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/tools/shape/using_skia_and_harfbuzz.cpp b/tools/shape/using_skia_and_harfbuzz.cpp
index 01d9a3ed86..5a74866794 100644
--- a/tools/shape/using_skia_and_harfbuzz.cpp
+++ b/tools/shape/using_skia_and_harfbuzz.cpp
@@ -138,7 +138,16 @@ public:
}
void WriteLine(const SkShaper& shaper, const char *text, size_t textBytes) {
- if (!pageCanvas || current_y > config->page_height.value) {
+ SkTextBlobBuilder textBlobBuilder;
+ SkPoint endPoint = shaper.shape(&textBlobBuilder, glyph_paint, text, textBytes, true,
+ SkPoint{0, 0},
+ config->page_width.value - 2*config->left_margin.value);
+ sk_sp<const SkTextBlob> blob = textBlobBuilder.make();
+ // If we don't have a page, or if we're not at the start of the page and the blob won't fit
+ if (!pageCanvas ||
+ (current_y > config->line_spacing_ratio.value * config->font_size.value &&
+ current_y + endPoint.y() > config->page_height.value)
+ ) {
if (pageCanvas) {
document->endPage();
}
@@ -149,11 +158,6 @@ public:
current_x = config->left_margin.value;
current_y = config->line_spacing_ratio.value * config->font_size.value;
}
- SkTextBlobBuilder textBlobBuilder;
- SkPoint endPoint = shaper.shape(&textBlobBuilder, glyph_paint, text, textBytes, true,
- SkPoint{0, 0},
- config->page_width.value - 2*config->left_margin.value);
- sk_sp<const SkTextBlob> blob = textBlobBuilder.make();
pageCanvas->drawTextBlob(
blob.get(), SkDoubleToScalar(current_x),
SkDoubleToScalar(current_y), glyph_paint);