๋ฐ˜์‘ํ˜•

CSS ํŒŒ์ผ ์ตœ์ƒ๋‹จ์— @import ๊ตฌ๋ฌธ์„ ์‚ฌ์šฉํ•ด์„œ ํฐํŠธ๋ฅผ ๋ถˆ๋Ÿฌ์˜ค๋ฉด CSS ํŒŒ์ผ์ด ์™„์ „ํžˆ ๋กœ๋“œ๋˜๊ณ  ํŒŒ์‹ฑ๋  ๋•Œ๊นŒ์ง€ ๋ฆฌ์†Œ์Šค ๋กœ๋“œ๊ฐ€ ์ง€์—ฐ๋ผ์„œ ์„ฑ๋Šฅ ์ €ํ•˜๋ฅผ ์ดˆ๋ž˜ํ•  ์ˆ˜ ์žˆ๋‹ค. ๋ฐ˜๋ฉด, HTML <head> ์•ˆ์—์„œ <link> ํƒœ๊ทธ๋ฅผ ํ†ตํ•ด ํฐํŠธ๋ฅผ ๋ถˆ๋Ÿฌ์˜ค๋ฉด ์—ฌ๋Ÿฌ ๋ฆฌ์†Œ์Šค๋ฅผ ๋ณ‘๋ ฌ๋กœ ๋กœ๋“œํ•  ์ˆ˜ ์žˆ์–ด ๋” ํšจ๊ณผ์ ์ด๋‹ค. ์‹ค์ œ๋กœ <link> ๋ฐฉ์‹์ด @import ๋ณด๋‹ค 1.3~1.6์ดˆ ์ •๋„ ๋” ๋น ๋ฅด๊ฒŒ ํฐํŠธ๋ฅผ ๋กœ๋“œํ•œ๋‹ค๊ณ  ํ•œ๋‹ค. 

 

๊ตฌ๊ธ€ ํฐํŠธ CSS ํŒŒ์ผ ๊ฐ€์ ธ์˜ค๊ธฐ ํŒ


์‚ฌ์šฉํ•˜๊ณ  ์‹ถ์€ ๊ตฌ๊ธ€ ํฐํŠธ ์ด๋ฆ„์„ ์ฃผ์†Œ์˜ family ๊ฐ’์— ์ž…๋ ฅํ•˜๋ฉด Font Family CSS ํŒŒ์ผ์„ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ๋‹ค. ์ฐธ๊ณ ๋กœ display=swap ํŒŒ๋ผ๋ฏธํ„ฐ๋Š” ํฐํŠธ ํŒŒ์ผ ๋กœ๋“œ๋ฅผ ๊ธฐ๋‹ค๋ฆฌ๋Š” ๋™์•ˆ ํ…์ŠคํŠธ๊ฐ€ ๋ณด์ด์ง€ ์•Š๋Š” ํ˜„์ƒ์„ ๋ฐฉ์ง€ ํ•˜๊ธฐ ์œ„ํ•ด ๋Œ€์ฒด ํฐํŠธ๋ฅผ ๋ณด์—ฌ์ฃผ๋Š” ์˜ต์…˜์ด๋‹ค. ๊ทธ ์™ธ์— wght, italic ๋“ฑ ์—ฌ๋Ÿฌ ํŒŒ๋ผ๋ฏธํ„ฐ๋“ค์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค(API Docs).

https://fonts.googleapis.com/css2?family=Oswald&display=swap
@font-face {
  font-family: "Oswald";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/oswald/v53/TK3_WkUHHAIjg75cFRf3bXL8LICs1_FvsUtiZSSUhiCXABTV.woff2) format('woff2');
  /* unicode-range ์†์„ฑ์„ ์ง€์ •ํ•˜๋ฉด ํ•ด๋‹น ๋ฌธ์ž ๋ฒ”์œ„์—๋งŒ ํฐํŠธ๊ฐ€ ์ ์šฉ๋œ๋‹ค */
  unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

 

CSS ํŒŒ์ผ์—์„œ ํฐํŠธ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ


๋ฐฉ๋ฒ• 1 - @import ๊ตฌ๋ฌธ ์‚ฌ์šฉ

CSS ํŒŒ์ผ ๊ฐ€์žฅ ์ƒ๋‹จ์— @import ๊ตฌ๋ฌธ์„ ์‚ฌ์šฉํ•˜์—ฌ ํ•ด๋‹น ์„œ์ฒด์˜ ๋ชจ๋“  font-face๋ฅผ ๋ถˆ๋Ÿฌ์˜ฌ ์ˆ˜ ์žˆ๋‹ค. ์ด ๋ฐฉ๋ฒ•์€ ํŽธ๋ฆฌํ•˜์ง€๋งŒ ํŽ˜์ด์ง€ ๋กœ๋”ฉ ์‹œ๊ฐ„์— ์˜ํ–ฅ์„ ์ค„ ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ ์ฃผ์˜๊ฐ€ ํ•„์š”ํ•˜๋‹ค. ํŠนํžˆ @import ๊ตฌ๋ฌธ์ด ์—ฌ๋Ÿฌ๊ฐœ ์žˆ๋Š” ๊ฒฝ์šฐ ํŽ˜์ด์ง€ ์„ฑ๋Šฅ์„ ์ €ํ•˜์‹œํ‚ฌ ์ˆ˜ ์žˆ๋‹ค.

@import url("https://fonts.googleapis.com/css2?family=Oswald:wght@200..700&display=swap");

h1 {
  font-family: "Oswald", sans-serif;
}

 

๋ฐฉ๋ฒ• 2 - @font-face ๊ตฌ๋ฌธ ์‚ฌ์šฉ

@font-face ๊ตฌ๋ฌธ์„ ์‚ฌ์šฉํ•˜์—ฌ ํŠน์ • font-face๋งŒ ๋ถˆ๋Ÿฌ์˜ฌ ์ˆ˜ ์žˆ๋‹ค. ํฐํŠธ ์Šคํƒ€์ผ, ๋‘๊ป˜, ์œ ๋‹ˆ์ฝ”๋“œ ๋ฒ”์œ„ ๋“ฑ ํฐํŠธ๋ฅผ ๋” ์„ธ๋ฐ€ํ•˜๊ฒŒ ํ†ต์ œํ•  ๋•Œ ์œ ์šฉํ•˜๋‹ค. ์ฐธ๊ณ ๋กœ ์ฃผ์†Œ์˜ v53์€ ํฐํŠธ ๋ฒ„์ „์„ ์˜๋ฏธํ•œ๋‹ค.

@font-face {
  font-family: "Oswald";
  font-style: normal;
  font-weight: 400;
  src: url(https://fonts.gstatic.com/s/oswald/v53/TK3_WkUHHAIjg75cFRf3bXL8LICs1_FvsUtiZSSUhiCXABTV.woff2) format('woff2'); 
  unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

h1 {
  font-family: "Oswald", sans-serif;
}

 

๋ ˆํผ๋Ÿฐ์Šค


 

CSS API ์—…๋ฐ์ดํŠธ  |  Google Fonts  |  Google for Developers

์ด ํŽ˜์ด์ง€๋Š” Cloud Translation API๋ฅผ ํ†ตํ•ด ๋ฒˆ์—ญ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. CSS API ์—…๋ฐ์ดํŠธ ์ปฌ๋ ‰์…˜์„ ์‚ฌ์šฉํ•ด ์ •๋ฆฌํ•˜๊ธฐ ๋‚ด ํ™˜๊ฒฝ์„ค์ •์„ ๊ธฐ์ค€์œผ๋กœ ์ฝ˜ํ…์ธ ๋ฅผ ์ €์žฅํ•˜๊ณ  ๋ถ„๋ฅ˜ํ•˜์„ธ์š”. ์ด์ œ Google Fonts๋Š” v2 API ์—…๋ฐ์ดํŠธ์—์„œ

developers.google.com

 


๊ธ€ ์ˆ˜์ •์‚ฌํ•ญ์€ ๋…ธ์…˜ ํŽ˜์ด์ง€์— ๊ฐ€์žฅ ๋น ๋ฅด๊ฒŒ ๋ฐ˜์˜๋ฉ๋‹ˆ๋‹ค. ๋งํฌ๋ฅผ ์ฐธ๊ณ ํ•ด ์ฃผ์„ธ์š”

 

๋ฐ˜์‘ํ˜•