/** * creates a SVG Font out of SGV files from a directory * * @param InputInterface $input input * @param OutputInterface $output output * @return void */ protected function execute(InputInterface $input, OutputInterface $output) { $directory = $input->getArgument('directory'); $outputFile = $input->getArgument('output-file'); $generator = new IconFontGenerator(); $output->writeln('reading files from "' . $directory . '" ...'); $generator->generateFromDir($directory, array('id' => $input->getOption('name') ?: 'SVGFont'), $input->getOption('rename-files')); $output->writeln('writing font to "' . $outputFile . '" ...'); file_put_contents($outputFile, $generator->getFont()->getXML()); $output->getFormatter()->setStyle('success', new OutputFormatterStyle(null, null, array('bold', 'reverse'))); $output->writeln('<success>created ' . $outputFile . ' successfully</success>'); }
/** * creates a CSS file with icon classes from a SVG font * * @param InputInterface $input input * @param OutputInterface $output output * @return void */ protected function execute(InputInterface $input, OutputInterface $output) { $fontFile = realpath($input->getArgument('font-file')); if ($fontFile === false || !file_exists($fontFile)) { throw new \InvalidArgumentException('"' . $input->getArgument('font-file') . '" does not exist'); } $outputFile = $input->getArgument('output-file'); $generator = new IconFontGenerator(); $output->writeln('reading font file from "' . $fontFile . '" ...'); $generator->generateFromFont(new Font(array(), file_get_contents($fontFile))); $output->writeln('writing CSS file to "' . $outputFile . '" ...'); file_put_contents($outputFile, $generator->getCss()); $output->getFormatter()->setStyle('success', new OutputFormatterStyle(null, null, array('bold', 'reverse'))); $output->writeln('<success>created CSS file successfully</success>'); }
/** * creates a HTML list * * @param IconFontGenerator $generator icon font generator * @param string $fontFile font file name * @return string HTML unordered list */ protected function getHTMLListFromGenerator(IconFontGenerator $generator, $fontFile) { $fontOptions = $generator->getFont()->getOptions(); $html = '<ul>'; $glyphNames = $generator->getGlyphNames(); asort($glyphNames); foreach ($glyphNames as $unicode => $glyph) { $html .= "\n\t" . '<li data-icon="&#x' . $unicode . ';" title="' . htmlspecialchars($glyph) . '">' . htmlspecialchars($glyph) . '</li>'; } $html .= "\n" . '</ul>' . "\n"; return $html; }