ASCII characters to polygon - ascii

We need to have ASCII set equivalent to Polygon shapes. Is there a script or routine available? request part with or provide some solution. This is required to print the text annotation on plotter which does not understand plain text.

Depends on your platform.
On Windows with .Net you can convert a string with a TTF font into a GraphicsPath object. Then you can convert the GraphicsPath into a sequence of points to send to your plotter.
https://msdn.microsoft.com/en-us/library/ms142533(v=vs.110).aspx
See also GetGlyphOutline
https://msdn.microsoft.com/en-us/library/dd144891(v=vs.85).aspx
I am certain that other platforms and libraries have similar capabilities.
Related:
Outline of a text as single line vector path

Related

Prevent ugly kerning when using DrawText

I use simple GDI DrawText to output blocks of text to a printer.
The font used in the sample is Segoe UI. But you can use Arial or others too. It doesn't matter.
The algorithm for large text blocks is simple. DrawText is called with DT_CALCRECT with a kind of binary search for the length to get the largest possible text to print. Than DrawText is called without DT_CALCRECT to print the block.
Simple one line text column text is written with one call to DrawText with the given coordinates of the rectangle.
The result is real strange and can be seen in this sample PDF.
Just look on the first line after the header. You can see the text "Test, Test" and you can see the strange kerning here perfectly. The kerning os sometimes so bad, that you can't even read the words.
How to get around this? Is it a problem with the used printer? Is it a problem with DrawText?
The distance between some chars in a word seem to be random in some case. Some spacing are wide other to narrow. The letter combination looks strange unreadable and ugly.
I tried different fonts and printers but the problem just varies but it is always present.
I know about ExTextOut and the capabilities to define the distance/kerning between all chars, but frankly I don't want to care about this. I just want that DrawText behaves on the printer like on the screen. The stuff works on the screen perfectly.
Added 2018-08-23 08:49 GMT+2*
To the code (it is a complex printing engine).
1.Fonts to print are created simply with CFont::CreatePointFont, so the LOGFONT structure is cleared to zero and no additional flags are used except point and face.
2.The mapping mode is MM_ANISOTROPIC. To scale what is seen on the screen and what is to be printed I just use the size of a komparable object (textblock) on the printer and the same size on the screen. The real values for the sample printout to the Microsoft PDF Printer are as follows, the real way I calculate them is not of interest:
m_pDC->SetMapMode(MM_ANISOTROPIC);
m_pDC->SetViewportExt(2363,100);
m_pDC->SetWindowExt(355,13);
This has the effect that the height of a line in LPs is 13, the average character width in LPs is 6...

URL as barcode (not QR)

QR codes are great for printing machine readable URLs if you have a square space. But they look horrible if placed in a text as they are much taller than a line of text.
Is there a way I can have a 1d-barcode with the same functionality as QR code (URL being the most important feature) so it can be put as text in a normal paragraph without special formatting?
If yes: How do I generate those barcodes?
There're different barcode symbologies that can encode text. The main problem is how much text you want to encode and which apps are you going to use to decode the barcode.
If you're using an URL shortener and you want to stick to a 1D barcode, CODE128 is probably the best choice.
Another option could be a PDF417, it's a 2D barcode but is not square like QRCode. In this case you can encode more chars in less space and this symbology is supported by iOS and the major Barcodes library.

How to display math in LaTeX font using Visual Studio 2010 C#

I would like to display mathematical symbols in the conventional LaTeX Font using C# in Visual Studio 2010. I do NOT want to use the LaTeX equation editing machinery, I only want to use the
traditional LaTeX font family, which I believe is called Computer Modern. Using mathematical
symbols in this font, I would like to build my own equation editor.
I have already downloaded and installed the Computer Modern font, and indeed I can now select this font from the list in Visual Studio. However, as a result all the text characters are indeed displayed in the Computer Modern font, all the mathematical symbols are NOT; the latter seem to be completely unaffected by changing the Font Family property.
For example, I have a label whose content property is a text string which contains a formula,
say the integral over x of some function f(x). I would like to display the formula in the conventional LaTeX font style. I use the unicode \u222b to refer to the integral sign. So the
text string reads \u222b f(x)dx. Now, when I change the Font Family property, only the text f(x)dx is affected, but the integral sign remains exactly the same! I find the unicode integral sign
extremely ugly, and the traditional LaTeX integral sign very beautiful, as is the case for many
other mathematical symbols as well. How can I make sure that the integral sign becomes displayed in the traditional LaTeX font style?
Please use a simple language in your answer, I am not a professional!
Any help is much appreciated!
If you downloaded a Computer Modern font that Windows understands, this is likely a conversion to TTF of the original representation in TeX. TeX was invented before Unicode, so these characters are probably missing from the converted font, causing Windows to fall back onto its default font.
TeX also does custom tricks, such as composing multiple glyphs into stretchable integral signs, which are not supported by the Windows font renderer.
Furthermore, using such a custom font, your application won't work properly on computers that don't have the font.
I think your best bet, sad but true, is to use LaTeX to render the equations to PNG files (with a transparent background), and use these in your UI. This question on SuperUser should help you accomplish the creation of these PNGs.

