SOLVED Why can’t font overview cell size be “float”?
ryan last edited by gferreira
If I try to set the cell size to a float...
from mojo.UI import CurrentFontWindow v = CurrentFontWindow().fontOverview.getGlyphCollection() v.getGlyphCellView().setCellSize_((40.5, 40.5)) cs = v.getCellSize() vw = v.getGlyphCellView().frameSize().width vh = v.getGlyphCellView().frameSize().height print(cs) print(vw, vh)
it returns the following. Cell size is a whole number while frame size can be float.
Since the cells are within the frame, I think it'd be useful for their dimensions to be more precise than that of the frame.
the cell size must be an
intbecause it is the number of pixels in the bitmap representations.
ryan last edited by gferreira
Hi @gferreira. I see where you're coming from. Maybe I can show you a sample of what I'm trying to do. There may be another solution I'm not seeing.
from mojo.UI import CurrentFontWindow ''' trying to perfectly fit 16 columns of cells across the font overview ''' gc = CurrentFontWindow().fontOverview.getGlyphCollection() v = gc.getGlyphCellView() # get the width of the cell view vw = v.frameSize().width cells_across = 16 cw = vw / cells_across print("frame width is ", vw) print("and the amount of cells I want across is ", cells_across) print("so: ") print("desired cell size is ", cw) # do it v.setCellSize_([cw, cw]) new_cw = gc.getCellSize() print("but resulting cell size is ", new_cw) print("so: ") print("leftover padding on right side of font overview is ", ((cw - new_cw) * cells_across))
frame width is 536.0 and the amount of cells I want across is 16 so: desired cell size is 33.5 but resulting cell size is 33 so: leftover padding on right side of font overview is 8.0
Resulting font overview with leftover space on the right is shown below. I've also tried resizing the font overview itself, but for some reason it needs to be re-run a few times before it almost hits flush with the cells. I'd love to be able to solve this without resizing the font overview itself.
Each cell is an image and images can not have float dimensions...
Resize the window by 8? (Untested..)
there’s a script to resize the window in Fill extra space in font overview
ryan last edited by ryan
If I go with the window resizing thing, there's another problem where the script needs to be run multiple times. I thought it had to do with the scrollbar at first, but I changed my settings, and it's not there anymore.
I gave it a try, this seems to work (very nice btw :)
from mojo.UI import CurrentFontWindow cells = 8 fontWindow = CurrentFontWindow() fontOverview = fontWindow.fontOverview cellView = fontOverview.getGlyphCollection().getGlyphCellView() frameWidth = cellView.frameSize().width cellSize = int(frameWidth / cells) # set cell size cellView.setCellSize_([cellSize, cellSize]) # resize cell view frameWidthNew = cells * cellSize xDiff = frameWidth % cellSize L, T, W, H = fontWindow.window().getPosSize() if fontWindow.doodleWindowName == 'SingleFontWindow': x, y, w, h = fontOverview.getPosSize() fontWindow.editor.splitView.setDimension('fontOverview', frameWidthNew) fontWindow.editor.splitView.setDimension('glyphView', W - frameWidthNew) fontWindow.centerGlyphInView() else: # FontWindow fontWindow.window().setPosSize((L, T, W - xDiff, H), False)
to do: update the cell size slider at the bottom
ryan last edited by
Thanks so much, @gferreira, this solves it perfectly in SWM!! I wouldn't have figured out
setDimensionx2 in splitView +
And yes the main tool has
I've flowed in your solve. Feel free to play with the real tool here.