|
1 | 1 | // ==UserScript== |
2 | 2 | // @name GitHub Font Preview |
3 | | -// @version 1.0.24 |
| 3 | +// @version 1.0.25 |
4 | 4 | // @description A userscript that adds a font file preview |
5 | 5 | // @license MIT |
6 | 6 | // @author Rob Garrison |
|
194 | 194 | #gfp-font-data .gfp-langname { padding-right:0.5em; } |
195 | 195 | #gfp-font-data .gfp-underline { border-bottom:1px solid #555; } |
196 | 196 | /* Glyph Inspector */ |
197 | | - #gfp-pagination span { margin:0 0.3em; cursor:pointer; } |
198 | | - #gfp-pagination span.gfp-page-selected { font-weight:bold; cursor:default; -webkit-filter:brightness(150%); filter:brightness(150%); } |
| 197 | + #gfp-pagination a { margin:0 0.3em; cursor:pointer; } |
| 198 | + #gfp-pagination .gfp-page-selected { font-weight:bold; cursor:default; -webkit-filter:brightness(150%); filter:brightness(150%); } |
199 | 199 | canvas.gfp-item { float:left; border:solid 1px #a0a0a0; margin-right:-1px; margin-bottom:-1px; cursor:pointer; } |
200 | 200 | canvas.gfp-item:hover { opacity:.8; } |
201 | 201 | #gfp-glyph-list-end { clear:both; height:20px; } |
|
208 | 208 | #gfp-glyph-data pre { font-size:11px; } |
209 | 209 | pre.gfp-path { margin:0; } |
210 | 210 | pre.gfp-contour { margin:0 0 1em 2em; border-bottom:solid 1px #a0a0a0; } |
211 | | - span.gfp-oncurve { color:blue; } |
212 | | - span.gfp-offcurve { color:red; } |
| 211 | + span.gfp-oncurve { color:var(--color-scale-blue-6); } |
| 212 | + span.gfp-offcurve { color:var(--color-scale-red-6); } |
213 | 213 | .gfp-loading { display:block; margin:20px auto; border-radius:50%; border-width:2px; border-style:solid; border-color: transparent transparent #000 #000; width:30px; height:30px; animation:gfploading .5s infinite linear; } |
214 | 214 | @keyframes gfploading { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } |
215 | 215 | `); |
|
330 | 330 |
|
331 | 331 | function contourToString(contour) { |
332 | 332 | return '<pre class="gfp-contour">' + contour.map(point => { |
333 | | - // ".text-blue" class modified by GitHub Dark style |
334 | | - // ".cdel" class modified by GitHub Dark style - more readable red |
335 | | - return '<span class="gfp-' + (point.onCurve ? 'oncurve text-blue' : 'offcurve cdel') + |
| 333 | + return '<span class="gfp-' + (point.onCurve ? 'oncurve' : 'offcurve') + |
336 | 334 | '">x=' + point.x + ' y=' + point.y + '</span>'; |
337 | 335 | }).join('\n') + '</pre>'; |
338 | 336 | } |
|
532 | 530 |
|
533 | 531 | function displayGlyphPage(pageNum) { |
534 | 532 | pageSelected = pageNum; |
| 533 | + const last = $('.gfp-page-selected'); |
| 534 | + if (last) last.className = ''; |
535 | 535 | document.getElementById('gfp-p' + pageNum).className = 'gfp-page-selected'; |
536 | 536 | let indx, |
537 | 537 | firstGlyph = pageNum * cellCount; |
|
541 | 541 | } |
542 | 542 |
|
543 | 543 | function pageSelect(event) { |
544 | | - document.getElementsByClassName('gfp-page-selected')[0].className = 'text-blue'; |
545 | 544 | displayGlyphPage((event.target.id || '').replace('gfp-p', '')); |
546 | 545 | } |
547 | 546 |
|
|
592 | 591 | pagination.innerHTML = ''; |
593 | 592 |
|
594 | 593 | for (indx = 0; indx < numPages; indx++) { |
595 | | - link = document.createElement('span'); |
| 594 | + link = document.createElement('a'); |
596 | 595 | lastIndex = Math.min(font.numGlyphs - 1, (indx + 1) * cellCount - 1); |
597 | 596 | link.textContent = indx * cellCount + '-' + lastIndex; |
598 | 597 | link.id = 'gfp-p' + indx; |
599 | | - link.className = 'text-blue'; |
600 | 598 | link.addEventListener('click', pageSelect, false); |
601 | 599 | fragment.appendChild(link); |
602 | 600 | // A white space allows to break very long lines into multiple lines. |
|
0 commit comments