从fontTools字形提取信息的例程

glyphtools的Python项目详细描述


字形工具

https://img.shields.io/pypi/v/glyphtools.svghttps://img.shields.io/travis/simoncozens/glyphtools.svgDocumentation Status

从字体字形中提取信息的例程

glyphtools.bin_glyphs_按度量单位(字体、字形、类别, bincount=5)

Organise glyphs according to a given metric.

Organises similar glyphs into a number of bins. The bins are not guaranteed to contain the same number of glyphs; the one-dimensional ckmeans clustering algorithm is used to cluster glyphs based on metric similarity. For example, if there are five glyphs of width 100, 102, 105, 210, and 220 units respectively, and you ask for two bins, the first bin will contain three glyphs and the second will contain two. This is usually what you want.

Parameters:
  • font – a ^{tt1}$ TTFont object OR a ^{tt2}$ GSFontMaster object OR a ^{tt3}$ Font object.
  • glyphs – a collection of glyph names
  • category – the metric (see metric keys in
    get_glyph_metrics().)
  • bincount – number of bins to return
Returns:

A list of ^{tt4}$ two-element tuples. The first element is a list of glyphnames in this bin; the second is the average metric value of the glyphs in this bin.

glyphtools.categorize_glyph(字体,字形名称)

Returns the category of the given glyph.

Parameters:
  • font – a ^{tt1}$ TTFont object OR a ^{tt2}$ GSFontMaster object OR a ^{tt3}$ Font object.
  • glyphname – name of the glyph.
Returns:

A two-element tuple. The first element is one of the following strings: ^{tt8}$, ^{tt9}$, ^{tt10}$, ^{tt11}$, ^{tt12}$. If the glyph is a mark, the second element is the mark attachment class number.

glyphtools.determine_内核(字体、字形1、字形2、目标距离, 偏移量1=0,0,偏移量2=0,0,最大值=0.4)

Determine a kerning value required to set two glyphs at given ink-to-ink distance.

The value is bounded by the ^{tt13}$ parameter. For example, if ^{tt13}$ is 0.20, the right glyph will not be placed any further left than 80% of the width of left glyph, even if this places the ink further than ^{tt15}$ units away.

Parameters:
  • font – a ^{tt1}$ TTFont object OR a ^{tt2}$ GSFontMaster object OR a ^{tt3}$ Font object.
  • glyph1 – name of the left glyph.
  • glyph2 – name of the right glyph.
  • targetdistance – distance to set the glyphs apart.
  • offset1 – offset (X-coordinate, Y-coordinate) to place
    left glyph.
  • offset2 – offset (X-coordinate, Y-coordinate) to place
    right glyph.
  • maxtuck – maximum proportion of the left glyph’s width to
    kern.

Returns: A kerning value, in units.

glyphtools.duplicate_glyph(字体、现有、新)

Add a new glyph to the font duplicating an existing one.

Parameters:
  • font – a ^{tt3}$ Font object.
  • existing – name of the glyph to duplicate.
  • new – name of the glyph to add.

glyphtools.get_glyph_度量名称

Returns glyph metrics as a dictionary.

Parameters:
  • font – a ^{tt1}$ TTFont object OR a ^{tt2}$ GSFontMaster object OR a ^{tt3}$ Font object.
  • glyphname – name of the glyph.
Returns:

width: Advance width of the glyph. lsb: Left side-bearing rsb: Right side-bearing xMin: minimum X coordinate xMax: maximum X coordinate yMin: minimum Y coordinate yMax: maximum Y coordinate rise: difference in Y coordinate between cursive entry and exit

Return type:

A dictionary with the following keys

glyphtools.set_glyph_类别(字体、字形名称、类别, maClass=无)

Sets the category of the glyph in the font.

Parameters:
  • font – a ^{tt1}$ TTFont object OR a ^{tt2}$ GSFontMaster object OR a ^{tt3}$ Font object.
  • glyphname – name of the glyph.
  • category – one of ^{tt9}$, ^{tt10}$, ^{tt11}$,
    ^{tt12}$.
  • maClass – If the category is ^{tt9}$, the mark
    attachment class number.

历史

  • PyPI的第一个版本。在

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何解决连接设备中的显示仿真器安卓 studio不止一个   java setOnClickListener错误,仅适用于平板电脑(10“)?   java如何将VSAM文件内容导出为可在windows中查看?   url JSP不会打开CSS、图像和JS   java在hibernate中有多级结构吗   以Java字节存储颜色;字节字节vs.字节[3]vs.整数   后台异步任务中的java Json请求未返回数据   仅在Linux WebLogic上引发java DuplicateKeyException   java执行MessageDigest时MessageDigest在做什么。是否多次更新?   仅在maven上发生java泛型编译错误   java如何在webview中显示具有图像的特定div   java自定义JSON序列化和反序列化   java是一个从JSON数组收集数据的arraylist   java CardView无法正确展开   java将目录上载到远程服务器   java Apache Camel:拆分器、CBR还是动态路由器?   java如何在GXT中禁用DualListField的“添加选定”按钮?   Java:查找数字是否为2的幂