How can I apply color to text following a specific string in LibreOffice Writer? - syntax-highlighting

I would like everything in the same line I type after a # to be RGB(98, 0, 196) and everything after ## to be RGB(0, 180, 180)
This would ideally apply within the current style but I don't mind if the rule applies to the whole document
This is what I mean:
I messed around with field variables but I could only figure out how to apply one of 8 colors to a number rather than any RGB color to text

Related

Can I add a border to node labels?

I am using the STRING app in Cytoscape and find most node labels difficult to read. I want to have white text with a black border/ stroke so that it will stand out against the white background and the color nodes, but I can't figure out how to do this. Is there a way to add labels with white text and a black border? 'STRING style labels' are black with white borders, but are too small and seem to not be customizable.
The STRING style labels actually are customizable, but they use the enhancedGraphics plugin, so the information is stored in a column -- stringdb::enhancedLabel Passthrough. If you look in that column, you'll see how the defaults are set, but you can certainly change those defaults, for example, by changing the "labelsize" from 12 to 16. You can similarly change the font color, outline color, etc.
-- scooter

Text drawn with DrawText() on certain background colors (when SetBkMode is TRANSPARENT) is unacceptably blotchy: How to overcome?

In a legacy MFC application, I am attempting to draw deep red (255, 26, 26) on a 'Carbon' theme background (97, 107, 136) in a dialog. Although I am using BCGSoft's MFC library to wrap the code that draws the text, the essential code that performs the drawing of the text is the following:
// CODE THAT DRAWS THE TEXT
// Copied from BCGSoft's 'BCGPStatic.cpp' text-drawing routine
// clrText is RGB(255, 26, 26)
COLORREF clrTextOld = pDC->SetTextColor (clrText);
// background is RGB(97, 107, 136)
pDC->SetBkMode (TRANSPARENT);
pDC->DrawText (strText, rectClient, uiDTFlags);
Problem is: The text displayed is unacceptably blotchy:
BLOTCHY TEXT
If I change the color (and nothing else) to a lighter red (255, 164, 164), the text displays just fine:
GOOD TEXT
Because the font is likely of relevance, here is the code that sets the FONT:
// SETTING THE FONT
CFont * currentFont = staticCtl.GetFont();
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));
currentFont->GetLogFont(&lf);
lf.lfHeight = 18;
lf.lfWeight = FW_BOLD;
// I have ALSO TRIED:
// CLEARTYPE_QUALITY
// ANTIALIASED_QUALITY
// NONANTIALIASED_QUALITY
// PROOF_QUALITY
// ...and just leaving it unset
lf.lfQuality = CLEARTYPE_NATURAL_QUALITY;
m_staticFontRed.CreateFontIndirect(&lf);
staticCtl.SetFont(&m_staticFontRed);
// The following are specific to BCGSoft
staticCtl.m_hFont = (HFONT)(m_staticFontRed.GetSafeHandle());
staticCtl.m_clrText = RGB(255, 164, 164);
I have researched this extensively and attempted as many 'workarounds' as I can think of. Specifically:
Use TextOut instead of DrawText
Set SetBkMode(OPAQUE) and simply fill the background with FillRect before drawing the text
Remove FW_BOLD from the font
As noted in the code snippet, attempt different 'qualities' in the LOGFONT (NONANTIALIASED_QUALITY, etc.)
What can I do, using MFC / WinAPI (in C++, obviously) to get my choice of color for both text and background to work without the text being unacceptably blotchy?
ADDENDUM
Based on #BarmakShemirani's comment, I zoomed in on the pixels and found that they are RED (after taking a screenshot as a bitmap). Therefore, for certain it would seem, those pixels are being generated as RED on the monitor and simply not being perceived by the eye that way).
Here is a picture of the zoomed-in version:
...The red pixels are present (blotchiness gone).
I now suspect that this is an issue with the MONITOR, and not with the way the pixels are being drawn on-screen or with the human eye.
Thanks to #BarmakShemirani!
ADDENDUM 2
I use my monitor in portrait mode, which is atypical. I just rotated the monitor to landscape and the very same screenshot in my question is significantly less blotchy. This leads me to believe this is mostly a MONITOR issue and not an OS or 'human eye' issue.
...I wonder if some monitors handle this situation better than others, or is this 'built in' to most monitors for some (good) reason?

How to apply a color palette generated by material.io to an app using Material Components for the web?

I have a color palette image, which was created by a designer using tools at material.io. This palette includes color hexes for the following:
Surface, Light and Dark (shown at the top of the palette)
Primary (plus hues for 50, 100, 200, etc..., 900)
Secondary (plus hues)
The image also includes what appear to be contrast percentages for black and white text on the mid points and extremes of each color swatch.
From the material docs I've looked at, it appears the way to customize a theme is by setting SCSS variables such as $mdc-theme-surface, $mdc-theme-primary and $mdc-theme-secondary before importing components, which I have tried. However, the hues of the primary and secondary colors generated don't match those on the generated palette. What additional variables need to be set in order to apply this theme?

Applying stroke-dasharray style to only part of a path

I have a run-of-the-mill nvd3 line chart. Sometimes the data represented by the chart is patchy. I would like to be able to style part of the lines differently to represent this, such as in this example:
Here, the dots are joined by a dashed line when far apart and a full line when close together. Is it possible to apply stroke-dasharray only to certain parts of a path, or do I have to trick nvd3 into creating a new line for each segment where the styling changes?
You can't apply stroke dasharray to part of a path, but you can create a very long stroke dash array that equals the length of your path and carefully calculate the locations of the dashes in JavaScript so that the dashes line up with the part of your path that you would like dashed.

font size bug with CGContextShowTextAtPoint

I have some rather simple code drawing some text into a CGContext. Here is an excerpt (slightly edited).
CGContextSelectFont(context, "Helvetica", 1.5, kCGEncodingMacRoman);
CGContextShowTextAtPoint(context, xpos, ypos, "Hello", 5);
The text renders ok. For some unknown reason, however, the font changes to a smaller size after I click in the view containing the context. Also when I resize the window containing the view the font returns to original size. What is the reason for this?
1.5 points is mighty tiny to begin with. Assuming no other scaling is in effect, that will be one whole pixel and a blurry pixel above it on the screen.
You're probably seeing a bug that I ran into myself: On entry into drawRect:, the current context's text matrix was not the identity matrix. In my case, I saw it contain a scale by 13 on both axes, plus a translation. (Possibly left over from drawing the title bar.) I filed this in Radar as #10585106, in case you want to file your own and cite it.
The solution is to set the text matrix back to the identity transform before trying to draw text.
Once you do that, you'll find that your text will be exactly as tiny as you asked for it to be. You should change your font size to something more reasonable; Core Text contains a function to get the system fonts (from which you can get their sizes), and AppKit's NSFont class contains methods for the same purpose.

Resources