예제 #1
0
/**
 * フォント設定を読み込む
 *
 * @return void
 */
function p2_fontconfig_apply_custom()
{
    global $STYLE, $_conf, $skin_en, $skin_uniq;
    if ($_conf['expack.skin.enabled']) {
        if (isset($_conf['expack.am.fontfamily'])) {
            $_conf['expack.am.fontfamily.orig'] = $_conf['expack.am.fontfamily'];
        } else {
            $_conf['expack.am.fontfamily.orig'] = '';
        }
        if (file_exists($_conf['expack.skin.fontconfig_path'])) {
            $fontconfig_data = file_get_contents($_conf['expack.skin.fontconfig_path']);
            $current_fontconfig = unserialize($fontconfig_data);
        }
        if (!is_array($current_fontconfig)) {
            $current_fontconfig = array('enabled' => false, 'custom' => array());
        }
        $type = p2_fontconfig_detect_agent();
        if ($current_fontconfig['enabled'] && is_array($current_fontconfig['custom'][$type])) {
            $skin_uniq = P2_VERSION_ID . sprintf('.%u', crc32($fontconfig_data));
            foreach ($current_fontconfig['custom'][$type] as $key => $value) {
                if ($value === '') {
                    continue;
                } elseif ($key == 'fontfamily_aa') {
                    if ($value == '-') {
                        $_conf['expack.am.fontfamily'] = '';
                    } else {
                        $_conf['expack.am.fontfamily'] = p2_correct_css_fontfamily($value);
                    }
                } else {
                    $STYLE["{$key}.orig"] = isset($STYLE[$key]) ? $STYLE[$key] : '';
                    if (strpos($key, 'fontfamily') !== false) {
                        $STYLE[$key] = p2_correct_css_fontfamily($value);
                    } else {
                        $STYLE[$key] = $value;
                    }
                }
            }
            $skin_en = preg_replace('/&_=[^&]*/', '', $skin_en) . '&_=' . rawurlencode($skin_uniq);
        }
    }
}
예제 #2
0
$controllerObject = (object) array('fontconfig_types' => $fontconfig_types, 'fontconfig_params' => $fontconfig_params, 'skindata' => p2_fontconfig_load_skin_setting(), 'safari' => 0, 'mac' => false);
if (file_exists($_conf['expack.skin.fontconfig_path'])) {
    $current_fontconfig = unserialize(file_get_contents($_conf['expack.skin.fontconfig_path']));
    if (!is_array($current_fontconfig)) {
        $current_fontconfig = array('enabled' => false, 'custom' => array());
    }
} else {
    FileCtl::make_datafile($_conf['expack.skin.fontconfig_path']);
    $current_fontconfig = array('enabled' => false, 'custom' => array());
}
$fontconfig_hash = md5(serialize($current_fontconfig));
$updated_fontconfig = array('enabled' => false, 'custom' => array());
// Mac はブラウザによって文字のレンダリング結果が大きく変わり
// その種類もそこそこ多いので現在のブラウザにマッチしないものを隠す
$ft =& $controllerObject->fontconfig_types;
$type = p2_fontconfig_detect_agent();
switch ($type) {
    case 'safari3':
        $controllerObject->safari = 3;
        unset($ft['safari2'], $ft['safari1'], $ft['macosx'], $ft['macos9']);
        break;
    case 'safari2':
        $controllerObject->safari = 2;
        unset($ft['safari3'], $ft['safari1'], $ft['macosx'], $ft['macos9']);
        break;
    case 'safari1':
        $controllerObject->safari = 1;
        unset($ft['safari3'], $ft['safari2'], $ft['macosx'], $ft['macos9']);
        break;
    case 'macosx':
        $controllerObject->mac = true;