Skip to content

Commit

Permalink
Merge pull request OpenTechStrategies#27 from OpenTechStrategies/24-f…
Browse files Browse the repository at this point in the history
…ix-fonts

Fix font paths
  • Loading branch information
slifty authored Apr 30, 2021
2 parents 6c96d1e + e13f490 commit 99bfcf6
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions services/api/mw2pdf/classes/PdfGenerator.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { fileURLToPath } from 'url'
import path from 'path'
import fs from 'fs'
import { v4 as uuidv4 } from 'uuid'
import PdfMerger from 'pdf-merger-js'
Expand All @@ -9,6 +11,11 @@ import {
} from 'pdf-lib'
import { Pdf } from './Pdf.js'

// The below two lines are from
// https://stackoverflow.com/questions/32705219/nodejs-accessing-file-with-relative-path/32707530#32707530
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

export class PdfGenerator {
constructor(directory = '') {
Object.assign(
Expand Down Expand Up @@ -115,13 +122,13 @@ export class PdfGenerator {
async generatePdfFromScaffold(scaffold, outPdf = this.generatePdfObject()) {
const printer = new PdfPrinter({
Roboto: {
normal: 'fonts/Roboto-Regular.ttf',
bold: 'fonts/Roboto-Medium.ttf',
italics: 'fonts/Roboto-Italic.ttf',
bolditalics: 'fonts/Roboto-MediumItalic.ttf',
normal: path.join(__dirname, '../fonts/Roboto-Regular.ttf'),
bold: path.join(__dirname, '../fonts/Roboto-Medium.ttf'),
italics: path.join(__dirname, '../fonts/Roboto-Italic.ttf'),
bolditalics: path.join(__dirname, '../fonts/Roboto-MediumItalic.ttf'),
},
SourceCodePro: {
normal: 'fonts/SourceCodePro-Regular.ttf',
normal: path.join(__dirname, '../fonts/SourceCodePro-Regular.ttf'),
}
})
// TODO: what is .end doing in this block -- is it sync? does it have to be called?
Expand Down

0 comments on commit 99bfcf6

Please sign in to comment.