February 01, 2022

How to convert TTF to TTX(XML) with Python


Converting font files using Python is simple. Just call the saveXML() function of the fontTools module. 

 

파이썬을 이용한 폰트 파일 변환은 간단하다. fontTools 모듈의 saveXML() 함수를 호출하면 된다.


from fontTools.ttLib import TTFont

font = TTFont("xxx.ttf")
font.saveXML("xxx.ttx")

1. Input TTF and create an object with TTFont().
2. Call the saveXML() method of the object to save it.
3. Check the generated TTX file in the same directory as the Python file.

1. TTF를 입력하여 TTFont()로 객체를 생성한다.
2. 해당 객체의 saveXML() 메소드를 호출하여 저장한다.
3. 파이썬 파일과 같은 디렉터리에 생성된 TTX 파일을 확인한다.