I am trying to create a software in (preferably) .Net where I can set a fixed area on my screen where text appears and then convert that data into machine readable code using some sort of OCR. I would like to do this on a live basis, meaning when the text changes, I would like my program to be instantly notified of the change and also what it has changed to.
The good thing is that the text is of standard font, color and fixed area.
How should I best implement this? Any third party software recommended for both the snapshotting and OCR?
for OCR try tesseract. .net wrappers are also available.
When working with different fonts, some might support, say, arabic characters where another might not.
Is there a way in C# to figure out what character ranges are supported by a specific font?
You would need to P/Invoke GetFontUnicodeRanges(). Not easy to do because the font needs to be selected in the device context, that requires more p/invoke.
But most of all, it isn't the right thing to do. You should rely on Windows' automatic font linking, it finds another font if necessary to supply the glyph. The feature is described in this article.
I would like to know if I can use FNT font file in c# .net.
FNTs are not windows font file.
If such fonts are available, can you please tell me how to load it and change windows form font to FNT?
I use .Net GDI+ technology, but please let me know if WPF is better for this.
Thanks,
Those are device fonts, a relic from the Windows 3.0 days before TrueType became available. They contain bitmaps of (typically) 256 glyphs in a certain character set at fixed pre-selected point sizes. They are not scalable beyond those fixed sizes.
Nope, neither GDI+ nor WPF supports them. You'd have to fall back to raw GDI to still use them. The file format isn't complicated, it would be technically possible to lift the bitmaps out of the file. I'm not aware of existing code, although I'm sure somebody did. Some kind of legacy font editor for example.
.NET uses either GDI+ (in WinForms) or WPF for its text handling and rendering.
So depending on what .NET technology you are using will determine what is supported.
I am having a hard time to find out which font is used by the Win 7 File Explorer in the tree view on the left hand side. Better, of course, would be if I can programmatically find out which the right font is (C#).
I searched the Windows 7 design guidelines but this particular scenario is not listed (at least I couldn't find it).
So anyone good with fonts?
It's Segoe UI. In the future, you can use WhatTheFont to resolve any questions you have about what font something is.
P/Invoke to SystemParametersInfo with SPI_GETICONTITLELOGFONT.
It depends on the language version of Windows. If you look at Robert Harvey's answer, you'll see a character that can't be displayed by Segoe UI.
Actually it's probably Segoe UI.
If you right-click on the desktop and select Personalize from the menu that pops up, you should find a place in there that will tell you what the default window content font is.
http://www.sevenforums.com/tutorials/1175-fonts-change.html
I took the liberty of capturing Windows Explorer with PAINT.NET (a great utility) and wrote the identical text above the captured text. Here's what I can tell you. The Font in Windows Explorer appears to be some compressed form of Seqoe UI. There's simply no other font that's close enough. However, it become apparent when you have a long word or phrase that the width has been compressed and the pixels bleed (aliasing). I've not yet found out how to reproduce the exact spacing, but I'm pretty convinced of the following:
The font used by Windows Explorer is Segoe UI.
The point size is most likely 9.
The font is definitely compressed from what you would get using Seqoe UI 9.0.
It is not Segoe. I've spent the last three days attempting to reverse engineer Windows Explorer in Windows 7. Having worked with WPF and Vista, Segoe UI was my first choice for a font family, but I can confirm that it doesn't match up exactly with what Windows Explorer is using.
After working on this subject for several months, here's what I've concluded: The default font is in fact Segoe UI, 9 pt. (12 pixels). However, there is something going on with the 'SnapsToDevicePixels' in Win32 that isn't or can't be emulated with WPF. If you start to mess with the boundaries of your text in fractions, you can start to see some of the aliasing that goes on with fonts. For example, place a simple canvas in front of your text block and give it a width of, say, 7.5 and you'll see your text start to 'bleed' into the surrounding pixels. I've played around with every combination of fractional spacing and fractional fonts and still can't exactly reproduce the text we see with Windows Explorer. This leaves me with the conclusion that Win32 text is simply rendered with a different engine than WPF.
From the Typography in WPF topic, have you tried the Font Stretch property?
That font is Tahoma 7,7pt - checked pixel-in-pixel in Photoshop, in Windows Server 2008.
Windows7 Aero or Windows7 Basic themes use Sagoe.
Windows7 "Windows Classic" theme uses Tahoma.
The font is indeed Segoe UI, 9 pt. However, the Graphics.DrawString() and TextRenderer.DrawText() methods render the font a little differently. If you use Graphics.DrawString(), the text will appear to have more kerning than Windows uses. TextRenderer.DrawText() appears to mimic the exact font that FileExplorer uses.
This is not particularly a programming question, but I was hoping someone here may know the answer.
We have in-house written application in C#. It's uses ListView control (i believe) to display a list of items - items/text that contains line breaks (newline chars). On most PCs (WinXP) the line breaks are displayed as two square characters. But on one particular PC the boxes are not displayed at all, and two lines are concatenated together without any visual separation..
Does anyone knows why would that be?
Is that controlled by some setting in OS?
Thanks in advance.
I would check default font on that machine. If you need to see how to check or change default font, read Fonts - Change Default article.
Update:
You can also try to restore default font. I just found this this article that explains how to restore default Windows XP Fonts.