bool freetype_engine::register_fonts(std::string const& dir, bool recurse) { boost::filesystem::path path(dir); if (!boost::filesystem::exists(path)) return false; if (!boost::filesystem::is_directory(path)) return mapnik::freetype_engine::register_font(dir); boost::filesystem::directory_iterator end_itr; for (boost::filesystem::directory_iterator itr(dir); itr != end_itr; ++itr) { if (boost::filesystem::is_directory(*itr) && recurse) { #if (BOOST_FILESYSTEM_VERSION == 3) if (!register_fonts(itr->path().string(), true)) return false; #else // v2 if (!register_fonts(itr->string(), true)) return false; #endif } else { #if (BOOST_FILESYSTEM_VERSION == 3) mapnik::freetype_engine::register_font(itr->path().string()); #else // v2 mapnik::freetype_engine::register_font(itr->string()); #endif } } return true; }
bool freetype_engine::register_fonts(std::string const& dir, bool recurse) { boost::filesystem::path path(dir); if (!boost::filesystem::exists(path)) return false; if (!boost::filesystem::is_directory(path)) return mapnik::freetype_engine::register_font(dir); boost::filesystem::directory_iterator end_itr; bool success = false; for (boost::filesystem::directory_iterator itr(dir); itr != end_itr; ++itr) { #if (BOOST_FILESYSTEM_VERSION == 3) std::string const& file_name = itr->path().string(); #else // v2 std::string const& file_name = itr->string(); #endif if (boost::filesystem::is_directory(*itr) && recurse) { success = register_fonts(file_name, true); } else if (boost::filesystem::is_regular_file(file_name) && is_font_file(file_name)) { success = mapnik::freetype_engine::register_font(file_name); } } return success; }
bool freetype_engine::register_fonts(std::string const& dir, bool recurse) { if (!mapnik::util::exists(dir)) { return false; } if (!mapnik::util::is_directory(dir)) { return mapnik::freetype_engine::register_font(dir); } bool success = false; try { boost::filesystem::directory_iterator end_itr; for (boost::filesystem::directory_iterator itr(dir); itr != end_itr; ++itr) { #if (BOOST_FILESYSTEM_VERSION == 3) std::string file_name = itr->path().string(); #else // v2 std::string file_name = itr->string(); #endif if (boost::filesystem::is_directory(*itr) && recurse) { if (register_fonts(file_name, true)) { success = true; } } else { #if (BOOST_FILESYSTEM_VERSION == 3) std::string base_name = itr->path().filename().string(); #else // v2 std::string base_name = itr->filename(); #endif if (!boost::algorithm::starts_with(base_name,".") && boost::filesystem::is_regular_file(file_name) && is_font_file(file_name)) { if (mapnik::freetype_engine::register_font(file_name)) { success = true; } } } } } catch (std::exception const& ex) { MAPNIK_LOG_ERROR(font_engine_freetype) << "register_fonts: " << ex.what(); } return success; }