DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:fontfamily

This is an old revision of the document!


fontfamily plugin

Compatible with DokuWiki

Anteater, Rincewind, Angua, Adora Belle, Weatherwax, Binky

plugin With fontfamily you can control the typeface of your text

Last updated on
2012-08-03
Provides
Syntax

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 typography, wrap

Tagged with typography

Der Toolbar Button funktioniert nur bis zur DokuWiki Version 2009-12-25 !
Diese Plugin wird nicht weiterentwickelt !

Download and Installation

Download and install the plugin using the Plugin Manager using the following URL. Refer to Plugins on how to install plugins manually.

I made workable analogue of fontcolor and put it here http://comicslate.org/_media/wiki/dokuplug/fontfamily.tgz. MD5 sum d5cfa70394c9fb1a23088fa849cee8a8. Fixed toolbar icon - added iconbar “corner triangle”.

Description

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

To change the fontfamily , mark the text that you would like to change. Then click on the button fontfamily and choose one of the predefined styles. The result is: <ff fontfamily> Your own text</ff>

Code

code based on the plugin highlight

syntax.php

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

<?php
<?php
/**
 * fontfamily Plugin: control the font-family 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:fontfamily
 * @version    0.1
 */
 
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_fontfamily extends DokuWiki_Syntax_Plugin {
 
    function getInfo(){  // return some info
        return array(
            'author' => 'Thorsten Stratmann',
            'email'  => 'thorsten.stratmann@web.de',
            'date'   => '2009-02-04',
            'name'   => 'fontfamily Plugin',
            'desc'   => 'With fontfamily you can control the typeface of your text
                         Syntax: <ff Value>Your Text</ff>',
            'url'    => 'http://wiki.splitbrain.org/plugin:fontfamily',
        );
    }
 
     // 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 92; }
 
 
    // Connect pattern to lexer
    function connectTo($mode) {
      $this->Lexer->addEntryPattern('(?i)<ff(?: .+?)?>(?=.+</ff>)',$mode,'plugin_fontfamily');
    }
    function postConnect() {
      $this->Lexer->addExitPattern('(?i)</ff>','plugin_fontfamily');
    }
 
 
    // Handle the match
    function handle($match, $state, $pos, &$handler)
    {
        switch ($state) 
        {
          case DOKU_LEXER_ENTER : 
            preg_match("/(?i)<ff (.+?)>/", $match, $ff);   // get the fontfamily
           if ( $this->_isValid($ff[1]) ) return array($state, $ff[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, "");
	}
 
    // Create output
    function render($mode, &$renderer, $data) {
        if($mode == 'xhtml'){
          list($state, $ff) = $data;
          switch ($state) {
            case DOKU_LEXER_ENTER : 
              $renderer->doc .= "<span style=\"font-family: $ff\">";
              break;
            case DOKU_LEXER_MATCHED :
              break;
            case DOKU_LEXER_UNMATCHED :
              $renderer->doc .= $renderer->_xmlEntities($ff);
              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 = "/^(Times New Roman|Arial|Brush Script MT|Comic Sans MS|Georgia|Impact|Trebuchet|Verdana|Webdings])/x";
 
  //      if (preg_match($pattern, $c)) return true;
    return true;
    }
}

Images

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

Changelog

  • Version 0.1: Created

Bugs

  • Click on icon make automatic saving comment in Discussion plugin without adding fontfamily syntax

Question

Though the plugin works fine within the text, it does not show in the toolbar any more.
This happens in Release 2009-12-25c “Lemming” of DokuWiki.
Any ideas?(11/05/2010)

Fixed.

plugin/fontfamily.1402601169.txt.gz · Last modified: 2014-06-12 21:26 by 217.150.76.53

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