I use TCastleControl to build the interface of my program, and I needed to display text with texture tags for verification:
"Using HTML tags to make <b>bold</b>, <i>italic and <b>bold and italic</b></i>.
Can also <font color=\"#6666ff\">change text color</font>
Can also <font size=\"-2\">change size</font>."
It seems you have added additional backslashes inside a string, your text and screenshots show:
...<font color=\"#6666ff\">...
These backslashes are not valid in HTML. Just write
...<font color="#6666ff">...
and HTML tags will be recognized OK. Looking at your code, you load text from test2.txt file, so you should remove backslashes from there.
( Maybe you wrote the backslashes because they have been present in the JSON contents in examples/fonts/html_text/data/gameviewmain.castle-user-interface ? If yes, then the explanation is that the backslashes are present in JSON because strings in JSON are surrounded by double quotes, so in JSON encoding backslashes are added when one wants to have a literal double quote in the output. But these backslashes are then stripped when reading JSON into a string (like Pascal string) in memory. )
P.S. As an unrelated suggestion: your code defines a lot of components using Pascal. I would suggest to define them instead using CGE editor, and just load the design from Pascal. Designing such components in CGE editor will allow to experiment with their properties much faster.
I thought about it, but in the future all resources will be loaded from a single file via TStream, can I somehow transfer configuration data without specifying the url?
All things in CGE can be loaded from an arbitrary TStream (not just from a URL). There are methods like LoadFromStream or overloads (like TSerializedComponent.Create) to take a TStream instead of an URL, always.
If you find something that’s missing such capability, please report It is our design goal to always allow loading from TStream.
Note that we generally recommend creating new threads for new questions. A separate question deserves a separate thread, so that people searching the forum can see it better, and so that talk about it can go in parallel to unrelated questions.
You meant TComponent.Tag? Yes. All CGE components descend from standard FPC/Delphi TComponent, so they have Tag property.
We have a dedicated TCastleEdit It does not descend from TCastleLabel, since editing necessarily means somewhat different logic that only display (e.g. editing has cursor, and a frame typically).
Though if you want to dynamically change the label to edit, you can, just have 2 controls (TCastleLabel and TCastleEdit), synchronize their text (MyLabel.Caption and MyEdit.Text) and make only one of them Exists at given time.
Note that we don’t yet have multi-line editing, i.e. we don’t have TCastleMemo. It’s a TODO. Our TCastleEdit only handles single-line editing for now.
Ah! In this case the answer is no, I’m afraid – we do not support <img...> inside the label text. The HTML elements/attributes supported by TCastleLabel.Html are rather limited, see API docs here: Castle Game Engine: CastleFonts: Class TCastleAbstractFont .
To have images between text, you could just add TCastleVerticalGroup, and add TCastleLabel, then TCastleImageControl, then another TCastleLabel.
Our TCastleLabel.Html will likely stay somewhat limited – it’s an easy way to tweak text in the middle, but I am afraid of trying to implement there a “real” full-featured HTML renderer
Good evening, no, I don’t need full html rendering, I thought CastleLabel is an analogue of TextView from android studio, it has such a spanned text class. In general, I’m writing an application that will download news, and some other data from the server, and so that the text is not completely dry, I want to add tags to the text