Skip to content

Commit

Permalink
#none font issue - updated dockerfile, added .ttf file, and updated c…
Browse files Browse the repository at this point in the history
…hartjs handler
  • Loading branch information
jgaribsin committed Mar 18, 2024
1 parent 5452d37 commit f6bc499
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
7 changes: 1 addition & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ RUN npm ci --quiet

COPY ./src ./src

RUN apt-get update && apt-get install -y --no-install-recommends \
# - For node-gyp
python make g++ \
# - For canvas
fontconfig

# Build stage > build project, remove deps and install runtime deps
FROM base AS build
WORKDIR /app
Expand All @@ -29,6 +23,7 @@ WORKDIR /home/node/app
COPY --chown=node:node --from=build /app/build ./build
COPY --chown=node:node --from=build /app/node_modules ./node_modules
COPY --chown=node:node package*.json *.config.js ./
COPY --chown=node:node --from=build /app/src/fonts ./fonts

# Set 'node' as owner of this directory (permits creating files eg. logs)
RUN chown -h node:node .
Expand Down
Binary file added src/fonts/Monda-Regular.ttf
Binary file not shown.
8 changes: 8 additions & 0 deletions src/handlers/graphs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ const smallChartJSNodeCanvas = new ChartJSNodeCanvas({
height: 400,
backgroundColour: 'black',
});
smallChartJSNodeCanvas.registerFont('./fonts/Monda-Regular.ttf', {
family: 'Monda',
});

const bigChartJSNodeCanvas = new ChartJSNodeCanvas({
width: 2000,
height: 2000,
backgroundColour: 'black',
});
bigChartJSNodeCanvas.registerFont('./fonts/Monda-Regular.ttf', {
family: 'Monda',
});

export async function campaignHistoryGraph(planet: string) {
// get all API data for 24 hours ago
Expand Down Expand Up @@ -111,5 +118,6 @@ export async function campaignHistoryGraph(planet: string) {

export const renderMediumChart = (configuration: ChartConfiguration) =>
smallChartJSNodeCanvas.renderToBuffer(configuration);

export const renderBigChart = (configuration: ChartConfiguration) =>
bigChartJSNodeCanvas.renderToBuffer(configuration);

0 comments on commit f6bc499

Please sign in to comment.