diff --git a/TextSymbolizer.md b/TextSymbolizer.md index da97dbd..c03ae5c 100644 --- a/TextSymbolizer.md +++ b/TextSymbolizer.md @@ -1,7 +1,3 @@ - - - - ## Configuration Options for TextSymbolizer | *parameter* | *value* | *description* | *unit* | *default* | @@ -44,45 +40,51 @@ In Mapnik2 all underscores "_" are replaced by dashes "-" (e.g. avoid-edges inst ## Examples - Some examples of Mapnik's ability to place text along lines: - [[BR]] -[[Image(http://trac.mapnik.org/raw-attachment/ticket/62/output_old.png)]] +Some examples of Mapnik's ability to place text along lines: + +![thumb](http://trac.mapnik.org/raw-attachment/ticket/62/output_old.png) ### XML - #!xml - +```xml +#!xml + +``` See [wiki:XMLGettingStarted] for more XML example uses of TextSymbolizer. ### Python - #!python - t = TextSymbolizer('FIELD_NAME', 'DejaVu Sans Book', 10, Color('black')) - t.halo_fill = Color('white') - t.halo_radius = 1 - t.label_placement = label_placement.LINE_PLACEMENT # POINT_PLACEMENT is default - dir(t) # for the rest of the attributes +```python +#!python +t = TextSymbolizer('FIELD_NAME', 'DejaVu Sans Book', 10, Color('black')) +t.halo_fill = Color('white') +t.halo_radius = 1 +t.label_placement = label_placement.LINE_PLACEMENT # POINT_PLACEMENT is default +dir(t) # for the rest of the attributes +``` ### C++ - #!cpp - #include - #include - - using namespace mapnik; - try { - freetype_engine::register_font("/path/to/font.ttf"); - /* some code */ - rule_type rule; - text_symbolizer ts("FIELD_NAME", "DejaVu Sans Book", 10, color(0, 0, 0)); - ts.set_halo_fill(color(255, 255, 200)); - ts.set_halo_radius(1); - rule.append(ts); - } +```cpp +#!cpp +#include +#include + +using namespace mapnik; +try { + freetype_engine::register_font("/path/to/font.ttf"); + /* some code */ + rule_type rule; + text_symbolizer ts("FIELD_NAME", "DejaVu Sans Book", 10, color(0, 0, 0)); + ts.set_halo_fill(color(255, 255, 200)); + ts.set_halo_radius(1); + rule.append(ts); +} +``` The first parameter is the field name of a database field, or from a shape file, or an osm file. In case of a shape file or osm file, the field name is case sensitive. You must load the needed fonts first, otherwise you'll get a run time error. But you can load as many true type fonts as you like. Mapnik is coming with a couple of fonts in "mapnik/fonts". I recommend to load all of this fonts, regardless if you need them or not. @@ -109,22 +111,30 @@ Note: Whitespace is ignored, e.g. "N,S,15,10" and "N, S,15,10" and "N, S, 15, 10 An XML example might look like: - #!xml - +```xml +#!xml + +``` ## New syntax Starting with r3354 Mapnik2 supports a new syntax: - #!xml - +``` +#!xml + +``` + becomes - #!xml - [label] +```xml +#!xml +[label] +``` + This change was made to be forward compatible with changes to text formatting being introduced in later versions.