bool LocalizedStringTableLoader::Load(const UknString& file, LocalizedStringTable& stringTable) { ukn::ConfigParserPtr parser = ukn::ConfigParser::MakeParser(ukn::ResourceLoader::Instance().loadResource(file)); if(parser && parser->toNode(L"strings")) { parser->toFirstChild(); do { UknString lanName = parser->getCurrentNodeName(); if(!lanName.empty()) { stringTable.addLanguage(lanName); parser->toFirstChild(); do { UknString stringId = parser->getCurrentNodeName(); if(!stringId.empty()) { UknString value = parser->getString(L"value"); stringTable.addString(lanName, stringId, value); } } while(parser->toNextChild()); parser->toParent(); } } while(parser->toNextChild()); return true; } return false; }
bool Font::deserialize(const ConfigParserPtr& config) { mGlyphs.clear(); if(config && config->toNode(L"font")) { UknString font_name = config->getString(L"name"); if(!font_name.empty()) { UknString fullFontPath = Path::CheckAndGetFontPath(font_name); if(fullFontPath.empty()) { log_error(L"ukn::Font::deserialize: error finding font name " + font_name); return false; } ResourcePtr fontResource = ResourceLoader::Instance().loadResource(fullFontPath); if(fontResource && fontResource->getResourceStream()) { bool result = mFace->load(fontResource); if(result) { mGlyphs.resize(mFace->face->num_glyphs); for(int i = 0; i < mFace->face->num_glyphs; ++i) { mGlyphs[i].size = mFontSize; mGlyphs[i].face = &mFace->face; } } } } mEnableShadow = config->getBool(L"shadow", false); mEnableStroke = config->getBool(L"stroke", false); if(config->getBool(L"bold", false)) { this->setFTStyle(FT_STYLE_FLAG_BOLD); } if(config->getBool(L"italic", false)) { this->setFTStyle(FT_STYLE_FLAG_ITALIC); } mShadowXOffset = config->getInt(L"shadow_offset_x", 0); mShadowYOffset = config->getInt(L"shadow_offset_y", 0); mStrokeWidth = config->getInt(L"stroke_width", 0); mFontSize = config->getInt(L"size", 14); mFontName = font_name; config->toParent(); return true; } return false; }