0. 잡설로 시작..


어떤 모바일 운영체제를 사용하건 항상 눈에 걸리는 것이 있다.

바로 한글 볼드체..

그리고 그 다음엔 한글 고정폭 폰트..


팜OS를 사용하던 시절은 잘 기억이 안나고,

윈도 모바일, iOS, webOS, 안드로이드에 이르기 까지

한글 볼드체와 한글 고정폭 폰트 문제가 기본적으로 해결되서 발매된 기종이 없었다.


iOS와 webOS는 국내에서 설계/제작되지 않기 때문에 뭐 그렇다고 쳐도,

심지어 국내 회사가 제작한 윈도 모바일, 안드로이드 기기들도 이 문제에서 자유롭지 못했다..

어이 삼숑.. 반성 좀 하시오!!!


여하튼 어떤 운영체제를 사용하건 한글 볼드체를 사용하기 위한 자료 준비와 삽질로 참 많은 시간을 허비했고,

안드로이드를 쓰는 지금도 여전히 그 삽질은 반복되고 있다. :)



1. 시작


여튼..

내가 요즘 사용하고 있는 갤럭시 노트의 경우 진저브레드 펌웨어에서는

기본 폰트를 원하는 한글 폰트로 바꿔서 사용할 수 있었으므로, 탈옥만 되어 있다면 별다른 노력 없이

한글 볼드체를 사용할 수 있었는데, ics 빌드(CM9포함) 부터는 기본폰트(영문폰트)를

한글 폰트로 그냥 덮어쓰면 반드시 문제가 발생했다..

부팅이 안되거나 영문 폰트가 아예 안나오거나.. ^^;;


뭐 목마른 사람이 우물 판다고..

대학교 시절 몇년 리눅스 사용하던 기억을 더듬어서 폰트 설정 파일을 찾아서 롬을 무작정 뒤졌다..

리눅스를 제대로 사용했던 것이 무려 8년 전이라 좀 염려했는데,

다행스럽게 금새 찾을 수 있었다..


위치는 리눅스 운영체제에 있어서 설정파일의 성지 /system/etc

그리고 파일 명은 진심 정직하게 system_fonts.xml과 fallback_fonts.xml


바로 이 두 파일이 CM9에서 폰트 설정을 담당하는 파일이다..

이것만 정복하면 행복한? 안드로이드 라이프를 즐길 수 있다.



2. 배경


자.. 폰트가 어떻게 설정되는지를 아주 간략히는 알고 있어야한다.


일단 안드로이드 운영체제(뭐.. 다른 운영체제도 다 마찬가지다)의 기본 폰트는 라틴폰트이다..

그렇지.. 몇 글자 안들어있다..

알파벳 계열을 사용하는 나라에서만 사용할 수 있는거다..


그러면 이 라틴 계열(알파벳 계열) 문자가 아닌 문자는?

일단 기본 폰트에서 문자를 찾고, 만약 해당 문자가 없으면 fallback_fonts.xml에 정의된 비상용^^; 폰트를 뒤진다.


그렇다.. 한글은 기본 폰트에 들어있지 않고, 운영체제는 fallback 폰트를 뒤져서 한글을 뿌려준다..


자.. 여기서 문제가 발생한다..

기본 폰트는 regular(기본), bold(두꺼운), italic(기울어진), bold italic(두껍고 기울어진) 폰트 네가지가

한 셋트로 이루어진다..


그렇지.. 라틴 계열 문자라봐야 알파벳 대/소문자, 숫자, 기본 문장부호 정도만 포함되어 있으니,

저렇게 네가지 셋트를 아예 만들어서 넣는게 한글에 비해서는 어렵지 않을게다..


그런데 한글은 폰트 한가지에 수만자가 들어간다.

그리고 내가 사용했던 모든! 모바일 운영체제에는 그런 이유인지 한글 볼드체가 들어있지 않다..


