1
+ import { readFileSync } from 'fs' ;
1
2
import marked from 'marked'
2
3
import { sanitizeHtml } from './sanitizer'
3
4
import { ParsedRequest } from './types'
4
5
const twemoji = require ( 'twemoji' )
5
6
const twOptions = { folder : 'svg' , ext : '.svg' }
6
7
const emojify = ( text : string ) => twemoji . parse ( text , twOptions )
7
8
9
+ const sourceRglr = readFileSync ( `${ __dirname } /../_fonts/SourceSansPro-Regular.woff2` ) . toString ( 'base64' ) ;
10
+ const sourceBold = readFileSync ( `${ __dirname } /../_fonts/SourceSansPro-Bold.woff2` ) . toString ( 'base64' ) ;
11
+ const robotoRglr = readFileSync ( `${ __dirname } /../_fonts/RobotoCondensed-Regular.woff2` ) . toString ( 'base64' ) ;
12
+ const robotoBold = readFileSync ( `${ __dirname } /../_fonts/RobotoCondensed-Bold.woff2` ) . toString ( 'base64' ) ;
13
+
8
14
function getCss ( theme : string , fontSize : string ) {
9
15
let background = 'white'
10
16
let foreground = 'black'
@@ -16,6 +22,34 @@ function getCss(theme: string, fontSize: string) {
16
22
radial = 'dimgray'
17
23
}
18
24
return `
25
+ @font-face {
26
+ font-family: 'Source Sans Pro';
27
+ font-style: normal;
28
+ font-weight: normal;
29
+ src: url(data:font/woff2;charset=utf-8;base64,${ sourceRglr } ) format('woff2');
30
+ }
31
+
32
+ @font-face {
33
+ font-family: 'Source Sans Pro';
34
+ font-style: normal;
35
+ font-weight: bold;
36
+ src: url(data:font/woff2;charset=utf-8;base64,${ sourceBold } ) format('woff2');
37
+ }
38
+
39
+ @font-face {
40
+ font-family: 'Roboto Condensed';
41
+ font-style: normal;
42
+ font-weight: normal;
43
+ src: url(data:font/woff2;charset=utf-8;base64,${ robotoRglr } ) format('woff2');
44
+ }
45
+
46
+ @font-face {
47
+ font-family: 'Roboto Condensed';
48
+ font-style: normal;
49
+ font-weight: bold;
50
+ src: url(data:font/woff2;charset=utf-8;base64,${ robotoBold } ) format('woff2');
51
+ }
52
+
19
53
body {
20
54
background: ${ background } ;
21
55
background-image: radial-gradient(circle at 25px 25px, ${ radial } 2%, transparent 0%), radial-gradient(circle at 75px 75px, ${ radial } 2%, transparent 0%);
0 commit comments