Skip to content

Commit 4b49f88

Browse files
Merge pull request #59 from MobilityData/copilot/fix-issue-52-bug
Fix country flag emojis not rendering on Microsoft Edge/Windows
2 parents 8aa12ba + 6011b46 commit 4b49f88

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"@vercel/speed-insights": "^1.3.1",
2222
"axios": "^1.7.2",
2323
"countries-list": "^3.1.1",
24+
"country-flag-emoji-polyfill": "^0.1.8",
2425
"date-fns": "^2.30.0",
2526
"date-fns-tz": "^2.0.0",
2627
"export-to-csv": "^1.3.0",
76.5 KB
Binary file not shown.

src/app/Theme.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ export enum ThemeModeEnum {
5656
}
5757

5858
export const fontFamily = {
59-
primary: 'var(--font-mulish)',
59+
// "Twemoji Country Flags" is loaded via a polyfill (polyfillCountryFlagEmojis in providers.tsx)
60+
// and uses unicode-range: U+1F1E6-1F1FF, so it only applies to flag emoji code points
61+
// and does not affect any other text rendering.
62+
primary: '"Twemoji Country Flags", var(--font-mulish)',
6063
secondary: 'var(--font-ibm-plex-mono)',
6164
};
6265

src/app/providers.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { type RemoteConfigValues } from './interface/RemoteConfig';
99
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
1010
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
1111
import { AuthSessionProvider } from './components/AuthSessionProvider';
12+
import { polyfillCountryFlagEmojis } from 'country-flag-emoji-polyfill';
1213

1314
interface ProvidersProps {
1415
children: React.ReactNode;
@@ -20,6 +21,15 @@ export function Providers({
2021
children,
2122
remoteConfig,
2223
}: ProvidersProps): React.ReactElement {
24+
// Polyfill country flag emojis for browsers that don't support them natively
25+
// (e.g. Microsoft Edge / Chrome on Windows)
26+
React.useEffect(() => {
27+
polyfillCountryFlagEmojis(
28+
'Twemoji Country Flags',
29+
'/fonts/TwemojiCountryFlags.woff2',
30+
);
31+
}, []);
32+
2333
// Start MSW in mock mode to intercept API calls client-side
2434
React.useEffect(() => {
2535
if (process.env.NEXT_PUBLIC_API_MOCKING === 'enabled') {

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5763,6 +5763,11 @@ countries-list@^3.1.1:
57635763
resolved "https://registry.yarnpkg.com/countries-list/-/countries-list-3.2.2.tgz#34ded4d3c8ebe715306cb5658c34f73a0c8f01cb"
57645764
integrity sha512-ABJ/RWQBrPWy+hRuZoW+0ooK8p65Eo3WmUZwHm6v4wmfSPznNAKzjy3+UUYrJK2v3182BVsgWxdB6ROidj39kw==
57655765

5766+
country-flag-emoji-polyfill@^0.1.8:
5767+
version "0.1.8"
5768+
resolved "https://registry.yarnpkg.com/country-flag-emoji-polyfill/-/country-flag-emoji-polyfill-0.1.8.tgz#d2cfb23dd2f949b80d83eb9822b613bf62957173"
5769+
integrity sha512-Mbah52sADS3gshUYhK5142gtUuJpHYOXlXtLFI3Ly4RqgkmPMvhX9kMZSTqDM8P7UqtSW99eHKFphhQSGXA3Cg==
5770+
57665771
crc-32@^1.2.0:
57675772
version "1.2.2"
57685773
resolved "https://registry.yarnpkg.com/crc-32/-/crc-32-1.2.2.tgz#3cad35a934b8bf71f25ca524b6da51fb7eace2ff"

0 commit comments

Comments
 (0)