Merge branch 'master' into custom-variant-2

This commit is contained in:
artemp 2014-08-12 10:41:58 +01:00
commit e5c316ae0b
24 changed files with 460 additions and 17 deletions

View file

@ -53,6 +53,6 @@ before_script:
script:
- if [[ ${BENCHMARK} != False ]]; then make bench; fi;
# install some exotic fonts to ensure we don't crash registering them
- sudo apt-get install ttf-wqy-microhei
- source localize.sh
- python -c "import mapnik;mapnik.logger.set_severity(mapnik.severity_type.Debug);mapnik.register_fonts('/usr/share/fonts/');mapnik.register_fonts('/usr/share/fonts/');print '\n'.join(list(mapnik.FontEngine.instance().face_names()))"
#- sudo apt-get install ttf-wqy-microhei
#- source localize.sh
#- python -c "import mapnik;mapnik.logger.set_severity(mapnik.severity_type.Debug);mapnik.register_fonts('/usr/share/fonts/');mapnik.register_fonts('/usr/share/fonts/');print '\n'.join(list(mapnik.FontEngine.instance().face_names()))"

View file

@ -111,11 +111,6 @@ unsigned long ft_read_cb(FT_Stream stream, unsigned long offset, unsigned char *
return std::fread ((char*)buffer, 1, count, file);
}
void ft_close_cb(FT_Stream stream)
{
std::fclose (static_cast<std::FILE *>(stream->descriptor.pointer));
}
bool freetype_engine::register_font(std::string const& file_name)
{
#ifdef MAPNIK_THREADSAFE
@ -138,7 +133,6 @@ bool freetype_engine::register_font_impl(std::string const& file_name, FT_Librar
#else
FILE * file = std::fopen(file_name.c_str(),"rb");
#endif
if (file == nullptr) return false;
FT_Face face = 0;
@ -154,7 +148,7 @@ bool freetype_engine::register_font_impl(std::string const& file_name, FT_Librar
streamRec.size = file_size;
streamRec.descriptor.pointer = file;
streamRec.read = ft_read_cb;
streamRec.close = ft_close_cb;
streamRec.close = NULL;
args.flags = FT_OPEN_STREAM;
args.stream = &streamRec;
int num_faces = 0;
@ -192,11 +186,11 @@ bool freetype_engine::register_font_impl(std::string const& file_name, FT_Librar
s << "which reports a family name of '" << std::string(face->family_name) << "' and lacks a style name";
else if (face->style_name)
s << "which reports a style name of '" << std::string(face->style_name) << "' and lacks a family name";
MAPNIK_LOG_ERROR(font_engine_freetype) << "register_font: " << s.str();
}
if (face) FT_Done_Face(face);
}
std::fclose(file);
return success;
}

View file

@ -22,7 +22,7 @@ int main(int argc, char** argv)
try
{
mapnik::logger logger;
logger.set_severity(mapnik::logger::none);
mapnik::logger::severity_type original_severity = logger.get_severity();
BOOST_TEST(set_working_dir(args));
@ -44,6 +44,8 @@ int main(int argc, char** argv)
BOOST_TEST( face_names.size() == 0 );
// directories without fonts
// silence warnings here by altering the logging severity
logger.set_severity(mapnik::logger::none);
std::string src("src");
// an empty directory will not return true
// we need to register at least one font and not fail on any
@ -61,31 +63,50 @@ int main(int argc, char** argv)
BOOST_TEST( mapnik::freetype_engine::register_fonts("tests/data/fonts/intentionally-broken.ttf") == false );
BOOST_TEST( mapnik::freetype_engine::face_names().size() == 0 );
// now restore the original severity
logger.set_severity(original_severity);
// register unifont, since we know it sits in the root fonts/ dir
BOOST_TEST( mapnik::freetype_engine::register_fonts(fontdir) );
face_names = mapnik::freetype_engine::face_names();
//std::clog << "number of registered fonts: " << face_names.size() << std::endl;
BOOST_TEST( face_names.size() > 0 );
BOOST_TEST( face_names.size() == 1 );
// re-register unifont, should not have any affect
BOOST_TEST( mapnik::freetype_engine::register_fonts(fontdir, false) );
face_names = mapnik::freetype_engine::face_names();
//std::clog << "number of registered fonts: " << face_names.size() << std::endl;
BOOST_TEST( face_names.size() == 1 );
// register a single dejavu font
std::string dejavu_bold_oblique("tests/data/fonts/DejaVuSansMono-BoldOblique.ttf");
BOOST_TEST( mapnik::freetype_engine::register_font(dejavu_bold_oblique) );
face_names = mapnik::freetype_engine::face_names();
//std::clog << "number of registered fonts: " << face_names.size() << std::endl;
BOOST_TEST( face_names.size() == 2 );
// recurse to find all dejavu fonts
BOOST_TEST( mapnik::freetype_engine::register_fonts(fontdir, true) );
face_names = mapnik::freetype_engine::face_names();
//std::clog << "number of registered fonts: " << face_names.size() << std::endl;
BOOST_TEST( face_names.size() == 22 );
// check that we can correctly read a .ttc containing
// multiple valid faces
// https://github.com/mapnik/mapnik/issues/2274
BOOST_TEST( mapnik::freetype_engine::register_font("tests/data/fonts/NotoSans-Regular.ttc") );
face_names = mapnik::freetype_engine::face_names();
BOOST_TEST( face_names.size() == 24 );
// now blindly register as many system fonts as possible
// the goal here to make sure we don't crash
// linux
mapnik::freetype_engine::register_fonts("/usr/share/fonts/", true);
mapnik::freetype_engine::register_fonts("/usr/local/share/fonts/", true);
// osx
mapnik::freetype_engine::register_fonts("/Library/Fonts/", true);
mapnik::freetype_engine::register_fonts("/System/Library/Fonts/", true);
// windows
mapnik::freetype_engine::register_fonts("C:\\Windows\\Fonts", true);
face_names = mapnik::freetype_engine::face_names();
BOOST_TEST( face_names.size() > 22 );
}
catch (std::exception const & ex)
{

View file

@ -1 +1,3 @@
XB Fonts.ttf from http://wiki.irmug.org/index.php/X_Series_2
XB Fonts.ttf from http://wiki.irmug.org/index.php/X_Series_2
NotoSans-Regular.tcc is Apache License Version 2.0: https://code.google.com/p/noto/source/browse/LICENSE

Binary file not shown.

View file

@ -0,0 +1,157 @@
{
"keys": [
"",
"1",
"2",
"3",
"5",
"7",
"8",
"9",
"10",
"11",
"13",
"15",
"16",
"17",
"18",
"19",
"21",
"22",
"23",
"25",
"26",
"27",
"29",
"30",
"31"
],
"data": {},
"grid": [
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" !!!### $$$ %%% &&''' ",
" !!!##### $$$$$ %%%%% &&''''' ",
" !!!##### $$$$$ %%%%% &&''''' ",
" !!!##### $$$$$ %%%%% &&''''' ",
" !!!### $$$ %%% &&'''' ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" (()))) **** ++++ ,,,---- ",
" ((())))) ***** +++++ ,,----- ",
" ((())))) ***** +++++ ,,----- ",
" (())))) ***** +++++ ,,,---- ",
" (())) *** +++ ,,,-- ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" .../// 000 11222 333 ",
" ...///// 00000 1122222 33333 ",
" ...///// 00000 1122222 33333 ",
" ...///// 00000 1122222 33333 ",
" .../// 000 112222 333 ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" 445555 6666 7778888 9999 ",
" 44455555 66666 7788888 99999 ",
" 44455555 66666 7788888 99999 ",
" 4455555 66666 7778888 99999 ",
" 44555 666 77788 999 ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
]
}

