+ load all fonts in specified dir
This commit is contained in:
parent
610537b614
commit
424949d312
2 changed files with 55 additions and 52 deletions
|
@ -18,12 +18,20 @@
|
|||
|
||||
//$Id$
|
||||
|
||||
|
||||
// qt
|
||||
#include <QApplication>
|
||||
#include <QStringList>
|
||||
#include <mapnik/datasource_cache.hpp>
|
||||
#include <mapnik/font_engine_freetype.hpp>
|
||||
#include "mainwindow.hpp"
|
||||
// boost
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
|
||||
bool is_font_file (std::string const& filename)
|
||||
{
|
||||
return boost::algorithm::ends_with(filename,std::string(".ttf"));
|
||||
}
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
|
@ -31,31 +39,24 @@ int main( int argc, char **argv )
|
|||
using mapnik::freetype_engine;
|
||||
|
||||
// modify this prefix based on your install location
|
||||
std::string mapniklib = "/usr/local/lib/mapnik/";
|
||||
std::string mapnik_dir = "/opt/mapnik";
|
||||
|
||||
datasource_cache::instance()->register_datasources(mapniklib + "input");
|
||||
datasource_cache::instance()->register_datasources(mapnik_dir + "/lib/mapnik/input");
|
||||
boost::filesystem::path path(mapnik_dir + "/lib/mapnik/fonts");
|
||||
boost::filesystem::directory_iterator end_itr;
|
||||
|
||||
freetype_engine::register_font(mapniklib + "fonts/DejaVuSans-Bold.ttf");
|
||||
freetype_engine::register_font(mapniklib + "fonts/DejaVuSans-BoldOblique.ttf");
|
||||
freetype_engine::register_font(mapniklib + "fonts/DejaVuSans-ExtraLight.ttf");
|
||||
freetype_engine::register_font(mapniklib + "fonts/DejaVuSans-Oblique.ttf");
|
||||
freetype_engine::register_font(mapniklib + "fonts/DejaVuSans.ttf");
|
||||
freetype_engine::register_font(mapniklib + "fonts/DejaVuSansCondensed-Bold.ttf");
|
||||
freetype_engine::register_font(mapniklib + "fonts/DejaVuSansCondensed-BoldOblique.ttf");
|
||||
freetype_engine::register_font(mapniklib + "fonts/DejaVuSansCondensed-Oblique.ttf");
|
||||
freetype_engine::register_font(mapniklib + "fonts/DejaVuSansCondensed.ttf");
|
||||
freetype_engine::register_font(mapniklib + "fonts/DejaVuSansMono-Bold.ttf");
|
||||
freetype_engine::register_font(mapniklib + "fonts/DejaVuSansMono-BoldOblique.ttf");
|
||||
freetype_engine::register_font(mapniklib + "fonts/DejaVuSansMono-Oblique.ttf");
|
||||
freetype_engine::register_font(mapniklib + "fonts/DejaVuSansMono.ttf");
|
||||
freetype_engine::register_font(mapniklib + "fonts/DejaVuSerif-Bold.ttf");
|
||||
freetype_engine::register_font(mapniklib + "fonts/DejaVuSerif-BoldItalic.ttf");
|
||||
freetype_engine::register_font(mapniklib + "fonts/DejaVuSerif-Italic.ttf");
|
||||
freetype_engine::register_font(mapniklib + "fonts/DejaVuSerif.ttf");
|
||||
freetype_engine::register_font(mapniklib + "fonts/DejaVuSerifCondensed-Bold.ttf");
|
||||
freetype_engine::register_font(mapniklib + "fonts/DejaVuSerifCondensed-BoldItalic.ttf");
|
||||
freetype_engine::register_font(mapniklib + "fonts/DejaVuSerifCondensed-Italic.ttf");
|
||||
freetype_engine::register_font(mapniklib + "fonts/DejaVuSerifCondensed.ttf");
|
||||
|
||||
if (boost::filesystem::exists(path) && boost::filesystem::is_directory(path))
|
||||
{
|
||||
for (boost::filesystem::directory_iterator itr(path);itr!=end_itr;++itr )
|
||||
{
|
||||
if (!boost::filesystem::is_directory(*itr) && is_font_file(itr->path().leaf()))
|
||||
{
|
||||
std::cout << "register font " << itr->string() << "\n";
|
||||
freetype_engine::register_font(itr->string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QApplication app( argc, argv );
|
||||
MainWindow window;
|
||||
|
|
|
@ -5,12 +5,14 @@ CC = g++
|
|||
TEMPLATE = app
|
||||
|
||||
INCLUDEPATH += /opt/mapnik/include
|
||||
INCLUDEPATH += /usr/local/include/boost-1_35
|
||||
INCLUDEPATH += /opt/boost/include/boost-1_39
|
||||
INCLUDEPATH += /usr/X11/include/
|
||||
INCLUDEPATH += /usr/X11/include/freetype2
|
||||
INCLUDEPATH += .
|
||||
|
||||
QMAKE_CXXFLAGS +=' -DDARWIN'
|
||||
#QMAKE_CXXFLAGS +=' -DDARWIN'
|
||||
unix:LIBS = -L/opt/mapnik/lib -L/usr/X11/lib -lmapnik -lfreetype -L/usr/local/lib -licuuc
|
||||
unix:LIBS += -lboost_system-xgcc40-mt -lboost_filesystem-xgcc40-mt -L/opt/boost/lib
|
||||
|
||||
# Input
|
||||
|
||||
|
|
Loading…
Reference in a new issue