I'm creating a dark theme for a Scintilla based editor. I've managed to define all styles as I wanted, except for the line endings. In other words, despite all the text in my editor being showed on a dark background, at the end of each line there's a small white-filled rectangle.
I believe this rectangle is related to line-feed character, because even empty lines have it. But no other control characters are being displayed.
So, how can I get rid of this white rectangle?
I've tried to change the ControlCharSymbol to other values (under or above 0x20) and got no result.
Note: I've just noticed that the same occurs for white-spaces and tabs if they are set to be INVISIBLE. If they are set to be visible, Scintilla shows them as '.' and '--->' using the colors I've defined.
If you've already set the background for all the styles defined by the lexer, you might also try setting the background for STYLE_DEFAULT.
If that doesn't work, the background can be set globally for all whitespace using SCI_SETWHITESPACEBACK.
Related
I want the outline of text with the standard Windows font "Bahnschrift". I tried to convert it with "Path->Object to Path" and then setting fill to X and stroke to black, but looks like the font is constructed with separate polygons for each letter. See this example:
Top is Bahnschrift, and bottom is Arial which works fine.
Is it possible to calculate somehow automatically the outline of the top text, without intersections, and without doing it all manually for all the letters? And including the right outline for letters with holes, like the "e"?
Some letters are even kind of twisted internally, looks pretty bad:
So I guess an algorithm to detect if it is a real hole, or if it is a hole from such twists and to ignore it, could be difficult.
Select the complete character in question. Then select from the drop down menu:
Path intersection followed by path union. This fixes the character font outline problem where the outline crosses into the body of the character.
Using wxWidgets wxStyledTextCtrl I cannot find a way of having the color behind the text to be anything but white. I can change the editor's background but typing in text results in black text with a white background behind the characters.
Searches and review of Scintilla's and wxWidgets docs has revealed nothing to me yet. Any suggestions? (C++, Linux Mint)
update #1: After poking around in the wxWidget source, as a test, I modified in PlatWX.cpp the SurfaceImpl::DrawTextTransparent. I added a call to set brush colour and changed hdc->SetBackgroundMode( wxBRUSHSTYLE_TRANSPARENT ) to wxBRUSHSTYLE_SOLID.
These seems to work reasonably well. However, there are added problems with whitespace. The first being the settings for white space coloring seem to be ignored. The second is a carriage return always leaves a white blank space and multiple spaces having a growing white bow (as on a ship) when holding the spacebar down.
For university, we need to make a game in Unity that is controlled with an Arduino. My idea was a hacking game where the Arduino acts as the 'hacking device' when hacking something in the game. The arduino would have a screen and on that screen would be a basic command-line interface that lets me input simple commands to 'hack' but I've been having trouble regarding text and clearing it.
I've been able to use unity to send typed characters to the display as-well as a backspace function (pressing backspace would remove last character in the string)
I first had issue with clearing all the text when writing (calling tft.print doesn't clear any previous text). I was using fillScreen which was slow. I found out setTextColor had a second argument that let me just set all certain colored text to a different color. Setting it to black would essentially clear it.
This made it update pretty much instantly when writing to the screen but I now had a new issue, backspace would no longer would.
My understand is that when removing the character, it's color won't be updated when calling setTextColor leaving it on the screen until a restart/fillScreen is called.
I'm not really sure how to solve this and all google searches turn up little to no help.
Here's my code for updating the text:
void updateString(char c){
tft.setTextColor(WHITE,BLACK);
if(c!='<'){
//Add new character to end of string
str.concat(String(c));
}
else if(c=='<' && str.length()>2){
//Remove last character in string
str.remove(str.length()-1);
}
//Set cursor back to 0,0
tft.setCursor(0,0);
//Display text
tft.print(str);
}
I'd appreciate any help.
Maybe, use a similar function to tft.clear() each time you refresh the screen or you can draw a filled square of the background on the text so it looks like it has been erased then you rewrite the text.
Sounds like you are using proportionally-spaced fonts instead of the original classic fonts that ships with Adafruit_GFX. Historically, when using the default classic fonts one could set the background color option of the text to the same color as the background of the screen (usually black). This would overwrite the old screen contents with new data and work because the characters using the classic fonts are a uniform size. When using proportionally-spaced fonts, the background color option for the font is disabled by design.
This was presumably because of memory requirements and speed on slower AVR's. Regardless, when using proportionally-spaced fonts the background color feature won't work due to non-uniform sized characters overlapping the same regions as adjacent characters.
There are two work-arounds to this. Adafruit says in order to replace previously drawn text when using custom fonts you can either:
Use getTextBounds() to determine the smallest rectangle that encloses a
string and then erase that area using fillRect() prior to drawing
the new text. OR
Create an offscreen bitmap using GFXcanvas1 for a fixed size area,
draw the text in the GFXcanvas1 object and then copy to the screen
using drawBitmap().
Note that options 1 & 2 above are mutually exclusive. The second method requires more memory. The first method isn't perfect and produces some small amount of flicker, but is in general acceptable if coded carefully.
I hope that I have understood what the nature of your problem is and answered it in a satisfactory manner. If nothing else, at least now you know why custom font's will not work with the so called background color feature that works with the original 'classic' Adafruit fonts.
Nikki Cooper
I am using SDL and libfreetype and constructing a very basic GUI, I'm implementing a textBox, but I haven't been able to figure out how I'm supposed to generate the standard blinking cursor part. It doesn't seem to be exactly the same as a | character. And moreover if I draw it as a | character that changes the text width.
What's the canonically correct way to render text in a textbox with a cursor?
The easiest way is to just draw a line primitive, this gives you a lot more control over the spacing, length and width of the caret.
And if you want to keep it as a text character in your font system, you can do a render-to-texture and copy it out, or do a simple memory blit onto your font atlas (so you can can keep pipe character separate, an use a control char like 0x01 for the caret).
I wonder if there is any possibility to render special characters (0-31 ASCII, for example) my own way in Qt/QPlainTextEdit? I want to render them as small rectangles as seen in this screenshot: ...or as Notepad++ is doing it. My goal is to be able see all characters. So if a character fails to render with current font (there is no such char for example), a small square should be rendered instead.
Qt does have ways to represent non-characters in QTextDocument which is used in QTextEdit and QPlainTextEditor. There's a sample on inserting an SVG object into a text edit:
http://doc.qt.io/archives/qt-4.7/richtext-textobject.html
Or you can use your own QAbstractTextDocumentLayout to handle the drawing of various text objects in the QTextDocument.