I am drawing a chart in a text file and I want to set the rows color grey and white one by one but I couldn't find the function that can help me.
my compiler is code blocks on windows.
can anyone please tell me the number of these colors and related function?
thanks
It is impossible in c++ to change color of texts in a file
A text file is just text. It has just nothing but the letters and punctuation. It has no notation of color or whatever. So you can't do it in C++ or anything else.
For formatting and colors there are special files - HTML, RTF and others. If you want to write such thing you must ask the question that way.
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.
today i need to print colorful text in console, but the color should be "unusual". I've found the only way to colorize text with windowh.h
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), colorNumber)
Main problem is the limited choice of colorNumber, there are only 16 colors, but it is not enough. What if i want to make text color #33F5C8? What if i want to make it transparent? How can i do it?
(nonstandard cpp tools allowed)
With ANSI you can use the following code to set a RGB based color:
\033[38;2;⟨r⟩;⟨g⟩;⟨b⟩m
To reset color after change:
\033[0m
Pay attention that the visual's console might not support it, although the CMD probably does. To check the colors, compile your program and run it using the CMD.
I am using Skia for one of my sample program. I have a canvas and inside this I am writing text with font_size 30, this is the code snippet.
string = "Test String";
SkString text(string);
SkPaint paint;
SkScalar textWidth;
paint.setTextSize(SkIntToScalar(font_size));
paint.getFontMetrics(&metrics);
textWidth = paint.measureText(text.c_str(), text.size());
textWidth will give the exact width of the text inside the canvas. My question is how can I get the height of the text ? Please help.
I once had to look into this myself in the past, this link here should help you, even though it is java, fonts all work on the same idea as far as I know.
I assume you will want from the ascender to the baseline, Which is just the ascent. Or you may want the whole thing from top to bottom which is the ascent and descent combined,
If you were writing on lined paper, the baseline is the same as the line you write on, anything above that is the ascent, anything below is the descent.
I dont know anything about skia, But A quick look into skia, at this link here, that there is a public member called fAscent in FontMetrics, and fDescent, Maybe you can use those.
the font size your have specified as "font_size" is the height of single line text
I am working on an embedded platform (STM32F407) with a TFT LCD as a display (480x800px) and would like to make my user interface somewhat customizable to the end user. I figured the best source of fonts would be windows compatible as their the most common.
My current implementation uses my own custom drawn font in a binary format and a descriptor table giving the character width and ascii value but having to draw my own font bit by bit is tedious.
I would like to read in a True Type Font file from an SD card and be able to use the different sized glyphs inside it but I have not seen a strait forward implementation on how to actually achieve this magic. Can somebody point me to a good c/c++ example of what I am looking for?
Even better as a way to iron out the kinks I would like to make a simple gcc command line program that will print out my input with a selected font using '#' as pixels. That way I can just worry about implementation and not any other random bugs that might pop up.
Can anybody help me out?
Perhaps you can use the Freetype library.
As duskwuff says: TTF is primarily a vector format, would need to write a renderer. Better off using an image file to define the font, or using a bitmap font format like FNT (Windows) or BDF (UNIX).
Here is my answer to my own question: AngelCode's BMFont & Useage. This makes choosing selective characters from the installed char set, mix in a font and exports an image with a map file to each character. Simple to use.
I'm new to GUI programming in C and Linux, and I'm having a hard time with it. It seems like a fairly simple/straightforward thing, but I can't find any answers googling. I want to add a background color to a widget. XmNbackground seems to be what I want to use, but I don't understand what I set it to, like a simple color blue, how do I get "blue" to set XmNbackground color to that?
See here for an answer in the function Pixel convert_color_name_to_pixel, and also here.
Hope this helps.
You can use a resource file which includes "*background: blue" or use XSetArgVal to do the same thing in the code.
If you have the widget in a function, you can set the widget background color resource like this, assuming the widget name is w:
XtVaSetValues(w, XmNbackground, XmRstring, "#c4c4c4", 8, NULL);
Where #c4c4c3 is the hex color code for red (first two characters), green (middle two characters) and blue (last two characters).
You can also use any of the textual color names from file rgb.txt - where that file is located seems to be something of a moving target, but on the computer I'm using at the moment it's in /usr/share/X11