Automatically resizing Font in [Py]Qt[5|6] - pyqt5

I know how to programmatically change QFont, either directly or via Style.
Problem is: is there some way to say "use the largest Font fitting into given space" (and change it when window is manually resized)?
Or should I override resizeEvent() for affected QWidget(s), recompute font, apply, etc, etc?

Related

How can I find exact position of Windows 11 settings slider for font size setting?

Windows allows me to set the font size of its text (e.g. in the window title bars and the menus) using a slider in Settings > Accessibility > Text size. I have an important GUI scripting program (written in AutoHotkey) that depends on keeping this font size the same; if the font size changes, then elements on the windows change position and my AutoHotkey script won't click on the correct controls.
However, I cannot tell how to specify this font size other than "the slider looks like it's one-fifth of the way across" or something vague like that. I need to change the font size temporarily but am not sure how I can put the slider back to exactly its current position.
How can I find out what the exact value of the setting of this slider, so I can reproduce it later? For example, is there some registry value that will store the setting of this slider?
I do not need the value to be accessible to my software; this is just so I, as a human, can try to slide the setting back to the way it was before, and if it is not exactly the same value as before, I want to be able to know whether I should nudge the slider up or down in order to get the same exact setting as previously.

NSTextField vertically misaligns text when using non-default typeface

I am having trouble making text fields look acceptable when using different typefaces.
See this screenshot taken from a test app I made to demonstrate the problem. It consists of a single XIB, with no code in the delegate or anywhere else. This is on OSX Mavericks with Xcode 5.1.1 but I haven't tried on other versions.
The default system font looks fine in the top text field, as you'd expect. Compare this to the one below: same exact size and shape, all I did differently was change the typeface in Interface Builder. Text is pushed downwards, and descending letters (lowercase pqjg) are clipped. The Menlo example below is also pushed downwards, though not quite as badly.
How do I fix this?
A quick test shows Lucida Grande and Helvetica require 17 pixels, and Menlo requires 19 pixels:
Note that this excludes the border and shadows, so you need your text view to be significantly larger than that to guarantee it will fit.
Interface Builder has been specifically designed for Lucida Grande, it knows it can get away with being too small because that font doesn't use all the space it has available. Doesn't work well with other fonts.
You can resolve this a couple of different ways:
• Enable "Uses Single Line Mode" on the Text Field Panel. When I first
encountered this issue it wasn't obvious that this would automatically
align the text vertically within an NSTextField.
or...
• Simply adjust the size of the NSTextField using the adjustment boxes
that appear after you click on it. You can also adjust them through
the "Control" properties.

how to set default font and font style in cocoa app?

My app has all different kind of NSViews, including NSTabView, NSButton, NSTextField, NSPopupButton and so on.
I would like to change all display text to a certain font and with certain font style.
is there anyway to set the default font and font style in cocoa app?
I have tried:
How to loop through subviews in order to get the text of NSTextViews
however it doesn't work with NSTabView and NSButton.
I think that there must be an easy to do so, it's just I don't know what it is.
Please advise.
There isn't a built in way to do this (ie. by setting a key in Info.plist). You really do need to go through all the controls in your app, one way or another, and set a custom font for them. There are a few possible approaches. One is to use a custom subclass for all the controls for which you need to use a custom font. The subclass can be really minimal, it just needs to set the correct font upon initialization, possibly preserving other font attributes (size, color, etc.) setup in Interface Builder. Another option is to do as you've suggested and go through each subview in your app, check to see if it responds to -setFont:, and set your custom font if it does. I've used the first approach (subclass) with good success.

Xcode 4 Interface Building Font Not Updating/Showing

When I am changing the font of a label to anything other than the default, the label's font never changes. I can change the font size but not the displaying font. However, when I double click on the label, I can see what the label's font would look like. Can anyone help me with this?
Not all fonts are available on the iPhone. If you are setting the font to an unavailable one, it will default to helvetica. Search the net for a list of the fonts you can use.
You can reference http://iosfonts.com/ for fonts available for each version of iOS. Fonts outside this list will appear as Helvetica, as jrturton said.
I would suggest expanding the size of the text box, by dragging its outermost edges? Despite having made your changes if the selected font/font size combo is to large for the text box to handle it will remain smaller than what you selected even though when you go into the highlight view it appears correct
Edit
Just Because its in that font selection tool does not mean it will show up on the device

What type of annotation (or other object) to use?

I'd like to take an existing PDF and add semi-transparent rectangles on top of the pages, at pre-defined locations. When the user moves the mouse over the rectangle, it should change color and/or transparency. I should be able to define different colors (including transparency) for both states. Clicking on it executes some action that I define (such as going to another page, or a website).
I understand that this can be done with annotations, but I'm having trouble figuring out which type of annotation would be best suited. They also don't seem to handle transparency very well. Of course, I'm open to using something other than annotations, if need be...
1) That would have to be annotations. If it's clickable-and-does-something, it's an annotation. It could be an annotation on top of some page content, but an annotation must be involved.
2) You can set the appearance of a button to be arbitrary PDF content, including "normal" and "mouse-over" appearances. Note that these appearances aren't available through the Acrobat UI, but can be accessed programmatically from your API of choice at the object level. All appearance dictionaries have 3 different states: "N"ormal, "R"ollover, and "D"own.
To be honest, I've never tried setting a form field's rollover (or down for that matter) appearance, so I'm not sure how well that will work, but the Theory is sound.
What's the difference between theory and practice? In theory, there's no difference between theory and practice. Ouch.
You didn't specify a programming language/os/anything, so it's not possible to give more detail.
Use a button with an ICON appearance and a transparent background. The icon is an arbitrary PDF content stream with resources. Within it, you can set transparency just like you would as part of a page content stream. In fact, the only way the acrobat gui lets you pick an icon is to select a page from an existing PDF document.
Alternatively you might also be able to set the widget's /DA to use transparency with an extended graphic state resource that you'd add to the Acroform's DR dictionary. I haven't tried that myself.