AmyrAhmady / FarsiType

FarsiType - type in Farsi or Arabic in C++ programs and get a fixed version of it!
MIT License
40 stars 8 forks source link

Text Parameter #1

Closed bigorange558 closed 5 years ago

bigorange558 commented 5 years ago

Thank you very much for your code, which is very important to our team。 But we encountered some minor problems during use. I set the parameters like this: string s= u8"مرحبا"; string s1 =FarsiType::ConvertToFAGlyphs(s); ImGui::Begin(s1.data(), &g_continue_pro, ImGuiWindowFlags_NoResize); This setting can't be displayed normally.I don't know what the problem is. When you are not too busy, you can help me look at it.Thanks again!

AmyrAhmady commented 5 years ago

Hi, I'm glad this small library can be useful for you and your project! Can you please provide a screenshot of how it is rendered in your software? Also, is that C++ standard string? if yes, I recommend using c_str instead of data. Keep me updated.

bigorange558 commented 5 years ago

Thank you very much for your reply!I tried the c_str,but still the same as before. I'm using the string type :
typedef basic_string<char, char_traits, allocator >string; the screenshot : problem

bigorange558 commented 5 years ago

Forgot to say,My email is: bigorange923@gamil.com
If you are convenient, you can send me your email address, I will send you a simple demo project file ,You probably know what went wrong.Thank you!

AmyrAhmady commented 5 years ago

Interesting... I would like to know more about this, I will send you an email so I can get more information about this issue and fix it as soon as possible.

bigorange558 commented 5 years ago

Sorry, I entered the wrong mailbox suffix. it's:bigorange923@gmail.com I am a careless person and need to get rid of these bad habits as soon as possible ~~~

AmyrAhmady commented 5 years ago

By looking at your code, I realized you are using GetGlyphRangesDefault while adding a font, which doesn't contain Farsi/Arabic glyph ranges In order to achieve this: farsitype

You have to declare glyph ranges you want to use. For example:

static const ImWchar ranges[] =
{
    0x0020, 0x00FF, // Basic Latin
    0x2010, 0x205E, // Punctuations
    0x0600, 0x06FF, // Farsi/Arabic
    0xFE00, 0xFEFF, // Farsi/Arabic
    0,
};

And then, while you're adding a new font, you should pass a reference of ranges. For example:

io.Fonts->AddFontFromFileTTF("C:\\Windows\\Fonts\\tahomabd.ttf", 15.0f, NULL, &ranges[0]); 

Hope I helped you. I guess I should do a how-to for ImGUI users when they want to use FarsiType!

bigorange558 commented 5 years ago

This time it worked, hahaha, I have no way to study for 3 days. Your technique is so good, it will help me solve it so soon, thank you very much! !

AmyrAhmady commented 5 years ago

I’m glad it works! so I guess its okay to close this issue now. Good luck

bigorange558 commented 5 years ago

Of course, this problem has been solved very well, thank you very much, keep in touch.

mscmajidGit commented 4 years ago

Hi, you need to add the 'bold row' to solve the problem with گچپژ static const ImWchar ranges[] = { 0x0020, 0x00FF, // Basic Latin 0x2010, 0x205E, // Punctuations 0x0600, 0x06FF, // Farsi/Arabic 0xFB50, 0xFBFF, // Farsi/Arabic 0xFE00, 0xFEFF, // Farsi/Arabic 0, }; ‌The reason is that without the row, the following rows of your vector will be useless: const std::vector<std::vector> fa_AlphabetsAllForms = { {u8"\u067e", u8"\ufb56", u8"\ufb58", u8"\ufb59", u8"\ufb57"}, // faa_PEH, // پ {u8"\u0686", u8"\ufb7a", u8"\ufb7c", u8"\ufb7d", u8"\ufb7b"}, // faa_CHEH, // چ {u8"\u0698", u8"\ufb8a", u8"\u0698", u8"\ufb8b", u8"\ufb8b"}, // faa_JEH, // ژ {u8"\u06af", u8"\ufb92", u8"\ufb94", u8"\ufb95", u8"\ufb93"}, // faa_GAAF, // گ with regard, Anjidani

AmyrAhmady commented 4 years ago

I see, thanks for noticing that missing range! @mscmajidGit

🙏🏻

SafuIraq commented 2 years ago

I see, thanks for noticing that missing range! @mscmajidGit

🙏🏻

salam bro Amyr i have real big problems arabic text with imgui, every arabic letter show it '?' with your process and without it, i am using android and i am try using your source but its not working with me can u help me please? and that my code

ImFontConfig cfg; cfg.FontDataOwnedByAtlas = false; cfg.SizePixels = ((float) density / 20.0f);

static const ImWchar ranges[] = { 0x0020, 0x00FF, // Basic Latin 0x2010, 0x205E, // Punctuations 0x0600, 0x06FF, // Farsi/Arabic 0xFE00, 0xFEFF, // Farsi/Arabic 0, };

std::string Path = "system/fonts/DancingScript-Bold.ttf"; font1 = io.Fonts->AddFontFromFileTTF(Path.c_str(), ((float) density / 20.0f), &cfg, &ranges[2]); std::string s= u8"السلام عليكم"; std::string s1 =FarsiType::ConvertToFAGlyphs(s); ImGui::Begin(s1.c_str(), 0, ImGuiWindowFlags_NoSavedSettings);

SafuIraq commented 2 years ago

thanks bro its working with me!!! thankyou for really nice tool!

AmyrAhmady commented 2 years ago

you're welcome, sorry for late response @SafuIraq I assume it was a problem with your font and you changed it, tell us how you fixed it so if someone else came across this issue they can figure it out as well