Skip to content

Commit

Permalink
made leo
Browse files Browse the repository at this point in the history
  • Loading branch information
natsag2000 committed Dec 13, 2010
1 parent c0ca4fd commit ed4e910
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 14 deletions.
53 changes: 41 additions & 12 deletions fontcreator/crazyfonter.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
#!/usr/bin/env python
# -- coding: utf-8 --
#@+leo-ver=5-thin
#@+node:nagi.20101207083602.1317: * @file /home/nagi/nagi-gits/mongolbichig/fontcreator/crazyfonter.py
#@@first
#@@first
#@@language python
#@@tabwidth -4
#@+others
#@+node:nagi.20101207083602.1328: ** толгой хэсэг
# ----------------------------------------------------------------
# __ __ ___ _ _ ____ ___ _ _ _ ____ _____ ____
# | \/ |/ _ \| \ | |/ ___|/ _ \| | | | | / ___|| ____/ ___|
# | |\/| | | | | \| | | _| | | | | | | | \___ \| _|| | _
# | | | | |_| | |\ | |_| | |_| | |___ | |_| |___) | |__| |_| |
# |_| |_|\___/|_| \_|\____|\___/|_____| \___/|____/|_____\____|
#
# crazy font creator
# Author: nagi (natsag2000@googlemail.com)
# mongol otf font creator
# отф тиг үүсгэгч
#
# Author: nagi (natsag2000@googlemail.com)
# ----------------------------------------------------------------
#@+node:nagi.20101207083602.1318: ** imports and globals

#@+<<imports>>
#@+node:nagi.20101207083602.1329: *3* <<imports>>
import fontforge
import ConfigParser
import os
import psMat
from math import pi
#@-<<imports>>

# GLOBALS
MONGOL_USEG = ''
Expand All @@ -33,6 +49,7 @@
# private usage zone
PRIVATE_ZONE =hex(0xf300)

#@+node:nagi.20101207083602.1319: ** main үндсэн гол дуудагдах функц
def main():
global MONGOL_USEG
global MONGOL_USEG_EXT
Expand All @@ -45,16 +62,7 @@ def main():
replace_feature()
generate_font("crazyfont.ttf")

def prepare_font():
global BASE_FONT
global TMP_FONT
global FONT
fontbase = fontforge.open(BASE_FONT)
# Delta char has conflict by otf generation, so delete it
fontbase["Delta"].clear()
fontbase.generate(TMP_FONT)
FONT = fontforge.open(TMP_FONT)

#@+node:nagi.20101207083602.1321: ** read_config
def read_config():
global MONGOL_USEG
global MONGOL_USEG_EXT
Expand Down Expand Up @@ -82,14 +90,29 @@ def read_config():
VERSION = config.get('General', 'VERSION')


#@+node:nagi.20101207083602.1320: ** prepare_font
def prepare_font():
global BASE_FONT
global TMP_FONT
global FONT
fontbase = fontforge.open(BASE_FONT)
# Delta char has conflict by otf generation, so delete it
fontbase["Delta"].clear()
fontbase.generate(TMP_FONT)
FONT = fontforge.open(TMP_FONT)

#@+node:nagi.20101207083602.1322: ** read_lines
def read_lines(FileName):
f = file(FileName, 'r')
lines = f.readlines()
f.close()
return lines

#@+node:nagi.20101207083602.1323: ** create_standart_zone
#@+at
# first unicode standart zone
# TODO check special cases: maaglha, dottedcircle etc!!
#@@c
def create_standart_zone(Usegs):
global GLYPHS_DIR
global FONT
Expand All @@ -109,6 +132,7 @@ def create_standart_zone(Usegs):
FONT[letter].left_side_bearing = 15
FONT[letter].right_side_bearing = 15

#@+node:nagi.20101207083602.1324: ** create_private_zone
def create_private_zone(Usegs):
global PRIVATE_ZONE
global GLYPHS_DIR
Expand All @@ -128,6 +152,7 @@ def create_private_zone(Usegs):
FONT[letter].right_side_bearing = -15
deccounter = deccounter + 1

#@+node:nagi.20101207083602.1325: ** replace_feature
# replace feature
def replace_feature(Fea = None):
global FONT
Expand All @@ -144,6 +169,7 @@ def replace_feature(Fea = None):
else:
FONT.mergeFeature(Feature)

#@+node:nagi.20101207083602.1326: ** generate_font
def generate_font(FontFileName):
global FONTNAME
global FAMILYNAME
Expand All @@ -156,9 +182,12 @@ def generate_font(FontFileName):
FONT.fontname = FONTNAME
FONT.generate(FontFileName)

#@+node:nagi.20101207083602.1327: ** rotate_glyph
def rotate_glyph(Glyph):
matrix = psMat.rotate(pi/2)
Glyph.transform(matrix)

