respect halo-transform in grid_renderer

This commit is contained in:
Dane Springmeyer 2014-09-19 15:37:13 -07:00
parent fee3a5568c
commit 0c901f790e
4 changed files with 185 additions and 167 deletions

View file

@ -28,6 +28,7 @@
#include <mapnik/text/symbolizer_helpers.hpp>
#include <mapnik/pixel_position.hpp>
#include <mapnik/text/renderer.hpp>
#include <mapnik/renderer_common/clipping_extent.hpp>
namespace mapnik {
@ -36,15 +37,16 @@ void grid_renderer<T>::process(text_symbolizer const& sym,
mapnik::feature_impl & feature,
proj_transform const& prj_trans)
{
box2d<double> clip_box = clipping_extent(common_);
agg::trans_affine tr;
auto transform = get_optional<transform_type>(sym, keys::geometry_transform);
if (transform) evaluate_transform(tr, feature, common_.vars_, *transform, common_.scale_factor_);
text_symbolizer_helper helper(
sym, feature, common_.vars_, prj_trans,
common_.width_, common_.height_,
common_.scale_factor_,
common_.t_, common_.font_manager_, *common_.detector_,
common_.query_extent_, tr);
sym, feature, common_.vars_, prj_trans,
common_.width_, common_.height_,
common_.scale_factor_,
common_.t_, common_.font_manager_, *common_.detector_,
clip_box, tr);
bool placement_found = false;
composite_mode_e comp_op = get<composite_mode_e>(sym, keys::comp_op, feature, common_.vars_, src_over);
@ -52,6 +54,15 @@ void grid_renderer<T>::process(text_symbolizer const& sym,
grid_text_renderer<T> ren(pixmap_,
comp_op,
common_.scale_factor_);
{ // halo transform
agg::trans_affine halo_transform;
auto transform = get_optional<transform_type>(sym, keys::halo_transform);
if (transform)
{
evaluate_transform(halo_transform, feature, common_.vars_, *transform);
ren.set_halo_transform(halo_transform);
}
}
placements_list const& placements = helper.get();
value_integer feature_id = feature.id();

View file

@ -240,16 +240,23 @@ void grid_text_renderer<T>::render(glyph_positions const& pos, value_integer fea
pixel_position const& base_point = pos.get_base_point();
start.x = static_cast<FT_Pos>(base_point.x * (1 << 6));
start.y = static_cast<FT_Pos>((height - base_point.y) * (1 << 6));
start.x += transform_.tx * 64;
start.y += transform_.ty * 64;
// now render transformed glyphs
double halo_radius = 0.0;
FT_Matrix halo_matrix;
halo_matrix.xx = halo_transform_.sx * 0x10000L;
halo_matrix.xy = halo_transform_.shx * 0x10000L;
halo_matrix.yy = halo_transform_.sy * 0x10000L;
halo_matrix.yx = halo_transform_.shy * 0x10000L;
for (auto & glyph : glyphs_)
{
if (glyph.properties)
{
halo_radius = glyph.properties->halo_radius * scale_factor_;
}
FT_Glyph_Transform(glyph.image, 0, &start);
FT_Glyph_Transform(glyph.image, &halo_matrix, &start);
error = FT_Glyph_To_Bitmap(&glyph.image, FT_RENDER_MODE_NORMAL, 0, 1);
if (!error)
{

View file

@ -1,20 +1,20 @@
{
"keys": [
"",
"1",
"9",
"2",
"1",
"10",
"3",
"2",
"11",
"4",
"3",
"12",
"5",
"4",
"13",
"6",
"5",
"14",
"7",
"6",
"15",
"7",
"8",
"16"
],
@ -26,84 +26,84 @@
" ",
" ",
" ",
" !! ",
" ## ! ! ",
" ### ! !! ",
" #### !! ! ",
" ## ## ! ! ",
" # ! ",
" # # ! ",
" # ! ",
" ! ",
" ",
" $$ ",
" %% $ $ ",
" %%% $ $$ ",
" %%%% $$$ $ ",
" %% %% % $ $ ",
" % %% $ ",
" % % $ ",
" $ ",
" $$ ",
" ",
" & ",
" && ",
" ' & & ",
" '''' &&& ",
" '' '' '' & ",
" ' '' & & ",
" ' & && ",
" & ",
" ",
" ",
" ",
" ! ! # ## # ",
" !!! ! # ### # ",
" !!!!!! !!! # #### # # ",
" ( ",
" ) ( ",
" )))) (( ",
" )) )) ) ( ",
" ))) ) ( ( ",
" ) ( ( ",
" ",
" ",
" ",
" ",
" ** ",
" ++ *** * ",
" +++++++ ****** ",
" ++++++++++ ***** ** ",
" +++++ + ** ** ",
" ++ ** ",
" ** ",
" ",
" ",
" ",
" $ $$ % %% % ",
" $$$ $ $ % %%% % ",
" $$$$$$ $$$ % %%%% %%% ",
" ,,, ",
" -- ,,,,,, ",
" -------- -- ,,,,,, ,, ",
" ------- - -- ,,,, , , ",
" --- -- -- , ,,, ,,, ",
" ----- ,,, , ",
" ,, ",
" ",
" ",
" ",
" ... ",
" //// / ...... ",
" /////////// /// ...... ... ",
" //////// // /// ...... ...... ",
" /////////////// ...... ... ",
" /////// ....... ",
" ... ",
" ",
" ",
" ",
" ",
" & & ' '' ",
" &&& & && ' ''' ",
" &&&&&& &&& ' '''' ''' ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ( ( ) )) ",
" ((( ( ( ) ))) ) ",
" (((((( ( ) )))) ) ) ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" *** *** ** ++++++ + ",
" ******* * +++++ + ",
" ******* *** +++++ ++ ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ,,,,,,,, , ,, -- --- -- --- ",
" , ,,,,, , ,,, -- --- - --- ",
" ,,,,,,,, ,,,,,, ------ ------ ",
" ",
" ",
" ",
" ",
" ",
" ",
" .. ... ... // /// // /// ",
" ........... ... /////// // /// ",
" ........ .. ... /////// // /// ",
" ............... ////// ////// ",
" ",
" ",
" ",
" ",
" ",
" ",
" 0000 00 000 111 1111111 ",
" 000 1111 ",
" 000000000000 1111111 ",
" 000000000000 11111111111 ",
" 0000000000000 11111111111 ",
" 0000000000000 11111111111 ",
" 000000000 00 1111111 111 ",
" ",
" 00000000000 111111111 ",
" 11 ",
" ",
" ",
" ",

View file

@ -1,112 +1,112 @@
{
"keys": [
"",
"1",
"9",
"2",
"1",
"10",
"3",
"2",
"11",
"4",
"3",
"12",
"5",
"4",
"13",
"6",
"5",
"14",
"7",
"6",
"15",
"8",
"16"
"7",
"16",
"8"
],
"data": {},
"grid": [
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ! ## # # ",
" ! ! !! # # ## ",
" !! !!! !!! !!! ! #### # # # # ",
" ! !! !! ! ! # # # # # # ",
" ! ! ! ! ! ! # # # # # # ",
" ! !!! !!! !!! ! !!!! # #### # # # ### ",
" ",
" ",
" ",
" ",
" $ $ %% % % %% ",
" $ $ $$ % % % ",
" $$ $$$ $$$ $$$ $$ %%%% % % % % ",
" $ $$ $$ $ $$ % % % % % %% ",
" $ $ $ $ $ $ % % % % % % ",
" $ $$$ $ $ $$$ $ $$$ % %%%% % % % %%% ",
" ",
" ",
" ",
" ",
" &&& & &&&& ''' ' ' ''' ",
" && & &&&& '' ' ' ''' ",
" &&&&&&& &&&&&&& &&& '''' '' ' ' ''' ",
" & &&&&&&& & &&&& '' ' '' ' ' '''' ",
" & && && &&&& && '' ' '' ' ' '' ",
" & &&&&&&&&&&&& && &&&& '' '''' ' ' '''''' ",
" && && &&& ' '' ",
" ",
" ",
" ",
" ((( ( (((( ))) ) ) ))))) ",
" (( ( (((( )) ) ) ))))) ",
" ((((((( ((((((( ( )))) )) ) ) )) ",
" ( ((((((( ( (( )) ) )) ) ) )) ",
" ( (( (( (((( (( )) ) )) ) ) ) ",
" ( (((((((((((( (( ( )) )))) ) ) )) )) ",
" (( ((( ) ",
" ",
" ",
" ",
" *** ** **** +++ ++ + +++ ",
" ******* ******* **** +++++++++ + +++ ",
" *************** ** +++++++++ + ++ ",
" ************* ** ++ ++++++ + ++ ",
" ************* ** ++ ++++++ + ++ ",
" ************** **** ++ ++++++ + +++++ ",
" ** *********** **** ++ ++++++ + +++++ ",
" ",
" ",
" ",
" ,,,, ,,, ,,, ,,,, ---- ---- ---- ----- ",
" ,,,,,,,,,,,,,,, ,,, ,,,, ----- ------ ---- ----- ",
" ,,,,,,,,,,,,,,, ,, ,,,,, ----- ------ -- ----- ",
" ,,,,,,,,,,,,,, ,, ,,,,, ----- ------ -- ----- ",
" ,,,,,,,,,,,,,, ,, ,,,,,,,, ------------ -- ---- -- ",
" ,,,,,,,,,,,,,,, ,,,,,,,,,,,, ------------ ------------ ",
" ,,,,,,,,,,,,,,, ,,,,,,,,,,, ------------ ------------ ",
" ",
" ",
" .... ... ..... ...... ///// ////// ///// ////// ",
" .... ... ...... ...... ///// ////// ////// ////// ",
" ................ ...... ...... ////////////// ////// ////// ",
" ................ ...... ...... ////////////// ////// ////// ",
" ................ ...... ...... ////////////// ////// ////// ",
" ............... ............. ///////////// ///////////// ",
" ............... ............. ///////////// ///////////// ",
" ............... ............. ///////////// ///////////// ",
" ........ .... //// ///// ",
" 000000 111111 1111111 ",
" 0000000 00000 000000 111111 1111111 111111 ",
" 000000000000000000000000 1111111111111111111111 ",
" 000000000000000000000000 1111111111111111111111 ",
" 0000000000000000000000000 1111111111111111111111 ",
" 0000000000000000000000000 1111111111111111111111 ",
" 0000000000000000000000000 1111111111111111111111 ",
" 0000000000000000000000000 111111111111111111111 ",
" 0000000000000000000000000 111111111111111111111 ",
" 000000000000000000 00000 11111111111111 11111 ",
" ",
" ",
" ! ",
" !! ! ",
" !!! ",
" ## !! ! ",
" ## ! ",
" # ## ! ! ",
" # # ! ! ! ",
" # #### ### # !! ! ! ",
" # # # ## !! ! ",
" ## # # ! !! ",
" ### # ### !! ",
" # # $$$$ ",
" # # $$ ",
" %% ## ## $$ !! ",
" % ## $$ $ ! !! ",
" %% % ## $ $ !! ",
" % % $ $ $ !!! ",
" % %%%% %%% % $$$ $ $$ ! ",
" % % % %% %%%% $ $ $$ ! ",
" %%% %% % %% $ $ ",
" % % % % $ ",
" % %% && $ ",
" % %% &&&&& $$ ",
" ''' % % &&&& $ ",
" '''' %%%% && && $ $$ $ ",
" ''''' && && & & $ $$ ",
" '' '''' && && && $ $ ",
" '' '''''''' ' &&&&&&& && $$ ",
" ' ''''''' '''' &&&&& && ",
" '''' '' ''' '''' & &&&& ",
" ''''' ' ' '' &&&& ",
" ''' ' ''' && && ",
" '' ' ' (((( &&& ",
" ' ' '' (((( & &&&&& ",
" ))) '''' ((((( & & && ",
" ))) (( (( ( (( && & ",
" )))))) (( (( (( ((( &&&& ",
" )) )))))))))) ( (((( (( ",
" ) )))))))))))) )) (((((( (( ",
" ) )))) ))) )) )))) ( (((( ",
" ))))) ) ) )) (( (( ( ",
" ))) )) )) (( ((( ",
" )) ) ))) ((( ",
" ) )) ***** (( ((( ",
" +++ ) **** (( (( ",
" ++++ ***** (( ",
" ++++++ ******** ** ",
" +++++++++++++ ** ** ******* ",
" +++++++++++++++ +++ ** ********* ",
" ++++++++++++++ +++ ********* *** ",
" +++++++++++++ ++ ******* **** ",
" ++++++++++ +++ ***** *** ",
" ++ +++ +++ ,,,,, ** *** ",
" ++++ ,,,,, **** ",
" --- ++ ,,,,, ,, **** ",
" ------ ,,,,,,,,,,,, **** ",
" -------------- ,,,,,,,,,,,,, ",
" --------------- ---- -- ,,,,,,,,,,,,, ,,,, ",
" --------------- ---- ----- ,,,,,,,,,, ,,,, ",
" -------------- --- ----- ,,,,,,,,, ,,,, ,, ",
" -------------- -- ---- ,,,,, ,,, ,,,,, ",
" ---------- ---- ----- ,, ,,,,, ,,,,, ",
" ---- ------------- ..... ,,,,, ,,,,, ",
" ------------ ...... ,,,,,,, ,,,, ",
" ///// ----- ....... ..... ,,,,,,,,, ",
" //////// /// .............. ,,,,,,, ",
" //////////////// ////// ................... ,,,,, ",
" /////////////////////// ////// .................... ",
" /////////////////////// ////// ............. ...... ..... ",
" ///////////////// ///// ////// ............. ...... ...... ",
" //////////////// ////// ////// .................. ...... ",
" ////////////////////////////// ....... ....... ...... ",
" //////////////////////// ... ............. ",
" ////////////// 0000000 ............. ",
" 111111 //////// 000000000000000......... ",
" 1111111111 11111 11111 0000000000000000 ...... ",
" 111111111111111111111111 0000000000000000000000 ",
" 111111111111111111111111 0000000000000000000000 ",
" 111111111111111111111111 0000000000000000000000 ",
" 1111111111111111111111111 0000000000000000000000 ",
" 1111111111111111111111111 0000000000000000000000 ",
" 1111111111111111111111111 0000000000000000000000 ",
" 1111111111111111111111111 0000000000000000000000 ",
" 1111111111111111111111 00000000000000000 ",
" 11111 000000 ",
" 00000 ",
" ",
" ",
" ",