Esempio n. 1
0
$FLIR['maxheight'] = is_number($_GET['h']) ? $_GET['h'] : UNKNOWN_FONT_SIZE;
// pixels
$FLIR['maxwidth'] = is_number($_GET['w']) ? $_GET['w'] : 800;
// pixels
$font_file = '';
$FStyle['cFont'] = strtolower($FStyle['cFont']);
$FONT_PARENT = false;
if (isset($fonts[$FStyle['cFont']])) {
    $font_file = $fonts[$FStyle['cFont']];
    if (is_array($font_file)) {
        $FONT_PARENT = reset($font_file);
        $font_file = match_font_style($font_file);
        $FONT_PARENT = $fonts_dir . (isset($FONT_PARENT['file']) ? $FONT_PARENT['file'] : $font_file);
    }
} elseif (FONT_DISCOVERY) {
    $font_file = discover_font($fonts['default'], $FStyle['cFont']);
} else {
    $font_file = $fonts['default'];
}
$FLIR['font'] = $fonts_dir . $font_file;
//die($FStyle['cFont']);
if (!is_file($FLIR['font'])) {
    err('FONT_DOESNT_EXIST');
}
if (in_array(strtolower(pathinfo($FLIR['font'], PATHINFO_EXTENSION)), array('pfb', 'pfm'))) {
    // pfm doesn't work
    // You can try uncommenting this line to see what kind of mileage you get.
    err('FONT_PS_UNSUPPORTED');
    // PostScript will work as long as you don't set any kind of spacing... unless you are using Windows (PHP bug?).
    $FLIR['postscript'] = true;
    $FLIR['ps'] = array('kerning' => 0, 'space' => 0);
$md5 = md5(($FLIR['mode'] == 'wrap' ? $FLIR['maxwidth'] : '') . $FLIR['font'] . ($_GET['c'] . $FLIR['text']));
$FLIR['cache'] = get_cache_fn($md5, $FLIR['output']);
$FLIR['file_meta'] = array();
// plugins can store info in file_meta that will be available to other plugins
$font_file = '';
$CSS['font-family'] = strtolower($CSS['font-family']);
$FONT_PARENT = false;
if (isset($fonts[$CSS['font-family']])) {
    $font_file = $fonts[$CSS['font-family']];
    if (is_array($font_file)) {
        $FONT_PARENT = reset($font_file);
        $font_file = match_font_style($font_file);
        $FONT_PARENT = $fonts_dir . (isset($FONT_PARENT['file']) ? $FONT_PARENT['file'] : $font_file);
    }
} elseif (FONT_DISCOVERY) {
    $font_file = discover_font($fonts['default'], $CSS['font-family']);
} else {
    $font_file = $fonts['default'];
}
$FLIR['font'] = $fonts_dir . $font_file;
if (!is_file($FLIR['font'])) {
    err('FONT_DOESNT_EXIST');
}
$SPACE_BOUNDS = false;
if (is_number($CSS['letter-spacing'], true, false, true)) {
    $SPACE_BOUNDS = bounding_box(' ');
    $spaces = ceil($CSS['letter-spacing'] / $SPACE_BOUNDS['width']);
    if ($spaces > 0) {
        $FLIR['text'] = space_out($FLIR['text'], $spaces);
        define('SPACING_GAP', $spaces);
    }