How to dynamically create documents and elements? #523
-
Hi I'm new to this so apologies if it's rough. I've been trying to understand how to dynamically create documents and elements I've read the documentation for Elements and Contexts and I don't think I missed anything, but I just can't get CreateDocument to work and I end up with a blank screen. I did manage to get it working easily when using LoadDocument() so there's that lol. The code I have here is in a constructor for my rmlui class (wrapper I guess is the more appropriate term?) Rml::ElementDocument* document = context->CreateDocument();
Rml::ElementPtr h1Element = document->CreateElement("h1");
h1Element->SetInnerRML("Hello World");
h1Element->SetProperty("color", "#f6470a");
h1Element->SetProperty("font-size", "1.5em");
h1Element->SetProperty("font-weight", "bold");
h1Element->SetProperty("margin-bottom", "0.7em");
document->AppendChild(std::move(h1Element));
document->Show(); I'm guessing I missed something just can't figure out what. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi there, |
Beta Was this translation helpful? Give feedback.
Hi there,
I think, you need to set the font family, e.g. like
h1Element->SetProperty("font-family", "LatoLatin");
When I try your code with the integrated debugger it complains about the missing font face, adding the above (with the LatoLatin font from the demo) it works here.