Skip to content

Commit

Permalink
Do away with kerning ayah numbers
Browse files Browse the repository at this point in the history
Shift the number glyphs instead.
  • Loading branch information
khaledhosny committed Jan 4, 2024
1 parent b23e92b commit e8044d9
Show file tree
Hide file tree
Showing 35 changed files with 461 additions and 175 deletions.
Binary file modified docs/assets/fonts/Raqq.woff2
Binary file not shown.
Binary file modified fonts/Raqq.ttf
Binary file not shown.
Binary file modified fonts/Raqq.woff2
Binary file not shown.
58 changes: 10 additions & 48 deletions scripts/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,6 @@ def getAnchorPos(font, glyph, default, name):
return f"({' '.join(x)})", f"({' '.join(y)})"


AYAH_ANCHORS = {"ayah"}


def makeMark(font, glyphOrder):
classes = ""
mark2base = {}
Expand All @@ -177,13 +174,13 @@ def makeMark(font, glyphOrder):
layer = glyph.layers[0]
for anchor in layer.anchors:
name = anchor.name
if name in AYAH_ANCHORS:
continue
x, y = getAnchorPos(font, glyph, layer, name)
if name.startswith("_"):
classes += f"markClass {gname} <anchor {x} {y}> @mark_{name[1:]};\n"
elif not name[0].isalpha():
continue
elif name.startswith("caret_") or name in ("exit", "entry"):
pass
continue
elif "_" in name:
name, index = name.split("_")
ligatures[gname][int(index)].append((name, (x, y)))
Expand All @@ -202,8 +199,6 @@ def makeMark(font, glyphOrder):
mark2liga += f" <anchor {x} {y}> mark @mark_{anchor}"
mark2liga += ";\n"

ayah = makeAyah(font, glyphOrder)

base = ""
for name, code in mark2base.items():
base += f"""
Expand All @@ -214,7 +209,6 @@ def makeMark(font, glyphOrder):
"""

return f"""
{ayah}
{classes}
{base}
lookup mark2liga_auto {{
Expand All @@ -224,45 +218,6 @@ def makeMark(font, glyphOrder):
"""


def makeAyah(font, glyphOrder):
bases = []
marks = {}
for gname in glyphOrder:
glyph = font.glyphs[gname]
if glyph is None:
continue

layer = glyph.layers[0]
for anchor in layer.anchors:
if anchor.name in AYAH_ANCHORS:
x = layer.width - anchor.position.x
y = anchor.position.y
bases.append((gname, (x, y)))
break
if anchor.name.startswith("_") and anchor.name[1:] in AYAH_ANCHORS:
x = anchor.position.x
y = anchor.position.y
marks.setdefault((x, y), []).append(gname)
break

ayah = ""
for base, (bx, by) in bases:
for mx, my in marks:
names = " ".join(marks[(mx, my)])
x = bx + mx
y = by - my
ayah += f"pos {base} <NULL> [{names}] <{-x} {y} 0 0>;\n"

if ayah:
return f"""
lookup ayah_auto {{
lookupflag 0;
{ayah}
}} ayah_auto;
"""
return ""


def makeCurs(font, glyphOrder):
fea = ""

Expand Down Expand Up @@ -812,6 +767,13 @@ def prepare(args):
elif (glyph.category, glyph.subCategory) == ("Mark", "Nonspacing"):
# Zero mark width
layer.width = 0
if origin := layer.anchors["*origin"]:
for path in layer.paths:
path.applyTransform([1, 0, 0, 1, -origin.position.x, 0])
for component in layer.components:
x = component.position.x - origin.position.x
y = component.position.y
component.position = (x, y)
propagateAnchors(glyph, layer)
removeOverlap(font, glyph, layer)

