GlyphLineView

RoboFont Forums Features GlyphLineView

This topic contains 10 replies, has 2 voices, and was last updated by  frederik 3 years ago.

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #5852

    luke
    Member

    is it possible to add a line break in GlyphLineView?

    or do I have to use MultiLineView then?

    thank you!

    #5853

    luke
    Member

    I just realized that GlyphLineView comes from DefconAppKit – so I guess I have to use MultiLineView.

    #5854

    frederik
    Keymaster

    Space center is a multi line view, add “\n” in you input string and a new line is being added

    good luck!

    #5856

    luke
    Member

    thank you – that is clear! I am appending glyphs to a list which are displayed by a MultiLineView. Maybe you can help how I can do that in this case? do i have to somehow use: createNewLineGlyph(self)? thank you!

    #5858

    frederik
    Keymaster

    I would use a spaceCenter object to manage input and change it there

    from mojo.UI import OpenSpaceCenter
    
    # open a space center or get the current one
    spaceCenter = OpenSpaceCenter(CurrentFont())
    
    # get the input as a list
    print spaceCenter.get()
    # get the input as raw string (same as you see in the edit text view)
    print spaceCenter.getRaw()
    
    # set the input as raw string
    spaceCenter.setRaw("hello\\nworld")
    
    #5861

    luke
    Member

    Unfortunately I have to use MultiLineView or GlyphLineView – which only displays glyphs (setGlyphs) – so I guess there is no easy solution.

    #5862

    frederik
    Keymaster

    oke, you want to use a MultiLineView, I misunderstood :)

    a small example:

    from mojo.UI import MultiLineView
    
    from vanilla import *
    
    inputText = """Hello
    world"""
    
    class LineController(object):
        
        def __init__(self):
            
            self.w = Window((400, 400), minSize=(200, 200))
            
            self.w.lineView = MultiLineView((0, 0, -0, -0))
            
            font = CurrentFont()
            charMap = font.getCharacterMapping()
    
            glyphs = []
            for char in inputText:
                if char == "\n":
                    glyph = self.w.lineView.createNewLineGlyph()
                else:
                    uni = ord(char)
                    glyphName = charMap.get(uni)
                    if glyphName:
                        glyphName = glyphName[0]
                        glyph = font[glyphName]
                glyphs.append(glyph)
            
            self.w.lineView.set(glyphs)
            self.w.open()
    
    LineController()
    
    #5863

    luke
    Member

    great!
    thats what i needed! thanks!

    if you could (whenever you find time) show how to setDisplayStates, that would be awesome!

    #5870

    frederik
    Keymaster

    see what the getDisplayStates() returns :)

    from mojo.UI import MultiLineView
    
    view = MultiLineView((0, 0, 0, 0))
    print view.getDisplayStates()
    
    {
        'Inverse': False, 
        'xHeight Cut': False, 
        'Show Kerning': True, 
        'Left to Right': True, 
        'Show Metrics': False, 
        'Show Space Matrix': True, 
        'Upside Down': False, 
        'Right to Left': False, 
        'Stroke': False, 
        'Beam': False, 
        'Water Fall': False, 
        'Multi Line': True, 
        'Single Line': False, 
        'Show Control glyphs': False, 
        'Fill': True
    }
    

    good luck

    #5871

    luke
    Member

    Thank you, Frederik!
    this is more than clear – but I was never able to set them – not sure if this is the right way – e.g.

    view.setDisplayStates({‘Inverse’: True})
    if you then:
    print view.getDisplayStates()
    nothing changed.

    #5876

    frederik
    Keymaster

    I see

    bug will be solved in the next update

    good luck

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

You must be logged in to reply to this topic.