Skip to content

Commit

Permalink
Typography: only use GT Super on supported languages
Browse files Browse the repository at this point in the history
  • Loading branch information
christianvuerings committed Mar 27, 2024
1 parent 9ecadcb commit 27d2d1d
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 8 deletions.
50 changes: 42 additions & 8 deletions packages/syntax-core/src/Typography/Typography.module.css
Expand Up @@ -8,28 +8,62 @@
font-style: normal;
font-weight: 510;
src: local("GT-Super-Text-Medium"),
url("https://static.cambly.com/fonts/gt-super-medium.woff2");
font-display: optional;
url("https://static.cambly.com/fonts/gt-super-text-medium-converted.woff2");
}

@font-face {
font-family: "GT Super";
font-style: normal;
font-weight: 700;
src: local("GT-Super-Text-Bold"),
url("https://static.cambly.com/fonts/gt-super-bold.woff2");
font-display: optional;
url("https://static.cambly.com/fonts/gt-super-text-bold-converted.woff2");
}

.sansSerif {
font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto,
Helvetica, Arial, sans-serif;
font-family: var(--syntax-font-sans-serif);
margin: 0;
}

.serif {
font-family: "GT Super", -apple-system, system-ui, BlinkMacSystemFont,
"Segoe UI", Roboto, Helvetica, Arial, serif;
font-family: var(
--syntax-font-sans-serif
); /* Intentional, the default is still to use sans-serif, we only use serif for certain languages */
}

/* GT Super only supports certain languages: https://www.grillitype.com/typeface/gt-super */

/* List of languages we use on Cambly and their support for GT Super
* English: ✅
* Arabic: ❌
* Azerbaijani: ✅
* German: ✅
* Spanish: ✅
* French: ✅
* Italian: ✅
* Japanese: ❌
* Korean: ❌
* Polish: ✅
* Portuguese: ✅
* Russian: ❌
* Thai: ❌
* Turkish: ✅
* Vietnamese: ❌
* Simplified Chinese: ❌
* Traditional Chinese: ❌
*/

/* stylelint-disable-next-line selector-max-compound-selectors -- only render serif font for certain languages */
:lang(en) .serif,
:lang(az) .serif,
:lang(fr) .serif,
:lang(de) .serif,
:lang(es) .serif,
:lang(it) .serif,
:lang(pl) .serif,
:lang(pt) .serif,
:lang(tr) .serif {
font-family: "GT Super", var(--syntax-font-sans-serif);
-webkit-font-smoothing: antialiased;
}

Expand Down
39 changes: 39 additions & 0 deletions packages/syntax-core/src/Typography/Typography.stories.tsx
@@ -1,5 +1,6 @@
import { type StoryObj, type Meta } from "@storybook/react";
import Typography from "./Typography";
import Box from "../Box/Box";

export default {
title: "Components/Typography",
Expand Down Expand Up @@ -162,6 +163,44 @@ export const colors: StoryObj<typeof Typography> = {
),
};

function SerifCharacterSupportExample() {
return (
<Box display="flex" gap={3} direction="column">
<Typography size={200} fontStyle="serif">
English: à, é, ñ
</Typography>
<Typography size={200} fontStyle="serif">
Azerbaijani: ə, ı, ş, ü
</Typography>
<Typography size={200} fontStyle="serif">
French: à, â, é, è, ê, ë, î, ï, ô, ö, ù, û, ü, ÿ, ç
</Typography>
<Typography size={200} fontStyle="serif">
German: ä, ö, ü, ß
</Typography>
<Typography size={200} fontStyle="serif">
Spanish: á, é, í, ó, ú, ü, ñ
</Typography>
<Typography size={200} fontStyle="serif">
Italian: à, è, é, ì, ò, ó, ù
</Typography>
<Typography size={200} fontStyle="serif">
Polish: ą, ć, ę, ł, ń, ó, ś, ź, ż
</Typography>
<Typography size={200} fontStyle="serif">
Portuguese: á, â, ã, à, é, ê, í, ó, ô, õ, ú
</Typography>
<Typography size={200} fontStyle="serif">
Turkish: ç, ğ, ı, ö, ş, ü
</Typography>
</Box>
);
}

export const SerifCharacterSupport: StoryObj<typeof Typography> = {
render: () => <SerifCharacterSupportExample />,
};

export const Inline: StoryObj<typeof Typography> = {
render: (args) => (
<>
Expand Down
9 changes: 9 additions & 0 deletions packages/syntax-design-tokens/tokens/font/base.json
@@ -0,0 +1,9 @@
{
"syntax": {
"font": {
"sans-serif": {
"value": "-apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif"
}
}
}
}

0 comments on commit 27d2d1d

Please sign in to comment.