Skip to content

Commit a6f59c8

Browse files
committed
perf(#194): updated default font to open sans to keep the file small
1 parent eda5808 commit a6f59c8

File tree

12 files changed

+36
-74
lines changed

12 files changed

+36
-74
lines changed

lib/@dsvgui/components/article/index.tsx

+1-8
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,13 @@ export const Article: React.FC<IArticle> = ({ articles }) => {
7676
<g transform={`translate(${xOffset} 24)`}>
7777
<text
7878
xmlSpace="preserve"
79-
fontFamily="Manrope"
8079
fontWeight="700"
8180
fill="#0c0c0c"
8281
fontSize="16"
8382
>
8483
{title}
8584
</text>
86-
<text
87-
fill="#999999"
88-
xmlSpace="preserve"
89-
fontSize={12}
90-
fontFamily="Manrope"
91-
y={5 + title.length * 15}
92-
>
85+
<text fill="#999999" fontSize={12} y={5 + title.length * 15}>
9386
{wrapText(
9487
article.meta.description.replace(/\n/gm, " "),
9588
{

lib/@dsvgui/components/barstats/index.tsx

+2-16
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,14 @@ export const BarStats: React.FC<IBarStats> = ({
3333
<g id="content">
3434
<g id="Frame 134">
3535
<g id="title">
36-
<text
37-
id="Most used languages"
38-
className="title"
39-
xmlSpace="preserve"
40-
fontFamily="Manrope"
41-
fontWeight="600"
42-
letterSpacing="0px"
43-
>
36+
<text className="title" fontWeight="700">
4437
<tspan x="0" y="21.511">
4538
{title}
4639
</tspan>
4740
</text>
4841
</g>
4942
<g id="subtitle">
50-
<text
51-
id="in the last 7 days"
52-
className="subtitle"
53-
xmlSpace="preserve"
54-
fontFamily="Manrope"
55-
fontWeight="600"
56-
letterSpacing="0px"
57-
>
43+
<text className="subtitle">
5844
<tspan x="0" y="40">
5945
{subtitle}
6046
</tspan>

lib/@dsvgui/components/calendar/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export const Calendar: React.FC<ICalendar> = ({
163163
{(title || subtitle || showStreak) && (
164164
<g id="Title">
165165
{title && (
166-
<text xmlSpace="preserve" className="title">
166+
<text xmlSpace="preserve" className="title" fontWeight="700">
167167
<tspan x="0" y="18">
168168
{title}
169169
</tspan>

lib/@dsvgui/components/fallback/index.tsx

+1-8
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ export const Fallback: React.FC<IFallback> = ({ title, message }) => {
3434
<text
3535
fill="#3e3e3e"
3636
xmlSpace="preserve"
37-
fontFamily="Manrope"
3837
fontSize="22"
3938
fontWeight="bold"
4039
letterSpacing="0.1px"
@@ -43,13 +42,7 @@ export const Fallback: React.FC<IFallback> = ({ title, message }) => {
4342
{title}
4443
</tspan>
4544
</text>
46-
<text
47-
fill="#6e6e6e"
48-
xmlSpace="preserve"
49-
fontFamily="Manrope"
50-
fontSize="14"
51-
fontWeight="400"
52-
>
45+
<text fill="#6e6e6e" xmlSpace="preserve" fontSize="14" fontWeight="400">
5346
{subtitle}
5447
</text>
5548
</Document>

lib/@dsvgui/components/flock/index.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ export const Flock: React.FC<IFlock> = ({
6262
<text
6363
xmlns="http://www.w3.org/2000/svg"
6464
className="title"
65-
fontFamily="Manrope"
66-
fontWeight="500"
65+
fontWeight="700"
6766
>
6867
<tspan x={headStart.x} y={headStart.y}>
6968
{title.trim()}
@@ -74,7 +73,6 @@ export const Flock: React.FC<IFlock> = ({
7473
<text
7574
xmlns="http://www.w3.org/2000/svg"
7675
className="subtitle"
77-
fontFamily="Manrope"
7876
fontWeight="400"
7977
>
8078
<tspan x={headStart.x} y={headStart.y + titleFontSize}>

lib/@dsvgui/components/line/index.tsx

+15-11
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,25 @@ export const Line: React.FC<ILine> = ({ items }) => {
4141
let x = -xGap;
4242
let path =
4343
"M " +
44-
(x + xGap) +
44+
(x + xGap).toFixed(3) +
4545
" " +
46-
(lineHeight -
46+
(
47+
lineHeight -
4748
(item.period ? 7 : -5) -
48-
(item.points[0] / maxValue) * lineHeight * ratio);
49+
(item.points[0] / maxValue) * lineHeight * ratio
50+
).toFixed(3);
4951

5052
for (const point of item.points) {
5153
x += xGap;
5254
path +=
5355
" L " +
5456
x +
5557
" " +
56-
(lineHeight -
58+
(
59+
lineHeight -
5760
(item.period ? 7 : -5) -
58-
(point / maxValue) * lineHeight * ratio);
61+
(point / maxValue) * lineHeight * ratio
62+
).toFixed(3);
5963
}
6064

6165
return path;
@@ -221,42 +225,42 @@ export const Line: React.FC<ILine> = ({ items }) => {
221225
>
222226
<stop offset="0" stopColor="#ffffff" />
223227
<stop
224-
offset="0.141455"
228+
offset="0.15"
225229
stopColor={`rgba(${hexToRgb(
226230
item.lineColor || "#000000",
227231
0.7
228232
).join(", ")})`}
229233
/>
230234
<stop
231-
offset="0.201455"
235+
offset="0.20"
232236
stopColor={`rgba(${hexToRgb(
233237
item.lineColor || "#000000",
234238
0.3
235239
).join(", ")})`}
236240
/>
237241
<stop
238-
offset="0.363128"
242+
offset="0.4"
239243
stopColor={`rgba(${hexToRgb(
240244
item.lineColor || "#000000",
241245
0.5
242246
).join(", ")})`}
243247
/>
244248
<stop
245-
offset="0.581288"
249+
offset="0.6"
246250
stopColor={`rgba(${hexToRgb(
247251
item.lineColor || "#000000",
248252
0.7
249253
).join(", ")})`}
250254
/>
251255
<stop
252-
offset="0.729526"
256+
offset="0.8"
253257
stopColor={`rgba(${hexToRgb(
254258
item.lineColor || "#000000",
255259
0.8
256260
).join(", ")})`}
257261
/>
258262
<stop
259-
offset="0.923128"
263+
offset="0.9"
260264
stopColor={`rgba(${hexToRgb(
261265
item.lineColor || "#000000",
262266
0.7

lib/@dsvgui/components/metrics/index.tsx

+1-7
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,14 @@ export const Metrics: React.FC<IMetrics> = ({ data, icon: Icon }) => {
3939

4040
return (
4141
<Fragment key={index}>
42-
<text
43-
fill="#878787"
44-
xmlSpace="preserve"
45-
fontFamily="Manrope"
46-
className="subtitle"
47-
>
42+
<text fill="#878787" xmlSpace="preserve" className="subtitle">
4843
<tspan x={xText} y={10}>
4944
{item.title}
5045
</tspan>
5146
</text>
5247
<text
5348
fill="black"
5449
xmlSpace="preserve"
55-
fontFamily="Manrope"
5650
className="title"
5751
fontWeight="600"
5852
>

lib/@dsvgui/components/progress/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const Progress: React.FC<IProgress> = ({ title, percent, metrics }) => {
1818

1919
return (
2020
<Document w={462} h={height}>
21-
<text fill="#5E5E5E" className="title">
21+
<text fill="#5E5E5E" className="title" fontWeight="700">
2222
<tspan x="0" y="20.7539">
2323
{title}
2424
</tspan>

lib/@dsvgui/document/branding.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export const Branding: React.FC<IBranding> = ({ x, y }) => {
99
id="dsvguibranding"
1010
xmlSpace="preserve"
1111
fontSize={8}
12-
fontFamily="Manrope"
1312
fill="#cccccc"
1413
x={x}
1514
y={y}

lib/@dsvgui/document/style.tsx

+1-17
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,8 @@
1-
import * as Manrope from "./fonts/manrope";
2-
3-
const buildFontFace = (font: string, weight: number, value: string) => {
4-
return `@font-face {
5-
font-family: '${font}';
6-
font-style: normal;
7-
font-weight: ${weight};
8-
font-display: swap;
9-
src: url('data:application/font-woff;base64,${value}') format('woff2');
10-
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
11-
}`;
12-
};
13-
141
export const Style: React.FC = () => {
152
return (
163
<defs>
174
<style>{`
18-
${buildFontFace("Manrope", 300, Manrope.W300)}
19-
${buildFontFace("Manrope", 500, Manrope.W500)}
20-
${buildFontFace("Manrope", 700, Manrope.W700)}
21-
text{ font-family: 'Manrope', 'Open Sans', 'Segoe UI', Ubuntu, 'Helvetica Neue', Sans-Serif; }
5+
text{ font-family: 'Open Sans', 'Segoe UI', Ubuntu, 'Helvetica Neue', Sans-Serif; }
226
text.title{ fill: #32373e; font-size: 22px; }
237
text.subtitle{ fill: #9c9c9c; font-size: 16px; }
248
.dsvgui-container{ fill: #fbfbfb; }

lib/@dsvgui/utils/fonts.ts

+11
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,14 @@ export const loadFontBuffer = (
3131
fonts[fontFamily][weight] = fontBuffer;
3232
return fontBuffer;
3333
};
34+
35+
export const buildFontFace = (font: string, weight: number, value: string) => {
36+
return `@font-face {
37+
font-family: '${font}';
38+
font-style: normal;
39+
font-weight: ${weight};
40+
font-display: swap;
41+
src: url('data:application/font-woff;base64,${value}') format('woff2');
42+
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
43+
}`;
44+
};

lib/@dsvgui/utils/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type IGetTextWidth = (
1212
) => number;
1313

1414
export const getTextWidth: IGetTextWidth = (inputText, options) => {
15-
const { fontSize, fontWeight = 500, fontFamily = "Manrope" } = options;
15+
const { fontSize, fontWeight = 500, fontFamily = "Open Sans" } = options;
1616

1717
let text = inputText ?? "";
1818
text = text.toString();

0 commit comments

Comments
 (0)