summaryrefslogtreecommitdiff
path: root/scripts/lib/fontbuild/markFeature.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/fontbuild/markFeature.py')
-rwxr-xr-xscripts/lib/fontbuild/markFeature.py49
1 files changed, 27 insertions, 22 deletions
diff --git a/scripts/lib/fontbuild/markFeature.py b/scripts/lib/fontbuild/markFeature.py
index b4a8061..b617ef6 100755
--- a/scripts/lib/fontbuild/markFeature.py
+++ b/scripts/lib/fontbuild/markFeature.py
@@ -1,4 +1,20 @@
-from FL import *
+# Copyright 2015 Google Inc. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+from fontbuild.features import updateFeature
+
aliases = [["uni0430", "a"], ["uni0435", "e"], ["uni0440", "p"], ["uni0441", "c"], ["uni0445", "x"], ["uni0455", "s"], ["uni0456", "i"], ["uni0471", "psi"]]
@@ -11,9 +27,9 @@ def GetAliaseName(gname):
def CreateAccNameList(font, acc_anchor_name, bCombAccentOnly = True):
#combrange = range(0x0300,0x0370) + range(0x1AB0,0x1ABF) + range(0x1DC0,0x1DE0)
lst = []
- for g in font.glyphs:
+ for g in font:
if bCombAccentOnly and g.width != 0: #((g.unicode < 0x0300) or (g.unicode > 0x362)):
- continue
+ continue
for anchor in g.anchors:
if acc_anchor_name == anchor.name:
lst.append(g.name)
@@ -21,7 +37,7 @@ def CreateAccNameList(font, acc_anchor_name, bCombAccentOnly = True):
def CreateAccGlyphList(font, acc_list, acc_anchor_name):
g_list = []
- for g in font.glyphs:
+ for g in font:
if g.name in acc_list:
for anchor in g.anchors:
if acc_anchor_name == anchor.name:
@@ -32,29 +48,28 @@ def CreateAccGlyphList(font, acc_list, acc_anchor_name):
def CreateGlyphList(font, acc_list, anchor_name):
g_list = []
- for g in font.glyphs:
+ for g in font:
if g.name in acc_list:
continue
for anchor in g.anchors:
if anchor_name == anchor.name:
g_list.append([g.name, anchor.x, anchor.y])
- break
+ break
return g_list
def Create_mark_lookup(accent_g_list, base_g_list, lookupname, acc_class, lookAliases = True):
txt = "lookup " + lookupname + " {\n"
for acc in accent_g_list:
- txt += " markClass " + acc[0] + " <anchor " + `acc[1]` + " " + `acc[2]` + "> " + acc_class +";\n"
-
+ txt += " markClass " + acc[0] + " <anchor " + `int(acc[1])` + " " + `int(acc[2])` + "> " + acc_class +";\n"
for base in base_g_list:
- txt += " pos base " + base[0] + " <anchor " + `base[1]` + " " + `base[2]` + "> mark " + acc_class + ";\n"
+ txt += " pos base " + base[0] + " <anchor " + `int(base[1])` + " " + `int(base[2])` + "> mark " + acc_class + ";\n"
if (lookAliases):
base2 = GetAliaseName(base[0])
if (None == base2):
continue
- txt += " pos base " + base2 + " <anchor " + `base[1]` + " " + `base[2]` + "> mark " + acc_class + ";\n"
+ txt += " pos base " + base2 + " <anchor " + `int(base[1])` + " " + `int(base[2])` + "> mark " + acc_class + ";\n"
txt += "} " + lookupname + ";\n"
@@ -77,7 +92,7 @@ def GenerateFeature_mark(font):
]
text = "feature mark {\n"
-
+
for n in range(len(combination_anchor_list)):
accent_name_list = []
@@ -98,15 +113,5 @@ def GenerateFeature_mark(font):
text += Create_mark_lookup(accent_mark_list, base_mark_list, lookupname, classname, expand_to_composits)
text += "} mark;\n"
- mark = Feature("mark", text)
-
- not_exist = True
- for n in range(len(font.features)):
- if ('mark' == font.features[n].tag):
- font.features[n] = mark
- not_exist = False
-
- if (not_exist):
- font.features.append(mark)
-
+ updateFeature(font, "mark", text)