Leun Kim's BlogWindy Odaiba

Others / Blog Tips

How to Use a Japanese Web Font in WordPress with @font-face

Blog TipsOthers4 comments

Translated from the Korean original. Read the original →

Japanese fonts in WordPress

When you build a website with WordPress, the biggest headache is Japanese fonts. If you don't care much about fonts, the default might be fine, but for people like me who are picky about fonts, it's hard to live with. In this post I'll show you an easy way to switch to a Japanese font using @font-face.

1. Get a Japanese font

The first thing to do is pick a font. How the font looks matters, of course, but the most important thing is the file size. Pages on the web need to load fast, so a font with a small file is best. If you're going to serve it from your own server, something under 1.0MB is about right (fonts with only hiragana and katakana can be as small as 10kB, and there are plenty of them). The font I recommend is M+ 1p Regular. The font's official site is here, and you can download it for free here. The license is free too, so no need to worry.

2. Convert the TTF font to WOFF

The font you get from the site above is mplus-1p-regular.ttf. But TTF files are large, and they may not work in Internet Explorer. So you'll want to compress the TTF font into WOFF format. You can do that easily on this site:

http://everythingfonts.com/ttf-to-woff

The 1.3MB mplus-1p-regular.ttf becomes an 800kB mplus-1p-regular.woff.

3. Upload the font to your server

Upload mplus-1p-regular.woff to a suitable place on your server (usually the root).

4. Edit the CSS

Open style.css, the file that controls your site's styles, and add this code at the very top:

@font-face{
     font-family: mplus-1p-regular; 
     src: url('/mplus-1p-regular.woff'); 
     format('woff');}

Then set mplus-1p-regular in font-family, for example like this:
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td{
      font-family: mplus-1p-regular, sans-serif;
      font-size:100%; 
      font-style:inherit; 
      font-weight:inherit;
}
And that's it. Of course, if you're willing to spend some money, you can probably find fonts that are even smaller and better-looking.

#font#japanese#ttf#woff#fonts

More in Blog Tips

See all

Comments 4

  1. negabaro kim

    와 카테고리 너무 깔끔하다 ㅠㅠ 카테고리관련 플러그인 쓰시는건가요?

    1. Leun Kim

      방문 감사드립니다! 헤헤 아닙니다. 그냥 Enhanced Text를 위젯에 추가한 후에 노가다 코드를 써 줬습니다..OTL


       
      src="/wp-content/uploads/2013/09/transparent.png" width="1" height="1"/>
       Mathematics




           
      src="/wp-content/uploads/2013/09/transparent.png" width="1" height="1"/>
        In Handai




                
      src="/wp-content/uploads/2013/09/transparent.png" width="1" height="1"/>
        M2 Seminar I~II


      괄호 숫자의 경우, 카테고리의 포스트 숫자를 불러오는 코드로

      를 썼습니다.

  2. irotori-dori

    こちらの記事を参考にいたしました。
    丁寧かつ端的に記載してくださっているので、素人でもなんなくフォント変更ができました。
    ありがとうございます。
    これからも、こちらのサイトを参考にいたします。

    1. Leun Kim

      コメント有難うございます!助けになれてよかったですね。今後も宜しくお願いいたします!

    Leave a comment

    Your name and comment are shown on this page (private comments only to the blog owner). Your e-mail address is never shown.

    Back to top