This commit is contained in:
杜恒 2021-03-20 09:18:29 +08:00
parent 514662f407
commit 608bff9df1
2 changed files with 12 additions and 17 deletions

View File

@ -339,8 +339,8 @@ function themeConfig($form)
NULL,
'自定义网站字体(非必填)',
'介绍:用于修改全站字体,填写则使用引入的字体,不填写使用默认字体 <br>
格式字体URL链接 <br>
注意:由于体积文件较大建议使用cdn链接方式进行引入'
格式字体URL链接推荐使用woff格式的字体网页专用字体格式 <br>
注意:字体文件一般有几兆建议使用cdn链接'
);
$JCustomFont->setAttribute('class', 'joe_content joe_global');
$form->addInput($JCustomFont);

View File

@ -29,18 +29,12 @@
detectIE() && (alert('当前站点不支持IE浏览器或您开启了兼容模式请使用其他浏览器访问或关闭兼容模式。'), (location.href = 'https://www.baidu.com'))
</script>
<?php
$format = null;
if (strpos($this->options->JCustomFont, 'woff2') !== false) {
$format = 'woff2';
} elseif (strpos($this->options->JCustomFont, 'woff') !== false) {
$format = 'woff';
} elseif (strpos($this->options->JCustomFont, 'ttf') !== false) {
$format = 'truetype';
} elseif (strpos($this->options->JCustomFont, 'eot') !== false) {
$format = 'embedded-opentype';
} elseif (strpos($this->options->JCustomFont, 'svg') !== false) {
$format = 'svg';
}
$fontUrl = $this->options->JCustomFont;
if (strpos($fontUrl, 'woff2') !== false) $fontFormat = 'woff2';
elseif (strpos($fontUrl, 'woff') !== false) $fontFormat = 'woff';
elseif (strpos($fontUrl, 'ttf') !== false) $fontFormat = 'truetype';
elseif (strpos($fontUrl, 'eot') !== false) $fontFormat = 'embedded-opentype';
elseif (strpos($fontUrl, 'svg') !== false) $fontFormat = 'svg';
?>
<style>
@font-face {
@ -48,12 +42,13 @@ if (strpos($this->options->JCustomFont, 'woff2') !== false) {
font-weight: 400;
font-style: normal;
font-display: swap;
src: url('<?php $this->options->JCustomFont() ?>');
<?php if ($format) echo "src: url('{$this->options->JCustomFont}') fromat('{$format}');" ?>
src: url('<?php echo $fontUrl ?>');
<?php if ($fontFormat) : ?>src: url('<?php echo $fontUrl ?>') format('<?php echo $fontFormat ?>');
<?php endif; ?>
}
body {
<?php if ($this->options->JCustomFont) : ?>font-family: 'Joe Font';
<?php if ($fontUrl) : ?>font-family: 'Joe Font';
<?php else : ?>font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', Arial, sans-serif;
<?php endif; ?>
}