- l, r, d = map(int, parts[1:])
- result += "kerning %d %d %.3f;\n"%(l, r, float(d)/fh)
+ kerning.append(values)
+
+ for c, n in codes.items():
+ h = metrics[n][1]
+ if c in caps:
+ cap_height.append(h)
+ elif c in xchars:
+ x_height.append(h)
+
+ if cap_height:
+ cap_height.sort()
+ result += "cap_height {:.3f};\n".format(float(cap_height[len(cap_height)*2//3])/fh)
+ if x_height:
+ x_height.sort()
+ result += "x_height {:.3f};\n".format(float(x_height[len(x_height)*2//3])/fh)
+
+ for c, n in codes.items():
+ _, _, ox, oy, a = metrics[n]
+ x, y, w, h, b = glyphs[n]
+ result += "glyph {}\n{{\n".format(c)
+ result += "\ttexcoords {} {} {} {};\n".format(float(x)/tw, float(th-y-h)/th, float(x+w)/tw, float(th-y)/th)
+ result += "\tsize {:.3f} {:.3f};\n".format(float(w)/fh, float(h)/fh)
+ result += "\toffset {:.3f} {:.3f};\n".format(float(ox-b)/fh, float(oy-b)/fh)
+ result += "\tadvance {:.3f};\n".format(float(a)/fh)
+ result += "};\n"
+
+ for k in kerning:
+ l, r, d = k
+ result += "kerning {} {} {:.3f};\n".format(l, r, float(d)/fh)