mirror of
https://github.com/mapnik/mapnik.git
synced 2025-12-08 20:13:09 +00:00
fix and doc out behavior of register_fonts
This commit is contained in:
parent
9964eefb55
commit
bfc92a469c
@ -242,7 +242,18 @@ class MAPNIK_DECL freetype_engine
|
||||
{
|
||||
public:
|
||||
static bool is_font_file(std::string const& file_name);
|
||||
|
||||
/*! \brief register a font file
|
||||
* @param file_name path to a font file.
|
||||
* @return bool - true if at least one face was successfully registered in the file.
|
||||
*/
|
||||
static bool register_font(std::string const& file_name);
|
||||
|
||||
/*! \brief register a font file
|
||||
* @param file_name - path to a directory containing fonts or subdirectories.
|
||||
* @param recurse - default false, whether to search for fonts in sub directories.
|
||||
* @return bool - true if at least one face was successfully registered.
|
||||
*/
|
||||
static bool register_fonts(std::string const& dir, bool recurse = false);
|
||||
static std::vector<std::string> face_names();
|
||||
static std::map<std::string,std::pair<int,std::string> > const& get_mapping();
|
||||
|
||||
@ -134,13 +134,14 @@ bool freetype_engine::register_font(std::string const& file_name)
|
||||
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)
|
||||
@ -152,7 +153,10 @@ bool freetype_engine::register_fonts(std::string const& dir, bool recurse)
|
||||
#endif
|
||||
if (boost::filesystem::is_directory(*itr) && recurse)
|
||||
{
|
||||
success = register_fonts(file_name, true);
|
||||
if (register_fonts(file_name, true))
|
||||
{
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -165,7 +169,10 @@ bool freetype_engine::register_fonts(std::string const& dir, bool recurse)
|
||||
boost::filesystem::is_regular_file(file_name) &&
|
||||
is_font_file(file_name))
|
||||
{
|
||||
success = mapnik::freetype_engine::register_font(file_name);
|
||||
if (mapnik::freetype_engine::register_font(file_name))
|
||||
{
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user