Font module not found
Unanswered
Gharial posted this in #help-forum
GharialOP
Folder structure is:
-public - "font1.ttf"
-src - app - ui - font.ts
font.ts code is:
I am geeting this error:
-public - "font1.ttf"
-src - app - ui - font.ts
font.ts code is:
import { Rajdhani } from "next/font/google";
import localFont from "next/font/local";
export const rajdhani = Rajdhani({
weight: ["700"],
subsets: ["latin"],
});
export const font1 = localFont({
src: "./font1.ttf",
});I am geeting this error:
src\app\ui\fonts.ts
Module not found: Can't resolve './font1.ttf'
https://nextjs.org/docs/messages/module-not-found
Import trace for requested module:
./src/app/ui/fonts.ts
./src/app/page.tsx29 Replies
can you maybe try ../ ntill you get the font (i think its relative to file and not public like images)
GharialOP
getting this :
src\app\ui\fonts.ts
Module not found: Can't resolve '../font1.ttf'maybe more ../ as you are in ui folder which is a few folders down from where public is
GharialOP
but public folder contents can be imported using "./filename"
?
yeah but this is next/font and that isn't the same as importing static files link image would be
GharialOP
nothing working:
and
src\app\ui\fonts.ts
Module not found: Can't resolve '../../../../public/font1.ttf'and
src\app\ui\fonts.ts
Module not found: Can't resolve '../../../../font1.ttf'wait can you actually use ttf with next/font (i have only tried it with woff) - id hope you can
GharialOP
@riský wait can you actually use ttf with next/font (i have only tried it with woff) - id hope you can
GharialOP
idk about that 😦
and they use ttf as an example 👀
GharialOP
src\app\ui\fonts.ts
Module not found: Can't resolve '../../../../font2.otf'
Module not found: Can't resolve '../../../../font2.otf'
not working with otf too
tried :
all the combinations
all the combinations
wait..let me keep all the font files in 'ui' folder
now,
font.ts and font1.ttf are in same folder uias you are going down folders but i see not going into the public
GharialOP
did that...not working
oh 😦
@Gharial now, `font.ts` and `font1.ttf` are in same folder `ui`
GharialOP
did this
still not workin
src: "./font2.otf",still not workin
and you reset .next folder and all ðŸ˜
yeah i have no idea what next/font's issue is
GharialOP
wait...it worked
👀
@Gharial wait...it worked
what did you do to fix it 🎉
@Gharial now, `font.ts` and `font1.ttf` are in same folder `ui`
GharialOP
this 🙂
and "./font1.tff"