바로 이것이 문제이다..

자.. 기본 폰트가 regular건 bold건 동일한 fallback 폰트에서 글꼴을 끌어오니,

영문은 볼드로 표기되어도 한글은 regular로 출력되는 우스운 현상이 발생하는 것이다.


대충 표현해보면 아래처럼 되는 것이다..

TISTORY 주소는 notme.tistory.com 입니다.

아놔.. 난 이거 못참는다..



3. 시도 1 - 실패한 방법


뭐.. 문제의 원인은 이미 알았다..

볼드체 fallback 폰트를 넣어주면 되는게다..

한글 폰트의 경우 italic, bold italic을 따로 구할수는 없을게니, 볼드체라도 챙겨주자..

(적어도 내가 알고 있는 범위 내에서는 없다.. -_-)


아까 말했듯, fallback 폰트는 /system/etc/fallback_fonts.xml 에서 정의된다..

그리고 그 내용은 아래와 같다.. CM9 에서는.. ^^


<?xml version="1.0" encoding="utf-8"?>
<!--
    Fallback Fonts

    This file specifies the fonts, and the priority order, that will be searched for any
    glyphs not handled by the default fonts specified in /system/etc/system_fonts.xml.
    Each entry consists of a family tag and a list of files (file names) which support that
    family. The fonts for each family are listed in the order of the styles that they
    handle (the order is: regular, bold, italic, and bold-italic).
The order in which the
    families are listed in this file represents the order in which these fallback fonts
    will be searched for glyphs that are not supported by the default system fonts (which are
    found in /system/etc/system_fonts.xml).

    Note that there is not nameset for fallback fonts, unlike the fonts specified in
    system_fonts.xml. The ability to support specific names in fallback fonts may be supported
    in the future. For now, the lack of files entries here is an indicator to the system that
    these are fallback fonts, instead of default named system fonts.

    There is another optional file in /vendor/etc/fallback_fonts.xml. That file can be used to
    provide references to other font families that should be used in addition to the default
    fallback fonts. That file can also specify the order in which the fallback fonts should be
    searched, to ensure that a vendor-provided font will be used before another fallback font
    which happens to handle the same glyph.
-->
<familyset>
    <family>
        <fileset>
            <file>DroidNaskh-Regular.ttf</file>
        </fileset>
    </family>
    <family>
        <fileset>
            <file>DroidSansEthiopic-Regular.ttf</file>
        </fileset>
    </family>
    <family>
        <fileset>
            <file>DroidSansHebrew-Regular.ttf</file>
            <file>DroidSansHebrew-Bold.ttf</file>
        </fileset>
    </family>
    <family>
        <fileset>
            <file>DroidSansThai.ttf</file>
        </fileset>
    </family>
    <family>
        <fileset>
            <file>DroidSansArmenian.ttf</file>
        </fileset>
    </family>
    <family>
        <fileset>
            <file>DroidSansGeorgian.ttf</file>
        </fileset>
    </family>
    <family>
        <fileset>
            <file>Lohit-Devanagari.ttf</file>
        </fileset>
    </family>
    <family>
        <fileset>
            <file>Lohit-Bengali.ttf</file>
        </fileset>
    </family>
    <family>
        <fileset>
            <file>Lohit-Tamil.ttf</file>
        </fileset>
    </family>
    <family>
        <fileset>
            <file>DroidSansFallback.ttf</file>
        </fileset>
    </family>
</familyset>
 


여기서 한글이 들어있는 폰트는 제~~일 아래 DroidSansFallback.ttf

그리고 제일 위에 빨강색으로 강조한 부분을 보면 regular, bold, italic, bold-italic 순서대로 써주면 된다고 한다..


아싸..

이제 원하는 한글 폰트의 기본체와 볼드체를 /system/fonts 에 카피하고,

파일명을 /system/etc/fallback_fonts.xml 에 기록해주면 된다.


