Creates font elements

@param string $str
@param string $size       = NULL
@param string $color      = NULL
@param string $face       = NULL
@param array  $attributes = []

@return string
197877
public function font(String $str, String $size = NULL, String $color = NULL, String $face = NULL, Array $attributes = []) : String
    {
        if( ! empty($size) )
        {
            $attributes['size'] = $size;
        }

        if( ! empty($color) )
        {
            $attributes['color'] = $color;
        }

        if( ! empty($face) )
        {
            $attributes['face'] = $face;
        }

        return $this->_multiElement('font', $str, $attributes);
    }
1152475
public static function getSpellIcon( string $spell_name, array $attributes = [] ): Html
	{
		self::checkInit();

		$attrs = array_merge([ 'alt'   => $spell_name ], self::getSetting(self::SET_CUSTOM_IMG_ATTRS, []), $attributes);
		$attrs['class'] = implode(' ', [
			self::getSetting(self::SET_DEFAULT_CLASS),
			self::getSetting(self::SET_SPELL_ICON_CLASS),
			@self::getSetting(self::SET_CUSTOM_IMG_ATTRS, [])['class'],
			@$attributes['class'],
		]);
		$attrs['src'] = self::getSpellIconUrl($spell_name);

		return Html::el('img', $attrs);
	}
242055
function createStringAttributes(textStyles) {
  const font = findFont(textStyles);

  const attribs = {
    MSAttributedStringFontAttribute: font.fontDescriptor(),
    NSFont: font,
    NSParagraphStyle: makeParagraphStyle(textStyles),
    NSUnderline: TEXT_DECORATION_UNDERLINE[textStyles.textDecoration] || 0,
    NSStrikethrough: TEXT_DECORATION_LINETHROUGH[textStyles.textDecoration] || 0
  };

  const color = makeColorFromCSS(textStyles.color || 'black');

  if (getSketchVersion() >= 50) {
    attribs.MSAttributedStringColorAttribute = color;
  } else {
    attribs.NSColor = NSColor.colorWithDeviceRed_green_blue_alpha(
      color.red,
      color.green,
      color.blue,
      color.alpha
    );
  }

  if (textStyles.letterSpacing !== undefined) {
    attribs.NSKern = textStyles.letterSpacing;
  }

  if (textStyles.textTransform !== undefined) {
    attribs.MSAttributedStringTextTransformAttribute = TEXT_TRANSFORM[textStyles.textTransform] * 1;
  }

  return attribs;
}
225932
public static Font getFont(Properties attributes) {
        fontImp.defaultEmbedding = defaultEmbedding;
        fontImp.defaultEncoding = defaultEncoding;
        return fontImp.getFont(attributes);
    }
719081
public function dissolve_short_font($str_value) {
		$font_prop_default = & $this->parser->data['csstidy']['font_prop_default'];
		$font_weight = array('normal', 'bold', 'bolder', 'lighter', 100, 200, 300, 400, 500, 600, 700, 800, 900);
		$font_variant = array('normal', 'small-caps');
		$font_style = array('normal', 'italic', 'oblique');
		$important = '';
		$return = array('font-style' => null, 'font-variant' => null, 'font-weight' => null, 'font-size' => null, 'line-height' => null, 'font-family' => null);

		if ($this->parser->is_important($str_value)) {
			$important = '!important';
			$str_value = $this->parser->gvw_important($str_value);
		}

		$have['style'] = false;
		$have['variant'] = false;
		$have['weight'] = false;
		$have['size'] = false;
		// Detects if font-family consists of several words w/o quotes
		$multiwords = false;

		// Workaround with multiple font-family
		$str_value = $this->explode_ws(',', trim($str_value));

		$str_value[0] = $this->explode_ws(' ', trim($str_value[0]));

		for ($j = 0; $j < count($str_value[0]); $j++) {
			if ($have['weight'] === false && in_array($str_value[0][$j], $font_weight)) {
				$return['font-weight'] = $str_value[0][$j];
				$have['weight'] = true;
			} elseif ($have['variant'] === false && in_array($str_value[0][$j], $font_variant)) {
				$return['font-variant'] = $str_value[0][$j];
				$have['variant'] = true;
			} elseif ($have['style'] === false && in_array($str_value[0][$j], $font_style)) {
				$return['font-style'] = $str_value[0][$j];
				$have['style'] = true;
			} elseif ($have['size'] === false && (is_numeric($str_value[0][$j]{0}) || $str_value[0][$j]{0} === null || $str_value[0][$j]{0} === '.')) {
				$size = $this->explode_ws('/', trim($str_value[0][$j]));
				$return['font-size'] = $size[0];
				if (isset($size[1])) {
					$return['line-height'] = $size[1];
				} else {
					$return['line-height'] = ''; // don't add 'normal' !
				}
				$have['size'] = true;
			} else {
				if (isset($return['font-family'])) {
					$return['font-family'] .= ' ' . $str_value[0][$j];
					$multiwords = true;
				} else {
					$return['font-family'] = $str_value[0][$j];
				}
			}
		}
		// add quotes if we have several qords in font-family
		if ($multiwords !== false) {
			$return['font-family'] = '"' . $return['font-family'] . '"';
		}
		$i = 1;
		while (isset($str_value[$i])) {
			$return['font-family'] .= ',' . trim($str_value[$i]);
			$i++;
		}

		// Fix for 100 and more font-size
		if ($have['size'] === false && isset($return['font-weight']) &&
						is_numeric($return['font-weight']{0})) {
			$return['font-size'] = $return['font-weight'];
			unset($return['font-weight']);
		}

		foreach ($font_prop_default as $font_prop => $default_value) {
			if ($return[$font_prop] !== null) {
				$return[$font_prop] = $return[$font_prop] . $important;
			}
			else
				$return[$font_prop] = $default_value . $important;
		}
		return $return;
	}
