Is it possible to set a specific font in Mayavi instead of the font family?
So far I only found the option
cb.title_text_property.font_family = 'times'
But I would like to use something like
cb.title_text_property.font_name = 'Roboto Light'
Is there maybe a way to reach through to vtkTextProperty?
If the symbolic constant VTK_FONT_FILE is returned by GetFontFamily(),
the string returned by GetFontFile() must be an absolute filepath to a
local FreeType compatible font.
I've got a QTextDocument read from an HTML file; given a QString of HTML data named topicFileData, I do topicFileTextDocument.setHtml(topicFileData);. I then want to strip off all of the color information, making the whole document just use the default foreground and background brush. (I do not want to explicitly set the text to be black text on a white background; I want to remove the color information from the document.) (Background info: the reason I need to do this is that there are spans within the document that are erroneously set with a black foreground color, rather than just having no color information set, and that causes those spans to display as black-on-black when my app is running in "dark mode", when Qt changes the default text background brush to be black instead of white.)
Here's what I tried:
QTextCursor tc(&topicFileTextDocument);
tc.select(QTextCursor::Document);
QTextCharFormat noColorFormat;
noColorFormat.clearForeground();
noColorFormat.clearBackground();
tc.mergeCharFormat(noColorFormat);
This does not work, unfortunately; it looks like mergeCharFormat() does not understand that I want the clearForeground() and clearBackground() actions to be merged in to strip off those attributes.
I can do tc.setCharFormat(noColorFormat); instead, of course, and that does strip off the color attributes correctly; but it also obliterates all of the other character format info (font, etc.), which is not acceptable.
So, ideally I'd like to find an API that lets me explicitly remove a given text attribute from a QTextDocument. Alternatively, I guess I need to loop through all the spans of the QTextDocument one by one, get the char format of the current span, remove the color attributes from the format, and set the modified format back onto the span. That would be fine; but I have no idea how to loop over spans in that way. Thanks for any help.
Instead of creating a new instance of QTextCharFormat, update the current format and reapply it on the QTextEdit;
default = QTextCharFormat()
charFormat = self.textCursor().charFormat()
charFormat.setBackground(default.background())
charFormat.setForeground(default.foreground())
self.textCursor().mergeCharFormat(charFormat)
A sub-optimal solution that I have found as a workaround is to actually edit the HTML data string before I create the QTextDocument, using a regex:
topicFileData.replace(QRegularExpression("(;? ?color: ?#[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f])"), "");
This works for my situation, because all of the colors in my HTML file are set with color: #XXXXXX style attributes that can be stripped out of the HTML itself. This is fragile, however; colors specified in other ways would not be stripped, and if the body text of the HTML document happened to contain text that matched the regex, the regex would modify it and thus corrupt the content of the document. So I don't recommend this solution, and I won't be accepting it. If somebody can offer a better solution that would be preferable.
is anybody aware of a way to change the DigiScan safe position using scripting commands?
Cheers
Unfortunately the answer (up to the current version GMS 3.3 at least) is:
This property is only accessible via the UI.
One can read the position, as it is stored in the global tags (see example below), but changing the values in the tags does not set the value in the currently used parameter set.
string strX = "Private:DigiScan:X Beam Park Position"
string strY = "Private:DigiScan:Y Beam Park Position"
number px,py
GetPersistentTaggroup().TagGroupGetTagAsLong(strX,px)
GetPersistentTaggroup().TagGroupGetTagAsLong(strY,py)
result("\n"+px+"/"+py)
I'm trying to get the font size of an NSAttributedString, however, I'm having trouble doing this.
How do you get the font size of an NSAttributedString in objective-c?
An attributed string does not have "a font size". The used font is an attribute, which can vary over the String. Look at your Q: There are two different fonts in one paragraph. (One for the usual text and one for the keywords.)
Therefore you can only ask for the existing attributes (including font) at a specific location. I. e. - attributesAtIndex:effectiveRange: does this job for you. The attribute key for the font is NSFontAttributeName. If yo do not find this key in the attributes dictionary, it is Helvetica(Neue), 12 pt.
I would like to enter the city name in the UISearchBar,then the map will jump to the current city.
How to do it?
You would need some kind of NSDictionary which would contain all of the city names with their map references (lat/long) maybe this could be integrated with google maps or some other mapping software. Otherwise you will need to attain or build the dictionary manually. Once you have the map reference you could scroll the map to the right location.