위에서 부터 순서대로 폰트를 뒤지니까 DroidSansFallback.ttf 앞에 적어주거나,

DroidSansFallback.ttf 를 삭제하고 아래처럼 고쳐주면 되겠다..



     <family>
        <fileset>
            <file>DroidSansFallback.ttf</file>
        </fileset>
    </family>

자.. 요 부분을 아래처럼..


    <family>
        <fileset>
            <file>복사해준regular폰트명.ttf</file>

            <file>복사해준bold폰트명.ttf</file>
        </fileset>
    </family>



저장하고 리붓!!!!


그런데 안된다.. OTL....

아놔.. 설정파일 대가리에는 된다고 써 있는데 왜.. ㅜ.ㅠ


여튼 안되고 난 이유를 모른다..



4. 시도 2 - 성공한 방법


쩝.. 내가 사용하는 CM9 빌드만 그런건지 안드로이드 전체가 그런건지는 모르겠다만

여하튼 위와같은 방법이 통하질 않았다.. 아.. 억울하다..


그렇다고 설정파일을 찾은 이상 방법이 없는건 아니지..


이건 좀 무식한 방법을 사용한다.

바로 가상 볼드체를 사용하는 것...


자.. 아까 한글 폰트는 이탤릭 전용 폰트가 없다고 했는데,

그런 한글은 이탤릭을 못쓰나?


전혀 그렇지 않다..

바로 폰트써버(이게 뭔지는 말하지 않는다... 그럴 능력도 없고)가 기울여주면 되니까..


그럼 볼드는?

그렇다.. 이 역시도 폰트 써버가 일반체 글꼴을 두껍게 보여주는 기능을 가지고 있다..


볼드 전용 폰트가 있으면 그걸 가져다 쓰고, 없으면 regular 폰트를 겹쳐서 두껍게 보여주면 그만..

그러나 글꼴 디자이너가 한땀한땀 고만해가며 다듬은 bold 전용 폰트만큼 미려할 수는 없겠지..

그래 이것이 단점이다..


자.. 여기까지 왔으면 이제 한글에 소프트 볼드를 적용하는 방법이 중요하겠네..

그런데 이게 무지 쉽다.. -_-;;


기본 영문 폰트 중 볼드, 이탤릭, 볼드 이탤릭 전용 폰트를 싸그리 지워주면 된다..

어디서?

바로 /system/etc/system_fonts.xml에서..


훗.. 간단한 꼼수다..

영문 볼드 폰트가 없으므로 폰트 써버는 소프트 볼드를 활성화할꺼고,

그러면 덩달아 fallback 폰트로 지정된 한글 폰트 역시도 소프트 볼드가 적용되는게다..

초간단.. :)


일단 /system/etc/system_fonts.xml 를 열어본다...



<?xml version="1.0" encoding="utf-8"?>
<!--
    System Fonts

    This file lists the font families that will be used by default for all supported glyphs.
    Each entry consists of a family, various names that are supported by that family, and
    up to four font files. The font files are listed in the order of the styles which they
    support: regular, bold, italic and bold-italic. If less than four styles are listed, then
    the styles with no associated font file will be supported by the other font files listed.

    The first family is also the default font, which handles font request that have not specified
    specific font names.

    Any glyph that is not handled by the system fonts will cause a search of the fallback fonts.
    The default fallback fonts are specified in the file /system/etc/fallback_fonts.xml, and there
    is an optional file which may be supplied by vendors to specify other fallback fonts to use
    in /vendor/etc/fallback_fonts.xml.
