Apply clang-format
Bug: 65125938
Test: m
Change-Id: I4a4319cc34c186aa0a3ce1d0301af1cd4e0feb81
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..e0611e3
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,8 @@
+BasedOnStyle: Google
+DerivePointerAlignment: false
+IndentWidth: 4
+ConstructorInitializerIndentWidth: 8
+ContinuationIndentWidth: 8
+ColumnLimit: 100
+AllowShortFunctionsOnASingleLine: Inline
+AccessModifierOffset: -4
diff --git a/PREUPLOAD.cfg b/PREUPLOAD.cfg
new file mode 100644
index 0000000..f031ffc
--- /dev/null
+++ b/PREUPLOAD.cfg
@@ -0,0 +1,5 @@
+[Builtin Hooks]
+clang_format = true
+
+[Builtin Hooks Options]
+clang_format = --commit ${PREUPLOAD_COMMIT} --style file --extensions h,cpp
diff --git a/app/HyphTool.cpp b/app/HyphTool.cpp
index 975cd8f..2fd9cbf 100644
--- a/app/HyphTool.cpp
+++ b/app/HyphTool.cpp
@@ -1,5 +1,5 @@
-#include <sys/stat.h>
#include <string.h>
+#include <sys/stat.h>
#include <cstdio>
#include <vector>
diff --git a/doc/minikin_style.md b/doc/minikin_style.md
index d51578c..3c1c521 100644
--- a/doc/minikin_style.md
+++ b/doc/minikin_style.md
@@ -15,7 +15,8 @@
6. Other libraries' files
7. A blank line
8. Minikin public files
- 9. Minikin private files
+ 9. A blank line
+ 10. Minikin private files
For example,
```
diff --git a/include/minikin/AndroidLineBreakerHelper.h b/include/minikin/AndroidLineBreakerHelper.h
index 2d84617..1c257ef 100644
--- a/include/minikin/AndroidLineBreakerHelper.h
+++ b/include/minikin/AndroidLineBreakerHelper.h
@@ -23,176 +23,172 @@
namespace android {
class AndroidLineWidth : public LineWidth {
- public:
- AndroidLineWidth(float firstWidth, int32_t firstLineCount, float restWidth,
- const std::vector<float>& indents, const std::vector<float>& leftPaddings,
- const std::vector<float>& rightPaddings, int32_t indentsAndPaddingsOffset)
- : mFirstWidth(firstWidth), mFirstLineCount(firstLineCount), mRestWidth(restWidth),
- mIndents(indents), mLeftPaddings(leftPaddings),
- mRightPaddings(rightPaddings), mOffset(indentsAndPaddingsOffset) {}
+public:
+ AndroidLineWidth(float firstWidth, int32_t firstLineCount, float restWidth,
+ const std::vector<float>& indents, const std::vector<float>& leftPaddings,
+ const std::vector<float>& rightPaddings, int32_t indentsAndPaddingsOffset)
+ : mFirstWidth(firstWidth),
+ mFirstLineCount(firstLineCount),
+ mRestWidth(restWidth),
+ mIndents(indents),
+ mLeftPaddings(leftPaddings),
+ mRightPaddings(rightPaddings),
+ mOffset(indentsAndPaddingsOffset) {}
- float getAt(size_t lineNo) const override {
- const float width = ((ssize_t)lineNo < (ssize_t)mFirstLineCount)
- ? mFirstWidth : mRestWidth;
- return width - get(mIndents, lineNo);
+ float getAt(size_t lineNo) const override {
+ const float width = ((ssize_t)lineNo < (ssize_t)mFirstLineCount) ? mFirstWidth : mRestWidth;
+ return width - get(mIndents, lineNo);
+ }
+
+ float getMin() const override {
+ // A simpler algorithm would have been simply looping until the larger of
+ // mFirstLineCount and mIndents.size()-mOffset, but that does unnecessary calculations
+ // when mFirstLineCount is large. Instead, we measure the first line, all the lines that
+ // have an indent, and the first line after firstWidth ends and restWidth starts.
+ float minWidth = std::min(getAt(0), getAt(mFirstLineCount));
+ for (size_t lineNo = 1; lineNo + mOffset < mIndents.size(); lineNo++) {
+ minWidth = std::min(minWidth, getAt(lineNo));
}
+ return minWidth;
+ }
- float getMin() const override {
- // A simpler algorithm would have been simply looping until the larger of
- // mFirstLineCount and mIndents.size()-mOffset, but that does unnecessary calculations
- // when mFirstLineCount is large. Instead, we measure the first line, all the lines that
- // have an indent, and the first line after firstWidth ends and restWidth starts.
- float minWidth = std::min(getAt(0), getAt(mFirstLineCount));
- for (size_t lineNo = 1; lineNo + mOffset < mIndents.size(); lineNo++) {
- minWidth = std::min(minWidth, getAt(lineNo));
- }
- return minWidth;
+ float getLeftPaddingAt(size_t lineNo) const override { return get(mLeftPaddings, lineNo); }
+
+ float getRightPaddingAt(size_t lineNo) const override { return get(mRightPaddings, lineNo); }
+
+private:
+ float get(const std::vector<float>& vec, size_t lineNo) const {
+ if (vec.empty()) {
+ return 0;
}
-
- float getLeftPaddingAt(size_t lineNo) const override {
- return get(mLeftPaddings, lineNo);
+ const size_t index = lineNo + mOffset;
+ if (index < vec.size()) {
+ return vec[index];
+ } else {
+ return vec.back();
}
+ }
- float getRightPaddingAt(size_t lineNo) const override {
- return get(mRightPaddings, lineNo);
- }
-
- private:
- float get(const std::vector<float>& vec, size_t lineNo) const {
- if (vec.empty()) {
- return 0;
- }
- const size_t index = lineNo + mOffset;
- if (index < vec.size()) {
- return vec[index];
- } else {
- return vec.back();
- }
- }
-
- const float mFirstWidth;
- const int32_t mFirstLineCount;
- const float mRestWidth;
- const std::vector<float>& mIndents;
- const std::vector<float>& mLeftPaddings;
- const std::vector<float>& mRightPaddings;
- const int32_t mOffset;
+ const float mFirstWidth;
+ const int32_t mFirstLineCount;
+ const float mRestWidth;
+ const std::vector<float>& mIndents;
+ const std::vector<float>& mLeftPaddings;
+ const std::vector<float>& mRightPaddings;
+ const int32_t mOffset;
};
class StyleRun : public Run {
- public:
- StyleRun(const Range& range, MinikinPaint&& paint,
- std::shared_ptr<FontCollection>&& collection, bool isRtl)
- : Run(range), mPaint(std::move(paint)),
- mCollection(std::move(collection)), mIsRtl(isRtl) {}
+public:
+ StyleRun(const Range& range, MinikinPaint&& paint, std::shared_ptr<FontCollection>&& collection,
+ bool isRtl)
+ : Run(range),
+ mPaint(std::move(paint)),
+ mCollection(std::move(collection)),
+ mIsRtl(isRtl) {}
- bool canHyphenate() const override { return true; }
- uint32_t getLocaleListId() const override { return mPaint.localeListId; }
- bool isRtl() const override { return mIsRtl; }
+ bool canHyphenate() const override { return true; }
+ uint32_t getLocaleListId() const override { return mPaint.localeListId; }
+ bool isRtl() const override { return mIsRtl; }
- void getMetrics(const U16StringPiece& text, float* advances,
- MinikinExtent* extents,
- LayoutOverhang* overhangs) const override {
- Bidi bidiFlag = mIsRtl ? Bidi::FORCE_RTL : Bidi::FORCE_LTR;
- Layout::measureText(text, mRange, bidiFlag, mPaint, mCollection, advances, extents,
- overhangs);
- }
+ void getMetrics(const U16StringPiece& text, float* advances, MinikinExtent* extents,
+ LayoutOverhang* overhangs) const override {
+ Bidi bidiFlag = mIsRtl ? Bidi::FORCE_RTL : Bidi::FORCE_LTR;
+ Layout::measureText(text, mRange, bidiFlag, mPaint, mCollection, advances, extents,
+ overhangs);
+ }
- const MinikinPaint* getPaint() const override {
- return &mPaint;
- }
+ const MinikinPaint* getPaint() const override { return &mPaint; }
- float measureHyphenPiece(const U16StringPiece& text, const Range& range,
- StartHyphenEdit startHyphen, EndHyphenEdit endHyphen,
- float* advances, LayoutOverhang* overhangs) const override {
- Bidi bidiFlag = mIsRtl ? Bidi::FORCE_RTL : Bidi::FORCE_LTR;
- return Layout::measureText(
- text, range, bidiFlag, mPaint, startHyphen, endHyphen, mCollection,
- advances, nullptr /* extent */, overhangs);
- }
+ float measureHyphenPiece(const U16StringPiece& text, const Range& range,
+ StartHyphenEdit startHyphen, EndHyphenEdit endHyphen, float* advances,
+ LayoutOverhang* overhangs) const override {
+ Bidi bidiFlag = mIsRtl ? Bidi::FORCE_RTL : Bidi::FORCE_LTR;
+ return Layout::measureText(text, range, bidiFlag, mPaint, startHyphen, endHyphen,
+ mCollection, advances, nullptr /* extent */, overhangs);
+ }
- private:
- MinikinPaint mPaint;
- std::shared_ptr<FontCollection> mCollection;
- const bool mIsRtl;
+private:
+ MinikinPaint mPaint;
+ std::shared_ptr<FontCollection> mCollection;
+ const bool mIsRtl;
};
class Replacement : public Run {
- public:
- Replacement(const Range& range, float width, uint32_t localeListId)
+public:
+ Replacement(const Range& range, float width, uint32_t localeListId)
: Run(range), mWidth(width), mLocaleListId(localeListId) {}
- bool isRtl() const { return false; }
- bool canHyphenate() const { return false; }
- uint32_t getLocaleListId() const { return mLocaleListId; }
+ bool isRtl() const { return false; }
+ bool canHyphenate() const { return false; }
+ uint32_t getLocaleListId() const { return mLocaleListId; }
- void getMetrics(const U16StringPiece& /* unused */, float* advances,
- MinikinExtent* /* unused */, LayoutOverhang* /* unused */) const override {
- advances[0] = mWidth;
- // TODO: Get the extents information from the caller.
- }
+ void getMetrics(const U16StringPiece& /* unused */, float* advances,
+ MinikinExtent* /* unused */, LayoutOverhang* /* unused */) const override {
+ advances[0] = mWidth;
+ // TODO: Get the extents information from the caller.
+ }
- private:
- const float mWidth;
- const uint32_t mLocaleListId;
+private:
+ const float mWidth;
+ const uint32_t mLocaleListId;
};
class StaticLayoutNative {
- public:
- StaticLayoutNative(
- BreakStrategy strategy, HyphenationFrequency frequency,
- bool isJustified, std::vector<float>&& indents, std::vector<float>&& leftPaddings,
- std::vector<float>&& rightPaddings)
- : mStrategy(strategy), mFrequency(frequency), mIsJustified(isJustified),
- mIndents(std::move(indents)), mLeftPaddings(std::move(leftPaddings)),
+public:
+ StaticLayoutNative(BreakStrategy strategy, HyphenationFrequency frequency, bool isJustified,
+ std::vector<float>&& indents, std::vector<float>&& leftPaddings,
+ std::vector<float>&& rightPaddings)
+ : mStrategy(strategy),
+ mFrequency(frequency),
+ mIsJustified(isJustified),
+ mIndents(std::move(indents)),
+ mLeftPaddings(std::move(leftPaddings)),
mRightPaddings(std::move(rightPaddings)) {}
- void addStyleRun(int32_t start, int32_t end, MinikinPaint&& paint,
- std::shared_ptr<FontCollection> collection, bool isRtl) {
- mRuns.emplace_back(std::make_unique<StyleRun>(
- Range(start, end), std::move(paint), std::move(collection), isRtl));
- }
+ void addStyleRun(int32_t start, int32_t end, MinikinPaint&& paint,
+ std::shared_ptr<FontCollection> collection, bool isRtl) {
+ mRuns.emplace_back(std::make_unique<StyleRun>(Range(start, end), std::move(paint),
+ std::move(collection), isRtl));
+ }
- void addReplacementRun(int32_t start, int32_t end, float width, uint32_t localeListId) {
- mRuns.emplace_back(
- std::make_unique<Replacement>(Range(start, end), width, localeListId));
- }
+ void addReplacementRun(int32_t start, int32_t end, float width, uint32_t localeListId) {
+ mRuns.emplace_back(std::make_unique<Replacement>(Range(start, end), width, localeListId));
+ }
- MeasuredText measureText(const U16StringPiece& text) const {
- return MeasuredText::generate(text, mRuns);
- }
+ MeasuredText measureText(const U16StringPiece& text) const {
+ return MeasuredText::generate(text, mRuns);
+ }
- LineBreakResult computeBreaks(
- const U16StringPiece& text, const MeasuredText& measuredText,
- // Line width arguments
- float firstWidth, int32_t firstWidthLineCount, float restWidth,
- int32_t indentsOffset,
- // Tab stop arguments
- const int32_t* tabStops, int32_t tabStopSize, int32_t defaultTabStopWidth) const {
- AndroidLineWidth lineWidth(firstWidth, firstWidthLineCount, restWidth, mIndents,
- mLeftPaddings, mRightPaddings, indentsOffset);
- LineBreaker lineBreaker(text, measuredText, mStrategy, mFrequency, mIsJustified);
- return lineBreaker.computeBreaks(mRuns, lineWidth,
- TabStops(tabStops, tabStopSize, defaultTabStopWidth));
- }
+ LineBreakResult computeBreaks(const U16StringPiece& text, const MeasuredText& measuredText,
+ // Line width arguments
+ float firstWidth, int32_t firstWidthLineCount, float restWidth,
+ int32_t indentsOffset,
+ // Tab stop arguments
+ const int32_t* tabStops, int32_t tabStopSize,
+ int32_t defaultTabStopWidth) const {
+ AndroidLineWidth lineWidth(firstWidth, firstWidthLineCount, restWidth, mIndents,
+ mLeftPaddings, mRightPaddings, indentsOffset);
+ LineBreaker lineBreaker(text, measuredText, mStrategy, mFrequency, mIsJustified);
+ return lineBreaker.computeBreaks(mRuns, lineWidth,
+ TabStops(tabStops, tabStopSize, defaultTabStopWidth));
+ }
- void clearRuns() {
- mRuns.clear();
- }
+ void clearRuns() { mRuns.clear(); }
- inline BreakStrategy getStrategy() const { return mStrategy; }
- inline HyphenationFrequency getFrequency() const { return mFrequency; }
- inline bool isJustified() const { return mIsJustified; }
+ inline BreakStrategy getStrategy() const { return mStrategy; }
+ inline HyphenationFrequency getFrequency() const { return mFrequency; }
+ inline bool isJustified() const { return mIsJustified; }
- private:
- const BreakStrategy mStrategy;
- const HyphenationFrequency mFrequency;
- const bool mIsJustified;
- const std::vector<float> mIndents;
- const std::vector<float> mLeftPaddings;
- const std::vector<float> mRightPaddings;
+private:
+ const BreakStrategy mStrategy;
+ const HyphenationFrequency mFrequency;
+ const bool mIsJustified;
+ const std::vector<float> mIndents;
+ const std::vector<float> mLeftPaddings;
+ const std::vector<float> mRightPaddings;
- std::vector<std::unique_ptr<Run>> mRuns;
+ std::vector<std::unique_ptr<Run>> mRuns;
};
} // namespace android
diff --git a/include/minikin/Characters.h b/include/minikin/Characters.h
index 7810000..f433baf 100644
--- a/include/minikin/Characters.h
+++ b/include/minikin/Characters.h
@@ -20,16 +20,16 @@
namespace minikin {
// Code point order
-constexpr uint32_t CHAR_TAB = 0x0009;
-constexpr uint32_t CHAR_HYPHEN_MINUS = 0x002D;
-constexpr uint32_t CHAR_NBSP = 0x00A0;
-constexpr uint32_t CHAR_SOFT_HYPHEN = 0x00AD;
-constexpr uint32_t CHAR_MIDDLE_DOT = 0x00B7;
+constexpr uint32_t CHAR_TAB = 0x0009;
+constexpr uint32_t CHAR_HYPHEN_MINUS = 0x002D;
+constexpr uint32_t CHAR_NBSP = 0x00A0;
+constexpr uint32_t CHAR_SOFT_HYPHEN = 0x00AD;
+constexpr uint32_t CHAR_MIDDLE_DOT = 0x00B7;
constexpr uint32_t CHAR_ARMENIAN_HYPHEN = 0x058A;
-constexpr uint32_t CHAR_MAQAF = 0x05BE;
-constexpr uint32_t CHAR_UCAS_HYPHEN = 0x1400;
-constexpr uint32_t CHAR_ZWJ = 0x200D;
-constexpr uint32_t CHAR_HYPHEN = 0x2010;
+constexpr uint32_t CHAR_MAQAF = 0x05BE;
+constexpr uint32_t CHAR_UCAS_HYPHEN = 0x1400;
+constexpr uint32_t CHAR_ZWJ = 0x200D;
+constexpr uint32_t CHAR_HYPHEN = 0x2010;
} // namespace minikin
diff --git a/include/minikin/CmapCoverage.h b/include/minikin/CmapCoverage.h
index 87ebf64..583593d 100644
--- a/include/minikin/CmapCoverage.h
+++ b/include/minikin/CmapCoverage.h
@@ -27,7 +27,7 @@
class CmapCoverage {
public:
static SparseBitSet getCoverage(const uint8_t* cmap_data, size_t cmap_size,
- std::vector<std::unique_ptr<SparseBitSet>>* out);
+ std::vector<std::unique_ptr<SparseBitSet>>* out);
};
} // namespace minikin
diff --git a/include/minikin/Emoji.h b/include/minikin/Emoji.h
index 2826173..046a9d6 100644
--- a/include/minikin/Emoji.h
+++ b/include/minikin/Emoji.h
@@ -31,4 +31,3 @@
UCharDirection emojiBidiOverride(const void* context, UChar32 c);
} // namespace minikin
-
diff --git a/include/minikin/FontCollection.h b/include/minikin/FontCollection.h
index 684527d..288ed0d 100644
--- a/include/minikin/FontCollection.h
+++ b/include/minikin/FontCollection.h
@@ -21,8 +21,8 @@
#include <unordered_set>
#include <vector>
-#include "minikin/MinikinFont.h"
#include "minikin/FontFamily.h"
+#include "minikin/MinikinFont.h"
namespace minikin {
@@ -37,8 +37,8 @@
int end;
};
- void itemize(const uint16_t *string, size_t string_length, const MinikinPaint& paint,
- std::vector<Run>* result) const;
+ void itemize(const uint16_t* string, size_t string_length, const MinikinPaint& paint,
+ std::vector<Run>* result) const;
// Returns true if there is a glyph for the code point and variation selector pair.
// Returns false if no fonts have a glyph for the code point and variation
@@ -50,12 +50,10 @@
// Creates new FontCollection based on this collection while applying font variations. Returns
// nullptr if none of variations apply to this collection.
- std::shared_ptr<FontCollection>
- createCollectionWithVariation(const std::vector<FontVariation>& variations);
+ std::shared_ptr<FontCollection> createCollectionWithVariation(
+ const std::vector<FontVariation>& variations);
- const std::unordered_set<AxisTag>& getSupportedTags() const {
- return mSupportedAxes;
- }
+ const std::unordered_set<AxisTag>& getSupportedTags() const { return mSupportedAxes; }
uint32_t getId() const;
@@ -77,17 +75,18 @@
void init(const std::vector<std::shared_ptr<FontFamily>>& typefaces);
const std::shared_ptr<FontFamily>& getFamilyForChar(uint32_t ch, uint32_t vs,
- uint32_t localeListId, FontFamily::Variant variant) const;
+ uint32_t localeListId,
+ FontFamily::Variant variant) const;
uint32_t calcFamilyScore(uint32_t ch, uint32_t vs, FontFamily::Variant variant,
uint32_t localeListId,
const std::shared_ptr<FontFamily>& fontFamily) const;
uint32_t calcCoverageScore(uint32_t ch, uint32_t vs,
- const std::shared_ptr<FontFamily>& fontFamily) const;
+ const std::shared_ptr<FontFamily>& fontFamily) const;
static uint32_t calcLocaleMatchingScore(uint32_t userLocaleListId,
- const FontFamily& fontFamily);
+ const FontFamily& fontFamily);
static uint32_t calcVariantMatchingScore(FontFamily::Variant variant,
const FontFamily& fontFamily);
diff --git a/include/minikin/FontFamily.h b/include/minikin/FontFamily.h
index 22531f0..1f5b40c 100644
--- a/include/minikin/FontFamily.h
+++ b/include/minikin/FontFamily.h
@@ -32,11 +32,12 @@
// attributes representing transforms (fake bold, fake italic) to match styles
class FontFakery {
public:
- FontFakery() : mFakeBold(false), mFakeItalic(false) { }
- FontFakery(bool fakeBold, bool fakeItalic) : mFakeBold(fakeBold), mFakeItalic(fakeItalic) { }
+ FontFakery() : mFakeBold(false), mFakeItalic(false) {}
+ FontFakery(bool fakeBold, bool fakeItalic) : mFakeBold(fakeBold), mFakeItalic(fakeItalic) {}
// TODO: want to support graded fake bolding
bool isFakeBold() { return mFakeBold; }
bool isFakeItalic() { return mFakeItalic; }
+
private:
bool mFakeBold;
bool mFakeItalic;
@@ -83,7 +84,7 @@
// TODO: Good to expose FontUtil.h.
static bool analyzeStyle(const std::shared_ptr<MinikinFont>& typeface, int* weight,
- bool* italic);
+ bool* italic);
FakedFont getClosestMatch(FontStyle style) const;
uint32_t localeListId() const { return mLocaleListId; }
diff --git a/include/minikin/FontStyle.h b/include/minikin/FontStyle.h
index ade9c1c..73cf427 100644
--- a/include/minikin/FontStyle.h
+++ b/include/minikin/FontStyle.h
@@ -23,20 +23,20 @@
class FontStyle {
public:
enum class Weight : uint16_t {
- THIN = 100,
+ THIN = 100,
EXTRA_LIGHT = 200,
- LIGHT = 300,
- NORMAL = 400,
- MEDIUM = 500,
- SEMI_BOLD = 600,
- BOLD = 700,
- EXTRA_BOLD = 800,
- BLACK = 900,
+ LIGHT = 300,
+ NORMAL = 400,
+ MEDIUM = 500,
+ SEMI_BOLD = 600,
+ BOLD = 700,
+ EXTRA_BOLD = 800,
+ BLACK = 900,
EXTRA_BLACK = 1000,
};
enum class Slant : bool {
- ITALIC = true,
+ ITALIC = true,
UPRIGHT = false,
};
diff --git a/include/minikin/GraphemeBreak.h b/include/minikin/GraphemeBreak.h
index a6095da..8d8e359 100644
--- a/include/minikin/GraphemeBreak.h
+++ b/include/minikin/GraphemeBreak.h
@@ -24,24 +24,18 @@
class GraphemeBreak {
public:
// These values must be kept in sync with CURSOR_AFTER etc in Paint.java
- enum MoveOpt {
- AFTER = 0,
- AT_OR_AFTER = 1,
- BEFORE = 2,
- AT_OR_BEFORE = 3,
- AT = 4
- };
+ enum MoveOpt { AFTER = 0, AT_OR_AFTER = 1, BEFORE = 2, AT_OR_BEFORE = 3, AT = 4 };
// Determine whether the given offset is a grapheme break.
// This implementation generally follows Unicode's UTR #29 extended
// grapheme break, with various tweaks.
static bool isGraphemeBreak(const float* advances, const uint16_t* buf, size_t start,
- size_t count, size_t offset);
+ size_t count, size_t offset);
// Matches Android's Java API. Note, return (size_t)-1 for AT to
// signal non-break because unsigned return type.
static size_t getTextRunCursor(const float* advances, const uint16_t* buf, size_t start,
- size_t count, size_t offset, MoveOpt opt);
+ size_t count, size_t offset, MoveOpt opt);
};
} // namespace minikin
diff --git a/include/minikin/Hyphenator.h b/include/minikin/Hyphenator.h
index c403850..d3386d1 100644
--- a/include/minikin/Hyphenator.h
+++ b/include/minikin/Hyphenator.h
@@ -72,28 +72,28 @@
enum class EndHyphenEdit : uint8_t {
// Note that everything inserting characters must have a value greater than or equal to
// INSERT_HYPHEN.
- NO_EDIT = 0b000,
- REPLACE_WITH_HYPHEN = 0b001,
+ NO_EDIT = 0b000,
+ REPLACE_WITH_HYPHEN = 0b001,
- INSERT_HYPHEN = 0b010,
+ INSERT_HYPHEN = 0b010,
INSERT_ARMENIAN_HYPHEN = 0b011,
- INSERT_MAQAF = 0b100,
- INSERT_UCAS_HYPHEN = 0b101,
- INSERT_ZWJ_AND_HYPHEN = 0b110,
+ INSERT_MAQAF = 0b100,
+ INSERT_UCAS_HYPHEN = 0b101,
+ INSERT_ZWJ_AND_HYPHEN = 0b110,
};
enum class StartHyphenEdit : uint8_t {
- NO_EDIT = 0b00,
+ NO_EDIT = 0b00,
INSERT_HYPHEN = 0b01,
- INSERT_ZWJ = 0b10,
+ INSERT_ZWJ = 0b10,
};
typedef uint8_t HyphenEdit;
constexpr uint8_t START_BITS_SHIFT = 3;
// The following two masks must keep in sync with the definitions in the Java code at:
// frameworks/base/graphics/java/android/graphics/Paint.java
-constexpr uint8_t MASK_END_OF_LINE = 0b00111;
+constexpr uint8_t MASK_END_OF_LINE = 0b00111;
constexpr uint8_t MASK_START_OF_LINE = 0b11000;
inline HyphenEdit packHyphenEdit(StartHyphenEdit start, EndHyphenEdit end) {
@@ -120,7 +120,10 @@
return static_cast<uint8_t>(hyph) >= static_cast<uint8_t>(EndHyphenEdit::INSERT_HYPHEN);
}
-template<typename T, size_t size> constexpr size_t ARRAYSIZE(T const (&)[size]) { return size; }
+template <typename T, size_t size>
+constexpr size_t ARRAYSIZE(T const (&)[size]) {
+ return size;
+}
constexpr uint32_t HYPHEN_STR_ZWJ[] = {CHAR_ZWJ};
constexpr uint32_t HYPHEN_STR_HYPHEN[] = {CHAR_HYPHEN};
constexpr uint32_t HYPHEN_STR_ARMENIAN_HYPHEN[] = {CHAR_ARMENIAN_HYPHEN};
@@ -189,7 +192,8 @@
// until this instance is deleted.
// Note: nullptr is valid input, in which case the hyphenator only processes soft hyphens.
static Hyphenator* loadBinary(const uint8_t* patternData, size_t minPrefix, size_t minSuffix,
- const std::string& locale);
+ const std::string& locale);
+
private:
enum class HyphenationLocale : uint8_t {
OTHER = 0,
@@ -200,7 +204,7 @@
// Use Hyphenator::loadBinary instead.
Hyphenator(const uint8_t* patternData, size_t minPrefix, size_t minSuffix,
- HyphenationLocale hyphenLocale);
+ HyphenationLocale hyphenLocale);
// apply various hyphenation rules including hard and soft hyphens, ignoring patterns
void hyphenateWithNoPatterns(HyphenationType* result, const uint16_t* word, size_t len) const;
@@ -213,7 +217,7 @@
// calculate hyphenation from patterns, assuming alphabet lookup has already been done
void hyphenateFromCodes(HyphenationType* result, const uint16_t* codes, size_t len,
- HyphenationType hyphenValue) const;
+ HyphenationType hyphenValue) const;
// See also LONGEST_HYPHENATED_WORD in LineBreaker.cpp. Here the constant is used so
// that temporary buffers can be stack-allocated without waste, which is a slightly
@@ -225,12 +229,9 @@
const HyphenationLocale mHyphenationLocale;
// accessors for binary data
- const Header* getHeader() const {
- return reinterpret_cast<const Header*>(mPatternData);
- }
-
+ const Header* getHeader() const { return reinterpret_cast<const Header*>(mPatternData); }
};
} // namespace minikin
-#endif // MINIKIN_HYPHENATOR_H
+#endif // MINIKIN_HYPHENATOR_H
diff --git a/include/minikin/Layout.h b/include/minikin/Layout.h
index b074462..2310bb7 100644
--- a/include/minikin/Layout.h
+++ b/include/minikin/Layout.h
@@ -50,25 +50,34 @@
// Must be the same value with Paint.java
enum class Bidi : uint8_t {
- LTR = 0b0000, // Must be same with Paint.BIDI_LTR
- RTL = 0b0001, // Must be same with Paint.BIDI_RTL
+ LTR = 0b0000, // Must be same with Paint.BIDI_LTR
+ RTL = 0b0001, // Must be same with Paint.BIDI_RTL
DEFAULT_LTR = 0b0010, // Must be same with Paint.BIDI_DEFAULT_LTR
DEFAULT_RTL = 0b0011, // Must be same with Paint.BIDI_DEFAULT_RTL
- FORCE_LTR = 0b0100, // Must be same with Paint.BIDI_FORCE_LTR
- FORCE_RTL = 0b0101, // Must be same with Paint.BIDI_FORCE_RTL
+ FORCE_LTR = 0b0100, // Must be same with Paint.BIDI_FORCE_LTR
+ FORCE_RTL = 0b0101, // Must be same with Paint.BIDI_FORCE_RTL
};
-inline bool isRtl(Bidi bidi) { return static_cast<uint8_t>(bidi) & 0b0001; }
-inline bool isOverride(Bidi bidi) { return static_cast<uint8_t>(bidi) & 0b0100; }
+inline bool isRtl(Bidi bidi) {
+ return static_cast<uint8_t>(bidi) & 0b0001;
+}
+inline bool isOverride(Bidi bidi) {
+ return static_cast<uint8_t>(bidi) & 0b0100;
+}
// Lifecycle and threading assumptions for Layout:
// The object is assumed to be owned by a single thread; multiple threads
// may not mutate it at the same time.
class Layout {
public:
-
- Layout() : mGlyphs(), mAdvances(), mExtents(), mClusterBounds(), mFaces(), mAdvance(0),
- mBounds() {
+ Layout()
+ : mGlyphs(),
+ mAdvances(),
+ mExtents(),
+ mClusterBounds(),
+ mFaces(),
+ mAdvance(0),
+ mBounds() {
mBounds.setEmpty();
}
@@ -80,44 +89,51 @@
void dump() const;
- void doLayout(const uint16_t* buf, size_t start, size_t count, size_t bufSize,
- Bidi bidiFlags, const MinikinPaint& paint,
- const std::shared_ptr<FontCollection>& collection);
+ void doLayout(const uint16_t* buf, size_t start, size_t count, size_t bufSize, Bidi bidiFlags,
+ const MinikinPaint& paint, const std::shared_ptr<FontCollection>& collection);
inline void doLayout(const U16StringPiece& str, const Range& range, Bidi bidiFlags,
- const MinikinPaint& paint, const std::shared_ptr<FontCollection>& collection) {
+ const MinikinPaint& paint,
+ const std::shared_ptr<FontCollection>& collection) {
doLayout(str.data(), range.getStart(), range.getLength(), str.size(), bidiFlags, paint,
collection);
}
static float measureText(const uint16_t* buf, size_t start, size_t count, size_t bufSize,
- Bidi bidiFlags, const MinikinPaint &paint, StartHyphenEdit startHyphen,
- EndHyphenEdit endHyphen, const std::shared_ptr<FontCollection>& collection,
- float* advances, MinikinExtent* extents, LayoutOverhang* overhangs);
+ Bidi bidiFlags, const MinikinPaint& paint, StartHyphenEdit startHyphen,
+ EndHyphenEdit endHyphen,
+ const std::shared_ptr<FontCollection>& collection, float* advances,
+ MinikinExtent* extents, LayoutOverhang* overhangs);
static inline float measureText(const uint16_t* buf, size_t start, size_t count, size_t bufSize,
- Bidi bidiFlags, const MinikinPaint &paint,
- const std::shared_ptr<FontCollection>& collection, float* advances,
- MinikinExtent* extents, LayoutOverhang* overhangs) {
+ Bidi bidiFlags, const MinikinPaint& paint,
+ const std::shared_ptr<FontCollection>& collection,
+ float* advances, MinikinExtent* extents,
+ LayoutOverhang* overhangs) {
return measureText(buf, start, count, bufSize, bidiFlags, paint,
- startHyphenEdit(paint.hyphenEdit), endHyphenEdit(paint.hyphenEdit), collection,
- advances, extents, overhangs);
+ startHyphenEdit(paint.hyphenEdit), endHyphenEdit(paint.hyphenEdit),
+ collection, advances, extents, overhangs);
}
static inline float measureText(const U16StringPiece& str, const Range& range, Bidi bidiFlags,
- const MinikinPaint &paint, StartHyphenEdit startHyphen, EndHyphenEdit endHyphen,
- const std::shared_ptr<FontCollection>& collection, float* advances,
- MinikinExtent* extents, LayoutOverhang* overhangs) {
+ const MinikinPaint& paint, StartHyphenEdit startHyphen,
+ EndHyphenEdit endHyphen,
+ const std::shared_ptr<FontCollection>& collection,
+ float* advances, MinikinExtent* extents,
+ LayoutOverhang* overhangs) {
return measureText(str.data(), range.getStart(), range.getLength(), str.length(), bidiFlags,
- paint, startHyphen, endHyphen, collection, advances, extents, overhangs);
+ paint, startHyphen, endHyphen, collection, advances, extents, overhangs);
}
static inline float measureText(const U16StringPiece& str, const Range& range, Bidi bidiFlags,
- const MinikinPaint &paint, const std::shared_ptr<FontCollection>& collection,
- float* advances, MinikinExtent* extents, LayoutOverhang* overhangs) {
+ const MinikinPaint& paint,
+ const std::shared_ptr<FontCollection>& collection,
+ float* advances, MinikinExtent* extents,
+ LayoutOverhang* overhangs) {
return measureText(str.data(), range.getStart(), range.getLength(), str.length(), bidiFlags,
- paint, startHyphenEdit(paint.hyphenEdit), endHyphenEdit(paint.hyphenEdit),
- collection, advances, extents, overhangs);
+ paint, startHyphenEdit(paint.hyphenEdit),
+ endHyphenEdit(paint.hyphenEdit), collection, advances, extents,
+ overhangs);
}
// public accessors
@@ -168,22 +184,23 @@
// When layout is not null, layout info will be stored in the object.
// When advances is not null, measurement results will be stored in the array.
static float doLayoutRunCached(const uint16_t* buf, size_t runStart, size_t runLength,
- size_t bufSize, bool isRtl, LayoutContext* ctx, size_t dstStart,
- StartHyphenEdit startHyphen, EndHyphenEdit endHyphen,
- const std::shared_ptr<FontCollection>& collection, Layout* layout, float* advances,
- MinikinExtent* extents, LayoutOverhang* overhangs);
+ size_t bufSize, bool isRtl, LayoutContext* ctx, size_t dstStart,
+ StartHyphenEdit startHyphen, EndHyphenEdit endHyphen,
+ const std::shared_ptr<FontCollection>& collection,
+ Layout* layout, float* advances, MinikinExtent* extents,
+ LayoutOverhang* overhangs);
// Lay out a single word
static float doLayoutWord(const uint16_t* buf, size_t start, size_t count, size_t bufSize,
- bool isRtl, LayoutContext* ctx, size_t bufStart,
- StartHyphenEdit startHyphen, EndHyphenEdit endHyphen,
- const std::shared_ptr<FontCollection>& collection, Layout* layout, float* advances,
- MinikinExtent* extents, LayoutOverhang* overhangs);
+ bool isRtl, LayoutContext* ctx, size_t bufStart,
+ StartHyphenEdit startHyphen, EndHyphenEdit endHyphen,
+ const std::shared_ptr<FontCollection>& collection, Layout* layout,
+ float* advances, MinikinExtent* extents, LayoutOverhang* overhangs);
// Lay out a single bidi run
- void doLayoutRun(const uint16_t* buf, size_t start, size_t count, size_t bufSize,
- bool isRtl, LayoutContext* ctx, StartHyphenEdit startHyphen, EndHyphenEdit endHyphen,
- const std::shared_ptr<FontCollection>& collection);
+ void doLayoutRun(const uint16_t* buf, size_t start, size_t count, size_t bufSize, bool isRtl,
+ LayoutContext* ctx, StartHyphenEdit startHyphen, EndHyphenEdit endHyphen,
+ const std::shared_ptr<FontCollection>& collection);
// Append another layout (for example, cached value) into this one
void appendLayout(Layout* src, size_t start, float extraAdvance);
@@ -194,8 +211,9 @@
// input text.
std::vector<float> mAdvances;
std::vector<MinikinExtent> mExtents;
- std::vector<MinikinRect> mClusterBounds; // per-cluster bounds, without a shift based on
- // previously-shaped text. Used to calculate overhangs.
+ std::vector<MinikinRect>
+ mClusterBounds; // per-cluster bounds, without a shift based on
+ // previously-shaped text. Used to calculate overhangs.
std::vector<FakedFont> mFaces;
float mAdvance;
diff --git a/include/minikin/LineBreaker.h b/include/minikin/LineBreaker.h
index 2f839da..10b737a 100644
--- a/include/minikin/LineBreaker.h
+++ b/include/minikin/LineBreaker.h
@@ -50,80 +50,81 @@
class WordBreaker;
class Run {
- public:
- Run(const Range& range) : mRange(range) {}
- virtual ~Run() {}
+public:
+ Run(const Range& range) : mRange(range) {}
+ virtual ~Run() {}
- // Returns true if this run is RTL. Otherwise returns false.
- virtual bool isRtl() const = 0;
+ // Returns true if this run is RTL. Otherwise returns false.
+ virtual bool isRtl() const = 0;
- // Returns true if this run is a target of hyphenation. Otherwise return false.
- virtual bool canHyphenate() const = 0;
+ // Returns true if this run is a target of hyphenation. Otherwise return false.
+ virtual bool canHyphenate() const = 0;
- // Returns the locale list ID for this run.
- virtual uint32_t getLocaleListId() const = 0;
+ // Returns the locale list ID for this run.
+ virtual uint32_t getLocaleListId() const = 0;
- // Fills the each character's advances, extents and overhangs.
- virtual void getMetrics(const U16StringPiece& text, float* advances, MinikinExtent* extents,
- LayoutOverhang* overhangs) const = 0;
+ // Fills the each character's advances, extents and overhangs.
+ virtual void getMetrics(const U16StringPiece& text, float* advances, MinikinExtent* extents,
+ LayoutOverhang* overhangs) const = 0;
- // Following two methods are only called when the implementation returns true for
- // canHyphenate method.
+ // Following two methods are only called when the implementation returns true for
+ // canHyphenate method.
- // Returns the paint pointer used for this run. Do not return null if you returns true for
- // canHyphenate method.
- virtual const MinikinPaint* getPaint() const { return nullptr; }
+ // Returns the paint pointer used for this run. Do not return null if you returns true for
+ // canHyphenate method.
+ virtual const MinikinPaint* getPaint() const { return nullptr; }
- // Measure the hyphenation piece and fills the each character's advances and overhangs.
- virtual float measureHyphenPiece(const U16StringPiece&, const Range&, StartHyphenEdit,
- EndHyphenEdit, float*, LayoutOverhang*) const {
- return 0.0;
- }
+ // Measure the hyphenation piece and fills the each character's advances and overhangs.
+ virtual float measureHyphenPiece(const U16StringPiece&, const Range&, StartHyphenEdit,
+ EndHyphenEdit, float*, LayoutOverhang*) const {
+ return 0.0;
+ }
- inline const Range& getRange() const { return mRange; }
+ inline const Range& getRange() const { return mRange; }
- protected:
- const Range mRange;
+protected:
+ const Range mRange;
};
class TabStops {
- public:
- // Caller must free stops. stops can be nullprt.
- TabStops(const int32_t* stops, size_t nStops, int32_t tabWidth)
- : mStops(stops), mStopsSize(nStops), mTabWidth(tabWidth) { }
+public:
+ // Caller must free stops. stops can be nullprt.
+ TabStops(const int32_t* stops, size_t nStops, int32_t tabWidth)
+ : mStops(stops), mStopsSize(nStops), mTabWidth(tabWidth) {}
- float nextTab(float widthSoFar) const {
- for (size_t i = 0; i < mStopsSize; i++) {
- if (mStops[i] > widthSoFar) {
- return mStops[i];
- }
+ float nextTab(float widthSoFar) const {
+ for (size_t i = 0; i < mStopsSize; i++) {
+ if (mStops[i] > widthSoFar) {
+ return mStops[i];
}
- return floor(widthSoFar / mTabWidth + 1) * mTabWidth;
}
- private:
- const int32_t* mStops;
- size_t mStopsSize;
- int32_t mTabWidth;
+ return floor(widthSoFar / mTabWidth + 1) * mTabWidth;
+ }
+
+private:
+ const int32_t* mStops;
+ size_t mStopsSize;
+ int32_t mTabWidth;
};
// Implement this for the additional information during line breaking.
// The functions in this class's interface may be called several times. The implementation
// must return the same value for the same input.
class LineWidth {
- public:
- virtual ~LineWidth() {}
+public:
+ virtual ~LineWidth() {}
- // Called to find out the width for the line.
- virtual float getAt(size_t lineNo) const = 0;
+ // Called to find out the width for the line.
+ virtual float getAt(size_t lineNo) const = 0;
- // Called to find out the minimum line width.
- virtual float getMin() const = 0;
+ // Called to find out the minimum line width.
+ virtual float getMin() const = 0;
- // Called to find out the available left-side padding for the line.
- virtual float getLeftPaddingAt(size_t lineNo) const = 0;
+ // Called to find out the available left-side padding for the line.
+ virtual float getLeftPaddingAt(size_t lineNo) const = 0;
- // Called to find out the available right-side padding for the line.
- virtual float getRightPaddingAt(size_t lineNo) const = 0;
+ // Called to find out the available right-side padding for the line.
+ virtual float getRightPaddingAt(size_t lineNo) const = 0;
};
class MeasuredText {
@@ -141,6 +142,7 @@
MeasuredText& operator=(MeasuredText&&) = default;
PREVENT_COPY_AND_ASSIGN(MeasuredText);
+
private:
// Use generate method instead.
MeasuredText(uint32_t size) : widths(size), extents(size), overhangs(size) {}
@@ -165,184 +167,180 @@
};
class LineBreaker {
- public:
- LineBreaker(const U16StringPiece& textBuffer, const MeasuredText& measuredText,
- BreakStrategy strategy, HyphenationFrequency frequency, bool justified);
+public:
+ LineBreaker(const U16StringPiece& textBuffer, const MeasuredText& measuredText,
+ BreakStrategy strategy, HyphenationFrequency frequency, bool justified);
- virtual ~LineBreaker();
+ virtual ~LineBreaker();
- const static int kTab_Shift = 29; // keep synchronized with TAB_MASK in StaticLayout.java
+ const static int kTab_Shift = 29; // keep synchronized with TAB_MASK in StaticLayout.java
- LineBreakResult computeBreaks(const std::vector<std::unique_ptr<Run>>& runs,
- const LineWidth& lineWidth, const TabStops& tabStops);
+ LineBreakResult computeBreaks(const std::vector<std::unique_ptr<Run>>& runs,
+ const LineWidth& lineWidth, const TabStops& tabStops);
- protected:
- // For testing purposes.
- LineBreaker(std::unique_ptr<WordBreaker>&& breaker, const U16StringPiece& textBuffer,
- const MeasuredText& measuredText, BreakStrategy strategy,
- HyphenationFrequency frequency, bool justified);
+protected:
+ // For testing purposes.
+ LineBreaker(std::unique_ptr<WordBreaker>&& breaker, const U16StringPiece& textBuffer,
+ const MeasuredText& measuredText, BreakStrategy strategy,
+ HyphenationFrequency frequency, bool justified);
- private:
- // ParaWidth is used to hold cumulative width from beginning of paragraph. Note that for
- // very large paragraphs, accuracy could degrade using only 32-bit float. Note however
- // that float is used extensively on the Java side for this. This is a typedef so that
- // we can easily change it based on performance/accuracy tradeoff.
- typedef double ParaWidth;
+private:
+ // ParaWidth is used to hold cumulative width from beginning of paragraph. Note that for
+ // very large paragraphs, accuracy could degrade using only 32-bit float. Note however
+ // that float is used extensively on the Java side for this. This is a typedef so that
+ // we can easily change it based on performance/accuracy tradeoff.
+ typedef double ParaWidth;
- // A single candidate break
- struct Candidate {
- size_t offset; // offset to text buffer, in code units
+ // A single candidate break
+ struct Candidate {
+ size_t offset; // offset to text buffer, in code units
- ParaWidth preBreak; // width of text until this point, if we decide to not break here:
- // preBreak is used as an optimized way to calculate the width
- // between two candidates. The line width between two line break
- // candidates i and j is calculated as postBreak(j) - preBreak(i).
- ParaWidth postBreak; // width of text until this point, if we decide to break here
+ ParaWidth preBreak; // width of text until this point, if we decide to not break here:
+ // preBreak is used as an optimized way to calculate the width
+ // between two candidates. The line width between two line break
+ // candidates i and j is calculated as postBreak(j) - preBreak(i).
+ ParaWidth postBreak; // width of text until this point, if we decide to break here
- float firstOverhang; // amount of overhang needed on the end of the line if we decide
- // to break here
- float secondOverhang; // amount of overhang needed on the beginning of the next line
- // if we decide to break here
+ float firstOverhang; // amount of overhang needed on the end of the line if we decide
+ // to break here
+ float secondOverhang; // amount of overhang needed on the beginning of the next line
+ // if we decide to break here
- float penalty; // penalty of this break (for example, hyphen penalty)
- size_t preSpaceCount; // preceding space count before breaking
- size_t postSpaceCount; // preceding space count after breaking
- HyphenationType hyphenType;
- bool isRtl; // The direction of the bidi run containing or ending in this candidate
- };
+ float penalty; // penalty of this break (for example, hyphen penalty)
+ size_t preSpaceCount; // preceding space count before breaking
+ size_t postSpaceCount; // preceding space count after breaking
+ HyphenationType hyphenType;
+ bool isRtl; // The direction of the bidi run containing or ending in this candidate
+ };
- void addRun(const Run& run, const LineWidth& lineWidth, const TabStops& tabStops);
+ void addRun(const Run& run, const LineWidth& lineWidth, const TabStops& tabStops);
- void setLocaleList(uint32_t localeListId, size_t restartFrom);
- // A locale list ID and locale ID currently used for word iterator and hyphenator.
- uint32_t mCurrentLocaleListId;
- uint64_t mCurrentLocaleId = 0;
+ void setLocaleList(uint32_t localeListId, size_t restartFrom);
+ // A locale list ID and locale ID currently used for word iterator and hyphenator.
+ uint32_t mCurrentLocaleListId;
+ uint64_t mCurrentLocaleId = 0;
- // Hyphenates a string potentially containing non-breaking spaces.
- std::vector<HyphenationType> hyphenate(const U16StringPiece& string);
+ // Hyphenates a string potentially containing non-breaking spaces.
+ std::vector<HyphenationType> hyphenate(const U16StringPiece& string);
- void addHyphenationCandidates(const Run& run,
- const Range& contextRange,
- const Range& wordRange, ParaWidth lastBreakWidth,
- ParaWidth PostBreak, size_t postSpaceCount,
- float hyphenPenalty);
+ void addHyphenationCandidates(const Run& run, const Range& contextRange, const Range& wordRange,
+ ParaWidth lastBreakWidth, ParaWidth PostBreak,
+ size_t postSpaceCount, float hyphenPenalty);
- void addWordBreak(size_t offset, ParaWidth preBreak, ParaWidth postBreak,
- float firstOverhang, float secondOverhang,
- size_t preSpaceCount, size_t postSpaceCount,
- float penalty, HyphenationType hyph, bool isRtl);
+ void addWordBreak(size_t offset, ParaWidth preBreak, ParaWidth postBreak, float firstOverhang,
+ float secondOverhang, size_t preSpaceCount, size_t postSpaceCount,
+ float penalty, HyphenationType hyph, bool isRtl);
- void adjustSecondOverhang(float secondOverhang);
+ void adjustSecondOverhang(float secondOverhang);
- std::unique_ptr<WordBreaker> mWordBreaker;
- U16StringPiece mTextBuf;
- const MeasuredText& mMeasuredText;
+ std::unique_ptr<WordBreaker> mWordBreaker;
+ U16StringPiece mTextBuf;
+ const MeasuredText& mMeasuredText;
- const Hyphenator* mHyphenator;
+ const Hyphenator* mHyphenator;
- // layout parameters
- BreakStrategy mStrategy;
- HyphenationFrequency mHyphenationFrequency;
- bool mJustified;
+ // layout parameters
+ BreakStrategy mStrategy;
+ HyphenationFrequency mHyphenationFrequency;
+ bool mJustified;
- // result of line breaking
- std::vector<int> mBreaks;
- std::vector<float> mWidths;
- std::vector<float> mAscents;
- std::vector<float> mDescents;
- std::vector<int> mFlags;
+ // result of line breaking
+ std::vector<int> mBreaks;
+ std::vector<float> mWidths;
+ std::vector<float> mAscents;
+ std::vector<float> mDescents;
+ std::vector<int> mFlags;
- void clearResults() {
- mBreaks.clear();
- mWidths.clear();
- mAscents.clear();
- mDescents.clear();
- mFlags.clear();
- }
+ void clearResults() {
+ mBreaks.clear();
+ mWidths.clear();
+ mAscents.clear();
+ mDescents.clear();
+ mFlags.clear();
+ }
- ParaWidth mWidth = 0; // Total width of text seen, assuming no line breaks
- std::vector<Candidate> mCandidates; // All line breaking candidates
+ ParaWidth mWidth = 0; // Total width of text seen, assuming no line breaks
+ std::vector<Candidate> mCandidates; // All line breaking candidates
- static LayoutOverhang computeOverhang(float totalAdvance,
- const std::vector<float>& advances, const std::vector<LayoutOverhang>& overhangs,
- bool isRtl);
+ static LayoutOverhang computeOverhang(float totalAdvance, const std::vector<float>& advances,
+ const std::vector<LayoutOverhang>& overhangs, bool isRtl);
- MinikinExtent computeMaxExtent(size_t start, size_t end) const;
+ MinikinExtent computeMaxExtent(size_t start, size_t end) const;
- //
- // Types, methods, and fields related to the greedy algorithm
- //
+ //
+ // Types, methods, and fields related to the greedy algorithm
+ //
- void computeBreaksGreedy(const LineWidth& lineWidth);
+ void computeBreaksGreedy(const LineWidth& lineWidth);
- // This method is called as a helper to computeBreaksGreedy(), but also when we encounter a
- // tab character, which forces the line breaking algorithm to greedy mode. It computes all
- // the greedy line breaks based on available candidates and returns the preBreak of the last
- // break which would then be used to calculate the width of the tab.
- ParaWidth computeBreaksGreedyPartial(const LineWidth& lineWidth);
+ // This method is called as a helper to computeBreaksGreedy(), but also when we encounter a
+ // tab character, which forces the line breaking algorithm to greedy mode. It computes all
+ // the greedy line breaks based on available candidates and returns the preBreak of the last
+ // break which would then be used to calculate the width of the tab.
+ ParaWidth computeBreaksGreedyPartial(const LineWidth& lineWidth);
- // Called by computerBreaksGreedyPartial() on all candidates to determine if the line should
- // be broken at the candidate
- void considerGreedyBreakCandidate(size_t candIndex, const LineWidth& lineWidth);
+ // Called by computerBreaksGreedyPartial() on all candidates to determine if the line should
+ // be broken at the candidate
+ void considerGreedyBreakCandidate(size_t candIndex, const LineWidth& lineWidth);
- // Adds a greedy break to list of line breaks.
- void addGreedyBreak(size_t breakIndex);
+ // Adds a greedy break to list of line breaks.
+ void addGreedyBreak(size_t breakIndex);
- // Push an actual break to the output. Takes care of setting flags for tab, etc.
- void pushBreak(int offset, float width, MinikinExtent extent, HyphenEdit hyphenEdit);
+ // Push an actual break to the output. Takes care of setting flags for tab, etc.
+ void pushBreak(int offset, float width, MinikinExtent extent, HyphenEdit hyphenEdit);
- void addDesperateBreaksGreedy(ParaWidth existingPreBreak, size_t start, size_t end,
- const LineWidth& lineWidth);
+ void addDesperateBreaksGreedy(ParaWidth existingPreBreak, size_t start, size_t end,
+ const LineWidth& lineWidth);
- bool fitsOnCurrentLine(float width, float leftOverhang, float rightOverhang,
- const LineWidth& lineWidth) const;
+ bool fitsOnCurrentLine(float width, float leftOverhang, float rightOverhang,
+ const LineWidth& lineWidth) const;
- struct GreedyBreak {
- size_t index;
- float penalty;
- };
- // This will hold a list of greedy breaks, with strictly increasing indices and penalties.
- // The top of the list always holds the best break.
- std::deque<GreedyBreak> mBestGreedyBreaks;
- // Return the best greedy break from the top of the queue.
- size_t popBestGreedyBreak();
- // Insert a greedy break in mBestGreedyBreaks.
- void insertGreedyBreakCandidate(size_t index, float penalty);
+ struct GreedyBreak {
+ size_t index;
+ float penalty;
+ };
+ // This will hold a list of greedy breaks, with strictly increasing indices and penalties.
+ // The top of the list always holds the best break.
+ std::deque<GreedyBreak> mBestGreedyBreaks;
+ // Return the best greedy break from the top of the queue.
+ size_t popBestGreedyBreak();
+ // Insert a greedy break in mBestGreedyBreaks.
+ void insertGreedyBreakCandidate(size_t index, float penalty);
- // The following are state for greedy breaker. They get updated during calculation of
- // greedy breaks (including when a partial greedy algorithm is run when adding style runs
- // containing tabs).
- size_t mLastGreedyBreakIndex; // The last greedy break index of mCandidates.
- const Candidate& getLastBreakCandidate() const;
- size_t mLastConsideredGreedyCandidate; // The index of the last candidate considered
- int mFirstTabIndex; // The index of the first tab character seen in current line
+ // The following are state for greedy breaker. They get updated during calculation of
+ // greedy breaks (including when a partial greedy algorithm is run when adding style runs
+ // containing tabs).
+ size_t mLastGreedyBreakIndex; // The last greedy break index of mCandidates.
+ const Candidate& getLastBreakCandidate() const;
+ size_t mLastConsideredGreedyCandidate; // The index of the last candidate considered
+ int mFirstTabIndex; // The index of the first tab character seen in current line
- // Used to hold a desperate break as the last greedy break
- Candidate mFakeDesperateCandidate;
+ // Used to hold a desperate break as the last greedy break
+ Candidate mFakeDesperateCandidate;
- //
- // Types, methods, and fields related to the optimal algorithm
- //
+ //
+ // Types, methods, and fields related to the optimal algorithm
+ //
- void computeBreaksOptimal(const LineWidth& lineWidth);
+ void computeBreaksOptimal(const LineWidth& lineWidth);
- void addDesperateBreaksOptimal(std::vector<Candidate>* out, ParaWidth existingPreBreak,
- size_t postSpaceCount, bool isRtl, size_t start, size_t end);
+ void addDesperateBreaksOptimal(std::vector<Candidate>* out, ParaWidth existingPreBreak,
+ size_t postSpaceCount, bool isRtl, size_t start, size_t end);
- void addAllDesperateBreaksOptimal(const LineWidth& lineWidth);
+ void addAllDesperateBreaksOptimal(const LineWidth& lineWidth);
- // Data used to compute optimal line breaks
- struct OptimalBreaksData {
- float score; // best score found for this break
- size_t prev; // index to previous break
- size_t lineNumber; // the computed line number of the candidate
- };
- void finishBreaksOptimal(const std::vector<OptimalBreaksData>& breaksData);
+ // Data used to compute optimal line breaks
+ struct OptimalBreaksData {
+ float score; // best score found for this break
+ size_t prev; // index to previous break
+ size_t lineNumber; // the computed line number of the candidate
+ };
+ void finishBreaksOptimal(const std::vector<OptimalBreaksData>& breaksData);
- float getSpaceWidth() const;
+ float getSpaceWidth() const;
- float mLinePenalty = 0.0f;
- size_t mSpaceCount; // Number of word spaces seen in the input text
+ float mLinePenalty = 0.0f;
+ size_t mSpaceCount; // Number of word spaces seen in the input text
};
} // namespace minikin
diff --git a/include/minikin/Macros.h b/include/minikin/Macros.h
index ba08864..08eea3c 100644
--- a/include/minikin/Macros.h
+++ b/include/minikin/Macros.h
@@ -16,8 +16,8 @@
#ifndef MINIKIN_MACROS_H
#define MINIKIN_MACROS_H
-#define PREVENT_COPY_AND_ASSIGN(Type) \
- Type(const Type&) = delete; \
+#define PREVENT_COPY_AND_ASSIGN(Type) \
+ Type(const Type&) = delete; \
Type& operator=(const Type&) = delete
#endif // MINIKIN_MACROS_H
diff --git a/include/minikin/Measurement.h b/include/minikin/Measurement.h
index c767b62..55c8474 100644
--- a/include/minikin/Measurement.h
+++ b/include/minikin/Measurement.h
@@ -22,10 +22,10 @@
namespace minikin {
float getRunAdvance(const float* advances, const uint16_t* buf, size_t start, size_t count,
- size_t offset);
+ size_t offset);
size_t getOffsetForAdvance(const float* advances, const uint16_t* buf, size_t start, size_t count,
- float advance);
+ float advance);
} // namespace minikin
diff --git a/include/minikin/MinikinFont.h b/include/minikin/MinikinFont.h
index a9337db..e4f5737 100644
--- a/include/minikin/MinikinFont.h
+++ b/include/minikin/MinikinFont.h
@@ -32,13 +32,19 @@
// Possibly move into own .h file?
// Note: if you add a field here, either add it to LayoutCacheKey or to skipCache()
struct MinikinPaint {
- MinikinPaint() : size(0), scaleX(0), skewX(0), letterSpacing(0), wordSpacing(0),
- paintFlags(0), localeListId(0), familyVariant(FontFamily::Variant::DEFAULT),
- hyphenEdit(), fontFeatureSettings() { }
+ MinikinPaint()
+ : size(0),
+ scaleX(0),
+ skewX(0),
+ letterSpacing(0),
+ wordSpacing(0),
+ paintFlags(0),
+ localeListId(0),
+ familyVariant(FontFamily::Variant::DEFAULT),
+ hyphenEdit(),
+ fontFeatureSettings() {}
- bool skipCache() const {
- return !fontFeatureSettings.empty();
- }
+ bool skipCache() const { return !fontFeatureSettings.empty(); }
float size;
float scaleX;
@@ -52,9 +58,7 @@
HyphenEdit hyphenEdit;
std::string fontFeatureSettings;
- void copyFrom(const MinikinPaint& paint) {
- *this = paint;
- }
+ void copyFrom(const MinikinPaint& paint) { *this = paint; }
MinikinPaint(MinikinPaint&&) = default;
MinikinPaint& operator=(MinikinPaint&&) = default;
@@ -76,9 +80,7 @@
float mTop = 0.0;
float mRight = 0.0;
float mBottom = 0.0;
- bool isEmpty() const {
- return mLeft == mRight || mTop == mBottom;
- }
+ bool isEmpty() const { return mLeft == mRight || mTop == mBottom; }
void set(const MinikinRect& r) {
mLeft = r.mLeft;
mTop = r.mTop;
@@ -91,21 +93,17 @@
mRight += dx;
mBottom += dy;
}
- void setEmpty() {
- mLeft = mTop = mRight = mBottom = 0.0;
- }
+ void setEmpty() { mLeft = mTop = mRight = mBottom = 0.0; }
void join(const MinikinRect& r);
};
// For holding vertical extents.
struct MinikinExtent {
- float ascent = 0.0; // negative
- float descent = 0.0; // positive
- float line_gap = 0.0; // positive
+ float ascent = 0.0; // negative
+ float descent = 0.0; // positive
+ float line_gap = 0.0; // positive
- void reset() {
- ascent = descent = line_gap = 0.0;
- }
+ void reset() { ascent = descent = line_gap = 0.0; }
void extendBy(const MinikinExtent& e) {
ascent = std::min(ascent, e.ascent);
@@ -115,7 +113,7 @@
};
// Callback for freeing data
-typedef void (*MinikinDestroyFunc) (void* data);
+typedef void (*MinikinDestroyFunc)(void* data);
class MinikinFont {
public:
@@ -123,34 +121,24 @@
virtual ~MinikinFont();
- virtual float GetHorizontalAdvance(uint32_t glyph_id,
- const MinikinPaint& paint,
+ virtual float GetHorizontalAdvance(uint32_t glyph_id, const MinikinPaint& paint,
const FontFakery& fakery) const = 0;
- virtual void GetBounds(MinikinRect* bounds,
- uint32_t glyph_id,
- const MinikinPaint &paint,
+ virtual void GetBounds(MinikinRect* bounds, uint32_t glyph_id, const MinikinPaint& paint,
const FontFakery& fakery) const = 0;
- virtual void GetFontExtent(MinikinExtent* extent,
- const MinikinPaint& paint,
+ virtual void GetFontExtent(MinikinExtent* extent, const MinikinPaint& paint,
const FontFakery& fakery) const = 0;
// Override if font can provide access to raw data
- virtual const void* GetFontData() const {
- return nullptr;
- }
+ virtual const void* GetFontData() const { return nullptr; }
// Override if font can provide access to raw data
- virtual size_t GetFontSize() const {
- return 0;
- }
+ virtual size_t GetFontSize() const { return 0; }
// Override if font can provide access to raw data.
// Returns index within OpenType collection
- virtual int GetFontIndex() const {
- return 0;
- }
+ virtual int GetFontIndex() const { return 0; }
virtual const std::vector<minikin::FontVariation>& GetAxes() const = 0;
@@ -160,11 +148,11 @@
}
static uint32_t MakeTag(char c1, char c2, char c3, char c4) {
- return ((uint32_t)c1 << 24) | ((uint32_t)c2 << 16) |
- ((uint32_t)c3 << 8) | (uint32_t)c4;
+ return ((uint32_t)c1 << 24) | ((uint32_t)c2 << 16) | ((uint32_t)c3 << 8) | (uint32_t)c4;
}
int32_t GetUniqueId() const { return mUniqueId; }
+
private:
const int32_t mUniqueId;
};
diff --git a/include/minikin/Range.h b/include/minikin/Range.h
index 4cb01be..43fb2f7 100644
--- a/include/minikin/Range.h
+++ b/include/minikin/Range.h
@@ -28,10 +28,10 @@
Range(const Range&) = default;
Range& operator=(const Range&) = default;
- inline uint32_t getStart() const { return mStart; } // inclusive
+ inline uint32_t getStart() const { return mStart; } // inclusive
inline void setStart(uint32_t start) { mStart = start; } // inclusive
- inline uint32_t getEnd() const { return mEnd; } // exclusive
+ inline uint32_t getEnd() const { return mEnd; } // exclusive
inline void setEnd(uint32_t end) { mEnd = end; } // exclusive
inline uint32_t getLength() const { return mEnd - mStart; }
@@ -56,9 +56,7 @@
// range.contains(0); // false
// range.contains(1); // true
// range.contains(2); // false
- inline bool contains(uint32_t pos) const {
- return mStart <= pos && pos < mEnd;
- }
+ inline bool contains(uint32_t pos) const { return mStart <= pos && pos < mEnd; }
private:
// Helper class for "for (uint32_t i : range)" style for-loop.
@@ -68,7 +66,10 @@
inline bool operator!=(const RangeIterator& o) const { return o.mPos != mPos; }
inline uint32_t operator*() const { return mPos; }
- inline RangeIterator& operator++() { mPos++; return *this; }
+ inline RangeIterator& operator++() {
+ mPos++;
+ return *this;
+ }
private:
uint32_t mPos;
diff --git a/include/minikin/SparseBitSet.h b/include/minikin/SparseBitSet.h
index d4f64ac..9ccef12 100644
--- a/include/minikin/SparseBitSet.h
+++ b/include/minikin/SparseBitSet.h
@@ -48,15 +48,13 @@
// Determine whether the value is included in the set
bool get(uint32_t ch) const {
if (ch >= mMaxVal) return false;
- const uint32_t *bitmap = &mBitmaps[mIndices[ch >> kLogValuesPerPage]];
+ const uint32_t* bitmap = &mBitmaps[mIndices[ch >> kLogValuesPerPage]];
uint32_t index = ch & kPageMask;
return (bitmap[index >> kLogBitsPerEl] & (kElFirst >> (index & kElMask))) != 0;
}
// One more than the maximum value in the set, or zero if empty
- uint32_t length() const {
- return mMaxVal;
- }
+ uint32_t length() const { return mMaxVal; }
// The next set bit starting at fromIndex, inclusive, or kNotFound
// if none exists.
@@ -95,4 +93,4 @@
} // namespace minikin
-#endif // MINIKIN_SPARSE_BIT_SET_H
+#endif // MINIKIN_SPARSE_BIT_SET_H
diff --git a/libs/minikin/CmapCoverage.cpp b/libs/minikin/CmapCoverage.cpp
index 1281543..ff7fa14 100644
--- a/libs/minikin/CmapCoverage.cpp
+++ b/libs/minikin/CmapCoverage.cpp
@@ -22,6 +22,7 @@
#include <vector>
#include "minikin/SparseBitSet.h"
+
#include "MinikinInternal.h"
namespace minikin {
@@ -35,17 +36,17 @@
static uint32_t readU24(const uint8_t* data, size_t offset) {
return ((uint32_t)data[offset]) << 16 | ((uint32_t)data[offset + 1]) << 8 |
- ((uint32_t)data[offset + 2]);
+ ((uint32_t)data[offset + 2]);
}
static uint32_t readU32(const uint8_t* data, size_t offset) {
return ((uint32_t)data[offset]) << 24 | ((uint32_t)data[offset + 1]) << 16 |
- ((uint32_t)data[offset + 2]) << 8 | ((uint32_t)data[offset + 3]);
+ ((uint32_t)data[offset + 2]) << 8 | ((uint32_t)data[offset + 3]);
}
// The start must be larger than or equal to coverage.back() if coverage is not empty.
// Returns true if the range is appended. Otherwise returns false as an error.
-static bool addRange(std::vector<uint32_t> &coverage, uint32_t start, uint32_t end) {
+static bool addRange(std::vector<uint32_t>& coverage, uint32_t start, uint32_t end) {
if (coverage.empty() || coverage.back() < start) {
coverage.push_back(start);
coverage.push_back(end);
@@ -64,37 +65,33 @@
struct Range {
uint32_t start; // inclusive
- uint32_t end; // exclusive
+ uint32_t end; // exclusive
- static Range InvalidRange() {
- return Range({ U32MAX, U32MAX });
- }
+ static Range InvalidRange() { return Range({U32MAX, U32MAX}); }
- inline bool isValid() const {
- return start != U32MAX && end != U32MAX;
- }
+ inline bool isValid() const { return start != U32MAX && end != U32MAX; }
// Returns true if left and right intersect.
inline static bool intersects(const Range& left, const Range& right) {
- return left.isValid() && right.isValid() &&
- left.start < right.end && right.start < left.end;
+ return left.isValid() && right.isValid() && left.start < right.end &&
+ right.start < left.end;
}
// Returns merged range. This method assumes left and right are not invalid ranges and they have
// an intersection.
static Range merge(const Range& left, const Range& right) {
- return Range({ std::min(left.start, right.start), std::max(left.end, right.end) });
+ return Range({std::min(left.start, right.start), std::max(left.end, right.end)});
}
};
// Returns Range from given ranges vector. Returns InvalidRange if i is out of range.
static inline Range getRange(const std::vector<uint32_t>& r, size_t i) {
- return i + 1 < r.size() ? Range({ r[i], r[i + 1] }) : Range::InvalidRange();
+ return i + 1 < r.size() ? Range({r[i], r[i + 1]}) : Range::InvalidRange();
}
// Merge two sorted lists of ranges into one sorted list.
-static std::vector<uint32_t> mergeRanges(
- const std::vector<uint32_t>& lRanges, const std::vector<uint32_t>& rRanges) {
+static std::vector<uint32_t> mergeRanges(const std::vector<uint32_t>& lRanges,
+ const std::vector<uint32_t>& rRanges) {
std::vector<uint32_t> out;
const size_t lsize = lRanges.size();
@@ -194,8 +191,8 @@
}
} else {
for (uint32_t j = start; j < end + 1; j++) {
- uint32_t actualRangeOffset = kHeaderSize + 6 * segCount + rangeOffset +
- (i + j - start) * 2;
+ uint32_t actualRangeOffset =
+ kHeaderSize + 6 * segCount + rangeOffset + (i + j - start) * 2;
if (actualRangeOffset + 2 > size) {
// invalid rangeOffset is considered a "warning" by OpenType Sanitizer
continue;
@@ -294,8 +291,8 @@
// function assumes code points in both default UVS Table and non-default UVS table are stored in
// ascending order. This is required by the standard.
static bool getVSCoverage(std::vector<uint32_t>* out_ranges, const uint8_t* data, size_t size,
- uint32_t defaultUVSTableOffset, uint32_t nonDefaultUVSTableOffset,
- const SparseBitSet& baseCoverage) {
+ uint32_t defaultUVSTableOffset, uint32_t nonDefaultUVSTableOffset,
+ const SparseBitSet& baseCoverage) {
// Need to merge supported ranges from default UVS Table and non-default UVS Table.
// First, collect all supported code points from non default UVS table.
std::vector<uint32_t> rangesFromNonDefaultUVSTable;
@@ -367,7 +364,8 @@
}
static void getCoverageFormat14(std::vector<std::unique_ptr<SparseBitSet>>* out,
- const uint8_t* data, size_t size, const SparseBitSet& baseCoverage) {
+ const uint8_t* data, size_t size,
+ const SparseBitSet& baseCoverage) {
constexpr size_t kHeaderSize = 10;
constexpr size_t kRecordSize = 11;
constexpr size_t kLengthOffset = 2;
@@ -404,7 +402,7 @@
}
std::vector<uint32_t> ranges;
if (!getVSCoverage(&ranges, data, length, defaultUVSOffset, nonDefaultUVSOffset,
- baseCoverage)) {
+ baseCoverage)) {
continue;
}
if (out->size() < vsIndex + 1) {
@@ -417,7 +415,7 @@
}
SparseBitSet CmapCoverage::getCoverage(const uint8_t* cmap_data, size_t cmap_size,
- std::vector<std::unique_ptr<SparseBitSet>>* out) {
+ std::vector<std::unique_ptr<SparseBitSet>>* out) {
constexpr size_t kHeaderSize = 4;
constexpr size_t kNumTablesOffset = 2;
constexpr size_t kTableSize = 8;
diff --git a/libs/minikin/Emoji.cpp b/libs/minikin/Emoji.cpp
index 312806a..baf15a2 100644
--- a/libs/minikin/Emoji.cpp
+++ b/libs/minikin/Emoji.cpp
@@ -26,14 +26,9 @@
// Optimization for characters outside the new emoji range.
return false;
}
- return (0x1F6F7 <= c && c <= 0x1F6F8)
- || c == 0x1F91F
- || (0x1F928 <= c && c <= 0x1F92F)
- || (0x1F931 <= c && c <= 0x1F932)
- || c == 0x1F94C
- || (0x1F95F <= c && c <= 0x1F96B)
- || (0x1F992 <= c && c <= 0x1F997)
- || (0x1F9D0 <= c && c <= 0x1F9E6);
+ return (0x1F6F7 <= c && c <= 0x1F6F8) || c == 0x1F91F || (0x1F928 <= c && c <= 0x1F92F) ||
+ (0x1F931 <= c && c <= 0x1F932) || c == 0x1F94C || (0x1F95F <= c && c <= 0x1F96B) ||
+ (0x1F992 <= c && c <= 0x1F997) || (0x1F9D0 <= c && c <= 0x1F9E6);
}
bool isEmoji(uint32_t c) {
@@ -56,9 +51,7 @@
// Emoji Modifier Base characters new in Unicode emoji 5.0.
// From http://www.unicode.org/Public/emoji/5.0/emoji-data.txt
// TODO: Remove once emoji-data.text 5.0 is in ICU or update to 6.0.
- if (c == 0x1F91F
- || (0x1F931 <= c && c <= 0x1F932)
- || (0x1F9D1 <= c && c <= 0x1F9DD)) {
+ if (c == 0x1F91F || (0x1F931 <= c && c <= 0x1F932) || (0x1F9D1 <= c && c <= 0x1F9DD)) {
return true;
}
return u_hasBinaryProperty(c, UCHAR_EMOJI_MODIFIER_BASE);
@@ -74,4 +67,3 @@
}
} // namespace minikin
-
diff --git a/libs/minikin/FontCollection.cpp b/libs/minikin/FontCollection.cpp
index 107a9ad..d9b200a 100644
--- a/libs/minikin/FontCollection.cpp
+++ b/libs/minikin/FontCollection.cpp
@@ -25,6 +25,7 @@
#include <unicode/unorm2.h>
#include "minikin/Emoji.h"
+
#include "Locale.h"
#include "LocaleListCache.h"
#include "MinikinInternal.h"
@@ -35,7 +36,7 @@
template <typename T>
static inline T max(T a, T b) {
- return a>b ? a : b;
+ return a > b ? a : b;
}
const uint32_t EMOJI_STYLE_VS = 0xFE0F;
@@ -49,8 +50,7 @@
init(typefaces);
}
-FontCollection::FontCollection(const vector<std::shared_ptr<FontFamily>>& typefaces) :
- mMaxChar(0) {
+FontCollection::FontCollection(const vector<std::shared_ptr<FontFamily>>& typefaces) : mMaxChar(0) {
init(typefaces);
}
@@ -77,10 +77,8 @@
mSupportedAxes.insert(supportedAxes.begin(), supportedAxes.end());
}
nTypefaces = mFamilies.size();
- MINIKIN_ASSERT(nTypefaces > 0,
- "Font collection must have at least one valid typeface");
- MINIKIN_ASSERT(nTypefaces <= 254,
- "Font collection may only have up to 254 font families.");
+ MINIKIN_ASSERT(nTypefaces > 0, "Font collection must have at least one valid typeface");
+ MINIKIN_ASSERT(nTypefaces <= 254, "Font collection may only have up to 254 font families.");
size_t nPages = (mMaxChar + kPageMask) >> kLogCharsPerPage;
// TODO: Use variation selector map for mRanges construction.
// A font can have a glyph for a base code point and variation selector pair but no glyph for
@@ -103,7 +101,7 @@
}
// See the comment in Range for more details.
LOG_ALWAYS_FATAL_IF(mFamilyVec.size() >= 0xFFFF,
- "Exceeded the maximum indexable cmap coverage.");
+ "Exceeded the maximum indexable cmap coverage.");
}
// Special scores for the font fallback.
@@ -127,8 +125,8 @@
// - kFirstFontScore: When the font is the first font family in the collection and it supports the
// given character or variation sequence.
uint32_t FontCollection::calcFamilyScore(uint32_t ch, uint32_t vs, FontFamily::Variant variant,
- uint32_t localeListId, const std::shared_ptr<FontFamily>& fontFamily) const {
-
+ uint32_t localeListId,
+ const std::shared_ptr<FontFamily>& fontFamily) const {
const uint32_t coverageScore = calcCoverageScore(ch, vs, fontFamily);
if (coverageScore == kFirstFontScore || coverageScore == kUnsupportedFontScore) {
// No need to calculate other scores.
@@ -155,7 +153,7 @@
// - Returns 1 if the variation selector is not specified or if the font family only supports the
// variation sequence's base character.
uint32_t FontCollection::calcCoverageScore(uint32_t ch, uint32_t vs,
- const std::shared_ptr<FontFamily>& fontFamily) const {
+ const std::shared_ptr<FontFamily>& fontFamily) const {
const bool hasVSGlyph = (vs != 0) && fontFamily->hasGlyph(ch, vs);
if (!hasVSGlyph && !fontFamily->getCoverage().get(ch)) {
// The font doesn't support either variation sequence or even the base character.
@@ -214,7 +212,7 @@
// Here, m is the maximum number of locales to be compared, and s(i) is the i-th locale's matching
// score. The possible values of s(i) are 0, 1, 2, 3 and 4.
uint32_t FontCollection::calcLocaleMatchingScore(uint32_t userLocaleListId,
- const FontFamily& fontFamily) {
+ const FontFamily& fontFamily) {
const LocaleList& localeList = LocaleListCache::getById(userLocaleListId);
const LocaleList& fontLocaleList = LocaleListCache::getById(fontFamily.localeListId());
@@ -250,8 +248,8 @@
// 2. Calculate a score for the font family. See comments in calcFamilyScore for the detail.
// 3. Highest score wins, with ties resolved to the first font.
// This method never returns nullptr.
-const std::shared_ptr<FontFamily>& FontCollection::getFamilyForChar(uint32_t ch, uint32_t vs,
- uint32_t localeListId, FontFamily::Variant variant) const {
+const std::shared_ptr<FontFamily>& FontCollection::getFamilyForChar(
+ uint32_t ch, uint32_t vs, uint32_t localeListId, FontFamily::Variant variant) const {
if (ch >= mMaxChar) {
return mFamilies[0];
}
@@ -259,7 +257,7 @@
Range range = mRanges[ch >> kLogCharsPerPage];
if (vs != 0) {
- range = { 0, static_cast<uint16_t>(mFamilies.size()) };
+ range = {0, static_cast<uint16_t>(mFamilies.size())};
}
int bestFamilyIndex = -1;
@@ -300,35 +298,29 @@
// properly by Minikin or HarfBuzz even if the font does not explicitly support them and it's
// usually meaningless to switch to a different font to display them.
static bool doesNotNeedFontSupport(uint32_t c) {
- return c == 0x000A // LINE FEED
- || c == 0x000D // CARRIAGE RETURN
- || c == 0x00AD // SOFT HYPHEN
- || c == 0x034F // COMBINING GRAPHEME JOINER
- || c == 0x061C // ARABIC LETTER MARK
- || (0x200C <= c && c <= 0x200F) // ZERO WIDTH NON-JOINER..RIGHT-TO-LEFT MARK
- || (0x202A <= c && c <= 0x202E) // LEFT-TO-RIGHT EMBEDDING..RIGHT-TO-LEFT OVERRIDE
- || (0x2066 <= c && c <= 0x2069) // LEFT-TO-RIGHT ISOLATE..POP DIRECTIONAL ISOLATE
- || c == 0xFEFF // BYTE ORDER MARK
- || isVariationSelector(c);
+ return c == 0x000A // LINE FEED
+ || c == 0x000D // CARRIAGE RETURN
+ || c == 0x00AD // SOFT HYPHEN
+ || c == 0x034F // COMBINING GRAPHEME JOINER
+ || c == 0x061C // ARABIC LETTER MARK
+ || (0x200C <= c && c <= 0x200F) // ZERO WIDTH NON-JOINER..RIGHT-TO-LEFT MARK
+ || (0x202A <= c && c <= 0x202E) // LEFT-TO-RIGHT EMBEDDING..RIGHT-TO-LEFT OVERRIDE
+ || (0x2066 <= c && c <= 0x2069) // LEFT-TO-RIGHT ISOLATE..POP DIRECTIONAL ISOLATE
+ || c == 0xFEFF // BYTE ORDER MARK
+ || isVariationSelector(c);
}
// Characters where we want to continue using existing font run instead of
// recomputing the best match in the fallback list.
static const uint32_t stickyWhitelist[] = {
- '!',
- ',',
- '-',
- '.',
- ':',
- ';',
- '?',
- 0x00A0, // NBSP
- 0x2010, // HYPHEN
- 0x2011, // NB_HYPHEN
- 0x202F, // NNBSP
- 0x2640, // FEMALE_SIGN,
- 0x2642, // MALE_SIGN,
- 0x2695, // STAFF_OF_AESCULAPIUS
+ '!', ',', '-', '.', ':', ';', '?',
+ 0x00A0, // NBSP
+ 0x2010, // HYPHEN
+ 0x2011, // NB_HYPHEN
+ 0x202F, // NNBSP
+ 0x2640, // FEMALE_SIGN,
+ 0x2642, // MALE_SIGN,
+ 0x2695, // STAFF_OF_AESCULAPIUS
};
static bool isStickyWhitelisted(uint32_t c) {
@@ -343,7 +335,7 @@
}
bool FontCollection::hasVariationSelector(uint32_t baseCodepoint,
- uint32_t variationSelector) const {
+ uint32_t variationSelector) const {
if (!isVariationSelector(variationSelector)) {
return false;
}
@@ -379,8 +371,8 @@
constexpr uint32_t REPLACEMENT_CHARACTER = 0xFFFD;
-void FontCollection::itemize(const uint16_t *string, size_t string_size, const MinikinPaint& paint,
- vector<Run>* result) const {
+void FontCollection::itemize(const uint16_t* string, size_t string_size, const MinikinPaint& paint,
+ vector<Run>* result) const {
const FontFamily::Variant familyVariant = paint.familyVariant;
const FontStyle style = paint.fontStyle;
const uint32_t localeListId = paint.localeListId;
@@ -436,8 +428,8 @@
// character to the new run. U+20E3 COMBINING ENCLOSING KEYCAP, used in emoji, is
// handled properly by this since it's a combining mark too.
if (utf16Pos != 0 &&
- (isCombining(ch) || (isEmojiModifier(ch) && isEmojiBase(prevCh))) &&
- family != nullptr && family->getCoverage().get(prevCh)) {
+ (isCombining(ch) || (isEmojiModifier(ch) && isEmojiBase(prevCh))) &&
+ family != nullptr && family->getCoverage().get(prevCh)) {
const size_t prevChLength = U16_LENGTH(prevCh);
if (run != nullptr) {
run->end -= prevChLength;
@@ -494,7 +486,7 @@
return nullptr;
}
- std::vector<std::shared_ptr<FontFamily> > families;
+ std::vector<std::shared_ptr<FontFamily>> families;
for (const std::shared_ptr<FontFamily>& family : mFamilies) {
std::shared_ptr<FontFamily> newFamily = family->createFamilyWithVariation(variations);
if (newFamily) {
diff --git a/libs/minikin/FontFamily.cpp b/libs/minikin/FontFamily.cpp
index 9a8179e..b500fdb 100644
--- a/libs/minikin/FontFamily.cpp
+++ b/libs/minikin/FontFamily.cpp
@@ -26,6 +26,7 @@
#include "minikin/CmapCoverage.h"
#include "minikin/MinikinFont.h"
+
#include "FontUtils.h"
#include "Locale.h"
#include "LocaleListCache.h"
@@ -34,12 +35,10 @@
namespace minikin {
Font::Font(const std::shared_ptr<MinikinFont>& typeface, FontStyle style)
- : typeface(typeface), style(style) {
-}
+ : typeface(typeface), style(style) {}
Font::Font(std::shared_ptr<MinikinFont>&& typeface, FontStyle style)
- : typeface(typeface), style(style) {
-}
+ : typeface(typeface), style(style) {}
std::unordered_set<AxisTag> Font::getSupportedAxesLocked() const {
const uint32_t fvarTag = MinikinFont::MakeTag('f', 'v', 'a', 'r');
@@ -66,20 +65,18 @@
// static
FontFamily::FontFamily(std::vector<Font>&& fonts)
- : FontFamily(Variant::DEFAULT, std::move(fonts)) {
-}
+ : FontFamily(Variant::DEFAULT, std::move(fonts)) {}
FontFamily::FontFamily(Variant variant, std::vector<Font>&& fonts)
- : FontFamily(LocaleListCache::kEmptyListId, variant, std::move(fonts)) {
-}
+ : FontFamily(LocaleListCache::kEmptyListId, variant, std::move(fonts)) {}
FontFamily::FontFamily(uint32_t localeListId, Variant variant, std::vector<Font>&& fonts)
- : mLocaleListId(localeListId), mVariant(variant), mFonts(std::move(fonts)) {
+ : mLocaleListId(localeListId), mVariant(variant), mFonts(std::move(fonts)) {
computeCoverage();
}
bool FontFamily::analyzeStyle(const std::shared_ptr<MinikinFont>& typeface, int* weight,
- bool* italic) {
+ bool* italic) {
android::AutoMutex _l(gMinikinLock);
const uint32_t os2Tag = MinikinFont::MakeTag('O', 'S', '/', '2');
HbBlob os2Table(getFontTable(typeface.get(), os2Tag));
@@ -103,7 +100,7 @@
// select fake bold.
bool isFakeBold = wanted.weight() >= 600 && (wanted.weight() - actual.weight()) >= 200;
bool isFakeItalic = wanted.slant() == FontStyle::Slant::ITALIC &&
- actual.slant() == FontStyle::Slant::UPRIGHT;
+ actual.slant() == FontStyle::Slant::UPRIGHT;
return FontFakery(isFakeBold, isFakeItalic);
}
@@ -119,9 +116,9 @@
}
}
if (bestFont != nullptr) {
- return FakedFont{ bestFont->typeface.get(), computeFakery(style, bestFont->style) };
+ return FakedFont{bestFont->typeface.get(), computeFakery(style, bestFont->style)};
}
- return FakedFont{ nullptr, FontFakery() };
+ return FakedFont{nullptr, FontFakery()};
}
bool FontFamily::isColorEmojiFamily() const {
diff --git a/libs/minikin/FontUtils.cpp b/libs/minikin/FontUtils.cpp
index f891a76..0d4c6d2 100644
--- a/libs/minikin/FontUtils.cpp
+++ b/libs/minikin/FontUtils.cpp
@@ -26,7 +26,7 @@
static uint32_t readU32(const uint8_t* data, size_t offset) {
return ((uint32_t)data[offset]) << 24 | ((uint32_t)data[offset + 1]) << 16 |
- ((uint32_t)data[offset + 2]) << 8 | ((uint32_t)data[offset + 3]);
+ ((uint32_t)data[offset + 2]) << 8 | ((uint32_t)data[offset + 3]);
}
bool analyzeStyle(const uint8_t* os2_data, size_t os2_size, int* weight, bool* italic) {
diff --git a/libs/minikin/GraphemeBreak.cpp b/libs/minikin/GraphemeBreak.cpp
index c4ac7c4..7d06d8f 100644
--- a/libs/minikin/GraphemeBreak.cpp
+++ b/libs/minikin/GraphemeBreak.cpp
@@ -29,17 +29,17 @@
int32_t tailoredGraphemeClusterBreak(uint32_t c) {
// Characters defined as Control that we want to treat them as Extend.
// These are curated manually.
- if (c == 0x00AD // SHY
- || c == 0x061C // ALM
- || c == 0x180E // MONGOLIAN VOWEL SEPARATOR
- || c == 0x200B // ZWSP
- || c == 0x200E // LRM
- || c == 0x200F // RLM
- || (0x202A <= c && c <= 0x202E) // LRE, RLE, PDF, LRO, RLO
- || ((c | 0xF) == 0x206F) // WJ, invisible math operators, LRI, RLI, FSI, PDI,
- // and the deprecated invisible format controls
- || c == 0xFEFF // BOM
- || ((c | 0x7F) == 0xE007F)) // recently undeprecated tag characters in Plane 14
+ if (c == 0x00AD // SHY
+ || c == 0x061C // ALM
+ || c == 0x180E // MONGOLIAN VOWEL SEPARATOR
+ || c == 0x200B // ZWSP
+ || c == 0x200E // LRM
+ || c == 0x200F // RLM
+ || (0x202A <= c && c <= 0x202E) // LRE, RLE, PDF, LRO, RLO
+ || ((c | 0xF) == 0x206F) // WJ, invisible math operators, LRI, RLI, FSI, PDI,
+ // and the deprecated invisible format controls
+ || c == 0xFEFF // BOM
+ || ((c | 0x7F) == 0xE007F)) // recently undeprecated tag characters in Plane 14
return U_GCB_EXTEND;
// THAI CHARACTER SARA AM is treated as a normal letter by most other implementations: they
// allow a grapheme break before it.
@@ -52,13 +52,14 @@
// Returns true for all characters whose IndicSyllabicCategory is Pure_Killer.
// From http://www.unicode.org/Public/9.0.0/ucd/IndicSyllabicCategory.txt
bool isPureKiller(uint32_t c) {
- return (c == 0x0E3A || c == 0x0E4E || c == 0x0F84 || c == 0x103A || c == 0x1714 || c == 0x1734
- || c == 0x17D1 || c == 0x1BAA || c == 0x1BF2 || c == 0x1BF3 || c == 0xA806
- || c == 0xA953 || c == 0xABED || c == 0x11134 || c == 0x112EA || c == 0x1172B);
+ return (c == 0x0E3A || c == 0x0E4E || c == 0x0F84 || c == 0x103A || c == 0x1714 ||
+ c == 0x1734 || c == 0x17D1 || c == 0x1BAA || c == 0x1BF2 || c == 0x1BF3 ||
+ c == 0xA806 || c == 0xA953 || c == 0xABED || c == 0x11134 || c == 0x112EA ||
+ c == 0x1172B);
}
bool GraphemeBreak::isGraphemeBreak(const float* advances, const uint16_t* buf, size_t start,
- size_t count, const size_t offset) {
+ size_t count, const size_t offset) {
// This implementation closely follows Unicode Standard Annex #29 on
// Unicode Text Segmentation (http://www.unicode.org/reports/tr29/),
// implementing a tailored version of extended grapheme clusters.
@@ -195,8 +196,8 @@
// disallow grapheme breaks (if we are here, we don't know about advances, or we already know
// that c2 has no advance).
if (u_getIntPropertyValue(c1, UCHAR_CANONICAL_COMBINING_CLASS) == 9 // virama
- && !isPureKiller(c1)
- && u_getIntPropertyValue(c2, UCHAR_GENERAL_CATEGORY) == U_OTHER_LETTER) {
+ && !isPureKiller(c1) &&
+ u_getIntPropertyValue(c2, UCHAR_GENERAL_CATEGORY) == U_OTHER_LETTER) {
return false;
}
// Rule GB999, Any ÷ Any
@@ -204,33 +205,33 @@
}
size_t GraphemeBreak::getTextRunCursor(const float* advances, const uint16_t* buf, size_t start,
- size_t count, size_t offset, MoveOpt opt) {
+ size_t count, size_t offset, MoveOpt opt) {
switch (opt) {
- case AFTER:
- if (offset < start + count) {
- offset++;
- }
+ case AFTER:
+ if (offset < start + count) {
+ offset++;
+ }
// fall through
- case AT_OR_AFTER:
- while (!isGraphemeBreak(advances, buf, start, count, offset)) {
- offset++;
- }
- break;
- case BEFORE:
- if (offset > start) {
- offset--;
- }
+ case AT_OR_AFTER:
+ while (!isGraphemeBreak(advances, buf, start, count, offset)) {
+ offset++;
+ }
+ break;
+ case BEFORE:
+ if (offset > start) {
+ offset--;
+ }
// fall through
- case AT_OR_BEFORE:
- while (!isGraphemeBreak(advances, buf, start, count, offset)) {
- offset--;
- }
- break;
- case AT:
- if (!isGraphemeBreak(advances, buf, start, count, offset)) {
- offset = (size_t)-1;
- }
- break;
+ case AT_OR_BEFORE:
+ while (!isGraphemeBreak(advances, buf, start, count, offset)) {
+ offset--;
+ }
+ break;
+ case AT:
+ if (!isGraphemeBreak(advances, buf, start, count, offset)) {
+ offset = (size_t)-1;
+ }
+ break;
}
return offset;
}
diff --git a/libs/minikin/HbFontCache.cpp b/libs/minikin/HbFontCache.cpp
index 6117292..6c10b2f 100644
--- a/libs/minikin/HbFontCache.cpp
+++ b/libs/minikin/HbFontCache.cpp
@@ -21,36 +21,25 @@
#include <utils/LruCache.h>
#include "minikin/MinikinFont.h"
+
#include "MinikinInternal.h"
namespace minikin {
class HbFontCache : private android::OnEntryRemoved<int32_t, hb_font_t*> {
public:
- HbFontCache() : mCache(kMaxEntries) {
- mCache.setOnEntryRemovedListener(this);
- }
+ HbFontCache() : mCache(kMaxEntries) { mCache.setOnEntryRemovedListener(this); }
// callback for OnEntryRemoved
- void operator()(int32_t& /* key */, hb_font_t*& value) {
- hb_font_destroy(value);
- }
+ void operator()(int32_t& /* key */, hb_font_t*& value) { hb_font_destroy(value); }
- hb_font_t* get(int32_t fontId) {
- return mCache.get(fontId);
- }
+ hb_font_t* get(int32_t fontId) { return mCache.get(fontId); }
- void put(int32_t fontId, hb_font_t* font) {
- mCache.put(fontId, font);
- }
+ void put(int32_t fontId, hb_font_t* font) { mCache.put(fontId, font); }
- void clear() {
- mCache.clear();
- }
+ void clear() { mCache.clear(); }
- void remove(int32_t fontId) {
- mCache.remove(fontId);
- }
+ void remove(int32_t fontId) { mCache.remove(fontId); }
private:
static const size_t kMaxEntries = 100;
@@ -102,7 +91,7 @@
const void* buf = minikinFont->GetFontData();
size_t size = minikinFont->GetFontSize();
hb_blob_t* blob = hb_blob_create(reinterpret_cast<const char*>(buf), size,
- HB_MEMORY_MODE_READONLY, nullptr, nullptr);
+ HB_MEMORY_MODE_READONLY, nullptr, nullptr);
face = hb_face_create(blob, minikinFont->GetFontIndex());
hb_blob_destroy(blob);
diff --git a/libs/minikin/Hyphenator.cpp b/libs/minikin/Hyphenator.cpp
index 3fe3b19..393e609 100644
--- a/libs/minikin/Hyphenator.cpp
+++ b/libs/minikin/Hyphenator.cpp
@@ -40,7 +40,7 @@
struct AlphabetTable1 {
uint32_t version;
uint32_t n_entries;
- uint32_t data[1]; // actually flexible array, size is known at runtime
+ uint32_t data[1]; // actually flexible array, size is known at runtime
static uint32_t codepoint(uint32_t entry) { return entry >> 11; }
static uint32_t value(uint32_t entry) { return entry & 0x7ff; }
@@ -90,9 +90,7 @@
const AlphabetTable1* alphabetTable1() const {
return reinterpret_cast<const AlphabetTable1*>(bytes() + alphabet_offset);
}
- const Trie* trieTable() const {
- return reinterpret_cast<const Trie*>(bytes() + trie_offset);
- }
+ const Trie* trieTable() const { return reinterpret_cast<const Trie*>(bytes() + trie_offset); }
const Pattern* patternTable() const {
return reinterpret_cast<const Pattern*>(bytes() + pattern_offset);
}
@@ -100,7 +98,7 @@
// static
Hyphenator* Hyphenator::loadBinary(const uint8_t* patternData, size_t minPrefix, size_t minSuffix,
- const std::string& locale) {
+ const std::string& locale) {
HyphenationLocale hyphenLocale = HyphenationLocale::OTHER;
if (locale == "pl") {
hyphenLocale = HyphenationLocale::POLISH;
@@ -113,18 +111,19 @@
}
Hyphenator::Hyphenator(const uint8_t* patternData, size_t minPrefix, size_t minSuffix,
- HyphenationLocale hyphenLocale)
- : mPatternData(patternData), mMinPrefix(minPrefix), mMinSuffix(minSuffix),
- mHyphenationLocale(hyphenLocale) {
-}
+ HyphenationLocale hyphenLocale)
+ : mPatternData(patternData),
+ mMinPrefix(minPrefix),
+ mMinSuffix(minSuffix),
+ mHyphenationLocale(hyphenLocale) {}
void Hyphenator::hyphenate(std::vector<HyphenationType>* result, const uint16_t* word,
- size_t len) const {
+ size_t len) const {
result->clear();
result->resize(len);
const size_t paddedLen = len + 2; // start and stop code each count for 1
- if (mPatternData != nullptr &&
- len >= mMinPrefix + mMinSuffix && paddedLen <= MAX_HYPHENATED_SIZE) {
+ if (mPatternData != nullptr && len >= mMinPrefix + mMinSuffix &&
+ paddedLen <= MAX_HYPHENATED_SIZE) {
uint16_t alpha_codes[MAX_HYPHENATED_SIZE];
const HyphenationType hyphenValue = alphabetLookup(alpha_codes, word, len);
if (hyphenValue != HyphenationType::DONT_BREAK) {
@@ -147,15 +146,15 @@
// inspecting all the characters that have the Unicode line breaking
// property of BA or HY and seeing which ones are hyphens.
bool Hyphenator::isLineBreakingHyphen(uint32_t c) {
- return (c == 0x002D || // HYPHEN-MINUS
- c == 0x058A || // ARMENIAN HYPHEN
- c == 0x05BE || // HEBREW PUNCTUATION MAQAF
- c == 0x1400 || // CANADIAN SYLLABICS HYPHEN
- c == 0x2010 || // HYPHEN
- c == 0x2013 || // EN DASH
- c == 0x2027 || // HYPHENATION POINT
- c == 0x2E17 || // DOUBLE OBLIQUE HYPHEN
- c == 0x2E40); // DOUBLE HYPHEN
+ return (c == 0x002D || // HYPHEN-MINUS
+ c == 0x058A || // ARMENIAN HYPHEN
+ c == 0x05BE || // HEBREW PUNCTUATION MAQAF
+ c == 0x1400 || // CANADIAN SYLLABICS HYPHEN
+ c == 0x2010 || // HYPHEN
+ c == 0x2013 || // EN DASH
+ c == 0x2027 || // HYPHENATION POINT
+ c == 0x2E17 || // DOUBLE OBLIQUE HYPHEN
+ c == 0x2E40); // DOUBLE HYPHEN
}
EndHyphenEdit editForThisLine(HyphenationType type) {
@@ -206,10 +205,8 @@
// for now to be safe. BREAK_AND_INSERT_MAQAF is already implemented, so if we want to switch
// to maqaf for Hebrew, we can simply add a condition here.
const UScriptCode script = getScript(codePoint);
- if (script == USCRIPT_KANNADA
- || script == USCRIPT_MALAYALAM
- || script == USCRIPT_TAMIL
- || script == USCRIPT_TELUGU) {
+ if (script == USCRIPT_KANNADA || script == USCRIPT_MALAYALAM || script == USCRIPT_TAMIL ||
+ script == USCRIPT_TELUGU) {
// Grantha is not included, since we don't support non-BMP hyphenation yet.
return HyphenationType::BREAK_AND_DONT_INSERT_HYPHEN;
} else if (script == USCRIPT_ARMENIAN) {
@@ -228,7 +225,7 @@
// Assumption for caller: location must be >= 2 and word[location] == CHAR_SOFT_HYPHEN.
// This function decides if the letters before and after the hyphen should appear as joining.
static inline HyphenationType getHyphTypeForArabic(const uint16_t* word, size_t len,
- size_t location) {
+ size_t location) {
ssize_t i = location;
int32_t type = U_JT_NON_JOINING;
while (static_cast<size_t>(i) < len && (type = getJoiningType(word[i])) == U_JT_TRANSPARENT) {
@@ -237,7 +234,7 @@
if (type == U_JT_DUAL_JOINING || type == U_JT_RIGHT_JOINING || type == U_JT_JOIN_CAUSING) {
// The next character is of the type that may join the last character. See if the last
// character is also of the right type.
- i = location - 2; // Skip the soft hyphen
+ i = location - 2; // Skip the soft hyphen
type = U_JT_NON_JOINING;
while (i >= 0 && (type = getJoiningType(word[i])) == U_JT_TRANSPARENT) {
i--;
@@ -253,17 +250,17 @@
// that didn't match patterns, especially words that contain hyphens or soft hyphens (See sections
// 5.3, Use of Hyphen, and 5.4, Use of Soft Hyphen).
void Hyphenator::hyphenateWithNoPatterns(HyphenationType* result, const uint16_t* word,
- size_t len) const {
+ size_t len) const {
result[0] = HyphenationType::DONT_BREAK;
for (size_t i = 1; i < len; i++) {
const uint16_t prevChar = word[i - 1];
if (i > 1 && isLineBreakingHyphen(prevChar)) {
// Break after hyphens, but only if they don't start the word.
- if ((prevChar == CHAR_HYPHEN_MINUS || prevChar == CHAR_HYPHEN)
- && (mHyphenationLocale == HyphenationLocale::POLISH
- || mHyphenationLocale == HyphenationLocale::SLOVENIAN)
- && getScript(word[i]) == USCRIPT_LATIN) {
+ if ((prevChar == CHAR_HYPHEN_MINUS || prevChar == CHAR_HYPHEN) &&
+ (mHyphenationLocale == HyphenationLocale::POLISH ||
+ mHyphenationLocale == HyphenationLocale::SLOVENIAN) &&
+ getScript(word[i]) == USCRIPT_LATIN) {
// In Polish and Slovenian, hyphens get repeated at the next line. To be safe,
// we will do this only if the next character is Latin.
result[i] = HyphenationType::BREAK_AND_INSERT_HYPHEN_AT_NEXT_LINE;
@@ -281,22 +278,21 @@
} else {
result[i] = hyphenationTypeBasedOnScript(word[i]);
}
- } else if (prevChar == CHAR_MIDDLE_DOT
- && mMinPrefix < i && i <= len - mMinSuffix
- && ((word[i - 2] == 'l' && word[i] == 'l')
- || (word[i - 2] == 'L' && word[i] == 'L'))
- && mHyphenationLocale == HyphenationLocale::CATALAN) {
+ } else if (prevChar == CHAR_MIDDLE_DOT && mMinPrefix < i && i <= len - mMinSuffix &&
+ ((word[i - 2] == 'l' && word[i] == 'l') ||
+ (word[i - 2] == 'L' && word[i] == 'L')) &&
+ mHyphenationLocale == HyphenationLocale::CATALAN) {
// In Catalan, "l·l" should break as "l-" on the first line
// and "l" on the next line.
result[i] = HyphenationType::BREAK_AND_REPLACE_WITH_HYPHEN;
} else {
result[i] = HyphenationType::DONT_BREAK;
}
- }
+ }
}
HyphenationType Hyphenator::alphabetLookup(uint16_t* alpha_codes, const uint16_t* word,
- size_t len) const {
+ size_t len) const {
const Header* header = getHeader();
HyphenationType result = HyphenationType::BREAK_AND_INSERT_HYPHEN;
// TODO: check header magic
@@ -355,7 +351,7 @@
* Note: len here is the padded length including 0 codes at start and end.
**/
void Hyphenator::hyphenateFromCodes(HyphenationType* result, const uint16_t* codes, size_t len,
- HyphenationType hyphenValue) const {
+ HyphenationType hyphenValue) const {
static_assert(sizeof(HyphenationType) == sizeof(uint8_t), "HyphnationType must be uint8_t.");
// Reuse the result array as a buffer for calculating intermediate hyphenation numbers.
uint8_t* buffer = reinterpret_cast<uint8_t*>(result);
diff --git a/libs/minikin/HyphenatorMap.cpp b/libs/minikin/HyphenatorMap.cpp
index 563aac3..b3b7b8b 100644
--- a/libs/minikin/HyphenatorMap.cpp
+++ b/libs/minikin/HyphenatorMap.cpp
@@ -31,7 +31,6 @@
constexpr int DEFAULT_MAX_PREFIX = 2;
} // namespace
-
// Following two function's implementations are here since Hyphenator.cpp can't include
// HyphenatorMap.h due to harfbuzz dependency on the host binary.
void addHyphenator(const std::string& localeStr, const Hyphenator* hyphenator) {
@@ -43,9 +42,8 @@
}
HyphenatorMap::HyphenatorMap()
- : mSoftHyphenOnlyHyphenator(Hyphenator::loadBinary(
- nullptr, DEFAULT_MIN_PREFIX, DEFAULT_MAX_PREFIX, "")) {
-}
+ : mSoftHyphenOnlyHyphenator(
+ Hyphenator::loadBinary(nullptr, DEFAULT_MIN_PREFIX, DEFAULT_MAX_PREFIX, "")) {}
void HyphenatorMap::addInternal(const std::string& localeStr, const Hyphenator* hyphenator) {
const Locale locale(localeStr);
@@ -59,8 +57,8 @@
mMap[locale.getIdentifier()] = hyphenator;
}
-void HyphenatorMap::addAliasInternal(
- const std::string& fromLocaleStr, const std::string& toLocaleStr) {
+void HyphenatorMap::addAliasInternal(const std::string& fromLocaleStr,
+ const std::string& toLocaleStr) {
const Locale fromLocale(fromLocaleStr);
const Locale toLocale(toLocaleStr);
android::AutoMutex _l(gMinikinLock);
@@ -119,8 +117,7 @@
return it == mMap.end() ? nullptr : it->second;
}
-const Hyphenator* HyphenatorMap::lookupBySubtagLocked(const Locale& locale,
- SubtagBits bits) const {
+const Hyphenator* HyphenatorMap::lookupBySubtagLocked(const Locale& locale, SubtagBits bits) const {
const Locale partialLocale = locale.getPartialLocale(bits);
if (!partialLocale.isSupported() || partialLocale == locale) {
return nullptr; // Skip the partial locale result in the same locale or not supported.
diff --git a/libs/minikin/HyphenatorMap.h b/libs/minikin/HyphenatorMap.h
index f206af0..4611c01 100644
--- a/libs/minikin/HyphenatorMap.h
+++ b/libs/minikin/HyphenatorMap.h
@@ -20,6 +20,7 @@
#include <map>
#include "minikin/Hyphenator.h"
+
#include "Locale.h"
namespace minikin {
@@ -52,7 +53,7 @@
protected:
// The following five methods are protected for testing purposes.
- HyphenatorMap(); // Use getInstance() instead.
+ HyphenatorMap(); // Use getInstance() instead.
void addInternal(const std::string& localeStr, const Hyphenator* hyphenator);
void addAliasInternal(const std::string& fromLocaleStr, const std::string& toLocaleStr);
const Hyphenator* lookupInternal(const Locale& locale);
@@ -73,4 +74,4 @@
} // namespace minikin
-#endif // MINIKIN_HYPHENATOR_MAP_H
+#endif // MINIKIN_HYPHENATOR_MAP_H
diff --git a/libs/minikin/Layout.cpp b/libs/minikin/Layout.cpp
index 4417b5a..187e962 100644
--- a/libs/minikin/Layout.cpp
+++ b/libs/minikin/Layout.cpp
@@ -33,6 +33,7 @@
#include <utils/Singleton.h>
#include "minikin/Emoji.h"
+
#include "HbFontCache.h"
#include "LayoutUtils.h"
#include "LocaleListCache.h"
@@ -91,21 +92,28 @@
class LayoutCacheKey {
public:
LayoutCacheKey(const std::shared_ptr<FontCollection>& collection, const MinikinPaint& paint,
- const uint16_t* chars, size_t start, size_t count, size_t nchars, bool dir,
- StartHyphenEdit startHyphen, EndHyphenEdit endHyphen)
- : mChars(chars), mNchars(nchars),
- mStart(start), mCount(count), mId(collection->getId()), mStyle(paint.fontStyle),
- mSize(paint.size), mScaleX(paint.scaleX), mSkewX(paint.skewX),
- mLetterSpacing(paint.letterSpacing),
- mPaintFlags(paint.paintFlags), mLocaleListId(paint.localeListId),
- mFamilyVariant(paint.familyVariant), mStartHyphen(startHyphen), mEndHyphen(endHyphen),
- mIsRtl(dir), mHash(computeHash()) {
- }
- bool operator==(const LayoutCacheKey &other) const;
+ const uint16_t* chars, size_t start, size_t count, size_t nchars, bool dir,
+ StartHyphenEdit startHyphen, EndHyphenEdit endHyphen)
+ : mChars(chars),
+ mNchars(nchars),
+ mStart(start),
+ mCount(count),
+ mId(collection->getId()),
+ mStyle(paint.fontStyle),
+ mSize(paint.size),
+ mScaleX(paint.scaleX),
+ mSkewX(paint.skewX),
+ mLetterSpacing(paint.letterSpacing),
+ mPaintFlags(paint.paintFlags),
+ mLocaleListId(paint.localeListId),
+ mFamilyVariant(paint.familyVariant),
+ mStartHyphen(startHyphen),
+ mEndHyphen(endHyphen),
+ mIsRtl(dir),
+ mHash(computeHash()) {}
+ bool operator==(const LayoutCacheKey& other) const;
- android::hash_t hash() const {
- return mHash;
- }
+ android::hash_t hash() const { return mHash; }
void copyText() {
uint16_t* charsCopy = new uint16_t[mNchars];
@@ -118,13 +126,13 @@
}
void doLayout(Layout* layout, LayoutContext* ctx,
- const std::shared_ptr<FontCollection>& collection) const {
+ const std::shared_ptr<FontCollection>& collection) const {
layout->mAdvances.resize(mCount, 0);
layout->mExtents.resize(mCount);
layout->mClusterBounds.resize(mCount);
ctx->clearHbFonts();
layout->doLayoutRun(mChars, mStart, mCount, mNchars, mIsRtl, ctx, mStartHyphen, mEndHyphen,
- collection);
+ collection);
}
private:
@@ -157,12 +165,10 @@
mCache.setOnEntryRemovedListener(this);
}
- void clear() {
- mCache.clear();
- }
+ void clear() { mCache.clear(); }
Layout* get(LayoutCacheKey& key, LayoutContext* ctx,
- const std::shared_ptr<FontCollection>& collection) {
+ const std::shared_ptr<FontCollection>& collection) {
Layout* layout = mCache.get(key);
mRequestCount++;
if (layout == NULL) {
@@ -179,7 +185,7 @@
void dumpStats(int fd) {
dprintf(fd, "\nLayout Cache Info:\n");
dprintf(fd, " Usage: %zd/%zd entries\n", mCache.size(), kMaxEntries);
- float ratio = (mRequestCount == 0) ? 0 : mCacheHitCount / (float) mRequestCount;
+ float ratio = (mRequestCount == 0) ? 0 : mCacheHitCount / (float)mRequestCount;
dprintf(fd, " Hit ratio: %d/%d (%f)\n", mCacheHitCount, mRequestCount, ratio);
}
@@ -195,7 +201,7 @@
int32_t mRequestCount;
int32_t mCacheHitCount;
- //static const size_t kMaxEntries = LruCache<LayoutCacheKey, Layout*>::kUnlimitedCapacity;
+ // static const size_t kMaxEntries = LruCache<LayoutCacheKey, Layout*>::kUnlimitedCapacity;
// TODO: eviction based on memory footprint; for now, we just use a constant
// number of strings
@@ -224,22 +230,13 @@
};
bool LayoutCacheKey::operator==(const LayoutCacheKey& other) const {
- return mId == other.mId
- && mStart == other.mStart
- && mCount == other.mCount
- && mStyle == other.mStyle
- && mSize == other.mSize
- && mScaleX == other.mScaleX
- && mSkewX == other.mSkewX
- && mLetterSpacing == other.mLetterSpacing
- && mPaintFlags == other.mPaintFlags
- && mLocaleListId == other.mLocaleListId
- && mFamilyVariant == other.mFamilyVariant
- && mStartHyphen == other.mStartHyphen
- && mEndHyphen == other.mEndHyphen
- && mIsRtl == other.mIsRtl
- && mNchars == other.mNchars
- && !memcmp(mChars, other.mChars, mNchars * sizeof(uint16_t));
+ return mId == other.mId && mStart == other.mStart && mCount == other.mCount &&
+ mStyle == other.mStyle && mSize == other.mSize && mScaleX == other.mScaleX &&
+ mSkewX == other.mSkewX && mLetterSpacing == other.mLetterSpacing &&
+ mPaintFlags == other.mPaintFlags && mLocaleListId == other.mLocaleListId &&
+ mFamilyVariant == other.mFamilyVariant && mStartHyphen == other.mStartHyphen &&
+ mEndHyphen == other.mEndHyphen && mIsRtl == other.mIsRtl && mNchars == other.mNchars &&
+ !memcmp(mChars, other.mChars, mNchars * sizeof(uint16_t));
}
android::hash_t LayoutCacheKey::computeHash() const {
@@ -254,8 +251,9 @@
hash = android::JenkinsHashMix(hash, android::hash_type(mPaintFlags));
hash = android::JenkinsHashMix(hash, android::hash_type(mLocaleListId));
hash = android::JenkinsHashMix(hash, android::hash_type(static_cast<uint8_t>(mFamilyVariant)));
- hash = android::JenkinsHashMix(hash, android::hash_type(
- static_cast<uint8_t>(packHyphenEdit(mStartHyphen, mEndHyphen))));
+ hash = android::JenkinsHashMix(
+ hash,
+ android::hash_type(static_cast<uint8_t>(packHyphenEdit(mStartHyphen, mEndHyphen))));
hash = android::JenkinsHashMix(hash, android::hash_type(mIsRtl));
hash = android::JenkinsHashMixShorts(hash, mChars, mNchars);
return android::JenkinsHashWhiten(hash);
@@ -287,15 +285,16 @@
}
static hb_position_t harfbuzzGetGlyphHorizontalAdvance(hb_font_t* /* hbFont */, void* fontData,
- hb_codepoint_t glyph, void* /* userData */) {
+ hb_codepoint_t glyph, void* /* userData */) {
SkiaArguments* args = reinterpret_cast<SkiaArguments*>(fontData);
float advance = args->font->GetHorizontalAdvance(glyph, *args->paint, args->fakery);
return 256 * advance + 0.5;
}
static hb_bool_t harfbuzzGetGlyphHorizontalOrigin(hb_font_t* /* hbFont */, void* /* fontData */,
- hb_codepoint_t /* glyph */, hb_position_t* /* x */, hb_position_t* /* y */,
- void* /* userData */) {
+ hb_codepoint_t /* glyph */,
+ hb_position_t* /* x */, hb_position_t* /* y */,
+ void* /* userData */) {
// Just return true, following the way that Harfbuzz-FreeType
// implementation does.
return true;
@@ -333,14 +332,12 @@
return cbdt.size() > 0;
}
-static float HBFixedToFloat(hb_position_t v)
-{
- return scalbnf (v, -8);
+static float HBFixedToFloat(hb_position_t v) {
+ return scalbnf(v, -8);
}
-static hb_position_t HBFloatToFixed(float v)
-{
- return scalbnf (v, +8);
+static hb_position_t HBFloatToFixed(float v) {
+ return scalbnf(v, +8);
}
void Layout::dump() const {
@@ -365,7 +362,7 @@
hb_font_t* font = getHbFontLocked(face.font);
hb_font_set_funcs(font, getHbFontFuncs(isColorBitmapFont(font)),
new SkiaArguments({face.font, &ctx->paint, face.fakery}),
- [] (void* data) { delete reinterpret_cast<SkiaArguments*>(data); });
+ [](void* data) { delete reinterpret_cast<SkiaArguments*>(data); });
ctx->hbFonts.push_back(font);
}
return ix;
@@ -381,11 +378,11 @@
static hb_codepoint_t decodeUtf16(const uint16_t* chars, size_t len, ssize_t* iter) {
UChar32 result;
- U16_NEXT(chars, *iter, (ssize_t) len, result);
- if (U_IS_SURROGATE(result)) { // isolated surrogate
- result = 0xFFFDu; // U+FFFD REPLACEMENT CHARACTER
+ U16_NEXT(chars, *iter, (ssize_t)len, result);
+ if (U_IS_SURROGATE(result)) { // isolated surrogate
+ result = 0xFFFDu; // U+FFFD REPLACEMENT CHARACTER
}
- return (hb_codepoint_t) result;
+ return (hb_codepoint_t)result;
}
static hb_script_t getScriptRun(const uint16_t* chars, size_t len, ssize_t* iter) {
@@ -395,17 +392,14 @@
uint32_t cp = decodeUtf16(chars, len, iter);
hb_script_t current_script = codePointToScript(cp);
for (;;) {
- if (size_t(*iter) == len)
- break;
+ if (size_t(*iter) == len) break;
const ssize_t prev_iter = *iter;
cp = decodeUtf16(chars, len, iter);
const hb_script_t script = codePointToScript(cp);
if (script != current_script) {
- if (current_script == HB_SCRIPT_INHERITED ||
- current_script == HB_SCRIPT_COMMON) {
+ if (current_script == HB_SCRIPT_INHERITED || current_script == HB_SCRIPT_COMMON) {
current_script = script;
- } else if (script == HB_SCRIPT_INHERITED ||
- script == HB_SCRIPT_COMMON) {
+ } else if (script == HB_SCRIPT_INHERITED || script == HB_SCRIPT_COMMON) {
continue;
} else {
*iter = prev_iter;
@@ -425,22 +419,13 @@
* applied. See https://github.com/behdad/harfbuzz/issues/64 for more details.
*/
static bool isScriptOkForLetterspacing(hb_script_t script) {
- return !(
- script == HB_SCRIPT_ARABIC ||
- script == HB_SCRIPT_NKO ||
- script == HB_SCRIPT_PSALTER_PAHLAVI ||
- script == HB_SCRIPT_MANDAIC ||
- script == HB_SCRIPT_MONGOLIAN ||
- script == HB_SCRIPT_PHAGS_PA ||
- script == HB_SCRIPT_DEVANAGARI ||
- script == HB_SCRIPT_BENGALI ||
- script == HB_SCRIPT_GURMUKHI ||
- script == HB_SCRIPT_MODI ||
- script == HB_SCRIPT_SHARADA ||
- script == HB_SCRIPT_SYLOTI_NAGRI ||
- script == HB_SCRIPT_TIRHUTA ||
- script == HB_SCRIPT_OGHAM
- );
+ return !(script == HB_SCRIPT_ARABIC || script == HB_SCRIPT_NKO ||
+ script == HB_SCRIPT_PSALTER_PAHLAVI || script == HB_SCRIPT_MANDAIC ||
+ script == HB_SCRIPT_MONGOLIAN || script == HB_SCRIPT_PHAGS_PA ||
+ script == HB_SCRIPT_DEVANAGARI || script == HB_SCRIPT_BENGALI ||
+ script == HB_SCRIPT_GURMUKHI || script == HB_SCRIPT_MODI ||
+ script == HB_SCRIPT_SHARADA || script == HB_SCRIPT_SYLOTI_NAGRI ||
+ script == HB_SCRIPT_TIRHUTA || script == HB_SCRIPT_OGHAM);
}
class BidiText {
@@ -455,16 +440,14 @@
Iter(UBiDi* bidi, size_t start, size_t end, size_t runIndex, size_t runCount, bool isRtl);
- bool operator!= (const Iter& other) const {
- return mIsEnd != other.mIsEnd || mNextRunIndex != other.mNextRunIndex
- || mBidi != other.mBidi;
+ bool operator!=(const Iter& other) const {
+ return mIsEnd != other.mIsEnd || mNextRunIndex != other.mNextRunIndex ||
+ mBidi != other.mBidi;
}
- const RunInfo& operator* () const {
- return mRunInfo;
- }
+ const RunInfo& operator*() const { return mRunInfo; }
- const Iter& operator++ () {
+ const Iter& operator++() {
updateRunInfo();
return *this;
}
@@ -489,13 +472,9 @@
}
}
- Iter begin () const {
- return Iter(mBidi, mStart, mEnd, 0, mRunCount, mIsRtl);
- }
+ Iter begin() const { return Iter(mBidi, mStart, mEnd, 0, mRunCount, mIsRtl); }
- Iter end() const {
- return Iter(mBidi, mStart, mEnd, mRunCount, mRunCount, mIsRtl);
- }
+ Iter end() const { return Iter(mBidi, mStart, mEnd, mRunCount, mRunCount, mIsRtl); }
private:
const size_t mStart;
@@ -510,9 +489,14 @@
};
BidiText::Iter::Iter(UBiDi* bidi, size_t start, size_t end, size_t runIndex, size_t runCount,
- bool isRtl)
- : mBidi(bidi), mIsEnd(runIndex == runCount), mNextRunIndex(runIndex), mRunCount(runCount),
- mStart(start), mEnd(end), mRunInfo() {
+ bool isRtl)
+ : mBidi(bidi),
+ mIsEnd(runIndex == runCount),
+ mNextRunIndex(runIndex),
+ mRunCount(runCount),
+ mStart(start),
+ mEnd(end),
+ mRunInfo() {
if (mRunCount == 1) {
mRunInfo.mRunStart = start;
mRunInfo.mRunLength = end - start;
@@ -551,8 +535,12 @@
}
BidiText::BidiText(const uint16_t* buf, size_t start, size_t count, size_t bufSize, Bidi bidiFlags)
- : mStart(start), mEnd(start + count), mBufSize(bufSize), mBidi(NULL), mRunCount(1),
- mIsRtl(isRtl(bidiFlags)) {
+ : mStart(start),
+ mEnd(start + count),
+ mBufSize(bufSize),
+ mBidi(NULL),
+ mRunCount(1),
+ mIsRtl(isRtl(bidiFlags)) {
if (isOverride(bidiFlags)) {
// force single run.
return;
@@ -596,8 +584,8 @@
}
void Layout::doLayout(const uint16_t* buf, size_t start, size_t count, size_t bufSize,
- Bidi bidiFlags, const MinikinPaint &paint,
- const std::shared_ptr<FontCollection>& collection) {
+ Bidi bidiFlags, const MinikinPaint& paint,
+ const std::shared_ptr<FontCollection>& collection) {
android::AutoMutex _l(gMinikinLock);
LayoutContext ctx(paint);
@@ -609,16 +597,17 @@
for (const BidiText::Iter::RunInfo& runInfo : BidiText(buf, start, count, bufSize, bidiFlags)) {
doLayoutRunCached(buf, runInfo.mRunStart, runInfo.mRunLength, bufSize, runInfo.mIsRtl, &ctx,
- start, startHyphenEdit(paint.hyphenEdit), endHyphenEdit(paint.hyphenEdit),
- collection, this, nullptr, nullptr, nullptr);
+ start, startHyphenEdit(paint.hyphenEdit), endHyphenEdit(paint.hyphenEdit),
+ collection, this, nullptr, nullptr, nullptr);
}
ctx.clearHbFonts();
}
float Layout::measureText(const uint16_t* buf, size_t start, size_t count, size_t bufSize,
- Bidi bidiFlags, const MinikinPaint &paint, StartHyphenEdit startHyphen,
- EndHyphenEdit endHyphen, const std::shared_ptr<FontCollection>& collection, float* advances,
- MinikinExtent* extents, LayoutOverhang* overhangs) {
+ Bidi bidiFlags, const MinikinPaint& paint, StartHyphenEdit startHyphen,
+ EndHyphenEdit endHyphen,
+ const std::shared_ptr<FontCollection>& collection, float* advances,
+ MinikinExtent* extents, LayoutOverhang* overhangs) {
android::AutoMutex _l(gMinikinLock);
LayoutContext ctx(paint);
@@ -630,8 +619,8 @@
MinikinExtent* extentsForRun = extents ? extents + offset : nullptr;
LayoutOverhang* overhangsForRun = overhangs ? overhangs + offset : nullptr;
advance += doLayoutRunCached(buf, runInfo.mRunStart, runInfo.mRunLength, bufSize,
- runInfo.mIsRtl, &ctx, 0, startHyphen, endHyphen, collection, NULL, advancesForRun,
- extentsForRun, overhangsForRun);
+ runInfo.mIsRtl, &ctx, 0, startHyphen, endHyphen, collection,
+ NULL, advancesForRun, extentsForRun, overhangsForRun);
}
ctx.clearHbFonts();
@@ -639,10 +628,11 @@
}
float Layout::doLayoutRunCached(const uint16_t* buf, size_t start, size_t count, size_t bufSize,
- bool isRtl, LayoutContext* ctx, size_t dstStart,
- StartHyphenEdit startHyphen, EndHyphenEdit endHyphen,
- const std::shared_ptr<FontCollection>& collection, Layout* layout, float* advances,
- MinikinExtent* extents, LayoutOverhang* overhangs) {
+ bool isRtl, LayoutContext* ctx, size_t dstStart,
+ StartHyphenEdit startHyphen, EndHyphenEdit endHyphen,
+ const std::shared_ptr<FontCollection>& collection, Layout* layout,
+ float* advances, MinikinExtent* extents,
+ LayoutOverhang* overhangs) {
float advance = 0;
if (!isRtl) {
// left to right
@@ -654,14 +644,13 @@
const size_t wordcount = std::min(start + count, wordend) - iter;
const size_t offset = iter - start;
advance += doLayoutWord(buf + wordstart, iter - wordstart, wordcount,
- wordend - wordstart, isRtl, ctx, iter - dstStart,
- // Only apply hyphen to the first or last word in the string.
- iter == start ? startHyphen : StartHyphenEdit::NO_EDIT,
- wordend >= start + count ? endHyphen : EndHyphenEdit::NO_EDIT,
- collection, layout,
- advances ? advances + offset : nullptr,
- extents ? extents + offset : nullptr,
- overhangs ? overhangs + offset : nullptr);
+ wordend - wordstart, isRtl, ctx, iter - dstStart,
+ // Only apply hyphen to the first or last word in the string.
+ iter == start ? startHyphen : StartHyphenEdit::NO_EDIT,
+ wordend >= start + count ? endHyphen : EndHyphenEdit::NO_EDIT,
+ collection, layout, advances ? advances + offset : nullptr,
+ extents ? extents + offset : nullptr,
+ overhangs ? overhangs + offset : nullptr);
wordstart = wordend;
}
} else {
@@ -674,15 +663,14 @@
size_t bufStart = std::max(start, wordstart);
const size_t offset = bufStart - start;
advance += doLayoutWord(buf + wordstart, bufStart - wordstart, iter - bufStart,
- wordend - wordstart, isRtl, ctx, bufStart - dstStart,
- // Only apply hyphen to the first (rightmost) or last (leftmost) word in the
- // string.
- wordstart <= start ? startHyphen : StartHyphenEdit::NO_EDIT,
- iter == end ? endHyphen : EndHyphenEdit::NO_EDIT,
- collection, layout,
- advances ? advances + offset : nullptr,
- extents ? extents + offset : nullptr,
- overhangs ? overhangs + offset : nullptr);
+ wordend - wordstart, isRtl, ctx, bufStart - dstStart,
+ // Only apply hyphen to the first (rightmost) or last (leftmost)
+ // word in the string.
+ wordstart <= start ? startHyphen : StartHyphenEdit::NO_EDIT,
+ iter == end ? endHyphen : EndHyphenEdit::NO_EDIT, collection,
+ layout, advances ? advances + offset : nullptr,
+ extents ? extents + offset : nullptr,
+ overhangs ? overhangs + offset : nullptr);
wordend = wordstart;
}
}
@@ -690,10 +678,10 @@
}
float Layout::doLayoutWord(const uint16_t* buf, size_t start, size_t count, size_t bufSize,
- bool isRtl, LayoutContext* ctx, size_t bufStart,
- StartHyphenEdit startHyphen, EndHyphenEdit endHyphen,
- const std::shared_ptr<FontCollection>& collection, Layout* layout, float* advances,
- MinikinExtent* extents, LayoutOverhang* overhangs) {
+ bool isRtl, LayoutContext* ctx, size_t bufStart,
+ StartHyphenEdit startHyphen, EndHyphenEdit endHyphen,
+ const std::shared_ptr<FontCollection>& collection, Layout* layout,
+ float* advances, MinikinExtent* extents, LayoutOverhang* overhangs) {
LayoutCache& cache = LayoutEngine::getInstance().layoutCache;
LayoutCacheKey key(collection, ctx->paint, buf, start, count, bufSize, isRtl, startHyphen,
endHyphen);
@@ -743,15 +731,15 @@
return advance;
}
-static void addFeatures(const std::string &str, std::vector<hb_feature_t>* features) {
+static void addFeatures(const std::string& str, std::vector<hb_feature_t>* features) {
SplitIterator it(str, ',');
while (it.hasNext()) {
StringPiece featureStr = it.next();
static hb_feature_t feature;
/* We do not allow setting features on ranges. As such, reject any
* setting that has non-universal range. */
- if (hb_feature_from_string (featureStr.data(), featureStr.size(), &feature)
- && feature.start == 0 && feature.end == (unsigned int) -1) {
+ if (hb_feature_from_string(featureStr.data(), featureStr.size(), &feature) &&
+ feature.start == 0 && feature.end == (unsigned int)-1) {
features->push_back(feature);
}
}
@@ -759,9 +747,9 @@
static inline hb_codepoint_t determineHyphenChar(hb_codepoint_t preferredHyphen, hb_font_t* font) {
hb_codepoint_t glyph;
- if (preferredHyphen == 0x058A /* ARMENIAN_HYPHEN */
- || preferredHyphen == 0x05BE /* HEBREW PUNCTUATION MAQAF */
- || preferredHyphen == 0x1400 /* CANADIAN SYLLABIC HYPHEN */) {
+ if (preferredHyphen == 0x058A /* ARMENIAN_HYPHEN */
+ || preferredHyphen == 0x05BE /* HEBREW PUNCTUATION MAQAF */
+ || preferredHyphen == 0x1400 /* CANADIAN SYLLABIC HYPHEN */) {
if (hb_font_get_nominal_glyph(font, preferredHyphen, &glyph)) {
return preferredHyphen;
} else {
@@ -775,15 +763,15 @@
// Note that we intentionally don't do anything special if the font doesn't have a
// HYPHEN-MINUS either, so a tofu could be shown, hinting towards something missing.
if (!hb_font_get_nominal_glyph(font, preferredHyphen, &glyph)) {
- return 0x002D; // HYPHEN-MINUS
+ return 0x002D; // HYPHEN-MINUS
}
}
return preferredHyphen;
}
template <typename HyphenEdit>
-static inline void addHyphenToHbBuffer(hb_buffer_t* buffer, hb_font_t* font,
- HyphenEdit hyphen, uint32_t cluster) {
+static inline void addHyphenToHbBuffer(hb_buffer_t* buffer, hb_font_t* font, HyphenEdit hyphen,
+ uint32_t cluster) {
const uint32_t* chars;
size_t size;
std::tie(chars, size) = getHyphenString(hyphen);
@@ -794,17 +782,16 @@
// Returns the cluster value assigned to the first codepoint added to the buffer, which can be used
// to translate cluster values returned by HarfBuzz to input indices.
-static inline uint32_t addToHbBuffer(hb_buffer_t* buffer,
- const uint16_t* buf, size_t start, size_t count, size_t bufSize,
- ssize_t scriptRunStart, ssize_t scriptRunEnd,
- StartHyphenEdit inStartHyphen, EndHyphenEdit inEndHyphen, hb_font_t* hbFont) {
-
+static inline uint32_t addToHbBuffer(hb_buffer_t* buffer, const uint16_t* buf, size_t start,
+ size_t count, size_t bufSize, ssize_t scriptRunStart,
+ ssize_t scriptRunEnd, StartHyphenEdit inStartHyphen,
+ EndHyphenEdit inEndHyphen, hb_font_t* hbFont) {
// Only hyphenate the very first script run for starting hyphens.
- const StartHyphenEdit startHyphen = (scriptRunStart == 0)
- ? inStartHyphen : StartHyphenEdit::NO_EDIT;
+ const StartHyphenEdit startHyphen =
+ (scriptRunStart == 0) ? inStartHyphen : StartHyphenEdit::NO_EDIT;
// Only hyphenate the very last script run for ending hyphens.
- const EndHyphenEdit endHyphen = (static_cast<size_t>(scriptRunEnd) == count)
- ? inEndHyphen : EndHyphenEdit::NO_EDIT;
+ const EndHyphenEdit endHyphen =
+ (static_cast<size_t>(scriptRunEnd) == count) ? inEndHyphen : EndHyphenEdit::NO_EDIT;
// In the following code, we drop the pre-context and/or post-context if there is a
// hyphen edit at that end. This is not absolutely necessary, since HarfBuzz uses
@@ -829,7 +816,7 @@
const uint16_t* hbText;
int hbTextLength;
unsigned int hbItemOffset;
- unsigned int hbItemLength = scriptRunEnd - scriptRunStart; // This is >= 1.
+ unsigned int hbItemLength = scriptRunEnd - scriptRunStart; // This is >= 1.
const bool hasEndInsertion = isInsertion(endHyphen);
const bool hasEndReplacement = isReplacement(endHyphen);
@@ -881,7 +868,7 @@
// we have a replacement that is replacing a one-code unit script run.
hyphenCluster = 0;
} else {
- hyphenCluster = cpInfo[numCodepoints - 1].cluster + (uint32_t) hasEndReplacement;
+ hyphenCluster = cpInfo[numCodepoints - 1].cluster + (uint32_t)hasEndReplacement;
}
addHyphenToHbBuffer(buffer, hbFont, endHyphen, hyphenCluster);
// Since we have just added to the buffer, cpInfo no longer necessarily points to
@@ -891,10 +878,10 @@
return cpInfo[0].cluster;
}
-
void Layout::doLayoutRun(const uint16_t* buf, size_t start, size_t count, size_t bufSize,
- bool isRtl, LayoutContext* ctx, StartHyphenEdit startHyphen, EndHyphenEdit endHyphen,
- const std::shared_ptr<FontCollection>& collection) {
+ bool isRtl, LayoutContext* ctx, StartHyphenEdit startHyphen,
+ EndHyphenEdit endHyphen,
+ const std::shared_ptr<FontCollection>& collection) {
hb_buffer_t* buffer = LayoutEngine::getInstance().hbBuffer;
std::vector<FontCollection::Run> items;
collection->itemize(buf + start, count, ctx->paint, &items);
@@ -905,10 +892,9 @@
// "When the effective spacing between two characters is not zero (due to
// either justification or a non-zero value of letter-spacing), user agents
// should not apply optional ligatures."
- if (fabs(ctx->paint.letterSpacing) > 0.03)
- {
- static const hb_feature_t no_liga = { HB_TAG('l', 'i', 'g', 'a'), 0, 0, ~0u };
- static const hb_feature_t no_clig = { HB_TAG('c', 'l', 'i', 'g'), 0, 0, ~0u };
+ if (fabs(ctx->paint.letterSpacing) > 0.03) {
+ static const hb_feature_t no_liga = {HB_TAG('l', 'i', 'g', 'a'), 0, 0, ~0u};
+ static const hb_feature_t no_clig = {HB_TAG('c', 'l', 'i', 'g'), 0, 0, ~0u};
features.push_back(no_liga);
features.push_back(no_clig);
}
@@ -920,9 +906,9 @@
float x = mAdvance;
float y = 0;
for (int run_ix = isRtl ? items.size() - 1 : 0;
- isRtl ? run_ix >= 0 : run_ix < static_cast<int>(items.size());
- isRtl ? --run_ix : ++run_ix) {
- FontCollection::Run &run = items[run_ix];
+ isRtl ? run_ix >= 0 : run_ix < static_cast<int>(items.size());
+ isRtl ? --run_ix : ++run_ix) {
+ FontCollection::Run& run = items[run_ix];
const FakedFont& fakedFont = run.fakedFont;
if (fakedFont.font == NULL) {
ALOGE("no font for run starting u+%04x length %d", buf[run.start], run.end - run.start);
@@ -947,9 +933,8 @@
// Note: scriptRunStart and scriptRunEnd, as well as run.start and run.end, run between 0
// and count.
ssize_t scriptRunEnd;
- for (ssize_t scriptRunStart = run.start;
- scriptRunStart < run.end;
- scriptRunStart = scriptRunEnd) {
+ for (ssize_t scriptRunStart = run.start; scriptRunStart < run.end;
+ scriptRunStart = scriptRunEnd) {
scriptRunEnd = scriptRunStart;
hb_script_t script = getScriptRun(buf + start, run.end, &scriptRunEnd /* iterator */);
// After the last line, scriptRunEnd is guaranteed to have increased, since the only
@@ -976,7 +961,7 @@
hb_buffer_clear_contents(buffer);
hb_buffer_set_script(buffer, script);
- hb_buffer_set_direction(buffer, isRtl? HB_DIRECTION_RTL : HB_DIRECTION_LTR);
+ hb_buffer_set_direction(buffer, isRtl ? HB_DIRECTION_RTL : HB_DIRECTION_LTR);
const LocaleList& localeList = LocaleListCache::getById(ctx->paint.localeListId);
if (localeList.size() != 0) {
hb_language_t hbLanguage = localeList.getHbLanguage(0);
@@ -989,11 +974,9 @@
hb_buffer_set_language(buffer, hbLanguage);
}
- const uint32_t clusterStart = addToHbBuffer(
- buffer,
- buf, start, count, bufSize,
- scriptRunStart, scriptRunEnd,
- startHyphen, endHyphen, hbFont);
+ const uint32_t clusterStart =
+ addToHbBuffer(buffer, buf, start, count, bufSize, scriptRunStart, scriptRunEnd,
+ startHyphen, endHyphen, hbFont);
hb_shape(hbFont, buffer, features.empty() ? NULL : &features[0], features.size());
unsigned int numGlyphs;
@@ -1008,8 +991,7 @@
// mAdvances.
const ssize_t clusterOffset = clusterStart - scriptRunStart;
- if (numGlyphs)
- {
+ if (numGlyphs) {
mAdvances[info[0].cluster - clusterOffset] += letterSpaceHalfLeft;
x += letterSpaceHalfLeft;
}
@@ -1051,15 +1033,14 @@
mAdvances[clusterBaseIndex] += xAdvance;
mClusterBounds[clusterBaseIndex].join(glyphBounds);
} else {
- ALOGE("cluster %zu (start %zu) out of bounds of count %zu",
- clusterBaseIndex, start, count);
+ ALOGE("cluster %zu (start %zu) out of bounds of count %zu", clusterBaseIndex,
+ start, count);
}
glyphBounds.offset(x, y);
mBounds.join(glyphBounds);
x += xAdvance;
}
- if (numGlyphs)
- {
+ if (numGlyphs) {
mAdvances[info[numGlyphs - 1].cluster - clusterOffset] += letterSpaceHalfRight;
x += letterSpaceHalfRight;
}
@@ -1184,4 +1165,3 @@
namespace android {
ANDROID_SINGLETON_STATIC_INSTANCE(minikin::LayoutEngine);
} // namespace android
-
diff --git a/libs/minikin/LayoutUtils.h b/libs/minikin/LayoutUtils.h
index 05c4156..3128148 100644
--- a/libs/minikin/LayoutUtils.h
+++ b/libs/minikin/LayoutUtils.h
@@ -33,8 +33,7 @@
* kerning or complex script processing. This is necessarily a
* heuristic, but should be accurate most of the time.
*/
-size_t getPrevWordBreakForCache(
- const uint16_t* chars, size_t offset, size_t len);
+size_t getPrevWordBreakForCache(const uint16_t* chars, size_t offset, size_t len);
/**
* Return offset of next word break. It is either > offset or == len.
@@ -43,8 +42,7 @@
* kerning or complex script processing. This is necessarily a
* heuristic, but should be accurate most of the time.
*/
-size_t getNextWordBreakForCache(
- const uint16_t* chars, size_t offset, size_t len);
+size_t getNextWordBreakForCache(const uint16_t* chars, size_t offset, size_t len);
} // namespace minikin
#endif // MINIKIN_LAYOUT_UTILS_H
diff --git a/libs/minikin/LineBreaker.cpp b/libs/minikin/LineBreaker.cpp
index bcac772..413c5f6 100644
--- a/libs/minikin/LineBreaker.cpp
+++ b/libs/minikin/LineBreaker.cpp
@@ -23,6 +23,7 @@
#include "minikin/Layout.h"
#include "minikin/Range.h"
#include "minikin/U16StringPiece.h"
+
#include "HyphenatorMap.h"
#include "LayoutUtils.h"
#include "Locale.h"
@@ -70,8 +71,8 @@
MeasuredText result(text.size());
for (const auto& run : runs) {
const uint32_t runOffset = run->getRange().getStart();
- run->getMetrics(text, result.widths.data() + runOffset,
- result.extents.data() + runOffset, result.overhangs.data() + runOffset);
+ run->getMetrics(text, result.widths.data() + runOffset, result.extents.data() + runOffset,
+ result.overhangs.data() + runOffset);
}
return result;
}
@@ -85,25 +86,22 @@
const MeasuredText& measuredText, BreakStrategy strategy,
HyphenationFrequency frequency, bool justified)
: mCurrentLocaleListId(LocaleListCache::kInvalidListId),
- mWordBreaker(std::move(breaker)),
- mTextBuf(textBuffer),
- mMeasuredText(measuredText),
- mStrategy(strategy),
- mHyphenationFrequency(frequency),
- mJustified(justified),
- mLastConsideredGreedyCandidate(LAST_BREAK_OFFSET_NOWHERE),
- mSpaceCount(0) {
-
+ mWordBreaker(std::move(breaker)),
+ mTextBuf(textBuffer),
+ mMeasuredText(measuredText),
+ mStrategy(strategy),
+ mHyphenationFrequency(frequency),
+ mJustified(justified),
+ mLastConsideredGreedyCandidate(LAST_BREAK_OFFSET_NOWHERE),
+ mSpaceCount(0) {
mWordBreaker->setText(mTextBuf.data(), mTextBuf.size());
// handle initial break here because addStyleRun may never be called
- mCandidates.push_back({
- 0 /* offset */, 0.0 /* preBreak */, 0.0 /* postBreak */,
- 0.0 /* firstOverhang */, 0.0 /* secondOverhang */,
- 0.0 /* penalty */,
- 0 /* preSpaceCount */, 0 /* postSpaceCount */,
- HyphenationType::DONT_BREAK /* hyphenType */,
- false /* isRtl. TODO: may need to be based on input. */});
+ mCandidates.push_back({0 /* offset */, 0.0 /* preBreak */, 0.0 /* postBreak */,
+ 0.0 /* firstOverhang */, 0.0 /* secondOverhang */, 0.0 /* penalty */,
+ 0 /* preSpaceCount */, 0 /* postSpaceCount */,
+ HyphenationType::DONT_BREAK /* hyphenType */,
+ false /* isRtl. TODO: may need to be based on input. */});
}
LineBreaker::~LineBreaker() {}
@@ -112,7 +110,8 @@
MINIKIN_ASSERT(mLastGreedyBreakIndex != LAST_BREAK_OFFSET_NOWHERE,
"Line break hasn't started.");
return mLastGreedyBreakIndex == LAST_BREAK_OFFSET_DESPERATE
- ? mFakeDesperateCandidate : mCandidates[mLastGreedyBreakIndex];
+ ? mFakeDesperateCandidate
+ : mCandidates[mLastGreedyBreakIndex];
}
void LineBreaker::setLocaleList(uint32_t localeListId, size_t restartFrom) {
@@ -125,10 +124,10 @@
const uint64_t newLocaleId = newLocale.getIdentifier();
const bool needUpdate =
- // The first time setLocale is called.
- mCurrentLocaleListId == LocaleListCache::kInvalidListId ||
- // The effective locale is changed.
- newLocaleId != mCurrentLocaleId;
+ // The first time setLocale is called.
+ mCurrentLocaleListId == LocaleListCache::kInvalidListId ||
+ // The effective locale is changed.
+ newLocaleId != mCurrentLocaleId;
// For now, we ignore all locales except the first valid one.
// TODO: Support selecting the locale based on the script of the text.
@@ -145,15 +144,14 @@
// plus '\n'.
// Note: all such characters are in the BMP, so it's ok to use code units for this.
static bool isLineEndSpace(uint16_t c) {
- return c == '\n'
- || c == ' ' // SPACE
- || c == 0x1680 // OGHAM SPACE MARK
- || (0x2000 <= c && c <= 0x200A && c != 0x2007) // EN QUAD, EM QUAD, EN SPACE, EM SPACE,
+ return c == '\n' || c == ' ' // SPACE
+ || c == 0x1680 // OGHAM SPACE MARK
+ || (0x2000 <= c && c <= 0x200A && c != 0x2007) // EN QUAD, EM QUAD, EN SPACE, EM SPACE,
// THREE-PER-EM SPACE, FOUR-PER-EM SPACE,
// SIX-PER-EM SPACE, PUNCTUATION SPACE,
// THIN SPACE, HAIR SPACE
- || c == 0x205F // MEDIUM MATHEMATICAL SPACE
- || c == 0x3000; // IDEOGRAPHIC SPACE
+ || c == 0x205F // MEDIUM MATHEMATICAL SPACE
+ || c == 0x3000; // IDEOGRAPHIC SPACE
}
// Hyphenates a string potentially containing non-breaking spaces.
@@ -164,7 +162,7 @@
// A word here is any consecutive string of non-NBSP characters.
bool inWord = false;
- size_t wordStart = 0; // The initial value will never be accessed, but just in case.
+ size_t wordStart = 0; // The initial value will never be accessed, but just in case.
for (size_t i = 0; i <= len; i++) {
if (i == len || str[i] == CHAR_NBSP) {
if (inWord) {
@@ -179,7 +177,7 @@
mHyphenator->hyphenate(&wordVec, str.data() + wordStart, wordLen);
out.insert(out.end(), wordVec.cbegin(), wordVec.cend());
}
- } else { // Word is too long. Inefficient to hyphenate.
+ } else { // Word is too long. Inefficient to hyphenate.
out.insert(out.end(), wordLen, HyphenationType::DONT_BREAK);
}
inWord = false;
@@ -198,9 +196,9 @@
// Compute the total overhang of text based on per-cluster advances and overhangs.
// The two input vectors are expected to be of the same size.
-/* static */ LayoutOverhang LineBreaker::computeOverhang(float totalAdvance,
- const std::vector<float>& advances, const std::vector<LayoutOverhang>& overhangs,
- bool isRtl) {
+/* static */ LayoutOverhang LineBreaker::computeOverhang(
+ float totalAdvance, const std::vector<float>& advances,
+ const std::vector<LayoutOverhang>& overhangs, bool isRtl) {
ParaWidth left = 0.0;
ParaWidth right = 0.0;
ParaWidth seenAdvance = 0.0;
@@ -239,14 +237,10 @@
// postSpaceCount is the number of spaces that would be seen if we decide to break at the end of the
// word (and like postBreak it doesn't count any line-ending space after the word).
// hyphenPenalty is the amount of penalty for hyphenation.
-void LineBreaker::addHyphenationCandidates(
- const Run& run,
- const Range& contextRange,
- const Range& wordRange,
- ParaWidth lastBreakWidth,
- ParaWidth postBreak,
- size_t postSpaceCount,
- float hyphenPenalty) {
+void LineBreaker::addHyphenationCandidates(const Run& run, const Range& contextRange,
+ const Range& wordRange, ParaWidth lastBreakWidth,
+ ParaWidth postBreak, size_t postSpaceCount,
+ float hyphenPenalty) {
MINIKIN_ASSERT(contextRange.contains(wordRange), "Context must contain word range");
const bool isRtlWord = run.isRtl();
@@ -270,9 +264,9 @@
const size_t firstPartLen = firstPart.getLength();
advances.resize(firstPartLen);
overhangs.resize(firstPartLen);
- const float firstPartWidth = run.measureHyphenPiece(
- mTextBuf, firstPart, StartHyphenEdit::NO_EDIT, editForThisLine(hyph),
- advances.data(), overhangs.data());
+ const float firstPartWidth =
+ run.measureHyphenPiece(mTextBuf, firstPart, StartHyphenEdit::NO_EDIT,
+ editForThisLine(hyph), advances.data(), overhangs.data());
const ParaWidth hyphPostBreak = lastBreakWidth + firstPartWidth;
LayoutOverhang overhang = computeOverhang(firstPartWidth, advances, overhangs, isRtlWord);
// TODO: This ignores potential overhang from a previous word, e.g. in "R table" if the
@@ -283,9 +277,9 @@
const size_t secondPartLen = secondPart.getLength();
advances.resize(secondPartLen);
overhangs.resize(secondPartLen);
- const float secondPartWidth = run.measureHyphenPiece(
- mTextBuf, secondPart, editForNextLine(hyph), EndHyphenEdit::NO_EDIT,
- advances.data(), overhangs.data());
+ const float secondPartWidth =
+ run.measureHyphenPiece(mTextBuf, secondPart, editForNextLine(hyph),
+ EndHyphenEdit::NO_EDIT, advances.data(), overhangs.data());
// hyphPreBreak is calculated like this so that when the line width for a future line break
// is being calculated, the width of the whole word would be subtracted and the width of the
// second part would be added.
@@ -293,8 +287,8 @@
overhang = computeOverhang(secondPartWidth, advances, overhangs, isRtlWord);
const float secondOverhang = isRtlWord ? overhang.right : overhang.left;
- addWordBreak(j, hyphPreBreak, hyphPostBreak, firstOverhang, secondOverhang,
- postSpaceCount, postSpaceCount, hyphenPenalty, hyph, isRtlWord);
+ addWordBreak(j, hyphPreBreak, hyphPostBreak, firstOverhang, secondOverhang, postSpaceCount,
+ postSpaceCount, hyphenPenalty, hyph, isRtlWord);
}
}
@@ -311,7 +305,7 @@
// a heuristic that seems to perform well
hyphenPenalty = 0.5 * paint->size * paint->scaleX * lineWidth.getAt(0);
if (mHyphenationFrequency == HyphenationFrequency::Normal) {
- hyphenPenalty *= 4.0; // TODO: Replace with a better value after some testing
+ hyphenPenalty *= 4.0; // TODO: Replace with a better value after some testing
}
if (mJustified) {
@@ -325,13 +319,13 @@
}
setLocaleList(run.getLocaleListId(), range.getStart());
- size_t current = (size_t) mWordBreaker->current();
+ size_t current = (size_t)mWordBreaker->current();
// This will keep the index of last code unit seen that's not a line-ending space, plus one.
// In other words, the index of the first code unit after a word.
Range hyphenationContextRange(range.getStart(), range.getStart());
- ParaWidth lastBreakWidth = mWidth; // The width of the text as of the previous break point.
- ParaWidth postBreak = mWidth; // The width of text seen if we decide to break here
+ ParaWidth lastBreakWidth = mWidth; // The width of the text as of the previous break point.
+ ParaWidth postBreak = mWidth; // The width of text seen if we decide to break here
// postBreak plus potential forward overhang. Guaranteed to be >= postBreak.
ParaWidth postBreakWithOverhang = mWidth;
// The maximum amount of backward overhang seen since last word.
@@ -375,8 +369,8 @@
// so we ignore it for now.
const float forwardOverhang =
isRtl ? mMeasuredText.overhangs[i].left : mMeasuredText.overhangs[i].right;
- postBreakWithOverhang = std::max(postBreakWithOverhang,
- postBreak + forwardOverhang);
+ postBreakWithOverhang =
+ std::max(postBreakWithOverhang, postBreak + forwardOverhang);
float backwardOverhang =
isRtl ? mMeasuredText.overhangs[i].right : mMeasuredText.overhangs[i].left;
@@ -385,10 +379,10 @@
maxBackwardOverhang = std::max(maxBackwardOverhang, backwardOverhang);
}
}
- if (i + 1 == current) { // We are at the end of a word.
+ if (i + 1 == current) { // We are at the end of a word.
// We skip breaks for zero-width characters inside replacement spans.
- const bool addBreak = canHyphenate || current == range.getEnd() ||
- mMeasuredText.widths[current] > 0;
+ const bool addBreak =
+ canHyphenate || current == range.getEnd() || mMeasuredText.widths[current] > 0;
if (addBreak) {
// adjust second overhang for previous breaks
@@ -398,17 +392,17 @@
const Range wordRange = mWordBreaker->wordRange();
if (!wordRange.isEmpty() && range.contains(wordRange)) {
addHyphenationCandidates(run, hyphenationContextRange, wordRange,
- lastBreakWidth, postBreak, postSpaceCount, hyphenPenalty);
+ lastBreakWidth, postBreak, postSpaceCount,
+ hyphenPenalty);
}
}
if (addBreak) {
const float penalty = hyphenPenalty * mWordBreaker->breakBadness();
// TODO: overhangs may need adjustment at bidi boundaries.
addWordBreak(current, mWidth /* preBreak */, postBreak,
- postBreakWithOverhang - postBreak /* firstOverhang */,
- 0.0 /* secondOverhang, to be adjusted later */,
- mSpaceCount, postSpaceCount,
- penalty, HyphenationType::DONT_BREAK, isRtl);
+ postBreakWithOverhang - postBreak /* firstOverhang */,
+ 0.0 /* secondOverhang, to be adjusted later */, mSpaceCount,
+ postSpaceCount, penalty, HyphenationType::DONT_BREAK, isRtl);
}
hyphenationContextRange = Range(current, current);
lastBreakWidth = mWidth;
@@ -426,7 +420,7 @@
ParaWidth width = mMeasuredText.widths[start];
for (size_t i = start + 1; i < end; i++) {
const float w = mMeasuredText.widths[i];
- if (w > 0) { // Add desperate breaks only before grapheme clusters.
+ if (w > 0) { // Add desperate breaks only before grapheme clusters.
const ParaWidth newWidth = width + w;
if (!fitsOnCurrentLine(newWidth, 0.0, 0.0, lineWidth)) {
const Candidate& lastGreedyBreak = getLastBreakCandidate();
@@ -453,10 +447,11 @@
// Add a word break (possibly for a hyphenated fragment).
inline void LineBreaker::addWordBreak(size_t offset, ParaWidth preBreak, ParaWidth postBreak,
- float firstOverhang, float secondOverhang, size_t preSpaceCount, size_t postSpaceCount,
- float penalty, HyphenationType hyph, bool isRtl) {
+ float firstOverhang, float secondOverhang,
+ size_t preSpaceCount, size_t postSpaceCount, float penalty,
+ HyphenationType hyph, bool isRtl) {
mCandidates.push_back({offset, preBreak, postBreak, firstOverhang, secondOverhang, penalty,
- preSpaceCount, postSpaceCount, hyph, isRtl});
+ preSpaceCount, postSpaceCount, hyph, isRtl});
}
// Go back and adjust earlier line breaks if needed.
@@ -472,8 +467,7 @@
// No more remaining overhang. We don't need to adjust anything anymore.
return;
}
- mCandidates[i].secondOverhang = std::max(mCandidates[i].secondOverhang,
- remainingOverhang);
+ mCandidates[i].secondOverhang = std::max(mCandidates[i].secondOverhang, remainingOverhang);
}
}
@@ -490,11 +484,10 @@
void LineBreaker::addGreedyBreak(size_t breakIndex) {
const Candidate& candidate = mCandidates[breakIndex];
const Candidate& lastGreedyBreak = getLastBreakCandidate();
- pushBreak(candidate.offset,
- candidate.postBreak - lastGreedyBreak.preBreak,
- computeMaxExtent(lastGreedyBreak.offset, candidate.offset),
- packHyphenEdit(editForNextLine(lastGreedyBreak.hyphenType),
- editForThisLine(candidate.hyphenType)));
+ pushBreak(candidate.offset, candidate.postBreak - lastGreedyBreak.preBreak,
+ computeMaxExtent(lastGreedyBreak.offset, candidate.offset),
+ packHyphenEdit(editForNextLine(lastGreedyBreak.hyphenType),
+ editForThisLine(candidate.hyphenType)));
mLastGreedyBreakIndex = breakIndex;
}
@@ -511,8 +504,8 @@
leftOverhang = lastGreedyBreak->secondOverhang;
rightOverhang = cand->firstOverhang;
}
- while (!fitsOnCurrentLine(cand->postBreak - lastGreedyBreak->preBreak,
- leftOverhang, rightOverhang, lineWidth)) {
+ while (!fitsOnCurrentLine(cand->postBreak - lastGreedyBreak->preBreak, leftOverhang,
+ rightOverhang, lineWidth)) {
// This break would create an overfull line, pick the best break and break there (greedy).
// We do this in a loop, since there's no guarantee that after a break the remaining text
// would fit on the next line.
@@ -524,7 +517,7 @@
// Add desperate breaks starting immediately after the last break.
addDesperateBreaksGreedy(lastGreedyBreak->preBreak, lastGreedyBreak->offset,
- cand->offset, lineWidth);
+ cand->offset, lineWidth);
break;
} else {
// Break at the best known break.
@@ -602,11 +595,10 @@
const Candidate* lastCandidate = &mCandidates.back();
if (mCandidates.size() == 1 || mLastGreedyBreakIndex != (mCandidates.size() - 1)) {
const Candidate& lastGreedyBreak = getLastBreakCandidate();
- pushBreak(lastCandidate->offset,
- lastCandidate->postBreak - lastGreedyBreak.preBreak,
- computeMaxExtent(lastGreedyBreak.offset, lastCandidate->offset),
- packHyphenEdit(editForNextLine(lastGreedyBreak.hyphenType),
- EndHyphenEdit::NO_EDIT));
+ pushBreak(lastCandidate->offset, lastCandidate->postBreak - lastGreedyBreak.preBreak,
+ computeMaxExtent(lastGreedyBreak.offset, lastCandidate->offset),
+ packHyphenEdit(editForNextLine(lastGreedyBreak.hyphenType),
+ EndHyphenEdit::NO_EDIT));
// No need to update mLastGreedyBreakIndex because we're done.
}
}
@@ -615,18 +607,19 @@
// Note: these breaks are based on the shaping of the (non-broken) original text; they
// are imprecise especially in the presence of kerning, ligatures, overhangs, and Arabic shaping.
void LineBreaker::addDesperateBreaksOptimal(std::vector<Candidate>* out, ParaWidth existingPreBreak,
- size_t postSpaceCount, bool isRtl, size_t start, size_t end) {
+ size_t postSpaceCount, bool isRtl, size_t start,
+ size_t end) {
ParaWidth width = existingPreBreak + mMeasuredText.widths[start];
for (size_t i = start + 1; i < end; i++) {
const float w = mMeasuredText.widths[i];
- if (w > 0) { // Add desperate breaks only before grapheme clusters.
+ if (w > 0) { // Add desperate breaks only before grapheme clusters.
out->push_back({i /* offset */, width /* preBreak */, width /* postBreak */,
- 0.0 /* firstOverhang */, 0.0 /* secondOverhang */,
- SCORE_DESPERATE /* penalty */,
- // postSpaceCount doesn't include trailing spaces.
- postSpaceCount /* preSpaceCount */, postSpaceCount /* postSpaceCount */,
- HyphenationType::BREAK_AND_DONT_INSERT_HYPHEN /* hyphenType */,
- isRtl /* isRtl */});
+ 0.0 /* firstOverhang */, 0.0 /* secondOverhang */,
+ SCORE_DESPERATE /* penalty */,
+ // postSpaceCount doesn't include trailing spaces.
+ postSpaceCount /* preSpaceCount */, postSpaceCount /* postSpaceCount */,
+ HyphenationType::BREAK_AND_DONT_INSERT_HYPHEN /* hyphenType */,
+ isRtl /* isRtl */});
width += w;
}
}
@@ -644,7 +637,7 @@
break;
}
}
- if (firstDesperateIndex == 0) { // No desperate breaks needed.
+ if (firstDesperateIndex == 0) { // No desperate breaks needed.
return;
}
@@ -652,15 +645,15 @@
// mCandidates. The beginning of mCandidates, where there are no desparate breaks, is skipped.
std::vector<Candidate> expandedCandidates;
const size_t nRemainingCandidates = nCand - firstDesperateIndex;
- expandedCandidates.reserve(nRemainingCandidates + 1); // At least one more is needed.
+ expandedCandidates.reserve(nRemainingCandidates + 1); // At least one more is needed.
for (size_t i = firstDesperateIndex; i < nCand; i++) {
const Candidate& previousCand = mCandidates[i - 1];
const Candidate& thisCand = mCandidates[i];
const ParaWidth requiredWidth = thisCand.postBreak - previousCand.preBreak;
if (requiredWidth > minLineWidth) {
addDesperateBreaksOptimal(&expandedCandidates, previousCand.preBreak,
- thisCand.postSpaceCount, thisCand.isRtl, previousCand.offset /* start */,
- thisCand.offset /* end */);
+ thisCand.postSpaceCount, thisCand.isRtl,
+ previousCand.offset /* start */, thisCand.offset /* end */);
}
expandedCandidates.push_back(thisCand);
}
@@ -690,9 +683,10 @@
mAscents.push_back(extent.ascent);
mDescents.push_back(extent.descent);
- const HyphenEdit edit = packHyphenEdit(
- prev == 0 ? StartHyphenEdit::NO_EDIT : editForNextLine(mCandidates[prev].hyphenType),
- editForThisLine(mCandidates[i].hyphenType));
+ const HyphenEdit edit =
+ packHyphenEdit(prev == 0 ? StartHyphenEdit::NO_EDIT
+ : editForNextLine(mCandidates[prev].hyphenType),
+ editForThisLine(mCandidates[i].hyphenType));
mFlags.push_back(static_cast<int>(edit));
}
std::reverse(mBreaks.begin(), mBreaks.end());
@@ -707,7 +701,7 @@
std::vector<OptimalBreaksData> breaksData;
breaksData.reserve(nCand);
- breaksData.push_back({0.0, 0, 0}); // The first candidate is always at the first line.
+ breaksData.push_back({0.0, 0, 0}); // The first candidate is always at the first line.
// "i" iterates through candidates for the end of the line.
for (size_t i = 1; i < nCand; i++) {
@@ -752,8 +746,8 @@
} else {
widthScore = delta * delta;
if (delta < 0) {
- if (-delta < maxShrink *
- (mCandidates[i].postSpaceCount - mCandidates[j].preSpaceCount)) {
+ if (-delta < maxShrink * (mCandidates[i].postSpaceCount -
+ mCandidates[j].preSpaceCount)) {
widthScore *= SHRINK_PENALTY_MULTIPLIER;
} else {
widthScore = SCORE_OVERFULL;
@@ -773,17 +767,15 @@
bestPrev = j;
}
}
- breaksData.push_back({
- best + mCandidates[i].penalty + mLinePenalty, // score
- bestPrev, // prev
- breaksData[bestPrev].lineNumber + 1}); // lineNumber
+ breaksData.push_back({best + mCandidates[i].penalty + mLinePenalty, // score
+ bestPrev, // prev
+ breaksData[bestPrev].lineNumber + 1}); // lineNumber
}
finishBreaksOptimal(breaksData);
}
LineBreakResult LineBreaker::computeBreaks(const std::vector<std::unique_ptr<Run>>& runs,
- const LineWidth& lineWidth,
- const TabStops& tabStops) {
+ const LineWidth& lineWidth, const TabStops& tabStops) {
for (const auto& run : runs) {
addRun(*run, lineWidth, tabStops);
}
@@ -814,10 +806,10 @@
if (!mBestGreedyBreaks.empty()) {
// Find the location in the queue where the penalty is <= the current penalty, and drop the
// elements from there to the end of the queue.
- auto where = std::lower_bound(
- mBestGreedyBreaks.begin(), mBestGreedyBreaks.end(), gBreak,
- [](GreedyBreak first, GreedyBreak second) -> bool
- { return first.penalty < second.penalty; });
+ auto where = std::lower_bound(mBestGreedyBreaks.begin(), mBestGreedyBreaks.end(), gBreak,
+ [](GreedyBreak first, GreedyBreak second) -> bool {
+ return first.penalty < second.penalty;
+ });
if (where != mBestGreedyBreaks.end()) {
mBestGreedyBreaks.erase(where, mBestGreedyBreaks.end());
}
diff --git a/libs/minikin/Locale.cpp b/libs/minikin/Locale.cpp
index 9df26bf..aad8cfd 100644
--- a/libs/minikin/Locale.cpp
+++ b/libs/minikin/Locale.cpp
@@ -21,8 +21,9 @@
#include <hb.h>
#include "minikin/LocaleList.h"
-#include "MinikinInternal.h"
+
#include "LocaleListCache.h"
+#include "MinikinInternal.h"
#include "StringPiece.h"
namespace minikin {
@@ -42,8 +43,8 @@
if (strncmp(buf, subtag, subtagLen) != 0) {
return false; // no match between two strings
}
- return (bufLen == subtagLen || buf[subtagLen] == '\0' ||
- buf[subtagLen] == '-' || buf[subtagLen] == '_');
+ return (bufLen == subtagLen || buf[subtagLen] == '\0' || buf[subtagLen] == '-' ||
+ buf[subtagLen] == '_');
}
// Pack the three letter code into 15 bits and stored to 16 bit integer. The highest bit is 0.
@@ -54,20 +55,18 @@
//
// In case of two letter code, use fullbit(0x1f) for the first letter instead.
static uint16_t packLanguageOrRegion(const StringPiece& in, uint8_t twoLetterBase,
- uint8_t threeLetterBase) {
+ uint8_t threeLetterBase) {
if (in.length() == 2) {
return 0x7c00u | // 0x1fu << 10
- (uint16_t)(in[0] - twoLetterBase) << 5 |
- (uint16_t)(in[1] - twoLetterBase);
+ (uint16_t)(in[0] - twoLetterBase) << 5 | (uint16_t)(in[1] - twoLetterBase);
} else {
return ((uint16_t)(in[0] - threeLetterBase) << 10) |
- (uint16_t)(in[1] - threeLetterBase) << 5 |
- (uint16_t)(in[2] - threeLetterBase);
+ (uint16_t)(in[1] - threeLetterBase) << 5 | (uint16_t)(in[2] - threeLetterBase);
}
}
static size_t unpackLanguageOrRegion(uint16_t in, char* out, uint8_t twoLetterBase,
- uint8_t threeLetterBase) {
+ uint8_t threeLetterBase) {
uint8_t first = (in >> 10) & FIVE_BITS;
uint8_t second = (in >> 5) & FIVE_BITS;
uint8_t third = in & FIVE_BITS;
@@ -96,7 +95,7 @@
constexpr char FIRST_LETTER_BASE = 'A';
constexpr char REST_LETTER_BASE = 'a';
return ((uint32_t)(c1 - FIRST_LETTER_BASE) << 15) | (uint32_t)(c2 - REST_LETTER_BASE) << 10 |
- ((uint32_t)(c3 - REST_LETTER_BASE) << 5) | (uint32_t)(c4 - REST_LETTER_BASE);
+ ((uint32_t)(c3 - REST_LETTER_BASE) << 5) | (uint32_t)(c4 - REST_LETTER_BASE);
}
constexpr uint32_t packScript(uint32_t script) {
@@ -146,13 +145,13 @@
// Returns true if buffer is valid for script code. The length of buffer must be 4.
static inline bool isValidScriptCode(const StringPiece& buffer) {
return buffer.size() == 4 && isUppercase(buffer[0]) && isLowercase(buffer[1]) &&
- isLowercase(buffer[2]) && isLowercase(buffer[3]);
+ isLowercase(buffer[2]) && isLowercase(buffer[3]);
}
// Returns true if the buffer is valid for region code.
static inline bool isValidRegionCode(const StringPiece& buffer) {
return (buffer.size() == 2 && isUppercase(buffer[0]) && isUppercase(buffer[1])) ||
- (buffer.size() == 3 && isDigit(buffer[0]) && isDigit(buffer[1]) && isDigit(buffer[2]));
+ (buffer.size() == 3 && isDigit(buffer[0]) && isDigit(buffer[1]) && isDigit(buffer[2]));
}
// Parse BCP 47 language identifier into internal structure
@@ -224,15 +223,15 @@
const size_t kMinSubtagLength = 10;
if (length >= kMinSubtagLength) {
static const char kPrefix[] = "-u-em-";
- const char *pos = std::search(buf, buf + length, kPrefix, kPrefix + strlen(kPrefix));
+ const char* pos = std::search(buf, buf + length, kPrefix, kPrefix + strlen(kPrefix));
if (pos != buf + length) { // found
pos += strlen(kPrefix);
const size_t remainingLength = length - (pos - buf);
- if (isEmojiSubtag(pos, remainingLength, "emoji", 5)){
+ if (isEmojiSubtag(pos, remainingLength, "emoji", 5)) {
return EMSTYLE_EMOJI;
- } else if (isEmojiSubtag(pos, remainingLength, "text", 4)){
+ } else if (isEmojiSubtag(pos, remainingLength, "text", 4)) {
return EMSTYLE_TEXT;
- } else if (isEmojiSubtag(pos, remainingLength, "default", 7)){
+ } else if (isEmojiSubtag(pos, remainingLength, "default", 7)) {
return EMSTYLE_DEFAULT;
}
}
@@ -250,7 +249,7 @@
return EMSTYLE_EMPTY;
}
-//static
+// static
uint8_t Locale::scriptToSubScriptBits(uint32_t script) {
uint8_t subScriptBits = 0u;
switch (script) {
@@ -381,15 +380,14 @@
bool scriptMatch = false;
for (size_t i = 0; i < supported.size(); ++i) {
- if (mEmojiStyle != EMSTYLE_EMPTY &&
- mEmojiStyle == supported[i].mEmojiStyle) {
+ if (mEmojiStyle != EMSTYLE_EMPTY && mEmojiStyle == supported[i].mEmojiStyle) {
subtagMatch = true;
if (mLanguage == supported[i].mLanguage) {
return 4;
}
}
if (isEqualScript(supported[i]) ||
- supportsScript(supported[i].mSubScriptBits, mSubScriptBits)) {
+ supportsScript(supported[i].mSubScriptBits, mSubScriptBits)) {
scriptMatch = true;
if (mLanguage == supported[i].mLanguage) {
languageScriptMatch = true;
@@ -415,12 +413,11 @@
}
static hb_language_t buildHbLanguage(const Locale& locale) {
- return locale.isSupported() ?
- hb_language_from_string(locale.getString().c_str(), -1) : HB_LANGUAGE_INVALID;
+ return locale.isSupported() ? hb_language_from_string(locale.getString().c_str(), -1)
+ : HB_LANGUAGE_INVALID;
}
-LocaleList::LocaleList(std::vector<Locale>&& locales)
- : mLocales(std::move(locales)) {
+LocaleList::LocaleList(std::vector<Locale>&& locales) : mLocales(std::move(locales)) {
if (mLocales.empty()) {
return;
}
@@ -439,8 +436,6 @@
}
mHbLangs.push_back(buildHbLanguage(locale));
}
-
-
}
} // namespace minikin
diff --git a/libs/minikin/Locale.h b/libs/minikin/Locale.h
index e4a731c..3ed81be 100644
--- a/libs/minikin/Locale.h
+++ b/libs/minikin/Locale.h
@@ -39,13 +39,13 @@
// Enum for making sub-locale from FontLangauge.
enum class SubtagBits : uint8_t {
- EMPTY = 0b00000000,
+ EMPTY = 0b00000000,
LANGUAGE = 0b00000001,
- SCRIPT = 0b00000010,
- REGION = 0b00000100,
- VARIANT = 0b00001000,
- EMOJI = 0b00010000,
- ALL = 0b00011111,
+ SCRIPT = 0b00000010,
+ REGION = 0b00000100,
+ VARIANT = 0b00001000,
+ EMOJI = 0b00010000,
+ ALL = 0b00011111,
};
inline constexpr SubtagBits operator&(SubtagBits l, SubtagBits r) {
@@ -76,24 +76,22 @@
// Default constructor creates the unsupported locale.
Locale()
: mScript(NO_SCRIPT),
- mLanguage(NO_LANGUAGE),
- mRegion(NO_REGION),
- mSubScriptBits(0ul),
- mVariant(Variant::NO_VARIANT),
- mEmojiStyle(EMSTYLE_EMPTY) {}
+ mLanguage(NO_LANGUAGE),
+ mRegion(NO_REGION),
+ mSubScriptBits(0ul),
+ mVariant(Variant::NO_VARIANT),
+ mEmojiStyle(EMSTYLE_EMPTY) {}
// Parse from string
Locale(const StringPiece& buf);
bool operator==(const Locale other) const {
return !isUnsupported() && isEqualScript(other) && mLanguage == other.mLanguage &&
- mRegion == other.mRegion && mVariant == other.mVariant &&
- mEmojiStyle == other.mEmojiStyle;
+ mRegion == other.mRegion && mVariant == other.mVariant &&
+ mEmojiStyle == other.mEmojiStyle;
}
- bool operator!=(const Locale other) const {
- return !(*this == other);
- }
+ bool operator!=(const Locale other) const { return !(*this == other); }
inline bool hasLanguage() const { return mLanguage != NO_LANGUAGE; }
inline bool hasScript() const { return mScript != NO_SCRIPT; }
@@ -105,9 +103,7 @@
return hasLanguage() || hasScript() || hasRegion() || hasVariant() || hasEmojiStyle();
}
- inline bool isUnsupported() const {
- return !isSupported();
- }
+ inline bool isUnsupported() const { return !isSupported(); }
EmojiStyle getEmojiStyle() const { return mEmojiStyle; }
@@ -126,7 +122,7 @@
uint64_t getIdentifier() const {
return ((uint64_t)mLanguage << 49) | ((uint64_t)mScript << 29) | ((uint64_t)mRegion << 14) |
- ((uint64_t)mEmojiStyle << 12) | (uint64_t)mVariant;
+ ((uint64_t)mEmojiStyle << 12) | (uint64_t)mVariant;
}
Locale getPartialLocale(SubtagBits bits) const;
@@ -180,7 +176,7 @@
size_t size() const { return mLocales.size(); }
bool empty() const { return mLocales.empty(); }
- const Locale& operator[] (size_t n) const { return mLocales[n]; }
+ const Locale& operator[](size_t n) const { return mLocales[n]; }
hb_language_t getHbLanguage(size_t n) const { return mHbLangs[n]; }
diff --git a/libs/minikin/LocaleListCache.cpp b/libs/minikin/LocaleListCache.cpp
index 883e25d..625b4d2 100644
--- a/libs/minikin/LocaleListCache.cpp
+++ b/libs/minikin/LocaleListCache.cpp
@@ -51,7 +51,7 @@
// Preserve "und" and "und-****" since uloc_addLikelySubtags changes "und" to "en-Latn-US".
if (strncmp(output, "und", 3) == 0 &&
- (outLength == 3 || (outLength == 8 && output[3] == '_'))) {
+ (outLength == 3 || (outLength == 8 && output[3] == '_'))) {
output[3] = '-'; // to be language tag.
return outLength;
}
diff --git a/libs/minikin/Measurement.cpp b/libs/minikin/Measurement.cpp
index 03cce9f..5d110c4 100644
--- a/libs/minikin/Measurement.cpp
+++ b/libs/minikin/Measurement.cpp
@@ -27,7 +27,7 @@
// are separate.
static float getRunAdvance(const float* advances, const uint16_t* buf, size_t layoutStart,
- size_t start, size_t count, size_t offset) {
+ size_t start, size_t count, size_t offset) {
float advance = 0.0f;
size_t lastCluster = start;
float clusterWidth = 0.0f;
@@ -51,8 +51,8 @@
int numGraphemeClustersAfter = 0;
for (size_t i = lastCluster; i < nextCluster; i++) {
bool isAfter = i >= offset;
- if (GraphemeBreak::isGraphemeBreak(
- advances + (start - layoutStart), buf, start, count, i)) {
+ if (GraphemeBreak::isGraphemeBreak(advances + (start - layoutStart), buf, start, count,
+ i)) {
numGraphemeClusters++;
if (isAfter) {
numGraphemeClustersAfter++;
@@ -67,7 +67,7 @@
}
float getRunAdvance(const float* advances, const uint16_t* buf, size_t start, size_t count,
- size_t offset) {
+ size_t offset) {
return getRunAdvance(advances, buf, start, start, count, offset);
}
@@ -80,7 +80,7 @@
* search within the cluster and grapheme breaks.
*/
size_t getOffsetForAdvance(const float* advances, const uint16_t* buf, size_t start, size_t count,
- float advance) {
+ float advance) {
float x = 0.0f, xLastClusterStart = 0.0f, xSearchStart = 0.0f;
size_t lastClusterStart = start, searchStart = start;
for (size_t i = start; i < start + count; i++) {
@@ -105,7 +105,7 @@
// "getRunAdvance(layout, buf, start, count, i) - advance" but more efficient
float delta = getRunAdvance(advances, buf, start, searchStart, count - searchStart, i)
- + xSearchStart - advance;
+ + xSearchStart - advance;
if (std::abs(delta) < bestDist) {
bestDist = std::abs(delta);
best = i;
diff --git a/libs/minikin/MinikinInternal.h b/libs/minikin/MinikinInternal.h
index 2d733c3..bffda70 100644
--- a/libs/minikin/MinikinInternal.h
+++ b/libs/minikin/MinikinInternal.h
@@ -70,21 +70,16 @@
public:
// Takes ownership of hb_blob_t object, caller is no longer
// responsible for calling hb_blob_destroy().
- explicit HbBlob(hb_blob_t* blob) : mBlob(blob) {
- }
+ explicit HbBlob(hb_blob_t* blob) : mBlob(blob) {}
- ~HbBlob() {
- hb_blob_destroy(mBlob);
- }
+ ~HbBlob() { hb_blob_destroy(mBlob); }
const uint8_t* get() const {
const char* data = hb_blob_get_data(mBlob, nullptr);
return reinterpret_cast<const uint8_t*>(data);
}
- size_t size() const {
- return (size_t)hb_blob_get_length(mBlob);
- }
+ size_t size() const { return (size_t)hb_blob_get_length(mBlob); }
private:
hb_blob_t* mBlob;
diff --git a/libs/minikin/SparseBitSet.cpp b/libs/minikin/SparseBitSet.cpp
index afbe851..66d6c02 100644
--- a/libs/minikin/SparseBitSet.cpp
+++ b/libs/minikin/SparseBitSet.cpp
@@ -80,11 +80,11 @@
}
size_t index = ((currentPage - 1) << (kLogValuesPerPage - kLogBitsPerEl)) +
- ((start & kPageMask) >> kLogBitsPerEl);
+ ((start & kPageMask) >> kLogBitsPerEl);
size_t nElements = (end - (start & ~kElMask) + kElMask) >> kLogBitsPerEl;
if (nElements == 1) {
- mBitmaps[index] |= (kElAllOnes >> (start & kElMask)) &
- (kElAllOnes << ((~end + 1) & kElMask));
+ mBitmaps[index] |=
+ (kElAllOnes >> (start & kElMask)) & (kElAllOnes << ((~end + 1) & kElMask));
} else {
mBitmaps[index] |= kElAllOnes >> (start & kElMask);
for (size_t j = 1; j < nElements - 1; j++) {
diff --git a/libs/minikin/StringPiece.h b/libs/minikin/StringPiece.h
index 5394ef2..befb312 100644
--- a/libs/minikin/StringPiece.h
+++ b/libs/minikin/StringPiece.h
@@ -35,7 +35,7 @@
inline size_t size() const { return mLength; }
inline bool empty() const { return mLength == 0; }
- inline char operator[] (size_t i) const { return mData[i]; }
+ inline char operator[](size_t i) const { return mData[i]; }
inline StringPiece substr(size_t from, size_t length) const {
return StringPiece(mData + from, length);
@@ -49,16 +49,14 @@
return p == nullptr ? mLength : p - mData;
}
- std::string toString() const {
- return std::string(mData, mData + mLength);
- }
+ std::string toString() const { return std::string(mData, mData + mLength); }
private:
const char* mData;
size_t mLength;
};
-inline bool operator== (const StringPiece& l, const StringPiece& r) {
+inline bool operator==(const StringPiece& l, const StringPiece& r) {
const size_t len = l.size();
if (len != r.size()) {
return false;
@@ -71,7 +69,7 @@
return memcmp(lData, rData, len) == 0;
}
-inline bool operator== (const StringPiece& l, const char* s) {
+inline bool operator==(const StringPiece& l, const char* s) {
const size_t len = l.size();
if (len != strlen(s)) {
return false;
@@ -79,18 +77,18 @@
return memcmp(l.data(), s, len) == 0;
}
-inline bool operator!= (const StringPiece& l, const StringPiece& r) {
+inline bool operator!=(const StringPiece& l, const StringPiece& r) {
return !(l == r);
}
-inline bool operator!= (const StringPiece& l, const char* s) {
+inline bool operator!=(const StringPiece& l, const char* s) {
return !(l == s);
}
class SplitIterator {
public:
- SplitIterator(const StringPiece& string, char delimiter) :
- mStarted(false), mCurrent(0), mString(string), mDelimiter(delimiter) {}
+ SplitIterator(const StringPiece& string, char delimiter)
+ : mStarted(false), mCurrent(0), mString(string), mDelimiter(delimiter) {}
inline StringPiece next() {
if (!hasNext()) {
@@ -102,6 +100,7 @@
return mString.substr(searchFrom, mCurrent - searchFrom);
}
inline bool hasNext() const { return mCurrent < mString.size(); }
+
private:
bool mStarted;
size_t mCurrent;
diff --git a/libs/minikin/WordBreaker.cpp b/libs/minikin/WordBreaker.cpp
index be31b5b..12d64f8 100644
--- a/libs/minikin/WordBreaker.cpp
+++ b/libs/minikin/WordBreaker.cpp
@@ -24,6 +24,7 @@
#include "minikin/Emoji.h"
#include "minikin/Hyphenator.h"
+
#include "Locale.h"
#include "MinikinInternal.h"
@@ -33,8 +34,9 @@
static icu::BreakIterator* createNewIterator(const Locale& locale) {
// TODO: handle failure status
UErrorCode status = U_ZERO_ERROR;
- return icu::BreakIterator::createLineInstance(locale.isUnsupported() ?
- icu::Locale::getRoot() : icu::Locale::createFromName(locale.getString().c_str()),
+ return icu::BreakIterator::createLineInstance(
+ locale.isUnsupported() ? icu::Locale::getRoot()
+ : icu::Locale::createFromName(locale.getString().c_str()),
status);
}
} // namespace
@@ -51,7 +53,7 @@
}
// Not found in pool. Create new one.
- return { id, std::unique_ptr<icu::BreakIterator>(createNewIterator(locale)) };
+ return {id, std::unique_ptr<icu::BreakIterator>(createNewIterator(locale))};
}
void ICULineBreakerPoolImpl::release(ICULineBreakerPool::Slot&& slot) {
@@ -68,11 +70,9 @@
mPool.push_front(std::move(slot));
}
-WordBreaker::WordBreaker() : mPool(&ICULineBreakerPoolImpl::getInstance()) {
-}
+WordBreaker::WordBreaker() : mPool(&ICULineBreakerPoolImpl::getInstance()) {}
-WordBreaker::WordBreaker(ICULineBreakerPool* pool) : mPool(pool) {
-}
+WordBreaker::WordBreaker(ICULineBreakerPool* pool) : mPool(pool) {}
ssize_t WordBreaker::followingWithLocale(const Locale& locale, size_t from) {
mIcuBreaker = mPool->acquire(locale);
@@ -175,8 +175,8 @@
// Chicago Manual of Style recommends breaking before these characters in URLs and email addresses
static bool breakBefore(uint16_t c) {
- return c == '~' || c == '.' || c == ',' || c == '-' || c == '_' || c == '?' || c == '#'
- || c == '%' || c == '=' || c == '&';
+ return c == '~' || c == '.' || c == ',' || c == '-' || c == '_' || c == '?' || c == '#' ||
+ c == '%' || c == '=' || c == '&';
}
enum ScanState {
@@ -245,7 +245,7 @@
}
// break before single slash
if (thisChar == '/' && lastChar != '/' &&
- !(i + 1 < mScanOffset && mText[i + 1] == '/')) {
+ !(i + 1 < mScanOffset && mText[i + 1] == '/')) {
break;
}
}
@@ -261,7 +261,7 @@
if (mInEmailOrUrl) {
mCurrent = findNextBreakInEmailOrUrl();
} else { // Business as usual
- mCurrent = (ssize_t) iteratorNext();
+ mCurrent = (ssize_t)iteratorNext();
}
return mCurrent;
}
diff --git a/libs/minikin/WordBreaker.h b/libs/minikin/WordBreaker.h
index da33059..84d1d62 100644
--- a/libs/minikin/WordBreaker.h
+++ b/libs/minikin/WordBreaker.h
@@ -28,6 +28,7 @@
#include <unicode/brkiter.h>
#include "minikin/Range.h"
+
#include "Locale.h"
namespace minikin {
@@ -71,7 +72,7 @@
protected:
// protected for testing purposes.
static constexpr size_t MAX_POOL_SIZE = 4;
- ICULineBreakerPoolImpl() {}; // singleton.
+ ICULineBreakerPoolImpl(){}; // singleton.
size_t getPoolSize() const { return mPool.size(); }
private:
@@ -80,9 +81,7 @@
class WordBreaker {
public:
- virtual ~WordBreaker() {
- finish();
- }
+ virtual ~WordBreaker() { finish(); }
WordBreaker();
diff --git a/tests/perftests/FontCollection.cpp b/tests/perftests/FontCollection.cpp
index 377d86f..0829818 100644
--- a/tests/perftests/FontCollection.cpp
+++ b/tests/perftests/FontCollection.cpp
@@ -21,9 +21,10 @@
#include <benchmark/benchmark.h>
#include "minikin/LocaleList.h"
+
#include "FontTestUtils.h"
-#include "UnicodeUtils.h"
#include "MinikinInternal.h"
+#include "UnicodeUtils.h"
namespace minikin {
@@ -58,22 +59,23 @@
// TODO: Rewrite with BENCHMARK_CAPTURE for better test name.
BENCHMARK(BM_FontCollection_hasVariationSelector)
- ->ArgPair(0x2708, 0xFE0F)
- ->ArgPair(0x2708, 0xFE0E)
- ->ArgPair(0x3402, 0xE0100);
+ ->ArgPair(0x2708, 0xFE0F)
+ ->ArgPair(0x2708, 0xFE0E)
+ ->ArgPair(0x3402, 0xE0100);
struct ItemizeTestCases {
std::string itemizeText;
std::string languageTag;
std::string labelText;
} ITEMIZE_TEST_CASES[] = {
- { "'A' 'n' 'd' 'r' 'o' 'i' 'd'", "en", "English" },
- { "U+4E16", "zh-Hans", "CJK Ideograph" },
- { "U+4E16", "zh-Hans,zh-Hant,ja,en,es,pt,fr,de", "CJK Ideograph with many language fallback" },
- { "U+3402 U+E0100", "ja", "CJK Ideograph with variation selector" },
- { "'A' 'n' U+0E1A U+0E31 U+0645 U+062D U+0648", "en", "Mixture of English, Thai and Arabic" },
- { "U+2708 U+FE0E", "en", "Emoji with variation selector" },
- { "U+0031 U+FE0F U+20E3", "en", "KEYCAP" },
+ {"'A' 'n' 'd' 'r' 'o' 'i' 'd'", "en", "English"},
+ {"U+4E16", "zh-Hans", "CJK Ideograph"},
+ {"U+4E16", "zh-Hans,zh-Hant,ja,en,es,pt,fr,de",
+ "CJK Ideograph with many language fallback"},
+ {"U+3402 U+E0100", "ja", "CJK Ideograph with variation selector"},
+ {"'A' 'n' U+0E1A U+0E31 U+0645 U+062D U+0648", "en", "Mixture of English, Thai and Arabic"},
+ {"U+2708 U+FE0E", "en", "Emoji with variation selector"},
+ {"U+0031 U+FE0F U+20E3", "en", "KEYCAP"},
};
static void BM_FontCollection_itemize(benchmark::State& state) {
@@ -85,8 +87,8 @@
uint16_t buffer[64];
size_t utf16_length = 0;
- ParseUnicode(
- buffer, 64, ITEMIZE_TEST_CASES[testIndex].itemizeText.c_str(), &utf16_length, nullptr);
+ ParseUnicode(buffer, 64, ITEMIZE_TEST_CASES[testIndex].itemizeText.c_str(), &utf16_length,
+ nullptr);
std::vector<FontCollection::Run> result;
MinikinPaint paint;
paint.localeListId = registerLocaleList(ITEMIZE_TEST_CASES[testIndex].languageTag);
@@ -99,7 +101,6 @@
}
// TODO: Rewrite with BENCHMARK_CAPTURE once it is available in Android.
-BENCHMARK(BM_FontCollection_itemize)
- ->Arg(0)->Arg(1)->Arg(2)->Arg(3)->Arg(4)->Arg(5)->Arg(6);
+BENCHMARK(BM_FontCollection_itemize)->Arg(0)->Arg(1)->Arg(2)->Arg(3)->Arg(4)->Arg(5)->Arg(6);
} // namespace minikin
diff --git a/tests/perftests/FontFamily.cpp b/tests/perftests/FontFamily.cpp
index 2bf8914..ceeae47 100644
--- a/tests/perftests/FontFamily.cpp
+++ b/tests/perftests/FontFamily.cpp
@@ -27,8 +27,8 @@
std::make_shared<MinikinFontForTest>("/system/fonts/NotoSansCJK-Regular.ttc", 0);
while (state.KeepRunning()) {
- std::shared_ptr<FontFamily> family = std::make_shared<FontFamily>(
- std::vector<Font>({Font(minikinFont, FontStyle())}));
+ std::shared_ptr<FontFamily> family =
+ std::make_shared<FontFamily>(std::vector<Font>({Font(minikinFont, FontStyle())}));
}
}
diff --git a/tests/perftests/GraphemeBreak.cpp b/tests/perftests/GraphemeBreak.cpp
index a3e06d7..af156c8 100644
--- a/tests/perftests/GraphemeBreak.cpp
+++ b/tests/perftests/GraphemeBreak.cpp
@@ -43,9 +43,9 @@
}
}
BENCHMARK(BM_GraphemeBreak_Ascii)
- ->Arg(0) // Begining of the text.
- ->Arg(1) // Middle of the text.
- ->Arg(12); // End of the text.
+ ->Arg(0) // Begining of the text.
+ ->Arg(1) // Middle of the text.
+ ->Arg(12); // End of the text.
static void BM_GraphemeBreak_Emoji(benchmark::State& state) {
size_t result_size;
@@ -58,9 +58,9 @@
}
}
BENCHMARK(BM_GraphemeBreak_Emoji)
- ->Arg(1) // Middle of emoji modifier sequence.
- ->Arg(2) // Middle of the surrogate pairs.
- ->Arg(3); // After emoji modifier sequence. Here is boundary of grapheme cluster.
+ ->Arg(1) // Middle of emoji modifier sequence.
+ ->Arg(2) // Middle of the surrogate pairs.
+ ->Arg(3); // After emoji modifier sequence. Here is boundary of grapheme cluster.
static void BM_GraphemeBreak_Emoji_Flags(benchmark::State& state) {
size_t result_size;
@@ -73,8 +73,8 @@
}
}
BENCHMARK(BM_GraphemeBreak_Emoji_Flags)
- ->Arg(2) // Middle of flag sequence.
- ->Arg(4) // After flag sequence. Here is boundary of grapheme cluster.
- ->Arg(10); // Middle of 3rd flag sequence.
+ ->Arg(2) // Middle of flag sequence.
+ ->Arg(4) // After flag sequence. Here is boundary of grapheme cluster.
+ ->Arg(10); // Middle of 3rd flag sequence.
} // namespace minikin
diff --git a/tests/perftests/Hyphenator.cpp b/tests/perftests/Hyphenator.cpp
index 2dfc324..253c0f4 100644
--- a/tests/perftests/Hyphenator.cpp
+++ b/tests/perftests/Hyphenator.cpp
@@ -27,8 +27,8 @@
const int enUsMinSuffix = 3;
static void BM_Hyphenator_short_word(benchmark::State& state) {
- Hyphenator* hyphenator = Hyphenator::loadBinary(
- readWholeFile(enUsHyph).data(), enUsMinPrefix, enUsMinSuffix, "en");
+ Hyphenator* hyphenator = Hyphenator::loadBinary(readWholeFile(enUsHyph).data(), enUsMinPrefix,
+ enUsMinSuffix, "en");
std::vector<uint16_t> word = utf8ToUtf16("hyphen");
std::vector<HyphenationType> result;
while (state.KeepRunning()) {
@@ -40,10 +40,9 @@
BENCHMARK(BM_Hyphenator_short_word);
static void BM_Hyphenator_long_word(benchmark::State& state) {
- Hyphenator* hyphenator = Hyphenator::loadBinary(
- readWholeFile(enUsHyph).data(), enUsMinPrefix, enUsMinSuffix, "en");
- std::vector<uint16_t> word = utf8ToUtf16(
- "Pneumonoultramicroscopicsilicovolcanoconiosis");
+ Hyphenator* hyphenator = Hyphenator::loadBinary(readWholeFile(enUsHyph).data(), enUsMinPrefix,
+ enUsMinSuffix, "en");
+ std::vector<uint16_t> word = utf8ToUtf16("Pneumonoultramicroscopicsilicovolcanoconiosis");
std::vector<HyphenationType> result;
while (state.KeepRunning()) {
hyphenator->hyphenate(&result, word.data(), word.size());
diff --git a/tests/perftests/WordBreaker.cpp b/tests/perftests/WordBreaker.cpp
index 33e5e57..6a8b1c4 100644
--- a/tests/perftests/WordBreaker.cpp
+++ b/tests/perftests/WordBreaker.cpp
@@ -23,15 +23,17 @@
namespace minikin {
static void BM_WordBreaker_English(benchmark::State& state) {
- const char* kLoremIpsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do "
- "eiusmod tempor incididunt ut labore et dolore magna aliqua.";
+ const char* kLoremIpsum =
+ "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do "
+ "eiusmod tempor incididunt ut labore et dolore magna aliqua.";
WordBreaker wb;
wb.followingWithLocale(Locale("en-US"), 0);
std::vector<uint16_t> text = utf8ToUtf16(kLoremIpsum);
while (state.KeepRunning()) {
wb.setText(text.data(), text.size());
- while (wb.next() != -1) {}
+ while (wb.next() != -1) {
+ }
}
}
BENCHMARK(BM_WordBreaker_English);
diff --git a/tests/perftests/main.cpp b/tests/perftests/main.cpp
index 8281dd6..142b396 100644
--- a/tests/perftests/main.cpp
+++ b/tests/perftests/main.cpp
@@ -14,8 +14,8 @@
* limitations under the License.
*/
#include <fcntl.h>
-#include <sys/stat.h>
#include <sys/mman.h>
+#include <sys/stat.h>
#include <benchmark/benchmark.h>
#include <cutils/log.h>
diff --git a/tests/stresstest/FontFamilyTest.cpp b/tests/stresstest/FontFamilyTest.cpp
index 88c26b2..efd6bbc 100644
--- a/tests/stresstest/FontFamilyTest.cpp
+++ b/tests/stresstest/FontFamilyTest.cpp
@@ -19,6 +19,7 @@
#include <gtest/gtest.h>
#include "minikin/FontCollection.h"
+
#include "FontTestUtils.h"
#include "HbFontCache.h"
#include "MinikinFontForTest.h"
@@ -44,8 +45,8 @@
for (uint32_t codePoint = 0; codePoint < MAX_UNICODE_CODE_POINT; ++codePoint) {
uint32_t unusedGlyph;
EXPECT_EQ(family->hasGlyph(codePoint, 0 /* variation selector */),
- static_cast<bool>(hb_font_get_glyph(hbFont, codePoint, 0 /* variation selector */,
- &unusedGlyph)));
+ static_cast<bool>(hb_font_get_glyph(hbFont, codePoint, 0 /* variation selector */,
+ &unusedGlyph)));
}
for (uint32_t vs = VS1; vs < VS256; ++vs) {
@@ -56,21 +57,17 @@
for (uint32_t codePoint = 0; codePoint < MAX_UNICODE_CODE_POINT; ++codePoint) {
uint32_t unusedGlyph;
ASSERT_EQ(family->hasGlyph(codePoint, vs),
- static_cast<bool>(hb_font_get_glyph(hbFont, codePoint, vs, &unusedGlyph)))
- << "Inconsistent Result: " << fontPath << "#" << ttcIndex
- << ": U+" << std::hex << codePoint << " U+" << std::hex << vs
- << " Minikin: " << family->hasGlyph(codePoint, vs)
- << " HarfBuzz: "
- << static_cast<bool>(hb_font_get_glyph(hbFont, codePoint, vs, &unusedGlyph));
-
+ static_cast<bool>(hb_font_get_glyph(hbFont, codePoint, vs, &unusedGlyph)))
+ << "Inconsistent Result: " << fontPath << "#" << ttcIndex << ": U+" << std::hex
+ << codePoint << " U+" << std::hex << vs
+ << " Minikin: " << family->hasGlyph(codePoint, vs) << " HarfBuzz: "
+ << static_cast<bool>(hb_font_get_glyph(hbFont, codePoint, vs, &unusedGlyph));
}
}
hb_font_destroy(hbFont);
}
-INSTANTIATE_TEST_CASE_P(FontFamilyTest,
- FontFamilyHarfBuzzCompatibilityTest,
- ::testing::Values(
- TestParam("/system/fonts/NotoSansCJK-Regular.ttc", 0),
- TestParam("/system/fonts/NotoColorEmoji.ttf", 0)));
+INSTANTIATE_TEST_CASE_P(FontFamilyTest, FontFamilyHarfBuzzCompatibilityTest,
+ ::testing::Values(TestParam("/system/fonts/NotoSansCJK-Regular.ttc", 0),
+ TestParam("/system/fonts/NotoColorEmoji.ttf", 0)));
} // namespace minikin
diff --git a/tests/stresstest/MultithreadTest.cpp b/tests/stresstest/MultithreadTest.cpp
index 5a6f409..684d0b5 100644
--- a/tests/stresstest/MultithreadTest.cpp
+++ b/tests/stresstest/MultithreadTest.cpp
@@ -25,8 +25,9 @@
#include <gtest/gtest.h>
#include "minikin/FontCollection.h"
-#include "MinikinInternal.h"
+
#include "FontTestUtils.h"
+#include "MinikinInternal.h"
namespace minikin {
@@ -41,8 +42,8 @@
std::condition_variable gCv;
bool gReady = false;
-static std::vector<uint16_t> generateTestText(
- std::mt19937* mt, int lettersInWord, int wordsInText) {
+static std::vector<uint16_t> generateTestText(std::mt19937* mt, int lettersInWord,
+ int wordsInText) {
std::uniform_int_distribution<uint16_t> dist('A', 'Z');
std::vector<uint16_t> text;
diff --git a/tests/unittest/AndroidLineBreakerHelperTest.cpp b/tests/unittest/AndroidLineBreakerHelperTest.cpp
index e0b40bc..5ef217d 100644
--- a/tests/unittest/AndroidLineBreakerHelperTest.cpp
+++ b/tests/unittest/AndroidLineBreakerHelperTest.cpp
@@ -19,6 +19,7 @@
#include <gtest/gtest.h>
#include "minikin/LineBreaker.h"
+
#include "FontTestUtils.h"
#include "ICUTestBase.h"
#include "UnicodeUtils.h"
@@ -39,13 +40,12 @@
std::shared_ptr<FontCollection> collection =
getFontCollection(SYSTEM_FONT_PATH, SYSTEM_FONT_XML);
- StaticLayoutNative layoutNative(
- BreakStrategy::Greedy, // break strategy
- HyphenationFrequency::None, // hyphenation frequency
- false, // not justified
- std::vector<float>(), // indents
- std::vector<float>(), // left padding
- std::vector<float>()); // right padding
+ StaticLayoutNative layoutNative(BreakStrategy::Greedy, // break strategy
+ HyphenationFrequency::None, // hyphenation frequency
+ false, // not justified
+ std::vector<float>(), // indents
+ std::vector<float>(), // left padding
+ std::vector<float>()); // right padding
layoutNative.addStyleRun(0, 2, MinikinPaint(), collection, false /* is RTL */);
layoutNative.addReplacementRun(2, 4, REPLACEMENT_WIDTH, 0 /* locale list id */);
@@ -54,15 +54,13 @@
std::vector<uint16_t> text(CHAR_COUNT, 'a');
MeasuredText measuredText = layoutNative.measureText(text);
- LineBreakResult result = layoutNative.computeBreaks(
- text, measuredText,
- LINE_WIDTH, 1, LINE_WIDTH, 0, // line width arguments,
- nullptr, 0, 0); // tab stop arguments.
+ LineBreakResult result = layoutNative.computeBreaks(text, measuredText, LINE_WIDTH, 1,
+ LINE_WIDTH, 0, // line width arguments,
+ nullptr, 0, 0); // tab stop arguments.
// ReplacementRun assigns all width to the first character and leave zeros others.
- std::vector<float> expectedWidths = {
- CHAR_WIDTH, CHAR_WIDTH, REPLACEMENT_WIDTH, 0, CHAR_WIDTH, CHAR_WIDTH
- };
+ std::vector<float> expectedWidths = {CHAR_WIDTH, CHAR_WIDTH, REPLACEMENT_WIDTH,
+ 0, CHAR_WIDTH, CHAR_WIDTH};
EXPECT_EQ(expectedWidths, measuredText.widths);
}
diff --git a/tests/unittest/CmapCoverageTest.cpp b/tests/unittest/CmapCoverageTest.cpp
index c401bbf..db3bb39 100644
--- a/tests/unittest/CmapCoverageTest.cpp
+++ b/tests/unittest/CmapCoverageTest.cpp
@@ -22,6 +22,7 @@
#include <log/log.h>
#include "minikin/SparseBitSet.h"
+
#include "MinikinInternal.h"
namespace minikin {
@@ -65,22 +66,23 @@
static std::vector<uint8_t> buildCmapFormat4Table(const std::vector<uint16_t>& ranges) {
uint16_t segmentCount = ranges.size() / 2 + 1 /* +1 for end marker */;
- const size_t numOfUint16 =
- 8 /* format, length, languages, segCountX2, searchRange, entrySelector, rangeShift, pad */ +
- segmentCount * 4 /* endCount, startCount, idRange, idRangeOffset */;
+ const size_t numOfUint16 = 8 /* format, length, languages, segCountX2, searchRange,
+ entrySelector, rangeShift, pad */
+ +
+ segmentCount * 4 /* endCount, startCount, idRange, idRangeOffset */;
const size_t finalLength = sizeof(uint16_t) * numOfUint16;
std::vector<uint8_t> out(finalLength);
size_t head = 0;
- head = writeU16(4, out.data(), head); // format
+ head = writeU16(4, out.data(), head); // format
head = writeU16(finalLength, out.data(), head); // length
- head = writeU16(0, out.data(), head); // langauge
+ head = writeU16(0, out.data(), head); // langauge
const uint16_t searchRange = 2 * (1 << static_cast<int>(floor(log2(segmentCount))));
- head = writeU16(segmentCount * 2, out.data(), head); // segCountX2
- head = writeU16(searchRange, out.data(), head); // searchRange
- head = writeU16(__builtin_ctz(searchRange) - 1, out.data(), head); // entrySelector
+ head = writeU16(segmentCount * 2, out.data(), head); // segCountX2
+ head = writeU16(searchRange, out.data(), head); // searchRange
+ head = writeU16(__builtin_ctz(searchRange) - 1, out.data(), head); // entrySelector
head = writeU16(segmentCount * 2 - searchRange, out.data(), head); // rangeShift
size_t endCountHead = head;
@@ -114,18 +116,19 @@
// 'a' (U+0061) is mapped to Glyph ID = 0x0061).
// 'range' should be specified with inclusive-inclusive values.
static std::vector<uint8_t> buildCmapFormat12Table(const std::vector<uint32_t>& ranges) {
- uint32_t numGroups = ranges.size() / 2;
+ uint32_t numGroups = ranges.size() / 2;
const size_t finalLength = 2 /* format */ + 2 /* reserved */ + 4 /* length */ +
- 4 /* languages */ + 4 /* numGroups */ + 12 /* size of a group */ * numGroups;
+ 4 /* languages */ + 4 /* numGroups */ +
+ 12 /* size of a group */ * numGroups;
std::vector<uint8_t> out(finalLength);
size_t head = 0;
- head = writeU16(12, out.data(), head); // format
- head = writeU16(0, out.data(), head); // reserved
+ head = writeU16(12, out.data(), head); // format
+ head = writeU16(0, out.data(), head); // reserved
head = writeU32(finalLength, out.data(), head); // length
- head = writeU32(0, out.data(), head); // langauge
- head = writeU32(numGroups, out.data(), head); // numGroups
+ head = writeU32(0, out.data(), head); // langauge
+ head = writeU32(numGroups, out.data(), head); // numGroups
for (uint32_t i = 0; i < numGroups; ++i) {
const uint32_t start = ranges[2 * i];
@@ -154,7 +157,7 @@
}
const size_t numOfRanges = defaultUVSRanges.size() / 2;
const size_t length = sizeof(uint32_t) /* numUnicodeValueRanges */ +
- numOfRanges * 4 /* size of Unicode Range Table */;
+ numOfRanges * 4 /* size of Unicode Range Table */;
std::vector<uint8_t> out(length);
size_t head = 0;
@@ -174,7 +177,7 @@
return std::vector<uint8_t>();
}
const size_t length = sizeof(uint32_t) /* numUnicodeValueRanges */ +
- nonDefaultUVS.size() * 5 /* size of UVS Mapping Record */;
+ nonDefaultUVS.size() * 5 /* size of UVS Mapping Record */;
std::vector<uint8_t> out(length);
size_t head = 0;
@@ -190,15 +193,14 @@
static std::vector<uint8_t> buildCmapFormat14Table(
const std::vector<VariationSelectorRecord>& vsRecords) {
-
const size_t headerLength = sizeof(uint16_t) /* format */ + sizeof(uint32_t) /* length */ +
- sizeof(uint32_t) /* numVarSelectorRecords */ +
- 11 /* size of variation selector record */ * vsRecords.size();
+ sizeof(uint32_t) /* numVarSelectorRecords */ +
+ 11 /* size of variation selector record */ * vsRecords.size();
std::vector<uint8_t> out(headerLength);
size_t head = 0;
- head = writeU16(14, out.data(), head); // format
- head += sizeof(uint32_t); // length will be filled later
+ head = writeU16(14, out.data(), head); // format
+ head += sizeof(uint32_t); // length will be filled later
head = writeU32(vsRecords.size(), out.data(), head); // numVarSelectorRecords;
for (const auto& record : vsRecords) {
@@ -233,14 +235,13 @@
CmapBuilder(int numTables) : mNumTables(numTables), mCurrentTableIndex(0) {
const size_t headerSize =
- 2 /* version */ + 2 /* numTables */ + kEncodingTableSize * numTables;
+ 2 /* version */ + 2 /* numTables */ + kEncodingTableSize * numTables;
out.resize(headerSize);
writeU16(0, out.data(), 0);
writeU16(numTables, out.data(), 2);
}
- void appendTable(uint16_t platformId, uint16_t encodingId,
- const std::vector<uint8_t>& table) {
+ void appendTable(uint16_t platformId, uint16_t encodingId, const std::vector<uint8_t>& table) {
appendEncodingTable(platformId, encodingId, out.size());
out.insert(out.end(), table.begin(), table.end());
}
@@ -252,14 +253,14 @@
// Helper functions.
static std::vector<uint8_t> buildSingleFormat4Cmap(uint16_t platformId, uint16_t encodingId,
- const std::vector<uint16_t>& ranges) {
+ const std::vector<uint16_t>& ranges) {
CmapBuilder builder(1);
builder.appendTable(platformId, encodingId, buildCmapFormat4Table(ranges));
return builder.build();
}
static std::vector<uint8_t> buildSingleFormat12Cmap(uint16_t platformId, uint16_t encodingId,
- const std::vector<uint32_t>& ranges) {
+ const std::vector<uint32_t>& ranges) {
CmapBuilder builder(1);
builder.appendTable(platformId, encodingId, buildCmapFormat12Table(ranges));
return builder.build();
@@ -317,8 +318,8 @@
}
{
SCOPED_TRACE("Reversed range");
- std::vector<uint8_t> cmap = CmapBuilder::buildSingleFormat4Cmap(0, 0, std::vector<uint16_t>(
- {'b', 'b', 'a', 'a'}));
+ std::vector<uint8_t> cmap = CmapBuilder::buildSingleFormat4Cmap(
+ 0, 0, std::vector<uint16_t>({'b', 'b', 'a', 'a'}));
SparseBitSet coverage = CmapCoverage::getCoverage(cmap.data(), cmap.size(), &vsTables);
EXPECT_EQ(0U, coverage.length());
@@ -326,8 +327,8 @@
}
{
SCOPED_TRACE("Reversed range - partially readable");
- std::vector<uint8_t> cmap = CmapBuilder::buildSingleFormat4Cmap(0, 0, std::vector<uint16_t>(
- { 'a', 'a', 'c', 'c', 'b', 'b'}));
+ std::vector<uint8_t> cmap = CmapBuilder::buildSingleFormat4Cmap(
+ 0, 0, std::vector<uint16_t>({'a', 'a', 'c', 'c', 'b', 'b'}));
SparseBitSet coverage = CmapCoverage::getCoverage(cmap.data(), cmap.size(), &vsTables);
EXPECT_EQ(0U, coverage.length());
@@ -342,11 +343,9 @@
uint16_t platformId;
uint16_t encodingId;
} TEST_CASES[] = {
- { "Platform 0, Encoding 0", 0, 0 },
- { "Platform 0, Encoding 1", 0, 1 },
- { "Platform 0, Encoding 2", 0, 2 },
- { "Platform 0, Encoding 3", 0, 3 },
- { "Platform 3, Encoding 1", 3, 1 },
+ {"Platform 0, Encoding 0", 0, 0}, {"Platform 0, Encoding 1", 0, 1},
+ {"Platform 0, Encoding 2", 0, 2}, {"Platform 0, Encoding 3", 0, 3},
+ {"Platform 3, Encoding 1", 3, 1},
};
for (const auto& testCase : TEST_CASES) {
@@ -368,9 +367,9 @@
uint16_t platformId;
uint16_t encodingId;
} TEST_CASES[] = {
- { "Platform 0, Encoding 4", 0, 4 },
- { "Platform 0, Encoding 6", 0, 6 },
- { "Platform 3, Encoding 10", 3, 10 },
+ {"Platform 0, Encoding 4", 0, 4},
+ {"Platform 0, Encoding 6", 0, 6},
+ {"Platform 3, Encoding 10", 3, 10},
};
for (const auto& testCase : TEST_CASES) {
@@ -418,26 +417,26 @@
uint16_t platformId;
uint16_t encodingId;
} TEST_CASES[] = {
- // Any encodings with platform 2 is not supported.
- { "Platform 2, Encoding 0", 2, 0 },
- { "Platform 2, Encoding 1", 2, 1 },
- { "Platform 2, Encoding 2", 2, 2 },
- { "Platform 2, Encoding 3", 2, 3 },
- // UCS-2 or UCS-4 are supported on Platform == 3. Others are not supported.
- { "Platform 3, Encoding 0", 3, 0 }, // Symbol
- { "Platform 3, Encoding 2", 3, 2 }, // ShiftJIS
- { "Platform 3, Encoding 3", 3, 3 }, // RPC
- { "Platform 3, Encoding 4", 3, 4 }, // Big5
- { "Platform 3, Encoding 5", 3, 5 }, // Wansung
- { "Platform 3, Encoding 6", 3, 6 }, // Johab
- { "Platform 3, Encoding 7", 3, 7 }, // Reserved
- { "Platform 3, Encoding 8", 3, 8 }, // Reserved
- { "Platform 3, Encoding 9", 3, 9 }, // Reserved
- // Uknown platforms
- { "Platform 4, Encoding 0", 4, 0 },
- { "Platform 5, Encoding 1", 5, 1 },
- { "Platform 6, Encoding 0", 6, 0 },
- { "Platform 7, Encoding 1", 7, 1 },
+ // Any encodings with platform 2 is not supported.
+ {"Platform 2, Encoding 0", 2, 0},
+ {"Platform 2, Encoding 1", 2, 1},
+ {"Platform 2, Encoding 2", 2, 2},
+ {"Platform 2, Encoding 3", 2, 3},
+ // UCS-2 or UCS-4 are supported on Platform == 3. Others are not supported.
+ {"Platform 3, Encoding 0", 3, 0}, // Symbol
+ {"Platform 3, Encoding 2", 3, 2}, // ShiftJIS
+ {"Platform 3, Encoding 3", 3, 3}, // RPC
+ {"Platform 3, Encoding 4", 3, 4}, // Big5
+ {"Platform 3, Encoding 5", 3, 5}, // Wansung
+ {"Platform 3, Encoding 6", 3, 6}, // Johab
+ {"Platform 3, Encoding 7", 3, 7}, // Reserved
+ {"Platform 3, Encoding 8", 3, 8}, // Reserved
+ {"Platform 3, Encoding 9", 3, 9}, // Reserved
+ // Uknown platforms
+ {"Platform 4, Encoding 0", 4, 0},
+ {"Platform 5, Encoding 1", 5, 1},
+ {"Platform 6, Encoding 0", 6, 0},
+ {"Platform 7, Encoding 1", 7, 1},
};
for (const auto& testCase : TEST_CASES) {
@@ -579,13 +578,8 @@
uint16_t encodingId;
const std::vector<uint8_t>& table;
} LOWER_PRIORITY_TABLES[] = {
- { 0, 0, format4 },
- { 0, 1, format4 },
- { 0, 2, format4 },
- { 0, 3, format4 },
- { 0, 4, format12 },
- { 0, 6, format12 },
- { 3, 1, format4 },
+ {0, 0, format4}, {0, 1, format4}, {0, 2, format4}, {0, 3, format4},
+ {0, 4, format12}, {0, 6, format12}, {3, 1, format4},
};
for (const auto& table : LOWER_PRIORITY_TABLES) {
@@ -595,7 +589,7 @@
std::vector<uint8_t> cmap = builder.build();
SparseBitSet coverage = CmapCoverage::getCoverage(cmap.data(), cmap.size(), &vsTables);
- EXPECT_TRUE(coverage.get('a')); // comes from highest table
+ EXPECT_TRUE(coverage.get('a')); // comes from highest table
EXPECT_FALSE(coverage.get('b')); // should not use other table.
EXPECT_TRUE(vsTables.empty());
}
@@ -608,10 +602,7 @@
uint16_t encodingId;
const std::vector<uint8_t>& table;
} LOWER_PRIORITY_TABLES[] = {
- { 0, 0, format4 },
- { 0, 1, format4 },
- { 0, 2, format4 },
- { 0, 3, format4 },
+ {0, 0, format4}, {0, 1, format4}, {0, 2, format4}, {0, 3, format4},
};
for (const auto& table : LOWER_PRIORITY_TABLES) {
@@ -621,7 +612,7 @@
std::vector<uint8_t> cmap = builder.build();
SparseBitSet coverage = CmapCoverage::getCoverage(cmap.data(), cmap.size(), &vsTables);
- EXPECT_TRUE(coverage.get('a')); // comes from highest table
+ EXPECT_TRUE(coverage.get('a')); // comes from highest table
EXPECT_FALSE(coverage.get('b')); // should not use other table.
EXPECT_TRUE(vsTables.empty());
}
@@ -641,7 +632,7 @@
std::vector<uint8_t> cmap = builder.build();
SparseBitSet coverage = CmapCoverage::getCoverage(cmap.data(), cmap.size(), &vsTables);
- EXPECT_TRUE(coverage.get('a')); // comes from valid table
+ EXPECT_TRUE(coverage.get('a')); // comes from valid table
EXPECT_FALSE(coverage.get('b')); // should not use invalid table.
EXPECT_TRUE(vsTables.empty());
}
@@ -655,7 +646,7 @@
std::vector<uint8_t> cmap = builder.build();
SparseBitSet coverage = CmapCoverage::getCoverage(cmap.data(), cmap.size(), &vsTables);
- EXPECT_TRUE(coverage.get('a')); // comes from valid table
+ EXPECT_TRUE(coverage.get('a')); // comes from valid table
EXPECT_FALSE(coverage.get('b')); // should not use invalid table.
EXPECT_TRUE(vsTables.empty());
}
@@ -669,7 +660,7 @@
std::vector<uint8_t> cmap = builder.build();
SparseBitSet coverage = CmapCoverage::getCoverage(cmap.data(), cmap.size(), &vsTables);
- EXPECT_TRUE(coverage.get('a')); // comes from valid table
+ EXPECT_TRUE(coverage.get('a')); // comes from valid table
EXPECT_FALSE(coverage.get('b')); // should not use invalid table.
EXPECT_TRUE(vsTables.empty());
}
@@ -677,8 +668,7 @@
TEST(CmapCoverageTest, TableSelection_SkipBrokenFormat12Table) {
std::vector<std::unique_ptr<SparseBitSet>> vsTables;
- std::vector<uint8_t> validTable =
- buildCmapFormat12Table(std::vector<uint32_t>({'a', 'a'}));
+ std::vector<uint8_t> validTable = buildCmapFormat12Table(std::vector<uint32_t>({'a', 'a'}));
{
SCOPED_TRACE("Unsupported format");
CmapBuilder builder(2);
@@ -689,7 +679,7 @@
std::vector<uint8_t> cmap = builder.build();
SparseBitSet coverage = CmapCoverage::getCoverage(cmap.data(), cmap.size(), &vsTables);
- EXPECT_TRUE(coverage.get('a')); // comes from valid table
+ EXPECT_TRUE(coverage.get('a')); // comes from valid table
EXPECT_FALSE(coverage.get('b')); // should not use invalid table.
EXPECT_TRUE(vsTables.empty());
}
@@ -703,7 +693,7 @@
std::vector<uint8_t> cmap = builder.build();
SparseBitSet coverage = CmapCoverage::getCoverage(cmap.data(), cmap.size(), &vsTables);
- EXPECT_TRUE(coverage.get('a')); // comes from valid table
+ EXPECT_TRUE(coverage.get('a')); // comes from valid table
EXPECT_FALSE(coverage.get('b')); // should not use invalid table.
EXPECT_TRUE(vsTables.empty());
}
@@ -717,7 +707,7 @@
std::vector<uint8_t> cmap = builder.build();
SparseBitSet coverage = CmapCoverage::getCoverage(cmap.data(), cmap.size(), &vsTables);
- EXPECT_TRUE(coverage.get('a')); // comes from valid table
+ EXPECT_TRUE(coverage.get('a')); // comes from valid table
EXPECT_FALSE(coverage.get('b')); // should not use invalid table.
EXPECT_TRUE(vsTables.empty());
}
@@ -727,9 +717,9 @@
std::vector<uint8_t> smallLetterTable =
buildCmapFormat12Table(std::vector<uint32_t>({'a', 'z'}));
std::vector<uint8_t> vsTable = buildCmapFormat14Table(std::vector<VariationSelectorRecord>({
- { 0xFE0E, { 'a', 'b' }, {} /* no non-default UVS table */ },
- { 0xFE0F, {} /* no default UVS table */, { 'a', 'b'} },
- { 0xE0100, { 'a', 'a' }, { 'b'} },
+ {0xFE0E, {'a', 'b'}, {} /* no non-default UVS table */},
+ {0xFE0F, {} /* no default UVS table */, {'a', 'b'}},
+ {0xE0100, {'a', 'a'}, {'b'}},
}));
CmapBuilder builder(2);
builder.appendTable(3, 1, smallLetterTable);
@@ -764,12 +754,20 @@
std::vector<uint8_t> smallLetterTable =
buildCmapFormat12Table(std::vector<uint32_t>({'a', 'z'}));
std::vector<uint8_t> vsTable = buildCmapFormat14Table(std::vector<VariationSelectorRecord>({
- { 0xFE0E, { 'a', 'e' }, { 'c', 'd', } },
- { 0xFE0F, { 'c', 'e'} , { 'a', 'b', 'c', 'd', 'e'} },
- { 0xE0100, { 'a', 'c' }, { 'b', 'c', 'd' } },
- { 0xE0101, { 'b', 'd'} , { 'a', 'b', 'c', 'd'} },
- { 0xE0102, { 'a', 'c', 'd', 'g'} , { 'b', 'c', 'd', 'e', 'f', 'g', 'h'} },
- { 0xE0103, { 'a', 'f'} , { 'b', 'd', } },
+ {0xFE0E,
+ {'a', 'e'},
+ {
+ 'c', 'd',
+ }},
+ {0xFE0F, {'c', 'e'}, {'a', 'b', 'c', 'd', 'e'}},
+ {0xE0100, {'a', 'c'}, {'b', 'c', 'd'}},
+ {0xE0101, {'b', 'd'}, {'a', 'b', 'c', 'd'}},
+ {0xE0102, {'a', 'c', 'd', 'g'}, {'b', 'c', 'd', 'e', 'f', 'g', 'h'}},
+ {0xE0103,
+ {'a', 'f'},
+ {
+ 'b', 'd',
+ }},
}));
CmapBuilder builder(2);
builder.appendTable(3, 1, smallLetterTable);
@@ -842,25 +840,23 @@
std::vector<uint8_t> cmap12Table = buildCmapFormat12Table(std::vector<uint32_t>({'a', 'z'}));
{
SCOPED_TRACE("Too small cmap size");
- std::vector<uint8_t> vsTable = buildCmapFormat14Table(std::vector<VariationSelectorRecord>({
- { 0xFE0E, { 'a', 'a' }, { 'b' } }
- }));
+ std::vector<uint8_t> vsTable = buildCmapFormat14Table(
+ std::vector<VariationSelectorRecord>({{0xFE0E, {'a', 'a'}, {'b'}}}));
CmapBuilder builder(2);
builder.appendTable(3, 1, cmap12Table);
builder.appendTable(VS_PLATFORM_ID, VS_ENCODING_ID, vsTable);
std::vector<uint8_t> cmap = builder.build();
std::vector<std::unique_ptr<SparseBitSet>> vsTables;
- SparseBitSet coverage = CmapCoverage::getCoverage(
- cmap.data(), 3 /* too small size */, &vsTables);
+ SparseBitSet coverage =
+ CmapCoverage::getCoverage(cmap.data(), 3 /* too small size */, &vsTables);
EXPECT_FALSE(coverage.get('a'));
ASSERT_TRUE(vsTables.empty());
}
{
SCOPED_TRACE("Too many variation records");
- std::vector<uint8_t> vsTable = buildCmapFormat14Table(std::vector<VariationSelectorRecord>({
- { 0xFE0F, { 'a', 'a' }, { 'b' } }
- }));
+ std::vector<uint8_t> vsTable = buildCmapFormat14Table(
+ std::vector<VariationSelectorRecord>({{0xFE0F, {'a', 'a'}, {'b'}}}));
writeU32(5000, vsTable.data(), 6 /* numVarSelectorRecord offset */);
CmapBuilder builder(2);
builder.appendTable(3, 1, cmap12Table);
@@ -873,9 +869,8 @@
}
{
SCOPED_TRACE("Invalid default UVS offset in variation records");
- std::vector<uint8_t> vsTable = buildCmapFormat14Table(std::vector<VariationSelectorRecord>({
- { 0xFE0F, { 'a', 'a' }, { 'b' } }
- }));
+ std::vector<uint8_t> vsTable = buildCmapFormat14Table(
+ std::vector<VariationSelectorRecord>({{0xFE0F, {'a', 'a'}, {'b'}}}));
writeU32(5000, vsTable.data(), 13 /* defaultUVSffset offset in the first record */);
CmapBuilder builder(2);
builder.appendTable(3, 1, cmap12Table);
@@ -888,9 +883,8 @@
}
{
SCOPED_TRACE("Invalid non default UVS offset in variation records");
- std::vector<uint8_t> vsTable = buildCmapFormat14Table(std::vector<VariationSelectorRecord>({
- { 0xFE0F, { 'a', 'a' }, { 'b' } }
- }));
+ std::vector<uint8_t> vsTable = buildCmapFormat14Table(
+ std::vector<VariationSelectorRecord>({{0xFE0F, {'a', 'a'}, {'b'}}}));
writeU32(5000, vsTable.data(), 17 /* nonDefaultUVSffset offset in the first record */);
CmapBuilder builder(2);
builder.appendTable(3, 1, cmap12Table);
@@ -903,9 +897,8 @@
}
{
SCOPED_TRACE("Too many ranges entry in default UVS table");
- std::vector<uint8_t> vsTable = buildCmapFormat14Table(std::vector<VariationSelectorRecord>({
- { 0xFE0F, { 'a', 'a' }, { 'b' } }
- }));
+ std::vector<uint8_t> vsTable = buildCmapFormat14Table(
+ std::vector<VariationSelectorRecord>({{0xFE0F, {'a', 'a'}, {'b'}}}));
// 21 is the offset of the numUnicodeValueRanges in the fist defulat UVS table.
writeU32(5000, vsTable.data(), 21);
CmapBuilder builder(2);
@@ -919,9 +912,8 @@
}
{
SCOPED_TRACE("Too many ranges entry in non default UVS table");
- std::vector<uint8_t> vsTable = buildCmapFormat14Table(std::vector<VariationSelectorRecord>({
- { 0xFE0F, { 'a', 'a' }, { 'b' } }
- }));
+ std::vector<uint8_t> vsTable = buildCmapFormat14Table(
+ std::vector<VariationSelectorRecord>({{0xFE0F, {'a', 'a'}, {'b'}}}));
// 29 is the offset of the numUnicodeValueRanges in the fist defulat UVS table.
writeU32(5000, vsTable.data(), 29);
CmapBuilder builder(2);
@@ -935,9 +927,8 @@
}
{
SCOPED_TRACE("Reversed range in default UVS table");
- std::vector<uint8_t> vsTable = buildCmapFormat14Table(std::vector<VariationSelectorRecord>({
- { 0xFE0F, { 'b', 'b', 'a', 'a' }, { } }
- }));
+ std::vector<uint8_t> vsTable = buildCmapFormat14Table(
+ std::vector<VariationSelectorRecord>({{0xFE0F, {'b', 'b', 'a', 'a'}, {}}}));
CmapBuilder builder(2);
builder.appendTable(3, 1, cmap12Table);
builder.appendTable(VS_PLATFORM_ID, VS_ENCODING_ID, vsTable);
@@ -949,9 +940,8 @@
}
{
SCOPED_TRACE("Reversed range in default UVS table - partially readable");
- std::vector<uint8_t> vsTable = buildCmapFormat14Table(std::vector<VariationSelectorRecord>({
- { 0xFE0F, { 'a', 'a', 'c', 'c', 'b', 'b' }, { } }
- }));
+ std::vector<uint8_t> vsTable = buildCmapFormat14Table(std::vector<VariationSelectorRecord>(
+ {{0xFE0F, {'a', 'a', 'c', 'c', 'b', 'b'}, {}}}));
CmapBuilder builder(2);
builder.appendTable(3, 1, cmap12Table);
builder.appendTable(VS_PLATFORM_ID, VS_ENCODING_ID, vsTable);
@@ -963,9 +953,8 @@
}
{
SCOPED_TRACE("Reversed mapping entries in non default UVS table");
- std::vector<uint8_t> vsTable = buildCmapFormat14Table(std::vector<VariationSelectorRecord>({
- { 0xFE0F, { }, { 'b', 'a' } }
- }));
+ std::vector<uint8_t> vsTable = buildCmapFormat14Table(
+ std::vector<VariationSelectorRecord>({{0xFE0F, {}, {'b', 'a'}}}));
CmapBuilder builder(2);
builder.appendTable(3, 1, cmap12Table);
builder.appendTable(VS_PLATFORM_ID, VS_ENCODING_ID, vsTable);
@@ -977,9 +966,8 @@
}
{
SCOPED_TRACE("Reversed mapping entries in non default UVS table");
- std::vector<uint8_t> vsTable = buildCmapFormat14Table(std::vector<VariationSelectorRecord>({
- { 0xFE0F, { }, { 'a', 'c', 'b' } }
- }));
+ std::vector<uint8_t> vsTable = buildCmapFormat14Table(
+ std::vector<VariationSelectorRecord>({{0xFE0F, {}, {'a', 'c', 'b'}}}));
CmapBuilder builder(2);
builder.appendTable(3, 1, cmap12Table);
builder.appendTable(VS_PLATFORM_ID, VS_ENCODING_ID, vsTable);
@@ -996,8 +984,7 @@
{
SCOPED_TRACE("Invalid default UVS offset in variation records");
std::vector<uint8_t> vsTable = buildCmapFormat14Table(std::vector<VariationSelectorRecord>({
- { 0xFE0E, { 'a', 'a' }, { 'b' } },
- { 0xFE0F, { 'a', 'a' }, { 'b' } },
+ {0xFE0E, {'a', 'a'}, {'b'}}, {0xFE0F, {'a', 'a'}, {'b'}},
}));
writeU32(5000, vsTable.data(), 13 /* defaultUVSffset offset in the record for 0xFE0E */);
CmapBuilder builder(2);
@@ -1020,8 +1007,7 @@
{
SCOPED_TRACE("Invalid non default UVS offset in variation records");
std::vector<uint8_t> vsTable = buildCmapFormat14Table(std::vector<VariationSelectorRecord>({
- { 0xFE0E, { 'a', 'a' }, { 'b' } },
- { 0xFE0F, { 'a', 'a' }, { 'b' } },
+ {0xFE0E, {'a', 'a'}, {'b'}}, {0xFE0F, {'a', 'a'}, {'b'}},
}));
writeU32(5000, vsTable.data(), 17 /* nonDefaultUVSffset offset in the first record */);
CmapBuilder builder(2);
@@ -1044,8 +1030,7 @@
{
SCOPED_TRACE("Unknown variation selectors.");
std::vector<uint8_t> vsTable = buildCmapFormat14Table(std::vector<VariationSelectorRecord>({
- { 0xFE0F, { 'a', 'a' }, { 'b' } },
- { 0xEFFFF, { 'a', 'a' }, { 'b' } },
+ {0xFE0F, {'a', 'a'}, {'b'}}, {0xEFFFF, {'a', 'a'}, {'b'}},
}));
CmapBuilder builder(2);
builder.appendTable(3, 1, cmap12Table);
@@ -1069,9 +1054,8 @@
TEST(CmapCoverageTest, TableSelection_defaultUVSPointMissingGlyph) {
std::vector<uint8_t> baseTable = buildCmapFormat12Table(std::vector<uint32_t>(
{RANGE('a', 'e'), RANGE('g', 'h'), RANGE('j', 'j'), RANGE('m', 'z')}));
- std::vector<uint8_t> vsTable = buildCmapFormat14Table(std::vector<VariationSelectorRecord>({
- { 0xFE0F, { 'a', 'z' }, { } }
- }));
+ std::vector<uint8_t> vsTable = buildCmapFormat14Table(
+ std::vector<VariationSelectorRecord>({{0xFE0F, {'a', 'z'}, {}}}));
CmapBuilder builder(2);
builder.appendTable(3, 1, baseTable);
@@ -1084,7 +1068,7 @@
ASSERT_LT(vsIndex, vsTables.size());
ASSERT_TRUE(vsTables[vsIndex]);
- for (char c = 'a'; c <= 'z'; ++c) {
+ for (char c = 'a'; c <= 'z'; ++c) {
// Default UVS table points the variation sequence to the glyph of the base code point.
// Thus, if the base code point is not supported, we should exclude them.
EXPECT_EQ(coverage.get(c), vsTables[vsIndex]->get(c)) << c;
@@ -1094,9 +1078,8 @@
#undef RANGE
TEST(CmapCoverageTest, TableSelection_vsTableOnly) {
- std::vector<uint8_t> vsTable = buildCmapFormat14Table(std::vector<VariationSelectorRecord>({
- { 0xFE0F, { }, { 'a' } }
- }));
+ std::vector<uint8_t> vsTable =
+ buildCmapFormat14Table(std::vector<VariationSelectorRecord>({{0xFE0F, {}, {'a'}}}));
CmapBuilder builder(1);
builder.appendTable(VS_PLATFORM_ID, VS_ENCODING_ID, vsTable);
diff --git a/tests/unittest/EmojiTest.cpp b/tests/unittest/EmojiTest.cpp
index 327cbd9..32ffde7 100644
--- a/tests/unittest/EmojiTest.cpp
+++ b/tests/unittest/EmojiTest.cpp
@@ -22,18 +22,18 @@
namespace minikin {
TEST(EmojiTest, isEmojiTest) {
- EXPECT_TRUE(isEmoji(0x0023)); // NUMBER SIGN
- EXPECT_TRUE(isEmoji(0x0035)); // DIGIT FIVE
- EXPECT_TRUE(isEmoji(0x2640)); // FEMALE SIGN
- EXPECT_TRUE(isEmoji(0x2642)); // MALE SIGN
- EXPECT_TRUE(isEmoji(0x2695)); // STAFF OF AESCULAPIUS
+ EXPECT_TRUE(isEmoji(0x0023)); // NUMBER SIGN
+ EXPECT_TRUE(isEmoji(0x0035)); // DIGIT FIVE
+ EXPECT_TRUE(isEmoji(0x2640)); // FEMALE SIGN
+ EXPECT_TRUE(isEmoji(0x2642)); // MALE SIGN
+ EXPECT_TRUE(isEmoji(0x2695)); // STAFF OF AESCULAPIUS
EXPECT_TRUE(isEmoji(0x1F0CF)); // PLAYING CARD BLACK JOKER
EXPECT_TRUE(isEmoji(0x1F1E9)); // REGIONAL INDICATOR SYMBOL LETTER D
EXPECT_TRUE(isEmoji(0x1F6F7)); // SLED
EXPECT_TRUE(isEmoji(0x1F9E6)); // SOCKS
- EXPECT_FALSE(isEmoji(0x0000)); // <control>
- EXPECT_FALSE(isEmoji(0x0061)); // LATIN SMALL LETTER A
+ EXPECT_FALSE(isEmoji(0x0000)); // <control>
+ EXPECT_FALSE(isEmoji(0x0061)); // LATIN SMALL LETTER A
EXPECT_FALSE(isEmoji(0x1F93B)); // MODERN PENTATHLON
EXPECT_FALSE(isEmoji(0x1F946)); // RIFLE
EXPECT_FALSE(isEmoji(0x29E3D)); // A han character.
@@ -46,15 +46,15 @@
EXPECT_TRUE(isEmojiModifier(0x1F3FE)); // EMOJI MODIFIER FITZPATRICK TYPE-5
EXPECT_TRUE(isEmojiModifier(0x1F3FF)); // EMOJI MODIFIER FITZPATRICK TYPE-6
- EXPECT_FALSE(isEmojiModifier(0x0000)); // <control>
+ EXPECT_FALSE(isEmojiModifier(0x0000)); // <control>
EXPECT_FALSE(isEmojiModifier(0x1F3FA)); // AMPHORA
EXPECT_FALSE(isEmojiModifier(0x1F400)); // RAT
EXPECT_FALSE(isEmojiModifier(0x29E3D)); // A han character.
}
TEST(EmojiTest, isEmojiBaseTest) {
- EXPECT_TRUE(isEmojiBase(0x261D)); // WHITE UP POINTING INDEX
- EXPECT_TRUE(isEmojiBase(0x270D)); // WRITING HAND
+ EXPECT_TRUE(isEmojiBase(0x261D)); // WHITE UP POINTING INDEX
+ EXPECT_TRUE(isEmojiBase(0x270D)); // WRITING HAND
EXPECT_TRUE(isEmojiBase(0x1F385)); // FATHER CHRISTMAS
EXPECT_TRUE(isEmojiBase(0x1F3C2)); // SNOWBOARDER
EXPECT_TRUE(isEmojiBase(0x1F3C7)); // HORSE RACING
@@ -69,8 +69,8 @@
EXPECT_TRUE(isEmojiBase(0x1F9D1)); // ADULT
EXPECT_TRUE(isEmojiBase(0x1F9DD)); // ELF
- EXPECT_FALSE(isEmojiBase(0x0000)); // <control>
- EXPECT_FALSE(isEmojiBase(0x261C)); // WHITE LEFT POINTING INDEX
+ EXPECT_FALSE(isEmojiBase(0x0000)); // <control>
+ EXPECT_FALSE(isEmojiBase(0x261C)); // WHITE LEFT POINTING INDEX
EXPECT_FALSE(isEmojiBase(0x1F384)); // CHRISTMAS TREE
EXPECT_FALSE(isEmojiBase(0x1F9DE)); // GENIE
EXPECT_FALSE(isEmojiBase(0x29E3D)); // A han character.
@@ -79,7 +79,7 @@
TEST(EmojiTest, emojiBidiOverrideTest) {
EXPECT_EQ(U_RIGHT_TO_LEFT, emojiBidiOverride(nullptr, 0x05D0)); // HEBREW LETTER ALEF
EXPECT_EQ(U_LEFT_TO_RIGHT,
- emojiBidiOverride(nullptr, 0x1F170)); // NEGATIVE SQUARED LATIN CAPITAL LETTER A
+ emojiBidiOverride(nullptr, 0x1F170)); // NEGATIVE SQUARED LATIN CAPITAL LETTER A
EXPECT_EQ(U_OTHER_NEUTRAL, emojiBidiOverride(nullptr, 0x1F6F7)); // SLED
EXPECT_EQ(U_OTHER_NEUTRAL, emojiBidiOverride(nullptr, 0x1F9E6)); // SOCKS
}
diff --git a/tests/unittest/FontCollectionItemizeTest.cpp b/tests/unittest/FontCollectionItemizeTest.cpp
index 628ebb0..2aa68be 100644
--- a/tests/unittest/FontCollectionItemizeTest.cpp
+++ b/tests/unittest/FontCollectionItemizeTest.cpp
@@ -22,6 +22,7 @@
#include "minikin/FontFamily.h"
#include "minikin/LocaleList.h"
+
#include "FontTestUtils.h"
#include "ICUTestBase.h"
#include "Locale.h"
@@ -45,13 +46,13 @@
const char kZH_HantFont[] = kTestFontDir "ZhHant.ttf";
const char kEmojiXmlFile[] = kTestFontDir "emoji.xml";
-const char kNoGlyphFont[] = kTestFontDir "NoGlyphFont.ttf";
+const char kNoGlyphFont[] = kTestFontDir "NoGlyphFont.ttf";
const char kColorEmojiFont[] = kTestFontDir "ColorEmojiFont.ttf";
const char kTextEmojiFont[] = kTestFontDir "TextEmojiFont.ttf";
const char kMixedEmojiFont[] = kTestFontDir "ColorTextMixedEmojiFont.ttf";
-const char kHasCmapFormat14Font[] = kTestFontDir "NoCmapFormat14.ttf";
-const char kNoCmapFormat14Font[] = kTestFontDir "VariationSelectorTest-Regular.ttf";
+const char kHasCmapFormat14Font[] = kTestFontDir "NoCmapFormat14.ttf";
+const char kNoCmapFormat14Font[] = kTestFontDir "VariationSelectorTest-Regular.ttf";
typedef ICUTestBase FontCollectionItemizeTest;
@@ -79,8 +80,8 @@
}
// Overloaded version for empty locale list id.
-void itemize(const std::shared_ptr<FontCollection>& collection, const char* str,
- FontStyle style, std::vector<FontCollection::Run>* result) {
+void itemize(const std::shared_ptr<FontCollection>& collection, const char* str, FontStyle style,
+ std::vector<FontCollection::Run>* result) {
itemize(collection, str, style, "", result);
}
@@ -749,12 +750,12 @@
std::vector<std::shared_ptr<FontFamily>> families;
std::shared_ptr<MinikinFont> font(new MinikinFontForTest(kLatinFont));
std::shared_ptr<FontFamily> family1(new FontFamily(FontFamily::Variant::DEFAULT,
- std::vector<Font>{ Font(font, FontStyle()) }));
+ std::vector<Font>{Font(font, FontStyle())}));
families.push_back(family1);
std::shared_ptr<MinikinFont> font2(new MinikinFontForTest(kVSTestFont));
- std::shared_ptr<FontFamily> family2(new FontFamily(FontFamily::Variant::DEFAULT,
- std::vector<Font>{ Font(font2, FontStyle()) }));
+ std::shared_ptr<FontFamily> family2(new FontFamily(
+ FontFamily::Variant::DEFAULT, std::vector<Font>{Font(font2, FontStyle())}));
families.push_back(family2);
std::shared_ptr<FontCollection> collection(new FontCollection(families));
@@ -839,102 +840,102 @@
std::vector<std::string> fontLocales;
int selectedFontIndex;
} testCases[] = {
- // Font can specify empty locale.
- { "und", { "", "" }, 0 },
- { "und", { "", "en-Latn" }, 0 },
- { "en-Latn", { "", "" }, 0 },
- { "en-Latn", { "", "en-Latn" }, 1 },
+ // Font can specify empty locale.
+ {"und", {"", ""}, 0},
+ {"und", {"", "en-Latn"}, 0},
+ {"en-Latn", {"", ""}, 0},
+ {"en-Latn", {"", "en-Latn"}, 1},
- // Single user preferred locale.
- // Exact match case
- { "en-Latn", { "en-Latn", "ja-Jpan" }, 0 },
- { "ja-Jpan", { "en-Latn", "ja-Jpan" }, 1 },
- { "en-Latn", { "en-Latn", "nl-Latn", "es-Latn" }, 0 },
- { "nl-Latn", { "en-Latn", "nl-Latn", "es-Latn" }, 1 },
- { "es-Latn", { "en-Latn", "nl-Latn", "es-Latn" }, 2 },
- { "es-Latn", { "en-Latn", "en-Latn", "nl-Latn" }, 0 },
+ // Single user preferred locale.
+ // Exact match case
+ {"en-Latn", {"en-Latn", "ja-Jpan"}, 0},
+ {"ja-Jpan", {"en-Latn", "ja-Jpan"}, 1},
+ {"en-Latn", {"en-Latn", "nl-Latn", "es-Latn"}, 0},
+ {"nl-Latn", {"en-Latn", "nl-Latn", "es-Latn"}, 1},
+ {"es-Latn", {"en-Latn", "nl-Latn", "es-Latn"}, 2},
+ {"es-Latn", {"en-Latn", "en-Latn", "nl-Latn"}, 0},
- // Exact script match case
- { "en-Latn", { "nl-Latn", "e-Latn" }, 0 },
- { "en-Arab", { "nl-Latn", "ar-Arab" }, 1 },
- { "en-Latn", { "be-Latn", "ar-Arab", "d-Beng" }, 0 },
- { "en-Arab", { "be-Latn", "ar-Arab", "d-Beng" }, 1 },
- { "en-Beng", { "be-Latn", "ar-Arab", "d-Beng" }, 2 },
- { "en-Beng", { "be-Latn", "ar-Beng", "d-Beng" }, 1 },
- { "zh-Hant", { "zh-Hant", "zh-Hans" }, 0 },
- { "zh-Hans", { "zh-Hant", "zh-Hans" }, 1 },
+ // Exact script match case
+ {"en-Latn", {"nl-Latn", "e-Latn"}, 0},
+ {"en-Arab", {"nl-Latn", "ar-Arab"}, 1},
+ {"en-Latn", {"be-Latn", "ar-Arab", "d-Beng"}, 0},
+ {"en-Arab", {"be-Latn", "ar-Arab", "d-Beng"}, 1},
+ {"en-Beng", {"be-Latn", "ar-Arab", "d-Beng"}, 2},
+ {"en-Beng", {"be-Latn", "ar-Beng", "d-Beng"}, 1},
+ {"zh-Hant", {"zh-Hant", "zh-Hans"}, 0},
+ {"zh-Hans", {"zh-Hant", "zh-Hans"}, 1},
- // Subscript match case, e.g. Jpan supports Hira.
- { "en-Hira", { "ja-Jpan" }, 0 },
- { "zh-Hani", { "zh-Hans", "zh-Hant" }, 0 },
- { "zh-Hani", { "zh-Hant", "zh-Hans" }, 0 },
- { "en-Hira", { "zh-Hant", "ja-Jpan", "ja-Jpan" }, 1 },
+ // Subscript match case, e.g. Jpan supports Hira.
+ {"en-Hira", {"ja-Jpan"}, 0},
+ {"zh-Hani", {"zh-Hans", "zh-Hant"}, 0},
+ {"zh-Hani", {"zh-Hant", "zh-Hans"}, 0},
+ {"en-Hira", {"zh-Hant", "ja-Jpan", "ja-Jpan"}, 1},
- // Language match case
- { "ja-Latn", { "zh-Latn", "ja-Latn" }, 1 },
- { "zh-Latn", { "zh-Latn", "ja-Latn" }, 0 },
- { "ja-Latn", { "zh-Latn", "ja-Latn" }, 1 },
- { "ja-Latn", { "zh-Latn", "ja-Latn", "ja-Latn" }, 1 },
+ // Language match case
+ {"ja-Latn", {"zh-Latn", "ja-Latn"}, 1},
+ {"zh-Latn", {"zh-Latn", "ja-Latn"}, 0},
+ {"ja-Latn", {"zh-Latn", "ja-Latn"}, 1},
+ {"ja-Latn", {"zh-Latn", "ja-Latn", "ja-Latn"}, 1},
- // Mixed case
- // Script/subscript match is strongest.
- { "ja-Jpan", { "en-Latn", "ja-Latn", "en-Jpan" }, 2 },
- { "ja-Hira", { "en-Latn", "ja-Latn", "en-Jpan" }, 2 },
- { "ja-Hira", { "en-Latn", "ja-Latn", "en-Jpan", "en-Jpan" }, 2 },
+ // Mixed case
+ // Script/subscript match is strongest.
+ {"ja-Jpan", {"en-Latn", "ja-Latn", "en-Jpan"}, 2},
+ {"ja-Hira", {"en-Latn", "ja-Latn", "en-Jpan"}, 2},
+ {"ja-Hira", {"en-Latn", "ja-Latn", "en-Jpan", "en-Jpan"}, 2},
- // Language match only happens if the script matches.
- { "ja-Hira", { "en-Latn", "ja-Latn" }, 0 },
- { "ja-Hira", { "en-Jpan", "ja-Jpan" }, 1 },
+ // Language match only happens if the script matches.
+ {"ja-Hira", {"en-Latn", "ja-Latn"}, 0},
+ {"ja-Hira", {"en-Jpan", "ja-Jpan"}, 1},
- // Multiple locales.
- // Even if all fonts have the same score, use the 2nd locale for better selection.
- { "en-Latn,ja-Jpan", { "zh-Hant", "zh-Hans", "ja-Jpan" }, 2 },
- { "en-Latn,nl-Latn", { "es-Latn", "be-Latn", "nl-Latn" }, 2 },
- { "en-Latn,br-Latn,nl-Latn", { "es-Latn", "be-Latn", "nl-Latn" }, 2 },
- { "en-Latn,br-Latn,nl-Latn", { "es-Latn", "be-Latn", "nl-Latn", "nl-Latn" }, 2 },
+ // Multiple locales.
+ // Even if all fonts have the same score, use the 2nd locale for better selection.
+ {"en-Latn,ja-Jpan", {"zh-Hant", "zh-Hans", "ja-Jpan"}, 2},
+ {"en-Latn,nl-Latn", {"es-Latn", "be-Latn", "nl-Latn"}, 2},
+ {"en-Latn,br-Latn,nl-Latn", {"es-Latn", "be-Latn", "nl-Latn"}, 2},
+ {"en-Latn,br-Latn,nl-Latn", {"es-Latn", "be-Latn", "nl-Latn", "nl-Latn"}, 2},
- // Script score.
- { "en-Latn,ja-Jpan", { "en-Arab", "en-Jpan" }, 1 },
- { "en-Latn,ja-Jpan", { "en-Arab", "en-Jpan", "en-Jpan" }, 1 },
+ // Script score.
+ {"en-Latn,ja-Jpan", {"en-Arab", "en-Jpan"}, 1},
+ {"en-Latn,ja-Jpan", {"en-Arab", "en-Jpan", "en-Jpan"}, 1},
- // Language match case
- { "en-Latn,ja-Latn", { "bd-Latn", "ja-Latn" }, 1 },
- { "en-Latn,ja-Latn", { "bd-Latn", "ja-Latn", "ja-Latn" }, 1 },
+ // Language match case
+ {"en-Latn,ja-Latn", {"bd-Latn", "ja-Latn"}, 1},
+ {"en-Latn,ja-Latn", {"bd-Latn", "ja-Latn", "ja-Latn"}, 1},
- // Language match only happens if the script matches.
- { "en-Latn,ar-Arab", { "en-Beng", "ar-Arab" }, 1 },
+ // Language match only happens if the script matches.
+ {"en-Latn,ar-Arab", {"en-Beng", "ar-Arab"}, 1},
- // Multiple locales in the font settings.
- { "ko-Jamo", { "ja-Jpan", "ko-Kore", "ko-Kore,ko-Jamo"}, 2 },
- { "en-Latn", { "ja-Jpan", "en-Latn,ja-Jpan"}, 1 },
- { "en-Latn", { "ja-Jpan", "ja-Jpan,en-Latn"}, 1 },
- { "en-Latn", { "ja-Jpan,zh-Hant", "en-Latn,ja-Jpan", "en-Latn"}, 1 },
- { "en-Latn", { "zh-Hant,ja-Jpan", "ja-Jpan,en-Latn", "en-Latn"}, 1 },
+ // Multiple locales in the font settings.
+ {"ko-Jamo", {"ja-Jpan", "ko-Kore", "ko-Kore,ko-Jamo"}, 2},
+ {"en-Latn", {"ja-Jpan", "en-Latn,ja-Jpan"}, 1},
+ {"en-Latn", {"ja-Jpan", "ja-Jpan,en-Latn"}, 1},
+ {"en-Latn", {"ja-Jpan,zh-Hant", "en-Latn,ja-Jpan", "en-Latn"}, 1},
+ {"en-Latn", {"zh-Hant,ja-Jpan", "ja-Jpan,en-Latn", "en-Latn"}, 1},
- // Kore = Hang + Hani, etc.
- { "ko-Kore", { "ko-Hang", "ko-Jamo,ko-Hani", "ko-Hang,ko-Hani"}, 2 },
- { "ja-Hrkt", { "ja-Hira", "ja-Kana", "ja-Hira,ja-Kana"}, 2 },
- { "ja-Jpan", { "ja-Hira", "ja-Kana", "ja-Hani", "ja-Hira,ja-Kana,ja-Hani"}, 3 },
- { "zh-Hanb", { "zh-Hant", "zh-Bopo", "zh-Hant,zh-Bopo"}, 2 },
- { "zh-Hanb", { "ja-Hanb", "zh-Hant,zh-Bopo"}, 1 },
+ // Kore = Hang + Hani, etc.
+ {"ko-Kore", {"ko-Hang", "ko-Jamo,ko-Hani", "ko-Hang,ko-Hani"}, 2},
+ {"ja-Hrkt", {"ja-Hira", "ja-Kana", "ja-Hira,ja-Kana"}, 2},
+ {"ja-Jpan", {"ja-Hira", "ja-Kana", "ja-Hani", "ja-Hira,ja-Kana,ja-Hani"}, 3},
+ {"zh-Hanb", {"zh-Hant", "zh-Bopo", "zh-Hant,zh-Bopo"}, 2},
+ {"zh-Hanb", {"ja-Hanb", "zh-Hant,zh-Bopo"}, 1},
- // Language match with unified subscript bits.
- { "zh-Hanb", { "zh-Hant", "zh-Bopo", "ja-Hant,ja-Bopo", "zh-Hant,zh-Bopo"}, 3 },
- { "zh-Hanb", { "zh-Hant", "zh-Bopo", "ja-Hant,zh-Bopo", "zh-Hant,zh-Bopo"}, 3 },
+ // Language match with unified subscript bits.
+ {"zh-Hanb", {"zh-Hant", "zh-Bopo", "ja-Hant,ja-Bopo", "zh-Hant,zh-Bopo"}, 3},
+ {"zh-Hanb", {"zh-Hant", "zh-Bopo", "ja-Hant,zh-Bopo", "zh-Hant,zh-Bopo"}, 3},
- // Two elements subtag matching: language and subtag or language or script.
- { "ja-Kana-u-em-emoji", { "zh-Hant", "ja-Kana"}, 1 },
- { "ja-Kana-u-em-emoji", { "zh-Hant", "ja-Kana", "ja-Zsye"}, 2 },
- { "ja-Zsym-u-em-emoji", { "ja-Kana", "ja-Zsym", "ja-Zsye"}, 2 },
+ // Two elements subtag matching: language and subtag or language or script.
+ {"ja-Kana-u-em-emoji", {"zh-Hant", "ja-Kana"}, 1},
+ {"ja-Kana-u-em-emoji", {"zh-Hant", "ja-Kana", "ja-Zsye"}, 2},
+ {"ja-Zsym-u-em-emoji", {"ja-Kana", "ja-Zsym", "ja-Zsye"}, 2},
- // One element subtag matching: subtag only or script only.
- { "en-Latn-u-em-emoji", { "ja-Latn", "ja-Zsye"}, 1 },
- { "en-Zsym-u-em-emoji", { "ja-Zsym", "ja-Zsye"}, 1 },
- { "en-Zsye-u-em-text", { "ja-Zsym", "ja-Zsye"}, 0 },
+ // One element subtag matching: subtag only or script only.
+ {"en-Latn-u-em-emoji", {"ja-Latn", "ja-Zsye"}, 1},
+ {"en-Zsym-u-em-emoji", {"ja-Zsym", "ja-Zsye"}, 1},
+ {"en-Zsye-u-em-text", {"ja-Zsym", "ja-Zsye"}, 0},
- // Multiple locale list with subtags.
- { "en-Latn,ja-Jpan-u-em-text", { "en-Latn", "en-Zsye", "en-Zsym"}, 0 },
- { "en-Latn,en-Zsye,ja-Jpan-u-em-text", { "zh", "en-Zsye", "en-Zsym"}, 1 },
+ // Multiple locale list with subtags.
+ {"en-Latn,ja-Jpan-u-em-text", {"en-Latn", "en-Zsye", "en-Zsym"}, 0},
+ {"en-Latn,en-Zsye,ja-Jpan-u-em-text", {"zh", "en-Zsye", "en-Zsym"}, 1},
};
for (auto testCase : testCases) {
@@ -952,11 +953,10 @@
std::vector<std::shared_ptr<FontFamily>> families;
// Prepare first font which doesn't supports U+9AA8
- std::shared_ptr<MinikinFont> firstFamilyMinikinFont(
- new MinikinFontForTest(kNoGlyphFont));
- std::shared_ptr<FontFamily> firstFamily(new FontFamily(
- registerLocaleList("und"), FontFamily::Variant::DEFAULT,
- std::vector<Font>({ Font(firstFamilyMinikinFont, FontStyle()) })));
+ std::shared_ptr<MinikinFont> firstFamilyMinikinFont(new MinikinFontForTest(kNoGlyphFont));
+ std::shared_ptr<FontFamily> firstFamily(
+ new FontFamily(registerLocaleList("und"), FontFamily::Variant::DEFAULT,
+ std::vector<Font>({Font(firstFamilyMinikinFont, FontStyle())})));
families.push_back(firstFamily);
// Prepare font families
@@ -968,7 +968,7 @@
std::shared_ptr<MinikinFont> minikin_font(new MinikinFontForTest(kJAFont));
std::shared_ptr<FontFamily> family(new FontFamily(
registerLocaleList(testCase.fontLocales[i]), FontFamily::Variant::DEFAULT,
- std::vector<Font>({ Font(minikin_font, FontStyle()) })));
+ std::vector<Font>({Font(minikin_font, FontStyle())})));
families.push_back(family);
fontLocaleIdxMap.insert(std::make_pair(minikin_font.get(), i));
}
@@ -995,290 +995,294 @@
std::string requestedLocales;
std::string expectedFont;
} testCases[] = {
- // Following test cases verify that following rules in font fallback chain.
- // - If the first font in the collection supports the given character or variation sequence,
- // it should be selected.
- // - If the font doesn't support the given character, variation sequence or its base
- // character, it should not be selected.
- // - If two or more fonts match the requested locales, the font matches with the highest
- // priority locale should be selected.
- // - If two or more fonts get the same score, the font listed earlier in the XML file
- // (here, kItemizeFontXml) should be selected.
+ // Following test cases verify that following rules in font fallback chain.
+ // - If the first font in the collection supports the given character or variation
+ // sequence,
+ // it should be selected.
+ // - If the font doesn't support the given character, variation sequence or its base
+ // character, it should not be selected.
+ // - If two or more fonts match the requested locales, the font matches with the highest
+ // priority locale should be selected.
+ // - If two or more fonts get the same score, the font listed earlier in the XML file
+ // (here, kItemizeFontXml) should be selected.
- // Regardless of locale, the first font is always selected if it covers the code point.
- { "'a'", "", kLatinFont},
- { "'a'", "en-Latn", kLatinFont},
- { "'a'", "ja-Jpan", kLatinFont},
- { "'a'", "ja-Jpan,en-Latn", kLatinFont},
- { "'a'", "zh-Hans,zh-Hant,en-Latn,ja-Jpan,fr-Latn", kLatinFont},
+ // Regardless of locale, the first font is always selected if it covers the code point.
+ {"'a'", "", kLatinFont},
+ {"'a'", "en-Latn", kLatinFont},
+ {"'a'", "ja-Jpan", kLatinFont},
+ {"'a'", "ja-Jpan,en-Latn", kLatinFont},
+ {"'a'", "zh-Hans,zh-Hant,en-Latn,ja-Jpan,fr-Latn", kLatinFont},
- // U+81ED is supported by both the ja font and zh-Hans font.
- { "U+81ED", "", kZH_HansFont }, // zh-Hans font is listed before ja font.
- { "U+81ED", "en-Latn", kZH_HansFont }, // zh-Hans font is listed before ja font.
- { "U+81ED", "ja-Jpan", kJAFont },
- { "U+81ED", "zh-Hans", kZH_HansFont },
+ // U+81ED is supported by both the ja font and zh-Hans font.
+ {"U+81ED", "", kZH_HansFont}, // zh-Hans font is listed before ja font.
+ {"U+81ED", "en-Latn", kZH_HansFont}, // zh-Hans font is listed before ja font.
+ {"U+81ED", "ja-Jpan", kJAFont},
+ {"U+81ED", "zh-Hans", kZH_HansFont},
- { "U+81ED", "ja-Jpan,en-Latn", kJAFont },
- { "U+81ED", "en-Latn,ja-Jpan", kJAFont },
- { "U+81ED", "en-Latn,zh-Hans", kZH_HansFont },
- { "U+81ED", "zh-Hans,en-Latn", kZH_HansFont },
- { "U+81ED", "ja-Jpan,zh-Hans", kJAFont },
- { "U+81ED", "zh-Hans,ja-Jpan", kZH_HansFont },
+ {"U+81ED", "ja-Jpan,en-Latn", kJAFont},
+ {"U+81ED", "en-Latn,ja-Jpan", kJAFont},
+ {"U+81ED", "en-Latn,zh-Hans", kZH_HansFont},
+ {"U+81ED", "zh-Hans,en-Latn", kZH_HansFont},
+ {"U+81ED", "ja-Jpan,zh-Hans", kJAFont},
+ {"U+81ED", "zh-Hans,ja-Jpan", kZH_HansFont},
- { "U+81ED", "en-Latn,zh-Hans,ja-Jpan", kZH_HansFont },
- { "U+81ED", "en-Latn,ja-Jpan,zh-Hans", kJAFont },
- { "U+81ED", "en-Latn,zh-Hans,ja-Jpan", kZH_HansFont },
- { "U+81ED", "ja-Jpan,en-Latn,zh-Hans", kJAFont },
- { "U+81ED", "ja-Jpan,zh-Hans,en-Latn", kJAFont },
- { "U+81ED", "zh-Hans,en-Latn,ja-Jpan", kZH_HansFont },
- { "U+81ED", "zh-Hans,ja-Jpan,en-Latn", kZH_HansFont },
+ {"U+81ED", "en-Latn,zh-Hans,ja-Jpan", kZH_HansFont},
+ {"U+81ED", "en-Latn,ja-Jpan,zh-Hans", kJAFont},
+ {"U+81ED", "en-Latn,zh-Hans,ja-Jpan", kZH_HansFont},
+ {"U+81ED", "ja-Jpan,en-Latn,zh-Hans", kJAFont},
+ {"U+81ED", "ja-Jpan,zh-Hans,en-Latn", kJAFont},
+ {"U+81ED", "zh-Hans,en-Latn,ja-Jpan", kZH_HansFont},
+ {"U+81ED", "zh-Hans,ja-Jpan,en-Latn", kZH_HansFont},
- // U+304A is only supported by ja font.
- { "U+304A", "", kJAFont },
- { "U+304A", "ja-Jpan", kJAFont },
- { "U+304A", "zh-Hant", kJAFont },
- { "U+304A", "zh-Hans", kJAFont },
+ // U+304A is only supported by ja font.
+ {"U+304A", "", kJAFont},
+ {"U+304A", "ja-Jpan", kJAFont},
+ {"U+304A", "zh-Hant", kJAFont},
+ {"U+304A", "zh-Hans", kJAFont},
- { "U+304A", "ja-Jpan,zh-Hant", kJAFont },
- { "U+304A", "zh-Hant,ja-Jpan", kJAFont },
- { "U+304A", "zh-Hans,zh-Hant", kJAFont },
- { "U+304A", "zh-Hant,zh-Hans", kJAFont },
- { "U+304A", "zh-Hans,ja-Jpan", kJAFont },
- { "U+304A", "ja-Jpan,zh-Hans", kJAFont },
+ {"U+304A", "ja-Jpan,zh-Hant", kJAFont},
+ {"U+304A", "zh-Hant,ja-Jpan", kJAFont},
+ {"U+304A", "zh-Hans,zh-Hant", kJAFont},
+ {"U+304A", "zh-Hant,zh-Hans", kJAFont},
+ {"U+304A", "zh-Hans,ja-Jpan", kJAFont},
+ {"U+304A", "ja-Jpan,zh-Hans", kJAFont},
- { "U+304A", "zh-Hans,ja-Jpan,zh-Hant", kJAFont },
- { "U+304A", "zh-Hans,zh-Hant,ja-Jpan", kJAFont },
- { "U+304A", "ja-Jpan,zh-Hans,zh-Hant", kJAFont },
- { "U+304A", "ja-Jpan,zh-Hant,zh-Hans", kJAFont },
- { "U+304A", "zh-Hant,zh-Hans,ja-Jpan", kJAFont },
- { "U+304A", "zh-Hant,ja-Jpan,zh-Hans", kJAFont },
+ {"U+304A", "zh-Hans,ja-Jpan,zh-Hant", kJAFont},
+ {"U+304A", "zh-Hans,zh-Hant,ja-Jpan", kJAFont},
+ {"U+304A", "ja-Jpan,zh-Hans,zh-Hant", kJAFont},
+ {"U+304A", "ja-Jpan,zh-Hant,zh-Hans", kJAFont},
+ {"U+304A", "zh-Hant,zh-Hans,ja-Jpan", kJAFont},
+ {"U+304A", "zh-Hant,ja-Jpan,zh-Hans", kJAFont},
- // U+242EE is supported by both ja font and zh-Hant fonts but not by zh-Hans font.
- { "U+242EE", "", kJAFont }, // ja font is listed before zh-Hant font.
- { "U+242EE", "ja-Jpan", kJAFont },
- { "U+242EE", "zh-Hans", kJAFont },
- { "U+242EE", "zh-Hant", kZH_HantFont },
+ // U+242EE is supported by both ja font and zh-Hant fonts but not by zh-Hans font.
+ {"U+242EE", "", kJAFont}, // ja font is listed before zh-Hant font.
+ {"U+242EE", "ja-Jpan", kJAFont},
+ {"U+242EE", "zh-Hans", kJAFont},
+ {"U+242EE", "zh-Hant", kZH_HantFont},
- { "U+242EE", "ja-Jpan,zh-Hant", kJAFont },
- { "U+242EE", "zh-Hant,ja-Jpan", kZH_HantFont },
- { "U+242EE", "zh-Hans,zh-Hant", kZH_HantFont },
- { "U+242EE", "zh-Hant,zh-Hans", kZH_HantFont },
- { "U+242EE", "zh-Hans,ja-Jpan", kJAFont },
- { "U+242EE", "ja-Jpan,zh-Hans", kJAFont },
+ {"U+242EE", "ja-Jpan,zh-Hant", kJAFont},
+ {"U+242EE", "zh-Hant,ja-Jpan", kZH_HantFont},
+ {"U+242EE", "zh-Hans,zh-Hant", kZH_HantFont},
+ {"U+242EE", "zh-Hant,zh-Hans", kZH_HantFont},
+ {"U+242EE", "zh-Hans,ja-Jpan", kJAFont},
+ {"U+242EE", "ja-Jpan,zh-Hans", kJAFont},
- { "U+242EE", "zh-Hans,ja-Jpan,zh-Hant", kJAFont },
- { "U+242EE", "zh-Hans,zh-Hant,ja-Jpan", kZH_HantFont },
- { "U+242EE", "ja-Jpan,zh-Hans,zh-Hant", kJAFont },
- { "U+242EE", "ja-Jpan,zh-Hant,zh-Hans", kJAFont },
- { "U+242EE", "zh-Hant,zh-Hans,ja-Jpan", kZH_HantFont },
- { "U+242EE", "zh-Hant,ja-Jpan,zh-Hans", kZH_HantFont },
+ {"U+242EE", "zh-Hans,ja-Jpan,zh-Hant", kJAFont},
+ {"U+242EE", "zh-Hans,zh-Hant,ja-Jpan", kZH_HantFont},
+ {"U+242EE", "ja-Jpan,zh-Hans,zh-Hant", kJAFont},
+ {"U+242EE", "ja-Jpan,zh-Hant,zh-Hans", kJAFont},
+ {"U+242EE", "zh-Hant,zh-Hans,ja-Jpan", kZH_HantFont},
+ {"U+242EE", "zh-Hant,ja-Jpan,zh-Hans", kZH_HantFont},
- // U+9AA8 is supported by all ja-Jpan, zh-Hans, zh-Hant fonts.
- { "U+9AA8", "", kZH_HansFont }, // zh-Hans font is listed before ja and zh-Hant fonts.
- { "U+9AA8", "ja-Jpan", kJAFont },
- { "U+9AA8", "zh-Hans", kZH_HansFont },
- { "U+9AA8", "zh-Hant", kZH_HantFont },
+ // U+9AA8 is supported by all ja-Jpan, zh-Hans, zh-Hant fonts.
+ {"U+9AA8", "", kZH_HansFont}, // zh-Hans font is listed before ja and zh-Hant fonts.
+ {"U+9AA8", "ja-Jpan", kJAFont},
+ {"U+9AA8", "zh-Hans", kZH_HansFont},
+ {"U+9AA8", "zh-Hant", kZH_HantFont},
- { "U+9AA8", "ja-Jpan,zh-Hant", kJAFont },
- { "U+9AA8", "zh-Hant,ja-Jpan", kZH_HantFont },
- { "U+9AA8", "zh-Hans,zh-Hant", kZH_HansFont },
- { "U+9AA8", "zh-Hant,zh-Hans", kZH_HantFont },
- { "U+9AA8", "zh-Hans,ja-Jpan", kZH_HansFont },
- { "U+9AA8", "ja-Jpan,zh-Hans", kJAFont },
+ {"U+9AA8", "ja-Jpan,zh-Hant", kJAFont},
+ {"U+9AA8", "zh-Hant,ja-Jpan", kZH_HantFont},
+ {"U+9AA8", "zh-Hans,zh-Hant", kZH_HansFont},
+ {"U+9AA8", "zh-Hant,zh-Hans", kZH_HantFont},
+ {"U+9AA8", "zh-Hans,ja-Jpan", kZH_HansFont},
+ {"U+9AA8", "ja-Jpan,zh-Hans", kJAFont},
- { "U+9AA8", "zh-Hans,ja-Jpan,zh-Hant", kZH_HansFont },
- { "U+9AA8", "zh-Hans,zh-Hant,ja-Jpan", kZH_HansFont },
- { "U+9AA8", "ja-Jpan,zh-Hans,zh-Hant", kJAFont },
- { "U+9AA8", "ja-Jpan,zh-Hant,zh-Hans", kJAFont },
- { "U+9AA8", "zh-Hant,zh-Hans,ja-Jpan", kZH_HantFont },
- { "U+9AA8", "zh-Hant,ja-Jpan,zh-Hans", kZH_HantFont },
+ {"U+9AA8", "zh-Hans,ja-Jpan,zh-Hant", kZH_HansFont},
+ {"U+9AA8", "zh-Hans,zh-Hant,ja-Jpan", kZH_HansFont},
+ {"U+9AA8", "ja-Jpan,zh-Hans,zh-Hant", kJAFont},
+ {"U+9AA8", "ja-Jpan,zh-Hant,zh-Hans", kJAFont},
+ {"U+9AA8", "zh-Hant,zh-Hans,ja-Jpan", kZH_HantFont},
+ {"U+9AA8", "zh-Hant,ja-Jpan,zh-Hans", kZH_HantFont},
- // U+242EE U+FE00 is supported by ja font but not by zh-Hans or zh-Hant fonts.
- { "U+242EE U+FE00", "", kJAFont },
- { "U+242EE U+FE00", "ja-Jpan", kJAFont },
- { "U+242EE U+FE00", "zh-Hant", kJAFont },
- { "U+242EE U+FE00", "zh-Hans", kJAFont },
+ // U+242EE U+FE00 is supported by ja font but not by zh-Hans or zh-Hant fonts.
+ {"U+242EE U+FE00", "", kJAFont},
+ {"U+242EE U+FE00", "ja-Jpan", kJAFont},
+ {"U+242EE U+FE00", "zh-Hant", kJAFont},
+ {"U+242EE U+FE00", "zh-Hans", kJAFont},
- { "U+242EE U+FE00", "ja-Jpan,zh-Hant", kJAFont },
- { "U+242EE U+FE00", "zh-Hant,ja-Jpan", kJAFont },
- { "U+242EE U+FE00", "zh-Hans,zh-Hant", kJAFont },
- { "U+242EE U+FE00", "zh-Hant,zh-Hans", kJAFont },
- { "U+242EE U+FE00", "zh-Hans,ja-Jpan", kJAFont },
- { "U+242EE U+FE00", "ja-Jpan,zh-Hans", kJAFont },
+ {"U+242EE U+FE00", "ja-Jpan,zh-Hant", kJAFont},
+ {"U+242EE U+FE00", "zh-Hant,ja-Jpan", kJAFont},
+ {"U+242EE U+FE00", "zh-Hans,zh-Hant", kJAFont},
+ {"U+242EE U+FE00", "zh-Hant,zh-Hans", kJAFont},
+ {"U+242EE U+FE00", "zh-Hans,ja-Jpan", kJAFont},
+ {"U+242EE U+FE00", "ja-Jpan,zh-Hans", kJAFont},
- { "U+242EE U+FE00", "zh-Hans,ja-Jpan,zh-Hant", kJAFont },
- { "U+242EE U+FE00", "zh-Hans,zh-Hant,ja-Jpan", kJAFont },
- { "U+242EE U+FE00", "ja-Jpan,zh-Hans,zh-Hant", kJAFont },
- { "U+242EE U+FE00", "ja-Jpan,zh-Hant,zh-Hans", kJAFont },
- { "U+242EE U+FE00", "zh-Hant,zh-Hans,ja-Jpan", kJAFont },
- { "U+242EE U+FE00", "zh-Hant,ja-Jpan,zh-Hans", kJAFont },
+ {"U+242EE U+FE00", "zh-Hans,ja-Jpan,zh-Hant", kJAFont},
+ {"U+242EE U+FE00", "zh-Hans,zh-Hant,ja-Jpan", kJAFont},
+ {"U+242EE U+FE00", "ja-Jpan,zh-Hans,zh-Hant", kJAFont},
+ {"U+242EE U+FE00", "ja-Jpan,zh-Hant,zh-Hans", kJAFont},
+ {"U+242EE U+FE00", "zh-Hant,zh-Hans,ja-Jpan", kJAFont},
+ {"U+242EE U+FE00", "zh-Hant,ja-Jpan,zh-Hans", kJAFont},
- // U+3402 U+E0100 is supported by both zh-Hans and zh-Hant but not by ja font.
- { "U+3402 U+E0100", "", kZH_HansFont }, // zh-Hans font is listed before zh-Hant font.
- { "U+3402 U+E0100", "ja-Jpan", kZH_HansFont }, // zh-Hans font is listed before zh-Hant font.
- { "U+3402 U+E0100", "zh-Hant", kZH_HantFont },
- { "U+3402 U+E0100", "zh-Hans", kZH_HansFont },
+ // U+3402 U+E0100 is supported by both zh-Hans and zh-Hant but not by ja font.
+ {"U+3402 U+E0100", "", kZH_HansFont}, // zh-Hans font is listed before zh-Hant font.
+ {"U+3402 U+E0100", "ja-Jpan",
+ kZH_HansFont}, // zh-Hans font is listed before zh-Hant font.
+ {"U+3402 U+E0100", "zh-Hant", kZH_HantFont},
+ {"U+3402 U+E0100", "zh-Hans", kZH_HansFont},
- { "U+3402 U+E0100", "ja-Jpan,zh-Hant", kZH_HantFont },
- { "U+3402 U+E0100", "zh-Hant,ja-Jpan", kZH_HantFont },
- { "U+3402 U+E0100", "zh-Hans,zh-Hant", kZH_HansFont },
- { "U+3402 U+E0100", "zh-Hant,zh-Hans", kZH_HantFont },
- { "U+3402 U+E0100", "zh-Hans,ja-Jpan", kZH_HansFont },
- { "U+3402 U+E0100", "ja-Jpan,zh-Hans", kZH_HansFont },
+ {"U+3402 U+E0100", "ja-Jpan,zh-Hant", kZH_HantFont},
+ {"U+3402 U+E0100", "zh-Hant,ja-Jpan", kZH_HantFont},
+ {"U+3402 U+E0100", "zh-Hans,zh-Hant", kZH_HansFont},
+ {"U+3402 U+E0100", "zh-Hant,zh-Hans", kZH_HantFont},
+ {"U+3402 U+E0100", "zh-Hans,ja-Jpan", kZH_HansFont},
+ {"U+3402 U+E0100", "ja-Jpan,zh-Hans", kZH_HansFont},
- { "U+3402 U+E0100", "zh-Hans,ja-Jpan,zh-Hant", kZH_HansFont },
- { "U+3402 U+E0100", "zh-Hans,zh-Hant,ja-Jpan", kZH_HansFont },
- { "U+3402 U+E0100", "ja-Jpan,zh-Hans,zh-Hant", kZH_HansFont },
- { "U+3402 U+E0100", "ja-Jpan,zh-Hant,zh-Hans", kZH_HantFont },
- { "U+3402 U+E0100", "zh-Hant,zh-Hans,ja-Jpan", kZH_HantFont },
- { "U+3402 U+E0100", "zh-Hant,ja-Jpan,zh-Hans", kZH_HantFont },
+ {"U+3402 U+E0100", "zh-Hans,ja-Jpan,zh-Hant", kZH_HansFont},
+ {"U+3402 U+E0100", "zh-Hans,zh-Hant,ja-Jpan", kZH_HansFont},
+ {"U+3402 U+E0100", "ja-Jpan,zh-Hans,zh-Hant", kZH_HansFont},
+ {"U+3402 U+E0100", "ja-Jpan,zh-Hant,zh-Hans", kZH_HantFont},
+ {"U+3402 U+E0100", "zh-Hant,zh-Hans,ja-Jpan", kZH_HantFont},
+ {"U+3402 U+E0100", "zh-Hant,ja-Jpan,zh-Hans", kZH_HantFont},
- // No font supports U+4444 U+FE00 but only zh-Hans supports its base character U+4444.
- { "U+4444 U+FE00", "", kZH_HansFont },
- { "U+4444 U+FE00", "ja-Jpan", kZH_HansFont },
- { "U+4444 U+FE00", "zh-Hant", kZH_HansFont },
- { "U+4444 U+FE00", "zh-Hans", kZH_HansFont },
+ // No font supports U+4444 U+FE00 but only zh-Hans supports its base character U+4444.
+ {"U+4444 U+FE00", "", kZH_HansFont},
+ {"U+4444 U+FE00", "ja-Jpan", kZH_HansFont},
+ {"U+4444 U+FE00", "zh-Hant", kZH_HansFont},
+ {"U+4444 U+FE00", "zh-Hans", kZH_HansFont},
- { "U+4444 U+FE00", "ja-Jpan,zh-Hant", kZH_HansFont },
- { "U+4444 U+FE00", "zh-Hant,ja-Jpan", kZH_HansFont },
- { "U+4444 U+FE00", "zh-Hans,zh-Hant", kZH_HansFont },
- { "U+4444 U+FE00", "zh-Hant,zh-Hans", kZH_HansFont },
- { "U+4444 U+FE00", "zh-Hans,ja-Jpan", kZH_HansFont },
- { "U+4444 U+FE00", "ja-Jpan,zh-Hans", kZH_HansFont },
+ {"U+4444 U+FE00", "ja-Jpan,zh-Hant", kZH_HansFont},
+ {"U+4444 U+FE00", "zh-Hant,ja-Jpan", kZH_HansFont},
+ {"U+4444 U+FE00", "zh-Hans,zh-Hant", kZH_HansFont},
+ {"U+4444 U+FE00", "zh-Hant,zh-Hans", kZH_HansFont},
+ {"U+4444 U+FE00", "zh-Hans,ja-Jpan", kZH_HansFont},
+ {"U+4444 U+FE00", "ja-Jpan,zh-Hans", kZH_HansFont},
- { "U+4444 U+FE00", "zh-Hans,ja-Jpan,zh-Hant", kZH_HansFont },
- { "U+4444 U+FE00", "zh-Hans,zh-Hant,ja-Jpan", kZH_HansFont },
- { "U+4444 U+FE00", "ja-Jpan,zh-Hans,zh-Hant", kZH_HansFont },
- { "U+4444 U+FE00", "ja-Jpan,zh-Hant,zh-Hans", kZH_HansFont },
- { "U+4444 U+FE00", "zh-Hant,zh-Hans,ja-Jpan", kZH_HansFont },
- { "U+4444 U+FE00", "zh-Hant,ja-Jpan,zh-Hans", kZH_HansFont },
+ {"U+4444 U+FE00", "zh-Hans,ja-Jpan,zh-Hant", kZH_HansFont},
+ {"U+4444 U+FE00", "zh-Hans,zh-Hant,ja-Jpan", kZH_HansFont},
+ {"U+4444 U+FE00", "ja-Jpan,zh-Hans,zh-Hant", kZH_HansFont},
+ {"U+4444 U+FE00", "ja-Jpan,zh-Hant,zh-Hans", kZH_HansFont},
+ {"U+4444 U+FE00", "zh-Hant,zh-Hans,ja-Jpan", kZH_HansFont},
+ {"U+4444 U+FE00", "zh-Hant,ja-Jpan,zh-Hans", kZH_HansFont},
- // No font supports U+81ED U+E0100 but ja and zh-Hans support its base character U+81ED.
- // zh-Hans font is listed before ja font.
- { "U+81ED U+E0100", "", kZH_HansFont },
- { "U+81ED U+E0100", "ja-Jpan", kJAFont },
- { "U+81ED U+E0100", "zh-Hant", kZH_HansFont },
- { "U+81ED U+E0100", "zh-Hans", kZH_HansFont },
+ // No font supports U+81ED U+E0100 but ja and zh-Hans support its base character U+81ED.
+ // zh-Hans font is listed before ja font.
+ {"U+81ED U+E0100", "", kZH_HansFont},
+ {"U+81ED U+E0100", "ja-Jpan", kJAFont},
+ {"U+81ED U+E0100", "zh-Hant", kZH_HansFont},
+ {"U+81ED U+E0100", "zh-Hans", kZH_HansFont},
- { "U+81ED U+E0100", "ja-Jpan,zh-Hant", kJAFont },
- { "U+81ED U+E0100", "zh-Hant,ja-Jpan", kJAFont },
- { "U+81ED U+E0100", "zh-Hans,zh-Hant", kZH_HansFont },
- { "U+81ED U+E0100", "zh-Hant,zh-Hans", kZH_HansFont },
- { "U+81ED U+E0100", "zh-Hans,ja-Jpan", kZH_HansFont },
- { "U+81ED U+E0100", "ja-Jpan,zh-Hans", kJAFont },
+ {"U+81ED U+E0100", "ja-Jpan,zh-Hant", kJAFont},
+ {"U+81ED U+E0100", "zh-Hant,ja-Jpan", kJAFont},
+ {"U+81ED U+E0100", "zh-Hans,zh-Hant", kZH_HansFont},
+ {"U+81ED U+E0100", "zh-Hant,zh-Hans", kZH_HansFont},
+ {"U+81ED U+E0100", "zh-Hans,ja-Jpan", kZH_HansFont},
+ {"U+81ED U+E0100", "ja-Jpan,zh-Hans", kJAFont},
- { "U+81ED U+E0100", "zh-Hans,ja-Jpan,zh-Hant", kZH_HansFont },
- { "U+81ED U+E0100", "zh-Hans,zh-Hant,ja-Jpan", kZH_HansFont },
- { "U+81ED U+E0100", "ja-Jpan,zh-Hans,zh-Hant", kJAFont },
- { "U+81ED U+E0100", "ja-Jpan,zh-Hant,zh-Hans", kJAFont },
- { "U+81ED U+E0100", "zh-Hant,zh-Hans,ja-Jpan", kZH_HansFont },
- { "U+81ED U+E0100", "zh-Hant,ja-Jpan,zh-Hans", kJAFont },
+ {"U+81ED U+E0100", "zh-Hans,ja-Jpan,zh-Hant", kZH_HansFont},
+ {"U+81ED U+E0100", "zh-Hans,zh-Hant,ja-Jpan", kZH_HansFont},
+ {"U+81ED U+E0100", "ja-Jpan,zh-Hans,zh-Hant", kJAFont},
+ {"U+81ED U+E0100", "ja-Jpan,zh-Hant,zh-Hans", kJAFont},
+ {"U+81ED U+E0100", "zh-Hant,zh-Hans,ja-Jpan", kZH_HansFont},
+ {"U+81ED U+E0100", "zh-Hant,ja-Jpan,zh-Hans", kJAFont},
- // No font supports U+9AA8 U+E0100 but all zh-Hans zh-hant ja fonts support its base
- // character U+9AA8.
- // zh-Hans font is listed before ja and zh-Hant fonts.
- { "U+9AA8 U+E0100", "", kZH_HansFont },
- { "U+9AA8 U+E0100", "ja-Jpan", kJAFont },
- { "U+9AA8 U+E0100", "zh-Hans", kZH_HansFont },
- { "U+9AA8 U+E0100", "zh-Hant", kZH_HantFont },
+ // No font supports U+9AA8 U+E0100 but all zh-Hans zh-hant ja fonts support its base
+ // character U+9AA8.
+ // zh-Hans font is listed before ja and zh-Hant fonts.
+ {"U+9AA8 U+E0100", "", kZH_HansFont},
+ {"U+9AA8 U+E0100", "ja-Jpan", kJAFont},
+ {"U+9AA8 U+E0100", "zh-Hans", kZH_HansFont},
+ {"U+9AA8 U+E0100", "zh-Hant", kZH_HantFont},
- { "U+9AA8 U+E0100", "ja-Jpan,zh-Hant", kJAFont },
- { "U+9AA8 U+E0100", "zh-Hant,ja-Jpan", kZH_HantFont },
- { "U+9AA8 U+E0100", "zh-Hans,zh-Hant", kZH_HansFont },
- { "U+9AA8 U+E0100", "zh-Hant,zh-Hans", kZH_HantFont },
- { "U+9AA8 U+E0100", "zh-Hans,ja-Jpan", kZH_HansFont },
- { "U+9AA8 U+E0100", "ja-Jpan,zh-Hans", kJAFont },
+ {"U+9AA8 U+E0100", "ja-Jpan,zh-Hant", kJAFont},
+ {"U+9AA8 U+E0100", "zh-Hant,ja-Jpan", kZH_HantFont},
+ {"U+9AA8 U+E0100", "zh-Hans,zh-Hant", kZH_HansFont},
+ {"U+9AA8 U+E0100", "zh-Hant,zh-Hans", kZH_HantFont},
+ {"U+9AA8 U+E0100", "zh-Hans,ja-Jpan", kZH_HansFont},
+ {"U+9AA8 U+E0100", "ja-Jpan,zh-Hans", kJAFont},
- { "U+9AA8 U+E0100", "zh-Hans,ja-Jpan,zh-Hant", kZH_HansFont },
- { "U+9AA8 U+E0100", "zh-Hans,zh-Hant,ja-Jpan", kZH_HansFont },
- { "U+9AA8 U+E0100", "ja-Jpan,zh-Hans,zh-Hant", kJAFont },
- { "U+9AA8 U+E0100", "ja-Jpan,zh-Hant,zh-Hans", kJAFont },
- { "U+9AA8 U+E0100", "zh-Hant,zh-Hans,ja-Jpan", kZH_HantFont },
- { "U+9AA8 U+E0100", "zh-Hant,ja-Jpan,zh-Hans", kZH_HantFont },
+ {"U+9AA8 U+E0100", "zh-Hans,ja-Jpan,zh-Hant", kZH_HansFont},
+ {"U+9AA8 U+E0100", "zh-Hans,zh-Hant,ja-Jpan", kZH_HansFont},
+ {"U+9AA8 U+E0100", "ja-Jpan,zh-Hans,zh-Hant", kJAFont},
+ {"U+9AA8 U+E0100", "ja-Jpan,zh-Hant,zh-Hans", kJAFont},
+ {"U+9AA8 U+E0100", "zh-Hant,zh-Hans,ja-Jpan", kZH_HantFont},
+ {"U+9AA8 U+E0100", "zh-Hant,ja-Jpan,zh-Hans", kZH_HantFont},
- // All zh-Hans,zh-Hant,ja fonts support U+35A8 U+E0100 and its base character U+35A8.
- // zh-Hans font is listed before ja and zh-Hant fonts.
- { "U+35A8", "", kZH_HansFont },
- { "U+35A8", "ja-Jpan", kJAFont },
- { "U+35A8", "zh-Hans", kZH_HansFont },
- { "U+35A8", "zh-Hant", kZH_HantFont },
+ // All zh-Hans,zh-Hant,ja fonts support U+35A8 U+E0100 and its base character U+35A8.
+ // zh-Hans font is listed before ja and zh-Hant fonts.
+ {"U+35A8", "", kZH_HansFont},
+ {"U+35A8", "ja-Jpan", kJAFont},
+ {"U+35A8", "zh-Hans", kZH_HansFont},
+ {"U+35A8", "zh-Hant", kZH_HantFont},
- { "U+35A8", "ja-Jpan,zh-Hant", kJAFont },
- { "U+35A8", "zh-Hant,ja-Jpan", kZH_HantFont },
- { "U+35A8", "zh-Hans,zh-Hant", kZH_HansFont },
- { "U+35A8", "zh-Hant,zh-Hans", kZH_HantFont },
- { "U+35A8", "zh-Hans,ja-Jpan", kZH_HansFont },
- { "U+35A8", "ja-Jpan,zh-Hans", kJAFont },
+ {"U+35A8", "ja-Jpan,zh-Hant", kJAFont},
+ {"U+35A8", "zh-Hant,ja-Jpan", kZH_HantFont},
+ {"U+35A8", "zh-Hans,zh-Hant", kZH_HansFont},
+ {"U+35A8", "zh-Hant,zh-Hans", kZH_HantFont},
+ {"U+35A8", "zh-Hans,ja-Jpan", kZH_HansFont},
+ {"U+35A8", "ja-Jpan,zh-Hans", kJAFont},
- { "U+35A8", "zh-Hans,ja-Jpan,zh-Hant", kZH_HansFont },
- { "U+35A8", "zh-Hans,zh-Hant,ja-Jpan", kZH_HansFont },
- { "U+35A8", "ja-Jpan,zh-Hans,zh-Hant", kJAFont },
- { "U+35A8", "ja-Jpan,zh-Hant,zh-Hans", kJAFont },
- { "U+35A8", "zh-Hant,zh-Hans,ja-Jpan", kZH_HantFont },
- { "U+35A8", "zh-Hant,ja-Jpan,zh-Hans", kZH_HantFont },
+ {"U+35A8", "zh-Hans,ja-Jpan,zh-Hant", kZH_HansFont},
+ {"U+35A8", "zh-Hans,zh-Hant,ja-Jpan", kZH_HansFont},
+ {"U+35A8", "ja-Jpan,zh-Hans,zh-Hant", kJAFont},
+ {"U+35A8", "ja-Jpan,zh-Hant,zh-Hans", kJAFont},
+ {"U+35A8", "zh-Hant,zh-Hans,ja-Jpan", kZH_HantFont},
+ {"U+35A8", "zh-Hant,ja-Jpan,zh-Hans", kZH_HantFont},
- // All zh-Hans,zh-Hant,ja fonts support U+35B6 U+E0100, but zh-Hant and ja fonts support its
- // base character U+35B6.
- // ja font is listed before zh-Hant font.
- { "U+35B6", "", kJAFont },
- { "U+35B6", "ja-Jpan", kJAFont },
- { "U+35B6", "zh-Hant", kZH_HantFont },
- { "U+35B6", "zh-Hans", kJAFont },
+ // All zh-Hans,zh-Hant,ja fonts support U+35B6 U+E0100, but zh-Hant and ja fonts support
+ // its
+ // base character U+35B6.
+ // ja font is listed before zh-Hant font.
+ {"U+35B6", "", kJAFont},
+ {"U+35B6", "ja-Jpan", kJAFont},
+ {"U+35B6", "zh-Hant", kZH_HantFont},
+ {"U+35B6", "zh-Hans", kJAFont},
- { "U+35B6", "ja-Jpan,zh-Hant", kJAFont },
- { "U+35B6", "zh-Hant,ja-Jpan", kZH_HantFont },
- { "U+35B6", "zh-Hans,zh-Hant", kZH_HantFont },
- { "U+35B6", "zh-Hant,zh-Hans", kZH_HantFont },
- { "U+35B6", "zh-Hans,ja-Jpan", kJAFont },
- { "U+35B6", "ja-Jpan,zh-Hans", kJAFont },
+ {"U+35B6", "ja-Jpan,zh-Hant", kJAFont},
+ {"U+35B6", "zh-Hant,ja-Jpan", kZH_HantFont},
+ {"U+35B6", "zh-Hans,zh-Hant", kZH_HantFont},
+ {"U+35B6", "zh-Hant,zh-Hans", kZH_HantFont},
+ {"U+35B6", "zh-Hans,ja-Jpan", kJAFont},
+ {"U+35B6", "ja-Jpan,zh-Hans", kJAFont},
- { "U+35B6", "zh-Hans,ja-Jpan,zh-Hant", kJAFont },
- { "U+35B6", "zh-Hans,zh-Hant,ja-Jpan", kZH_HantFont },
- { "U+35B6", "ja-Jpan,zh-Hans,zh-Hant", kJAFont },
- { "U+35B6", "ja-Jpan,zh-Hant,zh-Hans", kJAFont },
- { "U+35B6", "zh-Hant,zh-Hans,ja-Jpan", kZH_HantFont },
- { "U+35B6", "zh-Hant,ja-Jpan,zh-Hans", kZH_HantFont },
+ {"U+35B6", "zh-Hans,ja-Jpan,zh-Hant", kJAFont},
+ {"U+35B6", "zh-Hans,zh-Hant,ja-Jpan", kZH_HantFont},
+ {"U+35B6", "ja-Jpan,zh-Hans,zh-Hant", kJAFont},
+ {"U+35B6", "ja-Jpan,zh-Hant,zh-Hans", kJAFont},
+ {"U+35B6", "zh-Hant,zh-Hans,ja-Jpan", kZH_HantFont},
+ {"U+35B6", "zh-Hant,ja-Jpan,zh-Hans", kZH_HantFont},
- // All zh-Hans,zh-Hant,ja fonts support U+35C5 U+E0100, but only ja font supports its base
- // character U+35C5.
- { "U+35C5", "", kJAFont },
- { "U+35C5", "ja-Jpan", kJAFont },
- { "U+35C5", "zh-Hant", kJAFont },
- { "U+35C5", "zh-Hans", kJAFont },
+ // All zh-Hans,zh-Hant,ja fonts support U+35C5 U+E0100, but only ja font supports its
+ // base
+ // character U+35C5.
+ {"U+35C5", "", kJAFont},
+ {"U+35C5", "ja-Jpan", kJAFont},
+ {"U+35C5", "zh-Hant", kJAFont},
+ {"U+35C5", "zh-Hans", kJAFont},
- { "U+35C5", "ja-Jpan,zh-Hant", kJAFont },
- { "U+35C5", "zh-Hant,ja-Jpan", kJAFont },
- { "U+35C5", "zh-Hans,zh-Hant", kJAFont },
- { "U+35C5", "zh-Hant,zh-Hans", kJAFont },
- { "U+35C5", "zh-Hans,ja-Jpan", kJAFont },
- { "U+35C5", "ja-Jpan,zh-Hans", kJAFont },
+ {"U+35C5", "ja-Jpan,zh-Hant", kJAFont},
+ {"U+35C5", "zh-Hant,ja-Jpan", kJAFont},
+ {"U+35C5", "zh-Hans,zh-Hant", kJAFont},
+ {"U+35C5", "zh-Hant,zh-Hans", kJAFont},
+ {"U+35C5", "zh-Hans,ja-Jpan", kJAFont},
+ {"U+35C5", "ja-Jpan,zh-Hans", kJAFont},
- { "U+35C5", "zh-Hans,ja-Jpan,zh-Hant", kJAFont },
- { "U+35C5", "zh-Hans,zh-Hant,ja-Jpan", kJAFont },
- { "U+35C5", "ja-Jpan,zh-Hans,zh-Hant", kJAFont },
- { "U+35C5", "ja-Jpan,zh-Hant,zh-Hans", kJAFont },
- { "U+35C5", "zh-Hant,zh-Hans,ja-Jpan", kJAFont },
- { "U+35C5", "zh-Hant,ja-Jpan,zh-Hans", kJAFont },
+ {"U+35C5", "zh-Hans,ja-Jpan,zh-Hant", kJAFont},
+ {"U+35C5", "zh-Hans,zh-Hant,ja-Jpan", kJAFont},
+ {"U+35C5", "ja-Jpan,zh-Hans,zh-Hant", kJAFont},
+ {"U+35C5", "ja-Jpan,zh-Hant,zh-Hans", kJAFont},
+ {"U+35C5", "zh-Hant,zh-Hans,ja-Jpan", kJAFont},
+ {"U+35C5", "zh-Hant,ja-Jpan,zh-Hans", kJAFont},
- // None of ja-Jpan, zh-Hant, zh-Hans font supports U+1F469. Emoji font supports it.
- { "U+1F469", "", kEmojiFont },
- { "U+1F469", "ja-Jpan", kEmojiFont },
- { "U+1F469", "zh-Hant", kEmojiFont },
- { "U+1F469", "zh-Hans", kEmojiFont },
+ // None of ja-Jpan, zh-Hant, zh-Hans font supports U+1F469. Emoji font supports it.
+ {"U+1F469", "", kEmojiFont},
+ {"U+1F469", "ja-Jpan", kEmojiFont},
+ {"U+1F469", "zh-Hant", kEmojiFont},
+ {"U+1F469", "zh-Hans", kEmojiFont},
- { "U+1F469", "ja-Jpan,zh-Hant", kEmojiFont },
- { "U+1F469", "zh-Hant,ja-Jpan", kEmojiFont },
- { "U+1F469", "zh-Hans,zh-Hant", kEmojiFont },
- { "U+1F469", "zh-Hant,zh-Hans", kEmojiFont },
- { "U+1F469", "zh-Hans,ja-Jpan", kEmojiFont },
- { "U+1F469", "ja-Jpan,zh-Hans", kEmojiFont },
+ {"U+1F469", "ja-Jpan,zh-Hant", kEmojiFont},
+ {"U+1F469", "zh-Hant,ja-Jpan", kEmojiFont},
+ {"U+1F469", "zh-Hans,zh-Hant", kEmojiFont},
+ {"U+1F469", "zh-Hant,zh-Hans", kEmojiFont},
+ {"U+1F469", "zh-Hans,ja-Jpan", kEmojiFont},
+ {"U+1F469", "ja-Jpan,zh-Hans", kEmojiFont},
- { "U+1F469", "zh-Hans,ja-Jpan,zh-Hant", kEmojiFont },
- { "U+1F469", "zh-Hans,zh-Hant,ja-Jpan", kEmojiFont },
- { "U+1F469", "ja-Jpan,zh-Hans,zh-Hant", kEmojiFont },
- { "U+1F469", "ja-Jpan,zh-Hant,zh-Hans", kEmojiFont },
- { "U+1F469", "zh-Hant,zh-Hans,ja-Jpan", kEmojiFont },
- { "U+1F469", "zh-Hant,ja-Jpan,zh-Hans", kEmojiFont },
+ {"U+1F469", "zh-Hans,ja-Jpan,zh-Hant", kEmojiFont},
+ {"U+1F469", "zh-Hans,zh-Hant,ja-Jpan", kEmojiFont},
+ {"U+1F469", "ja-Jpan,zh-Hans,zh-Hant", kEmojiFont},
+ {"U+1F469", "ja-Jpan,zh-Hant,zh-Hans", kEmojiFont},
+ {"U+1F469", "zh-Hant,zh-Hans,ja-Jpan", kEmojiFont},
+ {"U+1F469", "zh-Hant,ja-Jpan,zh-Hans", kEmojiFont},
};
std::shared_ptr<FontCollection> collection(getFontCollection(kTestFontDir, kItemizeFontXml));
@@ -1538,17 +1542,15 @@
std::shared_ptr<MinikinFont> fontA(new MinikinFontForTest(kZH_HansFont));
std::shared_ptr<MinikinFont> fontB(new MinikinFontForTest(kZH_HansFont));
- std::shared_ptr<FontFamily> dummyFamily(new FontFamily(
- std::vector<Font>({ Font(dummyFont, FontStyle()) })));
- std::shared_ptr<FontFamily> familyA(new FontFamily(
- std::vector<Font>({ Font(fontA, FontStyle()) })));
- std::shared_ptr<FontFamily> familyB(new FontFamily(
- std::vector<Font>({ Font(fontB, FontStyle()) })));
+ std::shared_ptr<FontFamily> dummyFamily(
+ new FontFamily(std::vector<Font>({Font(dummyFont, FontStyle())})));
+ std::shared_ptr<FontFamily> familyA(
+ new FontFamily(std::vector<Font>({Font(fontA, FontStyle())})));
+ std::shared_ptr<FontFamily> familyB(
+ new FontFamily(std::vector<Font>({Font(fontB, FontStyle())})));
- std::vector<std::shared_ptr<FontFamily>> families =
- { dummyFamily, familyA, familyB };
- std::vector<std::shared_ptr<FontFamily>> reversedFamilies =
- { dummyFamily, familyB, familyA };
+ std::vector<std::shared_ptr<FontFamily>> families = {dummyFamily, familyA, familyB};
+ std::vector<std::shared_ptr<FontFamily>> reversedFamilies = {dummyFamily, familyB, familyA};
std::shared_ptr<FontCollection> collection(new FontCollection(families));
std::shared_ptr<FontCollection> reversedCollection(new FontCollection(reversedFamilies));
@@ -1566,22 +1568,20 @@
// For b/29585939
TEST_F(FontCollectionItemizeTest, itemizeShouldKeepOrderForVS2) {
std::shared_ptr<MinikinFont> dummyFont(new MinikinFontForTest(kNoGlyphFont));
- std::shared_ptr<MinikinFont> hasCmapFormat14Font(
- new MinikinFontForTest(kHasCmapFormat14Font));
- std::shared_ptr<MinikinFont> noCmapFormat14Font(
- new MinikinFontForTest(kNoCmapFormat14Font));
+ std::shared_ptr<MinikinFont> hasCmapFormat14Font(new MinikinFontForTest(kHasCmapFormat14Font));
+ std::shared_ptr<MinikinFont> noCmapFormat14Font(new MinikinFontForTest(kNoCmapFormat14Font));
- std::shared_ptr<FontFamily> dummyFamily(new FontFamily(
- std::vector<Font>({ Font(dummyFont, FontStyle()) })));
- std::shared_ptr<FontFamily> hasCmapFormat14Family(new FontFamily(
- std::vector<Font>({ Font(hasCmapFormat14Font, FontStyle()) })));
- std::shared_ptr<FontFamily> noCmapFormat14Family(new FontFamily(
- std::vector<Font>({ Font(noCmapFormat14Font, FontStyle()) })));
+ std::shared_ptr<FontFamily> dummyFamily(
+ new FontFamily(std::vector<Font>({Font(dummyFont, FontStyle())})));
+ std::shared_ptr<FontFamily> hasCmapFormat14Family(
+ new FontFamily(std::vector<Font>({Font(hasCmapFormat14Font, FontStyle())})));
+ std::shared_ptr<FontFamily> noCmapFormat14Family(
+ new FontFamily(std::vector<Font>({Font(noCmapFormat14Font, FontStyle())})));
- std::vector<std::shared_ptr<FontFamily>> families =
- { dummyFamily, hasCmapFormat14Family, noCmapFormat14Family };
- std::vector<std::shared_ptr<FontFamily>> reversedFamilies =
- { dummyFamily, noCmapFormat14Family, hasCmapFormat14Family };
+ std::vector<std::shared_ptr<FontFamily>> families = {dummyFamily, hasCmapFormat14Family,
+ noCmapFormat14Family};
+ std::vector<std::shared_ptr<FontFamily>> reversedFamilies = {dummyFamily, noCmapFormat14Family,
+ hasCmapFormat14Family};
std::shared_ptr<FontCollection> collection(new FontCollection(families));
std::shared_ptr<FontCollection> reversedCollection(new FontCollection(reversedFamilies));
diff --git a/tests/unittest/FontCollectionTest.cpp b/tests/unittest/FontCollectionTest.cpp
index 07af5d4..b05481e 100644
--- a/tests/unittest/FontCollectionTest.cpp
+++ b/tests/unittest/FontCollectionTest.cpp
@@ -49,32 +49,34 @@
}
if (vsSet.find(vs) == vsSet.end()) {
EXPECT_FALSE(fc->hasVariationSelector(codepoint, vs))
- << "Glyph for U+" << std::hex << codepoint << " U+" << vs;
+ << "Glyph for U+" << std::hex << codepoint << " U+" << vs;
} else {
EXPECT_TRUE(fc->hasVariationSelector(codepoint, vs))
- << "Glyph for U+" << std::hex << codepoint << " U+" << vs;
+ << "Glyph for U+" << std::hex << codepoint << " U+" << vs;
}
}
}
TEST(FontCollectionTest, hasVariationSelectorTest) {
- std::shared_ptr<MinikinFont> font(new MinikinFontForTest(kVsTestFont));
- std::shared_ptr<FontFamily> family(new FontFamily(
- std::vector<Font>({ Font(font, FontStyle()) })));
- std::vector<std::shared_ptr<FontFamily>> families({ family });
- std::shared_ptr<FontCollection> fc(new FontCollection(families));
+ std::shared_ptr<MinikinFont> font(new MinikinFontForTest(kVsTestFont));
+ std::shared_ptr<FontFamily> family(
+ new FontFamily(std::vector<Font>({Font(font, FontStyle())})));
+ std::vector<std::shared_ptr<FontFamily>> families({family});
+ std::shared_ptr<FontCollection> fc(new FontCollection(families));
- EXPECT_FALSE(fc->hasVariationSelector(0x82A6, 0));
- expectVSGlyphs(fc.get(), 0x82A6, std::set<uint32_t>({0xFE00, 0xFE0E, 0xE0100, 0xE0101, 0xE0102}));
+ EXPECT_FALSE(fc->hasVariationSelector(0x82A6, 0));
+ expectVSGlyphs(fc.get(), 0x82A6,
+ std::set<uint32_t>({0xFE00, 0xFE0E, 0xE0100, 0xE0101, 0xE0102}));
- EXPECT_FALSE(fc->hasVariationSelector(0x845B, 0));
- expectVSGlyphs(fc.get(), 0x845B, std::set<uint32_t>({0xFE01, 0xFE0E, 0xE0101, 0xE0102, 0xE0103}));
+ EXPECT_FALSE(fc->hasVariationSelector(0x845B, 0));
+ expectVSGlyphs(fc.get(), 0x845B,
+ std::set<uint32_t>({0xFE01, 0xFE0E, 0xE0101, 0xE0102, 0xE0103}));
- EXPECT_FALSE(fc->hasVariationSelector(0x537F, 0));
- expectVSGlyphs(fc.get(), 0x537F, std::set<uint32_t>({0xFE0E}));
+ EXPECT_FALSE(fc->hasVariationSelector(0x537F, 0));
+ expectVSGlyphs(fc.get(), 0x537F, std::set<uint32_t>({0xFE0E}));
- EXPECT_FALSE(fc->hasVariationSelector(0x717D, 0));
- expectVSGlyphs(fc.get(), 0x717D, std::set<uint32_t>({0xFE02, 0xE0102, 0xE0103}));
+ EXPECT_FALSE(fc->hasVariationSelector(0x717D, 0));
+ expectVSGlyphs(fc.get(), 0x717D, std::set<uint32_t>({0xFE02, 0xE0102, 0xE0103}));
}
const char kEmojiXmlFile[] = kTestFontDir "emoji.xml";
@@ -109,7 +111,6 @@
// None of the fonts support U+2229.
EXPECT_FALSE(collection->hasVariationSelector(0x2229, 0xFE0E));
EXPECT_FALSE(collection->hasVariationSelector(0x2229, 0xFE0F));
-
}
TEST(FontCollectionTest, newEmojiTest) {
@@ -131,29 +132,26 @@
const char kNoAxisFont[] = kTestFontDir "/Regular.ttf";
std::shared_ptr<MinikinFont> multiAxisFont(new MinikinFontForTest(kMultiAxisFont));
- std::shared_ptr<FontFamily> multiAxisFamily(new FontFamily(
- std::vector<Font>({ Font(multiAxisFont, FontStyle()) })));
+ std::shared_ptr<FontFamily> multiAxisFamily(
+ new FontFamily(std::vector<Font>({Font(multiAxisFont, FontStyle())})));
std::vector<std::shared_ptr<FontFamily>> multiAxisFamilies({multiAxisFamily});
std::shared_ptr<FontCollection> multiAxisFc(new FontCollection(multiAxisFamilies));
std::shared_ptr<MinikinFont> noAxisFont(new MinikinFontForTest(kNoAxisFont));
- std::shared_ptr<FontFamily> noAxisFamily(new FontFamily(
- std::vector<Font>({ Font(noAxisFont, FontStyle()) })));
+ std::shared_ptr<FontFamily> noAxisFamily(
+ new FontFamily(std::vector<Font>({Font(noAxisFont, FontStyle())})));
std::vector<std::shared_ptr<FontFamily>> noAxisFamilies({noAxisFamily});
std::shared_ptr<FontCollection> noAxisFc(new FontCollection(noAxisFamilies));
{
// Do not ceate new instance if none of variations are specified.
EXPECT_EQ(nullptr,
- multiAxisFc->createCollectionWithVariation(std::vector<FontVariation>()));
- EXPECT_EQ(nullptr,
- noAxisFc->createCollectionWithVariation(std::vector<FontVariation>()));
+ multiAxisFc->createCollectionWithVariation(std::vector<FontVariation>()));
+ EXPECT_EQ(nullptr, noAxisFc->createCollectionWithVariation(std::vector<FontVariation>()));
}
{
// New instance should be used for supported variation.
- std::vector<FontVariation> variations = {
- { MinikinFont::MakeTag('w', 'd', 't', 'h'), 1.0f }
- };
+ std::vector<FontVariation> variations = {{MinikinFont::MakeTag('w', 'd', 't', 'h'), 1.0f}};
std::shared_ptr<FontCollection> newFc(
multiAxisFc->createCollectionWithVariation(variations));
EXPECT_NE(nullptr, newFc.get());
@@ -163,10 +161,8 @@
}
{
// New instance should be used for supported variation (multiple variations case).
- std::vector<FontVariation> variations = {
- { MinikinFont::MakeTag('w', 'd', 't', 'h'), 1.0f },
- { MinikinFont::MakeTag('w', 'g', 'h', 't'), 1.0f }
- };
+ std::vector<FontVariation> variations = {{MinikinFont::MakeTag('w', 'd', 't', 'h'), 1.0f},
+ {MinikinFont::MakeTag('w', 'g', 'h', 't'), 1.0f}};
std::shared_ptr<FontCollection> newFc(
multiAxisFc->createCollectionWithVariation(variations));
EXPECT_NE(nullptr, newFc.get());
@@ -176,18 +172,14 @@
}
{
// Do not ceate new instance if none of variations are supported.
- std::vector<FontVariation> variations = {
- { MinikinFont::MakeTag('Z', 'Z', 'Z', 'Z'), 1.0f }
- };
+ std::vector<FontVariation> variations = {{MinikinFont::MakeTag('Z', 'Z', 'Z', 'Z'), 1.0f}};
EXPECT_EQ(nullptr, multiAxisFc->createCollectionWithVariation(variations));
EXPECT_EQ(nullptr, noAxisFc->createCollectionWithVariation(variations));
}
{
// At least one axis is supported, should create new instance.
- std::vector<FontVariation> variations = {
- { MinikinFont::MakeTag('w', 'd', 't', 'h'), 1.0f },
- { MinikinFont::MakeTag('Z', 'Z', 'Z', 'Z'), 1.0f }
- };
+ std::vector<FontVariation> variations = {{MinikinFont::MakeTag('w', 'd', 't', 'h'), 1.0f},
+ {MinikinFont::MakeTag('Z', 'Z', 'Z', 'Z'), 1.0f}};
std::shared_ptr<FontCollection> newFc(
multiAxisFc->createCollectionWithVariation(variations));
EXPECT_NE(nullptr, newFc.get());
diff --git a/tests/unittest/FontFamilyTest.cpp b/tests/unittest/FontFamilyTest.cpp
index 22d8cd3..f0412d8 100644
--- a/tests/unittest/FontFamilyTest.cpp
+++ b/tests/unittest/FontFamilyTest.cpp
@@ -19,6 +19,7 @@
#include <gtest/gtest.h>
#include "minikin/LocaleList.h"
+
#include "ICUTestBase.h"
#include "LocaleListCache.h"
#include "MinikinFontForTest.h"
@@ -47,8 +48,7 @@
std::shared_ptr<FontFamily> makeFamily(const std::string& fontPath) {
std::shared_ptr<MinikinFont> font(new MinikinFontForTest(fontPath));
- return std::make_shared<FontFamily>(
- std::vector<Font>({Font(font, FontStyle())}));
+ return std::make_shared<FontFamily>(std::vector<Font>({Font(font, FontStyle())}));
}
TEST_F(LocaleTest, basicTests) {
@@ -173,80 +173,80 @@
const std::string requestedScript;
bool isSupported;
} testCases[] = {
- // Same scripts
- { "en-Latn", "Latn", SUPPORTED },
- { "ja-Jpan", "Jpan", SUPPORTED },
- { "ja-Hira", "Hira", SUPPORTED },
- { "ja-Kana", "Kana", SUPPORTED },
- { "ja-Hrkt", "Hrkt", SUPPORTED },
- { "zh-Hans", "Hans", SUPPORTED },
- { "zh-Hant", "Hant", SUPPORTED },
- { "zh-Hani", "Hani", SUPPORTED },
- { "ko-Kore", "Kore", SUPPORTED },
- { "ko-Hang", "Hang", SUPPORTED },
- { "zh-Hanb", "Hanb", SUPPORTED },
+ // Same scripts
+ {"en-Latn", "Latn", SUPPORTED},
+ {"ja-Jpan", "Jpan", SUPPORTED},
+ {"ja-Hira", "Hira", SUPPORTED},
+ {"ja-Kana", "Kana", SUPPORTED},
+ {"ja-Hrkt", "Hrkt", SUPPORTED},
+ {"zh-Hans", "Hans", SUPPORTED},
+ {"zh-Hant", "Hant", SUPPORTED},
+ {"zh-Hani", "Hani", SUPPORTED},
+ {"ko-Kore", "Kore", SUPPORTED},
+ {"ko-Hang", "Hang", SUPPORTED},
+ {"zh-Hanb", "Hanb", SUPPORTED},
- // Japanese supports Hiragana, Katakanara, etc.
- { "ja-Jpan", "Hira", SUPPORTED },
- { "ja-Jpan", "Kana", SUPPORTED },
- { "ja-Jpan", "Hrkt", SUPPORTED },
- { "ja-Hrkt", "Hira", SUPPORTED },
- { "ja-Hrkt", "Kana", SUPPORTED },
+ // Japanese supports Hiragana, Katakanara, etc.
+ {"ja-Jpan", "Hira", SUPPORTED},
+ {"ja-Jpan", "Kana", SUPPORTED},
+ {"ja-Jpan", "Hrkt", SUPPORTED},
+ {"ja-Hrkt", "Hira", SUPPORTED},
+ {"ja-Hrkt", "Kana", SUPPORTED},
- // Chinese supports Han.
- { "zh-Hans", "Hani", SUPPORTED },
- { "zh-Hant", "Hani", SUPPORTED },
- { "zh-Hanb", "Hani", SUPPORTED },
+ // Chinese supports Han.
+ {"zh-Hans", "Hani", SUPPORTED},
+ {"zh-Hant", "Hani", SUPPORTED},
+ {"zh-Hanb", "Hani", SUPPORTED},
- // Hanb supports Bopomofo.
- { "zh-Hanb", "Bopo", SUPPORTED },
+ // Hanb supports Bopomofo.
+ {"zh-Hanb", "Bopo", SUPPORTED},
- // Korean supports Hangul.
- { "ko-Kore", "Hang", SUPPORTED },
+ // Korean supports Hangul.
+ {"ko-Kore", "Hang", SUPPORTED},
- // Different scripts
- { "ja-Jpan", "Latn", NOT_SUPPORTED },
- { "en-Latn", "Jpan", NOT_SUPPORTED },
- { "ja-Jpan", "Hant", NOT_SUPPORTED },
- { "zh-Hant", "Jpan", NOT_SUPPORTED },
- { "ja-Jpan", "Hans", NOT_SUPPORTED },
- { "zh-Hans", "Jpan", NOT_SUPPORTED },
- { "ja-Jpan", "Kore", NOT_SUPPORTED },
- { "ko-Kore", "Jpan", NOT_SUPPORTED },
- { "zh-Hans", "Hant", NOT_SUPPORTED },
- { "zh-Hant", "Hans", NOT_SUPPORTED },
- { "zh-Hans", "Kore", NOT_SUPPORTED },
- { "ko-Kore", "Hans", NOT_SUPPORTED },
- { "zh-Hant", "Kore", NOT_SUPPORTED },
- { "ko-Kore", "Hant", NOT_SUPPORTED },
+ // Different scripts
+ {"ja-Jpan", "Latn", NOT_SUPPORTED},
+ {"en-Latn", "Jpan", NOT_SUPPORTED},
+ {"ja-Jpan", "Hant", NOT_SUPPORTED},
+ {"zh-Hant", "Jpan", NOT_SUPPORTED},
+ {"ja-Jpan", "Hans", NOT_SUPPORTED},
+ {"zh-Hans", "Jpan", NOT_SUPPORTED},
+ {"ja-Jpan", "Kore", NOT_SUPPORTED},
+ {"ko-Kore", "Jpan", NOT_SUPPORTED},
+ {"zh-Hans", "Hant", NOT_SUPPORTED},
+ {"zh-Hant", "Hans", NOT_SUPPORTED},
+ {"zh-Hans", "Kore", NOT_SUPPORTED},
+ {"ko-Kore", "Hans", NOT_SUPPORTED},
+ {"zh-Hant", "Kore", NOT_SUPPORTED},
+ {"ko-Kore", "Hant", NOT_SUPPORTED},
- // Hiragana doesn't support Japanese, etc.
- { "ja-Hira", "Jpan", NOT_SUPPORTED },
- { "ja-Kana", "Jpan", NOT_SUPPORTED },
- { "ja-Hrkt", "Jpan", NOT_SUPPORTED },
- { "ja-Hani", "Jpan", NOT_SUPPORTED },
- { "ja-Hira", "Hrkt", NOT_SUPPORTED },
- { "ja-Kana", "Hrkt", NOT_SUPPORTED },
- { "ja-Hani", "Hrkt", NOT_SUPPORTED },
- { "ja-Hani", "Hira", NOT_SUPPORTED },
- { "ja-Hani", "Kana", NOT_SUPPORTED },
+ // Hiragana doesn't support Japanese, etc.
+ {"ja-Hira", "Jpan", NOT_SUPPORTED},
+ {"ja-Kana", "Jpan", NOT_SUPPORTED},
+ {"ja-Hrkt", "Jpan", NOT_SUPPORTED},
+ {"ja-Hani", "Jpan", NOT_SUPPORTED},
+ {"ja-Hira", "Hrkt", NOT_SUPPORTED},
+ {"ja-Kana", "Hrkt", NOT_SUPPORTED},
+ {"ja-Hani", "Hrkt", NOT_SUPPORTED},
+ {"ja-Hani", "Hira", NOT_SUPPORTED},
+ {"ja-Hani", "Kana", NOT_SUPPORTED},
- // Kanji doesn't support Chinese, etc.
- { "zh-Hani", "Hant", NOT_SUPPORTED },
- { "zh-Hani", "Hans", NOT_SUPPORTED },
- { "zh-Hani", "Hanb", NOT_SUPPORTED },
+ // Kanji doesn't support Chinese, etc.
+ {"zh-Hani", "Hant", NOT_SUPPORTED},
+ {"zh-Hani", "Hans", NOT_SUPPORTED},
+ {"zh-Hani", "Hanb", NOT_SUPPORTED},
- // Hangul doesn't support Korean, etc.
- { "ko-Hang", "Kore", NOT_SUPPORTED },
- { "ko-Hani", "Kore", NOT_SUPPORTED },
- { "ko-Hani", "Hang", NOT_SUPPORTED },
- { "ko-Hang", "Hani", NOT_SUPPORTED },
+ // Hangul doesn't support Korean, etc.
+ {"ko-Hang", "Kore", NOT_SUPPORTED},
+ {"ko-Hani", "Kore", NOT_SUPPORTED},
+ {"ko-Hani", "Hang", NOT_SUPPORTED},
+ {"ko-Hang", "Hani", NOT_SUPPORTED},
- // Han with botomofo doesn't support simplified Chinese, etc.
- { "zh-Hanb", "Hant", NOT_SUPPORTED },
- { "zh-Hanb", "Hans", NOT_SUPPORTED },
- { "zh-Hanb", "Jpan", NOT_SUPPORTED },
- { "zh-Hanb", "Kore", NOT_SUPPORTED },
+ // Han with botomofo doesn't support simplified Chinese, etc.
+ {"zh-Hanb", "Hant", NOT_SUPPORTED},
+ {"zh-Hanb", "Hans", NOT_SUPPORTED},
+ {"zh-Hanb", "Jpan", NOT_SUPPORTED},
+ {"zh-Hanb", "Kore", NOT_SUPPORTED},
};
for (auto testCase : testCases) {
@@ -254,12 +254,10 @@
HB_TAG(testCase.requestedScript[0], testCase.requestedScript[1],
testCase.requestedScript[2], testCase.requestedScript[3]));
if (testCase.isSupported) {
- EXPECT_TRUE(
- createLocale(testCase.baseScript).supportsHbScript(script))
+ EXPECT_TRUE(createLocale(testCase.baseScript).supportsHbScript(script))
<< testCase.baseScript << " should support " << testCase.requestedScript;
} else {
- EXPECT_FALSE(
- createLocale(testCase.baseScript).supportsHbScript(script))
+ EXPECT_FALSE(createLocale(testCase.baseScript).supportsHbScript(script))
<< testCase.baseScript << " shouldn't support " << testCase.requestedScript;
}
}
@@ -352,32 +350,22 @@
TEST_F(LocaleListTest, subtagEmojiTest) {
std::string subtagEmojiStrings[] = {
- // Duplicate subtag case.
- "und-Latn-u-em-emoji-u-em-text",
+ // Duplicate subtag case.
+ "und-Latn-u-em-emoji-u-em-text",
- // Strings that contain language.
- "und-u-em-emoji",
- "en-u-em-emoji",
+ // Strings that contain language.
+ "und-u-em-emoji", "en-u-em-emoji",
- // Strings that contain the script.
- "und-Jpan-u-em-emoji",
- "en-Latn-u-em-emoji",
- "und-Zsym-u-em-emoji",
- "und-Zsye-u-em-emoji",
- "en-Zsym-u-em-emoji",
- "en-Zsye-u-em-emoji",
+ // Strings that contain the script.
+ "und-Jpan-u-em-emoji", "en-Latn-u-em-emoji", "und-Zsym-u-em-emoji",
+ "und-Zsye-u-em-emoji", "en-Zsym-u-em-emoji", "en-Zsye-u-em-emoji",
- // Strings that contain the country.
- "und-US-u-em-emoji",
- "en-US-u-em-emoji",
- "es-419-u-em-emoji",
- "und-Latn-US-u-em-emoji",
- "en-Zsym-US-u-em-emoji",
- "en-Zsye-US-u-em-emoji",
- "es-Zsye-419-u-em-emoji",
+ // Strings that contain the country.
+ "und-US-u-em-emoji", "en-US-u-em-emoji", "es-419-u-em-emoji", "und-Latn-US-u-em-emoji",
+ "en-Zsym-US-u-em-emoji", "en-Zsye-US-u-em-emoji", "es-Zsye-419-u-em-emoji",
- // Strings that contain the variant.
- "de-Latn-DE-1901-u-em-emoji",
+ // Strings that contain the variant.
+ "de-Latn-DE-1901-u-em-emoji",
};
for (auto subtagEmojiString : subtagEmojiStrings) {
@@ -389,32 +377,22 @@
TEST_F(LocaleListTest, subtagTextTest) {
std::string subtagTextStrings[] = {
- // Duplicate subtag case.
- "und-Latn-u-em-text-u-em-emoji",
+ // Duplicate subtag case.
+ "und-Latn-u-em-text-u-em-emoji",
- // Strings that contain language.
- "und-u-em-text",
- "en-u-em-text",
+ // Strings that contain language.
+ "und-u-em-text", "en-u-em-text",
- // Strings that contain the script.
- "und-Latn-u-em-text",
- "en-Jpan-u-em-text",
- "und-Zsym-u-em-text",
- "und-Zsye-u-em-text",
- "en-Zsym-u-em-text",
- "en-Zsye-u-em-text",
+ // Strings that contain the script.
+ "und-Latn-u-em-text", "en-Jpan-u-em-text", "und-Zsym-u-em-text", "und-Zsye-u-em-text",
+ "en-Zsym-u-em-text", "en-Zsye-u-em-text",
- // Strings that contain the country.
- "und-US-u-em-text",
- "en-US-u-em-text",
- "es-419-u-em-text",
- "und-Latn-US-u-em-text",
- "en-Zsym-US-u-em-text",
- "en-Zsye-US-u-em-text",
- "es-Zsye-419-u-em-text",
+ // Strings that contain the country.
+ "und-US-u-em-text", "en-US-u-em-text", "es-419-u-em-text", "und-Latn-US-u-em-text",
+ "en-Zsym-US-u-em-text", "en-Zsye-US-u-em-text", "es-Zsye-419-u-em-text",
- // Strings that contain the variant.
- "de-Latn-DE-1901-u-em-text",
+ // Strings that contain the variant.
+ "de-Latn-DE-1901-u-em-text",
};
for (auto subtagTextString : subtagTextStrings) {
@@ -428,29 +406,21 @@
// unexpectedly translated to en-Latn by ICU.
TEST_F(LocaleListTest, subtagDefaultTest) {
std::string subtagDefaultStrings[] = {
- // Duplicate subtag case.
- "en-Latn-u-em-default-u-em-emoji",
- "en-Latn-u-em-default-u-em-text",
+ // Duplicate subtag case.
+ "en-Latn-u-em-default-u-em-emoji", "en-Latn-u-em-default-u-em-text",
- // Strings that contain language.
- "und-u-em-default",
- "en-u-em-default",
+ // Strings that contain language.
+ "und-u-em-default", "en-u-em-default",
- // Strings that contain the script.
- "en-Latn-u-em-default",
- "en-Zsym-u-em-default",
- "en-Zsye-u-em-default",
+ // Strings that contain the script.
+ "en-Latn-u-em-default", "en-Zsym-u-em-default", "en-Zsye-u-em-default",
- // Strings that contain the country.
- "en-US-u-em-default",
- "en-Latn-US-u-em-default",
- "es-Latn-419-u-em-default",
- "en-Zsym-US-u-em-default",
- "en-Zsye-US-u-em-default",
- "es-Zsye-419-u-em-default",
+ // Strings that contain the country.
+ "en-US-u-em-default", "en-Latn-US-u-em-default", "es-Latn-419-u-em-default",
+ "en-Zsym-US-u-em-default", "en-Zsye-US-u-em-default", "es-Zsye-419-u-em-default",
- // Strings that contain the variant.
- "de-Latn-DE-1901-u-em-default",
+ // Strings that contain the variant.
+ "de-Latn-DE-1901-u-em-default",
};
for (auto subtagDefaultString : subtagDefaultStrings) {
@@ -462,14 +432,14 @@
TEST_F(LocaleListTest, subtagEmptyTest) {
std::string subtagEmptyStrings[] = {
- "und",
- "jp",
- "en-US",
- "en-Latn",
- "en-Latn-US",
- "en-Latn-US-u-em",
- "en-Latn-US-u-em-defaultemoji",
- "de-Latn-DE-1901",
+ "und",
+ "jp",
+ "en-US",
+ "en-Latn",
+ "en-Latn-US",
+ "en-Latn-US-u-em",
+ "en-Latn-US-u-em-defaultemoji",
+ "de-Latn-DE-1901",
};
for (auto subtagEmptyString : subtagEmptyStrings) {
@@ -541,14 +511,13 @@
EXPECT_TRUE(family->hasGlyph(codepoint, i))
<< "Glyph for U+" << std::hex << codepoint << " U+" << i;
}
-
}
}
TEST_F(FontFamilyTest, hasVariationSelectorTest) {
std::shared_ptr<MinikinFont> minikinFont(new MinikinFontForTest(kVsTestFont));
std::shared_ptr<FontFamily> family(
- new FontFamily(std::vector<Font>{ Font(minikinFont, FontStyle()) }));
+ new FontFamily(std::vector<Font>{Font(minikinFont, FontStyle())}));
const uint32_t kVS1 = 0xFE00;
const uint32_t kVS2 = 0xFE01;
@@ -584,23 +553,20 @@
const std::string fontPath;
bool hasVSTable;
} testCases[] = {
- { kTestFontDir "Ja.ttf", true },
- { kTestFontDir "ZhHant.ttf", true },
- { kTestFontDir "ZhHans.ttf", true },
- { kTestFontDir "Italic.ttf", false },
- { kTestFontDir "Bold.ttf", false },
- { kTestFontDir "BoldItalic.ttf", false },
+ {kTestFontDir "Ja.ttf", true}, {kTestFontDir "ZhHant.ttf", true},
+ {kTestFontDir "ZhHans.ttf", true}, {kTestFontDir "Italic.ttf", false},
+ {kTestFontDir "Bold.ttf", false}, {kTestFontDir "BoldItalic.ttf", false},
};
for (auto testCase : testCases) {
- SCOPED_TRACE(testCase.hasVSTable ?
- "Font " + testCase.fontPath + " should have a variation sequence table." :
- "Font " + testCase.fontPath + " shouldn't have a variation sequence table.");
+ SCOPED_TRACE(testCase.hasVSTable ? "Font " + testCase.fontPath +
+ " should have a variation sequence table."
+ : "Font " + testCase.fontPath +
+ " shouldn't have a variation sequence table.");
- std::shared_ptr<MinikinFont> minikinFont(
- new MinikinFontForTest(testCase.fontPath));
- std::shared_ptr<FontFamily> family(new FontFamily(
- std::vector<Font>{ Font(minikinFont, FontStyle()) }));
+ std::shared_ptr<MinikinFont> minikinFont(new MinikinFontForTest(testCase.fontPath));
+ std::shared_ptr<FontFamily> family(
+ new FontFamily(std::vector<Font>{Font(minikinFont, FontStyle())}));
EXPECT_EQ(testCase.hasVSTable, family->hasVSTable());
}
}
@@ -616,9 +582,8 @@
{
// Do not ceate new instance if none of variations are specified.
EXPECT_EQ(nullptr,
- multiAxisFamily->createFamilyWithVariation(std::vector<FontVariation>()));
- EXPECT_EQ(nullptr,
- noAxisFamily->createFamilyWithVariation(std::vector<FontVariation>()));
+ multiAxisFamily->createFamilyWithVariation(std::vector<FontVariation>()));
+ EXPECT_EQ(nullptr, noAxisFamily->createFamilyWithVariation(std::vector<FontVariation>()));
}
{
// New instance should be used for supported variation.
@@ -631,10 +596,8 @@
}
{
// New instance should be used for supported variation. (multiple variations case)
- std::vector<FontVariation> variations = {
- { MinikinFont::MakeTag('w', 'd', 't', 'h'), 1.0f },
- { MinikinFont::MakeTag('w', 'g', 'h', 't'), 1.0f }
- };
+ std::vector<FontVariation> variations = {{MinikinFont::MakeTag('w', 'd', 't', 'h'), 1.0f},
+ {MinikinFont::MakeTag('w', 'g', 'h', 't'), 1.0f}};
std::shared_ptr<FontFamily> newFamily(
multiAxisFamily->createFamilyWithVariation(variations));
EXPECT_NE(nullptr, newFamily.get());
@@ -643,18 +606,14 @@
}
{
// Do not ceate new instance if none of variations are supported.
- std::vector<FontVariation> variations = {
- { MinikinFont::MakeTag('Z', 'Z', 'Z', 'Z'), 1.0f }
- };
+ std::vector<FontVariation> variations = {{MinikinFont::MakeTag('Z', 'Z', 'Z', 'Z'), 1.0f}};
EXPECT_EQ(nullptr, multiAxisFamily->createFamilyWithVariation(variations));
EXPECT_EQ(nullptr, noAxisFamily->createFamilyWithVariation(variations));
}
{
// At least one axis is supported, should create new instance.
- std::vector<FontVariation> variations = {
- { MinikinFont::MakeTag('w', 'd', 't', 'h'), 1.0f },
- { MinikinFont::MakeTag('Z', 'Z', 'Z', 'Z'), 1.0f }
- };
+ std::vector<FontVariation> variations = {{MinikinFont::MakeTag('w', 'd', 't', 'h'), 1.0f},
+ {MinikinFont::MakeTag('Z', 'Z', 'Z', 'Z'), 1.0f}};
std::shared_ptr<FontFamily> newFamily(
multiAxisFamily->createFamilyWithVariation(variations));
EXPECT_NE(nullptr, newFamily.get());
@@ -700,8 +659,8 @@
std::string fontStyleToString(const FontStyle& style) {
char buf[64] = {};
- snprintf(buf, sizeof(buf), "FontStyle(weight=%d, slant=%s)",
- style.weight(), slantToString(style.slant()));
+ snprintf(buf, sizeof(buf), "FontStyle(weight=%d, slant=%s)", style.weight(),
+ slantToString(style.slant()));
return buf;
}
@@ -719,58 +678,58 @@
constexpr FontStyle::Slant ITALIC = FontStyle::Slant::ITALIC;
const std::vector<FontStyle> STANDARD_SET = {
- FontStyle(NORMAL, UPRIGHT), // 0
- FontStyle(BOLD, UPRIGHT), // 1
- FontStyle(NORMAL, ITALIC), // 2
- FontStyle(BOLD, ITALIC), // 3
+ FontStyle(NORMAL, UPRIGHT), // 0
+ FontStyle(BOLD, UPRIGHT), // 1
+ FontStyle(NORMAL, ITALIC), // 2
+ FontStyle(BOLD, ITALIC), // 3
};
const std::vector<FontStyle> FULL_SET = {
- FontStyle(THIN, UPRIGHT), // 0
- FontStyle(LIGHT, UPRIGHT), // 1
- FontStyle(NORMAL, UPRIGHT), // 2
- FontStyle(MEDIUM, UPRIGHT), // 3
- FontStyle(BOLD, UPRIGHT), // 4
- FontStyle(BLACK, UPRIGHT), // 5
- FontStyle(THIN, ITALIC), // 6
- FontStyle(LIGHT, ITALIC), // 7
- FontStyle(NORMAL, ITALIC), // 8
- FontStyle(MEDIUM, ITALIC), // 9
- FontStyle(BOLD, ITALIC), // 10
- FontStyle(BLACK, ITALIC), // 11
+ FontStyle(THIN, UPRIGHT), // 0
+ FontStyle(LIGHT, UPRIGHT), // 1
+ FontStyle(NORMAL, UPRIGHT), // 2
+ FontStyle(MEDIUM, UPRIGHT), // 3
+ FontStyle(BOLD, UPRIGHT), // 4
+ FontStyle(BLACK, UPRIGHT), // 5
+ FontStyle(THIN, ITALIC), // 6
+ FontStyle(LIGHT, ITALIC), // 7
+ FontStyle(NORMAL, ITALIC), // 8
+ FontStyle(MEDIUM, ITALIC), // 9
+ FontStyle(BOLD, ITALIC), // 10
+ FontStyle(BLACK, ITALIC), // 11
};
struct TestCase {
FontStyle wantedStyle;
std::vector<FontStyle> familyStyles;
size_t expectedIndex;
} testCases[] = {
- { FontStyle(), { FontStyle() } , 0 },
+ {FontStyle(), {FontStyle()}, 0},
- // Exact matches
- { FontStyle(BOLD), { FontStyle(NORMAL), FontStyle(BOLD) }, 1 },
- { FontStyle(BOLD), { FontStyle(LIGHT), FontStyle(BOLD) }, 1 },
- { FontStyle(LIGHT), { FontStyle(NORMAL), FontStyle(LIGHT) }, 1 },
- { FontStyle(LIGHT), { FontStyle(BOLD), FontStyle(LIGHT) }, 1 },
- { FontStyle(NORMAL), { FontStyle(NORMAL), FontStyle(LIGHT) }, 0 },
- { FontStyle(NORMAL), { FontStyle(NORMAL), FontStyle(BOLD) }, 0 },
- { FontStyle(LIGHT), { FontStyle(LIGHT), FontStyle(NORMAL), FontStyle(BOLD) }, 0 },
- { FontStyle(NORMAL), { FontStyle(LIGHT), FontStyle(NORMAL), FontStyle(BOLD) }, 1 },
- { FontStyle(BOLD), { FontStyle(LIGHT), FontStyle(NORMAL), FontStyle(BOLD) }, 2 },
+ // Exact matches
+ {FontStyle(BOLD), {FontStyle(NORMAL), FontStyle(BOLD)}, 1},
+ {FontStyle(BOLD), {FontStyle(LIGHT), FontStyle(BOLD)}, 1},
+ {FontStyle(LIGHT), {FontStyle(NORMAL), FontStyle(LIGHT)}, 1},
+ {FontStyle(LIGHT), {FontStyle(BOLD), FontStyle(LIGHT)}, 1},
+ {FontStyle(NORMAL), {FontStyle(NORMAL), FontStyle(LIGHT)}, 0},
+ {FontStyle(NORMAL), {FontStyle(NORMAL), FontStyle(BOLD)}, 0},
+ {FontStyle(LIGHT), {FontStyle(LIGHT), FontStyle(NORMAL), FontStyle(BOLD)}, 0},
+ {FontStyle(NORMAL), {FontStyle(LIGHT), FontStyle(NORMAL), FontStyle(BOLD)}, 1},
+ {FontStyle(BOLD), {FontStyle(LIGHT), FontStyle(NORMAL), FontStyle(BOLD)}, 2},
- { FontStyle(UPRIGHT), { FontStyle(UPRIGHT), FontStyle(ITALIC) }, 0 },
- { FontStyle(ITALIC), { FontStyle(UPRIGHT), FontStyle(ITALIC) }, 1 },
+ {FontStyle(UPRIGHT), {FontStyle(UPRIGHT), FontStyle(ITALIC)}, 0},
+ {FontStyle(ITALIC), {FontStyle(UPRIGHT), FontStyle(ITALIC)}, 1},
- { FontStyle(NORMAL, UPRIGHT), STANDARD_SET, 0 },
- { FontStyle(BOLD, UPRIGHT), STANDARD_SET, 1 },
- { FontStyle(NORMAL, ITALIC), STANDARD_SET, 2 },
- { FontStyle(BOLD, ITALIC), STANDARD_SET, 3 },
+ {FontStyle(NORMAL, UPRIGHT), STANDARD_SET, 0},
+ {FontStyle(BOLD, UPRIGHT), STANDARD_SET, 1},
+ {FontStyle(NORMAL, ITALIC), STANDARD_SET, 2},
+ {FontStyle(BOLD, ITALIC), STANDARD_SET, 3},
- { FontStyle(NORMAL, UPRIGHT), FULL_SET, 2 },
- { FontStyle(BOLD, UPRIGHT), FULL_SET, 4 },
- { FontStyle(NORMAL, ITALIC), FULL_SET, 8 },
- { FontStyle(BOLD, ITALIC), FULL_SET, 10 },
+ {FontStyle(NORMAL, UPRIGHT), FULL_SET, 2},
+ {FontStyle(BOLD, UPRIGHT), FULL_SET, 4},
+ {FontStyle(NORMAL, ITALIC), FULL_SET, 8},
+ {FontStyle(BOLD, ITALIC), FULL_SET, 10},
- // TODO: Add fallback expectations. (b/68814338)
+ // TODO: Add fallback expectations. (b/68814338)
};
for (const TestCase& testCase : testCases) {
@@ -794,11 +753,11 @@
}
ASSERT_NE(idx, dummyFonts.size()) << "The selected font is unknown.";
EXPECT_EQ(testCase.expectedIndex, idx)
- << "Input Style: " << fontStyleToString(testCase.wantedStyle) << std::endl
- << "Actual Families' Style: "
- << fontStyleToString(testCase.familyStyles[idx]) << std::endl
- << "Expected Families' Style: "
- << fontStyleToString(testCase.familyStyles[testCase.expectedIndex]) << std::endl;
+ << "Input Style: " << fontStyleToString(testCase.wantedStyle) << std::endl
+ << "Actual Families' Style: " << fontStyleToString(testCase.familyStyles[idx])
+ << std::endl
+ << "Expected Families' Style: "
+ << fontStyleToString(testCase.familyStyles[testCase.expectedIndex]) << std::endl;
}
}
diff --git a/tests/unittest/FontLanguageListCacheTest.cpp b/tests/unittest/FontLanguageListCacheTest.cpp
index 8b2793c..fafa479 100644
--- a/tests/unittest/FontLanguageListCacheTest.cpp
+++ b/tests/unittest/FontLanguageListCacheTest.cpp
@@ -19,6 +19,7 @@
#include <gtest/gtest.h>
#include "minikin/LocaleList.h"
+
#include "ICUTestBase.h"
#include "LocaleListCache.h"
#include "MinikinInternal.h"
diff --git a/tests/unittest/GraphemeBreakTests.cpp b/tests/unittest/GraphemeBreakTests.cpp
index e897cd5..362ae10 100644
--- a/tests/unittest/GraphemeBreakTests.cpp
+++ b/tests/unittest/GraphemeBreakTests.cpp
@@ -48,10 +48,10 @@
// tests for invalid UTF-16
EXPECT_TRUE(IsBreak("U+D800 | U+D800")); // two leading surrogates
EXPECT_TRUE(IsBreak("U+DC00 | U+DC00")); // two trailing surrogates
- EXPECT_TRUE(IsBreak("'a' | U+D800")); // lonely leading surrogate
- EXPECT_TRUE(IsBreak("U+DC00 | 'a'")); // lonely trailing surrogate
- EXPECT_TRUE(IsBreak("U+D800 | 'a'")); // leading surrogate followed by non-surrogate
- EXPECT_TRUE(IsBreak("'a' | U+DC00")); // non-surrogate followed by trailing surrogate
+ EXPECT_TRUE(IsBreak("'a' | U+D800")); // lonely leading surrogate
+ EXPECT_TRUE(IsBreak("U+DC00 | 'a'")); // lonely trailing surrogate
+ EXPECT_TRUE(IsBreak("U+D800 | 'a'")); // leading surrogate followed by non-surrogate
+ EXPECT_TRUE(IsBreak("'a' | U+DC00")); // non-surrogate followed by trailing surrogate
}
TEST(GraphemeBreak, rules) {
@@ -97,15 +97,15 @@
// Rule GB12 and Rule GB13, Regional_Indicator x Regional_Indicator
EXPECT_FALSE(IsBreak("U+1F1FA | U+1F1F8"));
- EXPECT_TRUE(IsBreak("U+1F1FA U+1F1F8 | U+1F1FA U+1F1F8")); // Regional indicator pair (flag)
- EXPECT_FALSE(IsBreak("U+1F1FA | U+1F1F8 U+1F1FA U+1F1F8")); // Regional indicator pair (flag)
- EXPECT_FALSE(IsBreak("U+1F1FA U+1F1F8 U+1F1FA | U+1F1F8")); // Regional indicator pair (flag)
+ EXPECT_TRUE(IsBreak("U+1F1FA U+1F1F8 | U+1F1FA U+1F1F8")); // Regional indicator pair (flag)
+ EXPECT_FALSE(IsBreak("U+1F1FA | U+1F1F8 U+1F1FA U+1F1F8")); // Regional indicator pair (flag)
+ EXPECT_FALSE(IsBreak("U+1F1FA U+1F1F8 U+1F1FA | U+1F1F8")); // Regional indicator pair (flag)
- EXPECT_TRUE(IsBreak("U+1F1FA U+1F1F8 | U+1F1FA")); // Regional indicator pair (flag)
+ EXPECT_TRUE(IsBreak("U+1F1FA U+1F1F8 | U+1F1FA")); // Regional indicator pair (flag)
EXPECT_FALSE(IsBreak("U+1F1FA | U+1F1F8 U+1F1FA")); // Regional indicator pair (flag)
// Same case as the two above, knowing that the first two characters ligate, which is what
// would typically happen.
- const float firstPairLigated[] = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0}; // Two entries per codepoint
+ const float firstPairLigated[] = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0}; // Two entries per codepoint
EXPECT_TRUE(IsBreakWithAdvances(firstPairLigated, "U+1F1FA U+1F1F8 | U+1F1FA"));
EXPECT_FALSE(IsBreakWithAdvances(firstPairLigated, "U+1F1FA | U+1F1F8 U+1F1FA"));
// Repeat the tests, But now the font doesn't have a ligature for the first two characters,
@@ -115,7 +115,7 @@
EXPECT_FALSE(IsBreakWithAdvances(secondPairLigated, "U+1F1FA U+1F1F8 | U+1F1FA"));
EXPECT_TRUE(IsBreakWithAdvances(secondPairLigated, "U+1F1FA | U+1F1F8 U+1F1FA"));
- EXPECT_TRUE(IsBreak("'a' U+1F1FA U+1F1F8 | U+1F1FA")); // Regional indicator pair (flag)
+ EXPECT_TRUE(IsBreak("'a' U+1F1FA U+1F1F8 | U+1F1FA")); // Regional indicator pair (flag)
EXPECT_FALSE(IsBreak("'a' U+1F1FA | U+1F1F8 U+1F1FA")); // Regional indicator pair (flag)
EXPECT_TRUE(
@@ -135,9 +135,9 @@
// Rule GB999, Any ÷ Any
EXPECT_TRUE(IsBreak("'a' | 'b'"));
- EXPECT_TRUE(IsBreak("'f' | 'i'")); // probable ligature
- EXPECT_TRUE(IsBreak("U+0644 | U+0627")); // probable ligature, lam + alef
- EXPECT_TRUE(IsBreak("U+4E00 | U+4E00")); // CJK ideographs
+ EXPECT_TRUE(IsBreak("'f' | 'i'")); // probable ligature
+ EXPECT_TRUE(IsBreak("U+0644 | U+0627")); // probable ligature, lam + alef
+ EXPECT_TRUE(IsBreak("U+4E00 | U+4E00")); // CJK ideographs
EXPECT_TRUE(IsBreak("'a' | U+1F1FA U+1F1F8")); // Regional indicator pair (flag)
EXPECT_TRUE(IsBreak("U+1F1FA U+1F1F8 | 'a'")); // Regional indicator pair (flag)
@@ -172,10 +172,10 @@
TEST(GraphemeBreak, tailoring) {
// control characters that we interpret as "extend"
- EXPECT_FALSE(IsBreak("'a' | U+00AD")); // soft hyphen
- EXPECT_FALSE(IsBreak("'a' | U+200B")); // zwsp
- EXPECT_FALSE(IsBreak("'a' | U+200E")); // lrm
- EXPECT_FALSE(IsBreak("'a' | U+202A")); // lre
+ EXPECT_FALSE(IsBreak("'a' | U+00AD")); // soft hyphen
+ EXPECT_FALSE(IsBreak("'a' | U+200B")); // zwsp
+ EXPECT_FALSE(IsBreak("'a' | U+200E")); // lrm
+ EXPECT_FALSE(IsBreak("'a' | U+202A")); // lre
EXPECT_FALSE(IsBreak("'a' | U+E0041")); // tag character
// UTC-approved characters for the Prepend class
@@ -187,32 +187,32 @@
EXPECT_FALSE(IsBreak("U+0915 | U+094D U+0915")); // Devanagari ka+virama+ka
EXPECT_FALSE(IsBreak("U+0915 U+094D | U+0915")); // Devanagari ka+virama+ka
EXPECT_FALSE(IsBreak("U+0E01 | U+0E3A U+0E01")); // thai phinthu = pure killer
- EXPECT_TRUE(IsBreak("U+0E01 U+0E3A | U+0E01")); // thai phinthu = pure killer
+ EXPECT_TRUE(IsBreak("U+0E01 U+0E3A | U+0E01")); // thai phinthu = pure killer
// Repetition of above tests, but with a given advances array that implies everything
// became just one cluster.
const float conjoined[] = {1.0, 0.0, 0.0};
EXPECT_FALSE(IsBreakWithAdvances(conjoined,
- "U+0915 | U+094D U+0915")); // Devanagari ka+virama+ka
+ "U+0915 | U+094D U+0915")); // Devanagari ka+virama+ka
EXPECT_FALSE(IsBreakWithAdvances(conjoined,
- "U+0915 U+094D | U+0915")); // Devanagari ka+virama+ka
+ "U+0915 U+094D | U+0915")); // Devanagari ka+virama+ka
EXPECT_FALSE(IsBreakWithAdvances(conjoined,
- "U+0E01 | U+0E3A U+0E01")); // thai phinthu = pure killer
+ "U+0E01 | U+0E3A U+0E01")); // thai phinthu = pure killer
EXPECT_TRUE(IsBreakWithAdvances(conjoined,
- "U+0E01 U+0E3A | U+0E01")); // thai phinthu = pure killer
+ "U+0E01 U+0E3A | U+0E01")); // thai phinthu = pure killer
// Repetition of above tests, but with a given advances array that the virama did not
// form a cluster with the following consonant. The difference is that there is now
// a grapheme break after the virama in ka+virama+ka.
const float separate[] = {1.0, 0.0, 1.0};
EXPECT_FALSE(IsBreakWithAdvances(separate,
- "U+0915 | U+094D U+0915")); // Devanagari ka+virama+ka
+ "U+0915 | U+094D U+0915")); // Devanagari ka+virama+ka
EXPECT_TRUE(IsBreakWithAdvances(separate,
- "U+0915 U+094D | U+0915")); // Devanagari ka+virama+ka
+ "U+0915 U+094D | U+0915")); // Devanagari ka+virama+ka
EXPECT_FALSE(IsBreakWithAdvances(separate,
- "U+0E01 | U+0E3A U+0E01")); // thai phinthu = pure killer
+ "U+0E01 | U+0E3A U+0E01")); // thai phinthu = pure killer
EXPECT_TRUE(IsBreakWithAdvances(separate,
- "U+0E01 U+0E3A | U+0E01")); // thai phinthu = pure killer
+ "U+0E01 U+0E3A | U+0E01")); // thai phinthu = pure killer
// suppress grapheme breaks in zwj emoji sequences
EXPECT_FALSE(IsBreak("U+1F469 U+200D | U+2764 U+FE0F U+200D U+1F48B U+200D U+1F468"));
@@ -234,8 +234,8 @@
}
TEST(GraphemeBreak, emojiModifiers) {
- EXPECT_FALSE(IsBreak("U+261D | U+1F3FB")); // white up pointing index + modifier
- EXPECT_FALSE(IsBreak("U+270C | U+1F3FB")); // victory hand + modifier
+ EXPECT_FALSE(IsBreak("U+261D | U+1F3FB")); // white up pointing index + modifier
+ EXPECT_FALSE(IsBreak("U+270C | U+1F3FB")); // victory hand + modifier
EXPECT_FALSE(IsBreak("U+1F466 | U+1F3FB")); // boy + modifier
EXPECT_FALSE(IsBreak("U+1F466 | U+1F3FC")); // boy + modifier
EXPECT_FALSE(IsBreak("U+1F466 | U+1F3FD")); // boy + modifier
@@ -281,10 +281,10 @@
EXPECT_TRUE(IsBreakWithAdvances(unligated1_1_2, "U+270C U+FE0F | U+1F3FB"));
// heart is not an emoji base
- EXPECT_TRUE(IsBreak("U+2764 | U+1F3FB")); // heart + modifier
+ EXPECT_TRUE(IsBreak("U+2764 | U+1F3FB")); // heart + modifier
EXPECT_TRUE(IsBreak("U+2764 U+FE0E | U+1F3FB")); // heart + emoji style + modifier
EXPECT_TRUE(IsBreak("U+2764 U+FE0F | U+1F3FB")); // heart + emoji style + modifier
- EXPECT_TRUE(IsBreak("U+1F3FB | U+1F3FB")); // modifier + modifier
+ EXPECT_TRUE(IsBreak("U+1F3FB | U+1F3FB")); // modifier + modifier
// rat is not an emoji modifer
EXPECT_TRUE(IsBreak("U+1F466 | U+1F400")); // boy + rat
@@ -311,7 +311,7 @@
}
TEST(GraphemeBreak, offsets) {
- uint16_t string[] = { 0x0041, 0x06DD, 0x0045, 0x0301, 0x0049, 0x0301 };
+ uint16_t string[] = {0x0041, 0x06DD, 0x0045, 0x0301, 0x0049, 0x0301};
EXPECT_TRUE(GraphemeBreak::isGraphemeBreak(nullptr, string, 2, 3, 2));
EXPECT_FALSE(GraphemeBreak::isGraphemeBreak(nullptr, string, 2, 3, 3));
EXPECT_TRUE(GraphemeBreak::isGraphemeBreak(nullptr, string, 2, 3, 4));
diff --git a/tests/unittest/HbFontCacheTest.cpp b/tests/unittest/HbFontCacheTest.cpp
index ab4347c..066c595 100644
--- a/tests/unittest/HbFontCacheTest.cpp
+++ b/tests/unittest/HbFontCacheTest.cpp
@@ -22,8 +22,9 @@
#include <hb.h>
#include "minikin/MinikinFont.h"
-#include "MinikinInternal.h"
+
#include "MinikinFontForTest.h"
+#include "MinikinInternal.h"
namespace minikin {
@@ -36,11 +37,9 @@
};
TEST_F(HbFontCacheTest, getHbFontLockedTest) {
- std::shared_ptr<MinikinFontForTest> fontA(
- new MinikinFontForTest(kTestFontDir "Regular.ttf"));
+ std::shared_ptr<MinikinFontForTest> fontA(new MinikinFontForTest(kTestFontDir "Regular.ttf"));
- std::shared_ptr<MinikinFontForTest> fontB(
- new MinikinFontForTest(kTestFontDir "Bold.ttf"));
+ std::shared_ptr<MinikinFontForTest> fontB(new MinikinFontForTest(kTestFontDir "Bold.ttf"));
std::shared_ptr<MinikinFontForTest> fontC(
new MinikinFontForTest(kTestFontDir "BoldItalic.ttf"));
diff --git a/tests/unittest/HyphenatorMapTest.cpp b/tests/unittest/HyphenatorMapTest.cpp
index 53d857f..5be6dee 100644
--- a/tests/unittest/HyphenatorMapTest.cpp
+++ b/tests/unittest/HyphenatorMapTest.cpp
@@ -67,8 +67,8 @@
public:
TestableHyphenatorMap() : HyphenatorMap() {}
- using HyphenatorMap::addInternal;
using HyphenatorMap::addAliasInternal;
+ using HyphenatorMap::addInternal;
using HyphenatorMap::lookupInternal;
};
@@ -131,7 +131,6 @@
mMap.addAliasInternal("gez", "und-Ethi");
mMap.addAliasInternal("ti", "und-Ethi");
mMap.addAliasInternal("wal", "und-Ethi");
-
}
const Locale& getLocale(const std::string& localeStr) {
diff --git a/tests/unittest/HyphenatorTest.cpp b/tests/unittest/HyphenatorTest.cpp
index 5f4d703..8c6c26b 100644
--- a/tests/unittest/HyphenatorTest.cpp
+++ b/tests/unittest/HyphenatorTest.cpp
@@ -52,7 +52,7 @@
const uint16_t word[] = {'t', 'a', 'b', 'l', 'e'};
std::vector<HyphenationType> result;
hyphenator->hyphenate(&result, word, NELEM(word));
- EXPECT_EQ((size_t) 5, result.size());
+ EXPECT_EQ((size_t)5, result.size());
EXPECT_EQ(HyphenationType::DONT_BREAK, result[0]);
EXPECT_EQ(HyphenationType::DONT_BREAK, result[1]);
EXPECT_EQ(HyphenationType::BREAK_AND_INSERT_HYPHEN, result[2]);
@@ -66,7 +66,7 @@
const uint16_t word[] = {'l', 'l', MIDDLE_DOT, 'l', 'l'};
std::vector<HyphenationType> result;
hyphenator->hyphenate(&result, word, NELEM(word));
- EXPECT_EQ((size_t) 5, result.size());
+ EXPECT_EQ((size_t)5, result.size());
EXPECT_EQ(HyphenationType::DONT_BREAK, result[0]);
EXPECT_EQ(HyphenationType::DONT_BREAK, result[1]);
EXPECT_EQ(HyphenationType::DONT_BREAK, result[2]);
@@ -80,7 +80,7 @@
const uint16_t word[] = {'l', MIDDLE_DOT, 'l'};
std::vector<HyphenationType> result;
hyphenator->hyphenate(&result, word, NELEM(word));
- EXPECT_EQ((size_t) 3, result.size());
+ EXPECT_EQ((size_t)3, result.size());
EXPECT_EQ(HyphenationType::DONT_BREAK, result[0]);
EXPECT_EQ(HyphenationType::DONT_BREAK, result[1]);
EXPECT_EQ(HyphenationType::DONT_BREAK, result[2]);
@@ -92,7 +92,7 @@
const uint16_t word[] = {'x', HYPHEN, 'y'};
std::vector<HyphenationType> result;
hyphenator->hyphenate(&result, word, NELEM(word));
- EXPECT_EQ((size_t) 3, result.size());
+ EXPECT_EQ((size_t)3, result.size());
EXPECT_EQ(HyphenationType::DONT_BREAK, result[0]);
EXPECT_EQ(HyphenationType::DONT_BREAK, result[1]);
EXPECT_EQ(HyphenationType::BREAK_AND_INSERT_HYPHEN_AT_NEXT_LINE, result[2]);
@@ -104,7 +104,7 @@
const uint16_t word[] = {GREEK_LOWER_ALPHA, HYPHEN, GREEK_LOWER_ALPHA};
std::vector<HyphenationType> result;
hyphenator->hyphenate(&result, word, NELEM(word));
- EXPECT_EQ((size_t) 3, result.size());
+ EXPECT_EQ((size_t)3, result.size());
EXPECT_EQ(HyphenationType::DONT_BREAK, result[0]);
EXPECT_EQ(HyphenationType::DONT_BREAK, result[1]);
EXPECT_EQ(HyphenationType::BREAK_AND_DONT_INSERT_HYPHEN, result[2]);
@@ -117,7 +117,7 @@
const uint16_t word[] = {'x', EN_DASH, 'y'};
std::vector<HyphenationType> result;
hyphenator->hyphenate(&result, word, NELEM(word));
- EXPECT_EQ((size_t) 3, result.size());
+ EXPECT_EQ((size_t)3, result.size());
EXPECT_EQ(HyphenationType::DONT_BREAK, result[0]);
EXPECT_EQ(HyphenationType::DONT_BREAK, result[1]);
EXPECT_EQ(HyphenationType::BREAK_AND_DONT_INSERT_HYPHEN, result[2]);
@@ -130,7 +130,7 @@
const uint16_t word[] = {'x', HYPHEN, 'y'};
std::vector<HyphenationType> result;
hyphenator->hyphenate(&result, word, NELEM(word));
- EXPECT_EQ((size_t) 3, result.size());
+ EXPECT_EQ((size_t)3, result.size());
EXPECT_EQ(HyphenationType::DONT_BREAK, result[0]);
EXPECT_EQ(HyphenationType::DONT_BREAK, result[1]);
EXPECT_EQ(HyphenationType::BREAK_AND_INSERT_HYPHEN_AT_NEXT_LINE, result[2]);
@@ -142,7 +142,7 @@
const uint16_t word[] = {'x', SOFT_HYPHEN, 'y'};
std::vector<HyphenationType> result;
hyphenator->hyphenate(&result, word, NELEM(word));
- EXPECT_EQ((size_t) 3, result.size());
+ EXPECT_EQ((size_t)3, result.size());
EXPECT_EQ(HyphenationType::DONT_BREAK, result[0]);
EXPECT_EQ(HyphenationType::DONT_BREAK, result[1]);
EXPECT_EQ(HyphenationType::BREAK_AND_INSERT_HYPHEN, result[2]);
@@ -154,7 +154,7 @@
const uint16_t word[] = {SOFT_HYPHEN, 'y'};
std::vector<HyphenationType> result;
hyphenator->hyphenate(&result, word, NELEM(word));
- EXPECT_EQ((size_t) 2, result.size());
+ EXPECT_EQ((size_t)2, result.size());
EXPECT_EQ(HyphenationType::DONT_BREAK, result[0]);
EXPECT_EQ(HyphenationType::DONT_BREAK, result[1]);
}
@@ -165,7 +165,7 @@
const uint16_t word[] = {MALAYALAM_KA, SOFT_HYPHEN, MALAYALAM_KA};
std::vector<HyphenationType> result;
hyphenator->hyphenate(&result, word, NELEM(word));
- EXPECT_EQ((size_t) 3, result.size());
+ EXPECT_EQ((size_t)3, result.size());
EXPECT_EQ(HyphenationType::DONT_BREAK, result[0]);
EXPECT_EQ(HyphenationType::DONT_BREAK, result[1]);
EXPECT_EQ(HyphenationType::BREAK_AND_DONT_INSERT_HYPHEN, result[2]);
@@ -173,13 +173,12 @@
// In automatically hyphenated Malayalam script text, we should not insert a visible hyphen.
TEST_F(HyphenatorTest, malayalamAutomaticHyphenation) {
- Hyphenator* hyphenator = Hyphenator::loadBinary(
- readWholeFile(malayalamHyph).data(), 2, 2, "en");
- const uint16_t word[] = {
- MALAYALAM_KA, MALAYALAM_KA, MALAYALAM_KA, MALAYALAM_KA, MALAYALAM_KA};
+ Hyphenator* hyphenator =
+ Hyphenator::loadBinary(readWholeFile(malayalamHyph).data(), 2, 2, "en");
+ const uint16_t word[] = {MALAYALAM_KA, MALAYALAM_KA, MALAYALAM_KA, MALAYALAM_KA, MALAYALAM_KA};
std::vector<HyphenationType> result;
hyphenator->hyphenate(&result, word, NELEM(word));
- EXPECT_EQ((size_t) 5, result.size());
+ EXPECT_EQ((size_t)5, result.size());
EXPECT_EQ(HyphenationType::DONT_BREAK, result[0]);
EXPECT_EQ(HyphenationType::DONT_BREAK, result[1]);
EXPECT_EQ(HyphenationType::BREAK_AND_DONT_INSERT_HYPHEN, result[2]);
@@ -193,7 +192,7 @@
const uint16_t word[] = {ARMENIAN_AYB, SOFT_HYPHEN, ARMENIAN_AYB};
std::vector<HyphenationType> result;
hyphenator->hyphenate(&result, word, NELEM(word));
- EXPECT_EQ((size_t) 3, result.size());
+ EXPECT_EQ((size_t)3, result.size());
EXPECT_EQ(HyphenationType::DONT_BREAK, result[0]);
EXPECT_EQ(HyphenationType::DONT_BREAK, result[1]);
EXPECT_EQ(HyphenationType::BREAK_AND_INSERT_ARMENIAN_HYPHEN, result[2]);
@@ -206,7 +205,7 @@
const uint16_t word[] = {HEBREW_ALEF, SOFT_HYPHEN, HEBREW_ALEF};
std::vector<HyphenationType> result;
hyphenator->hyphenate(&result, word, NELEM(word));
- EXPECT_EQ((size_t) 3, result.size());
+ EXPECT_EQ((size_t)3, result.size());
EXPECT_EQ(HyphenationType::DONT_BREAK, result[0]);
EXPECT_EQ(HyphenationType::DONT_BREAK, result[1]);
EXPECT_EQ(HyphenationType::BREAK_AND_INSERT_HYPHEN, result[2]);
@@ -219,7 +218,7 @@
const uint16_t word[] = {ARABIC_BEH, SOFT_HYPHEN, ARABIC_BEH};
std::vector<HyphenationType> result;
hyphenator->hyphenate(&result, word, NELEM(word));
- EXPECT_EQ((size_t) 3, result.size());
+ EXPECT_EQ((size_t)3, result.size());
EXPECT_EQ(HyphenationType::DONT_BREAK, result[0]);
EXPECT_EQ(HyphenationType::DONT_BREAK, result[1]);
EXPECT_EQ(HyphenationType::BREAK_AND_INSERT_HYPHEN_AND_ZWJ, result[2]);
@@ -232,7 +231,7 @@
const uint16_t word[] = {ARABIC_ALEF, SOFT_HYPHEN, ARABIC_BEH};
std::vector<HyphenationType> result;
hyphenator->hyphenate(&result, word, NELEM(word));
- EXPECT_EQ((size_t) 3, result.size());
+ EXPECT_EQ((size_t)3, result.size());
EXPECT_EQ(HyphenationType::DONT_BREAK, result[0]);
EXPECT_EQ(HyphenationType::DONT_BREAK, result[1]);
EXPECT_EQ(HyphenationType::BREAK_AND_INSERT_HYPHEN, result[2]);
@@ -244,7 +243,7 @@
const uint16_t word[] = {ARABIC_BEH, ARABIC_ZWARAKAY, SOFT_HYPHEN, ARABIC_ZWARAKAY, ARABIC_BEH};
std::vector<HyphenationType> result;
hyphenator->hyphenate(&result, word, NELEM(word));
- EXPECT_EQ((size_t) 5, result.size());
+ EXPECT_EQ((size_t)5, result.size());
EXPECT_EQ(HyphenationType::DONT_BREAK, result[0]);
EXPECT_EQ(HyphenationType::DONT_BREAK, result[1]);
EXPECT_EQ(HyphenationType::DONT_BREAK, result[2]);
@@ -259,7 +258,7 @@
const uint16_t word[] = {ARABIC_BEH, ARABIC_ZWARAKAY, SOFT_HYPHEN, ARABIC_ZWARAKAY};
std::vector<HyphenationType> result;
hyphenator->hyphenate(&result, word, NELEM(word));
- EXPECT_EQ((size_t) 4, result.size());
+ EXPECT_EQ((size_t)4, result.size());
EXPECT_EQ(HyphenationType::DONT_BREAK, result[0]);
EXPECT_EQ(HyphenationType::DONT_BREAK, result[1]);
EXPECT_EQ(HyphenationType::DONT_BREAK, result[2]);
@@ -273,7 +272,7 @@
const uint16_t word[] = {ARABIC_ZWARAKAY, SOFT_HYPHEN, ARABIC_ZWARAKAY, ARABIC_BEH};
std::vector<HyphenationType> result;
hyphenator->hyphenate(&result, word, NELEM(word));
- EXPECT_EQ((size_t) 4, result.size());
+ EXPECT_EQ((size_t)4, result.size());
EXPECT_EQ(HyphenationType::DONT_BREAK, result[0]);
EXPECT_EQ(HyphenationType::DONT_BREAK, result[1]);
EXPECT_EQ(HyphenationType::BREAK_AND_INSERT_HYPHEN, result[2]);
@@ -286,7 +285,7 @@
const uint16_t word[] = {UCAS_E, SOFT_HYPHEN, UCAS_E};
std::vector<HyphenationType> result;
hyphenator->hyphenate(&result, word, NELEM(word));
- EXPECT_EQ((size_t) 3, result.size());
+ EXPECT_EQ((size_t)3, result.size());
EXPECT_EQ(HyphenationType::DONT_BREAK, result[0]);
EXPECT_EQ(HyphenationType::DONT_BREAK, result[1]);
EXPECT_EQ(HyphenationType::BREAK_AND_INSERT_UCAS_HYPHEN, result[2]);
@@ -299,7 +298,7 @@
const uint16_t word[] = {'a', SOFT_HYPHEN, UCAS_E};
std::vector<HyphenationType> result;
hyphenator->hyphenate(&result, word, NELEM(word));
- EXPECT_EQ((size_t) 3, result.size());
+ EXPECT_EQ((size_t)3, result.size());
EXPECT_EQ(HyphenationType::DONT_BREAK, result[0]);
EXPECT_EQ(HyphenationType::DONT_BREAK, result[1]);
EXPECT_EQ(HyphenationType::BREAK_AND_INSERT_UCAS_HYPHEN, result[2]);
@@ -311,7 +310,7 @@
const uint16_t word[] = {'x', HYPHEN, 'y'};
std::vector<HyphenationType> result;
hyphenator->hyphenate(&result, word, NELEM(word));
- EXPECT_EQ((size_t) 3, result.size());
+ EXPECT_EQ((size_t)3, result.size());
EXPECT_EQ(HyphenationType::DONT_BREAK, result[0]);
EXPECT_EQ(HyphenationType::DONT_BREAK, result[1]);
EXPECT_EQ(HyphenationType::BREAK_AND_DONT_INSERT_HYPHEN, result[2]);
@@ -323,7 +322,7 @@
const uint16_t word[] = {'x', HYPHEN_MINUS, 'y'};
std::vector<HyphenationType> result;
hyphenator->hyphenate(&result, word, NELEM(word));
- EXPECT_EQ((size_t) 3, result.size());
+ EXPECT_EQ((size_t)3, result.size());
EXPECT_EQ(HyphenationType::DONT_BREAK, result[0]);
EXPECT_EQ(HyphenationType::DONT_BREAK, result[1]);
EXPECT_EQ(HyphenationType::BREAK_AND_DONT_INSERT_HYPHEN, result[2]);
@@ -336,10 +335,9 @@
const uint16_t word[] = {HYPHEN_MINUS, 'y'};
std::vector<HyphenationType> result;
hyphenator->hyphenate(&result, word, NELEM(word));
- EXPECT_EQ((size_t) 2, result.size());
+ EXPECT_EQ((size_t)2, result.size());
EXPECT_EQ(HyphenationType::DONT_BREAK, result[0]);
EXPECT_EQ(HyphenationType::DONT_BREAK, result[1]);
}
} // namespace minikin
-
diff --git a/tests/unittest/ICUTestBase.h b/tests/unittest/ICUTestBase.h
index e0b0f5e..07bd865 100644
--- a/tests/unittest/ICUTestBase.h
+++ b/tests/unittest/ICUTestBase.h
@@ -19,8 +19,8 @@
// low level file access for mapping ICU data
#include <fcntl.h>
-#include <sys/stat.h>
#include <sys/mman.h>
+#include <sys/stat.h>
#include <gtest/gtest.h>
#include <unicode/uclean.h>
@@ -46,9 +46,7 @@
ASSERT_TRUE(U_SUCCESS(errorCode));
}
- virtual void TearDown() override {
- u_cleanup();
- }
+ virtual void TearDown() override { u_cleanup(); }
};
} // namespace minikin
diff --git a/tests/unittest/LayoutTest.cpp b/tests/unittest/LayoutTest.cpp
index b63bdfe..e025677 100644
--- a/tests/unittest/LayoutTest.cpp
+++ b/tests/unittest/LayoutTest.cpp
@@ -19,6 +19,7 @@
#include <gtest/gtest.h>
#include "minikin/FontCollection.h"
+
#include "FontTestUtils.h"
#include "ICUTestBase.h"
#include "UnicodeUtils.h"
@@ -48,8 +49,7 @@
class LayoutTest : public ICUTestBase {
protected:
- LayoutTest() : mCollection(nullptr) {
- }
+ LayoutTest() : mCollection(nullptr) {}
virtual ~LayoutTest() {}
@@ -58,8 +58,7 @@
getFontCollection(SYSTEM_FONT_PATH, SYSTEM_FONT_XML));
}
- virtual void TearDown() override {
- }
+ virtual void TearDown() override {}
std::shared_ptr<FontCollection> mCollection;
};
@@ -343,10 +342,12 @@
std::vector<uint16_t> text = parseUnicodeString("'a' 'b' U+3042 U+3043 'c' 'd'");
Layout ltrLayout;
- ltrLayout.doLayout(text.data(), 0, text.size(), text.size(), Bidi::FORCE_LTR, paint, mCollection);
+ ltrLayout.doLayout(text.data(), 0, text.size(), text.size(), Bidi::FORCE_LTR, paint,
+ mCollection);
Layout rtlLayout;
- rtlLayout.doLayout(text.data(), 0, text.size(), text.size(), Bidi::FORCE_RTL, paint, mCollection);
+ rtlLayout.doLayout(text.data(), 0, text.size(), text.size(), Bidi::FORCE_RTL, paint,
+ mCollection);
ASSERT_EQ(ltrLayout.nGlyphs(), rtlLayout.nGlyphs());
ASSERT_EQ(6u, ltrLayout.nGlyphs());
@@ -372,7 +373,7 @@
Layout defaultRtlLayout;
defaultRtlLayout.doLayout(text.data(), 0, text.size(), text.size(), Bidi::DEFAULT_RTL, paint,
- mCollection);
+ mCollection);
const size_t nGlyphs = ltrLayout.nGlyphs();
ASSERT_EQ(3u, nGlyphs);
@@ -413,8 +414,8 @@
SCOPED_TRACE("one word with hyphen replacement at the end");
text = utf8ToUtf16("oneword");
MinikinPaint paint;
- paint.hyphenEdit = packHyphenEdit(
- StartHyphenEdit::NO_EDIT, EndHyphenEdit::REPLACE_WITH_HYPHEN);
+ paint.hyphenEdit =
+ packHyphenEdit(StartHyphenEdit::NO_EDIT, EndHyphenEdit::REPLACE_WITH_HYPHEN);
layout.doLayout(text.data(), 0, text.size(), text.size(), Bidi::LTR, paint, mCollection);
EXPECT_EQ(70.0f, layout.getAdvance());
}
@@ -430,8 +431,8 @@
SCOPED_TRACE("one word with hyphen insertion at the both ends");
text = utf8ToUtf16("oneword");
MinikinPaint paint;
- paint.hyphenEdit = packHyphenEdit(
- StartHyphenEdit::INSERT_HYPHEN, EndHyphenEdit::INSERT_HYPHEN);
+ paint.hyphenEdit =
+ packHyphenEdit(StartHyphenEdit::INSERT_HYPHEN, EndHyphenEdit::INSERT_HYPHEN);
layout.doLayout(text.data(), 0, text.size(), text.size(), Bidi::LTR, paint, mCollection);
EXPECT_EQ(90.0f, layout.getAdvance());
}
diff --git a/tests/unittest/LayoutUtilsTest.cpp b/tests/unittest/LayoutUtilsTest.cpp
index b789f91..4c18cce 100644
--- a/tests/unittest/LayoutUtilsTest.cpp
+++ b/tests/unittest/LayoutUtilsTest.cpp
@@ -29,9 +29,8 @@
size_t size = 0U;
ParseUnicode(buf, BUF_SIZE, query_str, &size, &expected_breakpoint);
- EXPECT_EQ(expected_breakpoint,
- getNextWordBreakForCache(buf, offset_in, size))
- << "Expected position is [" << query_str << "] from offset " << offset_in;
+ EXPECT_EQ(expected_breakpoint, getNextWordBreakForCache(buf, offset_in, size))
+ << "Expected position is [" << query_str << "] from offset " << offset_in;
}
void ExpectPrevWordBreakForCache(size_t offset_in, const char* query_str) {
@@ -41,9 +40,8 @@
size_t size = 0U;
ParseUnicode(buf, BUF_SIZE, query_str, &size, &expected_breakpoint);
- EXPECT_EQ(expected_breakpoint,
- getPrevWordBreakForCache(buf, offset_in, size))
- << "Expected position is [" << query_str << "] from offset " << offset_in;
+ EXPECT_EQ(expected_breakpoint, getPrevWordBreakForCache(buf, offset_in, size))
+ << "Expected position is [" << query_str << "] from offset " << offset_in;
}
TEST(WordBreakTest, goNextWordBreakTest) {
@@ -90,8 +88,7 @@
ExpectNextWordBreakForCache(3, "U+4E00 U+4E00 U+4E00 U+4E00 | U+4E00");
ExpectNextWordBreakForCache(4, "U+4E00 U+4E00 U+4E00 U+4E00 U+4E00 |");
ExpectNextWordBreakForCache(5, "U+4E00 U+4E00 U+4E00 U+4E00 U+4E00 |");
- ExpectNextWordBreakForCache(1000,
- "U+4E00 U+4E00 U+4E00 U+4E00 U+4E00 |");
+ ExpectNextWordBreakForCache(1000, "U+4E00 U+4E00 U+4E00 U+4E00 U+4E00 |");
ExpectNextWordBreakForCache(0, "U+4E00 | U+4E8C U+4E09 U+56DB U+4E94");
ExpectNextWordBreakForCache(1, "U+4E00 U+4E8C | U+4E09 U+56DB U+4E94");
@@ -99,8 +96,7 @@
ExpectNextWordBreakForCache(3, "U+4E00 U+4E8C U+4E09 U+56DB | U+4E94");
ExpectNextWordBreakForCache(4, "U+4E00 U+4E8C U+4E09 U+56DB U+4E94 |");
ExpectNextWordBreakForCache(5, "U+4E00 U+4E8C U+4E09 U+56DB U+4E94 |");
- ExpectNextWordBreakForCache(1000,
- "U+4E00 U+4E8C U+4E09 U+56DB U+4E94 |");
+ ExpectNextWordBreakForCache(1000, "U+4E00 U+4E8C U+4E09 U+56DB U+4E94 |");
ExpectNextWordBreakForCache(0, "U+4E00 'a' 'b' | U+2000 'c' U+4E00");
ExpectNextWordBreakForCache(1, "U+4E00 'a' 'b' | U+2000 'c' U+4E00");
@@ -247,8 +243,7 @@
ExpectNextWordBreakForCache(4, "U+845B U+E0100 U+E0100 | U+845B");
ExpectNextWordBreakForCache(5, "U+845B U+E0100 U+E0100 U+845B |");
ExpectNextWordBreakForCache(6, "U+845B U+E0100 U+E0100 U+845B |");
- ExpectNextWordBreakForCache(1000,
- "U+845B U+E0100 U+E0100 U+845B |");
+ ExpectNextWordBreakForCache(1000, "U+845B U+E0100 U+E0100 U+845B |");
// CJK Ideographic char + Variation Selector(VS1) + Variation Selector(VS17)
ExpectNextWordBreakForCache(0, "U+845B U+FE00 U+E0100 | U+845B");
@@ -478,8 +473,7 @@
ExpectPrevWordBreakForCache(4, "| U+845B U+E0100 U+E0100 U+845B");
ExpectPrevWordBreakForCache(5, "| U+845B U+E0100 U+E0100 U+845B");
ExpectPrevWordBreakForCache(6, "U+845B U+E0100 U+E0100 | U+845B");
- ExpectPrevWordBreakForCache(1000,
- "U+845B U+E0100 U+E0100 | U+845B");
+ ExpectPrevWordBreakForCache(1000, "U+845B U+E0100 U+E0100 | U+845B");
// CJK Ideographic char + Variation Selector(VS1) + Variation Selector(VS17)
ExpectPrevWordBreakForCache(0, "| U+845B U+FE00 U+E0100 U+845B");
diff --git a/tests/unittest/LineBreakerTest.cpp b/tests/unittest/LineBreakerTest.cpp
index 9223ccd..f86357d 100644
--- a/tests/unittest/LineBreakerTest.cpp
+++ b/tests/unittest/LineBreakerTest.cpp
@@ -22,9 +22,9 @@
#include <utility>
#include <cutils/log.h>
+#include <gtest/gtest.h>
#include <unicode/locid.h>
#include <unicode/uchriter.h>
-#include <gtest/gtest.h>
#include "FontTestUtils.h"
#include "ICUTestBase.h"
@@ -48,28 +48,26 @@
}
struct LocaleComparator {
- bool operator() (const Locale& l, const Locale& r) const {
+ bool operator()(const Locale& l, const Locale& r) const {
return l.getIdentifier() > r.getIdentifier();
}
};
// Helper function for creating vector of move-only elements.
-template<class Base, class T, class... Tail>
+template <class Base, class T, class... Tail>
constexpr std::vector<Base> makeVector(T&& head, Tail&&... tail) {
- std::array<T, 1 + sizeof...(Tail)> ar = {{std::forward<T>(head), std::forward<Tail>(tail)... }};
- return std::vector<Base>({std::make_move_iterator(std::begin(ar)),
- std::make_move_iterator(std::end(ar))});
+ std::array<T, 1 + sizeof...(Tail)> ar = {{std::forward<T>(head), std::forward<Tail>(tail)...}};
+ return std::vector<Base>(
+ {std::make_move_iterator(std::begin(ar)), std::make_move_iterator(std::end(ar))});
}
typedef std::map<Locale, std::string, LocaleComparator> LocaleIteratorMap;
class MockBreakIterator : public icu::BreakIterator {
public:
- MockBreakIterator(const std::vector<int32_t>& breakPoints) : mBreakPoints(breakPoints) {
- }
+ MockBreakIterator(const std::vector<int32_t>& breakPoints) : mBreakPoints(breakPoints) {}
- virtual ~MockBreakIterator() {
- }
+ virtual ~MockBreakIterator() {}
UClassID getDynamicClassID() const override {
LOG_ALWAYS_FATAL("Not yet implemented.");
@@ -123,13 +121,9 @@
return 0;
}
- int32_t next() override {
- return following(mCurrent);
- }
+ int32_t next() override { return following(mCurrent); }
- int32_t current() const override {
- return mCurrent;
- }
+ int32_t current() const override { return mCurrent; }
int32_t following(int32_t offset) override {
auto i = std::upper_bound(mBreakPoints.begin(), mBreakPoints.end(), offset);
@@ -161,7 +155,7 @@
return nullptr;
}
- BreakIterator &refreshInputText(UText*, UErrorCode&) override {
+ BreakIterator& refreshInputText(UText*, UErrorCode&) override {
LOG_ALWAYS_FATAL("Not yet implemented.");
return *this;
}
@@ -179,11 +173,10 @@
Slot acquire(const Locale& locale) override {
auto i = mLocaleIteratorMap.find(locale);
- LOG_ALWAYS_FATAL_IF(i == mLocaleIteratorMap.end(),
- "Iterator not found for %s", locale.getString().c_str());
+ LOG_ALWAYS_FATAL_IF(i == mLocaleIteratorMap.end(), "Iterator not found for %s",
+ locale.getString().c_str());
return {locale.getIdentifier(),
- std::make_unique<MockBreakIterator>(buildBreakPointList(i->second)) };
-
+ std::make_unique<MockBreakIterator>(buildBreakPointList(i->second))};
}
void release(Slot&& slot) override {
@@ -196,7 +189,7 @@
// For example, "a|bc|d" will be {0, 1, 3, 4}.
// This means '|' could not be used as an input character.
static std::vector<int> buildBreakPointList(const std::string& input) {
- std::vector<int> out = { 0 };
+ std::vector<int> out = {0};
int breakPos = 0;
for (const char c : input) {
if (c == '|') {
@@ -221,8 +214,8 @@
TestableLineBreaker(ICULineBreakerPool* pool, const U16StringPiece& string,
const MeasuredText& measuredText)
: LineBreaker(std::make_unique<TestableWordBreaker>(pool), string, measuredText,
- BreakStrategy::Greedy, HyphenationFrequency::None, false /* justified */)
- {}
+ BreakStrategy::Greedy, HyphenationFrequency::None,
+ false /* justified */) {}
};
class RectangleLineWidthDelegate : public LineWidth {
@@ -230,18 +223,10 @@
RectangleLineWidthDelegate(float width) : mWidth(width) {}
virtual ~RectangleLineWidthDelegate() {}
- float getAt(size_t) const override {
- return mWidth;
- }
- float getMin() const override {
- return mWidth;
- }
- float getLeftPaddingAt(size_t) const override {
- return 0;
- }
- float getRightPaddingAt(size_t) const override {
- return 0;
- }
+ float getAt(size_t) const override { return mWidth; }
+ float getMin() const override { return mWidth; }
+ float getLeftPaddingAt(size_t) const override { return 0; }
+ float getRightPaddingAt(size_t) const override { return 0; }
private:
float mWidth;
@@ -249,8 +234,7 @@
class LineBreakerTest : public ICUTestBase {
public:
- LineBreakerTest()
- : ICUTestBase(), mTabStops(nullptr, 0, 0) {}
+ LineBreakerTest() : ICUTestBase(), mTabStops(nullptr, 0, 0) {}
virtual ~LineBreakerTest() {}
@@ -265,8 +249,7 @@
ICUTestBase::TearDown();
}
- LineBreakResult doLineBreak(ICULineBreakerPool* pool,
- const U16StringPiece& text,
+ LineBreakResult doLineBreak(ICULineBreakerPool* pool, const U16StringPiece& text,
const std::vector<std::unique_ptr<minikin::Run>>& runs,
float lineWidth) {
RectangleLineWidthDelegate rectangleLineWidth(lineWidth);
@@ -306,8 +289,8 @@
expectedBreaks.push_back(breakPos);
EXPECT_EQ(expectedBreaks, actualBreaks)
- << "Expected: " << buildDisplayText(text, expectedBreaks) << std::endl
- << "Actual : " << buildDisplayText(text, actualBreaks);
+ << "Expected: " << buildDisplayText(text, expectedBreaks) << std::endl
+ << "Actual : " << buildDisplayText(text, actualBreaks);
}
class ConstantRun : public Run {
@@ -324,9 +307,7 @@
std::fill(advances, advances + mRange.getLength(), mWidth);
}
- virtual const MinikinPaint* getPaint() const {
- return &mPaint;
- }
+ virtual const MinikinPaint* getPaint() const { return &mPaint; }
virtual float measureHyphenPiece(const U16StringPiece&, const Range& range, StartHyphenEdit,
EndHyphenEdit, float* advances, LayoutOverhang*) const {
@@ -361,22 +342,20 @@
map[enUSLocale] = "ab|cde|fgh|ijk|lmn|o|pqr|st|u|vwxyz";
MockICULineBreakerPoolImpl impl(std::move(map));
- LineBreakResult result = doLineBreak(&impl, text, makeVector<std::unique_ptr<minikin::Run>>(
- std::make_unique<ConstantRun>(Range(0, text.size()), enUSLocaleListId, CHAR_WIDTH)
- ), 5 * CHAR_WIDTH);
+ LineBreakResult result =
+ doLineBreak(&impl, text,
+ makeVector<std::unique_ptr<minikin::Run>>(std::make_unique<ConstantRun>(
+ Range(0, text.size()), enUSLocaleListId, CHAR_WIDTH)),
+ 5 * CHAR_WIDTH);
ASSERT_EQ(7U, result.breakPoints.size());
expectLineBreaks("abcde|fgh|ijk|lmno|pqrst|u|vwxyz", result.breakPoints);
EXPECT_EQ(std::vector<float>({
- 5 * CHAR_WIDTH,
- 3 * CHAR_WIDTH,
- 3 * CHAR_WIDTH,
- 4 * CHAR_WIDTH,
- 5 * CHAR_WIDTH,
- 1 * CHAR_WIDTH,
- 5 * CHAR_WIDTH,
- }), result.widths);
+ 5 * CHAR_WIDTH, 3 * CHAR_WIDTH, 3 * CHAR_WIDTH, 4 * CHAR_WIDTH,
+ 5 * CHAR_WIDTH, 1 * CHAR_WIDTH, 5 * CHAR_WIDTH,
+ }),
+ result.widths);
}
// TODO: Add more test cases, non rectangle, hyphenation, addReplacementSpan etc.
}
@@ -403,19 +382,21 @@
map[frFRLocale] = "ab|cdef|gh";
MockICULineBreakerPoolImpl impl(std::move(map));
- LineBreakResult result = doLineBreak(&impl, text, makeVector<std::unique_ptr<minikin::Run>>(
- std::make_unique<ConstantRun>(Range(0, 2), enUSLocaleListId, CHAR_WIDTH),
- std::make_unique<ConstantRun>(Range(2, text.size()), frFRLocaleListId, CHAR_WIDTH)
- ), 5 * CHAR_WIDTH);
+ LineBreakResult result = doLineBreak(
+ &impl, text,
+ makeVector<std::unique_ptr<minikin::Run>>(
+ std::make_unique<ConstantRun>(Range(0, 2), enUSLocaleListId, CHAR_WIDTH),
+ std::make_unique<ConstantRun>(Range(2, text.size()), frFRLocaleListId,
+ CHAR_WIDTH)),
+ 5 * CHAR_WIDTH);
ASSERT_EQ(3U, result.breakPoints.size());
expectLineBreaks("ab|cdef|gh", result.breakPoints);
EXPECT_EQ(std::vector<float>({
- 2 * CHAR_WIDTH,
- 4 * CHAR_WIDTH,
- 2 * CHAR_WIDTH,
- }), result.widths);
+ 2 * CHAR_WIDTH, 4 * CHAR_WIDTH, 2 * CHAR_WIDTH,
+ }),
+ result.widths);
}
// TODO: Add more test cases, hyphenataion etc.
}
@@ -436,17 +417,20 @@
map[enUSLocale] = "ab|cde|fgh";
MockICULineBreakerPoolImpl impl(std::move(map));
- LineBreakResult result = doLineBreak(&impl, text, makeVector<std::unique_ptr<minikin::Run>>(
- std::make_unique<ConstantRun>(Range(0, 2), enUSLocaleListId, CHAR_WIDTH),
- std::make_unique<ConstantRun>(Range(2, text.size()), enUSLocaleListId, CHAR_WIDTH)
- ), 5 * CHAR_WIDTH);
+ LineBreakResult result = doLineBreak(
+ &impl, text,
+ makeVector<std::unique_ptr<minikin::Run>>(
+ std::make_unique<ConstantRun>(Range(0, 2), enUSLocaleListId, CHAR_WIDTH),
+ std::make_unique<ConstantRun>(Range(2, text.size()), enUSLocaleListId,
+ CHAR_WIDTH)),
+ 5 * CHAR_WIDTH);
ASSERT_EQ(2U, result.breakPoints.size());
expectLineBreaks("abcde|fgh", result.breakPoints);
EXPECT_EQ(std::vector<float>({
- 5 * CHAR_WIDTH,
- 3 * CHAR_WIDTH,
- }), result.widths);
+ 5 * CHAR_WIDTH, 3 * CHAR_WIDTH,
+ }),
+ result.widths);
}
}
@@ -474,19 +458,22 @@
map[frFRLocale] = "aaa |b@c-d |eee";
MockICULineBreakerPoolImpl impl(std::move(map));
- LineBreakResult result = doLineBreak(&impl, text, makeVector<std::unique_ptr<minikin::Run>>(
- std::make_unique<ConstantRun>(Range(0, 7), enUSLocaleListId, CHAR_WIDTH),
- std::make_unique<ConstantRun>(Range(7, text.size()), frFRLocaleListId, CHAR_WIDTH)
- ), 4 * CHAR_WIDTH);
+ LineBreakResult result = doLineBreak(
+ &impl, text,
+ makeVector<std::unique_ptr<minikin::Run>>(
+ std::make_unique<ConstantRun>(Range(0, 7), enUSLocaleListId, CHAR_WIDTH),
+ std::make_unique<ConstantRun>(Range(7, text.size()), frFRLocaleListId,
+ CHAR_WIDTH)),
+ 4 * CHAR_WIDTH);
ASSERT_EQ(4U, result.breakPoints.size());
expectLineBreaks("aaa |b@c|-d |eee", result.breakPoints);
EXPECT_EQ(std::vector<float>({
- 3 * CHAR_WIDTH, // Doesn't count the trailing spaces.
- 3 * CHAR_WIDTH, // Doesn't count the trailing spaces.
- 2 * CHAR_WIDTH,
- 3 * CHAR_WIDTH,
- }), result.widths);
+ 3 * CHAR_WIDTH, // Doesn't count the trailing spaces.
+ 3 * CHAR_WIDTH, // Doesn't count the trailing spaces.
+ 2 * CHAR_WIDTH, 3 * CHAR_WIDTH,
+ }),
+ result.widths);
}
}
@@ -501,8 +488,7 @@
MockICULineBreakerPoolImpl impl(std::move(map));
std::vector<std::unique_ptr<minikin::Run>> runs = makeVector<std::unique_ptr<minikin::Run>>(
- std::make_unique<ConstantRun>(Range(0, text.size()), enUSLocaleListId, CHAR_WIDTH)
- );
+ std::make_unique<ConstantRun>(Range(0, text.size()), enUSLocaleListId, CHAR_WIDTH));
doLineBreak(&impl, text, runs, 5 * CHAR_WIDTH); // Make sure no crash happens.
}
@@ -513,8 +499,9 @@
Slot acquire(const Locale& locale) override {
mRequestedLocaleLog.push_back(locale);
UErrorCode status = U_ZERO_ERROR;
- return {locale.getIdentifier(), std::unique_ptr<icu::BreakIterator>(
- icu::BreakIterator::createLineInstance(icu::Locale::getRoot(), status))};
+ return {locale.getIdentifier(),
+ std::unique_ptr<icu::BreakIterator>(
+ icu::BreakIterator::createLineInstance(icu::Locale::getRoot(), status))};
}
void release(Slot&& slot) override {
@@ -522,17 +509,12 @@
Slot localSlot = std::move(slot);
}
- const std::vector<Locale>& getPassedLocaleLog() const {
- return mRequestedLocaleLog;
- }
+ const std::vector<Locale>& getPassedLocaleLog() const { return mRequestedLocaleLog; }
- void reset() {
- mRequestedLocaleLog.clear();
- }
+ void reset() { mRequestedLocaleLog.clear(); }
private:
std::vector<Locale> mRequestedLocaleLog;
-
};
TEST_F(LineBreakerTest, setLocaleList) {
@@ -546,73 +528,81 @@
const uint32_t enUSId = getLocaleListId("en-US");
{
localeTracer.reset();
- doLineBreak(&localeTracer, text, makeVector<std::unique_ptr<minikin::Run>>(
- std::make_unique<ConstantRun>(Range(0, 1), enUSId, CHAR_WIDTH)
- ), LINE_WIDTH);
+ doLineBreak(&localeTracer, text,
+ makeVector<std::unique_ptr<minikin::Run>>(
+ std::make_unique<ConstantRun>(Range(0, 1), enUSId, CHAR_WIDTH)),
+ LINE_WIDTH);
EXPECT_EQ(std::vector<Locale>({enUS}), localeTracer.getPassedLocaleLog());
// Changing to the same locale must not update locale.
localeTracer.reset();
- doLineBreak(&localeTracer, text, makeVector<std::unique_ptr<minikin::Run>>(
- std::make_unique<ConstantRun>(Range(0, 1), enUSId, CHAR_WIDTH),
- std::make_unique<ConstantRun>(Range(1, 2), enUSId, CHAR_WIDTH)
- ), LINE_WIDTH);
+ doLineBreak(&localeTracer, text,
+ makeVector<std::unique_ptr<minikin::Run>>(
+ std::make_unique<ConstantRun>(Range(0, 1), enUSId, CHAR_WIDTH),
+ std::make_unique<ConstantRun>(Range(1, 2), enUSId, CHAR_WIDTH)),
+ LINE_WIDTH);
EXPECT_EQ(std::vector<Locale>({enUS}), localeTracer.getPassedLocaleLog());
}
{
const uint32_t localeListId = getLocaleListId("fr-FR,en-US");
localeTracer.reset();
- doLineBreak(&localeTracer, text, makeVector<std::unique_ptr<minikin::Run>>(
- std::make_unique<ConstantRun>(Range(0, 1), enUSId, CHAR_WIDTH),
- std::make_unique<ConstantRun>(Range(1, 2), localeListId, CHAR_WIDTH)
- ), LINE_WIDTH);
+ doLineBreak(&localeTracer, text,
+ makeVector<std::unique_ptr<minikin::Run>>(
+ std::make_unique<ConstantRun>(Range(0, 1), enUSId, CHAR_WIDTH),
+ std::make_unique<ConstantRun>(Range(1, 2), localeListId, CHAR_WIDTH)),
+ LINE_WIDTH);
EXPECT_EQ(std::vector<Locale>({enUS, frFR}), localeTracer.getPassedLocaleLog());
// Changing to the same locale must not update locale.
localeTracer.reset();
- doLineBreak(&localeTracer, text, makeVector<std::unique_ptr<minikin::Run>>(
- std::make_unique<ConstantRun>(Range(0, 1), enUSId, CHAR_WIDTH),
- std::make_unique<ConstantRun>(Range(1, 2), localeListId, CHAR_WIDTH),
- std::make_unique<ConstantRun>(Range(2, 3), localeListId, CHAR_WIDTH)
- ), LINE_WIDTH);
+ doLineBreak(&localeTracer, text,
+ makeVector<std::unique_ptr<minikin::Run>>(
+ std::make_unique<ConstantRun>(Range(0, 1), enUSId, CHAR_WIDTH),
+ std::make_unique<ConstantRun>(Range(1, 2), localeListId, CHAR_WIDTH),
+ std::make_unique<ConstantRun>(Range(2, 3), localeListId, CHAR_WIDTH)),
+ LINE_WIDTH);
EXPECT_EQ(std::vector<Locale>({enUS, frFR}), localeTracer.getPassedLocaleLog());
}
{
const uint32_t localeListId = getLocaleListId("fr-FR");
localeTracer.reset();
- doLineBreak(&localeTracer, text, makeVector<std::unique_ptr<minikin::Run>>(
- std::make_unique<ConstantRun>(Range(0, 1), enUSId, CHAR_WIDTH),
- std::make_unique<ConstantRun>(Range(1, 2), localeListId, CHAR_WIDTH)
- ), LINE_WIDTH);
+ doLineBreak(&localeTracer, text,
+ makeVector<std::unique_ptr<minikin::Run>>(
+ std::make_unique<ConstantRun>(Range(0, 1), enUSId, CHAR_WIDTH),
+ std::make_unique<ConstantRun>(Range(1, 2), localeListId, CHAR_WIDTH)),
+ LINE_WIDTH);
EXPECT_EQ(std::vector<Locale>({enUS, frFR}), localeTracer.getPassedLocaleLog());
// Changing to the same locale must not update locale.
localeTracer.reset();
- doLineBreak(&localeTracer, text, makeVector<std::unique_ptr<minikin::Run>>(
- std::make_unique<ConstantRun>(Range(0, 1), enUSId, CHAR_WIDTH),
- std::make_unique<ConstantRun>(Range(1, 2), localeListId, CHAR_WIDTH),
- std::make_unique<ConstantRun>(Range(2, 3), localeListId, CHAR_WIDTH)
- ), LINE_WIDTH);
+ doLineBreak(&localeTracer, text,
+ makeVector<std::unique_ptr<minikin::Run>>(
+ std::make_unique<ConstantRun>(Range(0, 1), enUSId, CHAR_WIDTH),
+ std::make_unique<ConstantRun>(Range(1, 2), localeListId, CHAR_WIDTH),
+ std::make_unique<ConstantRun>(Range(2, 3), localeListId, CHAR_WIDTH)),
+ LINE_WIDTH);
EXPECT_EQ(std::vector<Locale>({enUS, frFR}), localeTracer.getPassedLocaleLog());
}
{
const uint32_t localeListId = getLocaleListId("");
localeTracer.reset();
- doLineBreak(&localeTracer, text, makeVector<std::unique_ptr<minikin::Run>>(
- std::make_unique<ConstantRun>(Range(0, 1), enUSId, CHAR_WIDTH),
- std::make_unique<ConstantRun>(Range(1, 2), localeListId, CHAR_WIDTH)
- ), LINE_WIDTH);
+ doLineBreak(&localeTracer, text,
+ makeVector<std::unique_ptr<minikin::Run>>(
+ std::make_unique<ConstantRun>(Range(0, 1), enUSId, CHAR_WIDTH),
+ std::make_unique<ConstantRun>(Range(1, 2), localeListId, CHAR_WIDTH)),
+ LINE_WIDTH);
ASSERT_EQ(2u, localeTracer.getPassedLocaleLog().size());
EXPECT_EQ(enUS, localeTracer.getPassedLocaleLog()[0]);
EXPECT_FALSE(localeTracer.getPassedLocaleLog()[1].isSupported());
// Changing to the same locale must not update locale.
localeTracer.reset();
- doLineBreak(&localeTracer, text, makeVector<std::unique_ptr<minikin::Run>>(
- std::make_unique<ConstantRun>(Range(0, 1), enUSId, CHAR_WIDTH),
- std::make_unique<ConstantRun>(Range(1, 2), localeListId, CHAR_WIDTH),
- std::make_unique<ConstantRun>(Range(2, 3), localeListId, CHAR_WIDTH)
- ), LINE_WIDTH);
+ doLineBreak(&localeTracer, text,
+ makeVector<std::unique_ptr<minikin::Run>>(
+ std::make_unique<ConstantRun>(Range(0, 1), enUSId, CHAR_WIDTH),
+ std::make_unique<ConstantRun>(Range(1, 2), localeListId, CHAR_WIDTH),
+ std::make_unique<ConstantRun>(Range(2, 3), localeListId, CHAR_WIDTH)),
+ LINE_WIDTH);
ASSERT_EQ(2u, localeTracer.getPassedLocaleLog().size());
EXPECT_EQ(enUS, localeTracer.getPassedLocaleLog()[0]);
EXPECT_FALSE(localeTracer.getPassedLocaleLog()[1].isSupported());
@@ -620,21 +610,23 @@
{
const uint32_t localeListId = getLocaleListId("THISISABOGUSLANGUAGE");
localeTracer.reset();
- doLineBreak(&localeTracer, text, makeVector<std::unique_ptr<minikin::Run>>(
- std::make_unique<ConstantRun>(Range(0, 1), enUSId, CHAR_WIDTH),
- std::make_unique<ConstantRun>(Range(1, 2), localeListId, CHAR_WIDTH)
- ), LINE_WIDTH);
+ doLineBreak(&localeTracer, text,
+ makeVector<std::unique_ptr<minikin::Run>>(
+ std::make_unique<ConstantRun>(Range(0, 1), enUSId, CHAR_WIDTH),
+ std::make_unique<ConstantRun>(Range(1, 2), localeListId, CHAR_WIDTH)),
+ LINE_WIDTH);
ASSERT_EQ(2u, localeTracer.getPassedLocaleLog().size());
EXPECT_EQ(enUS, localeTracer.getPassedLocaleLog()[0]);
EXPECT_FALSE(localeTracer.getPassedLocaleLog()[1].isSupported());
// Changing to the same locale must not update locale.
localeTracer.reset();
- doLineBreak(&localeTracer, text, makeVector<std::unique_ptr<minikin::Run>>(
- std::make_unique<ConstantRun>(Range(0, 1), enUSId, CHAR_WIDTH),
- std::make_unique<ConstantRun>(Range(1, 2), localeListId, CHAR_WIDTH),
- std::make_unique<ConstantRun>(Range(2, 3), localeListId, CHAR_WIDTH)
- ), LINE_WIDTH);
+ doLineBreak(&localeTracer, text,
+ makeVector<std::unique_ptr<minikin::Run>>(
+ std::make_unique<ConstantRun>(Range(0, 1), enUSId, CHAR_WIDTH),
+ std::make_unique<ConstantRun>(Range(1, 2), localeListId, CHAR_WIDTH),
+ std::make_unique<ConstantRun>(Range(2, 3), localeListId, CHAR_WIDTH)),
+ LINE_WIDTH);
ASSERT_EQ(2u, localeTracer.getPassedLocaleLog().size());
EXPECT_EQ(enUS, localeTracer.getPassedLocaleLog()[0]);
EXPECT_FALSE(localeTracer.getPassedLocaleLog()[1].isSupported());
@@ -642,57 +634,63 @@
{
const uint32_t localeListId = getLocaleListId("THISISABOGUSLANGUAGE,fr-FR");
localeTracer.reset();
- doLineBreak(&localeTracer, text, makeVector<std::unique_ptr<minikin::Run>>(
- std::make_unique<ConstantRun>(Range(0, 1), enUSId, CHAR_WIDTH),
- std::make_unique<ConstantRun>(Range(1, 2), localeListId, CHAR_WIDTH)
- ), LINE_WIDTH);
+ doLineBreak(&localeTracer, text,
+ makeVector<std::unique_ptr<minikin::Run>>(
+ std::make_unique<ConstantRun>(Range(0, 1), enUSId, CHAR_WIDTH),
+ std::make_unique<ConstantRun>(Range(1, 2), localeListId, CHAR_WIDTH)),
+ LINE_WIDTH);
EXPECT_EQ(std::vector<Locale>({enUS, frFR}), localeTracer.getPassedLocaleLog());
// Changing to the same locale must not update locale.
localeTracer.reset();
- doLineBreak(&localeTracer, text, makeVector<std::unique_ptr<minikin::Run>>(
- std::make_unique<ConstantRun>(Range(0, 1), enUSId, CHAR_WIDTH),
- std::make_unique<ConstantRun>(Range(1, 2), localeListId, CHAR_WIDTH),
- std::make_unique<ConstantRun>(Range(2, 3), localeListId, CHAR_WIDTH)
- ), LINE_WIDTH);
+ doLineBreak(&localeTracer, text,
+ makeVector<std::unique_ptr<minikin::Run>>(
+ std::make_unique<ConstantRun>(Range(0, 1), enUSId, CHAR_WIDTH),
+ std::make_unique<ConstantRun>(Range(1, 2), localeListId, CHAR_WIDTH),
+ std::make_unique<ConstantRun>(Range(2, 3), localeListId, CHAR_WIDTH)),
+ LINE_WIDTH);
EXPECT_EQ(std::vector<Locale>({enUS, frFR}), localeTracer.getPassedLocaleLog());
}
{
const uint32_t localeListId = getLocaleListId("THISISABOGUSLANGUAGE,en-US");
localeTracer.reset();
- doLineBreak(&localeTracer, text, makeVector<std::unique_ptr<minikin::Run>>(
- std::make_unique<ConstantRun>(Range(0, 1), enUSId, CHAR_WIDTH),
- std::make_unique<ConstantRun>(Range(1, 2), localeListId, CHAR_WIDTH)
- ), LINE_WIDTH);
+ doLineBreak(&localeTracer, text,
+ makeVector<std::unique_ptr<minikin::Run>>(
+ std::make_unique<ConstantRun>(Range(0, 1), enUSId, CHAR_WIDTH),
+ std::make_unique<ConstantRun>(Range(1, 2), localeListId, CHAR_WIDTH)),
+ LINE_WIDTH);
EXPECT_EQ(std::vector<Locale>({enUS}), localeTracer.getPassedLocaleLog());
// Changing to the same locale must not update locale.
localeTracer.reset();
- doLineBreak(&localeTracer, text, makeVector<std::unique_ptr<minikin::Run>>(
- std::make_unique<ConstantRun>(Range(0, 1), enUSId, CHAR_WIDTH),
- std::make_unique<ConstantRun>(Range(1, 2), localeListId, CHAR_WIDTH),
- std::make_unique<ConstantRun>(Range(2, 3), localeListId, CHAR_WIDTH)
- ), LINE_WIDTH);
+ doLineBreak(&localeTracer, text,
+ makeVector<std::unique_ptr<minikin::Run>>(
+ std::make_unique<ConstantRun>(Range(0, 1), enUSId, CHAR_WIDTH),
+ std::make_unique<ConstantRun>(Range(1, 2), localeListId, CHAR_WIDTH),
+ std::make_unique<ConstantRun>(Range(2, 3), localeListId, CHAR_WIDTH)),
+ LINE_WIDTH);
EXPECT_EQ(std::vector<Locale>({enUS}), localeTracer.getPassedLocaleLog());
}
{
const uint32_t localeListId = getLocaleListId("THISISABOGUSLANGUAGE,ANOTHERBOGUSLANGUAGE");
localeTracer.reset();
- doLineBreak(&localeTracer, text, makeVector<std::unique_ptr<minikin::Run>>(
- std::make_unique<ConstantRun>(Range(0, 1), enUSId, CHAR_WIDTH),
- std::make_unique<ConstantRun>(Range(1, 2), localeListId, CHAR_WIDTH)
- ), LINE_WIDTH);
+ doLineBreak(&localeTracer, text,
+ makeVector<std::unique_ptr<minikin::Run>>(
+ std::make_unique<ConstantRun>(Range(0, 1), enUSId, CHAR_WIDTH),
+ std::make_unique<ConstantRun>(Range(1, 2), localeListId, CHAR_WIDTH)),
+ LINE_WIDTH);
ASSERT_EQ(2u, localeTracer.getPassedLocaleLog().size());
EXPECT_EQ(enUS, localeTracer.getPassedLocaleLog()[0]);
EXPECT_FALSE(localeTracer.getPassedLocaleLog()[1].isSupported());
// Changing to the same locale must not update locale.
localeTracer.reset();
- doLineBreak(&localeTracer, text, makeVector<std::unique_ptr<minikin::Run>>(
- std::make_unique<ConstantRun>(Range(0, 1), enUSId, CHAR_WIDTH),
- std::make_unique<ConstantRun>(Range(1, 2), localeListId, CHAR_WIDTH),
- std::make_unique<ConstantRun>(Range(2, 3), localeListId, CHAR_WIDTH)
- ), LINE_WIDTH);
+ doLineBreak(&localeTracer, text,
+ makeVector<std::unique_ptr<minikin::Run>>(
+ std::make_unique<ConstantRun>(Range(0, 1), enUSId, CHAR_WIDTH),
+ std::make_unique<ConstantRun>(Range(1, 2), localeListId, CHAR_WIDTH),
+ std::make_unique<ConstantRun>(Range(2, 3), localeListId, CHAR_WIDTH)),
+ LINE_WIDTH);
ASSERT_EQ(2u, localeTracer.getPassedLocaleLog().size());
EXPECT_EQ(enUS, localeTracer.getPassedLocaleLog()[0]);
EXPECT_FALSE(localeTracer.getPassedLocaleLog()[1].isSupported());
diff --git a/tests/unittest/SparseBitSetTest.cpp b/tests/unittest/SparseBitSetTest.cpp
index 9e0e4df..03a14d9 100644
--- a/tests/unittest/SparseBitSetTest.cpp
+++ b/tests/unittest/SparseBitSetTest.cpp
@@ -28,7 +28,7 @@
std::mt19937 mt; // Fix seeds to be able to reproduce the result.
std::uniform_int_distribution<uint16_t> distribution(1, 512);
- std::vector<uint32_t> range { distribution(mt) };
+ std::vector<uint32_t> range{distribution(mt)};
for (size_t i = 1; i < kTestRangeNum * 2; ++i) {
range.push_back((range.back() - 1) + distribution(mt));
}
diff --git a/tests/unittest/StringPieceTest.cpp b/tests/unittest/StringPieceTest.cpp
index c7e8c72..f70fd3a 100644
--- a/tests/unittest/StringPieceTest.cpp
+++ b/tests/unittest/StringPieceTest.cpp
@@ -176,5 +176,4 @@
}
}
-} // namespace minikin
-
+} // namespace minikin
diff --git a/tests/unittest/UnicodeUtilsTest.cpp b/tests/unittest/UnicodeUtilsTest.cpp
index 8a3dcb9..9bdd07b 100644
--- a/tests/unittest/UnicodeUtilsTest.cpp
+++ b/tests/unittest/UnicodeUtilsTest.cpp
@@ -34,4 +34,4 @@
EXPECT_EQ(buf[3], 'a');
}
-} // namespace minikin
+} // namespace minikin
diff --git a/tests/unittest/WordBreakerTests.cpp b/tests/unittest/WordBreakerTests.cpp
index 725fbbf..8548e56 100644
--- a/tests/unittest/WordBreakerTests.cpp
+++ b/tests/unittest/WordBreakerTests.cpp
@@ -37,24 +37,24 @@
typedef ICUTestBase WordBreakerTest;
TEST_F(WordBreakerTest, basic) {
- uint16_t buf[] = {'h', 'e', 'l', 'l' ,'o', ' ', 'w', 'o', 'r', 'l', 'd'};
+ uint16_t buf[] = {'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd'};
WordBreaker breaker;
breaker.setText(buf, NELEM(buf));
EXPECT_EQ(0, breaker.current());
EXPECT_EQ(6, breaker.followingWithLocale(Locale("en-US"), 0)); // after "hello "
- EXPECT_EQ(0, breaker.wordStart()); // "hello"
+ EXPECT_EQ(0, breaker.wordStart()); // "hello"
EXPECT_EQ(5, breaker.wordEnd());
EXPECT_EQ(0, breaker.breakBadness());
EXPECT_EQ(6, breaker.current());
EXPECT_EQ((ssize_t)NELEM(buf), breaker.next()); // end
- EXPECT_EQ(6, breaker.wordStart()); // "world"
+ EXPECT_EQ(6, breaker.wordStart()); // "world"
EXPECT_EQ(11, breaker.wordEnd());
EXPECT_EQ(0, breaker.breakBadness());
EXPECT_EQ(11, breaker.current());
}
TEST_F(WordBreakerTest, softHyphen) {
- uint16_t buf[] = {'h', 'e', 'l', 0x00AD, 'l' ,'o', ' ', 'w', 'o', 'r', 'l', 'd'};
+ uint16_t buf[] = {'h', 'e', 'l', 0x00AD, 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd'};
WordBreaker breaker;
breaker.setText(buf, NELEM(buf));
EXPECT_EQ(0, breaker.current());
@@ -64,7 +64,7 @@
EXPECT_EQ(6, breaker.wordEnd());
EXPECT_EQ(0, breaker.breakBadness());
EXPECT_EQ((ssize_t)NELEM(buf), breaker.next()); // end
- EXPECT_EQ(7, breaker.wordStart()); // "world"
+ EXPECT_EQ(7, breaker.wordStart()); // "world"
EXPECT_EQ(12, breaker.wordEnd());
EXPECT_EQ(0, breaker.breakBadness());
}
@@ -82,17 +82,17 @@
}
TEST_F(WordBreakerTest, postfixAndPrefix) {
- uint16_t buf[] = {'U', 'S', 0x00A2, ' ', 'J', 'P', 0x00A5}; // US¢ JP¥
+ uint16_t buf[] = {'U', 'S', 0x00A2, ' ', 'J', 'P', 0x00A5}; // US¢ JP¥
WordBreaker breaker;
breaker.setText(buf, NELEM(buf));
EXPECT_EQ(0, breaker.current());
EXPECT_EQ(4, breaker.followingWithLocale(Locale("en-US"), 0)); // after CENT SIGN
- EXPECT_EQ(0, breaker.wordStart()); // "US¢"
+ EXPECT_EQ(0, breaker.wordStart()); // "US¢"
EXPECT_EQ(3, breaker.wordEnd());
EXPECT_EQ((ssize_t)NELEM(buf), breaker.next()); // end of string
- EXPECT_EQ(4, breaker.wordStart()); // "JP¥"
+ EXPECT_EQ(4, breaker.wordStart()); // "JP¥"
EXPECT_EQ((ssize_t)NELEM(buf), breaker.wordEnd());
}
@@ -111,14 +111,14 @@
TEST_F(WordBreakerTest, zwjEmojiSequences) {
uint16_t buf[] = {
- // man + zwj + heart + zwj + man
- UTF16(0x1F468), 0x200D, 0x2764, 0x200D, UTF16(0x1F468),
- // woman + zwj + heart + zwj + kiss mark + zwj + woman
- UTF16(0x1F469), 0x200D, 0x2764, 0x200D, UTF16(0x1F48B), 0x200D, UTF16(0x1F469),
- // eye + zwj + left speech bubble
- UTF16(0x1F441), 0x200D, UTF16(0x1F5E8),
- // CAT FACE + zwj + BUST IN SILHOUETTE
- UTF16(0x1F431), 0x200D, UTF16(0x1F464),
+ // man + zwj + heart + zwj + man
+ UTF16(0x1F468), 0x200D, 0x2764, 0x200D, UTF16(0x1F468),
+ // woman + zwj + heart + zwj + kiss mark + zwj + woman
+ UTF16(0x1F469), 0x200D, 0x2764, 0x200D, UTF16(0x1F48B), 0x200D, UTF16(0x1F469),
+ // eye + zwj + left speech bubble
+ UTF16(0x1F441), 0x200D, UTF16(0x1F5E8),
+ // CAT FACE + zwj + BUST IN SILHOUETTE
+ UTF16(0x1F431), 0x200D, UTF16(0x1F464),
};
WordBreaker breaker;
breaker.setText(buf, NELEM(buf));
@@ -140,8 +140,9 @@
TEST_F(WordBreakerTest, emojiWithModifier) {
uint16_t buf[] = {
- UTF16(0x1F466), UTF16(0x1F3FB), // boy + type 1-2 fitzpatrick modifier
- 0x270C, 0xFE0F, UTF16(0x1F3FF) // victory hand + emoji style + type 6 fitzpatrick modifier
+ UTF16(0x1F466), UTF16(0x1F3FB), // boy + type 1-2 fitzpatrick modifier
+ 0x270C, 0xFE0F,
+ UTF16(0x1F3FF) // victory hand + emoji style + type 6 fitzpatrick modifier
};
WordBreaker breaker;
breaker.setText(buf, NELEM(buf));
@@ -158,14 +159,14 @@
TEST_F(WordBreakerTest, unicode10Emoji) {
// Should break between emojis.
uint16_t buf[] = {
- // SLED + SLED
- UTF16(0x1F6F7), UTF16(0x1F6F7),
- // SLED + VS15 + SLED
- UTF16(0x1F6F7), 0xFE0E, UTF16(0x1F6F7),
- // WHITE SMILING FACE + SLED
- 0x263A, UTF16(0x1F6F7),
- // WHITE SMILING FACE + VS16 + SLED
- 0x263A, 0xFE0F, UTF16(0x1F6F7),
+ // SLED + SLED
+ UTF16(0x1F6F7), UTF16(0x1F6F7),
+ // SLED + VS15 + SLED
+ UTF16(0x1F6F7), 0xFE0E, UTF16(0x1F6F7),
+ // WHITE SMILING FACE + SLED
+ 0x263A, UTF16(0x1F6F7),
+ // WHITE SMILING FACE + VS16 + SLED
+ 0x263A, 0xFE0F, UTF16(0x1F6F7),
};
WordBreaker breaker;
breaker.setText(buf, NELEM(buf));
@@ -252,42 +253,42 @@
}
TEST_F(WordBreakerTest, punct) {
- uint16_t buf[] = {0x00A1, 0x00A1, 'h', 'e', 'l', 'l' ,'o', ',', ' ', 'w', 'o', 'r', 'l', 'd',
- '!', '!'};
+ uint16_t buf[] = {0x00A1, 0x00A1, 'h', 'e', 'l', 'l', 'o', ',',
+ ' ', 'w', 'o', 'r', 'l', 'd', '!', '!'};
WordBreaker breaker;
breaker.setText(buf, NELEM(buf));
EXPECT_EQ(0, breaker.current());
- EXPECT_EQ(9, breaker.followingWithLocale(Locale("en-US"), 0)); // after "¡¡hello, "
- EXPECT_EQ(2, breaker.wordStart()); // "hello"
+ EXPECT_EQ(9, breaker.followingWithLocale(Locale("en-US"), 0)); // after "¡¡hello, "
+ EXPECT_EQ(2, breaker.wordStart()); // "hello"
EXPECT_EQ(7, breaker.wordEnd());
EXPECT_EQ(0, breaker.breakBadness());
EXPECT_EQ((ssize_t)NELEM(buf), breaker.next()); // end
- EXPECT_EQ(9, breaker.wordStart()); // "world"
+ EXPECT_EQ(9, breaker.wordStart()); // "world"
EXPECT_EQ(14, breaker.wordEnd());
EXPECT_EQ(0, breaker.breakBadness());
}
TEST_F(WordBreakerTest, email) {
- uint16_t buf[] = {'f', 'o', 'o', '@', 'e', 'x', 'a', 'm', 'p', 'l', 'e', '.', 'c', 'o', 'm',
- ' ', 'x'};
+ uint16_t buf[] = {'f', 'o', 'o', '@', 'e', 'x', 'a', 'm', 'p',
+ 'l', 'e', '.', 'c', 'o', 'm', ' ', 'x'};
WordBreaker breaker;
breaker.setText(buf, NELEM(buf));
EXPECT_EQ(0, breaker.current());
- EXPECT_EQ(11, breaker.followingWithLocale(Locale("en-US"), 0)); // after "foo@example"
+ EXPECT_EQ(11, breaker.followingWithLocale(Locale("en-US"), 0)); // after "foo@example"
EXPECT_TRUE(breaker.wordStart() >= breaker.wordEnd());
EXPECT_EQ(1, breaker.breakBadness());
EXPECT_EQ(16, breaker.next()); // after ".com "
EXPECT_TRUE(breaker.wordStart() >= breaker.wordEnd());
EXPECT_EQ(0, breaker.breakBadness());
EXPECT_EQ((ssize_t)NELEM(buf), breaker.next()); // end
- EXPECT_EQ(16, breaker.wordStart()); // "x"
+ EXPECT_EQ(16, breaker.wordStart()); // "x"
EXPECT_EQ(17, breaker.wordEnd());
EXPECT_EQ(0, breaker.breakBadness());
}
TEST_F(WordBreakerTest, mailto) {
- uint16_t buf[] = {'m', 'a', 'i', 'l', 't', 'o', ':', 'f', 'o', 'o', '@',
- 'e', 'x', 'a', 'm', 'p', 'l', 'e', '.', 'c', 'o', 'm', ' ', 'x'};
+ uint16_t buf[] = {'m', 'a', 'i', 'l', 't', 'o', ':', 'f', 'o', 'o', '@', 'e',
+ 'x', 'a', 'm', 'p', 'l', 'e', '.', 'c', 'o', 'm', ' ', 'x'};
WordBreaker breaker;
breaker.setText(buf, NELEM(buf));
EXPECT_EQ(0, breaker.current());
@@ -301,7 +302,7 @@
EXPECT_TRUE(breaker.wordStart() >= breaker.wordEnd());
EXPECT_EQ(0, breaker.breakBadness());
EXPECT_EQ((ssize_t)NELEM(buf), breaker.next()); // end
- EXPECT_EQ(23, breaker.wordStart()); // "x"
+ EXPECT_EQ(23, breaker.wordStart()); // "x"
EXPECT_EQ(24, breaker.wordEnd());
EXPECT_EQ(0, breaker.breakBadness());
}
@@ -309,8 +310,8 @@
// The current logic always places a line break after a detected email address or URL
// and an immediately following non-ASCII character.
TEST_F(WordBreakerTest, emailNonAscii) {
- uint16_t buf[] = {'f', 'o', 'o', '@', 'e', 'x', 'a', 'm', 'p', 'l', 'e', '.', 'c', 'o', 'm',
- 0x4E00};
+ uint16_t buf[] = {'f', 'o', 'o', '@', 'e', 'x', 'a', 'm',
+ 'p', 'l', 'e', '.', 'c', 'o', 'm', 0x4E00};
WordBreaker breaker;
breaker.setText(buf, NELEM(buf));
EXPECT_EQ(0, breaker.current());
@@ -321,14 +322,14 @@
EXPECT_TRUE(breaker.wordStart() >= breaker.wordEnd());
EXPECT_EQ(0, breaker.breakBadness());
EXPECT_EQ((ssize_t)NELEM(buf), breaker.next()); // end
- EXPECT_EQ(15, breaker.wordStart()); // "一"
+ EXPECT_EQ(15, breaker.wordStart()); // "一"
EXPECT_EQ(16, breaker.wordEnd());
EXPECT_EQ(0, breaker.breakBadness());
}
TEST_F(WordBreakerTest, emailCombining) {
- uint16_t buf[] = {'f', 'o', 'o', '@', 'e', 'x', 'a', 'm', 'p', 'l', 'e', '.', 'c', 'o', 'm',
- 0x0303, ' ', 'x'};
+ uint16_t buf[] = {'f', 'o', 'o', '@', 'e', 'x', 'a', 'm', 'p',
+ 'l', 'e', '.', 'c', 'o', 'm', 0x0303, ' ', 'x'};
WordBreaker breaker;
breaker.setText(buf, NELEM(buf));
EXPECT_EQ(0, breaker.current());
@@ -339,7 +340,7 @@
EXPECT_TRUE(breaker.wordStart() >= breaker.wordEnd());
EXPECT_EQ(0, breaker.breakBadness());
EXPECT_EQ((ssize_t)NELEM(buf), breaker.next()); // end
- EXPECT_EQ(17, breaker.wordStart()); // "x"
+ EXPECT_EQ(17, breaker.wordStart()); // "x"
EXPECT_EQ(18, breaker.wordEnd());
EXPECT_EQ(0, breaker.breakBadness());
}
@@ -350,21 +351,21 @@
breaker.setText(buf, NELEM(buf));
EXPECT_EQ(0, breaker.current());
EXPECT_EQ(2, breaker.followingWithLocale(Locale("en-US"), 0)); // after "a "
- EXPECT_EQ(0, breaker.wordStart()); // "a"
+ EXPECT_EQ(0, breaker.wordStart()); // "a"
EXPECT_EQ(1, breaker.wordEnd());
EXPECT_EQ(0, breaker.breakBadness());
EXPECT_EQ(4, breaker.next()); // after "@ "
EXPECT_TRUE(breaker.wordStart() >= breaker.wordEnd());
EXPECT_EQ(0, breaker.breakBadness());
EXPECT_EQ((ssize_t)NELEM(buf), breaker.next()); // end
- EXPECT_EQ(4, breaker.wordStart()); // "b"
+ EXPECT_EQ(4, breaker.wordStart()); // "b"
EXPECT_EQ(5, breaker.wordEnd());
EXPECT_EQ(0, breaker.breakBadness());
}
TEST_F(WordBreakerTest, url) {
- uint16_t buf[] = {'h', 't', 't', 'p', ':', '/', '/', 'e', 'x', 'a', 'm', 'p', 'l', 'e',
- '.', 'c', 'o', 'm', ' ', 'x'};
+ uint16_t buf[] = {'h', 't', 't', 'p', ':', '/', '/', 'e', 'x', 'a',
+ 'm', 'p', 'l', 'e', '.', 'c', 'o', 'm', ' ', 'x'};
WordBreaker breaker;
breaker.setText(buf, NELEM(buf));
EXPECT_EQ(0, breaker.current());
@@ -381,15 +382,16 @@
EXPECT_TRUE(breaker.wordStart() >= breaker.wordEnd());
EXPECT_EQ(0, breaker.breakBadness());
EXPECT_EQ((ssize_t)NELEM(buf), breaker.next()); // end
- EXPECT_EQ(19, breaker.wordStart()); // "x"
+ EXPECT_EQ(19, breaker.wordStart()); // "x"
EXPECT_EQ(20, breaker.wordEnd());
EXPECT_EQ(0, breaker.breakBadness());
}
// Breaks according to section 14.12 of Chicago Manual of Style, *URLs or DOIs and line breaks*
TEST_F(WordBreakerTest, urlBreakChars) {
- uint16_t buf[] = {'h', 't', 't', 'p', ':', '/', '/', 'a', '.', 'b', '/', '~', 'c', ',', 'd',
- '-', 'e', '?', 'f', '=', 'g', '&', 'h', '#', 'i', '%', 'j', '_', 'k', '/', 'l'};
+ uint16_t buf[] = {'h', 't', 't', 'p', ':', '/', '/', 'a', '.', 'b', '/',
+ '~', 'c', ',', 'd', '-', 'e', '?', 'f', '=', 'g', '&',
+ 'h', '#', 'i', '%', 'j', '_', 'k', '/', 'l'};
WordBreaker breaker;
breaker.setText(buf, NELEM(buf));
EXPECT_EQ(0, breaker.current());
@@ -505,7 +507,7 @@
EXPECT_TRUE(breaker.wordStart() >= breaker.wordEnd());
// Restart from middle point of the URL. It should return the same previous break point.
- EXPECT_EQ(13, breaker.followingWithLocale(Locale("en-US"), 12)); // after "//"
+ EXPECT_EQ(13, breaker.followingWithLocale(Locale("en-US"), 12)); // after "//"
EXPECT_TRUE(breaker.wordStart() >= breaker.wordEnd());
EXPECT_EQ(16, breaker.next()); // after "abc"
EXPECT_TRUE(breaker.wordStart() >= breaker.wordEnd());
@@ -522,9 +524,9 @@
// b/68669534
TEST_F(WordBreakerTest, spaceAfterSpace) {
const std::vector<uint16_t> SPACES = {
- '\t', // TAB
- 0x1680, // OGHAM SPACE MARK
- 0x3000, // IDEOGRAPHIC SPACE
+ '\t', // TAB
+ 0x1680, // OGHAM SPACE MARK
+ 0x3000, // IDEOGRAPHIC SPACE
};
constexpr uint16_t CHAR_SPACE = 0x0020;
diff --git a/tests/util/FileUtils.h b/tests/util/FileUtils.h
index 322f7f3..3aabc0d 100644
--- a/tests/util/FileUtils.h
+++ b/tests/util/FileUtils.h
@@ -18,4 +18,3 @@
#include <vector>
std::vector<uint8_t> readWholeFile(const std::string& filePath);
-
diff --git a/tests/util/FontTestUtils.cpp b/tests/util/FontTestUtils.cpp
index a68591d..8e7876b 100644
--- a/tests/util/FontTestUtils.cpp
+++ b/tests/util/FontTestUtils.cpp
@@ -23,6 +23,7 @@
#include "minikin/FontCollection.h"
#include "minikin/FontFamily.h"
#include "minikin/LocaleList.h"
+
#include "MinikinFontForTest.h"
namespace minikin {
@@ -54,8 +55,9 @@
}
uint16_t weight = atoi((const char*)(xmlGetProp(fontNode, (const xmlChar*)"weight")));
- FontStyle::Slant italic = static_cast<FontStyle::Slant>(xmlStrcmp(
- xmlGetProp(fontNode, (const xmlChar*)"style"), (const xmlChar*)"italic") == 0);
+ FontStyle::Slant italic = static_cast<FontStyle::Slant>(
+ xmlStrcmp(xmlGetProp(fontNode, (const xmlChar*)"style"),
+ (const xmlChar*)"italic") == 0);
xmlChar* index = xmlGetProp(familyNode, (const xmlChar*)"index");
xmlChar* fontFileName = xmlNodeListGetString(doc, fontNode->xmlChildrenNode, 1);
diff --git a/tests/util/MinikinFontForTest.cpp b/tests/util/MinikinFontForTest.cpp
index b356b99..7ef92ab 100644
--- a/tests/util/MinikinFontForTest.cpp
+++ b/tests/util/MinikinFontForTest.cpp
@@ -34,11 +34,11 @@
static int uniqueId = 0; // TODO: make thread safe if necessary.
MinikinFontForTest::MinikinFontForTest(const std::string& font_path, int index,
- const std::vector<FontVariation>& variations) :
- MinikinFont(uniqueId++),
- mFontPath(font_path),
- mVariations(variations),
- mFontIndex(index) {
+ const std::vector<FontVariation>& variations)
+ : MinikinFont(uniqueId++),
+ mFontPath(font_path),
+ mVariations(variations),
+ mFontIndex(index) {
int fd = open(font_path.c_str(), O_RDONLY);
LOG_ALWAYS_FATAL_IF(fd == -1);
struct stat st = {};
@@ -60,8 +60,7 @@
return 10.0f;
}
-void MinikinFontForTest::GetBounds(MinikinRect* bounds,
- uint32_t /* glyph_id */,
+void MinikinFontForTest::GetBounds(MinikinRect* bounds, uint32_t /* glyph_id */,
const MinikinPaint& /* paint */,
const FontFakery& /* fakery */) const {
// TODO: Make mock values configurable if necessary.
@@ -71,8 +70,7 @@
bounds->mBottom = 10.0f;
}
-void MinikinFontForTest::GetFontExtent(MinikinExtent* extent,
- const MinikinPaint& /* paint */,
+void MinikinFontForTest::GetFontExtent(MinikinExtent* extent, const MinikinPaint& /* paint */,
const FontFakery& /* fakery */) const {
extent->ascent = -10.0f;
extent->descent = 20.0f;
diff --git a/tests/util/MinikinFontForTest.h b/tests/util/MinikinFontForTest.h
index 322df22..a841d72 100644
--- a/tests/util/MinikinFontForTest.h
+++ b/tests/util/MinikinFontForTest.h
@@ -26,22 +26,18 @@
class MinikinFontForTest : public MinikinFont {
public:
MinikinFontForTest(const std::string& font_path, int index,
- const std::vector<FontVariation>& variations);
+ const std::vector<FontVariation>& variations);
MinikinFontForTest(const std::string& font_path, int index)
: MinikinFontForTest(font_path, index, std::vector<FontVariation>()) {}
MinikinFontForTest(const std::string& font_path) : MinikinFontForTest(font_path, 0) {}
virtual ~MinikinFontForTest();
// MinikinFont overrides.
- float GetHorizontalAdvance(uint32_t glyph_id,
- const MinikinPaint& paint,
+ float GetHorizontalAdvance(uint32_t glyph_id, const MinikinPaint& paint,
const FontFakery& fakery) const override;
- void GetBounds(MinikinRect* bounds,
- uint32_t glyph_id,
- const MinikinPaint& paint,
+ void GetBounds(MinikinRect* bounds, uint32_t glyph_id, const MinikinPaint& paint,
const FontFakery& fakery) const override;
- void GetFontExtent(MinikinExtent* extent,
- const MinikinPaint& paint,
+ void GetFontExtent(MinikinExtent* extent, const MinikinPaint& paint,
const FontFakery& fakery) const override;
const std::string& fontPath() const { return mFontPath; }
@@ -52,6 +48,7 @@
const std::vector<minikin::FontVariation>& GetAxes() const { return mVariations; }
std::shared_ptr<MinikinFont> createFontWithVariation(
const std::vector<FontVariation>& variations) const;
+
private:
MinikinFontForTest() = delete;
MinikinFontForTest(const MinikinFontForTest&) = delete;
diff --git a/tests/util/UnicodeUtils.cpp b/tests/util/UnicodeUtils.cpp
index 87e3418..91e5337 100644
--- a/tests/util/UnicodeUtils.cpp
+++ b/tests/util/UnicodeUtils.cpp
@@ -15,8 +15,8 @@
*/
#include <cstdlib>
-#include <vector>
#include <string>
+#include <vector>
#include <cutils/log.h>
#include <unicode/utf.h>
@@ -27,61 +27,61 @@
// src is of the form "U+1F431 | 'h' 'i'". Position of "|" gets saved to offset if non-null.
// Size is returned in an out parameter because gtest needs a void return for ASSERT to work.
void ParseUnicode(uint16_t* buf, size_t buf_size, const char* src, size_t* result_size,
- size_t* offset) {
+ size_t* offset) {
size_t input_ix = 0;
size_t output_ix = 0;
bool seen_offset = false;
while (src[input_ix] != 0) {
switch (src[input_ix]) {
- case '\'':
- // single ASCII char
- LOG_ALWAYS_FATAL_IF(static_cast<uint8_t>(src[input_ix]) >= 0x80);
- input_ix++;
- LOG_ALWAYS_FATAL_IF(src[input_ix] == 0);
- LOG_ALWAYS_FATAL_IF(output_ix >= buf_size);
- buf[output_ix++] = (uint16_t)src[input_ix++];
- LOG_ALWAYS_FATAL_IF(src[input_ix] != '\'');
- input_ix++;
- break;
- case 'u':
- case 'U': {
- // Unicode codepoint in hex syntax
- input_ix++;
- LOG_ALWAYS_FATAL_IF(src[input_ix] != '+');
- input_ix++;
- char* endptr = (char*)src + input_ix;
- unsigned long int codepoint = strtoul(src + input_ix, &endptr, 16);
- size_t num_hex_digits = endptr - (src + input_ix);
+ case '\'':
+ // single ASCII char
+ LOG_ALWAYS_FATAL_IF(static_cast<uint8_t>(src[input_ix]) >= 0x80);
+ input_ix++;
+ LOG_ALWAYS_FATAL_IF(src[input_ix] == 0);
+ LOG_ALWAYS_FATAL_IF(output_ix >= buf_size);
+ buf[output_ix++] = (uint16_t)src[input_ix++];
+ LOG_ALWAYS_FATAL_IF(src[input_ix] != '\'');
+ input_ix++;
+ break;
+ case 'u':
+ case 'U': {
+ // Unicode codepoint in hex syntax
+ input_ix++;
+ LOG_ALWAYS_FATAL_IF(src[input_ix] != '+');
+ input_ix++;
+ char* endptr = (char*)src + input_ix;
+ unsigned long int codepoint = strtoul(src + input_ix, &endptr, 16);
+ size_t num_hex_digits = endptr - (src + input_ix);
- // also triggers on invalid number syntax, digits = 0
- LOG_ALWAYS_FATAL_IF(num_hex_digits < 4u);
- LOG_ALWAYS_FATAL_IF(num_hex_digits > 6u);
- LOG_ALWAYS_FATAL_IF(codepoint > 0x10FFFFu);
- input_ix += num_hex_digits;
- if (U16_LENGTH(codepoint) == 1) {
- LOG_ALWAYS_FATAL_IF(output_ix + 1 > buf_size);
- buf[output_ix++] = codepoint;
- } else {
- // UTF-16 encoding
- LOG_ALWAYS_FATAL_IF(output_ix + 2 > buf_size);
- buf[output_ix++] = U16_LEAD(codepoint);
- buf[output_ix++] = U16_TRAIL(codepoint);
+ // also triggers on invalid number syntax, digits = 0
+ LOG_ALWAYS_FATAL_IF(num_hex_digits < 4u);
+ LOG_ALWAYS_FATAL_IF(num_hex_digits > 6u);
+ LOG_ALWAYS_FATAL_IF(codepoint > 0x10FFFFu);
+ input_ix += num_hex_digits;
+ if (U16_LENGTH(codepoint) == 1) {
+ LOG_ALWAYS_FATAL_IF(output_ix + 1 > buf_size);
+ buf[output_ix++] = codepoint;
+ } else {
+ // UTF-16 encoding
+ LOG_ALWAYS_FATAL_IF(output_ix + 2 > buf_size);
+ buf[output_ix++] = U16_LEAD(codepoint);
+ buf[output_ix++] = U16_TRAIL(codepoint);
+ }
+ break;
}
- break;
- }
- case ' ':
- input_ix++;
- break;
- case '|':
- LOG_ALWAYS_FATAL_IF(seen_offset);
- LOG_ALWAYS_FATAL_IF(offset == nullptr);
- *offset = output_ix;
- seen_offset = true;
- input_ix++;
- break;
- default:
- LOG_ALWAYS_FATAL("Unexpected Character");
+ case ' ':
+ input_ix++;
+ break;
+ case '|':
+ LOG_ALWAYS_FATAL_IF(seen_offset);
+ LOG_ALWAYS_FATAL_IF(offset == nullptr);
+ *offset = output_ix;
+ seen_offset = true;
+ input_ix++;
+ break;
+ default:
+ LOG_ALWAYS_FATAL("Unexpected Character");
}
}
LOG_ALWAYS_FATAL_IF(result_size == nullptr);
diff --git a/tests/util/UnicodeUtils.h b/tests/util/UnicodeUtils.h
index 2da102d..81fb5f7 100644
--- a/tests/util/UnicodeUtils.h
+++ b/tests/util/UnicodeUtils.h
@@ -21,7 +21,7 @@
namespace minikin {
void ParseUnicode(uint16_t* buf, size_t buf_size, const char* src, size_t* result_size,
- size_t* offset);
+ size_t* offset);
std::vector<uint16_t> parseUnicodeStringWithOffset(const std::string& in, size_t* offset);
std::vector<uint16_t> parseUnicodeString(const std::string& in);