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

のねのBlog

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

addFont

6.0.0_r1

    103 bool FontFamily::addFont(MinikinFont* typeface) {
    104     AutoMutex _l(gMinikinLock);
    105     const uint32_t os2Tag = MinikinFont::MakeTag('O', 'S', '/', '2');
    106     size_t os2Size = 0;
    107     bool ok = typeface->GetTable(os2Tag, NULL, &os2Size);
    108     if (!ok) return false;
    109     UniquePtr<uint8_t[]> os2Data(new uint8_t[os2Size]);
    110     ok = typeface->GetTable(os2Tag, os2Data.get(), &os2Size);
    111     if (!ok) return false;
    112     int weight;
    113     bool italic;
    114     if (analyzeStyle(os2Data.get(), os2Size, &weight, &italic)) {
    115         //ALOGD("analyzed weight = %d, italic = %s", weight, italic ? "true" : "false");
    116         FontStyle style(weight, italic);
    117         addFontLocked(typeface, style);
    118         return true;
    119     } else {
    120         ALOGD("failed to analyze style");
    121     }
    122     return false;
    123 }

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

     81 bool MinikinFontSkia::GetTable(uint32_t tag, uint8_t *buf, size_t *size) {
     82     if (buf == NULL) {
     83         const size_t tableSize = mTypeface->getTableSize(tag);
     84         *size = tableSize;
     85         return tableSize != 0;
     86     } else {
     87         const size_t actualSize = mTypeface->getTableData(tag, 0, *size, buf);
     88         *size = actualSize;
     89         return actualSize != 0;
     90     }
     91 }

Cross Reference: /frameworks/base/core/jni/android/graphics/MinikinSkia.cpp

    61 bool MinikinFontFreeType::GetTable(uint32_t tag, uint8_t *buf, size_t *size) {
     62 	FT_ULong ftsize = *size;
     63 	FT_Error error = FT_Load_Sfnt_Table(mTypeface, tag, 0, buf, &ftsize);
     64 	if (error != 0) {
     65 		return false;
     66 	}
     67 	*size = ftsize;
     68 	return true;