예제 #1
0
 def checkFont(self, useSelection=False, excludeZeroWidth=True):
     f = CurrentFont()
     if f is not None:
         # initialize things
         self.w.options.progress.start()
         time0 = time.time()
         self.excludeZeroWidth = excludeZeroWidth
         self.f = f
 
         glyphNames = f.selection if useSelection else f.keys()
         glyphList = [f[x] for x in glyphNames]
         glyphList = self._trimGlyphList(glyphList)
         
         self.touchingPairs = Touche(f).findTouchingPairs(glyphList)
     
         # display output
         self.w.results.stats.set("%d glyphs checked" % len(glyphList))
         self.w.results.result.set("%d touching pairs found" % len(self.touchingPairs))
         self.w.results.show(True)
         
         outputList = [{"left glyph": g1, "right glyph": g2} for (g1, g2) in self.touchingPairs]
         self.w.outputList.set(outputList)
         if len(self.touchingPairs) > 0:
             self.w.outputList.setSelection([0])
         
         #self.w.preview.setFont(f)
         self.w.options.progress.stop()
         self._resizeWindow(enlarge=True)
     
         time1 = time.time()
         print u'Touché: finished checking %d glyphs in %.2f seconds' % (len(glyphList), time1-time0)
         
     else:
         Message(u'Touché: Can’t find a font to check')
예제 #2
0
    def checkFont(self, useSelection=False, excludeZeroWidth=True):
        f = CurrentFont()
        if f is not None:
            # initialize things
            self.w.options.progress.start()
            time0 = time.time()
            self.excludeZeroWidth = excludeZeroWidth
            self.f = f
    
            glyphNames = f.selection if useSelection else f.keys()
            glyphList = [f[x] for x in glyphNames]
            glyphList = self._trimGlyphList(glyphList)
            
            self.touchingPairs = Touche(f).findTouchingPairs(glyphList)
        
            # display output
            self.w.results.stats.set("%d glyphs checked" % len(glyphList))
            self.w.results.result.set("%d touching pairs found" % len(self.touchingPairs))
            self.w.results.show(True)
            
            outputList = [{"left glyph": g1, "right glyph": g2} for (g1, g2) in self.touchingPairs]

            outputStringList = [ "/%s/%s  " % (g1, g2) for (g1, g2) in self.touchingPairs ]
            outputStringMetalist = [outputStringList[i:i + 400] for i in range(0, len(outputStringList), 400)]

            ActiveFont = self.f._font
            ActiveFont.disableUpdateInterface()
            for eachList in outputStringMetalist:
                outputString = "".join(eachList)
                ActiveFont.newTab(outputString)

            self.w.outputList.set(outputList)
            if len(self.touchingPairs) > 0:
                self.w.outputList.setSelection([0])
            ActiveFont.enableUpdateInterface()
            
            #self.w.preview.setFont(f)
            self.w.options.progress.stop()
            self._resizeWindow(enlarge=True)
        
            time1 = time.time()
            print u'Touché: finished checking %d glyphs in %.2f seconds' % (len(glyphList), time1-time0)
            
        else:
            Message(u'Touché: Can’t find a font to check')
예제 #3
0
    def checkFont(self, useSelection=False, excludeZeroWidth=True):
        f = CurrentFont()
        if f is not None:
            # initialize things
            self.w.options.progress.start()
            time0 = time.time()
            self.excludeZeroWidth = excludeZeroWidth
            self.f = f

            glyphNames = f.selection if useSelection else f.keys()
            glyphList = [f[x] for x in glyphNames]
            glyphList = self._trimGlyphList(glyphList)

            self.touchingPairs = Touche(f).findTouchingPairs(glyphList)

            # display output
            self.w.results.stats.set("%d glyphs checked" % len(glyphList))
            self.w.results.result.set("%d touching pairs found" %
                                      len(self.touchingPairs))
            self.w.results.show(True)

            outputList = [{
                "left glyph": g1,
                "right glyph": g2
            } for (g1, g2) in self.touchingPairs]
            self.w.outputList.set(outputList)
            if len(self.touchingPairs) > 0:
                self.w.outputList.setSelection([0])

            #self.w.preview.setFont(f)
            self.w.options.progress.stop()
            self._resizeWindow(enlarge=True)

            time1 = time.time()
            print('Touché: finished checking %d glyphs in %.2f seconds' %
                  (len(glyphList), time1 - time0))

        else:
            Message('Touché: Can’t find a font to check')
 def wrapGlyphs(self):
     glyphs = []
     f = CurrentFont()
     if f is None:
         return
     names = f.keys()
     names.sort()
     # layers = f.layerOrder
     # if 'bounds' in layers:
     #     hasBounds = "yup"
     # else:
     hasBounds = "nope"
     for n in names:
         if n in self.masterNames:
             status = True
         else:
             continue
         g = f[n]
         gb = g.getLayer('bounds')
         if gb:
             xMin, yMin, xMax, yMax = gb.box
             width = xMax-xMin
             height = yMax-yMin
         else:
             width = g.width
             height = None
         contours, points = self.countGlyph(g)
         d = dict(name=g.name,
                 width=width,
                 height=height,
                 bounds=hasBounds,
                 status=status,
                 contours=contours,
                 points=points,
                 )
         glyphs.append(d)
     return glyphs
