DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:fontsize2

FontSize2 Plugin

Compatible with DokuWiki

Lemming, Anteater, Rincewind, Angua, Adora Belle, Weatherwax, Binky, Ponder Stibbons, Hrun, Greebo

plugin Text in different size

Last updated on
2017-01-07
Provides
Syntax
Conflicts with
edittable

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Similar to fontsize, typography, wrap

Tagged with style, typography

Download and Installation

Search and install the plugin using the Extension Manager. Refer to Plugins on how to install plugins manually.

Backup copy (following urls are tentative, waiting the plugin author will setup plugin files for download.)

Examples

Examples

Syntax: <fs size>Your Text</fs>
you can use any Value for size (em, ex, px, % , or xx-small , x-small, small, medium, large, x-large, xx-large)
example: <fs 2em>Your Text in 2em, 1em is DokuWiki standard</fs> <fs 200%>Your Text in 200%, 100% is DokuWiki standard</fs>'

Description

Change the fontsize by clicking a button in the edit toolbar.

To change the fontsize, mark the text that you would like to change the size.
Then click on the button fontsize2 and choose one of the predefined sizes.

The result is: <fs yoursize em> Your own text</fs>

Alternative you can write this by yourself.
In this case you have some additional possibilities:
Explaination of CSS - fontsize , Sorry only in German Language

  • em - <fs 2em>Your own text in 2em</fs> Percent-Value 1em = Normal, 2em = double size
  • ex - <fs 2ex>Your own text in 2ex</fs> Percent-Value 1ex = Normal, 2ex = double size
  • % - <fs 200%>Your own text in 200%</fs> Percent-Value 100% = Normal, 200% = double size
  • px - <fs 12px>Your own text in 12px</fs> Not so good! px values may vary on different computers!
  • keywords - xx-small , x-small, small, medium, large, x-large, xx-large - <fs small>Your own text in small</fs>

Code

code based on the plugin highlight

syntax.php

Put this code into lib/plugins/fontsize2/syntax.php:

 
<?php
/**
 * FontSize2 Plugin: control the size of your text
 *
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author      Thorsten Stratmann <thorsten.stratmann@web.de>
 * @link          http://wiki.splitbrain.org/plugin:fontsize2
 * @version    0.2
 */
 
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once(DOKU_PLUGIN.'syntax.php');
 
/**
 * All DokuWiki plugins to extend the parser/rendering mechanism
 * need to inherit from this class
 */
class syntax_plugin_fontsize2 extends DokuWiki_Syntax_Plugin {
 
    function getInfo(){  // return some info
        return array(
            'author' => 'Thorsten Stratmann',
            'email'  => 'thorsten.stratmann@web.de',
            'date'   => '2010-03-26',
            'name'   => 'fontsize2 Plugin',
            'desc'   => 'With fs you can control the size of your text
                         Syntax: <fs size>Your Text</fs>
			             you can use  any Value for size (em, ex, px, % , or xx-small , x-small, small, medium, large, x-large, xx-large)
			             example: <fs 2em>Your Text in 2em, 1em is DokuWiki standard</fs>
			             <fs 200%>Your Text in 200%, 100% is DokuWiki standard</fs>',
            'url'    => 'http://wiki.splitbrain.org/plugin:fontsize2',
        );
    }
 
     // What kind of syntax are we?
    function getType(){ return 'formatting'; }
 
    // What kind of syntax do we allow (optional)
    function getAllowedTypes() {
        return array('formatting', 'substition', 'disabled');
    }
 
   // What about paragraphs? (optional)
   function getPType(){ return 'normal'; }
 
    // Where to sort in?
    function getSort(){ return 91; }
 
 
    // Connect pattern to lexer
    function connectTo($mode) {
      $this->Lexer->addEntryPattern('(?i)<fs(?: .+?)?>(?=.+</fs>)',$mode,'plugin_fontsize2');
    }
    function postConnect() {
      $this->Lexer->addExitPattern('(?i)</fs>','plugin_fontsize2');
    }
 
 
    // Handle the match
    function handle($match, $state, $pos, &$handler)
    {
        switch ($state) 
        {
          case DOKU_LEXER_ENTER : 
            preg_match("/(?i)<fs (.+?)>/", $match, $fs);   // get the fontsize
           if ( $this->_isValid($fs[1]) ) return array($state, $fs[1]);
			break;
			case DOKU_LEXER_MATCHED :
			break;
			case DOKU_LEXER_UNMATCHED :
			return array($state, $match);
			break;
			case DOKU_LEXER_EXIT :
			break;
			case DOKU_LEXER_SPECIAL :
			break;
		}
		return array($state, "1em");
	}
 
    // Create output
    function render($mode, &$renderer, $data) {
        if($mode == 'xhtml'){
          list($state, $fs) = $data;
          switch ($state) {
            case DOKU_LEXER_ENTER : 
              $renderer->doc .= "<span style=\"font-size: $fs\">";
              break;
            case DOKU_LEXER_MATCHED :
              break;
            case DOKU_LEXER_UNMATCHED :
              $renderer->doc .= $renderer->_xmlEntities($fs);
              break;
            case DOKU_LEXER_EXIT :
              $renderer->doc .= "</span>";
              break;
            case DOKU_LEXER_SPECIAL :
              break;
          }
          return true;
        }
        return false;
    }
    function _isValid($c) {
 
        $c = trim($c);
 
        $pattern = "/
          ^([0-9]{1,4})\.[0-9](em|ex|px|%)|^([0-9]{1,4}(em|ex|px|%))|^(xx-small|x-small|small|medium|large|x-large|xx-large)
                              /x";
 
        if (preg_match($pattern, $c)) return true;
 
    }
}

action.php

