Sidebar

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

update_all_kerning_pairs [2015/09/02 13:06]
johan
update_all_kerning_pairs [2019/01/16 18:19]
Line 1: Line 1:
-====== Scripting ====== 
  
-BirdFont does not include scripting capabilities in the GUI but all BF files are in XML format and you can edit them with python scripts. Here is an example of how to add 10 more units of spacing to each kerning pair in your font. 
- 
-<file python update_kerning.py>​ 
-#​!/​usr/​bin/​python3 
- 
-from lxml import etree 
- 
-tree = etree.parse('​FontWithKerning.bf'​) 
-for elem in tree.xpath("​.//​kerning"​):​ 
-    kerning = float (elem.attrib['​hadjustment'​]) 
-    ​ 
-    # add 10 more units of space to each kerning pair 
-    elem.attrib['​hadjustment'​] = str (kerning - 10) 
- 
-with open('​FontWithUpdatedKerning.bf',​ '​wb'​) as file_handle:​ 
-    file_handle.write(etree.tostring(tree,​ pretty_print=True,​ encoding='​utf8'​)) 
-</​file>​ 
- 
-Put this file in your font folder and replace FontWithKerning with the file name of your BF font. 
- 
-**Make a backup of your font before you run this scripts!**