How to draw underlined text in a JavaFX Canvas - javafx

I'm trying to draw underlined text in a JavaFX 8 canvas. I need to draw directly to the canvas instead of using a Text node since I will then export the canvas to image and use it elsewhere.
I haven't found a way to configure the GraphicsContext to make it draw underlined text.
So far I've discovered:
The Font Constructor takes a font family, a font weight (bold, regular, etc) and a font posture (whether it is italic or not) but there is no sign of a underlined property.
To format text as underlined in a Text element you set the setUnderline property but the Text element is a Node and I'm trying to draw directly into the Canvas not placing a Node on top of it.
Is there a way to draw underlined text directly on a GraphicsContext? If not, Is there a workaround that would let me export it to an image?

Related

Fireworks how make symbol button grow at instance level

I have a rectangle with some text on it defined as a button symbol.
My problem when using the button is that the rectangle does NOT resize but keeps its dimensions. And when I resize the button the text font changes too.I have buttons with short text and some with very long texts. Currently the ones with long text the rectangle is not long enough to accommodate the whole text.
Anybody know how to make a button grow or shrink with text one enters at instance level?
I ended up duplicating the button symbol and making the rectangle much bigger as I found now way of scaling whatever symbol background scale with the text

Stop QLabel text blending with background colour

In short
I'm trying to get the text in my QLabel to paint as if it were over a black background, ignoring the real background colour.
In depth
I have a QLabel in a green coloured widget, the text is anti-aliased and white, the anti-aliasing softens the edges of the text by blending with the green background colour.
Hardware detects the exact green colour and uses it like a green screen to display some techno-wizardry without also drawing over my software overlay, it makes the background look black.
The anti-aliased text has a fuzzy green halo where it has slightly changed the green colour and hardware doesn't overwrite it.
I want the text to be draw as if it were over a black background
What I've tried
I have tried using a black opaque QGraphicsDropShadowEffect to be drawn under the text, thus giving the text a black background to draw on, this led to a bigger green halo around the text.
I have tried setting various QBrushes in the label's QPalette for the Qt::WindowText and Qt::Base ColorRoles.
I have re-implemented the paintEvent and I am trying to use style()->drawItemText(... ) to avoid re-implementing all the helpful alignment code.
I have tried intercepting the QStyleOpt parameter and setting its QPalette's background colour to black, however that didn't change anything, I still get fuzzy, greenish text.
I have tried various QBrush and QPen colours in the QPainter.
I'm really close using a QPainterPath in an overidden paintEvent function (in a class extending QLabel) where I paint a black path of the text behind the text, then I call QLabel::paintEvent and let it draw the text over the top. The issue here is that in some cases the path is clipped to smaller than the widgets rect() on the left hand side, scope for another question I think!
What I could try but haven't worked out yet
I could give the text a black outline as per this question however I'm using a QWidget not a QGraphicsView text item, and then the black outline would still probably blend with the green background.
Compromises I've already thought of and want to avoid
I could set the QLabel background to black, leaving large rectangles of black over the resulting overlay, unfortunately the labels are often much larger than the text being displayed.
I could stop the font being anti-aliased, this looks quite ugly and it stops all fonts being uniform across the product.

How to shade text color in TclTk

I implemented a button in TclTk with the text "Click". What I have to do is to write the text with different shades of green.
Is there anyway to make the text' color of a button to be green shaded?
The Tk button makes all of its text be a single colour (controlled by the -foreground option) as that's by far the most important use case for the large majority of users. Making the text vary in colour across its face is outside this use case, and so requires substantial trickery. The two ways I can think of are to use an image instead of a text label (when you can draw whatever you want on it, using the alpha channel to let the background show through) or to use a canvas widget to simulate a button.
Making an image (PNG, or GIF in 8.5 and before) is quite a lot easier.

In flex how can someone add both bold and border?

I am trying to make a text area in flex 4.5. The problem is i need some part of it as bold not all. Also i need border.
A simple code is
<s:TextArea text="Text here1 Text here2">
By default s:TextArea contain border but I cant bold only one part of text that is "text here1"
If I try to use mx:TextArea Then I cant add border to it.
Please if anyone can help over how to add border along with if i can make only a part of text as bold or of different color etc.
Why can't you add a border to mxTextArea? There are a couple of ways:
specify borderStyle css property;
write a skin class, which draws a border and background you need, and assign it to borderSkin css property;
draw a 3x3 graphic skin and assign it to borderSkin css property.
Place a border container around the control
Use the textFlow property instead of the text property and you will be able to use rich text (bold, italics and so on).
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flashx/textLayout/elements/TextFlow.html

Handling inverted pixels in bitmapData and bitmap class in as3

I am using bitmapData and bitmap classes to render a mouse cursor on the display screen. The bitmapData consists of an area whose colors should be inverted according to the background color. This is a very basic thing which could be observed with text cursor(the vertical line with two small horizontals on top and bottom), when moved over the text area.
I want to be able to do the same with the pixels in my bitmapData, is there a way to find out the background color effectively and invert the color values?
In this process i will be redrawing the whole pixels, is there any other efficient way to do that ?
You can draw your cursor using BlendMode.INVERT
http://livedocs.adobe.com/flex/3/langref/flash/display/BitmapData.html#draw()
or simply put your cursor display object over your bitmap and set it's blendMode to INVERT.

Resources