예제 #1
0
 def font_facecompare(self, Testfont, mockfont, glyphRange, \
 resolution, ptsize, pixeldepth, fonttype):
     spritepath = "/var/tmp/tmpn.bmp"
     if fonttype is "bold":
         spritepath = "/var/tmp/tmpb.bmp"
         for i in range (glyphRange[0],glyphRange[1]):
             if i in Testfont:
                 Testfont[i].changeWeight(50,"auto",0,0,"auto")
     if fonttype is "italic":
         Testfont.selection.all()
         Testfont = Testfont.italicize(-13)
         spritepath = "/var/tmp/tmpi.bmp"
     scores = list()
     comparator = BitmapCompare()
     pixelsize = (resolution*ptsize)/72
     print spritepath
     for i in range (glyphRange[0],glyphRange[1]):
         if i in Testfont:
             Testfont[i].export("/var/tmp/tmp.bmp",pixelsize,1)
             Testfont[i].export("tmp.bmp",pixelsize,1)
             glyphscore = comparator.basicCompare("/var/tmp/tmp.bmp",\
             spritepath,pixelsize,(i-glyphRange[0])*pixelsize)
             glyphscore*=100
         else:
             glyphscore=0
         scores.append((i,round(glyphscore)))
     Testfont.close()
     return scores
예제 #2
0
 def font_facecompare(self, Testfont, mockfont, glyphRange, \
 resolution, ptsize, pixeldepth, fonttype):
     spritepath = "/var/tmp/tmpn.bmp"
     if fonttype is "bold":
         spritepath = "/var/tmp/tmpb.bmp"
         for i in range (glyphRange[0],glyphRange[1]):
             if i in Testfont:
                 Testfont[i].changeWeight(50,"auto",0,0,"auto")
     if fonttype is "italic":
         Testfont.selection.all()
         Testfont = Testfont.italicize(-13)
         spritepath = "/var/tmp/tmpi.bmp"
     scores = list()
     comparator = BitmapCompare()
     pixelsize = (resolution*ptsize)/72
     print spritepath
     for i in range (glyphRange[0],glyphRange[1]):
         if i in Testfont:
             Testfont[i].export("/var/tmp/tmp.bmp",pixelsize,1)
             Testfont[i].export("tmp.bmp",pixelsize,1)
             glyphscore = comparator.basicCompare("/var/tmp/tmp.bmp",\
             spritepath,pixelsize,(i-glyphRange[0])*pixelsize)
             glyphscore*=100
         else:
             glyphscore=0
         scores.append((i,round(glyphscore)))
     Testfont.close()
     return scores
예제 #3
0
 def basicCompare(self,testpath, mockfont, fontsize):
     docpath = pkg_resources.resource_filename("fc","docs/doc.txt")
     bashcommand = "hb-view --output-format=\"png\" --output-file=\"/var/tmp/test.png\" --font-size="+str(fontsize)+" --text-file=\""
     bashcommand+=docpath+"\" "+"\""+testpath+"\""
     os.system(str(bashcommand))
     print bashcommand
     thefile = pkg_resources.resource_filename("fc",mockfont.highresdocfile)
     shutil.copy(thefile,"/var/tmp/standard.png")
     cm = BitmapCompare()
     score = cm.basicCompare("/var/tmp/test.png",\
     "/var/tmp/standard.png",1000,0,True)
예제 #4
0
 def basicCompare(self, testpath, mockfont, fontsize):
     docpath = pkg_resources.resource_filename("fc", "docs/doc.txt")
     bashcommand = "hb-view --output-format=\"png\" --output-file=\"/var/tmp/test.png\" --font-size=" + str(
         fontsize) + " --text-file=\""
     bashcommand += docpath + "\" " + "\"" + testpath + "\""
     os.system(str(bashcommand))
     print bashcommand
     thefile = pkg_resources.resource_filename("fc",
                                               mockfont.highresdocfile)
     shutil.copy(thefile, "/var/tmp/standard.png")
     cm = BitmapCompare()
     score = cm.basicCompare("/var/tmp/test.png",\
     "/var/tmp/standard.png",1000,0,True)
예제 #5
0
 def basicCompare(self,testpath, standardpath, docpath, fontsize):
     bashcommand = "hb-view --output-format=\"png\" --output-file=\"/var/tmp/test.png\" --font-size="+str(fontsize)+" --text-file=\""
     bashcommand+=docpath+"\" "+"\""+testpath+"\""
     print bashcommand
     os.system(str(bashcommand))
     
     bashcommand = "hb-view --output-format=\"png\" --output-file=\"/var/tmp/standard.png\" --font-size="+str(fontsize)+" --text-file=\""
     bashcommand+=docpath+"\" "+"\""+testpath+"\""
     print bashcommand
     os.system(str(bashcommand))
     cm = BitmapCompare()
     score = cm.basicCompare("/var/tmp/test.png",\
     "/var/tmp/standard.png")
     return score
예제 #6
0
from fc.BitmapHandler import BitmapCompare

bitcomp = BitmapCompare()


class GlyphConsistency:
    #computes the number of selfIntersects in the glyph is any across
    #all layers, it is a self consistency check
    def glyph_basicConsistency(self, font, glyphrange):
        scores = list()
        total = 0
        for i in range(glyphrange[0], glyphrange[1]):
            #worth outputting
            try:
                t = font[i]
                if i in font:
                    if font[i].isWorthOutputting():
                        scoreFactor = 1
                    else:
                        scoreFactor = 0
                    score = 10
                    if font[i].layers[1].selfIntersects():
                        score = 0
                    else:
                        score = score * scoreFactor
            except:
                score = 0
            #no counter intersection
            total += score
            scores.append((i, score))
        #scores.append(("Basic Consistency Score: ",total/len(scores)))