Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LQDN Adminsys
generateur-slogans
Commits
0e67ee32
Verified
Commit
0e67ee32
authored
Nov 27, 2017
by
Thibaut Broggi
Browse files
Change alignment of fonts on server-side generation (see
#15
)
parent
005c1457
Pipeline
#1740
passed with stages
in 2 minutes and 9 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
srv.js
View file @
0e67ee32
...
...
@@ -64,23 +64,56 @@ app.use(function(req, res, next) {
next
();
});
// {name: filepath}
// {name:
{
filepath
, offset}
}
let
fonts
=
{
'
FiraSans
'
:
'
FiraSans-Regular.otf
'
,
'
bilbo-inc
'
:
'
BilboINC.ttf
'
,
'
bluu-next
'
:
'
BluuNext-Bold.otf
'
,
'
combat
'
:
'
Combat.otf
'
,
'
gulax
'
:
'
Gulax.otf
'
,
'
lineal
'
:
'
Lineal.otf
'
,
'
resistance
'
:
'
Resistance.otf
'
,
'
savate
'
:
'
savate-regular.otf
'
,
'
solid-mirage
'
:
'
SolideMirageMono.otf
'
,
'
steps-mono
'
:
'
Steps-Mono.otf
'
,
'
terminal
'
:
'
terminal-grotesque_open.otf
'
'
FiraSans
'
:
{
path
:
'
FiraSans-Regular.otf
'
,
offset
:
0
},
'
bilbo-inc
'
:
{
path
:
'
BilboINC.ttf
'
,
offset
:
10
},
'
bluu-next
'
:
{
path
:
'
BluuNext-Bold.otf
'
,
offset
:
0
},
'
combat
'
:
{
path
:
'
Combat.otf
'
,
offset
:
0
},
'
gulax
'
:
{
path
:
'
Gulax.otf
'
,
offset
:
10
},
'
lineal
'
:
{
path
:
'
Lineal.otf
'
,
offset
:
4
},
'
resistance
'
:
{
path
:
'
Resistance.otf
'
,
offset
:
2
},
'
savate
'
:
{
path
:
'
savate-regular.otf
'
,
offset
:
10
},
'
solid-mirage
'
:
{
path
:
'
SolideMirageMono.otf
'
,
offset
:
0
},
'
steps-mono
'
:
{
path
:
'
Steps-Mono.otf
'
,
offset
:
10
},
'
terminal
'
:
{
path
:
'
terminal-grotesque_open.otf
'
,
offset
:
15
}
};
for
(
let
i
in
fonts
)
{
Canvas
.
registerFont
(
'
./static/fonts/
'
+
fonts
[
i
],
{
family
:
i
});
Canvas
.
registerFont
(
'
./static/fonts/
'
+
fonts
[
i
]
.
path
,
{
family
:
i
});
}
Canvas
.
registerFont
(
'
./static/fonts/FiraSans-Bold.otf
'
,
{
family
:
'
FiraSans
'
,
weight
:
'
bold
'
});
...
...
@@ -125,7 +158,7 @@ app.get('/generate.png', function (req, res) {
ctx
.
fillText
(
_
(
'
et libertés.
'
),
width
*
0.08
,
height
*
0.2
+
fontSize
*
2.8
);
ctx
.
font
=
fontSize
+
'
pt
'
+
req
.
args
.
font
;
ctx
.
fillStyle
=
req
.
args
.
fgColor
;
ctx
.
fillText
(
req
.
args
.
text
,
width
*
0.08
,
height
*
0.2
+
fontSize
*
1.4
);
ctx
.
fillText
(
req
.
args
.
text
,
width
*
0.08
,
height
*
0.2
+
fontSize
*
1.4
+
fonts
[
req
.
args
.
font
].
offset
);
// Add footer
ctx
.
fillStyle
=
'
white
'
;
...
...
Thibaut Broggi
@Erneraude
mentioned in issue
#15 (closed)
·
Nov 27, 2017
mentioned in issue
#15 (closed)
mentioned in issue #15
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment