์ material-ui์ ํจ๊ป ๋ฒ๋ค๋ก ์ ๊ณต๋๋ ๊ธ๊ผด์ ์ฌ์ฉํด์ผ ํฉ๋๊น?
์ด๊ฒ์ ์ ๊ฑฐํ๊ฑฐ๋ ๊ตฌ์ฑํ๋ ๋ฐฉ๋ฒ์ด ์์ต๋๊น?
์ค์ ๋ก 6์๊ฐ ๋์ ์จ๋ผ์ธ์์ ๊ฒ์ํ๊ณ lib ์ฝ๋๋ฅผ ํํค์น๊ณ ๋ฌด์์๋ก ์ถ์ธกํ ํ ๋ด๊ฐ ๋๋ฌํ ๊ฒฐ๋ก ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค. IT IS POSIBLE! :๋
/public/fonts/fonts.css
์์ฑ:@font-face {
font-family: 'inglobal';
font-weight: normal;
font-style: normal;
src: url('./inglobal.ttf');
}
<link rel="stylesheet" href="%PUBLIC_URL%/fonts/fonts.css">
๋ฅผ /public/index.html์ ํค๋์ ์ถ๊ฐ
๋ง์ธ!
4/๋. ์ด๋ค ์ด์ ๋ก๋ ์ฌ์ ํ ์๋ํ์ง ์์ผ๋ฉด ๊ธ๊ผด ํ์ฅ์๋ฅผ .css( src: url('./OperatorMono.css')
์์๋)๋ก ๋ณ๊ฒฝํ์ญ์์ค.
index.html์ Google ๊ธ๊ผด์ ์ฐ๊ฒฐํ์ธ์.
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,500,700&display=swap" rel="stylesheet">
๋น์ ์ ๋ฐ๋ ์คํ์ผ์ ์ถ๊ฐ
/* Styles */
body {
margin: 0 auto;
font-family: 'Montserrat';
}
app.js์ ๋ช ๊ฐ์ง ๋ณ๊ฒฝ ์ฌํญ
import { MuiThemeProvider, createMuiTheme } from '@material-ui/core/styles';
const theme = createMuiTheme({
typography: {
fontFamily: [
'Montserrat'
].join(','),
},
})
/public/index.html
๋๋ฅผ ์ํด ์ผํ์ต๋๋ค :)
์ค์ ๋ก 6์๊ฐ ๋์ ์จ๋ผ์ธ์์ ๊ฒ์ํ๊ณ lib ์ฝ๋๋ฅผ ํํค์น๊ณ ๋ฌด์์๋ก ์ถ์ธกํ ํ ๋ด๊ฐ ๋๋ฌํ ๊ฒฐ๋ก ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค. IT IS POSIBLE! :๋
- /public์ /font ๋๋ ํ ๋ฆฌ ์์ฑ
- @font-faces๋ฅผ ์ ์ํ๋
/public/fonts/fonts.css
์์ฑ:@font-face { font-family: 'inglobal'; font-weight: normal; font-style: normal; src: url('./inglobal.ttf'); }
<link rel="stylesheet" href="%PUBLIC_URL%/fonts/fonts.css">
๋ฅผ /public/index.html์ ํค๋์ ์ถ๊ฐ- ๋ง์ธ!
4/๋. ์ด๋ค ์ด์ ๋ก๋ ์ฌ์ ํ ์๋ํ์ง ์์ผ๋ฉด ๊ธ๊ผด ํ์ฅ์๋ฅผ .css(
src: url('./OperatorMono.css')
์์๋)๋ก ๋ณ๊ฒฝํ์ญ์์ค.
์ผ์ด์ผ!! ๊ฐ์ฌํฉ๋๋ค.
๊ธฐ๋ณธ ๊ธ๊ผด์ ๋ณ๊ฒฝํ๋ ค๋ฉด ๋ค์ 2๋จ๊ณ๋ฅผ ๋ฐ๋ฅด์ญ์์ค.
์ฌ๊ธฐ์์ ๊ธฐ๋ณธ ๊ธ๊ผด์ "Open Sans"๋ก ๋ณ๊ฒฝํ๊ฒ ์ต๋๋ค.
index.html์์ Google ๊ธ๊ผด ๊ฐ์ ธ์ค๊ธฐ
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;700&display=swap" rel="stylesheet"/>
index.js์์ ์ด๋ฌํ ๋ณ๊ฒฝ์ ์ํํ์ญ์์ค.
import { ThemeProvider } from '@material-ui/styles';
import { CssBaseline } from '@material-ui/core';
import { createMuiTheme } from '@material-ui/core';
const theme = createMuiTheme({ typography: { fontFamily: [ 'Open Sans' ].join(','), }, })
ReactDOM.render(
<ThemeProvider theme={theme}>
<CssBaseline />
<App />
</ThemeProvider>,
document.getElementById('root')
);
_๊ตฌ์ฑ ์ค์ ์ํ์ค๊ฐ โโ์ค์ํ ๊ฒฝ์ฐ๊ฐ ์์ต๋๋ค. createMuiTheme ์์ ๊ตฌ์ฑํ๋ ๋์ ํญ์ ์ต์์ ์์ค์์ ํ์ดํฌ๊ทธ๋ํผ๋ฅผ ์ ์ํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
๊ตฌ์ฑ ํ ๋ง์ ๊ธ๊ผด ๋ชจ์์ด ํ์๋์ง ์๋ ๊ฒฝ์ฐ
// Create a theme instance.
const theme = createMuiTheme({
palette: {
primary: {
main: "#2991d6",
},
secondary: {
main: "#19857b",
},
error: {
main: red.A400,
},
background: {
default: "#fff",
},
}, typography: {
fontFamily: "VarelaRound,sans-serif",
},
overrides: {
MuiCssBaseline: {
"@global": {
"@font-face": [varelaRound],
},
},
},
});
Note:
In this case Material UI using Roboto as the default font
// Create a theme instance.
const theme = createMuiTheme({
typography: {
fontFamily: "VarelaRound,sans-serif",
},
palette: {
primary: {
main: "#2991d6",
},
secondary: {
main: "#19857b",
},
error: {
main: red.A400,
},
background: {
default: "#fff",
},
},
overrides: {
MuiCssBaseline: {
"@global": {
"@font-face": [varelaRound],
},
},
},
});
๋๋ ์์๋ฅผ ๋ณ๊ฒฝํ๊ณ ๋ชจ๋ ๊ฒ์ด ์ ์๋ํฉ๋๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
์ค์ ๋ก 6์๊ฐ ๋์ ์จ๋ผ์ธ์์ ๊ฒ์ํ๊ณ lib ์ฝ๋๋ฅผ ํํค์น๊ณ ๋ฌด์์๋ก ์ถ์ธกํ ํ ๋ด๊ฐ ๋๋ฌํ ๊ฒฐ๋ก ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค. IT IS POSIBLE! :๋
/public/fonts/fonts.css
์์ฑ:<link rel="stylesheet" href="%PUBLIC_URL%/fonts/fonts.css">
๋ฅผ /public/index.html์ ํค๋์ ์ถ๊ฐ๋ง์ธ!
4/๋. ์ด๋ค ์ด์ ๋ก๋ ์ฌ์ ํ ์๋ํ์ง ์์ผ๋ฉด ๊ธ๊ผด ํ์ฅ์๋ฅผ .css(
src: url('./OperatorMono.css')
์์๋)๋ก ๋ณ๊ฒฝํ์ญ์์ค.