code that does what the home button is supposed to do in a line of text - arabic

I have an arabic line with english letters in it.
Ex: أنا في abcd البيت
I opened notepad. I started writing.
What I wanted to write is I'm at abcd home but what you see now (left to right) is at I'm abcd home
To fix this, I click anywhere on that line. I press the HOME button. You'll see the cursor moving to the beginning of the arabic word that to the left of the english word. I right click, choose INSERT UNICODE CONTROL CHARACTER then I choose RLE.
When i do that, the reads I'm at abcd home. It's fixed.
If you right click again and choose SHOW UNICODE CONTROL CHARACTER. you'll see that the very first "character" is the unicode character I inserted.
I wish to automate this process.
How do I do that? :D
I can tell you that RLE is represented as \u202B
Thanx

There's no very easy way to automate the process, but there are a couple of things that you can try:
Press Ctrl-Shift on the right-hand side of your keyboard. This will work in Notepad and in many other programs on Windows: Word, Internet Explorer, Google Chrome. It may work in Firefox, too, but if it doesn't, use Ctrl-Shift-X to set right-to-left direction in Firefox. Note that this will correct the display of the text and the cursor movement for you while you are writing it, but not necessarily for the people to whom you send this text.
Use the Microsoft Keyboard Layout Creator to add the RLE character to your keyboard. This program will let you create a new keyboard layout that you will be able to use in all the programs. Load the keyboard layout that you are currently using, find a key that is not assigned to any character and assign the RLE to it. Note that if you use RLE, you must also use the PDF character (U+202C) in the end of the right-to-left text, so assign this to some key, too (this is similar to writing <span dir="rtl">أنا في abcd البيت<span> in HTML—you must use the closing tag). This will fix your text, although it's tricky. Also, note that some websites remove characters like RLE when you try to post on them - Facebook and Twitter do this, for example.
Finally, note that this problem is unique to plain text. If you use a real word processor, like MS-Word or LibreOffice, or write your text as HTML with proper dir attributes, then it's a lot easier, but you'll have to store and send your text in these formats.

Related

Issue with Delphi Menu

I am Using RAD Studio 2010 and I have problem in Menu text
There are Z and Y texts in my menu and I want to remove it
This will happen when I use Non English text
This is because of TMainMenu.AutoHotkeys. By default, the value of this property is maAutomatic, which means that the menu will automatically choose accelerator keys for your menu items.
For instance, in a typical English application, you might get a menu like this:
Notice the underlined characters. These are used to access the menu using the keyboard. For instance, to open the File menu, I can press Alt+F. And once the File menu is open, I can press the key corresponding to the underlined character in the caption of the menu item I wish to invoke.
For keyboard users like myself, such accelerators are extremely important. I use them all the time. I could use the mouse instead, but that would slow me down tremendously. (For instance, in the application in the screenshot, I am very used to press Alt+E, O to open the Sort Lines dialog box. That takes about 0.2 seconds. If I had to use the mouse, it would take much longer!)
Now, in your case, there aren't any Latin letters to underline, so instead the RTL adds these parentheses (with the Latin letter being the accelerator), so you still can access the menus using the keyboard.
I have very little experience with non-Latin-based versions of Windows, but I do believe menus like these are standard. If I were a Chinese or Arabic user (for instance), I think I would refuse to use an application without these. If I cannot access GUI menus and controls with the keyboard, I get really annoyed.
Still, if you insist, you can set AutoHotkeys to maManual.

Aligning left and right on the same line in WordPad

