unicode

clearUnicodes(font)

Clear unicodes from all glyphs in the font.

from hTools3.modules.unicode import clearUnicodes
f = CurrentFont()
clearUnicodes(f)
autoUnicodes(font, customUnicodes={})

Automatically set unicode values for all glyphs in the font.

Parameters
  • font (RFont) – A font object.

  • customUnicodes (dict) – A dictionary with additional glyph name to unicode mappings. (optional)

from hTools3.modules.unicode import autoUnicodes
uniExtras = {
    'uhornacute' : 7913,
    'uhorngrave' : 7915,
}
f = CurrentFont()
autoUnicodes(f, customUnicodes=uniExtras)
autoUnicode(glyph, customUnicodes={}, verbose=False, indent=0)

Automatically set unicode value(s) for the specified glyph.

This function uses RoboFont’s glyph.autoUnicodes() first, and complements it with values from customUnicodes.

Parameters
  • glyph (RGlyph) – A glyph object.

  • customUnicodes (dict) – A dictionary with additional glyphname to unicode mappings. (optional)

from hTools3.modules.unicode import autoUnicode
uniExtras = {
    'uhornacute' : 7913,
    'uhorngrave' : 7915,
}
g = CurrentGlyph()
autoUnicode(g, customUnicodes=uniExtras)
unicodeIntToHex(intUnicode)

Converts unicode integer to hexadecimal string.

Parameters

intUnicode (int) – A unicode value as an integer.

from hTools3.modules.unicode import unicodeIntToHex
>>> glyph = CurrentGlyph()
>>> unicodeIntToHex(glyph.unicode)
0061

See also the reverse function unicodeHexToInt().

unicodeHexToInt(hexUnicode, stripUni=False)

Converts unicode hexadecimal to integer.

Parameters
  • hexUnicode (str) – The hexadecimal unicode value as a string.

  • stripUni (bool) – An optional toggle to allow uniXXXX names.

from hTools3.modules.unicode import unicodeHexToInt
glyph = CurrentGlyph()
glyph.unicode = unicodeHexToInt('0061')

See also the reverse function unicodeIntToHex().

unicodesExtra = {'AEmacron': '01E2', 'Adotbelow': '1EA0', 'Aringacute': '01FA', 'Delta': '0394', 'Edotbelow': '1EB8', 'Etilde': '1EBC', 'Gcaron': '01E6', 'Idotbelow': '1ECA', 'Ndotbelow': '1E46', 'Nhookleft': '019D', 'Odotbelow': '1ECC', 'Omega': '03A9', 'Oogonek': '01EA', 'Schwa': '018F', 'Sdotbelow': '1E62', 'Udotbelow': '1EE4', 'Uppercaseeszett': '1E9E', 'Ymacron': '0232', 'Ytilde': '1EF8', 'acutecomb': '0301', 'adotbelow': '1EA1', 'aemacron': '01E3', 'aringacute': '01FB', 'arrowdown': '2193', 'arrowdownleft': '2199', 'arrowdownright': '2198', 'arrowleft': '2190', 'arrowleftright': '2194', 'arrowright': '2192', 'arrowup': '2191', 'arrowupdown': '2195', 'arrowupleft': '2196', 'arrowupright': '2197', 'bulletoperator': '2219', 'cedillacomb': '0327', 'circumflexcomb': '0302', 'dieresiscomb': '0308', 'dotbelowcomb': '0323', 'dotlessj': '0237', 'edotbelow': '1EB9', 'eightinferior': '2088', 'eightsuperior': '2078', 'emspace': '2003', 'enspace': '2002', 'eszett': '00DF', 'etilde': '1EBD', 'f_f': 'FB00', 'f_f_i': 'FB03', 'f_f_l': 'FB04', 'fi': 'FB01', 'figurespace': '2007', 'fiveinferior': '2085', 'fivesuperior': '2075', 'fl': 'FB02', 'florin': '0192', 'fourinferior': '2084', 'foursuperior': '2074', 'gcaron': '01E7', 'gravecomb': '0300', 'hairspace': '200A', 'idotbelow': '1ECB', 'mu': '03BC', 'nbspace': '00A0', 'ndotbelow': '1E47', 'nhookleft': '0272', 'nineinferior': '2089', 'ninesuperior': '2079', 'odotbelow': '1ECD', 'oneinferior': '2081', 'onesuperior': '00B9', 'oogonek': '01EB', 'schwa': '0259', 'sdotbelow': '1E63', 'seveninferior': '2087', 'sevensuperior': '2077', 'sixinferior': '2086', 'sixsuperior': '2076', 'thickspace': '2004', 'thinspace': '2009', 'threeinferior': '2083', 'threesuperior': '00B3', 'tildecomb': '0303', 'twoinferior': '2082', 'twosuperior': '00B2', 'udotbelow': '1EE5', 'ymacron': '0233', 'ytilde': '1EF9', 'zeroinferior': '2080', 'zerosuperior': '2070', 'zerowidthspace': '200B'}

A dict containing additional glyphName to unicode mappings.