summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Seigo Nonaka <nona@google.com> 2025-01-08 15:00:28 +0900
committer Seigo Nonaka <nona@google.com> 2025-01-08 15:04:38 +0900
commit4893c55722b29bd43b15c6770e80ba8abadb0474 (patch)
tree20282442733f4bee82e613091fbfbf4033929f20
parent3c424e87908574b724eccc9991690ea03f85a3bd (diff)
Refactor Typeface class for ensuring all members are initialized
Bug: 385136165 Test: TreeHugger Flag: EXEMPT refactoring Change-Id: I430d7086afa256d899d2201cc568f361d2177c15
-rw-r--r--libs/hwui/hwui/MinikinUtils.cpp8
-rw-r--r--libs/hwui/hwui/Typeface.cpp83
-rw-r--r--libs/hwui/hwui/Typeface.h30
-rw-r--r--libs/hwui/jni/Paint.cpp5
-rw-r--r--libs/hwui/jni/Typeface.cpp40
-rw-r--r--libs/hwui/jni/text/TextShaper.cpp2
-rw-r--r--libs/hwui/tests/common/TestUtils.cpp7
-rw-r--r--libs/hwui/tests/unit/TypefaceTests.cpp252
8 files changed, 207 insertions, 220 deletions
diff --git a/libs/hwui/hwui/MinikinUtils.cpp b/libs/hwui/hwui/MinikinUtils.cpp
index 7b45070af312..290df997a8ed 100644
--- a/libs/hwui/hwui/MinikinUtils.cpp
+++ b/libs/hwui/hwui/MinikinUtils.cpp
@@ -36,7 +36,7 @@ minikin::MinikinPaint MinikinUtils::prepareMinikinPaint(const Paint* paint,
const Typeface* resolvedFace = Typeface::resolveDefault(typeface);
const SkFont& font = paint->getSkFont();
- minikin::MinikinPaint minikinPaint(resolvedFace->fFontCollection);
+ minikin::MinikinPaint minikinPaint(resolvedFace->getFontCollection());
/* Prepare minikin Paint */
minikinPaint.size =
font.isLinearMetrics() ? font.getSize() : static_cast<int>(font.getSize());
@@ -46,9 +46,9 @@ minikin::MinikinPaint MinikinUtils::prepareMinikinPaint(const Paint* paint,
minikinPaint.wordSpacing = paint->getWordSpacing();
minikinPaint.fontFlags = MinikinFontSkia::packFontFlags(font);
minikinPaint.localeListId = paint->getMinikinLocaleListId();
- minikinPaint.fontStyle = resolvedFace->fStyle;
+ minikinPaint.fontStyle = resolvedFace->getFontStyle();
minikinPaint.fontFeatureSettings = paint->getFontFeatureSettings();
- if (!resolvedFace->fIsVariationInstance) {
+ if (!resolvedFace->isVariationInstance()) {
// This is an optimization for direct private API use typically done by System UI.
// In the public API surface, if Typeface is already configured for variation instance
// (Target SDK <= 35) the font variation settings of Paint is not set.
@@ -132,7 +132,7 @@ minikin::MinikinExtent MinikinUtils::getFontExtent(const Paint* paint, minikin::
bool MinikinUtils::hasVariationSelector(const Typeface* typeface, uint32_t codepoint, uint32_t vs) {
const Typeface* resolvedFace = Typeface::resolveDefault(typeface);
- return resolvedFace->fFontCollection->hasVariationSelector(codepoint, vs);
+ return resolvedFace->getFontCollection()->hasVariationSelector(codepoint, vs);
}
float MinikinUtils::xOffsetForTextAlign(Paint* paint, const minikin::Layout& layout) {
diff --git a/libs/hwui/hwui/Typeface.cpp b/libs/hwui/hwui/Typeface.cpp
index 4dfe05377a48..a73aac632752 100644
--- a/libs/hwui/hwui/Typeface.cpp
+++ b/libs/hwui/hwui/Typeface.cpp
@@ -70,74 +70,45 @@ const Typeface* Typeface::resolveDefault(const Typeface* src) {
Typeface* Typeface::createRelative(Typeface* src, Typeface::Style style) {
const Typeface* resolvedFace = Typeface::resolveDefault(src);
- Typeface* result = new Typeface;
- if (result != nullptr) {
- result->fFontCollection = resolvedFace->fFontCollection;
- result->fBaseWeight = resolvedFace->fBaseWeight;
- result->fAPIStyle = style;
- result->fStyle = computeRelativeStyle(result->fBaseWeight, style);
- result->fIsVariationInstance = resolvedFace->fIsVariationInstance;
- }
- return result;
+ return new Typeface(resolvedFace->getFontCollection(),
+ computeRelativeStyle(resolvedFace->getBaseWeight(), style), style,
+ resolvedFace->getBaseWeight(), resolvedFace->isVariationInstance());
}
Typeface* Typeface::createAbsolute(Typeface* base, int weight, bool italic) {
const Typeface* resolvedFace = Typeface::resolveDefault(base);
- Typeface* result = new Typeface();
- if (result != nullptr) {
- result->fFontCollection = resolvedFace->fFontCollection;
- result->fBaseWeight = resolvedFace->fBaseWeight;
- result->fAPIStyle = computeAPIStyle(weight, italic);
- result->fStyle = computeMinikinStyle(weight, italic);
- result->fIsVariationInstance = resolvedFace->fIsVariationInstance;
- }
- return result;
+ return new Typeface(resolvedFace->getFontCollection(), computeMinikinStyle(weight, italic),
+ computeAPIStyle(weight, italic), resolvedFace->getBaseWeight(),
+ resolvedFace->isVariationInstance());
}
Typeface* Typeface::createFromTypefaceWithVariation(Typeface* src,
const minikin::VariationSettings& variations) {
const Typeface* resolvedFace = Typeface::resolveDefault(src);
- Typeface* result = new Typeface();
- if (result != nullptr) {
- result->fFontCollection =
- resolvedFace->fFontCollection->createCollectionWithVariation(variations);
- if (result->fFontCollection == nullptr) {
+ const std::shared_ptr<minikin::FontCollection>& fc =
+ resolvedFace->getFontCollection()->createCollectionWithVariation(variations);
+ return new Typeface(
// None of passed axes are supported by this collection.
// So we will reuse the same collection with incrementing reference count.
- result->fFontCollection = resolvedFace->fFontCollection;
- }
- // Do not update styles.
- // TODO: We may want to update base weight if the 'wght' is specified.
- result->fBaseWeight = resolvedFace->fBaseWeight;
- result->fAPIStyle = resolvedFace->fAPIStyle;
- result->fStyle = resolvedFace->fStyle;
- result->fIsVariationInstance = true;
- }
- return result;
+ fc ? fc : resolvedFace->getFontCollection(),
+ // Do not update styles.
+ // TODO: We may want to update base weight if the 'wght' is specified.
+ resolvedFace->fStyle, resolvedFace->getAPIStyle(), resolvedFace->getBaseWeight(), true);
}
Typeface* Typeface::createWithDifferentBaseWeight(Typeface* src, int weight) {
const Typeface* resolvedFace = Typeface::resolveDefault(src);
- Typeface* result = new Typeface;
- if (result != nullptr) {
- result->fFontCollection = resolvedFace->fFontCollection;
- result->fBaseWeight = weight;
- result->fAPIStyle = resolvedFace->fAPIStyle;
- result->fStyle = computeRelativeStyle(weight, result->fAPIStyle);
- result->fIsVariationInstance = resolvedFace->fIsVariationInstance;
- }
- return result;
+ return new Typeface(resolvedFace->getFontCollection(),
+ computeRelativeStyle(weight, resolvedFace->getAPIStyle()),
+ resolvedFace->getAPIStyle(), weight, resolvedFace->isVariationInstance());
}
Typeface* Typeface::createFromFamilies(std::vector<std::shared_ptr<minikin::FontFamily>>&& families,
int weight, int italic, const Typeface* fallback) {
- Typeface* result = new Typeface;
- if (fallback == nullptr) {
- result->fFontCollection = minikin::FontCollection::create(std::move(families));
- } else {
- result->fFontCollection =
- fallback->fFontCollection->createCollectionWithFamilies(std::move(families));
- }
+ const std::shared_ptr<minikin::FontCollection>& fc =
+ fallback ? fallback->getFontCollection()->createCollectionWithFamilies(
+ std::move(families))
+ : minikin::FontCollection::create(std::move(families));
if (weight == RESOLVE_BY_FONT_TABLE || italic == RESOLVE_BY_FONT_TABLE) {
int weightFromFont;
@@ -171,11 +142,8 @@ Typeface* Typeface::createFromFamilies(std::vector<std::shared_ptr<minikin::Font
weight = SkFontStyle::kNormal_Weight;
}
- result->fBaseWeight = weight;
- result->fAPIStyle = computeAPIStyle(weight, italic);
- result->fStyle = computeMinikinStyle(weight, italic);
- result->fIsVariationInstance = false;
- return result;
+ return new Typeface(fc, computeMinikinStyle(weight, italic), computeAPIStyle(weight, italic),
+ weight, false);
}
void Typeface::setDefault(const Typeface* face) {
@@ -205,11 +173,8 @@ void Typeface::setRobotoTypefaceForTest() {
std::shared_ptr<minikin::FontCollection> collection =
minikin::FontCollection::create(minikin::FontFamily::create(std::move(fonts)));
- Typeface* hwTypeface = new Typeface();
- hwTypeface->fFontCollection = collection;
- hwTypeface->fAPIStyle = Typeface::kNormal;
- hwTypeface->fBaseWeight = SkFontStyle::kNormal_Weight;
- hwTypeface->fStyle = minikin::FontStyle();
+ Typeface* hwTypeface = new Typeface(collection, minikin::FontStyle(), Typeface::kNormal,
+ SkFontStyle::kNormal_Weight, false);
Typeface::setDefault(hwTypeface);
#endif
diff --git a/libs/hwui/hwui/Typeface.h b/libs/hwui/hwui/Typeface.h
index 97d1bf4ef011..e8233a6bc6d8 100644
--- a/libs/hwui/hwui/Typeface.h
+++ b/libs/hwui/hwui/Typeface.h
@@ -32,21 +32,39 @@ constexpr int RESOLVE_BY_FONT_TABLE = -1;
struct ANDROID_API Typeface {
public:
- std::shared_ptr<minikin::FontCollection> fFontCollection;
+ enum Style : uint8_t { kNormal = 0, kBold = 0x01, kItalic = 0x02, kBoldItalic = 0x03 };
+ Typeface(const std::shared_ptr<minikin::FontCollection> fc, minikin::FontStyle style,
+ Style apiStyle, int baseWeight, bool isVariationInstance)
+ : fFontCollection(fc)
+ , fStyle(style)
+ , fAPIStyle(apiStyle)
+ , fBaseWeight(baseWeight)
+ , fIsVariationInstance(isVariationInstance) {}
+
+ const std::shared_ptr<minikin::FontCollection>& getFontCollection() const {
+ return fFontCollection;
+ }
// resolved style actually used for rendering
- minikin::FontStyle fStyle;
+ minikin::FontStyle getFontStyle() const { return fStyle; }
// style used in the API
- enum Style : uint8_t { kNormal = 0, kBold = 0x01, kItalic = 0x02, kBoldItalic = 0x03 };
- Style fAPIStyle;
+ Style getAPIStyle() const { return fAPIStyle; }
// base weight in CSS-style units, 1..1000
- int fBaseWeight;
+ int getBaseWeight() const { return fBaseWeight; }
// True if the Typeface is already created for variation settings.
- bool fIsVariationInstance;
+ bool isVariationInstance() const { return fIsVariationInstance; }
+private:
+ std::shared_ptr<minikin::FontCollection> fFontCollection;
+ minikin::FontStyle fStyle;
+ Style fAPIStyle;
+ int fBaseWeight;
+ bool fIsVariationInstance = false;
+
+public:
static const Typeface* resolveDefault(const Typeface* src);
// The following three functions create new Typeface from an existing Typeface with a different
diff --git a/libs/hwui/jni/Paint.cpp b/libs/hwui/jni/Paint.cpp
index 8d3a5eb2b4af..f6fdec1c82bc 100644
--- a/libs/hwui/jni/Paint.cpp
+++ b/libs/hwui/jni/Paint.cpp
@@ -609,7 +609,8 @@ namespace PaintGlue {
SkFont* font = &paint->getSkFont();
const Typeface* typeface = paint->getAndroidTypeface();
typeface = Typeface::resolveDefault(typeface);
- minikin::FakedFont baseFont = typeface->fFontCollection->baseFontFaked(typeface->fStyle);
+ minikin::FakedFont baseFont =
+ typeface->getFontCollection()->baseFontFaked(typeface->getFontStyle());
float saveSkewX = font->getSkewX();
bool savefakeBold = font->isEmbolden();
MinikinFontSkia::populateSkFont(font, baseFont.typeface().get(), baseFont.fakery);
@@ -641,7 +642,7 @@ namespace PaintGlue {
if (useLocale) {
minikin::MinikinPaint minikinPaint = MinikinUtils::prepareMinikinPaint(paint, typeface);
minikin::MinikinExtent extent =
- typeface->fFontCollection->getReferenceExtentForLocale(minikinPaint);
+ typeface->getFontCollection()->getReferenceExtentForLocale(minikinPaint);
metrics->fAscent = std::min(extent.ascent, metrics->fAscent);
metrics->fDescent = std::max(extent.descent, metrics->fDescent);
metrics->fTop = std::min(metrics->fAscent, metrics->fTop);
diff --git a/libs/hwui/jni/Typeface.cpp b/libs/hwui/jni/Typeface.cpp
index c5095c1a0704..63906de80745 100644
--- a/libs/hwui/jni/Typeface.cpp
+++ b/libs/hwui/jni/Typeface.cpp
@@ -99,17 +99,17 @@ static jlong Typeface_getReleaseFunc(CRITICAL_JNI_PARAMS) {
// CriticalNative
static jint Typeface_getStyle(CRITICAL_JNI_PARAMS_COMMA jlong faceHandle) {
- return toTypeface(faceHandle)->fAPIStyle;
+ return toTypeface(faceHandle)->getAPIStyle();
}
// CriticalNative
static jint Typeface_getWeight(CRITICAL_JNI_PARAMS_COMMA jlong faceHandle) {
- return toTypeface(faceHandle)->fStyle.weight();
+ return toTypeface(faceHandle)->getFontStyle().weight();
}
// Critical Native
static jboolean Typeface_isVariationInstance(CRITICAL_JNI_PARAMS_COMMA jlong faceHandle) {
- return toTypeface(faceHandle)->fIsVariationInstance;
+ return toTypeface(faceHandle)->isVariationInstance();
}
static jlong Typeface_createFromArray(JNIEnv *env, jobject, jlongArray familyArray,
@@ -128,18 +128,18 @@ static jlong Typeface_createFromArray(JNIEnv *env, jobject, jlongArray familyArr
// CriticalNative
static void Typeface_setDefault(CRITICAL_JNI_PARAMS_COMMA jlong faceHandle) {
Typeface::setDefault(toTypeface(faceHandle));
- minikin::SystemFonts::registerDefault(toTypeface(faceHandle)->fFontCollection);
+ minikin::SystemFonts::registerDefault(toTypeface(faceHandle)->getFontCollection());
}
static jobject Typeface_getSupportedAxes(JNIEnv *env, jobject, jlong faceHandle) {
Typeface* face = toTypeface(faceHandle);
- const size_t length = face->fFontCollection->getSupportedAxesCount();
+ const size_t length = face->getFontCollection()->getSupportedAxesCount();
if (length == 0) {
return nullptr;
}
std::vector<jint> tagVec(length);
for (size_t i = 0; i < length; i++) {
- tagVec[i] = face->fFontCollection->getSupportedAxisAt(i);
+ tagVec[i] = face->getFontCollection()->getSupportedAxisAt(i);
}
std::sort(tagVec.begin(), tagVec.end());
const jintArray result = env->NewIntArray(length);
@@ -150,7 +150,7 @@ static jobject Typeface_getSupportedAxes(JNIEnv *env, jobject, jlong faceHandle)
static void Typeface_registerGenericFamily(JNIEnv *env, jobject, jstring familyName, jlong ptr) {
ScopedUtfChars familyNameChars(env, familyName);
minikin::SystemFonts::registerFallback(familyNameChars.c_str(),
- toTypeface(ptr)->fFontCollection);
+ toTypeface(ptr)->getFontCollection());
}
#ifdef __ANDROID__
@@ -315,18 +315,19 @@ static jint Typeface_writeTypefaces(JNIEnv* env, jobject, jobject buffer, jint p
std::vector<std::shared_ptr<minikin::FontCollection>> fontCollections;
std::unordered_map<std::shared_ptr<minikin::FontCollection>, size_t> fcToIndex;
for (Typeface* typeface : typefaces) {
- bool inserted = fcToIndex.emplace(typeface->fFontCollection, fontCollections.size()).second;
+ bool inserted =
+ fcToIndex.emplace(typeface->getFontCollection(), fontCollections.size()).second;
if (inserted) {
- fontCollections.push_back(typeface->fFontCollection);
+ fontCollections.push_back(typeface->getFontCollection());
}
}
minikin::FontCollection::writeVector(&writer, fontCollections);
writer.write<uint32_t>(typefaces.size());
for (Typeface* typeface : typefaces) {
- writer.write<uint32_t>(fcToIndex.find(typeface->fFontCollection)->second);
- typeface->fStyle.writeTo(&writer);
- writer.write<Typeface::Style>(typeface->fAPIStyle);
- writer.write<int>(typeface->fBaseWeight);
+ writer.write<uint32_t>(fcToIndex.find(typeface->getFontCollection())->second);
+ typeface->getFontStyle().writeTo(&writer);
+ writer.write<Typeface::Style>(typeface->getAPIStyle());
+ writer.write<int>(typeface->getBaseWeight());
}
return static_cast<jint>(writer.size());
}
@@ -349,12 +350,10 @@ static jlongArray Typeface_readTypefaces(JNIEnv* env, jobject, jobject buffer, j
std::vector<jlong> faceHandles;
faceHandles.reserve(typefaceCount);
for (uint32_t i = 0; i < typefaceCount; i++) {
- Typeface* typeface = new Typeface;
- typeface->fFontCollection = fontCollections[reader.read<uint32_t>()];
- typeface->fStyle = minikin::FontStyle(&reader);
- typeface->fAPIStyle = reader.read<Typeface::Style>();
- typeface->fBaseWeight = reader.read<int>();
- typeface->fIsVariationInstance = false;
+ Typeface* typeface =
+ new Typeface(fontCollections[reader.read<uint32_t>()], minikin::FontStyle(&reader),
+ reader.read<Typeface::Style>(), reader.read<int>(),
+ false /* isVariationInstance */);
faceHandles.push_back(toJLong(typeface));
}
const jlongArray result = env->NewLongArray(typefaceCount);
@@ -382,7 +381,8 @@ static void Typeface_warmUpCache(JNIEnv* env, jobject, jstring jFilePath) {
// Critical Native
static void Typeface_addFontCollection(CRITICAL_JNI_PARAMS_COMMA jlong faceHandle) {
- std::shared_ptr<minikin::FontCollection> collection = toTypeface(faceHandle)->fFontCollection;
+ std::shared_ptr<minikin::FontCollection> collection =
+ toTypeface(faceHandle)->getFontCollection();
minikin::SystemFonts::addFontMap(std::move(collection));
}
diff --git a/libs/hwui/jni/text/TextShaper.cpp b/libs/hwui/jni/text/TextShaper.cpp
index d1782b285b34..7a4ae8330de8 100644
--- a/libs/hwui/jni/text/TextShaper.cpp
+++ b/libs/hwui/jni/text/TextShaper.cpp
@@ -104,7 +104,7 @@ static jlong shapeTextRun(const uint16_t* text, int textSize, int start, int cou
} else {
fontId = fonts.size(); // This is new to us. Create new one.
std::shared_ptr<minikin::Font> font;
- if (resolvedFace->fIsVariationInstance) {
+ if (resolvedFace->isVariationInstance()) {
// The optimization for target SDK 35 or before because the variation instance
// is already created and no runtime variation resolution happens on such
// environment.
diff --git a/libs/hwui/tests/common/TestUtils.cpp b/libs/hwui/tests/common/TestUtils.cpp
index 93118aeafaaf..b51414fd3c02 100644
--- a/libs/hwui/tests/common/TestUtils.cpp
+++ b/libs/hwui/tests/common/TestUtils.cpp
@@ -183,8 +183,11 @@ SkRect TestUtils::getLocalClipBounds(const SkCanvas* canvas) {
}
SkFont TestUtils::defaultFont() {
- const std::shared_ptr<minikin::MinikinFont>& minikinFont =
- Typeface::resolveDefault(nullptr)->fFontCollection->getFamilyAt(0)->getFont(0)->baseTypeface();
+ const std::shared_ptr<minikin::MinikinFont>& minikinFont = Typeface::resolveDefault(nullptr)
+ ->getFontCollection()
+ ->getFamilyAt(0)
+ ->getFont(0)
+ ->baseTypeface();
SkTypeface* skTypeface = reinterpret_cast<const MinikinFontSkia*>(minikinFont.get())->GetSkTypeface();
LOG_ALWAYS_FATAL_IF(skTypeface == nullptr);
return SkFont(sk_ref_sp(skTypeface));
diff --git a/libs/hwui/tests/unit/TypefaceTests.cpp b/libs/hwui/tests/unit/TypefaceTests.cpp
index c71c4d243a8b..7bcd937397b0 100644
--- a/libs/hwui/tests/unit/TypefaceTests.cpp
+++ b/libs/hwui/tests/unit/TypefaceTests.cpp
@@ -90,40 +90,40 @@ TEST(TypefaceTest, resolveDefault_and_setDefaultTest) {
TEST(TypefaceTest, createWithDifferentBaseWeight) {
std::unique_ptr<Typeface> bold(Typeface::createWithDifferentBaseWeight(nullptr, 700));
- EXPECT_EQ(700, bold->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, bold->fStyle.slant());
- EXPECT_EQ(Typeface::kNormal, bold->fAPIStyle);
+ EXPECT_EQ(700, bold->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, bold->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kNormal, bold->getAPIStyle());
std::unique_ptr<Typeface> light(Typeface::createWithDifferentBaseWeight(nullptr, 300));
- EXPECT_EQ(300, light->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, light->fStyle.slant());
- EXPECT_EQ(Typeface::kNormal, light->fAPIStyle);
+ EXPECT_EQ(300, light->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, light->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kNormal, light->getAPIStyle());
}
TEST(TypefaceTest, createRelativeTest_fromRegular) {
// In Java, Typeface.create(Typeface.DEFAULT, Typeface.NORMAL);
std::unique_ptr<Typeface> normal(Typeface::createRelative(nullptr, Typeface::kNormal));
- EXPECT_EQ(400, normal->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, normal->fStyle.slant());
- EXPECT_EQ(Typeface::kNormal, normal->fAPIStyle);
+ EXPECT_EQ(400, normal->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, normal->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kNormal, normal->getAPIStyle());
// In Java, Typeface.create(Typeface.DEFAULT, Typeface.BOLD);
std::unique_ptr<Typeface> bold(Typeface::createRelative(nullptr, Typeface::kBold));
- EXPECT_EQ(700, bold->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, bold->fStyle.slant());
- EXPECT_EQ(Typeface::kBold, bold->fAPIStyle);
+ EXPECT_EQ(700, bold->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, bold->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kBold, bold->getAPIStyle());
// In Java, Typeface.create(Typeface.DEFAULT, Typeface.ITALIC);
std::unique_ptr<Typeface> italic(Typeface::createRelative(nullptr, Typeface::kItalic));
- EXPECT_EQ(400, italic->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, italic->fStyle.slant());
- EXPECT_EQ(Typeface::kItalic, italic->fAPIStyle);
+ EXPECT_EQ(400, italic->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, italic->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kItalic, italic->getAPIStyle());
// In Java, Typeface.create(Typeface.DEFAULT, Typeface.BOLD_ITALIC);
std::unique_ptr<Typeface> boldItalic(Typeface::createRelative(nullptr, Typeface::kBoldItalic));
- EXPECT_EQ(700, boldItalic->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, boldItalic->fStyle.slant());
- EXPECT_EQ(Typeface::kBoldItalic, boldItalic->fAPIStyle);
+ EXPECT_EQ(700, boldItalic->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, boldItalic->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kBoldItalic, boldItalic->getAPIStyle());
}
TEST(TypefaceTest, createRelativeTest_BoldBase) {
@@ -132,31 +132,31 @@ TEST(TypefaceTest, createRelativeTest_BoldBase) {
// In Java, Typeface.create(Typeface.create("sans-serif-bold"),
// Typeface.NORMAL);
std::unique_ptr<Typeface> normal(Typeface::createRelative(base.get(), Typeface::kNormal));
- EXPECT_EQ(700, normal->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, normal->fStyle.slant());
- EXPECT_EQ(Typeface::kNormal, normal->fAPIStyle);
+ EXPECT_EQ(700, normal->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, normal->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kNormal, normal->getAPIStyle());
// In Java, Typeface.create(Typeface.create("sans-serif-bold"),
// Typeface.BOLD);
std::unique_ptr<Typeface> bold(Typeface::createRelative(base.get(), Typeface::kBold));
- EXPECT_EQ(1000, bold->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, bold->fStyle.slant());
- EXPECT_EQ(Typeface::kBold, bold->fAPIStyle);
+ EXPECT_EQ(1000, bold->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, bold->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kBold, bold->getAPIStyle());
// In Java, Typeface.create(Typeface.create("sans-serif-bold"),
// Typeface.ITALIC);
std::unique_ptr<Typeface> italic(Typeface::createRelative(base.get(), Typeface::kItalic));
- EXPECT_EQ(700, italic->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, italic->fStyle.slant());
- EXPECT_EQ(Typeface::kItalic, italic->fAPIStyle);
+ EXPECT_EQ(700, italic->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, italic->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kItalic, italic->getAPIStyle());
// In Java, Typeface.create(Typeface.create("sans-serif-bold"),
// Typeface.BOLD_ITALIC);
std::unique_ptr<Typeface> boldItalic(
Typeface::createRelative(base.get(), Typeface::kBoldItalic));
- EXPECT_EQ(1000, boldItalic->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, boldItalic->fStyle.slant());
- EXPECT_EQ(Typeface::kBoldItalic, boldItalic->fAPIStyle);
+ EXPECT_EQ(1000, boldItalic->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, boldItalic->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kBoldItalic, boldItalic->getAPIStyle());
}
TEST(TypefaceTest, createRelativeTest_LightBase) {
@@ -165,31 +165,31 @@ TEST(TypefaceTest, createRelativeTest_LightBase) {
// In Java, Typeface.create(Typeface.create("sans-serif-light"),
// Typeface.NORMAL);
std::unique_ptr<Typeface> normal(Typeface::createRelative(base.get(), Typeface::kNormal));
- EXPECT_EQ(300, normal->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, normal->fStyle.slant());
- EXPECT_EQ(Typeface::kNormal, normal->fAPIStyle);
+ EXPECT_EQ(300, normal->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, normal->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kNormal, normal->getAPIStyle());
// In Java, Typeface.create(Typeface.create("sans-serif-light"),
// Typeface.BOLD);
std::unique_ptr<Typeface> bold(Typeface::createRelative(base.get(), Typeface::kBold));
- EXPECT_EQ(600, bold->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, bold->fStyle.slant());
- EXPECT_EQ(Typeface::kBold, bold->fAPIStyle);
+ EXPECT_EQ(600, bold->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, bold->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kBold, bold->getAPIStyle());
// In Java, Typeface.create(Typeface.create("sans-serif-light"),
// Typeface.ITLIC);
std::unique_ptr<Typeface> italic(Typeface::createRelative(base.get(), Typeface::kItalic));
- EXPECT_EQ(300, italic->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, italic->fStyle.slant());
- EXPECT_EQ(Typeface::kItalic, italic->fAPIStyle);
+ EXPECT_EQ(300, italic->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, italic->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kItalic, italic->getAPIStyle());
// In Java, Typeface.create(Typeface.create("sans-serif-light"),
// Typeface.BOLD_ITALIC);
std::unique_ptr<Typeface> boldItalic(
Typeface::createRelative(base.get(), Typeface::kBoldItalic));
- EXPECT_EQ(600, boldItalic->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, boldItalic->fStyle.slant());
- EXPECT_EQ(Typeface::kBoldItalic, boldItalic->fAPIStyle);
+ EXPECT_EQ(600, boldItalic->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, boldItalic->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kBoldItalic, boldItalic->getAPIStyle());
}
TEST(TypefaceTest, createRelativeTest_fromBoldStyled) {
@@ -198,32 +198,32 @@ TEST(TypefaceTest, createRelativeTest_fromBoldStyled) {
// In Java, Typeface.create(Typeface.create(Typeface.DEFAULT, Typeface.BOLD),
// Typeface.NORMAL);
std::unique_ptr<Typeface> normal(Typeface::createRelative(base.get(), Typeface::kNormal));
- EXPECT_EQ(400, normal->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, normal->fStyle.slant());
- EXPECT_EQ(Typeface::kNormal, normal->fAPIStyle);
+ EXPECT_EQ(400, normal->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, normal->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kNormal, normal->getAPIStyle());
// In Java Typeface.create(Typeface.create(Typeface.DEFAULT, Typeface.BOLD),
// Typeface.BOLD);
std::unique_ptr<Typeface> bold(Typeface::createRelative(base.get(), Typeface::kBold));
- EXPECT_EQ(700, bold->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, bold->fStyle.slant());
- EXPECT_EQ(Typeface::kBold, bold->fAPIStyle);
+ EXPECT_EQ(700, bold->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, bold->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kBold, bold->getAPIStyle());
// In Java, Typeface.create(Typeface.create(Typeface.DEFAULT, Typeface.BOLD),
// Typeface.ITALIC);
std::unique_ptr<Typeface> italic(Typeface::createRelative(base.get(), Typeface::kItalic));
- EXPECT_EQ(400, normal->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, italic->fStyle.slant());
- EXPECT_EQ(Typeface::kItalic, italic->fAPIStyle);
+ EXPECT_EQ(400, normal->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, italic->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kItalic, italic->getAPIStyle());
// In Java,
// Typeface.create(Typeface.create(Typeface.DEFAULT, Typeface.BOLD),
// Typeface.BOLD_ITALIC);
std::unique_ptr<Typeface> boldItalic(
Typeface::createRelative(base.get(), Typeface::kBoldItalic));
- EXPECT_EQ(700, boldItalic->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, boldItalic->fStyle.slant());
- EXPECT_EQ(Typeface::kBoldItalic, boldItalic->fAPIStyle);
+ EXPECT_EQ(700, boldItalic->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, boldItalic->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kBoldItalic, boldItalic->getAPIStyle());
}
TEST(TypefaceTest, createRelativeTest_fromItalicStyled) {
@@ -233,33 +233,33 @@ TEST(TypefaceTest, createRelativeTest_fromItalicStyled) {
// Typeface.create(Typeface.create(Typeface.DEFAULT, Typeface.ITALIC),
// Typeface.NORMAL);
std::unique_ptr<Typeface> normal(Typeface::createRelative(base.get(), Typeface::kNormal));
- EXPECT_EQ(400, normal->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, normal->fStyle.slant());
- EXPECT_EQ(Typeface::kNormal, normal->fAPIStyle);
+ EXPECT_EQ(400, normal->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, normal->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kNormal, normal->getAPIStyle());
// In Java, Typeface.create(Typeface.create(Typeface.DEFAULT,
// Typeface.ITALIC), Typeface.BOLD);
std::unique_ptr<Typeface> bold(Typeface::createRelative(base.get(), Typeface::kBold));
- EXPECT_EQ(700, bold->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, bold->fStyle.slant());
- EXPECT_EQ(Typeface::kBold, bold->fAPIStyle);
+ EXPECT_EQ(700, bold->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, bold->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kBold, bold->getAPIStyle());
// In Java,
// Typeface.create(Typeface.create(Typeface.DEFAULT, Typeface.ITALIC),
// Typeface.ITALIC);
std::unique_ptr<Typeface> italic(Typeface::createRelative(base.get(), Typeface::kItalic));
- EXPECT_EQ(400, italic->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, italic->fStyle.slant());
- EXPECT_EQ(Typeface::kItalic, italic->fAPIStyle);
+ EXPECT_EQ(400, italic->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, italic->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kItalic, italic->getAPIStyle());
// In Java,
// Typeface.create(Typeface.create(Typeface.DEFAULT, Typeface.ITALIC),
// Typeface.BOLD_ITALIC);
std::unique_ptr<Typeface> boldItalic(
Typeface::createRelative(base.get(), Typeface::kBoldItalic));
- EXPECT_EQ(700, boldItalic->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, boldItalic->fStyle.slant());
- EXPECT_EQ(Typeface::kBoldItalic, boldItalic->fAPIStyle);
+ EXPECT_EQ(700, boldItalic->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, boldItalic->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kBoldItalic, boldItalic->getAPIStyle());
}
TEST(TypefaceTest, createRelativeTest_fromSpecifiedStyled) {
@@ -270,27 +270,27 @@ TEST(TypefaceTest, createRelativeTest_fromSpecifiedStyled) {
// .setWeight(700).setItalic(false).build();
// Typeface.create(typeface, Typeface.NORMAL);
std::unique_ptr<Typeface> normal(Typeface::createRelative(base.get(), Typeface::kNormal));
- EXPECT_EQ(400, normal->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, normal->fStyle.slant());
- EXPECT_EQ(Typeface::kNormal, normal->fAPIStyle);
+ EXPECT_EQ(400, normal->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, normal->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kNormal, normal->getAPIStyle());
// In Java,
// Typeface typeface = new Typeface.Builder(invalid).setFallback("sans-serif")
// .setWeight(700).setItalic(false).build();
// Typeface.create(typeface, Typeface.BOLD);
std::unique_ptr<Typeface> bold(Typeface::createRelative(base.get(), Typeface::kBold));
- EXPECT_EQ(700, bold->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, bold->fStyle.slant());
- EXPECT_EQ(Typeface::kBold, bold->fAPIStyle);
+ EXPECT_EQ(700, bold->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, bold->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kBold, bold->getAPIStyle());
// In Java,
// Typeface typeface = new Typeface.Builder(invalid).setFallback("sans-serif")
// .setWeight(700).setItalic(false).build();
// Typeface.create(typeface, Typeface.ITALIC);
std::unique_ptr<Typeface> italic(Typeface::createRelative(base.get(), Typeface::kItalic));
- EXPECT_EQ(400, italic->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, italic->fStyle.slant());
- EXPECT_EQ(Typeface::kItalic, italic->fAPIStyle);
+ EXPECT_EQ(400, italic->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, italic->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kItalic, italic->getAPIStyle());
// In Java,
// Typeface typeface = new Typeface.Builder(invalid).setFallback("sans-serif")
@@ -298,9 +298,9 @@ TEST(TypefaceTest, createRelativeTest_fromSpecifiedStyled) {
// Typeface.create(typeface, Typeface.BOLD_ITALIC);
std::unique_ptr<Typeface> boldItalic(
Typeface::createRelative(base.get(), Typeface::kBoldItalic));
- EXPECT_EQ(700, boldItalic->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, boldItalic->fStyle.slant());
- EXPECT_EQ(Typeface::kBoldItalic, boldItalic->fAPIStyle);
+ EXPECT_EQ(700, boldItalic->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, boldItalic->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kBoldItalic, boldItalic->getAPIStyle());
}
TEST(TypefaceTest, createAbsolute) {
@@ -309,45 +309,45 @@ TEST(TypefaceTest, createAbsolute) {
// Typeface.Builder(invalid).setFallback("sans-serif").setWeight(400).setItalic(false)
// .build();
std::unique_ptr<Typeface> regular(Typeface::createAbsolute(nullptr, 400, false));
- EXPECT_EQ(400, regular->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, regular->fStyle.slant());
- EXPECT_EQ(Typeface::kNormal, regular->fAPIStyle);
+ EXPECT_EQ(400, regular->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, regular->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kNormal, regular->getAPIStyle());
// In Java,
// new
// Typeface.Builder(invalid).setFallback("sans-serif").setWeight(700).setItalic(false)
// .build();
std::unique_ptr<Typeface> bold(Typeface::createAbsolute(nullptr, 700, false));
- EXPECT_EQ(700, bold->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, bold->fStyle.slant());
- EXPECT_EQ(Typeface::kBold, bold->fAPIStyle);
+ EXPECT_EQ(700, bold->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, bold->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kBold, bold->getAPIStyle());
// In Java,
// new
// Typeface.Builder(invalid).setFallback("sans-serif").setWeight(400).setItalic(true)
// .build();
std::unique_ptr<Typeface> italic(Typeface::createAbsolute(nullptr, 400, true));
- EXPECT_EQ(400, italic->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, italic->fStyle.slant());
- EXPECT_EQ(Typeface::kItalic, italic->fAPIStyle);
+ EXPECT_EQ(400, italic->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, italic->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kItalic, italic->getAPIStyle());
// In Java,
// new
// Typeface.Builder(invalid).setFallback("sans-serif").setWeight(700).setItalic(true)
// .build();
std::unique_ptr<Typeface> boldItalic(Typeface::createAbsolute(nullptr, 700, true));
- EXPECT_EQ(700, boldItalic->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, boldItalic->fStyle.slant());
- EXPECT_EQ(Typeface::kBoldItalic, boldItalic->fAPIStyle);
+ EXPECT_EQ(700, boldItalic->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, boldItalic->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kBoldItalic, boldItalic->getAPIStyle());
// In Java,
// new
// Typeface.Builder(invalid).setFallback("sans-serif").setWeight(1100).setItalic(true)
// .build();
std::unique_ptr<Typeface> over1000(Typeface::createAbsolute(nullptr, 1100, false));
- EXPECT_EQ(1000, over1000->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, over1000->fStyle.slant());
- EXPECT_EQ(Typeface::kBold, over1000->fAPIStyle);
+ EXPECT_EQ(1000, over1000->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, over1000->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kBold, over1000->getAPIStyle());
}
TEST(TypefaceTest, createFromFamilies_Single) {
@@ -355,43 +355,43 @@ TEST(TypefaceTest, createFromFamilies_Single) {
// Typeface.Builder("Roboto-Regular.ttf").setWeight(400).setItalic(false).build();
std::unique_ptr<Typeface> regular(Typeface::createFromFamilies(
makeSingleFamlyVector(kRobotoVariable), 400, false, nullptr /* fallback */));
- EXPECT_EQ(400, regular->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, regular->fStyle.slant());
- EXPECT_EQ(Typeface::kNormal, regular->fAPIStyle);
+ EXPECT_EQ(400, regular->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, regular->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kNormal, regular->getAPIStyle());
// In Java, new
// Typeface.Builder("Roboto-Regular.ttf").setWeight(700).setItalic(false).build();
std::unique_ptr<Typeface> bold(Typeface::createFromFamilies(
makeSingleFamlyVector(kRobotoVariable), 700, false, nullptr /* fallback */));
- EXPECT_EQ(700, bold->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, bold->fStyle.slant());
- EXPECT_EQ(Typeface::kBold, bold->fAPIStyle);
+ EXPECT_EQ(700, bold->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, bold->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kBold, bold->getAPIStyle());
// In Java, new
// Typeface.Builder("Roboto-Regular.ttf").setWeight(400).setItalic(true).build();
std::unique_ptr<Typeface> italic(Typeface::createFromFamilies(
makeSingleFamlyVector(kRobotoVariable), 400, true, nullptr /* fallback */));
- EXPECT_EQ(400, italic->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, italic->fStyle.slant());
- EXPECT_EQ(Typeface::kItalic, italic->fAPIStyle);
+ EXPECT_EQ(400, italic->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, italic->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kItalic, italic->getAPIStyle());
// In Java,
// new
// Typeface.Builder("Roboto-Regular.ttf").setWeight(700).setItalic(true).build();
std::unique_ptr<Typeface> boldItalic(Typeface::createFromFamilies(
makeSingleFamlyVector(kRobotoVariable), 700, true, nullptr /* fallback */));
- EXPECT_EQ(700, boldItalic->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, boldItalic->fStyle.slant());
- EXPECT_EQ(Typeface::kItalic, italic->fAPIStyle);
+ EXPECT_EQ(700, boldItalic->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, boldItalic->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kItalic, italic->getAPIStyle());
// In Java,
// new
// Typeface.Builder("Roboto-Regular.ttf").setWeight(1100).setItalic(false).build();
std::unique_ptr<Typeface> over1000(Typeface::createFromFamilies(
makeSingleFamlyVector(kRobotoVariable), 1100, false, nullptr /* fallback */));
- EXPECT_EQ(1000, over1000->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, over1000->fStyle.slant());
- EXPECT_EQ(Typeface::kBold, over1000->fAPIStyle);
+ EXPECT_EQ(1000, over1000->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, over1000->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kBold, over1000->getAPIStyle());
}
TEST(TypefaceTest, createFromFamilies_Single_resolveByTable) {
@@ -399,33 +399,33 @@ TEST(TypefaceTest, createFromFamilies_Single_resolveByTable) {
std::unique_ptr<Typeface> regular(
Typeface::createFromFamilies(makeSingleFamlyVector(kRegularFont), RESOLVE_BY_FONT_TABLE,
RESOLVE_BY_FONT_TABLE, nullptr /* fallback */));
- EXPECT_EQ(400, regular->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, regular->fStyle.slant());
- EXPECT_EQ(Typeface::kNormal, regular->fAPIStyle);
+ EXPECT_EQ(400, regular->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, regular->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kNormal, regular->getAPIStyle());
// In Java, new Typeface.Builder("Family-Bold.ttf").build();
std::unique_ptr<Typeface> bold(
Typeface::createFromFamilies(makeSingleFamlyVector(kBoldFont), RESOLVE_BY_FONT_TABLE,
RESOLVE_BY_FONT_TABLE, nullptr /* fallback */));
- EXPECT_EQ(700, bold->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, bold->fStyle.slant());
- EXPECT_EQ(Typeface::kBold, bold->fAPIStyle);
+ EXPECT_EQ(700, bold->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, bold->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kBold, bold->getAPIStyle());
// In Java, new Typeface.Builder("Family-Italic.ttf").build();
std::unique_ptr<Typeface> italic(
Typeface::createFromFamilies(makeSingleFamlyVector(kItalicFont), RESOLVE_BY_FONT_TABLE,
RESOLVE_BY_FONT_TABLE, nullptr /* fallback */));
- EXPECT_EQ(400, italic->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, italic->fStyle.slant());
- EXPECT_EQ(Typeface::kItalic, italic->fAPIStyle);
+ EXPECT_EQ(400, italic->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, italic->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kItalic, italic->getAPIStyle());
// In Java, new Typeface.Builder("Family-BoldItalic.ttf").build();
std::unique_ptr<Typeface> boldItalic(Typeface::createFromFamilies(
makeSingleFamlyVector(kBoldItalicFont), RESOLVE_BY_FONT_TABLE, RESOLVE_BY_FONT_TABLE,
nullptr /* fallback */));
- EXPECT_EQ(700, boldItalic->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, boldItalic->fStyle.slant());
- EXPECT_EQ(Typeface::kItalic, italic->fAPIStyle);
+ EXPECT_EQ(700, boldItalic->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::ITALIC, boldItalic->getFontStyle().slant());
+ EXPECT_EQ(Typeface::kItalic, italic->getAPIStyle());
}
TEST(TypefaceTest, createFromFamilies_Family) {
@@ -435,8 +435,8 @@ TEST(TypefaceTest, createFromFamilies_Family) {
std::unique_ptr<Typeface> typeface(
Typeface::createFromFamilies(std::move(families), RESOLVE_BY_FONT_TABLE,
RESOLVE_BY_FONT_TABLE, nullptr /* fallback */));
- EXPECT_EQ(400, typeface->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, typeface->fStyle.slant());
+ EXPECT_EQ(400, typeface->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, typeface->getFontStyle().slant());
}
TEST(TypefaceTest, createFromFamilies_Family_withoutRegular) {
@@ -445,8 +445,8 @@ TEST(TypefaceTest, createFromFamilies_Family_withoutRegular) {
std::unique_ptr<Typeface> typeface(
Typeface::createFromFamilies(std::move(families), RESOLVE_BY_FONT_TABLE,
RESOLVE_BY_FONT_TABLE, nullptr /* fallback */));
- EXPECT_EQ(700, typeface->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, typeface->fStyle.slant());
+ EXPECT_EQ(700, typeface->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, typeface->getFontStyle().slant());
}
TEST(TypefaceTest, createFromFamilies_Family_withFallback) {
@@ -458,8 +458,8 @@ TEST(TypefaceTest, createFromFamilies_Family_withFallback) {
std::unique_ptr<Typeface> regular(
Typeface::createFromFamilies(makeSingleFamlyVector(kRegularFont), RESOLVE_BY_FONT_TABLE,
RESOLVE_BY_FONT_TABLE, fallback.get()));
- EXPECT_EQ(400, regular->fStyle.weight());
- EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, regular->fStyle.slant());
+ EXPECT_EQ(400, regular->getFontStyle().weight());
+ EXPECT_EQ(minikin::FontStyle::Slant::UPRIGHT, regular->getFontStyle().slant());
}
} // namespace