Skip to content

Commit

Permalink
Modifying code to work when files are not provided
Browse files Browse the repository at this point in the history
  • Loading branch information
nandajavarma committed Sep 22, 2013
1 parent ffbfd4a commit 1b9f8e4
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 36 deletions.
@@ -1,7 +1,7 @@
[main]
Reference-file: lohit-devanagari-glyph.txt
Rendered-output: hb_lohit_devanagari_output.txt
#Font-file:
#Test-cases-file: ../devanagari-test-cases.txt
#Output-file: index.html
#Shaping-engine: Harfbuzz
Font-file: /usr/share/fonts/truetype/lohit-devanagari/Lohit-Devanagari.ttf
Test-cases-file: ../devanagari_test_cases.txt
Output-file: index.html
Shaping-engine: harfbuzz
@@ -1,4 +1,4 @@
[u0915]
[0915]
[u0958]
[u093F,u0915]
[u0915,u094D]
Expand Down
63 changes: 32 additions & 31 deletions rendering_test.py
Expand Up @@ -39,8 +39,9 @@ def ConfigSectionMap(option):
output_file = ConfigSectionMap('output-file')
engine = ConfigSectionMap('shaping-engine')
hbflag = 0
if engine.lower() == 'harfbuzz':
hbflag = 1
if engine:
if engine.lower() == 'harfbuzz':
hbflag = 1
outflag = 0
if output_file:
if output_file.endswith('.html'):
Expand All @@ -61,38 +62,38 @@ def ConfigSectionMap(option):
print "Provide an html file as output file." + \
"Cannot generate the result. Exiting.."
sys.exit()
# Assuming the engine would be harfbuzz if a directory name is provided
dirname = 'hb_images'
diflag = 0
if hbflag and outflag:
if font_file:
if font_file.endswith('.ttf'):
diflag = 1
font_fp = open_file(font_file, "r")
if os.path.isdir(dirname):
cmd0 = 'rm -rf ' + dirname
os.system(cmd0)
cmd1 = 'mkdir ' + dirname
os.system(cmd1)
i = 0
print "\nProcessing...."
while wordlist[i] != "":
cmd2 = 'hb-view ' + font_file + ' ' + \
wordlist[i] + ' > ' + dirname + \
'/' + '%d' % (i + 1) + '.png'
os.system(cmd2)
i = i + 1
font_fp.close()
else:
print "Provide a font file with .ttf extension." + \
"Cannot create harfbuzz rendered images.\n"
else:
print "No font file provided!" + \
"Cannot create harfbuzz rendered images.\n"
if outflag:
if test_cases:
#creating images if the engine is harfbuzz
dirname = 'hb_images'
diflag = 0
if hbflag:
if font_file:
if font_file.endswith('.ttf'):
diflag = 1
font_fp = open_file(font_file, "r")
if os.path.isdir(dirname):
cmd0 = 'rm -rf ' + dirname
os.system(cmd0)
cmd1 = 'mkdir ' + dirname
os.system(cmd1)
i = 0
print "\nProcessing...."
while wordlist[i] != "":
cmd2 = 'hb-view ' + font_file + ' ' + \
wordlist[i] + ' > ' + dirname + \
'/' + '%d' % (i + 1) + '.png'
os.system(cmd2)
i = i + 1
font_fp.close()
else:
print "Provide a font file with .ttf extension." + \
"Cannot create harfbuzz rendered images.\n"
else:
print "No font file provided!" + \
"Cannot create harfbuzz rendered images.\n"
print "\nOpen the file '" + output_file + \
"' in a browser to see the result\n"
"' in a browser to see the result\n"
# calling function to generate the results file
testing_modules.get_result(a, wordlist, output_fp, diflag, dirname)
output_fp.close()
Expand Down

0 comments on commit 1b9f8e4

Please sign in to comment.