<?php
/**
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     Andreas Gohr <andi@splitbrain.org>
 */

// must be run within DokuWiki
if(!defined('DOKU_INC')) die();

if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once(DOKU_PLUGIN.'action.php');

class action_plugin_fontsize2 extends DokuWiki_Action_Plugin {

    /**
     * return some info
     *
     * @author Andreas Gohr <andi@splitbrain.org>
     */
    function getInfo(){
        return array_merge(confToHash(dirname(__FILE__).'/README'), array('name' => 'Toolbar Component'));
    }

    /**
     * register the eventhandlers
     *
     * @author Andreas Gohr <andi@splitbrain.org>
     */
    function register(Doku_Event_Handler $controller){
        $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'fontsize2_toolbar', array ());
    }

    function fontsize2_toolbar(&$event, $param) {
        $event->data[] = array (
            'type' => 'picker',
            'title' => $this->getLang('fs_picker'),
            'icon' => '../../plugins/fontsize2/images/toolbar/picker.png',
            'list' => array(
                array(
                    'type'   => 'format',
                    'title'  => $this->getLang('fs_xxs'),
                    'sample' => $this->getLang('fs_xxs_sample'),
                    'icon'   => '../../plugins/fontsize2/images/toolbar/xxs.png',
                    'open'   => '<fs xx-small>',
                    'close'  => '</fs>',
                ),
                array(
                    'type'   => 'format',
                    'title'  => $this->getLang('fs_xs'),
                    'sample' => $this->getLang('fs_xs_sample'),
                    'icon'   => '../../plugins/fontsize2/images/toolbar/xs.png',
                    'open'   => '<fs x-small>',
                    'close'  => '</fs>',
                ),
                array(
                    'type'   => 'format',
                    'title'  => $this->getLang('fs_s'),
                    'sample' => $this->getLang('fs_s_sample'),
                    'icon'   => '../../plugins/fontsize2/images/toolbar/s.png',
                    'open'   => '<fs small>',
                    'close'  => '</fs>',
                ),
                array(
                    'type'   => 'format',
                    'title'  => $this->getLang('fs_m'),
                    'sample' => $this->getLang('fs_m_sample'),
                    'icon'   => '../../plugins/fontsize2/images/toolbar/m.png',
                    'open'   => '<fs medium>',
                    'close'  => '</fs>',
                ),
                array(
                    'type'   => 'format',
                    'title'  => $this->getLang('fs_l'),
                    'sample' => $this->getLang('fs_l_sample'),
                    'icon'   => '../../plugins/fontsize2/images/toolbar/l.png',
                    'open'   => '<fs large>',
                    'close'  => '</fs>',
                ),
                array(
                    'type'   => 'format',
                    'title'  => $this->getLang('fs_xl'),
                    'sample' => $this->getLang('fs_xl_sample'),
                    'icon'   => '../../plugins/fontsize2/images/toolbar/xl.png',
                    'open'   => '<fs x-large>',
                    'close'  => '</fs>',
                ),
                array(
                    'type'   => 'format',
                    'title'  => $this->getLang('fs_xxl'),
                    'sample' => $this->getLang('fs_xxl_sample'),
                    'icon'   => '../../plugins/fontsize2/images/toolbar/xxl.png',
                    'open'   => '<fs xx-large>',
                    'close'  => '</fs>',
                ),
                array(
                    'type'   => 'format',
                    'title'  => $this->getLang('fs_smaller'),
                    'sample' => $this->getLang('fs_smaller_sample'),
                    'icon'   => '../../plugins/fontsize2/images/toolbar/smaller.png',
                    'open'   => '<fs smaller>',
                    'close'  => '</fs>',
                ),
                array(
                    'type'   => 'format',
                    'title'  => $this->getLang('fs_larger'),
                    'sample' => $this->getLang('fs_larger_sample'),
                    'icon'   => '../../plugins/fontsize2/images/toolbar/larger.png',
                    'open'   => '<fs larger>',
                    'close'  => '</fs>',
                ),
            )
        );
    }
}


Images

Additionally you need the images, displayed by clicking the fontsize2 Button. Please obtain this images from the installation packet.

Changelog

  • Version 0.1: Created
  • Version 1.0: update to DokuWiki 2009-12-25

Wishlist

  • Hi! First of all I wanna thank you for this great plugin. As a second instance I've realized this could be a more powerful plugin if it was possible to add it to another editor such as fckeditor.

I've installed fckeditor in my dokuwiki, which allows me to switch between native DW editor or fck editor. Well, when I install fontsize2 plugin it's added to DW editor but not to fck editor. Is there any way to make this possible?

Thanks,

Alex

Bugs

  • Click on icon make automatic saving comment in Discussion plugin without adding fontsize syntax
  • Enabling fonsize2 disables Ace-Editor on Weatherwax

Discussion

  • version 0.3 works with PHP 7, great job
  • Works on angua, thanks a lot!
  • I cannot see any Button!! With Adore Bella?? How come? I installed fontsize2 folder into de lib/plugin folder, what am I doing wrong?? Thanks for your answer.
  • Same for me, doesn't seem to work with Adore Bella. Is it suppose to work, can anyone confirm this?
  • Standard download not working with Release 2014-05-05 “Ponder Stibbons”, download fontsize2 (version 0.2) works fortunately!
  • Is it running with “Igor”?
  • You can use this syntax if you want to increase / decrease font size
    • Increase: <html><big>Big Font</big></html>
    • Double Increase: <html><big><big>Even Bigger Font</big></big></html>
    • Decrease : <html><small>Small</small></html>
    • Decrease More: <html><small><small>Even Smaller</small></small></html>
plugin/fontsize2.txt · Last modified: by From-Russia-with-Love

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki