1 /*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 // running create_test_font_color generates ./<cbdt|sbix|cpal>.ttx
9 // which are read by fonttools ttx to produce native fonts.
10
11 #include "include/core/SkRefCnt.h"
12 #include "include/core/SkStream.h"
13 #include "include/core/SkString.h"
14 #include "tools/flags/CommandLineFlags.h"
15 #include "tools/fonts/TestSVGTypeface.h"
16
17 #if defined(SK_ENABLE_SVG)
18
export_ttx(sk_sp<TestSVGTypeface> typeface,SkString prefix,SkSpan<unsigned> cbdtStrikeSizes,SkSpan<unsigned> sbixStrikeSizes)19 static void export_ttx(sk_sp<TestSVGTypeface> typeface,
20 SkString prefix,
21 SkSpan<unsigned> cbdtStrikeSizes,
22 SkSpan<unsigned> sbixStrikeSizes) {
23 SkFILEWStream cbdt((SkString(prefix) += "cbdt.ttx").c_str());
24 typeface->exportTtxCbdt(&cbdt, cbdtStrikeSizes);
25 cbdt.flush();
26 cbdt.fsync();
27
28 SkFILEWStream sbix((SkString(prefix) += "sbix.ttx").c_str());
29 typeface->exportTtxSbix(&sbix, sbixStrikeSizes);
30 sbix.flush();
31 sbix.fsync();
32
33 SkFILEWStream colr((SkString(prefix) += "colr.ttx").c_str());
34 typeface->exportTtxColr(&colr);
35 colr.flush();
36 colr.fsync();
37 }
38
main(int argc,char ** argv)39 int main(int argc, char** argv) {
40 CommandLineFlags::Parse(argc, argv);
41
42 // Most of the time use these sizes.
43 unsigned usual[] = { 16, 64, 128 };
44
45 // But the planet font cannot get very big in the size limited cbdt format.
46 unsigned small[] = { 8, 16 };
47
48 export_ttx(TestSVGTypeface::Default(), SkString(), SkMakeSpan(usual), SkMakeSpan(usual));
49 export_ttx(
50 TestSVGTypeface::Planets(), SkString("planet"), SkMakeSpan(small), SkMakeSpan(usual));
51
52 return 0;
53 }
54
55 #else
56
main(int argc,char ** argv)57 int main(int argc, char** argv) {
58 SkDebugf("compile with SVG enabled\n");
59 return 1;
60 }
61
62 #endif // SK_ENABLE_SVG
63