#@-others
if __name__ == '__main__':
main()
#@-leo
35 changes: 33 additions & 2 deletions fontcreator/mongoluseg.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,40 @@
#!/usr/bin/env python
# -- coding: utf-8 --
#@+leo-ver=5-thin
#@+node:nagi.20101207083602.1297: * @file /home/nagi/nagi-gits/mongolbichig/fontcreator/mongoluseg.py
#@@first
#@@first
#@@language python
#@@tabwidth -4
#@+others
#@+node:nagi.20101207083602.1309: ** толгой хэсэг
# ----------------------------------------------------------------
# __ __ ___ _ _ ____ ___ _ _ _ ____ _____ ____
# | \/ |/ _ \| \ | |/ ___|/ _ \| | | | | / ___|| ____/ ___|
# | |\/| | | | | \| | | _| | | | | | | | \___ \| _|| | _
# | | | | |_| | |\ | |_| | |_| | |___ | |_| |___) | |__| |_| |
# |_| |_|\___/|_| \_|\____|\___/|_____| \___/|____/|_____\____|
#
# crazy useg creator
# Author: nagi (natsag2000@googlemail.com)
# үсэг үүсгэгч
#
# Author: nagi (natsag2000@googlemail.com)
# ----------------------------------------------------------------
#@+node:nagi.20101207083602.1298: ** import хэсэг
import ConfigParser
import subprocess
import re
import os

#@+node:nagi.20101207083602.1299: ** main гол дуудагдах функц
def main():
# read config file
config = ConfigParser.RawConfigParser()
config.read("config.cfg")
# TODO: check if they exist!
#@+<<TODO тохиргооны оруулгууд зөв эсэхийг шалгах>>
#@+node:nagi.20101207083602.1313: *3* <<TODO тохиргооны оруулгууд зөв эсэхийг шалгах>>
# TODO: Тохиргооны оруулгууд зөв үү гэдгийг шалга!
#@-<<TODO тохиргооны оруулгууд зөв эсэхийг шалгах>>
USEG_ATOM = config.get('Mongol useg', 'USEG_ATOM')
USEG_DESC = config.get('Mongol useg', 'USEG_DESC')
ATOM_FOLDER=config.get('Mongol useg', 'ATOM_FOLDER')
Expand All @@ -31,6 +48,7 @@ def main():
descs = read_desc(usegdesc)
useg_uusge(atoms, descs, ATOM_FOLDER, GLYPH_OUT)

#@+node:nagi.20101207083602.1300: ** useg_uusge
def useg_uusge(Atoms, Desc, AFolder, OFolder):
atomkeys = Atoms.keys()
Missed = {}
Expand Down Expand Up @@ -75,23 +93,30 @@ def useg_uusge(Atoms, Desc, AFolder, OFolder):
for Key in Missed.keys():
print Key, ' : ', Missed[Key]

#@+node:nagi.20101207083602.1301: ** createByCopy
#@+at
# зөвхөн сангаас сангийн хооронд хуулна
#@@c
def createByCopy(AFolder, OFolder, NameA, NameB):
AFile = AFolder + '/' + NameA
BFile = OFolder + '/' + NameB
copyGlyph(AFile, BFile)

#@+node:nagi.20101207083602.1302: ** copyGlyph
def copyGlyph(A, B):
Cmd = 'cp ' + A + ' ' + B
if not subprocess.call(Cmd, shell=True) == 0:
print "Not Created: " + Cmd
else:
print B, " is copied succesfully!"

#@+node:nagi.20101207083602.1303: ** isNumber
def isNumber(Str):
if Str.startswith("-") or Str.startswith("+"):
return Str[1:].isdigit()
return Str.isdigit()

#@+node:nagi.20101207083602.1304: ** read_atoms
def read_atoms(List):
dic = dict()
for L in List:
Expand All @@ -108,6 +133,7 @@ def read_atoms(List):
dic[L1] = L1
return dic

#@+node:nagi.20101207083602.1305: ** read_desc
def read_desc(List):
dic = dict()
for L in List:
Expand All @@ -122,18 +148,23 @@ def read_desc(List):
dic[L2[0]] = L2[1]
return dic

#@+node:nagi.20101207083602.1306: ** splitAndStrip
def splitAndStrip(Line, Pattern):
return [ X.strip() for X in Line.split(Pattern) if X != '']

#@+node:nagi.20101207083602.1307: ** isEmptyOrComment
def isEmptyOrComment(Line):
if Line.startswith('#') or len(Line) == 0:
return True

#@+node:nagi.20101207083602.1308: ** readlines
def readlines(FileName):
f = file(FileName, 'r')
lines = f.readlines()
f.close()
return lines

#@-others
if __name__=='__main__':
main()
#@-leo

0 comments on commit ed4e910

Please sign in to comment.