Harfbuzz成型引擎的流线型cython绑定
uharfbuzz的Python项目详细描述
uharfbuzz
流线型cython绑定,用于HarfBuzz整形引擎。
示例
importuharfbuzzashbimportsyswithopen(sys.argv[1],'rb')asfontfile:fontdata=fontfile.read()text=sys.argv[2]face=hb.Face(fontdata)font=hb.Font(face)upem=face.upemfont.scale=(upem,upem)hb.ot_font_set_funcs(font)buf=hb.Buffer()buf.add_str(text)buf.guess_segment_properties()features={"kern":True,"liga":True}hb.shape(font,buf,features)infos=buf.glyph_infospositions=buf.glyph_positionsforinfo,posinzip(infos,positions):gid=info.codepointcluster=info.clusterx_advance=pos.x_advancex_offset=pos.x_offsety_offset=pos.y_offsetprint(f"gid{gid}={cluster}@{x_advance},{x_offset}+{y_offset}")