| 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 |
| 11 #include <cassert> | 11 #include <cassert> |
| 12 #include <cstdlib> |
| 12 #include <iostream> | 13 #include <iostream> |
| 13 #include <map> | 14 #include <map> |
| 14 #include <string> | 15 #include <string> |
| 16 #include <sstream> |
| 15 | 17 |
| 16 #include <hb-ot.h> | 18 #include <hb-ot.h> |
| 17 | 19 |
| 18 #include "SkCanvas.h" | 20 #include "SkCanvas.h" |
| 19 #include "SkDocument.h" | 21 #include "SkDocument.h" |
| 20 #include "SkStream.h" | 22 #include "SkStream.h" |
| 21 #include "SkTextBlob.h" | 23 #include "SkTextBlob.h" |
| 22 #include "SkTypeface.h" | 24 #include "SkTypeface.h" |
| 23 | 25 |
| 24 struct BaseOption { | 26 struct BaseOption { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 39 Option(std::string selector, std::string description, T defaultValue) : | 41 Option(std::string selector, std::string description, T defaultValue) : |
| 40 BaseOption(selector, description), | 42 BaseOption(selector, description), |
| 41 value(defaultValue) {} | 43 value(defaultValue) {} |
| 42 }; | 44 }; |
| 43 | 45 |
| 44 struct DoubleOption : Option<double> { | 46 struct DoubleOption : Option<double> { |
| 45 virtual void set(std::string _value) { | 47 virtual void set(std::string _value) { |
| 46 value = atof(_value.c_str()); | 48 value = atof(_value.c_str()); |
| 47 } | 49 } |
| 48 virtual std::string valueToString() { | 50 virtual std::string valueToString() { |
| 49 return std::to_string(value); | 51 std::ostringstream stm; |
| 52 stm << value; |
| 53 return stm.str(); |
| 50 } | 54 } |
| 51 DoubleOption(std::string selector, std::string description, double defaultValu
e) : | 55 DoubleOption(std::string selector, std::string description, double defaultValu
e) : |
| 52 Option<double>(selector, description, defaultValue) {} | 56 Option<double>(selector, description, defaultValue) {} |
| 53 }; | 57 }; |
| 54 | 58 |
| 55 struct SkStringOption : Option<SkString> { | 59 struct SkStringOption : Option<SkString> { |
| 56 virtual void set(std::string _value) { | 60 virtual void set(std::string _value) { |
| 57 value = _value.c_str(); | 61 value = _value.c_str(); |
| 58 } | 62 } |
| 59 virtual std::string valueToString() { | 63 virtual std::string valueToString() { |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 Config config(argc, argv); | 301 Config config(argc, argv); |
| 298 | 302 |
| 299 Placement placement(config, new SkFILEWStream(config.output_file_name->value
.c_str())); | 303 Placement placement(config, new SkFILEWStream(config.output_file_name->value
.c_str())); |
| 300 for (std::string line; std::getline(std::cin, line);) { | 304 for (std::string line; std::getline(std::cin, line);) { |
| 301 placement.WriteLine(line.c_str()); | 305 placement.WriteLine(line.c_str()); |
| 302 } | 306 } |
| 303 placement.Close(); | 307 placement.Close(); |
| 304 | 308 |
| 305 return 0; | 309 return 0; |
| 306 } | 310 } |
| OLD | NEW |