Create a unified target for the txt and minikin library, tests and benchmarks. (flutter/engine#4016)
This commit is contained in:
@@ -14,8 +14,8 @@ group("flutter") {
|
||||
if (!is_fuchsia) {
|
||||
if (current_toolchain == host_toolchain) {
|
||||
deps += [
|
||||
"//dart:create_sdk",
|
||||
"//flutter/frontend_server",
|
||||
"//dart:create_sdk",
|
||||
"//flutter/frontend_server",
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -42,8 +42,12 @@ group("flutter") {
|
||||
"//flutter/fml:fml_unittests",
|
||||
"//flutter/sky/engine/wtf:wtf_unittests",
|
||||
"//flutter/synchronization:synchronization_unittests",
|
||||
"//flutter/third_party/txt:txt_unittests",
|
||||
"//lib/ftl:ftl_unittests",
|
||||
]
|
||||
if (is_linux) {
|
||||
deps += [ "//flutter/third_party/txt:txt_benchmarks" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
11
engine/src/flutter/third_party/txt/Android.bp
vendored
11
engine/src/flutter/third_party/txt/Android.bp
vendored
@@ -1,11 +0,0 @@
|
||||
cc_library_headers {
|
||||
name: "libminikin_headers",
|
||||
host_supported: true,
|
||||
export_include_dirs: ["include"],
|
||||
}
|
||||
|
||||
subdirs = [
|
||||
"app",
|
||||
"libs/minikin",
|
||||
"tests",
|
||||
]
|
||||
147
engine/src/flutter/third_party/txt/BUILD.gn
vendored
147
engine/src/flutter/third_party/txt/BUILD.gn
vendored
@@ -13,11 +13,8 @@
|
||||
# limitations under the License.
|
||||
|
||||
config("txt_config") {
|
||||
include_dirs = [
|
||||
"//lib/txt/include",
|
||||
"//third_party/harfbuzz/src",
|
||||
"//lib/txt/shims",
|
||||
]
|
||||
visibility = [ ":*" ]
|
||||
include_dirs = [ "src" ]
|
||||
}
|
||||
|
||||
source_set("txt") {
|
||||
@@ -29,34 +26,126 @@ source_set("txt") {
|
||||
}
|
||||
|
||||
sources = [
|
||||
"src/font_collection.cc",
|
||||
"src/font_collection.h",
|
||||
"src/font_skia.cc",
|
||||
"src/font_skia.h",
|
||||
"src/font_style.h",
|
||||
"src/font_weight.h",
|
||||
"src/paint_record.cc",
|
||||
"src/paint_record.h",
|
||||
"src/paragraph.cc",
|
||||
"src/paragraph.h",
|
||||
"src/paragraph_builder.cc",
|
||||
"src/paragraph_builder.h",
|
||||
"src/paragraph_style.cc",
|
||||
"src/paragraph_style.h",
|
||||
"src/styled_runs.cc",
|
||||
"src/styled_runs.h",
|
||||
"src/text_align.h",
|
||||
"src/text_baseline.h",
|
||||
"src/text_decoration.cc",
|
||||
"src/text_decoration.h",
|
||||
"src/text_style.cc",
|
||||
"src/text_style.h",
|
||||
"src/log/log.cc",
|
||||
"src/log/log.h",
|
||||
"src/minikin/CmapCoverage.cpp",
|
||||
"src/minikin/CmapCoverage.h",
|
||||
"src/minikin/Emoji.cpp",
|
||||
"src/minikin/Emoji.h",
|
||||
"src/minikin/FontCollection.cpp",
|
||||
"src/minikin/FontCollection.h",
|
||||
"src/minikin/FontFamily.cpp",
|
||||
"src/minikin/FontFamily.h",
|
||||
"src/minikin/FontLanguage.cpp",
|
||||
"src/minikin/FontLanguage.h",
|
||||
"src/minikin/FontLanguageListCache.cpp",
|
||||
"src/minikin/FontLanguageListCache.h",
|
||||
"src/minikin/FontUtils.cpp",
|
||||
"src/minikin/FontUtils.h",
|
||||
"src/minikin/GraphemeBreak.cpp",
|
||||
"src/minikin/GraphemeBreak.h",
|
||||
"src/minikin/HbFontCache.cpp",
|
||||
"src/minikin/HbFontCache.h",
|
||||
"src/minikin/Hyphenator.cpp",
|
||||
"src/minikin/Hyphenator.h",
|
||||
"src/minikin/Layout.cpp",
|
||||
"src/minikin/Layout.h",
|
||||
"src/minikin/LayoutUtils.cpp",
|
||||
"src/minikin/LayoutUtils.h",
|
||||
"src/minikin/LineBreaker.cpp",
|
||||
"src/minikin/LineBreaker.h",
|
||||
"src/minikin/Measurement.cpp",
|
||||
"src/minikin/Measurement.h",
|
||||
"src/minikin/MinikinFont.cpp",
|
||||
"src/minikin/MinikinFont.h",
|
||||
"src/minikin/MinikinInternal.cpp",
|
||||
"src/minikin/MinikinInternal.h",
|
||||
"src/minikin/SparseBitSet.cpp",
|
||||
"src/minikin/SparseBitSet.h",
|
||||
"src/minikin/WordBreaker.cpp",
|
||||
"src/minikin/WordBreaker.h",
|
||||
"src/txt/font_collection.cc",
|
||||
"src/txt/font_collection.h",
|
||||
"src/txt/font_skia.cc",
|
||||
"src/txt/font_skia.h",
|
||||
"src/txt/font_style.h",
|
||||
"src/txt/font_weight.h",
|
||||
"src/txt/paint_record.cc",
|
||||
"src/txt/paint_record.h",
|
||||
"src/txt/paragraph.cc",
|
||||
"src/txt/paragraph.h",
|
||||
"src/txt/paragraph_builder.cc",
|
||||
"src/txt/paragraph_builder.h",
|
||||
"src/txt/paragraph_style.cc",
|
||||
"src/txt/paragraph_style.h",
|
||||
"src/txt/styled_runs.cc",
|
||||
"src/txt/styled_runs.h",
|
||||
"src/txt/text_align.h",
|
||||
"src/txt/text_baseline.h",
|
||||
"src/txt/text_decoration.cc",
|
||||
"src/txt/text_decoration.h",
|
||||
"src/txt/text_style.cc",
|
||||
"src/txt/text_style.h",
|
||||
"src/utils/JenkinsHash.cpp",
|
||||
"src/utils/JenkinsHash.h",
|
||||
"src/utils/LruCache.h",
|
||||
"src/utils/TypeHelpers.h",
|
||||
]
|
||||
|
||||
public_configs = [ ":txt_config" ]
|
||||
|
||||
deps = [
|
||||
"//lib/txt/libs/minikin",
|
||||
public_deps = [
|
||||
"//lib/ftl",
|
||||
"//third_party/harfbuzz",
|
||||
"//third_party/icu",
|
||||
"//third_party/skia",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//third_party/skia:effects",
|
||||
]
|
||||
}
|
||||
|
||||
txt_common_executable_deps = [
|
||||
"//dart/runtime:libdart_jit", # For logging.
|
||||
"//flutter/fml", # For ICU initialization.
|
||||
]
|
||||
|
||||
executable("txt_unittests") {
|
||||
testonly = true
|
||||
|
||||
sources = [
|
||||
"tests/font_collection_unittests.cc",
|
||||
"tests/paragraph_unittests.cc",
|
||||
"tests/render_test.cc",
|
||||
"tests/render_test.h",
|
||||
"tests/txt_run_all_unittests.cc",
|
||||
"tests/utils.cc",
|
||||
"tests/utils.h",
|
||||
]
|
||||
|
||||
deps = [
|
||||
":txt",
|
||||
"//third_party/gtest",
|
||||
] + txt_common_executable_deps
|
||||
}
|
||||
|
||||
executable("txt_benchmarks") {
|
||||
testonly = true
|
||||
|
||||
sources = [
|
||||
"benchmarks/font_collection_benchmarks.cc",
|
||||
"benchmarks/paint_record_benchmarks.cc",
|
||||
"benchmarks/paragraph_benchmarks.cc",
|
||||
"benchmarks/paragraph_builder_benchmarks.cc",
|
||||
"benchmarks/styled_runs_benchmarks.cc",
|
||||
"benchmarks/txt_run_all_benchmarks.cc",
|
||||
"benchmarks/utils.cc",
|
||||
"benchmarks/utils.h",
|
||||
]
|
||||
|
||||
deps = [
|
||||
":txt",
|
||||
"//third_party/benchmark",
|
||||
] + txt_common_executable_deps
|
||||
}
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
// Copyright (C) 2015 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// see how_to_run.txt for instructions on running these tests
|
||||
|
||||
cc_binary_host {
|
||||
name: "hyphtool",
|
||||
|
||||
static_libs: ["libminikin"],
|
||||
|
||||
// Shared libraries which are dependencies of minikin; these are not automatically
|
||||
// pulled in by the build system (and thus sadly must be repeated).
|
||||
shared_libs: [
|
||||
"liblog",
|
||||
"libicuuc",
|
||||
],
|
||||
|
||||
srcs: ["HyphTool.cpp"],
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "unicode/locid.h"
|
||||
|
||||
#include <vector>
|
||||
#include <minikin/Hyphenator.h>
|
||||
|
||||
using minikin::HyphenationType;
|
||||
using minikin::Hyphenator;
|
||||
|
||||
Hyphenator* loadHybFile(const char* fn, int minPrefix, int minSuffix) {
|
||||
struct stat statbuf;
|
||||
int status = stat(fn, &statbuf);
|
||||
if (status < 0) {
|
||||
fprintf(stderr, "error opening %s\n", fn);
|
||||
return nullptr;
|
||||
}
|
||||
size_t size = statbuf.st_size;
|
||||
FILE* f = fopen(fn, "rb");
|
||||
if (f == NULL) {
|
||||
fprintf(stderr, "error opening %s\n", fn);
|
||||
return nullptr;
|
||||
}
|
||||
uint8_t* buf = new uint8_t[size];
|
||||
size_t read_size = fread(buf, 1, size, f);
|
||||
fclose(f);
|
||||
if (read_size < size) {
|
||||
fprintf(stderr, "error reading %s\n", fn);
|
||||
delete[] buf;
|
||||
return nullptr;
|
||||
}
|
||||
return Hyphenator::loadBinary(buf, minPrefix, minSuffix);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
Hyphenator* hyph = loadHybFile("/tmp/en.hyb", 2, 3); // should also be configurable
|
||||
std::vector<HyphenationType> result;
|
||||
std::vector<uint16_t> word;
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "usage: hyphtool word\n");
|
||||
return 1;
|
||||
}
|
||||
char* asciiword = argv[1];
|
||||
size_t len = strlen(asciiword);
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
uint32_t c = asciiword[i];
|
||||
if (c == '-') {
|
||||
c = 0x00AD;
|
||||
}
|
||||
// ASCII (or possibly ISO Latin 1), but kinda painful to do utf conversion :(
|
||||
word.push_back(c);
|
||||
}
|
||||
hyph->hyphenate(&result, word.data(), word.size(), icu::Locale::getUS());
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
if (result[i] != HyphenationType::DONT_BREAK) {
|
||||
printf("-");
|
||||
}
|
||||
printf("%c", word[i]);
|
||||
}
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
# Copyright 2017 Google, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
executable("benchmarks") {
|
||||
output_name = "txt_benchmarks"
|
||||
testonly = true
|
||||
|
||||
include_dirs = [
|
||||
"//lib/txt/src",
|
||||
"//lib/txt/include",
|
||||
"//third_party/icu/source",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"font_collection_benchmarks.cc",
|
||||
"paint_record_benchmarks.cc",
|
||||
"paragraph_benchmarks.cc",
|
||||
"paragraph_builder_benchmarks.cc",
|
||||
"styled_runs_benchmarks.cc",
|
||||
"txt_run_all_benchmarks.cc",
|
||||
"utils.cc",
|
||||
"utils.h",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//dart/runtime:libdart_jit", # Logging
|
||||
"//flutter/fml",
|
||||
"//lib/txt/shims",
|
||||
"//lib/txt",
|
||||
"//third_party/benchmark",
|
||||
"//third_party/skia",
|
||||
"//third_party/harfbuzz",
|
||||
"//lib/txt/libs/minikin",
|
||||
]
|
||||
|
||||
}
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
#include "lib/ftl/command_line.h"
|
||||
#include "lib/ftl/logging.h"
|
||||
#include "lib/txt/src/font_collection.h"
|
||||
#include "third_party/skia/include/ports/SkFontMgr.h"
|
||||
#include "third_party/skia/include/ports/SkFontMgr_directory.h"
|
||||
#include "txt/font_collection.h"
|
||||
#include "utils.h"
|
||||
|
||||
namespace txt {
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
#include "lib/ftl/command_line.h"
|
||||
#include "lib/ftl/logging.h"
|
||||
#include "lib/txt/src/paint_record.h"
|
||||
#include "lib/txt/src/text_style.h"
|
||||
#include "txt/paint_record.h"
|
||||
#include "txt/text_style.h"
|
||||
#include "utils.h"
|
||||
|
||||
namespace txt {
|
||||
|
||||
@@ -19,18 +19,18 @@
|
||||
#include <minikin/Layout.h>
|
||||
#include "lib/ftl/command_line.h"
|
||||
#include "lib/ftl/logging.h"
|
||||
#include "lib/txt/libs/minikin/LayoutUtils.h"
|
||||
#include "lib/txt/src/font_collection.h"
|
||||
#include "lib/txt/src/font_skia.h"
|
||||
#include "lib/txt/src/font_style.h"
|
||||
#include "lib/txt/src/font_weight.h"
|
||||
#include "lib/txt/src/paragraph.h"
|
||||
#include "lib/txt/src/paragraph_builder.h"
|
||||
#include "lib/txt/src/text_align.h"
|
||||
#include "minikin/LayoutUtils.h"
|
||||
#include "third_party/icu/source/common/unicode/unistr.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "third_party/skia/include/core/SkCanvas.h"
|
||||
#include "third_party/skia/include/core/SkColor.h"
|
||||
#include "txt/font_collection.h"
|
||||
#include "txt/font_skia.h"
|
||||
#include "txt/font_style.h"
|
||||
#include "txt/font_weight.h"
|
||||
#include "txt/paragraph.h"
|
||||
#include "txt/paragraph_builder.h"
|
||||
#include "txt/text_align.h"
|
||||
#include "utils.h"
|
||||
|
||||
namespace txt {
|
||||
|
||||
@@ -17,14 +17,14 @@
|
||||
#include "third_party/benchmark/include/benchmark/benchmark_api.h"
|
||||
|
||||
#include "lib/ftl/logging.h"
|
||||
#include "lib/txt/src/font_collection.h"
|
||||
#include "lib/txt/src/font_style.h"
|
||||
#include "lib/txt/src/font_weight.h"
|
||||
#include "lib/txt/src/paragraph.h"
|
||||
#include "lib/txt/src/paragraph_builder.h"
|
||||
#include "lib/txt/src/text_align.h"
|
||||
#include "third_party/icu/source/common/unicode/unistr.h"
|
||||
#include "third_party/skia/include/core/SkColor.h"
|
||||
#include "txt/font_collection.h"
|
||||
#include "txt/font_style.h"
|
||||
#include "txt/font_weight.h"
|
||||
#include "txt/paragraph.h"
|
||||
#include "txt/paragraph_builder.h"
|
||||
#include "txt/text_align.h"
|
||||
#include "utils.h"
|
||||
|
||||
namespace txt {
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
#include "lib/ftl/command_line.h"
|
||||
#include "lib/ftl/logging.h"
|
||||
#include "lib/txt/src/styled_runs.h"
|
||||
#include "lib/txt/src/text_style.h"
|
||||
#include "txt/styled_runs.h"
|
||||
#include "txt/text_style.h"
|
||||
#include "utils.h"
|
||||
|
||||
namespace txt {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "lib/ftl/command_line.h"
|
||||
#include "lib/txt/tests/txt/utils.h"
|
||||
#include "utils.h"
|
||||
|
||||
namespace txt {
|
||||
|
||||
|
||||
@@ -1,135 +0,0 @@
|
||||
# Hyb (hyphenation pattern binary) file format
|
||||
|
||||
The hyb file format is how hyphenation patterns are stored in the system image.
|
||||
|
||||
Goals include:
|
||||
|
||||
* Concise (system image space is at a premium)
|
||||
* Usable when mmap'ed, so it doesn't take significant physical RAM
|
||||
* Fast to compute
|
||||
* Simple
|
||||
|
||||
It is _not_ intended as an interchange format, so there is no attempt to make the format
|
||||
extensible or facilitate backward and forward compatibility.
|
||||
|
||||
Further, at some point we will probably pack patterns for multiple languages into a single
|
||||
physical file, to reduce number of open mmap'ed files. This document doesn't cover that.
|
||||
|
||||
## Theoretical basis
|
||||
|
||||
At heart, the file contains packed tries with suffix compression, actually quite similar
|
||||
to the implementation in TeX.
|
||||
|
||||
The file contains three sections. The first section represents the "alphabet," including
|
||||
case folding. It is effectively a map from Unicode code point to a small integer.
|
||||
|
||||
The second section contains the trie in packed form. It is an array of 3-tuples, packed
|
||||
into a 32 bit integer. Each (suffix-compressed) trie node has a unique index within this
|
||||
array, and the pattern field in the tuple is the pattern for that node. Further, each edge
|
||||
in the trie has an entry in the array, and the character and link fields in the tuple
|
||||
represent the label and destination of the edge. The packing strategy is as in
|
||||
[Word Hy-phen-a-tion by Com-put-er](http://www.tug.org/docs/liang/liang-thesis.pdf) by
|
||||
Franklin Mark Liang.
|
||||
|
||||
The trie representation is similar but not identical to the "double-array trie".
|
||||
The fundamental operation of lookup of the edge from `s` to `t` with label `c` is
|
||||
to compare `c == character[s + c]`, and if so, `t = link[s + c]`.
|
||||
|
||||
The third section contains the pattern strings. This section is in two parts: first,
|
||||
an array with a 3-tuple for each pattern (length, number of trailing 0's, and offset
|
||||
into the string pool); and second, the string pool. Each pattern is encoded as a byte
|
||||
(packing 2 per byte would be possible but the space savings would not be signficant).
|
||||
|
||||
As much as possible of the file is represented as 32 bit integers, as that is especially
|
||||
efficent to access. All are little-endian (this could be revised if the code ever needs
|
||||
to be ported to big-endian systems).
|
||||
|
||||
## Header
|
||||
|
||||
```
|
||||
uint32_t magic == 0x62ad7968
|
||||
uint32_t version = 0
|
||||
uint32_t alphabet_offset (in bytes)
|
||||
uint32_t trie_offset (in bytes)
|
||||
uint32_t pattern_offset (in bytes)
|
||||
uint32_t file_size (in bytes)
|
||||
```
|
||||
|
||||
Offsets are from the front of the file, and in bytes.
|
||||
|
||||
## Alphabet
|
||||
|
||||
The alphabet table comes in two versions. The first is well suited to dense Unicode
|
||||
ranges and is limited to 256. The second is more general, but lookups will be slower.
|
||||
|
||||
### Alphabet, direct version
|
||||
|
||||
```
|
||||
uint32_t version = 0
|
||||
uint32_t min_codepoint
|
||||
uint32_t max_codepoint (exclusive)
|
||||
uint8_t[] data
|
||||
```
|
||||
|
||||
The size of the data array is max_codepoint - min_codepoint. 0 represents an unmapped
|
||||
character. Note that, in the current implementation, automatic hyphenation is disabled
|
||||
for any word containing an unmapped character.
|
||||
|
||||
In general, pad bytes follow this table, aligning the next table to a 4-byte boundary.
|
||||
|
||||
### Alphabet, general version
|
||||
|
||||
```
|
||||
uint32_t version = 1
|
||||
uint32_t n_entries
|
||||
uint32_t[n_entries] data
|
||||
```
|
||||
|
||||
Each element in the data table is `(codepoint << 11) | value`. Note that this is
|
||||
restricted to 11 bits (2048 possible values). The largest known current value is 483
|
||||
(for Sanskrit).
|
||||
|
||||
The entries are sorted by codepoint, to facilitate binary search. Another reasonable
|
||||
implementation for consumers of the data would be to build a hash table at load time.
|
||||
|
||||
## Trie
|
||||
|
||||
```
|
||||
uint32_t version = 0
|
||||
uint32_t char_mask
|
||||
uint32_t link_shift
|
||||
uint32_t link_mask
|
||||
uint32_t pattern_shift
|
||||
uint32_t n_entries
|
||||
uint32_t[n_entries] data
|
||||
```
|
||||
|
||||
Each element in the data table is `(pattern << pattern_shift) | (link << link_shift) | char`.
|
||||
|
||||
All known pattern tables fit in 32 bits total. If this is exceeded, there is a fairly
|
||||
straightforward tweak, where each node occupies a slot by itself (as opposed to sharing
|
||||
it with edge slots), which would require very minimal changes to the implementation (TODO
|
||||
present in more detail).
|
||||
|
||||
## Pattern
|
||||
|
||||
```
|
||||
uint32_t version = 0
|
||||
uint32_t n_entries
|
||||
uint32_t pattern_offset (in bytes)
|
||||
uint32_t pattern_size (in bytes)
|
||||
uint32_t[n_entries] data
|
||||
uint8_t[] pattern_buf
|
||||
```
|
||||
|
||||
Each element in data table is `(len << 26) | (shift << 20) | offset`, where an offset of 0
|
||||
points to the first byte of pattern_buf.
|
||||
|
||||
Generally pattern_offset is `16 + 4 * n_entries`.
|
||||
|
||||
For example, 'a4m5ato' would be represented as `[4, 5, 0, 0, 0]`, then len = 2, shift = 3, and
|
||||
offset points to [4, 5] in the pattern buffer.
|
||||
|
||||
Future extension: additional data representing nonstandard hyphenation. See
|
||||
[Automatic non-standard hyphenation in OpenOffice.org](https://www.tug.org/TUGboat/tb27-1/tb86nemeth.pdf)
|
||||
for more information about that issue.
|
||||
@@ -1,28 +0,0 @@
|
||||
# Copyright 2017 Google Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
executable("txt_example") {
|
||||
sources = [
|
||||
"main.cc",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//dart/runtime:libdart_jit",
|
||||
"//flutter/fml",
|
||||
"//lib/txt/libs/minikin",
|
||||
"//lib/txt",
|
||||
"//third_party/icu:icuuc",
|
||||
"//third_party/skia",
|
||||
]
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <unicode/unistr.h>
|
||||
|
||||
#include <SkCanvas.h>
|
||||
#include <SkGraphics.h>
|
||||
#include <SkImageEncoder.h>
|
||||
|
||||
#include "flutter/fml/icu_util.h"
|
||||
#include "lib/txt/src/paragraph_builder.h"
|
||||
|
||||
namespace txt {
|
||||
|
||||
int runTest() {
|
||||
const char* utf8_text =
|
||||
"fine world that we live in is called Earth. It's pretty nice, as far as "
|
||||
"I can tell. Rock, rock on. "
|
||||
"\xe0\xa4\xa8\xe0\xa4\xae\xe0\xa4\xb8\xe0\xa5\x8d\xe0\xa4\xa4\xe0\xa5"
|
||||
"\x87";
|
||||
icu::UnicodeString icu_text = icu::UnicodeString::fromUTF8(utf8_text);
|
||||
std::u16string u16_text(icu_text.getBuffer(),
|
||||
icu_text.getBuffer() + icu_text.length());
|
||||
|
||||
ParagraphStyle paragraph_style;
|
||||
ParagraphBuilder builder(paragraph_style);
|
||||
TextStyle style;
|
||||
style.color = SK_ColorBLUE;
|
||||
style.font_size = 32.0;
|
||||
builder.PushStyle(style);
|
||||
builder.AddText(u16_text);
|
||||
style.color = SK_ColorYELLOW;
|
||||
builder.PushStyle(style);
|
||||
builder.AddText(u16_text);
|
||||
builder.Pop();
|
||||
builder.AddText(u16_text);
|
||||
builder.Pop();
|
||||
auto paragraph = builder.Build();
|
||||
|
||||
int width = 800;
|
||||
int height = 600;
|
||||
paragraph->Layout(width);
|
||||
|
||||
SkAutoGraphics ag;
|
||||
SkBitmap bitmap;
|
||||
bitmap.allocN32Pixels(width, height);
|
||||
SkCanvas canvas(bitmap);
|
||||
paragraph->Paint(&canvas, 10.0, 200.0);
|
||||
|
||||
SkFILEWStream file("foo.png");
|
||||
|
||||
return SkEncodeImage(&file, bitmap, SkEncodedImageFormat::kPNG, 100)
|
||||
? EXIT_SUCCESS
|
||||
: EXIT_FAILURE;
|
||||
}
|
||||
|
||||
} // namespace txt
|
||||
|
||||
int main(int argc, const char** argv) {
|
||||
fml::icu::InitializeICU();
|
||||
return txt::runTest();
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
// Copyright (C) 2013 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
cc_library_headers {
|
||||
name: "libminikin-headers-for-tests",
|
||||
export_include_dirs: ["."],
|
||||
shared_libs: ["libharfbuzz_ng"],
|
||||
export_shared_lib_headers: ["libharfbuzz_ng"],
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "libminikin",
|
||||
host_supported: true,
|
||||
srcs: [
|
||||
"Hyphenator.cpp",
|
||||
],
|
||||
target: {
|
||||
android: {
|
||||
srcs: [
|
||||
"CmapCoverage.cpp",
|
||||
"Emoji.cpp",
|
||||
"FontCollection.cpp",
|
||||
"FontFamily.cpp",
|
||||
"FontLanguage.cpp",
|
||||
"FontLanguageListCache.cpp",
|
||||
"FontUtils.cpp",
|
||||
"GraphemeBreak.cpp",
|
||||
"HbFontCache.cpp",
|
||||
"Layout.cpp",
|
||||
"LayoutUtils.cpp",
|
||||
"LineBreaker.cpp",
|
||||
"Measurement.cpp",
|
||||
"MinikinInternal.cpp",
|
||||
"MinikinFont.cpp",
|
||||
"SparseBitSet.cpp",
|
||||
"WordBreaker.cpp",
|
||||
],
|
||||
shared_libs: [
|
||||
"libharfbuzz_ng",
|
||||
"libft2",
|
||||
"libz",
|
||||
"libutils",
|
||||
],
|
||||
// TODO: clean up Minikin so it doesn't need the freetype include
|
||||
export_shared_lib_headers: ["libft2"],
|
||||
},
|
||||
},
|
||||
cppflags: [
|
||||
"-Werror",
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
],
|
||||
product_variables: {
|
||||
debuggable: {
|
||||
// Enable race detection on eng and userdebug build.
|
||||
cppflags: ["-DENABLE_RACE_DETECTION"],
|
||||
},
|
||||
},
|
||||
shared_libs: [
|
||||
"liblog",
|
||||
"libicuuc",
|
||||
],
|
||||
header_libs: ["libminikin_headers"],
|
||||
export_header_lib_headers: ["libminikin_headers"],
|
||||
export_shared_lib_headers: ["libicuuc"],
|
||||
|
||||
clang: true,
|
||||
sanitize: {
|
||||
misc_undefined: [
|
||||
"signed-integer-overflow",
|
||||
// b/26432628.
|
||||
//"unsigned-integer-overflow",
|
||||
],
|
||||
},
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
# Copyright 2017 Google Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
config("minikin_config") {
|
||||
include_dirs = [ "../../include" ]
|
||||
}
|
||||
|
||||
source_set("minikin") {
|
||||
defines = [ "WIP_NEEDS_ICU_UPDATE" ]
|
||||
|
||||
sources = [
|
||||
"CmapCoverage.cpp",
|
||||
"Emoji.cpp",
|
||||
"FontCollection.cpp",
|
||||
"FontFamily.cpp",
|
||||
"FontLanguage.cpp",
|
||||
"FontLanguage.h",
|
||||
"FontLanguageListCache.cpp",
|
||||
"FontLanguageListCache.h",
|
||||
"FontUtils.cpp",
|
||||
"FontUtils.h",
|
||||
"GraphemeBreak.cpp",
|
||||
"HbFontCache.cpp",
|
||||
"HbFontCache.h",
|
||||
"Hyphenator.cpp",
|
||||
"Layout.cpp",
|
||||
"LayoutUtils.cpp",
|
||||
"LayoutUtils.h",
|
||||
"LineBreaker.cpp",
|
||||
"Measurement.cpp",
|
||||
"MinikinFont.cpp",
|
||||
"MinikinInternal.cpp",
|
||||
"MinikinInternal.h",
|
||||
"SparseBitSet.cpp",
|
||||
"WordBreaker.cpp",
|
||||
]
|
||||
|
||||
public_configs = [ ":minikin_config" ]
|
||||
|
||||
public_deps = [
|
||||
"//lib/txt/shims",
|
||||
"//third_party/freetype2",
|
||||
"//third_party/harfbuzz",
|
||||
"//third_party/icu:icuuc",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//third_party/zlib",
|
||||
]
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
# Copyright 2017 Google Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
config("shims_config") {
|
||||
include_dirs = [ "." ]
|
||||
}
|
||||
|
||||
source_set("shims") {
|
||||
sources = [
|
||||
"log/log.h",
|
||||
"log/log.cc",
|
||||
"utils/JenkinsHash.cpp",
|
||||
"utils/JenkinsHash.h",
|
||||
"utils/LruCache.h",
|
||||
"utils/TypeHelpers.h",
|
||||
]
|
||||
|
||||
public_configs = [ ":shims_config" ]
|
||||
|
||||
public_deps = [
|
||||
"//lib/ftl",
|
||||
]
|
||||
}
|
||||
17
engine/src/flutter/third_party/txt/src/BUILD.gn
vendored
17
engine/src/flutter/third_party/txt/src/BUILD.gn
vendored
@@ -1,17 +0,0 @@
|
||||
# Copyright 2017 Google Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
source_set("src") {
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "lib/txt/src/font_collection.h"
|
||||
#include "font_collection.h"
|
||||
|
||||
#include <list>
|
||||
#include <memory>
|
||||
@@ -24,8 +24,8 @@
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "font_skia.h"
|
||||
#include "lib/ftl/logging.h"
|
||||
#include "lib/txt/src/font_skia.h"
|
||||
#include "third_party/skia/include/core/SkString.h"
|
||||
#include "third_party/skia/include/ports/SkFontMgr.h"
|
||||
#include "third_party/skia/include/ports/SkFontMgr_android.h"
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "lib/txt/src/font_skia.h"
|
||||
#include "font_skia.h"
|
||||
|
||||
#include <minikin/MinikinFont.h>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "lib/txt/src/paint_record.h"
|
||||
#include "paint_record.h"
|
||||
#include "lib/ftl/logging.h"
|
||||
|
||||
namespace txt {
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "lib/ftl/logging.h"
|
||||
#include "lib/ftl/macros.h"
|
||||
#include "lib/txt/src/text_style.h"
|
||||
#include "text_style.h"
|
||||
#include "third_party/skia/include/core/SkPaint.h"
|
||||
#include "third_party/skia/include/core/SkTextBlob.h"
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "lib/txt/src/paragraph.h"
|
||||
#include "paragraph.h"
|
||||
|
||||
#include <hb.h>
|
||||
#include <algorithm>
|
||||
@@ -24,13 +24,13 @@
|
||||
#include <vector>
|
||||
|
||||
#include <minikin/Layout.h>
|
||||
#include "font_collection.h"
|
||||
#include "font_skia.h"
|
||||
#include "lib/ftl/logging.h"
|
||||
#include "lib/txt/include/minikin/MinikinFont.h"
|
||||
#include "lib/txt/libs/minikin/HbFontCache.h"
|
||||
#include "lib/txt/libs/minikin/LayoutUtils.h"
|
||||
#include "lib/txt/src/font_collection.h"
|
||||
#include "lib/txt/src/font_skia.h"
|
||||
#include "minikin/HbFontCache.h"
|
||||
#include "minikin/LayoutUtils.h"
|
||||
#include "minikin/LineBreaker.h"
|
||||
#include "minikin/MinikinFont.h"
|
||||
#include "third_party/skia/include/core/SkCanvas.h"
|
||||
#include "third_party/skia/include/core/SkPaint.h"
|
||||
#include "third_party/skia/include/core/SkTextBlob.h"
|
||||
@@ -20,12 +20,12 @@
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
#include "font_collection.h"
|
||||
#include "lib/ftl/macros.h"
|
||||
#include "lib/txt/src/font_collection.h"
|
||||
#include "lib/txt/src/paint_record.h"
|
||||
#include "lib/txt/src/paragraph_style.h"
|
||||
#include "lib/txt/src/styled_runs.h"
|
||||
#include "minikin/LineBreaker.h"
|
||||
#include "paint_record.h"
|
||||
#include "paragraph_style.h"
|
||||
#include "styled_runs.h"
|
||||
#include "third_party/gtest/include/gtest/gtest_prod.h"
|
||||
#include "third_party/skia/include/core/SkPoint.h"
|
||||
#include "third_party/skia/include/core/SkRect.h"
|
||||
@@ -17,8 +17,8 @@
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "lib/txt/src/paragraph_builder.h"
|
||||
#include "lib/txt/src/paragraph_style.h"
|
||||
#include "paragraph_builder.h"
|
||||
#include "paragraph_style.h"
|
||||
#include "third_party/icu/source/common/unicode/unistr.h"
|
||||
|
||||
namespace txt {
|
||||
@@ -20,12 +20,12 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "font_collection.h"
|
||||
#include "lib/ftl/macros.h"
|
||||
#include "lib/txt/src/font_collection.h"
|
||||
#include "lib/txt/src/paragraph.h"
|
||||
#include "lib/txt/src/paragraph_style.h"
|
||||
#include "lib/txt/src/styled_runs.h"
|
||||
#include "lib/txt/src/text_style.h"
|
||||
#include "paragraph.h"
|
||||
#include "paragraph_style.h"
|
||||
#include "styled_runs.h"
|
||||
#include "text_style.h"
|
||||
|
||||
namespace txt {
|
||||
|
||||
@@ -14,4 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "lib/txt/src/paragraph_style.h"
|
||||
#include "paragraph_style.h"
|
||||
|
||||
namespace txt {
|
||||
|
||||
//
|
||||
|
||||
} // namespace txt
|
||||
@@ -20,10 +20,10 @@
|
||||
#include <climits>
|
||||
#include <string>
|
||||
|
||||
#include "lib/txt/include/minikin/LineBreaker.h"
|
||||
#include "lib/txt/src/font_style.h"
|
||||
#include "lib/txt/src/font_weight.h"
|
||||
#include "lib/txt/src/text_align.h"
|
||||
#include "font_style.h"
|
||||
#include "font_weight.h"
|
||||
#include "minikin/LineBreaker.h"
|
||||
#include "text_align.h"
|
||||
|
||||
namespace txt {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "lib/txt/src/styled_runs.h"
|
||||
#include "styled_runs.h"
|
||||
|
||||
#include "lib/ftl/logging.h"
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
#include "lib/txt/src/text_style.h"
|
||||
#include "text_style.h"
|
||||
#include "third_party/gtest/include/gtest/gtest_prod.h"
|
||||
|
||||
namespace txt {
|
||||
@@ -17,6 +17,10 @@
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
#include "lib/txt/src/text_decoration.h"
|
||||
#include "text_decoration.h"
|
||||
|
||||
namespace txt {} // namespace txt
|
||||
namespace txt {
|
||||
|
||||
//
|
||||
|
||||
} // namespace txt
|
||||
@@ -32,4 +32,4 @@ enum TextDecorationStyle { kSolid, kDouble, kDotted, kDashed, kWavy };
|
||||
|
||||
} // namespace txt
|
||||
|
||||
#endif // LIB_TXT_SRC_TEXT_DECORATION_H_
|
||||
#endif // LIB_TXT_SRC_TEXT_DECORATION_H_
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "lib/txt/src/text_style.h"
|
||||
#include "lib/txt/src/font_style.h"
|
||||
#include "lib/txt/src/font_weight.h"
|
||||
#include "text_style.h"
|
||||
#include "font_style.h"
|
||||
#include "font_weight.h"
|
||||
#include "third_party/skia/include/core/SkColor.h"
|
||||
|
||||
namespace txt {
|
||||
@@ -19,10 +19,10 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "lib/txt/src/font_style.h"
|
||||
#include "lib/txt/src/font_weight.h"
|
||||
#include "lib/txt/src/text_baseline.h"
|
||||
#include "lib/txt/src/text_decoration.h"
|
||||
#include "font_style.h"
|
||||
#include "font_weight.h"
|
||||
#include "text_baseline.h"
|
||||
#include "text_decoration.h"
|
||||
#include "third_party/skia/include/core/SkColor.h"
|
||||
|
||||
namespace txt {
|
||||
@@ -1,33 +0,0 @@
|
||||
filegroup {
|
||||
name: "minikin-test-data",
|
||||
srcs: [
|
||||
"data/Bold.ttf",
|
||||
"data/BoldItalic.ttf",
|
||||
"data/ColorEmojiFont.ttf",
|
||||
"data/ColorTextMixedEmojiFont.ttf",
|
||||
"data/Emoji.ttf",
|
||||
"data/Italic.ttf",
|
||||
"data/Ja.ttf",
|
||||
"data/Ko.ttf",
|
||||
"data/MultiAxis.ttf",
|
||||
"data/NoCmapFormat14.ttf",
|
||||
"data/NoGlyphFont.ttf",
|
||||
"data/Regular.ttf",
|
||||
"data/TextEmojiFont.ttf",
|
||||
"data/UnicodeBMPOnly.ttf",
|
||||
"data/UnicodeBMPOnly2.ttf",
|
||||
"data/UnicodeUCS4.ttf",
|
||||
"data/VariationSelectorTest-Regular.ttf",
|
||||
"data/ZhHans.ttf",
|
||||
"data/ZhHant.ttf",
|
||||
"data/emoji.xml",
|
||||
"data/itemize.xml",
|
||||
],
|
||||
}
|
||||
|
||||
subdirs = [
|
||||
"perftests",
|
||||
"stresstest",
|
||||
"unittest",
|
||||
"util",
|
||||
]
|
||||
@@ -1,22 +0,0 @@
|
||||
# Copyright 2017 Google, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
group("tests") {
|
||||
testonly = true
|
||||
|
||||
deps = [
|
||||
"txt",
|
||||
"unittest",
|
||||
]
|
||||
}
|
||||
@@ -14,11 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "font_collection.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "lib/ftl/command_line.h"
|
||||
#include "lib/ftl/logging.h"
|
||||
#include "lib/txt/tests/txt/utils.h"
|
||||
#include "txt/font_collection.h"
|
||||
#include "utils.h"
|
||||
|
||||
namespace txt {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user