I am trying to use Code128A.ttf font to generate barcodes. I have been using the same font for years in Windows 2000 and 2003 with Delphi. However, when I try to use the font now with C# and .NET 4.5 in Windows 8.x, all of the text characters seem to work, however, the start and stop code characters do not render the same as the Windows Character Map shows them.
For example: In the Character Map, \u008A shows a nice Code128 stop code barcode glyph in the Character Map. However, when Graphics.DrawString renders it, the character looks like the Š "Latin Capital S with caron". Similarly, the Code128 start code \u0087 is rendered by graphics.DrawString as the ‡ "Double Dagger" instead of its Character Map barcode glyph.
Failed Platform = Windows.Forms, C#, .NET 4.5, Visual Studio 2013, Windows 8.1 Last known working platform was = Delphi 6 (VCL)/Nevrona RAVE, Windows Server 2003
I'm hoping I'm just missing a setting or something simple.
void On_PrintPage(object sender, PrintPageEventArgs ppea)
{
string sCodeAStart = "\u0087"; // Code128A.ttf's glyph for Start A 103
string sStopCode = "\u008A"; // Code128A.ttf's glyph for StopCode 106
int iCheckDigit = MyCheckSumFunction(103, "500014630");
string sBarcode = sCodeAStart + "500014630"
+ ((char)iCheckDigit).ToString() + sStopCode;
Font fontBarcode = new Font("Code128A", 24, FontStyle.Regular);
ppea.Graphics.DrawString(sBarcode, fontBarcode, Brushes.Black, 100, 100);
}
Code128A.ttf Character Map with Stop Character selected.

DrawString Not Rendering Start and Stop Glyphs Properly

This is what it should look like



ppea.Graphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixel;but it only changes the appearance of the characters. Maybe the code page is the problem. I was only looking at the Character Map for the glyph's index in the font. I expected WYSIWYG like all the other fonts and the way it used to work.byte gdiCharSetvalues for thatnew Font(,,,)parameter with no change. The problem is probably related to code page setup. How do I change the code page for the .NET graphics routines? How do I determine which code page will correctly render my Code128A font?System.Text.Encodingprovides the methods for manipulating the code page and encoding/decoding characters, bytes, strings, etc. After testing a few code pages, the only variance was between 7bit and 8bit. In 7bit code pages, the start and stop codes get converted to 7bits and end up as printed barcode characters - just not the correct characters! I do not think the code page is the issue; unless I just didn't figure out which one works. There are thousands of code pages, so trial and error is not going to work for me!DrawString("‡...Š", ...)WORKS!DrawString("\u0087....\u008A", ...)(and variations like \x0087 \u87 \x87) do not work. The answer to my question will be how to use the System.Text.Encoding routines to convert (char)135 to "‡".