forked from jaywcjlove/free-font
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreview.html
152 lines (149 loc) · 9.12 KB
/
preview.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Free Font - 收录商用免费字体,包括汉字和英文字体,提供免费下载和使用。">
<meta name="keywords" content="免费字体, 商用字体, 汉字字体, 英文字体, 字体下载, 免费商用字体, free fonts, commercial free fonts, Chinese fonts, English fonts, font download, free commercial fonts">
<meta name="author" content="jaywcjlove">
<meta property="og:title" content="Free Font - 收录商用免费字体(汉字英文字体)">
<meta property="og:description" content="Free Font - 收录商用免费字体,包括汉字和英文字体,提供免费下载和使用。">
<meta property="og:type" content="website">
<meta property="og:url" content="https://wangchujiang.com/free-font/preview.html">
<meta property="og:image" content="https://wangchujiang.com/icons/banner.jpeg">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:creator" content="jaywcjlove">
<meta name="twitter:title" content="Free Font - 收录商用免费字体(汉字英文字体)">
<meta name="twitter:description" content="Free Font - 收录商用免费字体,包括汉字和英文字体,提供免费下载和使用。">
<meta name="twitter:image" content="https://wangchujiang.com/icons/banner.jpeg">
<title>Free Font - 收录商用免费字体(汉字英文字体)</title>
<link rel="stylesheet" type="text/css" href="css/main.css?v=2.10.0">
<link rel="stylesheet" type="text/css" href="css/preview.css?v=2.10.0">
</head>
<body>
<a href="https://github.com/jaywcjlove/free-font" target="_blank" class="github-corner">
<svg viewBox="0 0 250 250">
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z" fill="#dcdcdc3d"></path>
<path class="octo-arm" fill="currentColor" style="transform-origin: 130px 106px;" d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"></path>
<path fill="currentColor" class="octo-body" d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"></path>
</svg>
</a>
<header>
<h1><a href="./index.html">商用免费字体</a></h1>
<nav>
<a class="" href="index.html">全部字体</a>
<a class="" href="hei.html">黑体</a>
<a class="" href="kai.html">楷体</a>
<a class="" href="song.html">宋体</a>
<a class="" href="art.html">艺术体</a>
<a class="" href="handwriting.html">手绘体</a>
<a class="" href="english.html">英文字体</a>
<a class="" href="open-source.html">开源字体</a>
</nav>
<p>Free Font 收录商用免费字体,已收录 <a href="https://github.com/jaywcjlove/free-font" target="_blank">861</a> 个字体</p>
<a href="" id="download">
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" class="bi bi-file-earmark-font-fill" viewBox="0 0 16 16" height="1em" width="1em">
<path d="M9.293 0H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V4.707A1 1 0 0 0 13.707 4L10 .293A1 1 0 0 0 9.293 0zM9.5 3.5v-2l3 3h-2a1 1 0 0 1-1-1zM5.057 6h5.886L11 8h-.5c-.18-1.096-.356-1.192-1.694-1.235l-.298-.01v5.09c0 .47.1.582.903.655v.5H6.59v-.5c.799-.073.898-.184.898-.654V6.755l-.293.01C5.856 6.808 5.68 6.905 5.5 8H5l.057-2z"/>
</svg>
</a>
<div id="license"></div>
<div id="preview"></div>
</header>
<main>
<p id="font-status" align="center"></p>
<h2>简体字预览</h2>
<pre contenteditable="true">
天地玄黄,宇宙洪荒。日月盈昃,辰宿列张。寒来暑往,秋收冬藏。
闰余成岁,律吕调阳。云腾致雨,露结为霜。金生丽水,玉出昆冈。
剑号巨阙,珠称夜光。果珍李柰,菜重芥姜。海咸河淡,鳞潜羽翔。
龙师火帝,鸟官人皇。始制文字,乃服衣裳。推位让国,有虞陶唐。
吊民伐罪,周发殷汤。坐朝问道,垂拱平章。爱育黎首,臣伏戎羌。
遐迩一体,率宾归王。鸣凤在竹,白驹食场。化被草木,赖及万方。</pre>
<h2>繁体字预览</h2>
<pre contenteditable="true">
天地玄黃,宇宙洪荒。日月盈昃,辰宿列張。寒來暑往,秋收冬藏。
閏余成歲,律呂調陽。雲騰致雨,露結為霜。金生麗水,玉出崑岡。
劍號巨闕,珠稱夜光。果珍李柰,菜重芥姜。海咸河淡,鱗潛羽翔。
龍師火帝,鳥官人皇。始制文字,乃服衣裳。推位讓國,有虞陶唐。
弔民伐罪,周發殷湯。坐朝問道,垂拱平章。愛育黎首,臣伏戎羌。
遐邇一體,率賓歸王。鳴鳳在竹,白駒食場。化被草木,賴及萬方。</pre>
<h2>大写字母预览</h2>
<pre contenteditable="true">A B C D E F G H I J K L M N O P Q R S T U V W X Y Z</pre>
<h2>小写字母预览</h2>
<pre contenteditable="true">a b c d e f g h i j k l m n o p q r s t u v w x y z</pre>
<h2>数字预览</h2>
<pre contenteditable="true">0 1 2 3 4 5 6 7 8 9</pre>
</main>
<script>
window.onload = function() {
const urlParams = new URLSearchParams(window.location.search);
const fontUrl = urlParams.get('p');
const fontName = urlParams.get('t');
if (fontUrl) {
let styleTag = document.getElementById('dynamic-style');
if (!styleTag) {
styleTag = document.createElement('style');
styleTag.id = 'dynamic-style';
document.head.appendChild(styleTag);
}
const fontFaceRule = `
@font-face { font-family: 'PreviewFont'; src: url('${fontUrl}') format('truetype');}
main, main pre {
font-family: 'PreviewFont', sans-serif;
}
`;
styleTag.innerHTML = fontFaceRule;
// Define the font face
const font = new FontFace('PreviewFont', `url(${fontUrl})`);
const statusElement = document.getElementById('font-status');
document.fonts.ready.then((fontFaceSet) => {
if (fontFaceSet.check('1em PreviewFont')) {
statusElement.textContent = `"${fontName}"已加载`;
statusElement.classList.add('done');
} else {
statusElement.textContent = `"${fontName}"尚未加载`;
}
});
statusElement.textContent = `"${fontName}"正在加载...`;
// Load the font
font.load().then((loadedFont) => {
document.fonts.add(loadedFont);
statusElement.textContent = `"${fontName}"已加载`;
statusElement.classList.add('done');
}).catch((error) => {
console.error('Failed to load the custom font:', error);
statusElement.textContent = `加载"${fontName}"失败`;
});
const download = document.getElementById('download');
download.href = fontUrl;
const svgIcon = `<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" class="bi bi-file-earmark-font-fill" viewBox="0 0 16 16" height="1em" width="1em"><path d="M9.293 0H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V4.707A1 1 0 0 0 13.707 4L10 .293A1 1 0 0 0 9.293 0zM9.5 3.5v-2l3 3h-2a1 1 0 0 1-1-1zM5.057 6h5.886L11 8h-.5c-.18-1.096-.356-1.192-1.694-1.235l-.298-.01v5.09c0 .47.1.582.903.655v.5H6.59v-.5c.799-.073.898-.184.898-.654V6.755l-.293.01C5.856 6.808 5.68 6.905 5.5 8H5l.057-2z"/> </svg>`
download.innerHTML = `${svgIcon} 下载字体:${fontName}`;
const preview = document.getElementById('preview')
if (preview && fontName) {
preview.innerHTML = `<img src="./images/${fontName}-preview.jpg" alt="${fontName}" />`;
}
const licenseElement = document.getElementById('license');
const urlHome = urlParams.get('u');
const license = urlParams.get('l');
const size = urlParams.get('s');
let licenseText = [];
if (size) licenseText.push(`<span class="size">${size}</span>`);
if (license) licenseText.push(`<span>${license}</span>`);
if (urlHome) licenseText.push(`<a href="${urlHome}" target="_blank">来源</a>`);
if (fontUrl) licenseText.push(`<a href="https://github.com/jaywcjlove/free-font/tree/main/docs/${fontUrl}" target="_blank">文件</a>`);
if (licenseText.length > 0) {
licenseElement.innerHTML = licenseText.join(' ');
} else {
licenseElement.remove();
}
}
};
</script>
<footer class="footer">
您可以在<a href="https://github.com/jaywcjlove/free-font" target="_blank">这里</a>提交商用免费字体 <sup>2.10.0</sup><br />
<div>
Made by<a href="https://jaywcjlove.github.io/#/sponsor" target="_blank"> 小弟调调™ </a>with<span class="heart"> ❤</span></span>
</div>
</footer>
</body>
</html>