예제 #5
0
# or Glyph object respectively. It will be the
# front most font or the front most glyph.
from robofab.world import CurrentFont, CurrentGlyph

# This is a brief intro into Robofabs all singing and
# dancing dialog class. It will produce simple
# dialogs in almost any environment, FontLab, Python IDE, W.
from robofab.interface.all.dialogs import Message

# (make sure you have a font opened in FontLab)

f = CurrentFont()
# so now f is the name of a font object for the current font.

if f == None:
    # let's see what dialog can do, a warning
    Message("You should open a font first, there's nothing to look at now!")
else:
    # and another dialog.
    Message("The current font is %s" % (f.info.postscriptFullName))

    # let's have a look at some of the attributes a RoboFab Font object has
    print "the number of glyphs:", len(f)

    # some of the attributes map straight to the FontLab Font class
    # We just straightened the camelCase here and there
    print "full name of this font:", f.info.postscriptFullName
    print "list of glyph names:", f.keys()
    print 'ascender:', f.info.ascender
    print 'descender:', f.info.descender
예제 #6
0
# or Glyph object respectively. It will be the
# front most font or the front most glyph.
from robofab.world import CurrentFont, CurrentGlyph

# This is a brief intro into Robofabs all singing and
# dancing dialog class. It will produce simple
# dialogs in almost any environment, FontLab, Python IDE, W.
from robofab.interface.all.dialogs import Message

# (make sure you have a font opened in FontLab)

f = CurrentFont()
# so now f is the name of a font object for the current font.

if f == None:
	# let's see what dialog can do, a warning
	Message("You should open a font first, there's nothing to look at now!")
else:
	# and another dialog.
	Message("The current font is %s"%(f.info.postscriptFullName))

	# let's have a look at some of the attributes a RoboFab Font object has
	print "the number of glyphs:", len(f)
	
	# some of the attributes map straight to the FontLab Font class
	# We just straightened the camelCase here and there
	print "full name of this font:", f.info.postscriptFullName
	print "list of glyph names:", f.keys()
	print 'ascender:', f.info.ascender
	print 'descender:', f.info.descender
예제 #7
0
# robofab manual
# 	Font object
#	method examples
from robofab.world import CurrentFont

f = CurrentFont()

# the keys() method returns a list of glyphnames:
print f.keys()

# find unicodes for each glyph by using the postscript name:
f.autoUnicodes()
예제 #8
0
# iteration through alphabetically sorted glyphnames

from robofab.world import CurrentFont

font = CurrentFont()
print "font has %d glyphs" % len(font)

# names is now a list of strings, the names of the glyphs
# not the glyphs themselves!
names = font.keys()

# the list of names is sorted
names.sort()

# now we iterate through the list of names
for glyphName in names:
    # now we ask for the glyph with glyphName
    print font[glyphName]
예제 #9
0
for lig in base:
    parts = lig.split('_')
    temp = []
    for x in parts:
        if x in accented.keys():
            temp.append(accented[x])
        else:
            temp.append([x])
    toMake = combinations(temp)
    for i in toMake:
        name = ''
        for x in i:
            name = name + '_' + x
        name = name[1:]
        if name not in font.keys():
            font.newGlyph(name)
            font[name].appendComponent(lig)
            font[name].mark = 200
            font[name].rightMargin = 20
            glyphs = name.split('_')
            previous = ''
            index = 1
            for n in glyphs:
                if n in position.keys():
                    if index == 1:
                        font[name].appendComponent(position[n][0], position[n][1])
                    if index == 2:
                        if splitAccent(n)[0] == 'J':
                            p = (position[n][1][0] + 854, position[n][1][1])
                        elif previous == 'A':
