从fontTools字形提取信息的例程
glyphtools的Python项目详细描述
字形工具
从字体字形中提取信息的例程
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.
- 免费软件:Apache软件许可证2.0
- 文档:https://glyphtools.readthedocs.io。在
历史
- PyPI的第一个版本。在
- 项目
标签: