Memo1.Loadfromfile() space - delphi

How do I keep the same spaces that exist in the file .txt? In .txt file it says:
text :text
text1 :text1
text23 :text2
text345 :text3
if I write this code:
Memo1.Lines.LoadFromFile('Text.txt');
this appears in the Memo1:
text :text
text1 :text1
text23 :text2
text345 :text3
the text is different from the file. txt.

The file will be loaded faithfully. All whitespace is preserved exactly as it is in the file.
The most plausible explanation for what you observe is that your text editor displays the file differently from how the TMemo control displays it. Possibly your file contains tab characters. These are often displayed differently in different viewers. Or perhaps the text editor uses a monospace font, and your memo control does not.
But I stress again, the file will be loaded faithfully. The contents of the file are loaded into the memo control without alteration.

You could use a propotional Font like Courier.
Or better format your text with TAB.

Related

TRichEdit adds blanks lines when change wordwrap (any recreate property)

The following was found in Embarcardero RAD Studio 10.2. I have not looked at other versions.
If you have a TRichEdit on your form that contains existing text (more than 1021 characters), and change the WordWrap (or any other recreate window) property, then the component will sometimes insert additional blank lines in the middle of your existing text. It appears to depend on where the CR/LF characters land.
To demonstrate the problem, paste the following text into the Lines property of a TRichEdit on a form in Delphi:
01xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx78
02xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
03xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
04xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
05xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
06xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
07xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
08xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
09xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
10xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
11x456789012345678901234567890123456789012345678901234567890123456789012345678
12xxxxxxx1xxxxxxxxx2xxxxxxxxx3xxxxxxxxx4xxxxxxxxx5xxxxxxxxx6xxxxxxxxx7xxxxxxxx
13x4567890123456789012345678901234567890123456789012345678901
x
The purpose of the sample text above is to have 1024 characters (counting the CR/LF at the end of the preceding lines) when you get to the last line (the 'x' on its own). What comes after does not matter.
Now, with the above text in your TRichEdit, and still in design mode, toggle the WordWrap property a few times. (The same thing should happen if you set up your form to do it at runtime.) If your Delphi does the same as mine, the last line (the 'x' on its own) will start to separate from the earlier lines as new lines are inserted.
If you change the length of the 13th line - add or remove just one character - the problem seems to go away.
I say "seems to go away" because the 1022/1023 position for CR/LF is not the only sensitive positions. I found more further on (when playing with larger text), but not always on the 1k borders (I think, not studied in detail).
I found the problem with WordWrap, but it happens with any of the properties that recreate the window handle (I think) - certainly BorderStyle does the same thing.
Has anyone else seen this? Is it too much to ask if someone could try the above test in Delphi 10.3 to see if it's fixed?
Probably the only reliable fix (if 10.3 doesn't fix it) is to avoid using TRichEdit, or - and this is my next step for testing the problem - to create and use a derivation that inserts code to save and restore content during handle recreation. Any other ideas?
UPDATE At runtime the problem only happens if the PlainText property is true. At designtime it happens whether that property is true or not.

UILabel Only Supports Certain Unicode Characters

My app uses unicode characters. These characters (not the actual codes) are pasted directly into a PLIST file and then imported.
Some of them are not appearing correctly in UILabel and UIButton
When I print them to the log in Xcode they appear normal, but when displayed on the iPhone/Simulator some of the characters turn into an "alien in a box".
See image for example of problem (screenshot from UIButton titles)
My guess is that the font you are using does not define these characters. Select a font (or build one into your app) that includes the characters you need.

Xcode JSON arabic text black instead of red

I have a project including a JSON file which contains Arabic text.
I copied the text from a Word Document file into the JSON file in Xcode.
As far as I know, the correct bits of text in the JSON file are usually shown in red and
the incorrect bits are shown in black color.
This is what it looks like in Xcode:
There are plenty of parts in my JSON file where text is shown in black, hence it must be incorrect. When I run the app, which should output the arabic text in a tableview, the
tableview is shown as empty.
Thus, there must be a problem with the JSON file.
I also checked it on http://jsonlint.com/ with the JSONLint Validator. It showed me the following error message in the red box at the bottom:
Here is the JSON file containing the Arabic text:
https://www.dropbox.com/s/5gxdqmh2l9lr7cv/MyFavoriteDishes_ARA.json
I don't know how to fix it! It's frustrating. Any help is appreciated!

How do I make sure only one font and font size is used in a text field?

The default settings of a text field allow content of a different font and font size to be pasted into the field. How do I make sure that pasted content is converted to use a specific font and font size, i.e. the one I choose as default for the field?
You need to trap the paste from happening, then replicate it yourself. For example in a field (untested):
on pasteKey
put the clipBoardData["text"] into char (word 2 of the selectedchunk of me) to (word 4 of the selectedchunk of me) of me
end pasteKey
You also need to care about drag & drop:
on dragDrop
put the dragData["text"] into char (word 2 of the dropChunk) to (word 4 of the dropChunk) of me
end dragDrop
If you use the "paste" command, it will not trigger the pasteKey message, so if you have such code in your app, so you need to make sure to handle special cases there.
Note: Testing this in the IDE can be tricky, because it interrupts some messages, including pasteKey (use "suspend development tools" from the "development" menu).

Why text on SWC won't show up when imported from FlashDevelop?

I've posted this question before but no useful answer was found. People told me to use embedAsCFF=false, but I'm not embedding any font directly.
There is a textfield using "Impact" as font inside a movieclip. I exported the movieclip as an swc so that I would be able to use it's graphics in my Flashdevelop project.
When I add the swc to the screen, everything is fine but the text. It doesn't appear.
var swcInstance:SwcClass = new SwcClass
swcInstance.textFiel.text = "hello world!"
addChild(swcInstance)
Hope I explained it well
Make sure you create a "Classic TextField" and not a "TLF TextField" in Flash Pro.
Also make sure you embed the needed character for the font - see Properties panel for your field instance in Flash Pro and check at least Basic Latin (and Latin 1 for accented characters).

Resources