diff options
author | Hal Canary <halcanary@google.com> | 2018-07-25 16:52:48 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-07-31 20:11:19 +0000 |
commit | f107a2fd014cd39c489060f2cd1b99cd49c7d0be (patch) | |
tree | 5c324821344901869203bbe055be8d3f69f696cb /tools | |
parent | 1935aa3d27cd4ed4aef2dc04360f247a541d4b00 (diff) |
SkUTF
Create new header and namespace, `SkUTF` where we are putting all of our
robust, well documented UTF-8, UTF-16, and UTF-32 functions:
`SkUTF::{Count,Next,To}UTF{8,16,32}()`.
SkUTF.h and SkUTF.cpp do not depend on the rest of Skia and are suitable
for re-use in other modules.
Some of the old UTF-{8,16} functions still live in SkUtils.h; their use
will be phased out in future CLs.
Also added more unit testing and cleaned up old tests.
Removed functions that were unused outside of tests or used only once.
Change-Id: Iaa59b8705abccf9c4ba082f855da368a0bad8380
Reviewed-on: https://skia-review.googlesource.com/143306
Reviewed-by: Ben Wagner <bungeman@google.com>
Commit-Queue: Hal Canary <halcanary@google.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/fonts/create_test_font.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/tools/fonts/create_test_font.cpp b/tools/fonts/create_test_font.cpp index 36ead3cb65..de19c099c9 100644 --- a/tools/fonts/create_test_font.cpp +++ b/tools/fonts/create_test_font.cpp @@ -140,13 +140,12 @@ static int output_points(const SkPoint* pts, int emSize, int count, SkString* pt static void output_path_data(const SkPaint& paint, int emSize, SkString* ptsOut, SkTDArray<SkPath::Verb>* verbs, SkTDArray<unsigned>* charCodes, SkTDArray<SkScalar>* widths) { - for (int ch = 0x00; ch < 0x7f; ++ch) { - char str[1]; - str[0] = ch; - const char* used = str; - SkUnichar index = SkUTF8_NextUnichar(&used, str + 1); + for (SkUnichar index = 0x00; index < 0x7f; ++index) { + uint16_t utf16[2]; + size_t utf16Bytes = sizeof(uint16_t) * SkUTF::ToUTF16(index, utf16); SkPath path; - paint.getTextPath((const void*) &index, 2, 0, 0, &path); + SkASSERT(paint.getTextEncoding() == SkPaint::kUTF16_TextEncoding); + paint.getTextPath(utf16, utf16Bytes, 0, 0, &path); SkPath::RawIter iter(path); SkPath::Verb verb; SkPoint pts[4]; @@ -175,12 +174,12 @@ static void output_path_data(const SkPaint& paint, *verbs->append() = SkPath::kDone_Verb; *charCodes->append() = index; SkScalar width; - SkDEBUGCODE(int charCount =) paint.getTextWidths((const void*) &index, 2, &width); + SkDEBUGCODE(int charCount =) paint.getTextWidths(utf16, utf16Bytes, &width); SkASSERT(charCount == 1); // SkASSERT(floor(width) == width); // not true for Hiragino Maru Gothic Pro *widths->append() = width; - if (!ch) { - ch = 0x1f; // skip the rest of the control codes + if (0 == index) { + index = 0x1f; // skip the rest of the control codes } } } @@ -432,7 +431,11 @@ static void generate_index(const char* defaultName) { } int main(int , char * const []) { +#ifdef SK_BUILD_FOR_UNIX + generate_fonts("/usr/share/fonts/truetype/liberation/"); +#else generate_fonts("/Library/Fonts/"); // or /usr/share/fonts/truetype/ttf-liberation/ +#endif generate_index(DEFAULT_FONT_NAME); return 0; } |