예제 #10
0
for lig in base:
    parts = lig.split('_')
    temp = []
    for x in parts:
        if x in accented.keys():
            temp.append(accented[x])
        else:
            temp.append([x])
    toMake = combinations(temp)
    for i in toMake:
        name = ''
        for x in i:
            name = name + '_' + x
        name = name[1:]
        if name not in font.keys():
            font.newGlyph(name)
            font[name].appendComponent(lig)
            font[name].mark = 200
            font[name].rightMargin = 20
            glyphs = name.split('_')
            previous = ''
            index = 1
            for n in glyphs:
                if n in position.keys():
                    if index == 1:
                        font[name].appendComponent(position[n][0],
                                                   position[n][1])
                    if index == 2:
                        if splitAccent(n)[0] == 'J':
                            p = (position[n][1][0] + 854, position[n][1][1])
예제 #11
0
# robofab manual
# Font object
# method examples

from robofab.world import CurrentFont
f = CurrentFont()

# the keys() method returns a list of glyphnames:
print f.keys()

# find unicodes for each glyph by using the postscript name:
f.autoUnicodes()
예제 #12
0
# RoboFont Script
# Install current font with empty glyphs. It is useful when you are testing font in InDesign
# Alexander Lubovenko
# http://github.com/typedev

from robofab.world import CurrentFont

s = 'space exclam quotesingle quotedbl numbersign dollar percent ampersand parenleft parenright asterisk plus comma hyphen period slash zero one two three four five six seven eight nine colon semicolon less equal greater question at A B C D E F G H I J K L M N O P Q R S T U V W X Y Z bracketleft backslash bracketright asciicircum underscore grave a b c d e f g h i j k l m n o p q r s t u v w x y z braceleft bar braceright asciitilde exclamdown cent sterling currency yen brokenbar section dieresis copyright ordfeminine guillemotleft logicalnot registered macron degree plusminus twosuperior threesuperior acute mu paragraph periodcentered cedilla onesuperior ordmasculine guillemotright onequarter onehalf threequarters questiondown Agrave Aacute Acircumflex Atilde Adieresis Aring AE Ccedilla Egrave Eacute Ecircumflex Edieresis Igrave Iacute Icircumflex Idieresis Eth Ntilde Ograve Oacute Ocircumflex Otilde Odieresis multiply Oslash Ugrave Uacute Ucircumflex Udieresis Yacute Thorn germandbls agrave aacute acircumflex atilde adieresis aring ae ccedilla egrave eacute ecircumflex edieresis igrave iacute icircumflex idieresis eth ntilde ograve oacute ocircumflex otilde odieresis divide oslash ugrave uacute ucircumflex udieresis yacute thorn ydieresis dotlessi circumflex caron breve dotaccent ring ogonek tilde hungarumlaut quoteleft quoteright minus u00A0|00A0 afii10017 afii10018 afii10019 afii10020 afii10021 afii10022 afii10023 afii10024 afii10025 afii10026 afii10027 afii10028 afii10029 afii10030 afii10031 afii10032 afii10033 afii10034 afii10035 afii10036 afii10037 afii10038 afii10039 afii10040 afii10041 afii10042 afii10043 afii10044 afii10045 afii10046 afii10047 afii10048 afii10049 afii10065 afii10066 afii10067 afii10068 afii10069 afii10070 afii10071 afii10072 afii10073 afii10074 afii10075 afii10076 afii10077 afii10078 afii10079 afii10080 afii10081 afii10082 afii10083 afii10084 afii10085 afii10086 afii10087 afii10088 afii10089 afii10090 afii10091 afii10092 afii10093 afii10094 afii10095 afii10096 afii10097 afii10051 afii10099 afii10050 afii10055 afii10052 afii10100 afii10103 afii10098 afii10057 afii10053 afii10101 afii10056 afii10104 afii10058 afii10106 afii10059 afii10107 afii10105 afii10054 afii10060 afii10108 afii10061 afii10109 afii10102 afii10062 afii10110 afii10145 afii10193 afii61352'

ng = s.split(' ')

font = CurrentFont()

for gname in ng:
    if gname not in font.keys():
        d = RGlyph()
        font[gname] = d
        missglyph = font[gname]
        missglyph.width = 0
        missglyph.update()

font.update()

font.testInstall()

glyphOrder = font.glyphOrder

for gname in ng:
    if font[gname].width == 0:
        font.removeGlyph(gname)
예제 #13
0
for f in fonts:
    if f.info.postscriptFullName == fontCompare:
        f1 = f

f2 = CurrentFont()
glyph = CurrentGlyph()
fl.SetUndo()
error = 0
print f1, f2

if len(fonts) < 2:
    error = "Debe abrir dos fuentes para comparar"
elif f1.path == f2.path:
    error = "Origen y destino son la misma fuente."

if error == 0:
    tickCount = len(f2.selection)
    bar = ProgressBar('Chequeando...', tickCount)
    tick = 0

    for g in f2.keys():
        if f2[g].selected or g.index == fl.iglyph or g == glyph.name:
            chequear(f2[g], f2, f1)
            bar.tick(tick)
            tick = tick + 1
    bar.close()
    f1.update()
    f2.update()
else:
    print error
# RoboFont Script
# Install current font with empty glyphs. It is useful when you are testing font in InDesign 
# Alexander Lubovenko
# http://github.com/typedev

from robofab.world import CurrentFont


s = 'space exclam quotesingle quotedbl numbersign dollar percent ampersand parenleft parenright asterisk plus comma hyphen period slash zero one two three four five six seven eight nine colon semicolon less equal greater question at A B C D E F G H I J K L M N O P Q R S T U V W X Y Z bracketleft backslash bracketright asciicircum underscore grave a b c d e f g h i j k l m n o p q r s t u v w x y z braceleft bar braceright asciitilde exclamdown cent sterling currency yen brokenbar section dieresis copyright ordfeminine guillemotleft logicalnot registered macron degree plusminus twosuperior threesuperior acute mu paragraph periodcentered cedilla onesuperior ordmasculine guillemotright onequarter onehalf threequarters questiondown Agrave Aacute Acircumflex Atilde Adieresis Aring AE Ccedilla Egrave Eacute Ecircumflex Edieresis Igrave Iacute Icircumflex Idieresis Eth Ntilde Ograve Oacute Ocircumflex Otilde Odieresis multiply Oslash Ugrave Uacute Ucircumflex Udieresis Yacute Thorn germandbls agrave aacute acircumflex atilde adieresis aring ae ccedilla egrave eacute ecircumflex edieresis igrave iacute icircumflex idieresis eth ntilde ograve oacute ocircumflex otilde odieresis divide oslash ugrave uacute ucircumflex udieresis yacute thorn ydieresis dotlessi circumflex caron breve dotaccent ring ogonek tilde hungarumlaut quoteleft quoteright minus u00A0|00A0 afii10017 afii10018 afii10019 afii10020 afii10021 afii10022 afii10023 afii10024 afii10025 afii10026 afii10027 afii10028 afii10029 afii10030 afii10031 afii10032 afii10033 afii10034 afii10035 afii10036 afii10037 afii10038 afii10039 afii10040 afii10041 afii10042 afii10043 afii10044 afii10045 afii10046 afii10047 afii10048 afii10049 afii10065 afii10066 afii10067 afii10068 afii10069 afii10070 afii10071 afii10072 afii10073 afii10074 afii10075 afii10076 afii10077 afii10078 afii10079 afii10080 afii10081 afii10082 afii10083 afii10084 afii10085 afii10086 afii10087 afii10088 afii10089 afii10090 afii10091 afii10092 afii10093 afii10094 afii10095 afii10096 afii10097 afii10051 afii10099 afii10050 afii10055 afii10052 afii10100 afii10103 afii10098 afii10057 afii10053 afii10101 afii10056 afii10104 afii10058 afii10106 afii10059 afii10107 afii10105 afii10054 afii10060 afii10108 afii10061 afii10109 afii10102 afii10062 afii10110 afii10145 afii10193 afii61352'

ng = s.split(' ')

font = CurrentFont()

for gname in ng:
    if gname not in font.keys():
        d = RGlyph()
        font[gname] = d
        missglyph = font[gname]
        missglyph.width = 0
        missglyph.update()

font.update()

font.testInstall()

glyphOrder = font.glyphOrder

for gname in ng:
    if font[gname].width == 0:
         font.removeGlyph(gname)