Is it possible to align texts left and right on the same line in WordPad? For example, I want my name to the left and the date to the right. Both on the same line. How can I do this?
While WordPad does not allow you to modify the alignment of tab stops the RTF format supports tab stops with alignments and WordPad can display and edit documents containing such tab stops, for example when you create them in Microsoft Word and save as RTF.
If you don't have access to Microsoft Word you can create the tab stops in WordPad, save the file as RTF, then open it with a text editor and modify the tab stop definitions you are interested in.
Here is an example:
I created a simple RTF document in WordPad which contains the text Left<tab>Middle<tab>Right and created two tab stops. I want the first tab stop to align centered and the second tab stop to align right.
Then I save the document in RTF format on my desktop and open it in notepad. It looks like this:
{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1031{\fonttbl{\f0\fnil\fcharset0 Calibri;}}
{\*\generator Riched20 10.0.14393}\viewkind4\uc1
\pard\sa200\sl276\slmult1\tx3976\tx7242\f0\fs22\lang7 Left\tab Middle\tab Right\par
}
Notice the \tx3976 and \tx7242 commands which define the tab stop positions (generally you look for \tx followed by some number).
Now you can insert the \tqc command for center-aligned tabstops or the \tqr command for right-aligned tabstops. You enter that command in front of the \tx command you want to modify. The RTF document now looks like this:
{\rtf1\ansi\ansicpg1252\deff0\nouicompat\deflang1031{\fonttbl{\f0\fnil\fcharset0 Calibri;}}
{\*\generator Riched20 10.0.14393}\viewkind4\uc1
\pard\sa200\sl276\slmult1\tqc\tx3976\tqr\tx7242\f0\fs22\lang7 Left\tab Middle\tab Right\par
}
Now you can save the document and exit notepad, when you reopen the file in WordPad you should see it displaying with the correct tab stop alignments. It is also possible to move the tab stops around in WordPad without losing the alignments.
Tested on Windows 10 but it probably will work on earlier versions of WordPad since the required commands are not exactly new.
It's not possible using proper formatting.
For example, in Microsoft Word/LibreOffice Writer you'd use left- and right-aligning tabs, as demonstrated in this howto for Word. However, WordPad only has left-aligning tabs.
It is possible to fake it, as it was done in the old days (and still now, by those who don't know better), by clever usage of spaces (or a mix of spaces and tab stops).

iTextSharp - Pre filled Chinese characters in PDF do not come visible until textfield is focused

I am creating PDF with pre filled values in Chinese but when opening the PDF all the textfields containing Chinese text are empty. When focusing a textfield the Chinese text comes visible but is hided again when unfocusing the field. What could be the issue?
Please share some more info, as there could be more than one reason why the appearances aren't generated by iText.
A. The first reason is explained in the StackOverflow question "AcroForm values missing after flattening". In this case, the PDF contains a parameter that instructs iText not to generate appearances, which would explain why you don't see any value up until you click the field, in which case the viewer will create them.
B. The second reason is explained in section 8.3.3 (entitled "Text fields and fonts") of my book. In this case, the parameter in the PDF doesn't prevent the creation of field appearances, but iText fails to do so because you're not providing a font that knows how to display the Chinese characters.
See for instance figure 8.3 and 8.4 of the book.
In figure 8.3, you see that Chinese text isn't displayed in the upper window. By fixing the form (using two different strategies), the Chinese text appears in the lower two windows. Note that the Chinese text won't appear in all viewers in the case of the middle window.
In figure 8.4, you see that Korean text isn't displayed in the upper window, nor in the third window. In all other windows, different strategies were used to fix this problem:
It would lead us too far to discuss all the different strategies in an answer on SO. Instead, please take a look at the TextFontFields example (for the C# version, please take a look at the ported examples). My guess is that you'll benefit most from the AddSubstitutionFont() method, provided that you use a font of which a subset will be embedded in the document (in the example arialuni.ttf is used).
In case of A., the phenomenon also concerns other languages. In case of B., the parameter is correct, but you're not providing a font that can be used to generate the appearance.

Special characters in Xcode look different in edit and view modes

I want to use a special character on an iOS button. When I insert it from special characters collection located in Edit/Special Characters menu it looks like this:
But after I exit the edit mode or run the app on device the character turns into this:
It looks like it uses different font. Is there a way to fix it?
Open up the character viewer (you may need to enable this in the Settings / Language)
You can inspect the arrows in here, and then check the font variations.
Once you've located the font you want, apply that to the label. I suspect you want Lucida Grande Bold.

Using Unicode characters with Delphi XE2

I'm looking at converting one of our applications to Delphi XE2 and generally take the opportunity to bring it up to date.
One of the features of the application is a StringGrid that displays a number of check marks in a couple of columns. To achieve this the grid is actually 2 aligned grids - the second of which is setup with the font as Wingdings in order to display the check marks.
Am I wrong in thinking that I should be able to use something like a TListView and use the checkmark char (U+2713) alongside the rest of the text... If so how the heck do I do this?
Do I need to set the font to Wingdings for that column? Does this need to be in OnDraw?
Am I barking up the wrong tree...
File->New->VCL Forms application
In the Component Palette, expand the Win32 tab and choose TListView, and drop it on the form.
Right-click the newly added TreeView1, and choose Items Editor... from the context menu.
Click New Item. Type in any text (for instance x Testing, using the 'x' as a placeholder for now).
Start the Windows Character Map application (Start button, type Chara in the search box, or Start->Programs->Accessories->Character Map). Change the font to Arial Unicode MS, and navigate to the character you want (it's in there).
Click the character, and then the Copy button. Switch back to the IDE, select the x placeholder you put in the edit, and hit Ctrl+V to paste the character you just chose from Character Map. You should now see your check mark (or whatever character you chose), followed by Testing.
(The steps above are the two-minute process I followed to find out how to do this, and that quick experiment showed that you could.)

Resources