Reference<ResourceContainer*> ResourceSpawnImplementation::createResource(int units) { Reference<ResourceContainer*> newResource = NULL; newResource = (getZoneServer()->createObject(containerCRC, 2)).castTo<ResourceContainer*>(); if(newResource == NULL) { error("Unable to create resource container, using generic. CRC attempted was: " + String::valueOf(containerCRC)); print(); String genericContainer = "object/resource_container/organic_food.iff"; newResource = (getZoneServer()->createObject(genericContainer.hashCode(), 2)).castTo<ResourceContainer*>(); } Locker locker(newResource); newResource->setSpawnObject(_this.getReferenceUnsafeStaticCast()); if (units != 0) newResource->setQuantity(units); newResource->setCustomObjectName(getFamilyName(), false); ++containerReferenceCount; return newResource; }
String IColumn::dumpStructure() const { WriteBufferFromOwnString res; res << getFamilyName() << "(size = " << size(); ColumnCallback callback = [&](ColumnPtr & subcolumn) { res << ", " << subcolumn->dumpStructure(); }; const_cast<IColumn*>(this)->forEachSubcolumn(callback); res << ")"; return res.str(); }
void findFilesByExt(const boost::filesystem::path & folder, const std::string & ext, StringStringMap & found) { if (boost::filesystem::is_directory(folder)) { for(boost::filesystem::directory_iterator itr(folder); itr != boost::filesystem::directory_iterator(); ++itr) { if (boost::algorithm::iequals(boost::filesystem::extension(*itr), ext)) { found[itr->path().stem().string()] = itr->path().string(); getFamilyName(itr->path().string()); } findFilesByExt(*itr, ext, found); } } }
QVector<OsmAnd::TextRasterizer_P::LinePaint> OsmAnd::TextRasterizer_P::evaluatePaints( const QVector<QStringRef>& lineRefs, const Style& style) const { // Prepare default paint SkPaint paint = _defaultPaint; paint.setTextSize(style.size); paint.setColor(style.color.toSkColor()); // Transform text style to font style const SkFontStyle fontStyle( style.bold ? SkFontStyle::kBold_Weight : SkFontStyle::kNormal_Weight, SkFontStyle::kNormal_Width, style.italic ? SkFontStyle::kItalic_Slant : SkFontStyle::kUpright_Slant); const auto pText = lineRefs.first().string()->constData(); QVector<LinePaint> linePaints; linePaints.reserve(lineRefs.count()); for (const auto& lineRef : constOf(lineRefs)) { LinePaint linePaint; linePaint.line = lineRef; TextPaint* pTextPaint = nullptr; const auto pLine = lineRef.constData(); const auto pEnd = pLine + lineRef.size(); auto pNextCharacter = pLine; while (pNextCharacter != pEnd) { const auto pCharacter = pNextCharacter; const auto position = pNextCharacter - pText; const auto characterUCS4 = SkUTF16_NextUnichar(reinterpret_cast<const uint16_t**>(&pNextCharacter)); // First of all check previous font if it contains this character auto font = pTextPaint ? pTextPaint->paint.getTypeface() : nullptr; if (font) { SkPaint paint; paint.setTextEncoding(SkPaint::kUTF32_TextEncoding); paint.setTypeface(font); if (!paint.containsText(&characterUCS4, sizeof(uint32_t))) font = nullptr; #if OSMAND_LOG_CHARACTERS_FONT else { SkString fontName; font->getFamilyName(&fontName); LogPrintf(LogSeverityLevel::Warning, "UCS4 character 0x%08x (%u) has been found in '%s' font (reused)", characterUCS4, characterUCS4, fontName.c_str()); } #endif // OSMAND_LOG_CHARACTERS_FONT } if (!font) { font = owner->fontFinder->findFontForCharacterUCS4(characterUCS4, fontStyle); #if OSMAND_LOG_CHARACTERS_WITHOUT_FONT if (!font) { LogPrintf(LogSeverityLevel::Warning, "UCS4 character 0x%08x (%u) has not been found in any font", characterUCS4, characterUCS4); } #endif // OSMAND_LOG_CHARACTERS_WITHOUT_FONT #if OSMAND_LOG_CHARACTERS_FONT if (font) { SkString fontName; font->getFamilyName(&fontName); LogPrintf(LogSeverityLevel::Warning, "UCS4 character 0x%08x (%u) has been found in '%s' font", characterUCS4, characterUCS4, fontName.c_str()); } #endif // OSMAND_LOG_CHARACTERS_FONT } if (pTextPaint == nullptr || pTextPaint->paint.getTypeface() != font) { linePaint.textPaints.push_back(qMove(TextPaint())); pTextPaint = &linePaint.textPaints.last(); pTextPaint->text = QStringRef(lineRef.string(), position, 1); pTextPaint->paint = paint; pTextPaint->paint.setTypeface(font); SkPaint::FontMetrics metrics; pTextPaint->height = paint.getFontMetrics(&metrics); linePaint.maxFontHeight = qMax(linePaint.maxFontHeight, pTextPaint->height); linePaint.minFontHeight = qMin(linePaint.minFontHeight, pTextPaint->height); linePaint.maxFontLineSpacing = qMax(linePaint.maxFontLineSpacing, metrics.fLeading); linePaint.minFontLineSpacing = qMin(linePaint.minFontLineSpacing, metrics.fLeading); linePaint.maxFontTop = qMax(linePaint.maxFontTop, -metrics.fTop); linePaint.minFontTop = qMin(linePaint.minFontTop, -metrics.fTop); linePaint.maxFontBottom = qMax(linePaint.maxFontBottom, metrics.fBottom); linePaint.minFontBottom = qMin(linePaint.minFontBottom, metrics.fBottom); if (style.bold && (!font || (font && font->fontStyle().weight() <= SkFontStyle::kNormal_Weight))) pTextPaint->paint.setFakeBoldText(true); } else { pTextPaint->text = QStringRef(lineRef.string(), pTextPaint->text.position(), pTextPaint->text.size() + 1); } } linePaints.push_back(qMove(linePaint)); } return linePaints; }