My question might be a little bit confusing, but I think it's still worth of paying some attention.
Basically I'm designing a program to display all printable Unicode characters in a RichTextBox.
I'm using VC# 2010 Express Edition.
However, the RichTextBox has a critical problem: some special characters cannot be displayed correctly.
For example, some Korean Characters (ᄀᄁᆪᄂᆬᆭᄃᄄᄅᆰᆱᆲᆳᆴᆵᄚᄆᄇᄈᄡᄉᄊᄋᄌᄍᄎᄏᄐᄑᄒ), can be displayed correctly in Microsoft Word. After I copy to the RichTextBox, the characters cannot be displayed correctly. However, when I copy back to Microsoft Word, it can be displayed correctly.
Therefore, it's a display problem (the characters themselves are correct). I guess it might be a font problem.
Some related property info:
RichTextBox.Font.GdiChaSet
RichTextBox.Font
How can I solve it? So that all printable Unicode characters can be displayed correctly (using different fonts for different CharSets are acceptable).
Actually, I need further assistance about removing all formatting when pasting
rtbxFileContent.Paste(DataFormats.GetFormat(DataFormats.Text)); // DataFormats.UnicodeText
I still need to have all printable characters to be displayed correctly, but without any formatting (except font).
Thanks.
Hope I made myself understood.
I hate sounding like MS Office Clippy, but your questions seems a lot like this one.
Essentially, you're not mad, it is hard. You could try reading/writing the text manually, using UTF8Encoding and BinaryWriter/BinaryReader.
I found the font "Arial Unicode MS" can almost solve my problem, but some characters from Char Sets looks weird to me. (Also, what if the user computer has not installed the font "Arial Unicode MS"?
So I'm still looking for a better universal solution to my question: automatically using different font for different Char Sets in the RichTextBox.
Thanks.
Related
I'm having a strange problem and i cannot figure out, where it is coming from.
We are using MS ReportViewer (tried both 14 and 15) to generate PDF from RDLC. Now I have two custom fonts, both installed on my test system, where the PDFs are generated. Let's call them Hell43 and Hell55 (it's actually Helvetica...[] but as it is giving me hell hat the moment, let's stick with hell[]).
Now Hell43 is HelveticaNeueLt Pro 43 LtEx
and Hell55 is HelveticaNeueLt Pro 55 Roman
The issue is the following: When generating the PDF and opening with Adobe Acrobat everything written in Hell55 gets messed up (no real characters), when there are special characters used in the textbox in the RDLC. You can place two textboxes using Hell55 side by side, the one with special characters will get messed up:
while the same text using Hell43 will work out fine:
No what is strange:
1. This happens only when opening with Adobe Acrobat - Sumatra PDF seems to work. Chrome, Edge, IE only mess up the special characters, not the whole line.
2. When looking at the document properties in Adobe Acrobat it seems, that Hell55 doesn't get embedded into the PDF.
I did read some posts about visibilty-property on certain elements messing up font embedding, but I tried with Hell43 to hide one single element, and look if I could reproduce the behavior for the font - but couldn't.
Further: When looking at the character set, the needed characters should be there (when creating the RDLC in design mode, the characters are displayed correctly). And then when looking at the font properties in windows the two fonts have the same properties, and should be embeddable:
Could maybe the weights cause the problem? I tried setting it from bold to normal, but that didn't solve it.
3. Updating from MS ReportViewer version 14 to 15 didn't solve anything.
Now I am a little short on things to test. Any suggestions? Thanks and thanks and thanks in advance.
I'm using sharpPDF dll (http://sharppdf.sourceforge.net) to create PDF's in C#. Everything works great but I don't get any special characters (actually these are Polish letters such as "ą, ć, ł, Ó...") in my output. I'm saving strings in that PDF.
Is there any way to get that working?
Thanks.
Unfortunately SharpPDF has a lot of issues with special characters and there is no evolution planned for a correction of the special characters problem.
Sorry.
I'm currently working on a Silverlight solution that accepts Unicode characters and displays these correctly, however the text boxes don't seem to accept foreign characters such as Japanese (I'm trying Hiragana at the moment) and Chinese. These can be copied from the clipboard however when changing the language bar in Windows these characters cannot be entered. Is this a common problem and how should this be handled?
Any help much appreciated
I create an image in C# which should contain some text in Japanese. Then I put this image into the whole page which is also in Japanese. The whole page is displayed correctly (Encoding: UTF-8), but the image is rendered incorrectly. Instead of the correct text I get wrong symbols (not '?' but something similar to square).
I need to write this text on image in Arial. Does anyone know what might be wrong? Why text is not rendered correctly.
And one more think... when I test it on my local machine everything looks correctly, but when I deploy app with page on external server this strange error occurs.
In order to create image with text I use:
Font f = Font("Arial", 10f, FontStyle.Bold);
g.DrawString(text, f, b, rect);
The external server likely has a version of Arial installed, which doesn't include the Japanese character set (as far as I recall, the one that includes Japanese is called "Arial Unicode MS"). Remember that when you're generating an image in ASP.NET, it's the servers fonts that are used.
Note, however, that legally, you're not allowed to install "Arial Unicode MS", except when it's part of Office - or if you've licensed it ("Arial Unicode") from Monotype/Ascender. It may be a more viable option to replace Arial with some other typeface, depending on your funds (I'll keep my subjective opinions on Arial out of this).
When installing a new font on the server, make sure you restart IIS. .NET won't recognize installed fonts until a restart (it's not enough to restart the application - may be enough to recycle the app pool, but I never tried that).
Update
If it still doesn't work, it's likely font fallback isn't in place. I.e., you're specifying "Arial", but GDI+ (DrawString) doesn't know to fall back to "Arial Unicode MS" for characters that aren't in Arial (Office sets this up on install, I think).
Two possibilities:
Change your code to actually use the font (i.e. "Arial Unicode MS") rather than "Arial" (which never has Japanese characters in any other versions). This has the disadvantage that if you're using other characters than Japanese, they may look (even) less good than in the standard "Arial" typeface, because "Arial Unicode MS" includes no kerning or other such features.
Or check if there's a link between Arial and other fonts in your (local) registry: HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontLink\SystemLink - one of those fonts will be the one actually displaying your Japanese characters as a fallback font - it may not even be "Arial Unicode". You may add the same link manually in registry on the server (and probably restart IIS again).
Another likely candidate that may be used for fallback is "MS Gothic". As far as I recall, GDI+ uses the above "FontLink" system for font fallback, while WPF uses its own system. The easiest way to be sure (when you're using fonts that you control anyway) is to directly use a font that has Japanese glyphs. Arial Unicode is merely intended as a last resort for Windows when glyphs aren't found in other fonts - not as something that looks nice in itself.
My application needs to be able to display text in English, German, Chinese, and Korean. I would like to use a single font throughout the application. I know I could use Arial Unicode MS or Lucida Sans Unicode. But they are both very large and need to be licensed.
Is the a good font that I could use?
edit:
This is a windows forms application.
First of all, Arial Unicode MS is a fallback font, it shouldn't be used explicitly. And the idea of having a single font is of much less use than most people think. Keep in mind that the scripts are already very different. You'll need Latin, sinographs and Hangul. While all those probably can be found in a single font I have found the Latin characters to be pretty ugly in comparison.
Furthermore, the operating system already knows which font it can use for which script. And mostly it does a pretty good job at choosing the right one.
It would help if you can say what kind of application we are talking about.
There are big differences (for instance) between ASP.NET (accessed with random browsers from random operating systems) and forms/WPF/Win32 applications.
You cannot use the same font between Korean, Traditional Chinese and Simplified Chinese.
If you do, it is immediately obvious to a native if the font is not the one for his language.