Skip to content

Commit

Permalink
Adds renaming script
Browse files Browse the repository at this point in the history
  • Loading branch information
kalapi committed May 29, 2024
1 parent b769892 commit cdbe426
Show file tree
Hide file tree
Showing 2 changed files with 165 additions and 0 deletions.
65 changes: 65 additions & 0 deletions scripts/_glyphsScripts/UT_renameGlyphsFromDatabase.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#MenuTitle: [UT] Rename Glyphs from DataBase
# -*- coding: utf-8 -*-
from __future__ import division, print_function, unicode_literals
from bangla_glyph_names import glyph_names as name_dict
__doc__="""
Does what it says on the tin!
The script takes a dictionary of before/after glyph-names and renames glyphs if they're found in the font.
TODO:
- Update prefixes
- Update classes
- Update features
- [DONE] Update glyphOrder
"""
Glyphs.clearLog()

this_font = Glyphs.font

def renameGlyphs(font, data):
"""docstring for renameGlyphs"""
for names in data:
if names in font.glyphs:
font.glyphs[names].name = data[names]
else:
print("Glyph \'{}\' not found in source!".format(names))

def updateGlyphOrder(font, data):
if font.customParameters["glyphOrder"]:
for names in data.keys():
if names in font.customParameters["glyphOrder"]:
# print(font.glyphOrder().index(n))
glyph_index = font.customParameters["glyphOrder"].index(names)
font.customParameters["glyphOrder"][glyph_index] = data[names]

# update prefixes
#if len(this_font.featurePrefixes) > 1:
# # Do stuff
# print(this_font.featurePrefixes)
#else:
# pass

# update classes
#if len(this_font.classes) > 0:
# # Do stuff
# print(this_font.classes)
#else:
# pass

# update features


#if len(this_font.features) > 0:
# # Do stuff
# print(this_font.features[0].code)
#else:
# pass

this_font.disableUpdateInterface()
glyph_name_data = name_dict
renameGlyphs(this_font, glyph_name_data)
updateGlyphOrder(this_font, glyph_name_data)
this_font.enableUpdateInterface()
100 changes: 100 additions & 0 deletions scripts/_glyphsScripts/bangla_glyph_names.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# -*- coding: utf-8 -*-

glyph_names = {
"uni0980": "anji-beng",
"anusvarabeng": "anusvara-beng",
"visargabeng": "visarga-beng",
"abeng": "a-beng",
"aabeng": "aa-beng",
"ibeng": "i-beng",
"iibeng": "ii-beng",
"ubeng": "u-beng",
"uubeng": "uu-beng",
"rvocalicbeng": "rVocalic-beng",
"lvocalicbeng": "lVocalic-beng",
"ebeng": "e-beng",
"aibeng": "ai-beng",
"obeng": "o-beng",
"aubeng": "au-beng",
"kabeng": "ka-beng",
"khabeng": "kha-beng",
"gabeng": "ga-beng",
"ghabeng": "gha-beng",
"ngabeng": "nga-beng",
"cabeng": "ca-beng",
"chabeng": "cha-beng",
"jabeng": "ja-beng",
"jhabeng": "jha-beng",
"nyabeng": "nya-beng",
"ttabeng": "tta-beng",
"tthabeng": "ttha-beng",
"ddabeng": "dda-beng",
"ddhabeng": "ddha-beng",
"nnabeng": "nna-beng",
"tabeng": "ta-beng",
"thabeng": "tha-beng",
"dabeng": "da-beng",
"dhabeng": "dha-beng",
"nabeng": "na-beng",
"pabeng": "pa-beng",
"phabeng": "pha-beng",
"babeng": "ba-beng",
"bhabeng": "bha-beng",
"mabeng": "ma-beng",
"yabeng": "ya-beng",
"rabeng": "ra-beng",
"labeng": "la-beng",
"shabeng": "sha-beng",
"ssabeng": "ssa-beng",
"sabeng": "sa-beng",
"habeng": "ha-beng",
"nuktabeng": "nukta-beng",
"avagrahabeng": "avagraha-beng",
"aavowelsignbeng": "aaMatra-beng",
"ivowelsignbeng": "iMatra-beng",
"iivowelsignbeng": "iiMatra-beng",
"uvowelsignbeng": "uMatra-beng",
"uuvowelsignbeng": "uuMatra-beng",
"rvocalicvowelsignbeng": "rVocalicMatra-beng",
"rrvocalicvowelsignbeng": "rrVocalicMatra-beng",
"evowelsignbeng": "eMatra-beng",
"aivowelsignbeng": "aiMatra-beng",
"ovowelsignbeng": "oMatra-beng",
"auvowelsignbeng": "auMatra-beng",
"viramabeng": "halant-beng",
"khandatabeng": "taKhanda-beng",
"aulengthmarkbeng": "auLength-beng",
"rrabeng": "rra-beng",
"rhabeng": "rha-beng",
"yyabeng": "yya-beng",
"rrvocalicbeng": "rrVocalic-beng",
"llvocalicbeng": "llVocalic-beng",
"lvocalicvowelsignbeng": "lVocalicMatra-beng",
"llvocalicvowelsignbeng": "llVocalicMatra-beng",
"zerobeng": "zero-beng",
"onebeng": "one-beng",
"twobeng": "two-beng",
"threebeng": "three-beng",
"fourbeng": "four-beng",
"fivebeng": "five-beng",
"sixbeng": "six-beng",
"sevenbeng": "seven-beng",
"eightbeng": "eight-beng",
"ninebeng": "nine-beng",
"ra1beng": "ramiddlediagonal-beng",
"wabeng": "ralowerdiagonal-beng",
"rupeemarkbeng": "rupeeMark-beng",
"rupeesignbeng": "rupeeSign-beng",
"uni09F4": "oneNumr-beng",
"uni09F5": "twoNumr-beng",
"uni09F6": "threeNumr-beng",
"uni09F7": "fourNumr-beng",
"uni09F8": "oneLessNumr-beng",
"uni09F9": "sixteenDnom-beng",
"issharbeng": "isshar-beng",
"uni09FB": "ganda-beng",
"uni09FC": "vedicAnusvara-beng",
"uni09FD": "abbreviation-beng",
"uni09FE": "sandhi-beng"
}

0 comments on commit cdbe426

Please sign in to comment.