|
|
@ -68,6 +68,7 @@ const TextToSVG = require('text-to-svg') |
|
|
|
const fs = require('fs') |
|
|
|
const fs = require('fs') |
|
|
|
const textToSVG = TextToSVG.loadSync('./static/Dubai-Bold.otf') |
|
|
|
const textToSVG = TextToSVG.loadSync('./static/Dubai-Bold.otf') |
|
|
|
const app = express() |
|
|
|
const app = express() |
|
|
|
|
|
|
|
const path = require('path') |
|
|
|
|
|
|
|
|
|
|
|
const lineLengthviewer = (oneLineText, fontSize) => { //to view the length of each line by pixel
|
|
|
|
const lineLengthviewer = (oneLineText, fontSize) => { //to view the length of each line by pixel
|
|
|
|
let {width} = textToSVG.getMetrics(oneLineText, options = {fontSize: fontSize})
|
|
|
|
let {width} = textToSVG.getMetrics(oneLineText, options = {fontSize: fontSize})
|
|
|
@ -79,9 +80,9 @@ app.use(express.json()) |
|
|
|
app.post('/textToSVG', (req, res) => { |
|
|
|
app.post('/textToSVG', (req, res) => { |
|
|
|
console.log(req); |
|
|
|
console.log(req); |
|
|
|
console.log(req.body); |
|
|
|
console.log(req.body); |
|
|
|
const text = req.body.text |
|
|
|
let text = req.body.text |
|
|
|
const screenSize = req.body.screenSize |
|
|
|
let screenSize = req.body.screenSize |
|
|
|
const userFontSize = req.body.fontSize |
|
|
|
let userFontSize = req.body.fontSize |
|
|
|
|
|
|
|
|
|
|
|
let svgFormat = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="" > ' //header of a svg xml
|
|
|
|
let svgFormat = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="" > ' //header of a svg xml
|
|
|
|
|
|
|
|
|
|
|
@ -137,6 +138,11 @@ app.post('/textToSVG', (req, res) => { |
|
|
|
res.status(201).sendFile('./static/mySVG.svg') |
|
|
|
res.status(201).sendFile('./static/mySVG.svg') |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.get('/getSVG', (req, res) => { |
|
|
|
|
|
|
|
const filePath = path.join(__dirname, '/static/mySVG.svg') |
|
|
|
|
|
|
|
console.log(filePath) |
|
|
|
|
|
|
|
res.status(200).sendFile(filePath) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const port = process.env.PORT || 3000 |
|
|
|
const port = process.env.PORT || 3000 |
|
|
|
app.listen(port, () => {
|
|
|
|
app.listen(port, () => {
|
|
|
|