Winform character spacing - c#

I am trying to use Graphics.DrawString and TextRenderer.DrawText to laydown on a fixed rectangle some strings with variable number of characters.
However, even using the GDI+ wrapping methods I am not satisfied with result: I would need to control the font kerning (or string character spacing) to give a chance to pack high number of characters strings.
I read about FontStretches but I do not know how to use in winform. Another method is Typography.SetKerning but again I am blank about using it.
Can someone help?!
Round 2:
I know it could be hard, Win32 API has a freetype support which could be the solution to issue.
Practically my aim is to do something similar to "http://stackoverflow.com/questions/4582545/kerning-problems-when-drawing-text-character-by-character", in .NET. Notice that I am working on pre-formed string of arabic language, not user character imput.
My problem is:
(1) identify which library has the wanted kerning function (most probably gdi32.dll), (2) build a c# safe environment to deal with dll calls, (3) implement a call to dll that works in c#.
Can someone help?
Thank you for answering.

If you look at the documentation, its quite easy to find out which does what, and how to use it.
The method Typography.SetKerning is an WPF-only thing, so you won't be able to use it in WinForms.
A quick Google found this article, which shows us how to modify kerning values to GDI text.

Related

Unix Banner Library for C#

Back in the late eighties I seem to remember using a unix utility method named 'banner' - (see http://en.wikipedia.org/wiki/Banner_(Unix) It basically took a string of text and 'rendered' it as a larger text 'banner' using each character as blocks to form the original character. It was usually used at the start of print runs to create a heading for multi-sheet reports.
Does anyone know of a C# library that reproduces this functionality?
I remember a similar thing on the VAX mainframes at college. useful with a roomful of people banging in Pascal programs on VT100 terminals, and only one matrix printer behind closed doors in the hallowed office where the IT staff worked.
Anyway, this is a C# ASCII art creator - if you could find a way of rendering your text to a graphic file you could then convert it.
You probably could invoke a free software C program doing the same, perhaps figlet

Math equation to image

I'm developing an application for Windows Phone that are using different kinds of math problems, such as hard equations. The thing is that I want this app to be nice and cool and therefor It's obviously that you can't use the * (snowflake) as the multiplication symbol and you can't use the ^ (roof-top) as the exponent symbol. No, what I want is that I want to parse equations into cool images. I mean like this:
I know that there are several ways to parse math, including Latex, MathML and many more, I do also know that there are many javascript based strategies to create images like this, but I still haven't found one that are compatible with Windows Phone 7 based on C#. And I don't want to have anything server based, I want the conversion between equation to an image to be done in the client.
If you have any suggestions please leave a answer.
So the "*" becomes a "."? Not sure whether that's cooler or not but you still don't need an image generator, a nice font will do.

Printing a line instead of "--------"

For a Windows CE project that we print slips, we have a new request which asks if it is possible to print a line insted of printing "-----------" all the way.
Is this possible without printing an image?
c# / .net 3.5
Thank you
On your desktop run charmap.exe. Tick "Advanced view" and type "box" in the Search box. You'll get the Unicode codepoints that you can use to draw lines and boxes. Copy and paste them into your code. Whether they actually show up properly on your device depends on the font support. Odds are decent since they've been around since the first IBM PC. You'll have to try.
There are extendedascii values to do this (196) but it really depends on the printer.
Or as quppa comments use _ but it will not be adequate if you want to box in a title or so.
Wikipedia has an article on box-drawing characters.
Since ─ (U+2500) didn't work for you, it's unlikely ━ (U+2501) will work either, but it's perhaps worth a shot. There is also no guarantee that there won't be spaces between these characters, given that spaces appear between underscores.
The issue is not Windows CE supporting Unicode but finding a font that you can use that has the box-drawing characters. Given the likely size limitations (fonts with lots of characters are tens of megabytes big), this might be a challenge.

Unicode string display in XNA

In the game I'm making, I'd like to be able to display and have the user input Unicode characters. However, I'm having problems with using SpriteFonts to handle this task. Including all of the Unicode characters uses up WAY too many resources (it even causes VS2010 to crash!), so that's out of the question. But I'm not sure what other options I may have.
I know there are ways to dynamically load Unicode codepoints in an "as-needed" basis, but these methods seem to be geared towards string tables and other static text. All of my text is provided by the user, so a static approach wouldn't work here. Any ideas/help?
The XNA Forums are a good place to ask XNA questions. Here is a question similar to yours:
http://forums.xna.com/forums/p/3302/16475.aspx#16475

What type of BarCode is this?

I am starting the process of writing an application, one part of which is to decode bar codes, however I'm off to a bad start. I am no bar code expert and this is not a common bar code type, so I'm in trouble. I cannot figure out what type of bar code this is, which I have to decode.
I have looked on Wikipedia and some other sites with visual descriptions of different types of bar codes (and how to identify them), however I cannot identify it. Please note that I have tried several free bar code decoding programs and they have all failed to decode this.
So here is a picture of that bar code:
alt text http://www.shrani.si/f/2B/4p/4UCVyP72/barcode.jpg
I hope one of you can recognize it. Also if anyone has worked with this before and knows of a library that can decode them (from an image), I'd love to hear about them.
I'm very thankful for any additional pointers I can receive. Thank you.
zbar thinks it's Code 128 but the decoded string is suspiciously different than the barcode's own caption. Maybe it's a charset difference?
~/src/zebra-0.5/zebraimg$ ./zebraimg ~/src/barcode/reader/barcode.jpg
CODE-128:10657958011502540742
scanned 1 barcode symbols from 1 images in 0.04 seconds
My old copy was called zebra but the library is now called zbar. http://sourceforge.net/projects/zbar/
I don't recognize this bar code - but here are a few sites that might help you (libraries etc.) - assuming you use C# and .NET (you didn't specify in your question):
http://www.idautomation.com/csharp/
http://www.bokai.com/barcode.net.htm
It looks a bit like Code 128 but http://www.onlinebarcodereader.com/ does not recognize it as such. Maybe the image quality isn't good enough.
If you are using Java:
http://code.google.com/p/zxing/
Open Source, supports multiple types of barcodes
A list of software can be found here:
http://www.dmoz.org/Computers/Software/Bar_Code/Decoding/
IANABCE (I Am Not A Barcode Expert), but looking at the barcodes here, I'd say this looks closest to the UCC/EAN-128 symbology, character set 'C'.
Do you know what the barcode is used for? What's the application domain?

Categories

Resources