How to install a text filter for plain_text input format The users at my Drupal 7 website discuss a card game in plain_text comments and I'd like to format the hearts and diamonds characters by red color.

Based on the Examples module recommended to me here at "Drupal Answers" site I've added the following code to my custom module sites/default/modules/pref/pref.module:

function pref_block_view($block_name = '') {
       ... this other part of my custom module works well ...
}

function pref_filter_info() {
  $filters['plain_text'] = array(
    'title' =&gt; t('Pref filter'),
    'description' =&gt; t('Replace the ♠ ♣ ♦ ♥ characters'),
    'process callback' =&gt; '_pref_filter_process',
  );
  return $filters;
}

function _pref_filter_process($text, $filter) {
  $text = str_replace('♦', '&lt;font color="red"&gt;♦&lt;/font&gt;', $text);
  $text = str_replace('♥', '&lt;font color="red"&gt;♥&lt;/font&gt;', $text);
  return $text;
}


However still nothing is highlighted in comments.

The rest of my custom module works fine (it generates few blocks - for the Flash game and player rating).

How to register my filter for the plain_text please? I suspect that 

 $filters['plain_text'] = array( ... );


is a wrong way.
Do it in GUI. http://example.org/admin/config/content/formats/plain_text 

Check it in Enabled filters section and then make sure it's the last one in Filter processing order section. If you'll put it before Display any HTML as plain text, your tags will get added and then in the very next step removed.

Also, &lt;font&gt; tag may be removed by HTML cleaning modules. Modern way is to make it like &lt;span class="red-card"&gt; and then style it in CSS. Actually, it might be a wise idea to add &lt;span class="black-card"&gt; as well, and maybe "card" class for both, and respective classes for clubs, spades, hearts and diamonds. That way you will be able to style them differently or even use image substitution, if you wish - all in CSS.

You can provide default CSS in your module. In mymodule.info add line:

stylesheets[all][] = css/cards.css


Create that file in mymodule/css directory and place all styles there. That way they will be there, and themes will be able to override them in their own CSS files.