Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1355)

Side by Side Diff: tools/using_skia_and_harfbuzz.cpp

Issue 2084533004: SkTextBlob: Begin implementing Extended TextBlob API (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/SkShaper_harfbuzz.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2016 Google Inc. 2 * Copyright 2016 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 // This sample progam demonstrates how to use Skia and HarfBuzz to 8 // This sample progam demonstrates how to use Skia and HarfBuzz to
9 // produce a PDF file from UTF-8 text in stdin. 9 // produce a PDF file from UTF-8 text in stdin.
10 10
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } 144 }
145 pageCanvas = document->beginPage( 145 pageCanvas = document->beginPage(
146 SkDoubleToScalar(config->page_width.value), 146 SkDoubleToScalar(config->page_width.value),
147 SkDoubleToScalar(config->page_height.value)); 147 SkDoubleToScalar(config->page_height.value));
148 pageCanvas->drawPaint(white_paint); 148 pageCanvas->drawPaint(white_paint);
149 current_x = config->left_margin.value; 149 current_x = config->left_margin.value;
150 current_y = config->line_spacing_ratio.value * config->font_size.val ue; 150 current_y = config->line_spacing_ratio.value * config->font_size.val ue;
151 } 151 }
152 SkTextBlobBuilder textBlobBuilder; 152 SkTextBlobBuilder textBlobBuilder;
153 shaper.shape(&textBlobBuilder, glyph_paint, text, textBytes, SkPoint{0, 0}); 153 shaper.shape(&textBlobBuilder, glyph_paint, text, textBytes, SkPoint{0, 0});
154 sk_sp<const SkTextBlob> blob(textBlobBuilder.build()); 154 sk_sp<const SkTextBlob> blob = textBlobBuilder.make();
155 pageCanvas->drawTextBlob( 155 pageCanvas->drawTextBlob(
156 blob.get(), SkDoubleToScalar(current_x), 156 blob.get(), SkDoubleToScalar(current_x),
157 SkDoubleToScalar(current_y), glyph_paint); 157 SkDoubleToScalar(current_y), glyph_paint);
158 // Advance to the next line. 158 // Advance to the next line.
159 current_y += config->line_spacing_ratio.value * config->font_size.value; 159 current_y += config->line_spacing_ratio.value * config->font_size.value;
160 } 160 }
161 161
162 private: 162 private:
163 const Config* config; 163 const Config* config;
164 SkDocument *document; 164 SkDocument *document;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 } 207 }
208 SkShaper shaper(typeface); 208 SkShaper shaper(typeface);
209 assert(shaper.good()); 209 assert(shaper.good());
210 for (std::string line; std::getline(std::cin, line);) { 210 for (std::string line; std::getline(std::cin, line);) {
211 placement.WriteLine(shaper, line.c_str(), line.size()); 211 placement.WriteLine(shaper, line.c_str(), line.size());
212 } 212 }
213 213
214 doc->close(); 214 doc->close();
215 return 0; 215 return 0;
216 } 216 }
OLDNEW
« no previous file with comments | « tools/SkShaper_harfbuzz.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698