← Back to team overview

widelands-dev team mailing list archive

Re: [Merge] lp:~widelands-dev/widelands/bug-1525680 into lp:widelands

 

Some code nits, not tested.

What guarantees that the richtext renderer does not break   when layouting the text? It seems it is equivalent to a regular space.



Diff comments:

> === modified file 'src/graphic/richtext.cc'
> --- src/graphic/richtext.cc	2016-01-28 21:27:04 +0000
> +++ src/graphic/richtext.cc	2016-01-29 08:02:54 +0000
> @@ -34,6 +36,14 @@
>  
>  namespace {
>  int32_t const h_space = 3;
> +
> +// TODO(GunChleoc): This function is mirrored in rt_render. Keep them identical.

Why not pull them out into a new unit?

> +void replace_entities(std::string* text) {
> +	boost::replace_all(*text, ">", ">");
> +	boost::replace_all(*text, "&lt;", "<");
> +	boost::replace_all(*text, "&nbsp;", " ");
> +}
> +
>  } // namespace
>  
>  /**
> @@ -85,7 +95,8 @@
>  			std::string previous_word;
>  			for (std::vector<std::string>::iterator source_it = words.begin();

range based for loop? otherwise auto source_it reads easier.

>  				  source_it != words.end(); ++source_it) {
> -				const std::string& word = *source_it;
> +				std::string& word = *source_it;
> +				replace_entities(&word);
>  				if (source_it != words.end()) {
>  					if (i18n::has_rtl_character(word.c_str()) || i18n::has_rtl_character(previous_word.c_str())) {
>  						it = result_words.insert(result_words.begin(), word);


-- 
https://code.launchpad.net/~widelands-dev/widelands/bug-1525680/+merge/283793
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1525680 into lp:widelands.


References