+ 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,62 +18,63 @@
|
|||
|
||||
//$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 )
|
||||
{
|
||||
using mapnik::datasource_cache;
|
||||
using mapnik::freetype_engine;
|
||||
|
||||
// modify this prefix based on your install location
|
||||
std::string mapniklib = "/usr/local/lib/mapnik/";
|
||||
|
||||
datasource_cache::instance()->register_datasources(mapniklib + "input");
|
||||
|
||||
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");
|
||||
|
||||
QApplication app( argc, argv );
|
||||
MainWindow window;
|
||||
window.show();
|
||||
if (argc > 1) window.open(argv[1]);
|
||||
if (argc == 3)
|
||||
{
|
||||
QStringList list = QString(argv[2]).split(",");
|
||||
if (list.size()==4)
|
||||
{
|
||||
bool ok;
|
||||
double x0 = list[0].toDouble(&ok);
|
||||
double y0 = list[1].toDouble(&ok);
|
||||
double x1 = list[2].toDouble(&ok);
|
||||
double y1 = list[3].toDouble(&ok);
|
||||
if (ok) window.set_default_extent(x0,y0,x1,y1);
|
||||
}
|
||||
}
|
||||
|
||||
return app.exec();
|
||||
using mapnik::datasource_cache;
|
||||
using mapnik::freetype_engine;
|
||||
|
||||
// modify this prefix based on your install location
|
||||
std::string mapnik_dir = "/opt/mapnik";
|
||||
|
||||
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;
|
||||
|
||||
|
||||
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;
|
||||
window.show();
|
||||
if (argc > 1) window.open(argv[1]);
|
||||
if (argc == 3)
|
||||
{
|
||||
QStringList list = QString(argv[2]).split(",");
|
||||
if (list.size()==4)
|
||||
{
|
||||
bool ok;
|
||||
double x0 = list[0].toDouble(&ok);
|
||||
double y0 = list[1].toDouble(&ok);
|
||||
double x1 = list[2].toDouble(&ok);
|
||||
double y1 = list[3].toDouble(&ok);
|
||||
if (ok) window.set_default_extent(x0,y0,x1,y1);
|
||||
}
|
||||
}
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -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