読者です 読者をやめる 読者になる 読者になる

のねのBlog

パソコンやソフト開発で起きた問題など書きます。よろしくお願いします。

Font collection must have at least one valid typeface

Cross Reference: /frameworks/minikin/libs/minikin/FontCollection.cpp

     78 FontCollection::FontCollection(const vector<FontFamily*>& typefaces) :
     79     mMaxChar(0) {
     80     AutoMutex _l(gMinikinLock);
     81     mId = sNextId++;
     82     vector<uint32_t> lastChar;
     83     size_t nTypefaces = typefaces.size();
     84 #ifdef VERBOSE_DEBUG
     85     ALOGD("nTypefaces = %zd\n", nTypefaces);
     86 #endif
     87     const FontStyle defaultStyle;
     88     for (size_t i = 0; i < nTypefaces; i++) {
     89         FontFamily* family = typefaces[i];
     90         MinikinFont* typeface = family->getClosestMatch(defaultStyle).font;
     91         if (typeface == NULL) {
     92             continue;
     93         }
     94         family->RefLocked();
     95         const SparseBitSet* coverage = family->getCoverage();
     96         if (coverage == nullptr) {
     97             family->UnrefLocked();
     98             continue;
     99         }
    100         mFamilies.push_back(family);  // emplace_back would be better
    101         if (family->hasVSTable()) {
    102             mVSFamilyVec.push_back(family);
    103         }
    104         mMaxChar = max(mMaxChar, coverage->length());
    105         lastChar.push_back(coverage->nextSetBit(0));
    106     }
    107     nTypefaces = mFamilies.size();
    108     LOG_ALWAYS_FATAL_IF(nTypefaces == 0,
    109         "Font collection must have at least one valid typeface");
    110     size_t nPages = (mMaxChar + kPageMask) >> kLogCharsPerPage;
    111     size_t offset = 0;
    112     // TODO: Use variation selector map for mRanges construction.
    113     // A font can have a glyph for a base code point and variation selector pair but no glyph for
    114     // the base code point without variation selector. The family won't be listed in the range in
    115     // this case.
    116     for (size_t i = 0; i < nPages; i++) {
    117         Range dummy;
    118         mRanges.push_back(dummy);
    119         Range* range = &mRanges.back();
    120 #ifdef VERBOSE_DEBUG
    121         ALOGD("i=%zd: range start = %zd\n", i, offset);
    122 #endif
    123         range->start = offset;
    124         for (size_t j = 0; j < nTypefaces; j++) {
    125             if (lastChar[j] < (i + 1) << kLogCharsPerPage) {
    126                 FontFamily* family = mFamilies[j];
    127                 mFamilyVec.push_back(family);
    128                 offset++;
    129                 uint32_t nextChar = family->getCoverage()->nextSetBit((i + 1) << kLogCharsPerPage);
    130 #ifdef VERBOSE_DEBUG
    131                 ALOGD("nextChar = %d (j = %zd)\n", nextChar, j);
    132 #endif
    133                 lastChar[j] = nextChar;
    134             }
    135         }
    136         range->end = offset;
    137     }
    138 }

Cross Reference: /system/core/include/log/log.h

   390 /*
    391  * Log a fatal error.  If the given condition fails, this stops program
    392  * execution like a normal assertion, but also generating the given message.
    393  * It is NOT stripped from release builds.  Note that the condition test
    394  * is -inverted- from the normal assert() semantics.
    395  */
    396 #ifndef LOG_ALWAYS_FATAL_IF
    397 #define LOG_ALWAYS_FATAL_IF(cond, ...) \
    398     ( (__predict_false(cond)) \
    399     ? ((void)android_printAssert(#cond, LOG_TAG, ## __VA_ARGS__)) \
    400     : (void)0 )
    401 #endif
    402 
    403 #ifndef LOG_ALWAYS_FATAL
    404 #define LOG_ALWAYS_FATAL(...) \
    405     ( ((void)android_printAssert(NULL, LOG_TAG, ## __VA_ARGS__)) )
    406 #endif