====== FontSize2 Plugin ====== ---- plugin ---- description: Text in different size author : Thorsten Stratmann email : thorsten.stratmann@web.de type : syntax lastupdate : 2017-01-07 compatible : Lemming, Anteater, Rincewind, Angua, Adora Belle, Weatherwax, Binky, Ponder Stibbons, Hrun, Greebo depends : conflicts : similar : fontsize, typography tags : style, typography downloadurl: https://github.com/ssahara/dw-plugin-fontsize2/archive/master.zip ---- ===== Download and Installation ===== Search and install the plugin using the [[plugin:extension|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.) * [[https://github.com/lupo49/dokuwiki-plugin-fontsize2/archive/master.zip|fontsize2]] (version 0.1) * [[https://github.com/ssahara/dw-plugin-fontsize2/archive/master.zip|fontsize2]] (version 0.3) ===== Examples ===== [[https://web.archive.org/web/20090501161354/http://www.tstratmann.de:80/dokuwiki/doku.php?id=code:dokuwiki:plugin:fontsize2:beispiel|Examples]] Syntax: Your Text \\ you can use any Value for size (em, ex, px, % , or xx-small , x-small, small, medium, large, x-large, xx-large) \\ example: Your Text in 2em, 1em is DokuWiki standard Your Text in 200%, 100% is DokuWiki standard' ===== 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: Your own text Alternative you can write this by yourself. \\ In this case you have some additional possibilities: \\ [[http://de.selfhtml.org/css/eigenschaften/schrift.htm#font_size|Explaination of CSS - fontsize , Sorry only in German Language]] * em - Your own text in 2em Percent-Value 1em = Normal, 2em = double size * ex - Your own text in 2ex Percent-Value 1ex = Normal, 2ex = double size * % - Your own text in 200% Percent-Value 100% = Normal, 200% = double size * px - Your own text in 12px Not so good! px values may vary on different computers! * keywords - xx-small , x-small, small, medium, large, x-large, xx-large - Your own text in small ===== Code ===== code based on the [[plugin:highlight|plugin highlight]] ==== syntax.php==== Put this code into ''lib/plugins/fontsize2/syntax.php'': * @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: Your Text you can use any Value for size (em, ex, px, % , or xx-small , x-small, small, medium, large, x-large, xx-large) example: Your Text in 2em, 1em is DokuWiki standard Your Text in 200%, 100% is DokuWiki standard', '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)(?=.+)',$mode,'plugin_fontsize2'); } function postConnect() { $this->Lexer->addExitPattern('(?i)','plugin_fontsize2'); } // Handle the match function handle($match, $state, $pos, &$handler) { switch ($state) { case DOKU_LEXER_ENTER : preg_match("/(?i)/", $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 .= ""; break; case DOKU_LEXER_MATCHED : break; case DOKU_LEXER_UNMATCHED : $renderer->doc .= $renderer->_xmlEntities($fs); break; case DOKU_LEXER_EXIT : $renderer->doc .= ""; 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 ==== */ // 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 */ function getInfo(){ return array_merge(confToHash(dirname(__FILE__).'/README'), array('name' => 'Toolbar Component')); } /** * register the eventhandlers * * @author Andreas Gohr */ 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' => '', 'close' => '', ), array( 'type' => 'format', 'title' => $this->getLang('fs_xs'), 'sample' => $this->getLang('fs_xs_sample'), 'icon' => '../../plugins/fontsize2/images/toolbar/xs.png', 'open' => '', 'close' => '', ), array( 'type' => 'format', 'title' => $this->getLang('fs_s'), 'sample' => $this->getLang('fs_s_sample'), 'icon' => '../../plugins/fontsize2/images/toolbar/s.png', 'open' => '', 'close' => '', ), array( 'type' => 'format', 'title' => $this->getLang('fs_m'), 'sample' => $this->getLang('fs_m_sample'), 'icon' => '../../plugins/fontsize2/images/toolbar/m.png', 'open' => '', 'close' => '', ), array( 'type' => 'format', 'title' => $this->getLang('fs_l'), 'sample' => $this->getLang('fs_l_sample'), 'icon' => '../../plugins/fontsize2/images/toolbar/l.png', 'open' => '', 'close' => '', ), array( 'type' => 'format', 'title' => $this->getLang('fs_xl'), 'sample' => $this->getLang('fs_xl_sample'), 'icon' => '../../plugins/fontsize2/images/toolbar/xl.png', 'open' => '', 'close' => '', ), array( 'type' => 'format', 'title' => $this->getLang('fs_xxl'), 'sample' => $this->getLang('fs_xxl_sample'), 'icon' => '../../plugins/fontsize2/images/toolbar/xxl.png', 'open' => '', 'close' => '', ), array( 'type' => 'format', 'title' => $this->getLang('fs_smaller'), 'sample' => $this->getLang('fs_smaller_sample'), 'icon' => '../../plugins/fontsize2/images/toolbar/smaller.png', 'open' => '', 'close' => '', ), array( 'type' => 'format', 'title' => $this->getLang('fs_larger'), 'sample' => $this->getLang('fs_larger_sample'), 'icon' => '../../plugins/fontsize2/images/toolbar/larger.png', 'open' => '', 'close' => '', ), ) ); } } ===== 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? * **2014-03-03**: I opened a thread with all required PNG files for a working toolbar: https://github.com/lupo49/dokuwiki-plugin-fontsize2/issues/1 - deej * 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: Big Font * Double Increase: Even Bigger Font * Decrease : Small * Decrease More: Even Smaller