accents
Tools to work with accented glyphs using Glyph Construction syntax.
- ACCENTS = ['acute', 'grave', 'circumflex', 'dieresis', 'tilde', 'macron', 'breve', 'dotaccent', 'ring', 'cedilla', 'hungarumlaut', 'ogonek', 'caron']
A basic default list of latin diacritics.
- buildConstructionGlyph(constructionGlyph, font, clear=True, autoUnicodes=True)
Low-level function to build a ConstructionGlyph in a given font.
- Parameters
constructionGlyph – A ConstructionGlyph object.
- Returns
The newly constructed glyph.
- buildGlyphConstruction(font, construction, clear=True, verbose=False, indentLevel=0, autoUnicodes=True)
Build glyph from Glyph Construction rule in the given font.
- Parameters
font (RFont) – A font object.
construction (str) – A Glyph Construction rule.
clear (bool) – Clear glyph contents before constructing new glyph.
verbose (bool) – Turn text output on/off.
indentLevel (int) – Number of indents before text output lines.
autoUnicodes (bool) – Automatically set the unicode value for the constructed glyph.
- Returns
The newly constructed glyph.
from hTools3.modules.accents import buildGlyphConstruction construction = "agrave = a + grave@center,`top+100`" f = CurrentFont() buildGlyphConstruction(f, construction, clear=True, verbose=False, indentLevel=0, autoUnicodes=True)
- buildAccentedGlyphs(font, glyphNames, glyphConstructions, clear=True, markColor=None, verbose=False, indentLevel=0, autoUnicodes=True)
Build accented glyphs in the current font using Glyph Construction rules.
- Parameters
font (RFont) – A font object.
glyphNames (list) – A list of accented glyph names to build in the given font.
glyphConstructions (str) – A string of Glyph Construction definitions, one per line.
clear (bool) – Clear glyph contents before constructing new glyphs.
markColor (tuple) – Optional mark color for the constructed glyphs.
verbose (bool) – Turn text output on/off.
indentLevel (int) – Number of indents before text output lines.
autoUnicodes (bool) – Automatically set the unicode value for the constructed glyphs.
from hTools3.modules.accents import buildAccentedGlyphs f = CurrentFont() constructions = """ agrave = a + grave@center,`top+100` aacute = a + acute@center,`top+100` """ buildAccentedGlyphs(f, ['agrave'], constructions, verbose=True, indentLevel=0, markColor=(0, 1, 1, 0.5), clear=True)
- buildGlyphConstructions(font, glyphConstructions, clear=True, markColor=None, verbose=False, indentLevel=0, autoUnicodes=True)
Build new glyphs in a font from a string of Glyph Construction definitions.
- Parameters
font (RFont) – A font object.
glyphConstructions (str) – A string of Glyph Construction definitions, one per line.
clear (bool) – Clear glyph contents before constructing new glyph.
markColor (tuple) – Optional mark color for the constructed glyphs.
verbose (bool) – Turn text output on/off.
indentLevel (int) – Number of indents before text output lines.
autoUnicodes (bool) – Automatically set the unicode value for the constructed glyphs.
glyphNames (list) – A list of glyph names to restrict the output. If the list is empty, all glyph construction definitions are built.
- Returns
A list with the names of all built glyphs.
from hTools3.modules.accents import buildGlyphConstructions f = CurrentFont() constructions = """\ agrave = a + grave@center,`top+100` aacute = a + acute@center,`top+100` """ buildGlyphConstructions(f, constructions, verbose=True, indentLevel=0, markColor=(0, 1, 1, 0.5), clear=True)
- extractGlyphConstructions(font, glyphNames=None, accents=['acute', 'grave', 'circumflex', 'dieresis', 'tilde', 'macron', 'breve', 'dotaccent', 'ring', 'cedilla', 'hungarumlaut', 'ogonek', 'caron'])
Extract Glyph Construction rules from components in glyphs.
- Parameters
font (RFont) – A font object.
glyphNames (list) – A list with names of glyphs from which to extract glyph constructions.
accents (list) – A list with names of glyphs which are not base glyphs. (optional)
- Returns
A string of Glyph Construction definitions, one per line.
>>> from hTools3.modules.accents import buildGlyphConstructions >>> f = CurrentFont() >>> constructions = extractGlyphConstructions(f, glyphNames=['agrave', 'aacute']) >>> print(constructions) agrave = a + grave aacute = a + acute
Note
The extracted glyph construction definitions are very basic. You’ll probably want to refine them with positioning instructions. See the Glyph Construction documentation for syntax examples.
- extractGlyphConstruction(glyph, accents=['acute', 'grave', 'circumflex', 'dieresis', 'tilde', 'macron', 'breve', 'dotaccent', 'ring', 'cedilla', 'hungarumlaut', 'ogonek', 'caron'])
Extract Glyph Construction rule from a glyph with components.
- Parameters
glyph (RGlyph) – A glyph object.
accents (list) – A list with names of glyphs which are not base glyphs. (optional)
- Returns
A string of Glyph Construction definitions, one per line.
>>> from hTools3.modules.accents import extractGlyphConstruction >>> g = CurrentGlyph() >>> construction = extractGlyphConstruction(g) >>> print(construction) agrave = a + grave