Expand Down
16 changes: 14 additions & 2 deletions sources/Raqq.glyphspackage/glyphs/ayah.005.glyph
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ layers = (
{
anchors = (
{
name = _ayah;
pos = (556,183);
name = "*origin";
pos = (1117,0);
}
);
backgroundImage = {
Expand All @@ -29,6 +29,12 @@ ref = _ayah.decoration1;
width = 1117;
},
{
anchors = (
{
name = "*origin";
pos = (1117,0);
}
);
associatedMasterId = m01;
attr = {
colorPalette = 4;
Expand All @@ -48,6 +54,12 @@ ref = _ayah.decoration1.1;
width = 1117;
},
{
anchors = (
{
name = "*origin";
pos = (1117,0);
}
);
associatedMasterId = m01;
attr = {
colorPalette = 1;
Expand Down
16 changes: 14 additions & 2 deletions sources/Raqq.glyphspackage/glyphs/ayah.010.glyph
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ layers = (
{
anchors = (
{
name = _ayah;
pos = (556,183);
name = "*origin";
pos = (1117,0);
}
);
layerId = m01;
Expand All @@ -23,6 +23,12 @@ ref = _ayah.decoration1;
width = 1117;
},
{
anchors = (
{
name = "*origin";
pos = (1117,0);
}
);
associatedMasterId = m01;
attr = {
colorPalette = 4;
Expand All @@ -43,6 +49,12 @@ ref = _ayah.decoration1.1;
width = 1117;
},
{
anchors = (
{
name = "*origin";
pos = (1117,0);
}
);
associatedMasterId = m01;
attr = {
colorPalette = 1;
Expand Down
16 changes: 14 additions & 2 deletions sources/Raqq.glyphspackage/glyphs/ayah.020.glyph
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ layers = (
{
anchors = (
{
name = _ayah;
pos = (556,183);
name = "*origin";
pos = (1117,0);
}
);
layerId = m01;
Expand All @@ -29,6 +29,12 @@ ref = _ayah.noon;
width = 1117;
},
{
anchors = (
{
name = "*origin";
pos = (1117,0);
}
);
associatedMasterId = m01;
attr = {
colorPalette = 4;
Expand All @@ -55,6 +61,12 @@ ref = _ayah.noon.1;
width = 1117;
},
{
anchors = (
{
name = "*origin";
pos = (1117,0);
}
);
associatedMasterId = m01;
attr = {
colorPalette = 1;
Expand Down
16 changes: 14 additions & 2 deletions sources/Raqq.glyphspackage/glyphs/ayah.030.glyph
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ layers = (
{
anchors = (
{
name = _ayah;
pos = (556,183);
name = "*origin";
pos = (1117,0);
}
);
layerId = m01;
Expand All @@ -24,6 +24,12 @@ ref = _ayah.noon;
width = 1117;
},
{
anchors = (
{
name = "*origin";
pos = (1117,0);
}
);
associatedMasterId = m01;
attr = {
colorPalette = 4;
Expand All @@ -45,6 +51,12 @@ ref = _ayah.noon.1;
width = 1117;
},
{
anchors = (
{
name = "*origin";
pos = (1117,0);
}
);
associatedMasterId = m01;
attr = {
colorPalette = 1;
Expand Down
14 changes: 10 additions & 4 deletions sources/Raqq.glyphspackage/glyphs/ayah.040.glyph
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ layers = (
{
anchors = (
{
name = _ayah;
pos = (556,183);
name = "*origin";
pos = (1117,0);
}
);
layerId = m01;
Expand Down Expand Up @@ -37,6 +37,12 @@ scale = (0.7,0.8);
width = 1117;
},
{
anchors = (
{
name = "*origin";
pos = (1117,0);
}
);
associatedMasterId = m01;
attr = {
colorPalette = 4;
Expand Down Expand Up @@ -73,8 +79,8 @@ width = 1117;
{
anchors = (
{
name = _ayah;
pos = (556,183);
name = "*origin";
pos = (1117,0);
}
);
associatedMasterId = m01;
Expand Down
16 changes: 14 additions & 2 deletions sources/Raqq.glyphspackage/glyphs/ayah.050.glyph
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ layers = (
{
anchors = (
{
name = _ayah;
pos = (556,183);
name = "*origin";
pos = (1117,0);
}
);
layerId = m01;
Expand All @@ -25,6 +25,12 @@ ref = _ayah.noon;
width = 1117;
},
{
anchors = (
{
name = "*origin";
pos = (1117,0);
}
);
associatedMasterId = m01;
attr = {
colorPalette = 4;
Expand All @@ -48,6 +54,12 @@ visible = 1;
width = 1117;
},
{
anchors = (
{
name = "*origin";
pos = (1117,0);
}
);
associatedMasterId = m01;
attr = {
colorPalette = 1;
Expand Down
16 changes: 14 additions & 2 deletions sources/Raqq.glyphspackage/glyphs/ayah.060.glyph
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ layers = (
{
anchors = (
{
name = _ayah;
pos = (556,183);
name = "*origin";
pos = (1117,0);
}
);
layerId = m01;
Expand All @@ -24,6 +24,12 @@ ref = _ayah.noon;
width = 1117;
},
{
anchors = (
{
name = "*origin";
pos = (1117,0);
}
);
associatedMasterId = m01;
attr = {
colorPalette = 4;
Expand All @@ -46,6 +52,12 @@ visible = 1;
width = 1117;
},
{
anchors = (
{
name = "*origin";
pos = (1117,0);
}
);
associatedMasterId = m01;
attr = {
colorPalette = 1;
Expand Down
16 changes: 14 additions & 2 deletions sources/Raqq.glyphspackage/glyphs/ayah.070.glyph
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ layers = (
{
anchors = (
{
name = _ayah;
pos = (556,183);
name = "*origin";
pos = (1117,0);
}
);
layerId = m01;
Expand All @@ -24,6 +24,12 @@ ref = _ayah.noon;
width = 1117;
},
{
anchors = (
{
name = "*origin";
pos = (1117,0);
}
);
associatedMasterId = m01;
attr = {
colorPalette = 4;
Expand All @@ -45,6 +51,12 @@ ref = _ayah.noon.1;
width = 1117;
},
{
anchors = (
{
name = "*origin";
pos = (1117,0);
}
);
associatedMasterId = m01;
attr = {
colorPalette = 1;
Expand Down
Loading

0 comments on commit e8044d9

Please sign in to comment.