<commit_before><?php

require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'FontForgeScript.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'SVGFontContainer.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'UnicodeRange.php';

class Cufon {

	public static function getUnusedFilename($suffix)
	{
		$filename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'cufon_';

		do
		{
			$wanted = $filename . uniqid(mt_rand(), true) . $suffix;
		}
		while (file_exists($wanted));

		return $wanted;
	}

	public static function log($message)
	{
		$args = func_get_args();

		array_shift($args);

		error_log(sprintf("[cufon]: %s", vsprintf($message, $args)), 0);
	}

	/**
	 * @param string $file
	 * @param array $options
	 * @return array
	 */
	public static function generate($file, array $options)
	{
		Cufon::log('Processing %s', $file);

		$script = new FontForgeScript();

		$script->open($file);
		$script->flattenCID();
		$script->reEncode('unicode');
		$script->selectNone();

		if (!empty($options['useGlyphCSSRange']) && !empty($options['customGlyphs']))
		{
			$options['glyphs'][] = UnicodeRange::fromCSSValue($options['customGlyphs'])->asHexString();

			$options['customGlyphs'] = '';
		}

		if (!empty($options['glyphs']))
		{
			foreach ($options['glyphs'] as $glyph)
			{<commit_msg>A glyph for the space character is now always included (and this time with correct width, too).<commit_after><?php

require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'FontForgeScript.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'SVGFontContainer.php';
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'UnicodeRange.php';

class Cufon {

	public static function getUnusedFilename($suffix)
	{
		$filename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'cufon_';

		do
		{
			$wanted = $filename . uniqid(mt_rand(), true) . $suffix;
		}
		while (file_exists($wanted));

		return $wanted;
	}

	public static function log($message)
	{
		$args = func_get_args();

		array_shift($args);

		error_log(sprintf("[cufon]: %s", vsprintf($message, $args)), 0);
	}

	/**
	 * @param string $file
	 * @param array $options
	 * @return array
	 */
	public static function generate($file, array $options)
	{
		Cufon::log('Processing %s', $file);

		$script = new FontForgeScript();

		$script->open($file);
		$script->flattenCID();
		$script->reEncode('unicode');
		$script->selectNone();
		$script->selectUnicode(0x20); // space

		if (!empty($options['useGlyphCSSRange']) && !empty($options['customGlyphs']))
		{
			$options['glyphs'][] = UnicodeRange::fromCSSValue($options['customGlyphs'])->asHexString();

			$options['customGlyphs'] = '';
		}

		if (!empty($options['glyphs']))
		{
			foreach ($options['glyphs'] as $glyph)
			{
{'fraction_non_alphanumeric': 0.17265143271672106, 'fraction_numerical': 0.0018135654697134566, 'mean_word_length': 4.8931623931623935, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6849811', 'n_tokens_mistral': 1053, 'n_tokens_neox': 936, 'n_words': 180}