Mapnik에서는 폰트 이름을 그대로 사용하지 않고 Font face name을 이용하는데...

이 Font Face name을 어떻게 알아낼 길이 없어서 고생하기도 한다.

Font Face Name을 알려면, 아래와 같은 파이선 코드를 함 돌려 주면 Mapnik에 설정되어 있는 폰트의 face name이 모두 나온다.

이를 Mapnik에서 사용하면 된다.

------------Fontnames.py --------------

try:
    from mapnik import *
except:
    print '\n\nThe mapnik library and python bindings must have been compiled and \
installed successfully before running this script.\n\n'
    raise

names = FontEngine.instance().face_names()
print len(names)

for i, fontname in enumerate(names):
 print i, fontname

---------------------------------------

위 코드를 돌리면 뭐 아래와 비스무레하게 결과가 나온다. 숫자 다음에 나오는 스트링을 그대로 사용하면 된다.

즉, 아래 결과 같은 경우 만약 맑은고딕 한글 폰트를 사용한다면 Font Face Name은 "Malgun Gothic Regular"가 되겠다..

------------
22
0 DejaVu Sans Bold
1 DejaVu Sans Bold Oblique
2 DejaVu Sans Book
3 DejaVu Sans Condensed
4 DejaVu Sans Condensed Bold
5 DejaVu Sans Condensed Bold Oblique
6 DejaVu Sans Condensed Oblique
7 DejaVu Sans ExtraLight
8 DejaVu Sans Mono Bold
9 DejaVu Sans Mono Bold Oblique
10 DejaVu Sans Mono Book
11 DejaVu Sans Mono Oblique
12 DejaVu Sans Oblique
13 DejaVu Serif Bold
14 DejaVu Serif Bold Oblique
15 DejaVu Serif Book
16 DejaVu Serif Condensed
17 DejaVu Serif Condensed Bold
18 DejaVu Serif Condensed Bold Oblique
19 DejaVu Serif Condensed Oblique
20 DejaVu Serif Oblique
21 Malgun Gothic Regular

-------------

가끔 참조할 일이 있을 듯하여 남겨두다.

2008년 12월 3일

2008/05/17 - Mapnik으로 지도 그리기..

Posted by 뚜와띠엔
,