Skip to content

Commit

Permalink
feat(fonts): add support for arabic text
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonsaldan committed Dec 19, 2024
1 parent 1985e57 commit 8698b53
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/constants/fonts.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const notoSansSC = localFont({
variable: "--font-noto-sans-sc",
});

export const notoSansJP = localFont({
export const notoSerifJP = localFont({
src: "../fonts/NotoSerifJP-VF.woff2",
variable: "--font-noto-sans-jp",
});
Expand All @@ -41,3 +41,13 @@ export const notoSansKR = localFont({
src: "../fonts/NotoSerifKR-VF.woff2",
variable: "--font-noto-sans-kr",
});

export const notoSerifKR = localFont({
src: "../fonts/NotoSerifKR-VF.woff2",
variable: "--font-noto-sans-kr",
});

export const notoNaskhAR = localFont({
src: "../fonts/NotoNaskhAR-VF.woff2",
variable: "--font-noto-naskh-ar",
});
Binary file added src/fonts/NotoNaskhAR-VF.woff2
Binary file not shown.
10 changes: 8 additions & 2 deletions src/pages/_app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ import {
checkNetworkConnectivity,
startNetworkMonitoring,
} from "../lib/networkChecker";
import { inter, notoSansSC, notoSansJP, notoSansKR } from "../constants/fonts";
import {
inter,
notoSansSC,
notoSerifJP,
notoSerifKR,
notoNaskhAR,
} from "../constants/fonts";

const initialAuthState = () => {
if (typeof window === "undefined") {
Expand Down Expand Up @@ -1778,7 +1784,7 @@ export default function App({ Component, pageProps }) {
<main
className={`overflow-hidden relative min-h-screen rounded-2xl ${inter.className}`}
style={{
fontFamily: `${inter.style.fontFamily}, ${notoSansSC.style.fontFamily}, ${notoSansJP.style.fontFamily}, ${notoSansKR.style.fontFamily}, sans-serif`,
fontFamily: `${inter.style.fontFamily}, ${notoSansSC.style.fontFamily}, ${notoSerifJP.style.fontFamily}, ${notoSerifKR.style.fontFamily}, ${notoNaskhAR.style.fontFamily}, sans-serif`,
fontOpticalSizing: "auto",
}}
>
Expand Down
10 changes: 10 additions & 0 deletions src/pages/now-playing.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,12 @@ const NowPlaying = ({
</svg>
);

const isArabicText = (text) => {
const arabicRegex =
/[\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/;
return arabicRegex.test(text);
};

return (
<>
{open && (
Expand Down Expand Up @@ -1041,6 +1047,10 @@ const NowPlaying = ({
index === currentLyricIndex
? "text-white"
: "text-white/60"
} ${
isArabicText(lyric.text)
? "text-right font-noto-naskh-ar"
: ""
}`}
>
{lyric.text}
Expand Down
1 change: 1 addition & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = {
"var(--font-noto-sans-sc)",
"var(--font-noto-sans-jp)",
"var(--font-noto-sans-kr)",
"var(--font-noto-naskh-ar)",
],
},
letterSpacing: {
Expand Down

0 comments on commit 8698b53

Please sign in to comment.