How can I change the background color of specific characters in a RTF document?

I'm trying to output RTF (Rich Text Format) from a Ruby program - and I'd prefer to just emit RTF directly without using the RTF gem as I'm doing pretty simple stuff.
I would like to highlight specific characters in a DNA sequence alignment and from the docs it seems that I can either use \highlightN ... \highlight0 or \cbN ... \cb1
The problem is that I cannot get \cb to work in either Word:Mac 2008 or Mac TextEdit (\cf works fine so I know it's not a color table issue)
\highlight does work but seemingly only with two of the possible colors (black and red) and \highlight does not use the custom color table.
By creating simple docs in Word with character shading and saving as RTF I can see blocks of ridiculously verbose RTF code that presumably does what I want, but it is so impenetrable that I'm not seeing the wood for the trees.
Part of the problem may well be that Mac Word is just not implementing RTF properly. I don't have a Windows version of Word handy.
Anyone know the right way to shade blocks of text?
Thanks
--Rob
There is a note in the RTF Pocket Guide that says MS Word does not implement the \cb command. It says MS Word uses \chshdng0\chcbpatN (where "N" is the color number that you would use with \cb). The book recommends using something like the following for compatibility with programs that implement \cbN and/or \chshdng0\chcbpatN: {\chshdng0\chcbpat5\cb5 text}.
Note: The copy of the book I have was published in 2003, so it might be a bit out-of-date.
The sequence of RTF commands that seems to be most universally supported by RTF-capable applications is:
\chshdng10000\chcbpatN\chcfpatN\cbN
These commands:
set the shading to 100 percent
set the pattern foreground and background colors to the color from the color table (we're not actually specifying a shading pattern)
set the character background to the color from the color table
Word was the most difficult application to properly render background colors in:
Despite what the latest (1.9.1) RTF spec says, Word 2013 does not resolve \highlightN colors from the \colortbl. Instead, \highlightN maps to a predefined list of colors. It looks like those colors come from the 1.5 version of the RTF spec.
Regarding \cb, the 1.9.1 spec contains this helpful pointer at the end of the section on Color Table:
Note: Windows versions of Word have never supported \cbN, but it can be emulated by the control word sequence \chshdng0\chcbpatN.
This is almost a useful suggestion, except that if you read the documentation for \chshdngN:
Character shading. The N argument is a value representing the shading of the text in hundredths of a percent.
So, 0 turns out to not be a very useful value; 100 / 0.01 gives us the 10000 we used in the sequence above.
Use WordPad to create RTF documents, not Word. WordPad creates much simpler documents, i.e. approaching human-readable.
I use WordPad every time I need to display formatted text in a WinForms application, and need something that the RichTextBox control can handle being assigned to its Rtf parameter.

How to render an arabic character in OpenGL?

I am able to display chinese character correctly but when I try to display arabic string the output that display in OpenGL scene is different from the arabic string that display in Visual Studio Editor. I know it should be something to do with "Complex Script" but I am not able to find any good example regarding to this matter. I would like to know how to display arabic text correctly?
Unlike Latin characters which each have a single visual representation, each Arabic character can have many different appearances depending on the surrounding characters. The logical characters in an Arabic string need to be converted to a sequence of visual glyphs in order to be correctly displayed. OpenGL doesn't do this processing for you so you're seeing the logical characters rendered without this processing.
To get around this you will need to use a library such as Uniscribe to transform the logical string into a visual string which you then give to OpenGL for rendering. There are some samples here.

Resources