Example #1
0
function CheckTTF($file)
{
	//Check if font license allows embedding
	$f = fopen($file, 'rb');
	if (!$f) {
		die('Error: unable to open ' . $file);
	}
	//Extract number of tables
	fseek($f, 4, SEEK_CUR);
	$nb = ReadShort($f);
	fseek($f, 6, SEEK_CUR);
	//Seek OS/2 table
	$found = false;
	for ($i = 0; $i < $nb; $i++) {
		if (fread($f, 4) == 'OS/2') {
			$found = true;
			break;
		}
		fseek($f, 12, SEEK_CUR);
	}
	if (!$found) {
		fclose($f);

		return;
	}
	fseek($f, 4, SEEK_CUR);
	$offset = ReadLong($f);
	fseek($f, $offset, SEEK_SET);
	//Extract fsType flags
	fseek($f, 8, SEEK_CUR);
	$fsType = ReadShort($f);
	$rl = ($fsType & 0x02) != 0;
	$pp = ($fsType & 0x04) != 0;
	$e = ($fsType & 0x08) != 0;
	fclose($f);
	if ($rl AND (!$pp) AND (!$e)) {
		print "Warning: font license does not allow embedding\n";
	}
}
Example #2
0
function CheckTTF($file)
{
    //Check if font license allows embedding
    $f = fopen($file, 'rb');
    if (!$f) {
        die('<B>Error:</B> Can\'t open ' . $file);
    }
    //Extract number of tables
    fseek($f, 4, SEEK_CUR);
    $nb = ReadShort($f);
    fseek($f, 6, SEEK_CUR);
    //Seek OS/2 table
    $found = false;
    for ($i = 0; $i < $nb; $i++) {
        if (fread($f, 4) == 'OS/2') {
            $found = true;
            break;
        }
        fseek($f, 12, SEEK_CUR);
    }
    if (!$found) {
        fclose($f);
        return;
    }
    fseek($f, 4, SEEK_CUR);
    $offset = ReadLong($f);
    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) {
        echo '<B>Warning:</B> font license does not allow embedding';
    }
}
Example #3
0
function CheckTTF($file)
{
    $f = fopen($file, 'rb');
    if (!$f) {
        die('<b>Error:</b> Can\'t open ' . $file);
    }
    fseek($f, 4, SEEK_CUR);
    $nb = ReadShort($f);
    fseek($f, 6, SEEK_CUR);
    $found = false;
    for ($i = 0; $i < $nb; $i++) {
        if (fread($f, 4) == 'OS/2') {
            $found = true;
            break;
        }
        fseek($f, 12, SEEK_CUR);
    }
    if (!$found) {
        fclose($f);
        return;
    }
    fseek($f, 4, SEEK_CUR);
    $offset = ReadLong($f);
    fseek($f, $offset, SEEK_SET);
    fseek($f, 8, SEEK_CUR);
    $fsType = ReadShort($f);
    $rl = ($fsType & 0x2) != 0;
    $pp = ($fsType & 0x4) != 0;
    $e = ($fsType & 0x8) != 0;
    fclose($f);
    if ($rl && !$pp && !$e) {
        echo '<b>Warning:</b> font license does not allow embedding';
    }
}