Oops, the new method is named *rescale_sizes()* - a last-minute change - as correctly shown in my code example. The PR has just been approved, so it should be in the latest version of the devel branch.
On Friday, March 11, 2022 at 12:10:44 AM UTC-5 [email protected] wrote: > I have just submitted a PR for a new method to be added to Leo's > Stylesheet Manager (g.app.gui.styleSheetManagerClass). The new method > is named *rescale_fonts() *and it lets you easily rescale all the sizes > in a CSS stylesheet or a Leo theme outline. It rescales logical sizes > (like @string font-family-base = 10.6pt) and physical sizes (like font-size: > 10.6pt;) > > The background is that I have been struggling with coming up with a theme > that works on a small tablet I have. I couldn't get it to be usable, and I > got tired of trying to hand-edit all those logical font-sizes, like > @font-family-basic > = 10.6pt. Also, there are many other sizes that are not usually given > logical names, like the various paddings and margins that also need to be > changed. > > At the same time, I was becoming aware that my two plugins, VR3 and > Freewin, as well as a new thing I'm working on, don't adjust to changes in > theme font size, and I was wondering how to make them adapt more > automatically. And I found that some of the standard plugins that I depend > on all the time, like the Find and Nav tabs, also don't scale with the > theme sizes. How to fix all that? > > So I wrote a script that uses a regular expression to find all the size > instances in pt or px and resize them by a specified factor. Non-integer > sizes are allowed (since I use them in places). Qt and browsers honor point > sizes to at least .5pt granularity, and possibly finer. I'm not sure what > will happen for a size in fractional px, like 1.5px. Presumably the > nearest integer will be used, but it remains to be seen. If necessary, I > could adapt the method to avoid fractional px values - that would be easy. > > Once I had this script, I thought that it could be useful to others, > especially plugin developers, and that the obvious home for it would be as > a new method on the style sheet manager. After all, the SSM already has a > node for "Computations on stylesheets themselves". > > Using the method to rescale a theme or stylesheet is this easy: > > # Input "theme" is a theme or css string > SCALE = 1.25 > ssm = g.app.gui.styleSheetManagerClass(c) > rescaled = ssm.rescale_sizes(theme, SCALE) > # Save to a new theme file if desired, or load the > # changed stylesheet back into the master widget, etc. > > Assuming that @Edward agrees, the new method should show up on the devel > branch soon. The PR is at Add new utility method to Qt styleSheetManager > class: rescale <https://github.com/leo-editor/leo-editor/pull/2477> > -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/19534e3a-82c2-43ce-9462-bc0a9918cba5n%40googlegroups.com.
