2022-07-02 01:23 AM
Hi,
I am trying to achieve the functionality of a dropdown list having multiple fonts listed and upon selecting the desired font the textArea font gets changed at runtime.
As shown in Image the Selected font is "Times New Roman" and I want to make the textArea "EC:\> Hello World" written in that font and able to change it vice versa.
2022-07-04 07:20 AM
Hello A.Qasim,
There's multiple way to do it, but the easiest would be to create multiple languages where you'll have the same translation but a different typography. Then you can call the setLanguage() function to switch between your fonts.
void Screen1View::ChangeFontCourrier()
{
Texts::setLanguage(COURRIER);
textArea1.invalidate();
textArea1.resizeToCurrentText();
textArea1.invalidate();
}
Don't forget this include this :
#include <texts/TextKeysAndLanguages.hpp>
I attached a project, you can use that for reference for your own project. Tell me if you succeed on it, that's an interesting project =)
/Osman
2022-07-04 07:26 AM
2022-07-05 12:00 AM
Hi Osman,
Thanks a lot for your help. One thing I am facing is that I want to keep the original text and want that text to be available in every font and that text is dynamic i.e., can be changed by the user.
I am thinking of using wildcard can that be possible? Is there any way to deal with this complexity? also if possible kindly point toward other methods to change the font.
Regards
-Arslan
2022-07-05 02:44 AM
Hi Arslan,
Yes you can totally use wildcard to do that. But remember to add the wildcard range to allow the letters you want, and this for each of your language/font.
Then a simple strncpy would be enough.
Unicode::strncpy(textArea1Buffer, "Hello Vivaldi", TEXTAREA1_SIZE);
The other method I have in mind is to use binary fonts. We have an article about how to use it, I invite you to have a look at it 🙂
/Osman
2022-07-05 02:47 AM
Thanks Alot Bro You're Great.
2022-07-05 04:19 AM
You're welcome !