Skip to content

Commit

Permalink
Merge pull request #2746 from owid/grapher-redesign-fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelgerber authored Oct 11, 2023
2 parents a754187 + bf38e28 commit 412f6c2
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 11 deletions.
Binary file removed functions/_common/fonts/Lato-Bold.ttf.bin
Binary file not shown.
Binary file removed functions/_common/fonts/Lato-Regular.ttf.bin
Binary file not shown.
Binary file modified functions/_common/fonts/LatoLatin-Bold.ttf.bin
Binary file not shown.
Binary file added functions/_common/fonts/LatoLatin-Medium.ttf.bin
Binary file not shown.
Binary file modified functions/_common/fonts/LatoLatin-Regular.ttf.bin
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
9 changes: 5 additions & 4 deletions functions/_common/grapherRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import { png } from "itty-router"
import svg2png_wasm from "../../node_modules/svg2png-wasm/svg2png_wasm_bg.wasm"

// these are regular .ttf files, but cloudflare needs the .bin extension to serve them correctly
import LatoRegular from "../_common/fonts/LatoLatin-Regular.ttf.bin" // https://raw.githubusercontent.com/googlefonts/LatoGFVersion/main/fonts/Lato-Regular.ttf
import LatoBold from "../_common/fonts/LatoLatin-Bold.ttf.bin" // https://raw.githubusercontent.com/googlefonts/LatoGFVersion/main/fonts/Lato-Bold.ttf
import PlayfairRegular from "../_common/fonts/PlayfairDisplayLatin-Regular.ttf.bin" // https://raw.githubusercontent.com/clauseggers/Playfair/1.202/fonts/TTF/PlayfairDisplay-Regular.ttf
import LatoRegular from "../_common/fonts/LatoLatin-Regular.ttf.bin"
import LatoMedium from "../_common/fonts/LatoLatin-Medium.ttf.bin"
import LatoBold from "../_common/fonts/LatoLatin-Bold.ttf.bin"
import PlayfairSemiBold from "../_common/fonts/PlayfairDisplayLatin-SemiBold.ttf.bin"
import { Env } from "../grapher/thumbnail/[slug].js"

declare global {
Expand Down Expand Up @@ -225,7 +226,7 @@ async function renderSvgToPng(svg: string, options: ImageOptions) {
// if we include details, pngHeight is only the height of the chart, but we also have an "appendix" at the bottom that we want to include
height: options.details ? undefined : options.pngHeight,
backgroundColor: "#fff",
fonts: [LatoRegular, LatoBold, PlayfairRegular].map(
fonts: [LatoRegular, LatoMedium, LatoBold, PlayfairSemiBold].map(
(f) => new Uint8Array(f)
),
})
Expand Down
7 changes: 7 additions & 0 deletions site/GrapherPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ window.Grapher.renderSingleGrapherOnGrapherPage(jsonConfig)`
))
)
)}
<link
rel="preload"
href="/fonts/PlayfairDisplayLatin-SemiBold.woff2"
as="font"
type="font/woff2"
crossOrigin="anonymous"
/>
</Head>
<body className={GRAPHER_PAGE_BODY_CLASS}>
<SiteHeader baseUrl={baseUrl} />
Expand Down
7 changes: 0 additions & 7 deletions site/Head.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,6 @@ export const Head = (props: {
type="font/woff2"
crossOrigin="anonymous"
/>
<link
rel="preload"
href="/fonts/PlayfairDisplayLatin-Regular.woff2"
as="font"
type="font/woff2"
crossOrigin="anonymous"
/>
<meta property="fb:app_id" content="1149943818390250" />
<meta property="og:url" content={canonicalUrl} />
<meta property="og:title" content={pageTitle} />
Expand Down

0 comments on commit 412f6c2

Please sign in to comment.