am faf26d17: Minikin: Remove unused variables, fix init order
* commit 'faf26d176f220c5fa00c20085b764346c998405e': Minikin: Remove unused variables, fix init order
This commit is contained in:
@@ -141,7 +141,8 @@ public:
|
|||||||
MinikinFont* getFont(size_t index) const;
|
MinikinFont* getFont(size_t index) const;
|
||||||
FontStyle getStyle(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();
|
const SparseBitSet* getCoverage();
|
||||||
private:
|
private:
|
||||||
void addFontLocked(MinikinFont* typeface, FontStyle style);
|
void addFontLocked(MinikinFont* typeface, FontStyle style);
|
||||||
|
|||||||
@@ -53,8 +53,12 @@ FontCollection::FontCollection(const vector<FontFamily*>& typefaces) :
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
family->RefLocked();
|
family->RefLocked();
|
||||||
mFamilies.push_back(family); // emplace_back would be better
|
|
||||||
const SparseBitSet* coverage = family->getCoverage();
|
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());
|
mMaxChar = max(mMaxChar, coverage->length());
|
||||||
lastChar.push_back(coverage->nextSetBit(0));
|
lastChar.push_back(coverage->nextSetBit(0));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -191,10 +191,18 @@ const SparseBitSet* FontFamily::getCoverage() {
|
|||||||
MinikinFont* typeface = getClosestMatch(defaultStyle).font;
|
MinikinFont* typeface = getClosestMatch(defaultStyle).font;
|
||||||
const uint32_t cmapTag = MinikinFont::MakeTag('c', 'm', 'a', 'p');
|
const uint32_t cmapTag = MinikinFont::MakeTag('c', 'm', 'a', 'p');
|
||||||
size_t cmapSize = 0;
|
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]);
|
UniquePtr<uint8_t[]> cmapData(new uint8_t[cmapSize]);
|
||||||
ok = typeface->GetTable(cmapTag, cmapData.get(), &cmapSize);
|
if (!typeface->GetTable(cmapTag, cmapData.get(), &cmapSize)) {
|
||||||
CmapCoverage::getCoverage(mCoverage, 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
|
#ifdef VERBOSE_DEBUG
|
||||||
ALOGD("font coverage length=%d, first ch=%x\n", mCoverage->length(),
|
ALOGD("font coverage length=%d, first ch=%x\n", mCoverage->length(),
|
||||||
mCoverage->nextSetBit(0));
|
mCoverage->nextSetBit(0));
|
||||||
|
|||||||
@@ -77,11 +77,11 @@ class LayoutCacheKey {
|
|||||||
public:
|
public:
|
||||||
LayoutCacheKey(const FontCollection* collection, const MinikinPaint& paint, FontStyle style,
|
LayoutCacheKey(const FontCollection* collection, const MinikinPaint& paint, FontStyle style,
|
||||||
const uint16_t* chars, size_t start, size_t count, size_t nchars, bool dir)
|
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),
|
mSize(paint.size), mScaleX(paint.scaleX), mSkewX(paint.skewX),
|
||||||
mLetterSpacing(paint.letterSpacing),
|
mLetterSpacing(paint.letterSpacing),
|
||||||
mPaintFlags(paint.paintFlags), mIsRtl(dir),
|
mPaintFlags(paint.paintFlags), mIsRtl(dir) {
|
||||||
mChars(chars), mNchars(nchars) {
|
|
||||||
}
|
}
|
||||||
bool operator==(const LayoutCacheKey &other) const;
|
bool operator==(const LayoutCacheKey &other) const;
|
||||||
hash_t hash() 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_Set_Pixel_Sizes(mTypeface, 0, paint.size);
|
||||||
FT_UInt32 flags = FT_LOAD_DEFAULT; // TODO: respect hinting settings
|
FT_UInt32 flags = FT_LOAD_DEFAULT; // TODO: respect hinting settings
|
||||||
FT_Fixed advance;
|
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);
|
return advance * (1.0 / 65536);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,8 +55,6 @@ FontCollection *makeFontCollection() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
FontFamily *family = new FontFamily();
|
FontFamily *family = new FontFamily();
|
||||||
FT_Face face;
|
|
||||||
FT_Error error;
|
|
||||||
for (size_t i = 0; i < sizeof(fns)/sizeof(fns[0]); i++) {
|
for (size_t i = 0; i < sizeof(fns)/sizeof(fns[0]); i++) {
|
||||||
const char *fn = fns[i];
|
const char *fn = fns[i];
|
||||||
SkTypeface *skFace = SkTypeface::CreateFromFile(fn);
|
SkTypeface *skFace = SkTypeface::CreateFromFile(fn);
|
||||||
@@ -118,7 +116,6 @@ int runMinikinTest() {
|
|||||||
Layout layout;
|
Layout layout;
|
||||||
layout.setFontCollection(collection);
|
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 *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;
|
int bidiFlags = 0;
|
||||||
FontStyle fontStyle(7);
|
FontStyle fontStyle(7);
|
||||||
MinikinPaint minikinPaint;
|
MinikinPaint minikinPaint;
|
||||||
|
|||||||
Reference in New Issue
Block a user