summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeigo Nonaka <nona@google.com>2016-03-07 18:43:15 -0800
committerSeigo Nonaka <nona@google.com>2016-04-15 12:45:04 +0900
commit994aa84f7b18466806fe552ea57da1852b909f24 (patch)
treea4c9327c574989b4971e75e8bc3758b175724754
parentb1203b648acb109fddd537f8d76d168b7f70103e (diff)
downloadandroid_frameworks_minikin-994aa84f7b18466806fe552ea57da1852b909f24.tar.gz
android_frameworks_minikin-994aa84f7b18466806fe552ea57da1852b909f24.tar.bz2
android_frameworks_minikin-994aa84f7b18466806fe552ea57da1852b909f24.zip
Returns hasVariationSelector true for VS15/VS16
Minikin has a special font fallback for VS15/VS16, so hasVariationSelector for emojis with VS15/VS16 should always return true. Bug: 27531970 Change-Id: Ieebd58f48b135b6ec50d999df68dcc09b1284606
-rw-r--r--include/minikin/FontFamily.h5
-rw-r--r--libs/minikin/FontCollection.cpp64
-rw-r--r--libs/minikin/FontFamily.cpp19
-rw-r--r--tests/FontCollectionItemizeTest.cpp27
-rw-r--r--tests/FontCollectionTest.cpp32
-rw-r--r--tests/FontFamilyTest.cpp4
-rw-r--r--tests/FontTestUtils.cpp8
-rw-r--r--tests/FontTestUtils.h5
-rw-r--r--tests/data/ColorEmojiFont.ttfbin1020 -> 1112 bytes
-rw-r--r--tests/data/ColorEmojiFont.ttx13
-rw-r--r--tests/data/TextEmojiFont.ttfbin964 -> 1040 bytes
-rw-r--r--tests/data/TextEmojiFont.ttx13
12 files changed, 156 insertions, 34 deletions
diff --git a/include/minikin/FontFamily.h b/include/minikin/FontFamily.h
index 149dc7b..81033d2 100644
--- a/include/minikin/FontFamily.h
+++ b/include/minikin/FontFamily.h
@@ -100,7 +100,7 @@ struct FakedFont {
class FontFamily : public MinikinRefCounted {
public:
- FontFamily() {}
+ FontFamily();
FontFamily(int variant);
@@ -126,6 +126,7 @@ public:
size_t getNumFonts() const;
MinikinFont* getFont(size_t index) const;
FontStyle getStyle(size_t index) const;
+ bool isColorEmojiFamily() const;
// Get Unicode coverage. Lifetime of returned bitset is same as receiver. May return nullptr on
// error.
@@ -133,7 +134,7 @@ public:
// Returns true if the font has a glyph for the code point and variation selector pair.
// Caller should acquire a lock before calling the method.
- bool hasVariationSelector(uint32_t codepoint, uint32_t variationSelector);
+ bool hasGlyph(uint32_t codepoint, uint32_t variationSelector);
// Returns true if this font family has a variaion sequence table (cmap format 14 subtable).
bool hasVSTable() const;
diff --git a/libs/minikin/FontCollection.cpp b/libs/minikin/FontCollection.cpp
index 75cbd76..b1b0aaf 100644
--- a/libs/minikin/FontCollection.cpp
+++ b/libs/minikin/FontCollection.cpp
@@ -37,6 +37,42 @@ static inline T max(T a, T b) {
return a>b ? a : b;
}
+const uint32_t EMOJI_STYLE_VS = 0xFE0F;
+const uint32_t TEXT_STYLE_VS = 0xFE0E;
+
+// See http://www.unicode.org/Public/9.0.0/ucd/StandardizedVariants-9.0.0d1.txt
+// Must be sorted.
+const uint32_t EMOJI_STYLE_VS_BASES[] = {
+ 0x0023, 0x002A, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039,
+ 0x00A9, 0x00AE, 0x203C, 0x2049, 0x2122, 0x2139, 0x2194, 0x2195, 0x2196, 0x2197, 0x2198, 0x2199,
+ 0x21A9, 0x21AA, 0x231A, 0x231B, 0x2328, 0x23CF, 0x23ED, 0x23EE, 0x23EF, 0x23F1, 0x23F2, 0x23F8,
+ 0x23F9, 0x23FA, 0x24C2, 0x25AA, 0x25AB, 0x25B6, 0x25C0, 0x25FB, 0x25FC, 0x25FD, 0x25FE, 0x2600,
+ 0x2601, 0x2602, 0x2603, 0x2604, 0x260E, 0x2611, 0x2614, 0x2615, 0x2618, 0x261D, 0x2620, 0x2622,
+ 0x2623, 0x2626, 0x262A, 0x262E, 0x262F, 0x2638, 0x2639, 0x263A, 0x2648, 0x2649, 0x264A, 0x264B,
+ 0x264C, 0x264D, 0x264E, 0x264F, 0x2650, 0x2651, 0x2652, 0x2653, 0x2660, 0x2663, 0x2665, 0x2666,
+ 0x2668, 0x267B, 0x267F, 0x2692, 0x2693, 0x2694, 0x2696, 0x2697, 0x2699, 0x269B, 0x269C, 0x26A0,
+ 0x26A1, 0x26AA, 0x26AB, 0x26B0, 0x26B1, 0x26BD, 0x26BE, 0x26C4, 0x26C5, 0x26C8, 0x26CF, 0x26D1,
+ 0x26D3, 0x26D4, 0x26E9, 0x26EA, 0x26F0, 0x26F1, 0x26F2, 0x26F3, 0x26F4, 0x26F5, 0x26F7, 0x26F8,
+ 0x26F9, 0x26FA, 0x26FD, 0x2702, 0x2708, 0x2709, 0x270C, 0x270D, 0x270F, 0x2712, 0x2714, 0x2716,
+ 0x271D, 0x2721, 0x2733, 0x2734, 0x2744, 0x2747, 0x2757, 0x2763, 0x2764, 0x27A1, 0x2934, 0x2935,
+ 0x2B05, 0x2B06, 0x2B07, 0x2B1B, 0x2B1C, 0x2B50, 0x2B55, 0x3030, 0x303D, 0x3297, 0x3299,
+ 0x1F004, 0x1F170, 0x1F171, 0x1F17E, 0x1F17F, 0x1F202, 0x1F21A, 0x1F22F, 0x1F237, 0x1F321,
+ 0x1F324, 0x1F325, 0x1F326, 0x1F327, 0x1F328, 0x1F329, 0x1F32A, 0x1F32B, 0x1F32C, 0x1F336,
+ 0x1F37D, 0x1F396, 0x1F397, 0x1F399, 0x1F39A, 0x1F39B, 0x1F39E, 0x1F39F, 0x1F3CB, 0x1F3CC,
+ 0x1F3CD, 0x1F3CE, 0x1F3D4, 0x1F3D5, 0x1F3D6, 0x1F3D7, 0x1F3D8, 0x1F3D9, 0x1F3DA, 0x1F3DB,
+ 0x1F3DC, 0x1F3DD, 0x1F3DE, 0x1F3DF, 0x1F3F3, 0x1F3F5, 0x1F3F7, 0x1F43F, 0x1F441, 0x1F4FD,
+ 0x1F549, 0x1F54A, 0x1F56F, 0x1F570, 0x1F573, 0x1F574, 0x1F575, 0x1F576, 0x1F577, 0x1F578,
+ 0x1F579, 0x1F587, 0x1F58A, 0x1F58B, 0x1F58C, 0x1F58D, 0x1F590, 0x1F5A5, 0x1F5A8, 0x1F5B1,
+ 0x1F5B2, 0x1F5BC, 0x1F5C2, 0x1F5C3, 0x1F5C4, 0x1F5D1, 0x1F5D2, 0x1F5D3, 0x1F5DC, 0x1F5DD,
+ 0x1F5DE, 0x1F5E1, 0x1F5E3, 0x1F5E8, 0x1F5EF, 0x1F5F3, 0x1F5FA, 0x1F6CB, 0x1F6CD, 0x1F6CE,
+ 0x1F6CF, 0x1F6E0, 0x1F6E1, 0x1F6E2, 0x1F6E3, 0x1F6E4, 0x1F6E5, 0x1F6E9, 0x1F6F0, 0x1F6F3,
+};
+
+static bool isEmojiStyleVSBase(uint32_t cp) {
+ const size_t length = sizeof(EMOJI_STYLE_VS_BASES) / sizeof(EMOJI_STYLE_VS_BASES[0]);
+ return std::binary_search(EMOJI_STYLE_VS_BASES, EMOJI_STYLE_VS_BASES + length, cp);
+}
+
uint32_t FontCollection::sNextId = 0;
FontCollection::FontCollection(const vector<FontFamily*>& typefaces) :
@@ -156,7 +192,7 @@ uint32_t FontCollection::calcFamilyScore(uint32_t ch, uint32_t vs, int variant,
// - 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, FontFamily* fontFamily) const {
- const bool hasVSGlyph = (vs != 0) && fontFamily->hasVariationSelector(ch, vs);
+ 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.
return kUnsupportedFontScore;
@@ -176,7 +212,7 @@ uint32_t FontCollection::calcCoverageScore(uint32_t ch, uint32_t vs, FontFamily*
return 3;
}
- if (vs == 0xFE0F || vs == 0xFE0E) {
+ if (vs == EMOJI_STYLE_VS || vs == TEXT_STYLE_VS) {
const FontLanguages& langs = FontLanguageListCache::getById(fontFamily->langId());
bool hasEmojiFlag = false;
for (size_t i = 0; i < langs.size(); ++i) {
@@ -186,9 +222,9 @@ uint32_t FontCollection::calcCoverageScore(uint32_t ch, uint32_t vs, FontFamily*
}
}
- if (vs == 0xFE0F) {
+ if (vs == EMOJI_STYLE_VS) {
return hasEmojiFlag ? 2 : 1;
- } else { // vs == 0xFE0E
+ } else { // vs == TEXT_STYLE_VS
return hasEmojiFlag ? 1 : 2;
}
}
@@ -325,17 +361,27 @@ bool FontCollection::hasVariationSelector(uint32_t baseCodepoint,
if (baseCodepoint >= mMaxChar) {
return false;
}
- if (variationSelector == 0) {
- return false;
- }
+
+ AutoMutex _l(gMinikinLock);
// Currently mRanges can not be used here since it isn't aware of the variation sequence.
for (size_t i = 0; i < mVSFamilyVec.size(); i++) {
- AutoMutex _l(gMinikinLock);
- if (mVSFamilyVec[i]->hasVariationSelector(baseCodepoint, variationSelector)) {
+ if (mVSFamilyVec[i]->hasGlyph(baseCodepoint, variationSelector)) {
return true;
}
}
+
+ // Even if there is no cmap format 14 subtable entry for the given sequence, should return true
+ // for emoji + U+FE0E case since we have special fallback rule for the sequence.
+ if (isEmojiStyleVSBase(baseCodepoint) && variationSelector == TEXT_STYLE_VS) {
+ for (size_t i = 0; i < mFamilies.size(); ++i) {
+ if (!mFamilies[i]->isColorEmojiFamily() && variationSelector == TEXT_STYLE_VS &&
+ mFamilies[i]->hasGlyph(baseCodepoint, 0)) {
+ return true;
+ }
+ }
+ }
+
return false;
}
diff --git a/libs/minikin/FontFamily.cpp b/libs/minikin/FontFamily.cpp
index 0f71f51..e2d86f0 100644
--- a/libs/minikin/FontFamily.cpp
+++ b/libs/minikin/FontFamily.cpp
@@ -65,6 +65,9 @@ uint32_t FontStyle::pack(int variant, int weight, bool italic) {
return (weight & kWeightMask) | (italic ? kItalicMask : 0) | (variant << kVariantShift);
}
+FontFamily::FontFamily() : FontFamily(0 /* variant */) {
+}
+
FontFamily::FontFamily(int variant) : FontFamily(FontLanguageListCache::kEmptyListId, variant) {
}
@@ -156,6 +159,16 @@ FontStyle FontFamily::getStyle(size_t index) const {
return mFonts[index].style;
}
+bool FontFamily::isColorEmojiFamily() const {
+ const FontLanguages& languageList = FontLanguageListCache::getById(mLangId);
+ for (size_t i = 0; i < languageList.size(); ++i) {
+ if (languageList[i].hasEmojiFlag()) {
+ return true;
+ }
+ }
+ return false;
+}
+
const SparseBitSet* FontFamily::getCoverage() {
if (!mCoverageValid) {
const FontStyle defaultStyle;
@@ -179,9 +192,11 @@ const SparseBitSet* FontFamily::getCoverage() {
return &mCoverage;
}
-bool FontFamily::hasVariationSelector(uint32_t codepoint, uint32_t variationSelector) {
+bool FontFamily::hasGlyph(uint32_t codepoint, uint32_t variationSelector) {
assertMinikinLocked();
- if (!mHasVSTable) {
+ if (variationSelector != 0 && !mHasVSTable) {
+ // Early exit if the variation selector is specified but the font doesn't have a cmap format
+ // 14 subtable.
return false;
}
diff --git a/tests/FontCollectionItemizeTest.cpp b/tests/FontCollectionItemizeTest.cpp
index 45587e9..8ad9472 100644
--- a/tests/FontCollectionItemizeTest.cpp
+++ b/tests/FontCollectionItemizeTest.cpp
@@ -32,6 +32,7 @@ using android::FontLanguage;
using android::FontLanguages;
using android::FontLanguageListCache;
using android::FontStyle;
+using android::MinikinAutoUnref;
using android::MinikinFont;
using android::gMinikinLock;
@@ -80,7 +81,7 @@ const FontLanguages& registerAndGetFontLanguages(const std::string& lang_string)
}
TEST_F(FontCollectionItemizeTest, itemize_latin) {
- std::unique_ptr<FontCollection> collection = getFontCollection(kTestFontDir, kItemizeFontXml);
+ MinikinAutoUnref<FontCollection> collection(getFontCollection(kTestFontDir, kItemizeFontXml));
std::vector<FontCollection::Run> runs;
const FontStyle kRegularStyle = FontStyle();
@@ -150,7 +151,7 @@ TEST_F(FontCollectionItemizeTest, itemize_latin) {
}
TEST_F(FontCollectionItemizeTest, itemize_emoji) {
- std::unique_ptr<FontCollection> collection = getFontCollection(kTestFontDir, kItemizeFontXml);
+ MinikinAutoUnref<FontCollection> collection(getFontCollection(kTestFontDir, kItemizeFontXml));
std::vector<FontCollection::Run> runs;
itemize(collection.get(), "U+1F469 U+1F467", FontStyle(), &runs);
@@ -211,7 +212,7 @@ TEST_F(FontCollectionItemizeTest, itemize_emoji) {
}
TEST_F(FontCollectionItemizeTest, itemize_non_latin) {
- std::unique_ptr<FontCollection> collection = getFontCollection(kTestFontDir, kItemizeFontXml);
+ MinikinAutoUnref<FontCollection> collection(getFontCollection(kTestFontDir, kItemizeFontXml));
std::vector<FontCollection::Run> runs;
FontStyle kJAStyle = FontStyle(FontStyle::registerLanguageList("ja_JP"));
@@ -300,7 +301,7 @@ TEST_F(FontCollectionItemizeTest, itemize_non_latin) {
}
TEST_F(FontCollectionItemizeTest, itemize_mixed) {
- std::unique_ptr<FontCollection> collection = getFontCollection(kTestFontDir, kItemizeFontXml);
+ MinikinAutoUnref<FontCollection> collection(getFontCollection(kTestFontDir, kItemizeFontXml));
std::vector<FontCollection::Run> runs;
FontStyle kUSStyle = FontStyle(FontStyle::registerLanguageList("en_US"));
@@ -339,7 +340,7 @@ TEST_F(FontCollectionItemizeTest, itemize_mixed) {
}
TEST_F(FontCollectionItemizeTest, itemize_variationSelector) {
- std::unique_ptr<FontCollection> collection = getFontCollection(kTestFontDir, kItemizeFontXml);
+ MinikinAutoUnref<FontCollection> collection(getFontCollection(kTestFontDir, kItemizeFontXml));
std::vector<FontCollection::Run> runs;
// A glyph for U+4FAE is provided by both Japanese font and Simplified
@@ -478,7 +479,7 @@ TEST_F(FontCollectionItemizeTest, itemize_variationSelector) {
}
TEST_F(FontCollectionItemizeTest, itemize_variationSelectorSupplement) {
- std::unique_ptr<FontCollection> collection = getFontCollection(kTestFontDir, kItemizeFontXml);
+ MinikinAutoUnref<FontCollection> collection(getFontCollection(kTestFontDir, kItemizeFontXml));
std::vector<FontCollection::Run> runs;
// A glyph for U+845B is provided by both Japanese font and Simplified
@@ -603,7 +604,7 @@ TEST_F(FontCollectionItemizeTest, itemize_variationSelectorSupplement) {
}
TEST_F(FontCollectionItemizeTest, itemize_no_crash) {
- std::unique_ptr<FontCollection> collection = getFontCollection(kTestFontDir, kItemizeFontXml);
+ MinikinAutoUnref<FontCollection> collection(getFontCollection(kTestFontDir, kItemizeFontXml));
std::vector<FontCollection::Run> runs;
// Broken Surrogate pairs. Check only not crashing.
@@ -627,7 +628,7 @@ TEST_F(FontCollectionItemizeTest, itemize_no_crash) {
}
TEST_F(FontCollectionItemizeTest, itemize_fakery) {
- std::unique_ptr<FontCollection> collection = getFontCollection(kTestFontDir, kItemizeFontXml);
+ MinikinAutoUnref<FontCollection> collection(getFontCollection(kTestFontDir, kItemizeFontXml));
std::vector<FontCollection::Run> runs;
FontStyle kJABoldStyle = FontStyle(FontStyle::registerLanguageList("ja_JP"), 0, 7, false);
@@ -1134,7 +1135,7 @@ TEST_F(FontCollectionItemizeTest, itemize_LanguageAndCoverage) {
{ "U+1F469", "zh-Hant,ja-Jpan,zh-Hans", kEmojiFont },
};
- std::unique_ptr<FontCollection> collection = getFontCollection(kTestFontDir, kItemizeFontXml);
+ MinikinAutoUnref<FontCollection> collection(getFontCollection(kTestFontDir, kItemizeFontXml));
for (auto testCase : testCases) {
SCOPED_TRACE("Test for \"" + testCase.testString + "\" with languages " +
@@ -1150,7 +1151,7 @@ TEST_F(FontCollectionItemizeTest, itemize_LanguageAndCoverage) {
}
TEST_F(FontCollectionItemizeTest, itemize_emojiSelection_withFE0E) {
- std::unique_ptr<FontCollection> collection = getFontCollection(kTestFontDir, kEmojiXmlFile);
+ MinikinAutoUnref<FontCollection> collection(getFontCollection(kTestFontDir, kEmojiXmlFile));
std::vector<FontCollection::Run> runs;
const FontStyle kDefaultFontStyle;
@@ -1232,7 +1233,7 @@ TEST_F(FontCollectionItemizeTest, itemize_emojiSelection_withFE0E) {
}
TEST_F(FontCollectionItemizeTest, itemize_emojiSelection_withFE0F) {
- std::unique_ptr<FontCollection> collection = getFontCollection(kTestFontDir, kEmojiXmlFile);
+ MinikinAutoUnref<FontCollection> collection(getFontCollection(kTestFontDir, kEmojiXmlFile));
std::vector<FontCollection::Run> runs;
const FontStyle kDefaultFontStyle;
@@ -1314,7 +1315,7 @@ TEST_F(FontCollectionItemizeTest, itemize_emojiSelection_withFE0F) {
}
TEST_F(FontCollectionItemizeTest, itemize_emojiSelection_with_skinTone) {
- std::unique_ptr<FontCollection> collection = getFontCollection(kTestFontDir, kEmojiXmlFile);
+ MinikinAutoUnref<FontCollection> collection(getFontCollection(kTestFontDir, kEmojiXmlFile));
std::vector<FontCollection::Run> runs;
const FontStyle kDefaultFontStyle;
@@ -1353,7 +1354,7 @@ TEST_F(FontCollectionItemizeTest, itemize_emojiSelection_with_skinTone) {
}
TEST_F(FontCollectionItemizeTest, itemize_PrivateUseArea) {
- std::unique_ptr<FontCollection> collection = getFontCollection(kTestFontDir, kEmojiXmlFile);
+ MinikinAutoUnref<FontCollection> collection(getFontCollection(kTestFontDir, kEmojiXmlFile));
std::vector<FontCollection::Run> runs;
const FontStyle kDefaultFontStyle;
diff --git a/tests/FontCollectionTest.cpp b/tests/FontCollectionTest.cpp
index bbc53e3..5a03f60 100644
--- a/tests/FontCollectionTest.cpp
+++ b/tests/FontCollectionTest.cpp
@@ -17,6 +17,7 @@
#include <gtest/gtest.h>
#include <minikin/FontCollection.h>
+#include "FontTestUtils.h"
#include "MinikinFontForTest.h"
#include "MinikinInternal.h"
@@ -75,4 +76,35 @@ TEST(FontCollectionTest, hasVariationSelectorTest) {
expectVSGlyphs(fc, 0x717D, std::set<uint32_t>({0xFE02, 0xE0102, 0xE0103}));
}
+const char kEmojiXmlFile[] = kTestFontDir "emoji.xml";
+
+TEST(FontCollectionTest, hasVariationSelectorTest_emoji) {
+ MinikinAutoUnref<FontCollection> collection(getFontCollection(kTestFontDir, kEmojiXmlFile));
+
+ // Both text/color font have cmap format 14 subtable entry for VS15/VS16 respectively.
+ EXPECT_TRUE(collection->hasVariationSelector(0x2623, 0xFE0E));
+ EXPECT_TRUE(collection->hasVariationSelector(0x2623, 0xFE0F));
+
+ // The text font has cmap format 14 subtable entry for VS15 but the color font doesn't have for
+ // VS16
+ EXPECT_TRUE(collection->hasVariationSelector(0x2626, 0xFE0E));
+ EXPECT_FALSE(collection->hasVariationSelector(0x2626, 0xFE0F));
+
+ // The color font has cmap format 14 subtable entry for VS16 but the text font doesn't have for
+ // VS15.
+ EXPECT_TRUE(collection->hasVariationSelector(0x262A, 0xFE0E));
+ EXPECT_TRUE(collection->hasVariationSelector(0x262A, 0xFE0F));
+
+ // Neither text/color font have cmap format 14 subtable entry for VS15/VS16.
+ EXPECT_TRUE(collection->hasVariationSelector(0x262E, 0xFE0E));
+ EXPECT_FALSE(collection->hasVariationSelector(0x262E, 0xFE0F));
+
+ // Text font doesn't have U+262F U+FE0E or even its base code point U+262F.
+ EXPECT_FALSE(collection->hasVariationSelector(0x262F, 0xFE0E));
+
+ // VS15/VS16 is only for emoji, should return false for not an emoji code point.
+ EXPECT_FALSE(collection->hasVariationSelector(0x2229, 0xFE0E));
+ EXPECT_FALSE(collection->hasVariationSelector(0x2229, 0xFE0F));
+}
+
} // namespace android
diff --git a/tests/FontFamilyTest.cpp b/tests/FontFamilyTest.cpp
index 194063f..1b24576 100644
--- a/tests/FontFamilyTest.cpp
+++ b/tests/FontFamilyTest.cpp
@@ -339,10 +339,10 @@ void expectVSGlyphs(FontFamily* family, uint32_t codepoint, const std::set<uint3
i = 0xE0100;
}
if (vs.find(i) == vs.end()) {
- EXPECT_FALSE(family->hasVariationSelector(codepoint, i))
+ EXPECT_FALSE(family->hasGlyph(codepoint, i))
<< "Glyph for U+" << std::hex << codepoint << " U+" << i;
} else {
- EXPECT_TRUE(family->hasVariationSelector(codepoint, i))
+ EXPECT_TRUE(family->hasGlyph(codepoint, i))
<< "Glyph for U+" << std::hex << codepoint << " U+" << i;
}
diff --git a/tests/FontTestUtils.cpp b/tests/FontTestUtils.cpp
index 98dab51..fdc3ed6 100644
--- a/tests/FontTestUtils.cpp
+++ b/tests/FontTestUtils.cpp
@@ -24,8 +24,7 @@
#include "FontLanguage.h"
#include "MinikinFontForTest.h"
-std::unique_ptr<android::FontCollection> getFontCollection(
- const char* fontDir, const char* fontXml) {
+android::FontCollection* getFontCollection(const char* fontDir, const char* fontXml) {
xmlDoc* doc = xmlReadFile(fontXml, NULL, 0);
xmlNode* familySet = xmlDocGetRootElement(doc);
@@ -73,9 +72,10 @@ std::unique_ptr<android::FontCollection> getFontCollection(
}
xmlFreeDoc(doc);
- std::unique_ptr<android::FontCollection> r(new android::FontCollection(families));
+ android::FontCollection* collection = new android::FontCollection(families);
+ collection->Ref();
for (size_t i = 0; i < families.size(); ++i) {
families[i]->Unref();
}
- return r;
+ return collection;
}
diff --git a/tests/FontTestUtils.h b/tests/FontTestUtils.h
index 7c62c46..5258a76 100644
--- a/tests/FontTestUtils.h
+++ b/tests/FontTestUtils.h
@@ -24,8 +24,9 @@
*
* This function reads /system/etc/fonts.xml and make font families and
* collections of them. MinikinFontForTest is used for FontFamily creation.
+ *
+ * Caller must unref the returned pointer.
*/
-std::unique_ptr<android::FontCollection> getFontCollection(
- const char* fontDir, const char* fontXml);
+android::FontCollection* getFontCollection(const char* fontDir, const char* fontXml);
#endif // MINIKIN_FONT_TEST_UTILS_H
diff --git a/tests/data/ColorEmojiFont.ttf b/tests/data/ColorEmojiFont.ttf
index e0b34a1..ed18c72 100644
--- a/tests/data/ColorEmojiFont.ttf
+++ b/tests/data/ColorEmojiFont.ttf
Binary files differ
diff --git a/tests/data/ColorEmojiFont.ttx b/tests/data/ColorEmojiFont.ttx
index 58b3d83..7cdc0ae 100644
--- a/tests/data/ColorEmojiFont.ttx
+++ b/tests/data/ColorEmojiFont.ttx
@@ -162,6 +162,7 @@
<cmap>
<tableVersion version="0"/>
<cmap_format_12 format="12" reserved="0" length="7" nGroups="1" platformID="3" platEncID="10" language="0">
+ <!-- TODO: Clean up and write the target test name. -->
<map code="0x00AE" name="Emoji2" /> <!-- Text Default -->
<map code="0x203C" name="Emoji3" /> <!-- Text Default -->
<map code="0x231B" name="Emoji6" /> <!-- Emoji Default -->
@@ -169,7 +170,19 @@
<map code="0x26F9" name="Emoji9" /> <!-- U+26F9 U+FE0F is in ColorTextMixedEmojiFont.ttf -->
<map code="0x261D" name="WHITE_UP_POINTING_INDEX" />
<map code="0x1F3FD" name="EMOJI_MODIFIER_FITZPATRICK_TYPE_4" />
+
+ <!-- For FontCollectionTest.hasVariationSelectorTest_emoji -->
+ <map code="0x2623" name="Emoji1" />
+ <map code="0x2626" name="Emoji1" />
+ <map code="0x262A" name="Emoji1" />
+ <map code="0x262E" name="Emoji1" />
+ <map code="0x262F" name="Emoji1" />
</cmap_format_12>
+ <cmap_format_14 format="14" platformID="0" platEncID="5" length="40" numVarSelectorRecords="2">
+ <!-- For FontCollectionTest.hasVariationSelectorTest_emoji -->
+ <map uvs="0xFE0F" uv="0x2623" name="None" />
+ <map uvs="0xFE0F" uv="0x262A" name="None" />
+ </cmap_format_14>
</cmap>
<loca>
diff --git a/tests/data/TextEmojiFont.ttf b/tests/data/TextEmojiFont.ttf
index 21b6801..943b05d 100644
--- a/tests/data/TextEmojiFont.ttf
+++ b/tests/data/TextEmojiFont.ttf
Binary files differ
diff --git a/tests/data/TextEmojiFont.ttx b/tests/data/TextEmojiFont.ttx
index 83cc9bc..309fe59 100644
--- a/tests/data/TextEmojiFont.ttx
+++ b/tests/data/TextEmojiFont.ttx
@@ -160,13 +160,26 @@
<cmap>
<tableVersion version="0"/>
<cmap_format_4 platformID="3" platEncID="10" language="0">
+ <!-- TODO: Clean up and write the target test name. -->
<map code="0x00A9" name="Emoji1" /> <!-- Text Default -->
<map code="0x203C" name="Emoji3" /> <!-- Text Default -->
<map code="0x231A" name="Emoji5" /> <!-- Emoji Default -->
<map code="0x23E9" name="Emoji7" /> <!-- Emoji Default -->
<map code="0x26FA" name="Emoji9" /> <!-- U+26FA U+FE0E is in ColorTextMixedEmojiFont.ttf -->
<map code="0x261D" name="WHITE_UP_POINTING_INDEX" />
+
+ <!-- For FontCollectionTest.hasVariationSelectorTest_emoji -->
+ <map code="0x2623" name="Emoji1" />
+ <map code="0x2626" name="Emoji1" />
+ <map code="0x262A" name="Emoji1" />
+ <map code="0x262E" name="Emoji1" />
+ <!-- U+262F is reserved for this test. -->
</cmap_format_4>
+ <cmap_format_14 format="14" platformID="0" platEncID="5" length="40" numVarSelectorRecords="2">
+ <!-- For FontCollectionTest.hasVariationSelectorTest_emoji -->
+ <map uvs="0xFE0E" uv="0x2623" name="None" />
+ <map uvs="0xFE0E" uv="0x2626" name="None" />
+ </cmap_format_14>
</cmap>
<loca>