mapnik/mapnik — pull request #2286 by springmeyer (2014-06-26 05:17:32+00:00)
Title: add fontfile lookup on map, memory cache per face_manager

This change creates a new font registry on the `mapnik::map`. This is currently against the 2.3.x branch but I will port to master next.

This is important because:

- We support the `font-directory` property which allows fonts local to an XML to be at loaded
- However, these fonts are currently put in the the global `freetype_engine::name2file_` cache when they instead need to be local to the map
- This creates a problem: a clash is possible when registration of two different font files with a common name is done by two different maps in the same process.

This change also drops the global in-memory font cache completely and moves it to be a member of the `face_manager`. This means that it will be created per renderer/thread and will not persist long term. This has the advantage of not indefinitely growing memory for a process that renders many different fonts over time. Also I benchmarked with and without this change and could not detect a significant benefit to persisting this cache across renders. To detect a benefit I presume you'd need to render a tile with multiple fontsets using very larger fonts such that you could detect the first load penalty per tile.

Here are my latest results on OS X 10.9 (libstdc++, 4 core, 16 GB ram)

```
$./benchmark/out/test_rendering --name "text rendering" --map benchmark/data/roads.xml --extent 1477001.12245,6890242.37746,1480004.49012,6892244.62256 --width 600 --height 600 --iterations 20 --threads 10
text rendering: t:10 i:20 6890 milliseconds
```