View file

@ -0,0 +1,145 @@
{
"keys": [
"",
"2",
"1",
"3",
"5",
"8",
"7",
"10",
"9",
"11",
"13",
"16",
"15"
],
"data": {},
"grid": [
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" !#!!#!!! $ $$ $$ % %%%%% &&&'&&&' ",
" #! #! ! $$ $$$ %% %%% '& &''& ",
" ! !# # $ $$ $ % %% % && &'& ' ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ()(()((( * ** ** + + ++ , ,-,,,- ",
" ( (( ** *** ++ +++ ,, ,--, ",
" )))) ( ** ** ++ ++ ,, ,-, ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

View file

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Map>
<Map background-color="white" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
<FontSet name="book">
<Font face-name="DejaVu Sans Book"/>
</FontSet>
<Layer name="layer" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
<StyleName>My Style</StyleName>
<Datasource>
<Parameter name="type">csv</Parameter>
<Parameter name="inline">
lat,long,overlap,placement
0.33,-0.36,noexpr-true,noexpr-false
0.33,-0.34,noexpr-true,noexpr-false
0.33,-0.13,noexpr-false,noexpr-false
0.33,-0.11,noexpr-false,noexpr-false
0.33, 0.10,noexpr-true,noexpr-false
0.33, 0.12,noexpr-false,noexpr-false
0.33, 0.34,noexpr-false,noexpr-false
0.33, 0.36,noexpr-true,noexpr-false
0.11,-0.36,true,false
0.11,-0.34,true,false
0.11,-0.13,false,false
0.11,-0.11,false,false
0.11, 0.10,true,false
0.11, 0.12,false,false
0.11, 0.34,false,false
0.11, 0.36,true,false
-0.11,-0.36,noexpr-false,noexpr-true
-0.11,-0.34,noexpr-false,noexpr-true
-0.11,-0.13,noexpr-false,noexpr-false
-0.11,-0.11,noexpr-false,noexpr-false
-0.11, 0.10,noexpr-false,noexpr-true
-0.11, 0.12,noexpr-false,noexpr-false
-0.11, 0.34,noexpr-false,noexpr-false
-0.11, 0.36,noexpr-false,noexpr-true
-0.33,-0.36,false,true
-0.33,-0.34,false,true
-0.33,-0.13,false,false
-0.33,-0.11,false,false
-0.33, 0.10,false,true
-0.33, 0.12,false,false
-0.33, 0.34,false,false
-0.33, 0.36,false,true
</Parameter>
</Datasource>
</Layer>
<Style name="My Style" filter-mode="first">
<Rule>
<Filter>[overlap] = "noexpr-true" and [placement] = "noexpr-true"</Filter>
<PointSymbolizer allow-overlap="true" ignore-placement="true" file="../../data/svg/point_sm.svg" />
</Rule>
<Rule>
<Filter>[overlap] = "noexpr-true" and [placement] = "noexpr-false"</Filter>
<PointSymbolizer allow-overlap="true" ignore-placement="false" file="../../data/svg/point_sm.svg" />
</Rule>
<Rule>
<Filter>[overlap] = "noexpr-false" and [placement] = "noexpr-false"</Filter>
<PointSymbolizer allow-overlap="false" ignore-placement="false" file="../../data/svg/point_sm.svg" />
</Rule>
<Rule>
<Filter>[overlap] = "noexpr-false" and [placement] = "noexpr-true"</Filter>
<PointSymbolizer allow-overlap="false" ignore-placement="true" file="../../data/svg/point_sm.svg" />
</Rule>
<Rule>
<PointSymbolizer allow-overlap="[overlap]" ignore-placement="[placement]" file="../../data/svg/point_sm.svg" />
</Rule>
</Style>
</Map>

View file

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Map>
<Map background-color="white" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
<FontSet name="book">
<Font face-name="DejaVu Sans Book"/>
</FontSet>
<Layer name="layer" srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs">
<StyleName>My Style</StyleName>
<Datasource>
<Parameter name="type">csv</Parameter>
<Parameter name="inline">
lat,long,test,text
0.25,-0.35,noexpr-true,ABC
0.25,-0.35,noexpr-true,XYZ
0.25,-0.12,noexpr-false,ABC
0.25,-0.12,noexpr-false,XYZ
0.25, 0.11,noexpr-true,ABC
0.25, 0.11,noexpr-false,XYZ
0.25, 0.35,noexpr-false,ABC
0.25, 0.35,noexpr-true,XYZ
0 ,-0.35,true,ABC
0 ,-0.35,true,XYZ
0 ,-0.12,false,ABC
0 ,-0.12,false,XYZ
0 , 0.11,true,ABC
0 , 0.11,false,XYZ
0 , 0.35,false,ABC
0 , 0.35,true,XYZ
</Parameter>
</Datasource>
</Layer>
<Style name="My Style" filter-mode="first">
<Rule>
<Filter>[test] = "noexpr-true"</Filter>
<TextSymbolizer fontset-name="book" size="16" placement="point" dx="0" dy="0" allow-overlap="true">[text]</TextSymbolizer>
</Rule>
<Rule>
<Filter>[test] = "noexpr-false"</Filter>
<TextSymbolizer fontset-name="book" size="16" placement="point" dx="0" dy="0" allow-overlap="false">[text]</TextSymbolizer>
</Rule>
<Rule>
<TextSymbolizer fontset-name="book" size="16" placement="point" dx="0" dy="0" allow-overlap="[test]">[text]</TextSymbolizer>
</Rule>
</Style>
</Map>

View file

@ -247,6 +247,7 @@ files = {
'line-symbolizer-expressions-all':{'sizes':[(256,256)]},
'point-symbolizer-expressions':{'sizes':[(256,256)]},
'point-symbolizer-expressions-all':{'sizes':[(256,256)]},
'point-symbolizer-overlap-placement-expr': {'bbox':large_text_box, 'sizes': [(500, 500)]},
'marker-symbolizer-expressions-all':{'sizes':[(256,256)]},
'polygon-symbolizer-expressions':{'sizes':[(256,256)]},
'polygon-symbolizer-expressions-all':{'sizes':[(256,256)]},