568816
private function HtmlAttributes($attributes)
    {
        $formatted = join(' ', array_map(function ($key) use ($attributes) {
            if (is_bool($attributes[$key])) {
                return $attributes[$key] ? $key : '';
            }
            return $key . '="' . $attributes[$key] . '"';
        }, array_keys($attributes)));
        return $formatted;
    }
987677
public static function create(string $tag, string $content = null, array $attributes = null,
        bool $selfClosing = false, bool $v5 = true): string
    {
        if ($attributes != null) {
            $tmp = [];
            foreach ($attributes as $name => $value) {
                if ($value === null) { // eg: ['a' => 1, 'b' => null, ...]
                    $tmp[] = $name;
                } elseif (is_int($name)) { // eg: ['a' => 1, 'b', ...]
                    $tmp[] = $value;
                } else { // eg: ['a' => 1, 'b' => 2, ...]
                    $tmp[] = sprintf('%s="%s"', $name, strtr((string) $value, ['"' => '&quot;']));
                }
            }
            $attributes = ' '. join(' ', $tmp);
        }

        return $selfClosing || in_array($tag, self::$selfClosingTags)
            ? sprintf('<%s%s%s>', $tag, $attributes, $v5 ? '' : ' /')
            : sprintf('<%s%s>%s</%s>', $tag, $attributes, $content, $tag);
    }
263551
private function _filter_attributes(string $str): string
    {
        if ($str === '') {
            return '';
        }

        $out = '';
        if (\preg_match_all('#\s*[\\p{L}0-9_\-\[\]]+\s*=\s*("|\042|\'|\047)(?:[^\\1]*?)\\1#ui', $str, $matches)) {
            foreach ($matches[0] as $match) {
                $out .= $match;
            }
        }

        return $out;
    }
5401
public function signature($string, $size = 25, $color = 'ffffff')
    {
        $this->setFontPath(__DIR__ . DIRECTORY_SEPARATOR . 'Fonts/Jellyka_Saint-Andrew\'s_Queen.ttf')
            ->setFontSize($size)
            ->setFontColor($color)
            ->setString($string);

        if ($this->position === 'AUTO') {
            $this->position = 'CENTER';
        }

        return $this;
    }
974661
public function make(array $attributes = [])
    {
        $resolution = $this->resolution(
            isset($attributes['width']) ? $attributes['width'] : null,
            isset($attributes['height']) ? $attributes['height'] : null
        );

        return $this->faker->imageGenerator(
            null, // dir
            $resolution['width'],
            $resolution['height'],
            $attributes['type'], // jpg or png
            true, // fullpath
            (function_exists('imagettfbbox') ? (isset($attributes['text']) ? $attributes['text'] : $this->faker->word) : null),
            (isset($attributes['background']) ? $attributes['background'] : $this->faker->hexColor),
            (isset($attributes['color']) ? $attributes['color'] : $this->faker->hexColor)
        );
    }
785457
public function style($url, $attributes = [], $secure = null)
    {
        $defaults = ['media' => 'all', 'type' => 'text/css', 'rel' => 'stylesheet'];

        $attributes = $attributes + $defaults;

        $attributes['href'] = $this->url->asset($url, $secure);

        return '<link' . $this->attributes($attributes) . '>' . PHP_EOL;
    }
242335
public function getImage($type, $size, array $attributes = array())
	{
		if (empty($this->$type))
		{
			return null;
		}
		$html = '<img src="' . $this->getImageSrc($type, $size) . '"';
		$html .= ' alt="' . $this->{$type.'_alt'} . '"';
		$html .= ' width="' . $this->getImageWidth($type, $size) . '"';
		$html .= ' height="' . $this->getImageHeight($type, $size) . '"';
		
		$html_attributes = '';
		if (!empty($attributes)) {
			$html_attributes = join(' ', array_map(function($key) use ($attributes) {
				if(is_bool($attributes[$key]))
				{
					return $attributes[$key] ? $key : '';
				}
				return "{$key}=\"{$attributes[$key]}\"";
			}, array_keys($attributes)));
		}
		
		return $html;
	}
1307253
private function createElement($type, $children = array(), array $attributes = array(), $text = null)
    {
        $element = new NodeElement();
        $element->openTag($type);

        if (!empty($attributes)) {
            $element->addAttributes($attributes);
        }

        if (!empty($children)) {
            if ($children instanceof NodeElement) {
                $children = array($children);
            }

            $element->appendChildren($children);
        }

        if ($text !== null) {
            $element->setText($text);
        }

        $element->closeTag();

        return $element;
    }
838154
function font(size) {
    var cssText = selectors + '{ font-size: ' + size + 'px; }',
        el = document.createElement('style');

    el.type = 'text/css';
    if (el.styleSheet) {
      el.styleSheet.cssText = cssText;//IE only
    } else {
      el.appendChild(document.createTextNode(cssText));
    }
    head.appendChild(el);
  }
567981
public static function nl2br(string $str, bool $xhtml = true) : string
    {
        return str_replace(array("\r\n", "\n\r", "\n", "\r"), (($xhtml) ? '<br />' : '<br>'), $str);
    }
505989
function SetStyles($str)
	{
		$style = '';
		foreach (['B', 'I'] as $s) {
			if (strpos($str, $s) !== false) {
				$this->$s = true;
				$style .= $s;
			} else {
				$this->$s = false;
			}
		}
		$this->currentfontstyle = $style;
		$this->SetFont('', $style, 0, false);
	}
1142926
public static function createChar($name, $size)
    {
        $field = new DatabaseField($name, self::TYPE_CHAR);
        $field->m_constraint = intval($size);
        return $field;
    }