提交 da094908 编写于 作者: A Andreas Gampe 提交者: Android Git Automerger

am 919fbb99: am cb20a2f0: Minikin: Remove unused variables, fix init order

* commit '919fbb99':
  Minikin: Remove unused variables, fix init order
......@@ -141,7 +141,8 @@ public:
MinikinFont* getFont(size_t index) const;
FontStyle getStyle(size_t index) const;
// Get Unicode coverage. Lifetime of returned bitset is same as receiver.
// Get Unicode coverage. Lifetime of returned bitset is same as receiver. May return nullptr on
// error.
const SparseBitSet* getCoverage();
private:
void addFontLocked(MinikinFont* typeface, FontStyle style);
......
......@@ -53,8 +53,12 @@ FontCollection::FontCollection(const vector<FontFamily*>& typefaces) :
continue;
}
family->RefLocked();
mFamilies.push_back(family); // emplace_back would be better
const SparseBitSet* coverage = family->getCoverage();
if (coverage == nullptr) {
family->UnrefLocked();
continue;
}
mFamilies.push_back(family); // emplace_back would be better
mMaxChar = max(mMaxChar, coverage->length());
lastChar.push_back(coverage->nextSetBit(0));
}
......
......@@ -191,10 +191,18 @@ const SparseBitSet* FontFamily::getCoverage() {
MinikinFont* typeface = getClosestMatch(defaultStyle).font;
const uint32_t cmapTag = MinikinFont::MakeTag('c', 'm', 'a', 'p');
size_t cmapSize = 0;
bool ok = typeface->GetTable(cmapTag, NULL, &cmapSize);
if (!typeface->GetTable(cmapTag, NULL, &cmapSize)) {
ALOGE("Could not get cmap table size!\n");
// Note: This means we will retry on the next call to getCoverage, as we can't store
// the failure. This is fine, as we assume this doesn't really happen in practice.
return nullptr;
}
UniquePtr<uint8_t[]> cmapData(new uint8_t[cmapSize]);
ok = typeface->GetTable(cmapTag, cmapData.get(), &cmapSize);
CmapCoverage::getCoverage(mCoverage, cmapData.get(), cmapSize);
if (!typeface->GetTable(cmapTag, cmapData.get(), &cmapSize)) {
ALOGE("Unexpected failure to read cmap table!\n");
return nullptr;
}
CmapCoverage::getCoverage(mCoverage, cmapData.get(), cmapSize); // TODO: Error check?
#ifdef VERBOSE_DEBUG
ALOGD("font coverage length=%d, first ch=%x\n", mCoverage->length(),
mCoverage->nextSetBit(0));
......
......@@ -77,11 +77,11 @@ class LayoutCacheKey {
public:
LayoutCacheKey(const FontCollection* collection, const MinikinPaint& paint, FontStyle style,
const uint16_t* chars, size_t start, size_t count, size_t nchars, bool dir)
: mStart(start), mCount(count), mId(collection->getId()), mStyle(style),
: mChars(chars), mNchars(nchars),
mStart(start), mCount(count), mId(collection->getId()), mStyle(style),
mSize(paint.size), mScaleX(paint.scaleX), mSkewX(paint.skewX),
mLetterSpacing(paint.letterSpacing),
mPaintFlags(paint.paintFlags), mIsRtl(dir),
mChars(chars), mNchars(nchars) {
mPaintFlags(paint.paintFlags), mIsRtl(dir) {
}
bool operator==(const LayoutCacheKey &other) const;
hash_t hash() const;
......
......@@ -49,7 +49,7 @@ float MinikinFontFreeType::GetHorizontalAdvance(uint32_t glyph_id,
FT_Set_Pixel_Sizes(mTypeface, 0, paint.size);
FT_UInt32 flags = FT_LOAD_DEFAULT; // TODO: respect hinting settings
FT_Fixed advance;
FT_Error error = FT_Get_Advance(mTypeface, glyph_id, flags, &advance);
FT_Get_Advance(mTypeface, glyph_id, flags, &advance);
return advance * (1.0 / 65536);
}
......
......@@ -55,8 +55,6 @@ FontCollection *makeFontCollection() {
};
FontFamily *family = new FontFamily();
FT_Face face;
FT_Error error;
for (size_t i = 0; i < sizeof(fns)/sizeof(fns[0]); i++) {
const char *fn = fns[i];
SkTypeface *skFace = SkTypeface::CreateFromFile(fn);
......@@ -118,7 +116,6 @@ int runMinikinTest() {
Layout layout;
layout.setFontCollection(collection);
const char *text = "fine world \xe0\xa4\xa8\xe0\xa4\xae\xe0\xa4\xb8\xe0\xa5\x8d\xe0\xa4\xa4\xe0\xa5\x87";
const char *style = "font-size: 32; font-weight: 700;";
int bidiFlags = 0;
FontStyle fontStyle(7);
MinikinPaint minikinPaint;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册