private function addptext($styleconf, $text, $posx = null, $posy = null, $width = 0, $height = 0) { static $cfonts = array(); $font = $this->conf[$styleconf . '_font']; $size = isset($this->conf[$styleconf . '_size']) ? $this->conf[$styleconf . '_size'] : 10; $style = isset($this->conf[$styleconf . '_style']) ? $this->conf[$styleconf . '_style'] : ''; $color = isset($this->conf[$styleconf . '_color']) ? $this->conf[$styleconf . '_color'] : '#000000'; $height = isset($this->conf[$styleconf . '_height']) ? $this->conf[$styleconf . '_height'] : $height; $text = utf8_decode($text); if (!is_file(FPDF_FONTPATH . $font . '.php')) { ob_start(); MakeFont(FPDF_FONTPATH . $font . '.ttf'); file_put_contents(FPDF_FONTPATH . $font . '.log', ob_get_contents()); ob_end_clean(); } if (!isset($cfonts[$font])) { $cfonts[$font] = $this->AddFont($font, $style, $font . '.php'); } $this->SetFont($font, $style, $size); $this->colordecode($color, $comp); $this->SetTextColor($comp[0], $comp[1], $comp[2]); if ($posx !== null && $posy !== null) { $this->SetXY($posx, $posy); $this->Cell($width, $height, $text, $this->border); } else { $this->Write($height, $text); } }
$subset = false; Notice('Font file could not be compressed (zlib extension not available)'); } } MakeDefinitionFile($basename . '.php', $type, $enc, $embed, $subset, $map, $info); Message('Font definition file generated: ' . $basename . '.php'); } if (PHP_SAPI == 'cli') { // Command-line interface ini_set('log_errors', '0'); if ($argc == 1) { die("Usage: php makefont.php fontfile [encoding] [embed] [subset]\n"); } $fontfile = $argv[1]; if ($argc >= 3) { $enc = $argv[2]; } else { $enc = 'cp1252'; } if ($argc >= 4) { $embed = $argv[3] == 'true' || $argv[3] == '1'; } else { $embed = true; } if ($argc >= 5) { $subset = $argv[4] == 'true' || $argv[4] == '1'; } else { $subset = true; } MakeFont($fontfile, $enc, $embed, $subset); }
function getFile() { if (isset($_FILES['ttf'])) { // get font file $tmp = $_FILES['ttf']['tmp_name']; $RESULT[] = '$tmp_name: ' . $tmp; $ttf = $_FILES['ttf']['name']; $RESULT[] = '$ttf: ' . $ttf; $a = explode('.', $ttf); if (strtolower($a[1]) != 'ttf') { $RESULT[] = 'NOT TTF FILE'; } //die('File is not a .ttf');} if (!move_uploaded_file($tmp, $ttf)) { $RESULT[] = 'ERROR IN UPLOAD'; } //die('Error in upload'); $fontname = $_REQUEST['fontname']; if (empty($fontname)) { $fontname = $a[0]; } $RESULT[] = 'FONT NAME: ' . $fontname; // AFM generation $RESULT[] = "ttf2pt1.exe -a " . $ttf . " " . $fontname; system("ttf2pt1.exe -a " . $ttf . " " . $fontname); // MakeFont call //$RESULT[] = 'MAKE FONT CALL '; //return $RESULT; MakeFont($ttf, "{$fontname}.afm", $_REQUEST['enc']); copy("{$fontname}.php", "../{$fontname}.php"); unlink("{$fontname}.php"); if (file_exists("{$fontname}.z")) { copy("{$fontname}.z", "../{$fontname}.z"); unlink("{$fontname}.z"); } else { copy($ttf, "../{$ttf}"); } unlink("{$fontname}.afm"); unlink("{$fontname}.t1a"); unlink($ttf); echo "<script language='javascript'>alert('Font processed');\n"; echo "window.location.href='addfont.php';</script>"; //exit; } return $RESULT; }
$G["teamcountresults"] = 3; error_reporting(E_ALL - E_NOTICE); include "konfiguracia.php"; include $G["dir"] . ".php"; $G["nadpis"] = $G["nazov"]; if ($argv[1] == "fontimport") { require 'fpdf/font/makefont/makefont.php'; require 'fpdf\\font\\makefont\\makefont.php'; $d = dir("."); while (false !== ($entry = $d->read())) { #echo $entry."\n"; if (strtolower(substr($entry, -4)) == ".pfb" || strtolower(substr($entry, -4)) == ".ttf") { $cmd = "ttf2pt1 " . $entry . " " . substr($entry, 0, -4); echo $cmd . "\n"; exec($cmd); MakeFont($entry, substr($entry, 0, -4) . '.afm', 'cp1250'); } } $d->close(); exit; } class aPDF extends FPDF { var $nadpis; # nadpis PDF suboru var $cislastran; //Page header function Header() { if ($this->noheader) { } else {
<?php include 'makefont.php'; MakeFont('calibrib.ttf', 'calibrib.afm');
<?php //Generation of font definition file for tutorial 7 require 'font/makefont/makefont.php'; MakeFont('verdana.ttf', 'verdana.afm');
<?php /** * PHP file wsp\class\modules\PDF\info\tutoriel\makefont.php */ /** * Class * * WebSite-PHP : PHP Framework 100% object (http://www.website-php.com) * Copyright (c) 2009-2015 WebSite-PHP.com * PHP versions >= 5.2 * * Licensed under The MIT License * Redistributions of files must retain the above copyright notice. * * @author Emilien MOREL <*****@*****.**> * @link http://www.website-php.com * @copyright WebSite-PHP.com 12/05/2015 * @version 1.2.13 * @access public * @since 1.2.0 */ //Génération du fichier de définition de police pour le tutoriel 7 require '../font/makefont/makefont.php'; MakeFont('calligra.ttf', 'calligra.afm');
if (function_exists('gzcompress')) { $file = $basename . '.z'; SaveToFile($file, gzcompress($info['Data']), 'b'); $info['File'] = $file; Message('Font file compressed: ' . $file); } else { $info['File'] = basename($fontfile); Notice('Font file could not be compressed (zlib extension not available)'); } } MakeDefinitionFile($basename . '.php', $type, $enc, $embed, $map, $info); Message('Font definition file generated: ' . $basename . '.php'); } if (PHP_SAPI == 'cli') { // Command-line interface if ($argc == 1) { die("Usage: php makefont.php fontfile [enc] [embed]\n"); } $fontfile = $argv[1]; if ($argc >= 3) { $enc = $argv[2]; } else { $enc = 'cp1252'; } if ($argc >= 4) { $embed = $argv[3] == 'true' || $argv[3] == '1'; } else { $embed = true; } MakeFont($fontfile, $enc, $embed); }
/** * This method add a font to SugarCRM from a font file and a metric file using MakeFont() * @param $font_file string * @param $metric_file string * @param $embedded boolean * @param $encoding_table string * @param $patch array * @param $cid_info string * @param $style string * @return boolean true on success * @see MakeFont() in K_PATH_FONTS/utils */ public function addFont($font_file, $metric_file, $embedded = true, $encoding_table = 'cp1252', $patch = array(), $cid_info = "", $style = "regular") { global $current_user; if (!is_admin($current_user)) { sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']); } $error = false; $oldStr = ob_get_contents(); ob_clean(); require_once "include/tcpdf/fonts/utils/makefont.php"; $filename = MakeFont($font_file, $metric_file, $embedded, $encoding_table, $patch, $cid_info); unlink($font_file); unlink($metric_file); $this->log = ob_get_contents(); ob_clean(); echo $oldStr; if (empty($filename)) { array_push($this->errors, translate("ERR_FONT_MAKEFONT", "Configurator")); $error = true; } else { require_once "include/utils/file_utils.php"; $this->filename = basename($filename . ".php"); if (!$this->loadFontFile()) { if (!mkdir_recursive(K_PATH_CUSTOM_FONTS)) { array_push($this->errors, "Error : Impossible to create the custom font directory."); $error = true; } else { $styleLetter = ""; switch ($style) { case "italic": $styleLetter = "i"; break; case "bold": $styleLetter = "b"; break; case "boldItalic": $styleLetter = "bi"; break; default: $styleLetter = ""; } sugar_rename($filename . ".php", K_PATH_CUSTOM_FONTS . basename($filename . $styleLetter . ".php")); $this->log .= "\n" . translate("LBL_FONT_MOVE_DEFFILE", "Configurator") . K_PATH_CUSTOM_FONTS . basename($filename . $styleLetter . ".php"); if (file_exists($filename . ".z")) { sugar_rename($filename . ".z", K_PATH_CUSTOM_FONTS . basename($filename . $styleLetter . ".z")); $this->log .= "\n" . translate("LBL_FONT_MOVE_FILE", "Configurator") . K_PATH_CUSTOM_FONTS . basename($filename . $styleLetter . ".z"); } if (file_exists($filename . ".ctg.z")) { sugar_rename($filename . ".ctg.z", K_PATH_CUSTOM_FONTS . basename($filename . $styleLetter . ".ctg.z")); $this->log .= "\n" . translate("LBL_FONT_MOVE_FILE", "Configurator") . K_PATH_CUSTOM_FONTS . basename($filename . $styleLetter . ".ctg.z"); } } } else { array_push($this->errors, "\n" . translate("ERR_FONT_ALREADY_EXIST", "Configurator")); $error = true; } if ($error) { if (file_exists($filename . ".php")) { unlink($filename . ".php"); } if (file_exists($filename . ".ctg.z")) { unlink($filename . ".ctg.z"); } if (file_exists($filename . ".z")) { unlink($filename . ".z"); } } } $this->clearCachedFile(); return $error; }
function _LoadFont($fontkey, $family, $encoding) { if (!isset($this->fonts[$fontkey])) { global $g_font_resolver_pdf; $file = $g_font_resolver_pdf->ttf_mappings[$family]; $embed = $g_font_resolver_pdf->embed[$family]; // Remove the '.ttf' suffix $file = substr($file, 0, strlen($file) - 4); // Generate (if required) PHP font description files if (!file_exists($this->_getfontpath() . $fontkey . '.php') || ManagerEncoding::is_custom_encoding($encoding)) { // As MakeFont squeaks a lot, we'll need to capture and discard its output MakeFont(TTF_FONTS_REPOSITORY . $file . '.ttf', TTF_FONTS_REPOSITORY . $file . '.afm', $this->_getfontpath(), $fontkey . '.php', $encoding); } $this->AddFont($fontkey, $family, $encoding, $fontkey . '.php', $embed); } }
if (is_file($name . $type . '.php')) { unlink($name . $type . '.php'); } } // conversion au format afm echo ' Generate AFM file' . "\n"; foreach ($types as $type) { echo ' ' . $name . ' ' . $type . "\n"; exec('ttf2pt1.exe -a ' . $name . $type . '.ttf ' . $name . $type, $output); } // generation du fichier de definition echo ' Generate PHP file in ' . $enc . ' with patch : ' . print_r($enc, true) . "\n"; foreach ($types as $type) { echo ' ' . $name . ' ' . $type . "\n"; echo '<div style="border: solid 1px black; margin-left: 15px; width: 600px;">'; MakeFont($name . $type . '.ttf', $name . $type . '.afm', $enc, $patch); echo '</div>'; } // nettoyage des fichiers inutiles echo ' Delete and move files' . "\n"; foreach ($types as $type) { echo ' ' . $name . ' ' . $type . "\n"; if (is_file($name . $type . '.afm')) { unlink($name . $type . '.afm'); } if (is_file($name . $type . '.t1a')) { unlink($name . $type . '.t1a'); } if (is_file('../_fpdf/font/' . $name . $type . '.z')) { unlink('../_fpdf/font/' . $name . $type . '.z'); }
<?php include_once "makefont.php"; MakeFont('verdana.ttf', 'verdana.afm', 'cp1252');
<?php include 'makefont/makefont.php'; MakeFont('uhvb8v.pfb', 'uhvb8v.afm', 'viscii');
if (!$pos) { die('<b>Error:</b> font file does not seem to be valid Type1'); } $size2 = $pos - $size1; $file = substr($file, 0, $size1 + $size2); } if (function_exists('gzcompress')) { $cmp = $basename . '.z'; SaveToFile($cmp, gzcompress($file), 'b'); $s .= '$file=\'' . $cmp . "';\n"; echo 'Font file compressed (' . $cmp . ')<br>'; } else { $s .= '$file=\'' . basename($fontfile) . "';\n"; echo '<b>Notice:</b> font file could not be compressed (zlib extension not available)<br>'; } if ($type == 'Type1') { $s .= '$size1=' . $size1 . ";\n"; $s .= '$size2=' . $size2 . ";\n"; } else { $s .= '$originalsize=' . filesize($fontfile) . ";\n"; } } else { //Not embedded font $s .= '$file=' . "'';\n"; } $s .= "?>\n"; SaveToFile($basename . '.php', $s, 't'); echo 'Font definition file generated (' . $basename . '.php' . ')<br>'; } MakeFont('Delicious-Heavy.pfb', 'Delicious-Heavy.afm', 'ISO-8859-1', array(164 => 'Euro'), 'Type1');
<?php include_once "makefont.php"; MakeFont('CMUNRM.OTF', 'cp1252', TRUE);
$s.='$file=\''.basename($fontfile)."';\n"; echo '<B>Notice:</B> font file could not be compressed (gzcompress not available)<BR>'; $cmp=$basename.'.ctg'; $f = fopen($cmp, 'wb'); fwrite($f, $cidtogidmap); fclose($f); echo 'CIDToGIDMap created ('.$cmp.')<BR>'; $s.='$ctg=\''.$cmp."';\n"; } if($type=='Type1') { $s.='$size1='.$size1.";\n"; $s.='$size2='.$size2.";\n"; } else $s.='$originalsize='.filesize($fontfile).";\n"; } else { //Not embedded font $s.='$file='."'';\n"; } $s.="?>\n"; SaveToFile($basename.'.php',$s); echo 'Font definition file generated ('.$basename.'.php'.')<BR>'; } MakeFont('font.ttf','font.ufm'); ?>
<?php require 'fpdf/font/makefont/makefont.php'; MakeFont('fpdf/ttf/arial.ttf', 'fpdf/ttf/arial.afm', 'cp1251'); MakeFont('fpdf/ttf/arialb.ttf', 'fpdf/ttf/arialb.afm', 'cp1251'); MakeFont('fpdf/ttf/arialbi.ttf', 'fpdf/ttf/arialbi.afm', 'cp1251'); MakeFont('fpdf/ttf/ariali.ttf', 'fpdf/ttf/ariali.afm', 'cp1251'); MakeFont('fpdf/ttf/times.ttf', 'fpdf/ttf/times.afm', 'cp1251'); MakeFont('fpdf/ttf/timesb.ttf', 'fpdf/ttf/timesb.afm', 'cp1251'); MakeFont('fpdf/ttf/timesbi.ttf', 'fpdf/ttf/timesbi.afm', 'cp1251'); MakeFont('fpdf/ttf/timesi.ttf', 'fpdf/ttf/timesi.afm', 'cp1251'); MakeFont('fpdf/ttf/cour.ttf', 'fpdf/ttf/cour.afm', 'cp1251'); MakeFont('fpdf/ttf/courb.ttf', 'fpdf/ttf/courb.afm', 'cp1251'); MakeFont('fpdf/ttf/courbi.ttf', 'fpdf/ttf/courbi.afm', 'cp1251'); MakeFont('fpdf/ttf/couri.ttf', 'fpdf/ttf/couri.afm', 'cp1251');
<?php require 'C:\\xampp\\php\\pear\\fpdf\\makefont\\makefont.php'; MakeFont('C:\\Users\\Bison\\Downloads\\mistral.ttf', 'ISO-8859-15');
<?php require 'makefont.php'; MakeFont('ariblk.ttf', 'arialb.afm', 'cp1252');
<?php require 'fpdf/makefont/makefont.php'; MakeFont('C:\\xampp\\htdocs\\sdm\\fpdf\\font\\ARLRDBD.TTF', 'cp1252');
$cmp = $basename . '.ctg'; $f = fopen($cmp, 'wb'); fwrite($f, $cidtogidmap); fclose($f); echo 'CIDToGIDMap created (' . $cmp . ')<BR>'; $s .= ' font[:ctg]=\'' . $cmp . "'\n"; } if ($type == 'Type1') { $s .= ' font[:size1]=' . $size1 . "\n"; $s .= ' font[:size2]=' . $size2 . "\n"; } else { $s .= ' font[:originalsize]=' . filesize($fontfile) . "\n"; } } else { //Not embedded font $s .= ' font[:file]=' . "''\n"; } $s .= "end\n"; SaveToFile($basename . '.rb', $s); echo 'Font definition file generated (' . $basename . '.rb' . ')<BR>'; } $arg = $GLOBALS['argv']; if (count($arg) >= 3) { ob_start(); array_shift($arg); MakeFont($arg[0], $arg[1]); $t = ob_get_clean(); print preg_replace('!<BR( /)?>!i', "\n", $t); } else { print "Usage: makefontuni_ruby.php <ttf-file> <ufm-file>\n"; }
} else { if ($step == 3) { $ff = scandir('./'); foreach ($ff as $f) { if (substr($f, -4, 4) == '.ttf') { $file = substr($f, 0, strlen($f) - 4); foreach ($cpages as $cpage) { $success = false; if ($cpage == 'win-1252') { $success = MakeFont($file . '.pfb', $file . '.afm', 'win-1252'); if ($success) { @unlink($file . '.pfb'); @unlink($file . '.afm'); } } else { $success = MakeFont($file . '-' . $cpage . '.pfb', $file . '-' . $cpage . '.afm', $cpage); if ($success) { @unlink($file . '-' . $cpage . '.pfb'); @unlink($file . '-' . $cpage . '.afm'); } } } } } echo '<h3>Step 3 - Unibyte (codepage) font files - C</h3>'; echo '<p>When you have done that, check you have the following files (for each of your original .ttf files):</p>'; echo '<ul><li>fontname.z</li>'; echo '<li>fontname.php</li>'; echo '<li>fontname-win-1251.z</li>'; echo '<li>fontname-win-1251.php</li>'; echo '<li>fontname-iso-8859-2.z</li>';
function _LoadFont($fontkey, $family, $encoding, $style) { $style = strtolower($style); if (!isset($this->fonts[$fontkey])) { global $g_font_resolver_pdf; $file = $g_font_resolver_pdf->ttf_mappings[$family]; $embed = $g_font_resolver_pdf->embed[$family]; // Remove the '.ttf' suffix $file = substr($file, 0, strlen($file) - 4); // Generate (if required) PHP font description files if (!file_exists($this->_getfontpath() . $fontkey . '.php')) { // As MakeFont squeaks a lot, we'll need to capture and discard its output ob_start(); MakeFont(PDFLIB_TTF_FONTS_REPOSITORY . $file . '.ttf', PDFLIB_TTF_FONTS_REPOSITORY . $file . '.afm', $this->_getfontpath(), $fontkey . '.php', $encoding); ob_end_clean(); } $this->AddFont($fontkey, $family, "", $encoding, $fontkey . '.php', $embed); } }
<?php require('font/makefont.php'); // // แทรกไฟล์สร้างฟอนต์จากโฟลเดอร์ font มาใช้งาน MakeFont('E:\xampp\htdocs\Jknowledge\font\THSarabun.ttf','cp874'); // MakeFont('พาธของฟอนต์','Encode ของฟอนต์'); ?>
fseek($f, $offset, SEEK_SET); //Extract fsType flags fseek($f, 8, SEEK_CUR); $fsType = ReadShort($f); $rl = ($fsType & 0x2) != 0; $pp = ($fsType & 0x4) != 0; $e = ($fsType & 0x8) != 0; fclose($f); if ($rl and !$pp and !$e) { print "Warning: font license does not allow embedding\n"; } } $arg = $GLOBALS['argv']; if (count($arg) >= 3) { ob_start(); array_shift($arg); if (!isset($arg[2])) { $arg[2] = true; } if (!isset($arg[3])) { $arg[3] = 'cp1252'; } if (!isset($arg[4])) { $arg[4] = array(); } MakeFont($arg[0], $arg[1], $arg[2], $arg[3], $arg[4]); $t = ob_get_clean(); print preg_replace('!<BR( /)?>!i', "\n", $t); } else { print "Usage: makefont.php <ttf file> <afm/ufm file> <encoding> <patch>\n"; }
<?php require 'makefont/makefont.php'; MakeFont('Function-Regular.ttf', 'cp1252');
<?php require('makefont2.php'); // แทรกไฟล์สร้างฟอนต์จากโฟลเดอร์ makefont มาใช้งาน MakeFont('THSarabun.ttf','cp874'); // MakeFont('พาธของฟอนต์','Encode ของฟอนต์'); MakeFont('THSarabun Bold.ttf','cp874'); // MakeFont('พาธของฟอนต์','Encode ของฟอนต์'); MakeFont('THSarabun BoldItalic.ttf','cp874'); // MakeFont('พาธของฟอนต์','Encode ของฟอนต์'); MakeFont('THSarabun Italic.ttf','cp874'); // MakeFont('พาธของฟอนต์','Encode ของฟอนต์'); ?>
#!/usr/bin/env php <?php if (php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) { require 'make-fpdf-fonts/makefont.php'; $usage = <<<EOD Usage: makefont /path/to/fonts/root EOD; if ($argc < 2) { exit($usage); } $fonts_path = realpath($argv[1]); if (!is_dir($fonts_path)) { exit($fonts_path . ' does not appear to be a directory'); } $save_path = $fonts_path . '/metrics'; if (!is_dir($save_path)) { mkdir($save_path); } foreach (glob($fonts_path . '/*/*ttf') as $font) { system(implode(' ', array('ttf2pt1 -a', escapeshellarg($font), escapeshellarg(pathinfo($font, PATHINFO_FILENAME))))); // no control over output directories is provided by these files by default, so we // get to do a rename dance! rename(pathinfo($font, PATHINFO_FILENAME) . '.afm', pathinfo($font, PATHINFO_DIRNAME) . '/' . pathinfo($font, PATHINFO_FILENAME) . '.afm'); rename(pathinfo($font, PATHINFO_FILENAME) . '.t1a', pathinfo($font, PATHINFO_DIRNAME) . '/' . pathinfo($font, PATHINFO_FILENAME) . '.t1a'); MakeFont($font, str_replace('ttf', 'afm', $font), 'ISO-8859-1'); rename(pathinfo($font, PATHINFO_FILENAME) . '.php', $save_path . '/' . pathinfo($font, PATHINFO_FILENAME) . '.php'); rename(pathinfo($font, PATHINFO_FILENAME) . '.z', $save_path . '/' . pathinfo($font, PATHINFO_FILENAME) . '.z'); } }
<?php // Generation of font definition file for tutorial 7 require('../makefont/makefont.php'); MakeFont('calligra.ttf', 'cp1252'); ?>
<?php require 'makefont/makefont.php'; MakeFont('FRADMCN.TTF', 'franklin_gothic.afm');