FANDOM


local fonts = require('module:Font/data')
 
-- Default options
local defaultColor = 'black'
local defaultSize = '16px'
 
-- Utility functions
function split(stringToSplit)
    local text = {}
 
    local i = 1;
    for letter in string.gmatch(stringToSplit, '.') do
        text[i] = letter
        i = i + 1
    end
 
    return text
end
 
local moduleFont = {
    ['parseFont'] = function (frame)
 
            local fontType = frame.args[1]
            local text = frame.args[2]
            local size = frame.args.size
            local color = frame.args.color
            local link = frame.args.link
 
            if( color == nil or color == '' ) then
                color = defaultColor
            end
 
            if( color ~= 'black' and color ~= 'white' ) then
                return '<span style="color: red">Improper color</span>'
            end
 
            if( size == nil or size == '' ) then
                size = defaultSize
            end
 
            text = split(text)
 
            local i = 1;
 
            while( text[i] ~= nil ) do
 
                if( fonts[fontType][text[i]] ~= nil ) then
                    text[i] = '[[File:' .. fonts[fontType][text[i]][color] .. '|x' .. size
 
                    if(link ~= nil and link ~= '') then
                        text[i] = text[i] .. '|link=' .. link
                    end
 
                    text[i] = text[i] .. ']]'
                end
 
                i = i + 1
 
            end
 
            return table.concat(text, '')
 
        end
}
 
return moduleFont

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.