のねのBlog

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

weight bold

41 
     42 // Resolve the 1..9 weight based on base weight and bold flag
     43 static void resolveStyle(TypefaceImpl* typeface) {
     44     int weight = typeface->fBaseWeight / 100;
     45     if (typeface->fSkiaStyle & SkTypeface::kBold) {
     46         weight += 3;
     47     }
     48     if (weight > 9) {
     49         weight = 9;
     50     }
     51     bool italic = (typeface->fSkiaStyle & SkTypeface::kItalic) != 0;
     52     typeface->fStyle = FontStyle(weight, italic);
     53 }
     67     FontStyle(int weight = 4, bool italic = false) {
     68         bits = (weight & kWeightMask) | (italic ? kItalicMask : 0);
     69     }
  137 TypefaceImpl* TypefaceImpl_createFromFamilies(const jlong* families, size_t size) {
    138     std::vector<FontFamily *>familyVec;
    139     for (size_t i = 0; i < size; i++) {
    140         FontFamily* family = reinterpret_cast<FontFamily*>(families[i]);
    141         familyVec.push_back(family);
    142     }
    143     TypefaceImpl* result = new TypefaceImpl;
    144     result->fFontCollection = new FontCollection(familyVec);
    145     if (size == 0) {
    146         ALOGW("createFromFamilies creating empty collection");
    147         result->fSkiaStyle = SkTypeface::kNormal;
    148     } else {
    149         const FontStyle defaultStyle;
    150         FontFamily* firstFamily = reinterpret_cast<FontFamily*>(families[0]);
    151         MinikinFont* mf = firstFamily->getClosestMatch(defaultStyle).font;
    152         if (mf != NULL) {
    153             SkTypeface* skTypeface = reinterpret_cast<MinikinFontSkia*>(mf)->GetSkTypeface();
    154             // TODO: probably better to query more precise style from family, will be important
    155             // when we open up API to access 100..900 weights
    156             result->fSkiaStyle = skTypeface->style();
    157         } else {
    158             result->fSkiaStyle = SkTypeface::kNormal;
    159         }
    160     }
    161     result->fBaseWeight = 400;
    162     resolveStyle(result);
    163     return result;
    164 }