Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1079)

Unified Diff: third_party/WebKit/Source/platform/fonts/CharacterData.h

Issue 1742293002: Support src/build/linux/unbundle in CharacterDataGenerator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/fonts/CharacterData.h
diff --git a/third_party/WebKit/Source/platform/fonts/CharacterDataGenerator.cpp b/third_party/WebKit/Source/platform/fonts/CharacterData.h
similarity index 61%
copy from third_party/WebKit/Source/platform/fonts/CharacterDataGenerator.cpp
copy to third_party/WebKit/Source/platform/fonts/CharacterData.h
index a1c540184e14a42fc4726b10227a0cb5d3600435..a9c8f21d959abca0d2175a66afbf97d96d785206 100644
--- a/third_party/WebKit/Source/platform/fonts/CharacterDataGenerator.cpp
+++ b/third_party/WebKit/Source/platform/fonts/CharacterData.h
@@ -2,20 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "CharacterProperty.h"
+#ifndef CharacterData_h
+#define CharacterData_h
-#include <cassert>
-#include <cstring>
-#include <stdio.h>
#include <unicode/uobject.h>
-#define MUTEX_H // Prevent compile failure of utrie2.h on Windows
-#include <utrie2.h>
-const UChar32 kMaxCodepoint = 0x10FFFF;
-using CharacterProperty = blink::CharacterProperty;
-#define ARRAY_LENGTH(a) (sizeof(a) / sizeof((a)[0]))
+namespace blink {
-static const UChar32 cjkIsolatedSymbolsArray[] = {
+static const UChar32 isCJKIdeographOrSymbolArray[] = {
// 0x2C7 Caron, Mandarin Chinese 3rd Tone
0x2C7,
// 0x2CA Modifier Letter Acute Accent, Mandarin Chinese 2nd Tone
@@ -36,7 +30,8 @@ static const UChar32 cjkIsolatedSymbolsArray[] = {
0x1F100
};
-static const UChar32 cjkIdeographRanges[] = {
+static const UChar32 isCJKIdeographOrSymbolRanges[] = {
+ // cjkIdeographRanges
// CJK Radicals Supplement and Kangxi Radicals.
0x2E80, 0x2FDF,
// CJK Strokes.
@@ -53,10 +48,9 @@ static const UChar32 cjkIdeographRanges[] = {
// CJK Unified Ideographs Extension D.
0x2A700, 0x2B81F,
// CJK Compatibility Ideographs Supplement.
- 0x2F800, 0x2FA1F
-};
+ 0x2F800, 0x2FA1F,
-static const UChar32 cjkSymbolRanges[] = {
+ // cjkSymbolRanges
0x2156, 0x215A,
0x2160, 0x216B,
0x2170, 0x217B,
@@ -225,113 +219,6 @@ static const UChar32 isUprightInMixedVerticalRanges[] = {
0x100000, 0x10FFFD,
};
-static void setRanges(CharacterProperty* values,
- const UChar32* ranges, size_t length,
- CharacterProperty value)
-{
- assert(length % 2 == 0);
- const UChar32* end = ranges + length;
- for (; ranges != end; ranges += 2) {
- assert(ranges[0] <= ranges[1]
- && ranges[1] <= kMaxCodepoint);
- for (UChar32 c = ranges[0]; c <= ranges[1]; c++)
- values[c] |= value;
- }
-}
-
-static void setValues(CharacterProperty* values,
- const UChar32* begin, size_t length,
- CharacterProperty value)
-{
- const UChar32* end = begin + length;
- for (; begin != end; begin++) {
- assert(*begin <= kMaxCodepoint);
- values[*begin] |= value;
- }
-}
-
-static void generate(FILE* fp, int32_t size, uint8_t* array)
-{
- fprintf(fp,
- "#include <cstdint>\n\n"
- "namespace blink {\n\n"
- "int32_t serializedCharacterDataSize = %d;\n"
- "uint8_t serializedCharacterData[] = {", size);
- for (int32_t i = 0; i < size; ) {
- fprintf(fp, "\n ");
- for (int col = 0; col < 16 && i < size; col++, i++)
- fprintf(fp, " 0x%02X,", array[i]);
- }
- fprintf(fp,
- "\n};\n\n"
- "} // namespace blink\n");
-}
-
-int main(int argc, char** argv)
-{
- // Create a value array of all possible code points.
- const UChar32 size = kMaxCodepoint + 1;
- CharacterProperty* values = new CharacterProperty[size];
- memset(values, 0, sizeof(CharacterProperty) * size);
-
- setRanges(values,
- cjkIdeographRanges, ARRAY_LENGTH(cjkIdeographRanges),
- CharacterProperty::isCJKIdeographOrSymbol);
- setRanges(values,
- cjkSymbolRanges, ARRAY_LENGTH(cjkSymbolRanges),
- CharacterProperty::isCJKIdeographOrSymbol);
- setValues(values,
- cjkIsolatedSymbolsArray, ARRAY_LENGTH(cjkIsolatedSymbolsArray),
- CharacterProperty::isCJKIdeographOrSymbol);
-
- setRanges(values,
- isUprightInMixedVerticalRanges,
- ARRAY_LENGTH(isUprightInMixedVerticalRanges),
- CharacterProperty::isUprightInMixedVertical);
- setValues(values,
- isUprightInMixedVerticalArray,
- ARRAY_LENGTH(isUprightInMixedVerticalArray),
- CharacterProperty::isUprightInMixedVertical);
-
- // Create a trie from the value array.
- UErrorCode error = U_ZERO_ERROR;
- UTrie2* trie = utrie2_open(0, 0, &error);
- assert(error == U_ZERO_ERROR);
- UChar32 start = 0;
- CharacterProperty value = values[0];
- for (UChar32 c = 1;; c++) {
- if (c < size && values[c] == value)
- continue;
- if (static_cast<uint32_t>(value)) {
- utrie2_setRange32(trie, start, c - 1,
- static_cast<uint32_t>(value), TRUE, &error);
- assert(error == U_ZERO_ERROR);
- }
- if (c >= size)
- break;
- start = c;
- value = values[start];
- }
-
- // Freeze and serialize the trie to a byte array.
- utrie2_freeze(trie, UTrie2ValueBits::UTRIE2_16_VALUE_BITS, &error);
- assert(error == U_ZERO_ERROR);
- int32_t serializedSize = utrie2_serialize(trie, nullptr, 0, &error);
- error = U_ZERO_ERROR;
- uint8_t* serialized = new uint8_t[serializedSize];
- serializedSize = utrie2_serialize(trie, serialized, serializedSize, &error);
- assert(error == U_ZERO_ERROR);
-
- // Write the serialized array to the source file.
- if (argc <= 1) {
- generate(stdout, serializedSize, serialized);
- } else {
- FILE* fp = fopen(argv[1], "wb");
- generate(fp, serializedSize, serialized);
- fclose(fp);
- }
-
- utrie2_close(trie);
+} // namespace blink
- return 0;
-}
+#endif

Powered by Google App Engine
This is Rietveld 408576698