forked from segabito/ZenzaWatch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFontTest.html
203 lines (164 loc) · 8.45 KB
/
FontTest.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>FontTest</title>
<style type="text/css" id="layoutCss">%LAYOUT_CSS%</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.10.1/lodash.js"></script>
<style type="text/css">
#fontTest { white-space: pre; letter-spacing: 1px; font-weight: bolder; font-kerning: none; }
.big { font-size: 39px; line-height: 45px;}
.medium { font-size: 24px; line-height: 29px;}
.small { font-size: 15px; line-height: 18px;}
.arial { font-family: Arial; background: red; display: inline-block; }
.gothic { font-family: 'MS Pゴシック'; background: blue; display: inline-block;}
.mono { font-family: 'Courier New', 'Osaka-mono', 'MS ゴシック', monospace; background: green; display: inline-block;}
.mono2 { font-family: 'Osaka-mono', 'MS ゴシック', monospace; background: lightgreen; display: inline-block;}
.zero { font-family: 'Arial'; background: cyan; display: inline-block;}
.big.mono.type9 { letter-spacing: 1.6241em; } /* 1387.94px */
.medium.mono.type9 { letter-spacing: 1.6252em; } /* 854.5px */
.small.mono.type9 { letter-spacing: 1.5375em; } /* 513px */
.big.mono.type20 { letter-spacing: -0.2966em; } /* 189.375px */
.medium.mono.type20 { letter-spacing: -0.2806em; } /* 122.688px */
.small.mono.type20 { letter-spacing: -0.2667em; } /* 80px */
.big.mono.type2001 { } /* 640px */
.medium.mono.type2001 { }
.small.mono.type2001 { }
.big.mono.type2003 { } /* 640px */
.medium.mono.type2003 { }
.small.mono.type2003 { }
.big.mono.type3000 { letter-spacing: -0.3103em; } /* 430.375px */
.medium.mono.type3000 { letter-spacing: -0.2943em; } /* 271px */
.small.mono.type3000 { letter-spacing: -0.2693em; } /* 175.375px */
.big.mono.typeA0 { letter-spacing: -0.2966em; } /* 189.375px */
.medium.mono.typeA0 { letter-spacing: -0.2806em; } /* 122.688px */
.small.mono.typeA0 { letter-spacing: -0.2667em; } /* 80px */
.big.mono.typeE800 { } /* 652.188px */ /* MSPゴシック合わせ */
.medium.mono.typeE800 { } /* 407.5px */
.small.mono.typeE800 { } /* 260.688px */
.big.mono2.type9 { letter-spacing: 1.6241em; } /* 1387.94px */
.medium.mono2.type9 { letter-spacing: 1.6252em; } /* 854.5px */
.small.mono2.type9 { letter-spacing: 1.5375em; } /* 513px */
.big.mono2.type20 { letter-spacing: -0.1965em; } /* 189.375px */
.medium.mono2.type20 { letter-spacing: -0.1806em; } /* 122.688px */
.small.mono2.type20 { letter-spacing: -0.1667em; } /* 80px */
.big.mono2.type20 { letter-spacing: -0.216em; } /* 189.375px */
.medium.mono2.type20 { letter-spacing: -0.2001em; } /* 122.688px */
.small.mono2.type20 { letter-spacing: -0.1862em; } /* 80px */
.big.mono2.type2001 { } /* 640px */
.medium.mono2.type2001 { }
.small.mono2.type2001 { }
.big.mono2.type2003 { } /* 640px */
.medium.mono2.type2003 { }
.small.mono2.type2003 { }
.big.mono2.type3000 { letter-spacing: -0.3103em; } /* 430.375px */
.medium.mono2.type3000 { letter-spacing: -0.2943em; } /* 271px */
.small.mono2.type3000 { letter-spacing: -0.2693em; } /* 175.375px */
.big.mono2.type3000 { letter-spacing: -0.3298em; } /* 430.375px */
.medium.mono2.type3000 { letter-spacing: -0.3138em; } /* 271px */
.small.mono2.type3000 { letter-spacing: -0.2888em; } /* 175.375px */
.big.mono2.typeA0 { letter-spacing: -0.1965em; } /* 189.375px */
.medium.mono2.typeA0 { letter-spacing: -0.1806em; } /* 122.688px */
.small.mono2.typeA0 { letter-spacing: -0.1667em; } /* 80px */
.big.mono2.typeA0 { letter-spacing: -0.216em; } /* 189.375px */
.medium.mono2.typeA0 { letter-spacing: -0.2001em; } /* 122.688px */
.small.mono2.typeA0 { letter-spacing: -0.1862em; } /* 80px */
.big.mono2.typeE800 { } /* 652.188px */ /* MSPゴシック合わせ */
.medium.mono2.typeE800 { } /* 407.5px */
.small.mono2.typeE800 { } /* 260.688px */
/* 固定幅フォント ー letter-spacing ではなく、 ゼロ幅文字 + letter-spacing という発想 */
.big.zero.type9 > spacer { width: 86.55875px; } /* 1387.94px */
.medium.zero.type9 > spacer { width: 53.4px; } /* 854.5px */
.small.zero.type9 > spacer { width: 32.0625px; } /* 513px */
.big.zero.type20 > spacer { width: 11.8359375px; } /* 189.375px */
.medium.zero.type20 > spacer { width: 7.668px; } /* 122.688px */
.small.zero.type20 > spacer { width: 5px; } /* 80px */
.big.zero.type2001 { } /* 640px */
.medium.zero.type2001 { }
.small.zero.type2001 { }
.big.zero.type2003 { } /* 640px */
.medium.zero.type2003 { }
.small.zero.type2003 { }
.big.zero.type3000 > spacer { width: 26.8984375px; } /* 430.375px */
.medium.zero.type3000 > spacer { width: 16.9375px; } /* 271px */
.small.zero.type3000 > spacer { width: 10.9609375px; } /* 175.375px */
.big.zero.typeA0 > spacer { width: 11.8359375px; } /* 189.375px */
.medium.zero.typeA0 > spacer { width: 7.668px; } /* 122.688px */
.small.zero.typeA0 > spacer { width: 5px; } /* 80px */
.big.zero.typeE800 { } /* 652.188px */ /* MSPゴシック合わせ */
.medium.zero.typeE800 { } /* 407.5px */
.small.zero.typeE800 { } /* 260.688px */
spacer { display: inline-block; overflow: hidden; outline: 1px dotted silver; height: 10px;}
</style>
<body>
<div id="fontTest">
<!--<p>こんなことするより、MSPゴシックと同幅で空白文字だけのWeb Font作ったらいいんじゃないか?</p>-->
<div style="font-size: 24px; letter-spacing: 1px;">
<span style="display: inline-block; width: 24px; height: 24px;"><span style="">◢</span></span><span style="background: #666;">█</span>
</div>
</div>
<script type="text/javascript">
var textList = [
String.fromCharCode(0x09), // tab
String.fromCharCode(0x20),
String.fromCharCode(0x2001),
String.fromCharCode(0x2003),
String.fromCharCode(0x3000),
String.fromCharCode(0x3164),
String.fromCharCode(0x00A0),
String.fromCharCode(0xE800),
'lW'
];
var tmp = [];
textList.forEach(function(text) {
var c = text.charCodeAt(0).toString(16).toUpperCase();
//while(text.length < 16) { text = text + text; }
text = text.repeat(parseInt(Math.random() * 20) + 1);
var t = (text.charAt(0) === '\t') ? text.replace(/[\t]/g , '^') : text;
t = t.replace(/([\u3000]+)/g ,
function(g) { return '□'.repeat(g.length); } )
.replace(/([\u0020]+)/g,
function(g) { return '_'.repeat(g.length); } )
.replace(/([\u00A0]+)/g,
function(g) { return '_'.repeat(g.length); } );
var z = text.replace(/(.*)/,
function(g) {
// return '<span>̣</span>'.repeat(g.length); // letter-spacingがそのまま幅になる. 興味深い
return '<spacer></spacer>'.repeat(g.length); // letter-spacingがそのまま幅になる. 興味深い
//return '‪'.repeat(g.length);
} );
tmp.push([
'code: U+', c, '<br>',
'<div class="arial big type', c, '">', text, '<', '/div>arial', '<br>',
'<div class="gothic big type', c, '">', text, '<', '/div>gothic', '<br>',
'<div class="mono big type', c, '">', t, '<', '/div>mono<br>',
'<div class="mono2 big type', c, '">', t, '<', '/div>mono2<br>',
'<div class="zero big type', c, '">', z, '<', '/div>zero<br>',
'<div class="arial medium type', c, '">', text, '<', '/div>', '<br>',
'<div class="gothic medium type', c, '">', text, '<', '/div>', '<br>',
'<div class="mono medium type', c, '">', t, '<', '/div><br>',
'<div class="mono2 medium type', c, '">', t, '<', '/div><br>',
'<div class="zero medium type', c, '">', z, '<', '/div><br>',
'<div class="arial small type', c, '">', text, '<', '/div>', '<br>',
'<div class="gothic small type', c, '">', text, '<', '/div>', '<br>',
'<div class="mono small type', c, '">', t, '<', '/div><br>',
'<div class="mono2 small type', c, '">', t, '<', '/div><br>',
'<div class="zero small type', c, '">', z, '<', '/div><br>',
'<hr>',
''].join(''));
});
document.getElementById('fontTest').innerHTML =
tmp.join('\n') + document.getElementById('fontTest').innerHTML;
var divs = document.querySelectorAll('#fontTest > span');
_.each(divs, function(div) {
window.console.log(div.className, div.offsetWidth, div.offsetWidth / 16);
});
</script>
<div class="mono" style="font-size: 15px; font-weight: bolder; letter-spacing: 1px;">
AAAAAAAAAAAAAAAA<br>
BBBBBBBBBBBBBBBB<br>
iiiiiiiiiiiiiiii<br>
wwwwwwwwwwwwwwww<br>
</div>
</body>
</html>