-->
<familyset>

    <family>
        <nameset>
            <name>sans-serif</name>
            <name>arial</name>
            <name>helvetica</name>
            <name>tahoma</name>
            <name>verdana</name>
        </nameset>
        <fileset>
            <file>Roboto-Regular.ttf</file>
            <file>Roboto-Bold.ttf</file>
            <file>Roboto-Italic.ttf</file>
            <file>Roboto-BoldItalic.ttf</file>

        </fileset>
    </family>

    <family>
        <nameset>
            <name>serif</name>
            <name>times</name>
            <name>times new roman</name>
            <name>palatino</name>
            <name>georgia</name>
            <name>baskerville</name>
            <name>goudy</name>
            <name>fantasy</name>
            <name>cursive</name>
            <name>ITC Stone Serif</name>
        </nameset>
        <fileset>
            <file>DroidSerif-Regular.ttf</file>
            <file>DroidSerif-Bold.ttf</file>
            <file>DroidSerif-Italic.ttf</file>
            <file>DroidSerif-BoldItalic.ttf</file>

        </fileset>
    </family>

    <family>
        <nameset>
            <name>Droid Sans</name>
        </nameset>
        <fileset>
            <file>DroidSans.ttf</file>
            <file>DroidSans-Bold.ttf</file>
        </fileset>
    </family>

    <family>
        <nameset>
            <name>monospace</name>
            <name>courier</name>
            <name>courier new</name>
            <name>monaco</name>
        </nameset>
        <fileset>
            <file>DroidSansMono.ttf</file>
        </fileset>
    </family>

</familyset>
 


자.. 간단히 말하면 빨간색으로 표기한 부분을 지워주면 된다.. :)

물론 위 파일은 내가 사용하는 CM9 빌드에서 가져온 것이고, 다른 버전에서는 당연히! 내용이 다를게다..


전체 내용을 아주 간략히 설명하면 <nameset> 에 정의된 이름의 폰트가 필요할 경우,

<fileset>에 적어놓은 파일을 찾아서 글씨를 뿌려주는 것이다..

그래서 <fileset> 에서 regular를 제외한 다른 폰트를 싸그리 지워주는게다..


자.. 이 방법은 확실히 통한다..

할렐루야.. ㅜ0ㅠ



5. AS (아후타 서비스)


자.. 3번과 4번의 배경지식을 조합하면 한글 폰트를 바꿀 수 있게된다..

바로 Fallback_Fonts.xml에 정의된 fallback 폰트를 원하는 폰트로 덮어쓰는 것!!


그런데 이러면 나 처럼 까탈스런 사람은 또 문제를 느낀다..

영문 폰트랑 한글 폰트가 따로 놀거든.. :)

(진저브레드는 영문 폰트를 그냥 한글 폰트로 덮어도 문제 없었는데.. ㅜ.ㅠ)


어찌하면 되냐고?

잘 어울리는 영문 폰트를 구해서 기본 영문 폰트를 덮어쓰거나,

한글 폰트를 여차저차한 방법으로 잘 편집하고 라틴 전용으로 변환해서 사용하는 것...


그러나 이건 소개하지 않는다..

나도 이렇게 까지는 안하는데다 좀 힘들거든.. :)


그리고 영문 폰트 바꾸는 방법은 구글님에게 물어보면 세상에 널렸다.

다만 좀 주의하시라.. :)

CM9의 경우 /system/fons 폴더에 보면 symbolic link가 걸려있는 녀석들이 있는데,

고 녀석들을 실제 폰트 파일로 덮어쓰면 문제가 생기나보더라..

나야 뭐 폰트 한가지만 사용하니 그런짓은 안해봤다.. :)



6. 부록..


자.. 그럼 고정폭 폰트는?

아래 링크를 참조하시라..

윈도 모바일 사용하던 시절에 작성한 글인데 뭐 원리는 온전히 같다..


다만 아쉬운건 마이미츠가 서버 개편하면서 첨부한 그림이 싸악 날아갔다는거.. ㅜ.ㅠ


http://www.mymits.net/722308


마지막 한줄 요약이 핵심이다.. :)



7. 마무리


자.. 이렇게 성의없고 긴~~글은 여기서 그만..

이런거 1000명 중 999명은 관심 없잖아.. ^^