Skip to content

Commit

Permalink
Update code style
Browse files Browse the repository at this point in the history
  • Loading branch information
IdreesInc committed Jun 10, 2023
1 parent bd29dc0 commit ac2252b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 23 deletions.
6 changes: 3 additions & 3 deletions src/continuous_ligatures.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"head": "=>",
"body": "=",
"head_name": "Right fat arrow",
"head_name": "right thick arrow",
"body_name": "equals sign",
"direction": "right",
"min_length": 1,
Expand Down Expand Up @@ -30,7 +30,7 @@
{
"head": "<=",
"body": "=",
"head_name": "left fat arrow",
"head_name": "left thick arrow",
"body_name": "equals sign",
"direction": "left",
"min_length": 1,
Expand Down Expand Up @@ -58,7 +58,7 @@
{
"head": "->",
"body": "-",
"head_name": "Right arrow",
"head_name": "right arrow",
"body_name": "minus",
"direction": "right",
"min_length": 1,
Expand Down
38 changes: 19 additions & 19 deletions src/generate_continuous_ligatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,35 +41,35 @@ def generate_continuous_ligatures(filename):
- "sequence": a list of integers representing the Unicode code points of the characters in the progress bar
- "pixels": a list of integers representing the pixels of the progress bar
"""
data = json.load(open(filename))
continuous_ligatures = json.load(open(filename))
out = []
for d in data:
name = f'{d["head_name"]} {d["body_name"]} '
body_pixels = d["body_pixels"]
head_pixels = d["head_pixels"]
body = [[] for _ in range(len(body_pixels))] # copy.deepcopy(body_pixels)
for i in range( d["min_length"],d["max_length"] + 1):
o = {}
#generate ligature data
o["name"] = name + str(i);
if d["direction"] == "right":
o["ligature"] = d["body"] * i +d["head"]
for ligature in continuous_ligatures:
name = f'{ligature["head_name"]} {ligature["body_name"]} '
body_pixels = ligature["body_pixels"]
head_pixels = ligature["head_pixels"]
body = [[] for _ in range(len(body_pixels))]
for i in range( ligature["min_length"],ligature["max_length"] + 1):
glyph = {}
# Generate ligature data
glyph["name"] = name + str(i);
if ligature["direction"] == "right":
glyph["ligature"] = ligature["body"] * i + ligature["head"]
else:
o["ligature"] = d["head"] + d["body"] * i
o["sequence"] = [ord(c) for c in o["ligature"]]
#generate pixels
#expand the body by 1
glyph["ligature"] = ligature["head"] + ligature["body"] * i
glyph["sequence"] = [ord(c) for c in glyph["ligature"]]
# Generate pixels
# Expand the body by 1
for k in range(len(body)):
body[k] += body_pixels[k]
pixels = []
if d["direction"] == "right":
if ligature["direction"] == "right":
pixels = copy.deepcopy(body)
for j in range(len(pixels)):
pixels[j] += head_pixels[j]
else:
pixels = copy.deepcopy(head_pixels)
for j in range(len(pixels)):
pixels[j] += body[j]
o["pixels"] = pixels
out.append(o)
glyph["pixels"] = pixels
out.append(glyph)
return out
3 changes: 2 additions & 1 deletion src/monocraft.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@

characters = json.load(open("./characters.json"))
diacritics = json.load(open("./diacritics.json"))
ligatures = json.load(open("./ligatures.json")) + generate_continuous_ligatures("./continuous_ligatures.json")
ligatures = json.load(open("./ligatures.json"))
ligatures += generate_continuous_ligatures("./continuous_ligatures.json")

characters = generateDiacritics(characters, diacritics)
charactersByCodepoint = {}
Expand Down

0 comments on commit ac2252b

Please sign in to comment.