| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |