Assign Font Layer

RoboFont Forums Help / General Assign Font Layer

This topic contains 4 replies, has 2 voices, and was last updated by  frederik 6 years, 7 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #5813

    Jeremie
    Member

    Hello again,

    I want to copy a font’s foreground layer to another font ‘new’ layer (equivalent to FontLab ‘assign font mask’). Is there a way to do that ?

    here is an excerpt of my script:

     		 print "Source Font:", sourceFont
    		 print "Target Font:", targetFont
    		 print "New Layer Name:", self.layerName
    		 
    		 #get the first glyph's name
    		 firstGlyphName = targetFont.keys()[0]
    		 #create a new layer with specified layerName
    		 targetFont[firstGlyphName].getLayer(self.layerName)
    		 #parse the target font's glyphs
    		 for gT in targetFont:
    		 	#parse the source font's glyphs
    		 	for gS in sourceFont:
    		 		#if they names match, I want the targetLayer to be a copy of the sourceLayer
    		 		if gT.name == gS.name:
    		 			sourceLayer = gS.getLayer("foreground")
    		 			targetLayer = gT.getLayer(self.layerName)
    		 			#clear contours if any
    		 			targetLayer.clearContours()
    		 			# HOW CAN I COPY THE SOURCE LAYER OF A FONT TO A TARGET LAYER OF ANOTHER FONT ??
    
    #5814

    Jeremie
    Member

    OK, issue solved with 2 flipLayers():

    targetLayer.clearContours()
    gT.flipLayers("foreground", self.layerName)
    targetFont[gT.name] = gS.copy()
    gT.flipLayers("foreground", self.layerName)
    

    it works

    #5815

    frederik
    Keymaster

    there is a flip-swap-copy layers pop up window, see the preferences hot keys to assign a key to it

    see http://doc.robofont.com/documentation/workspace/preferences/glyph-view/

    good luck

    #5816

    Jeremie
    Member

    Yes I noticed that one, with the ‘l’ hot key, it’s pretty cool. But it works only at the glyph level, and I wanted to work at the font level (all glyphs) and between two separate UFOs.

    I’ve placed the full code of my script there:
    https://github.com/sansplomb/RobofontTools/tree/master/AssignFontLayer

    #5823

    frederik
    Keymaster

    cool, thanks

    also check out Gustavo’s hTools2 http://hipertipo.org/temp/hTools2/_html/

    there are some layers scripts available there

    good luck

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.