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.
Related
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.
How can I get the C# winform graphics system from iTextSharp?
So that I can use DrawString(....) to draw text directly onto the existed PDF.
Unfortunately this isn't possible right now. iText, the Java-based library, subclassed the system class java.awt.Graphics2D which is a further subclass of java.awt.Graphics. This allowed them to bridge Sun/Oracle's drawing paradigms with their own. iTextSharp was ported from Java to C# but for whatever reason the system Graphics bridging code was not ported.
If I were to guess Java and .Net's version of Graphics were too dissimilar and there just wasn't enough community desire to bother with it. Also, .Net's implementation has extra abstractions like Pen and Brush so this would have made the bridge code very different between the Java and .Net version. Not to mention methods like FillPie(), MeasureString(), etc.
Right now your two main options are to either just manually draw to the PdfContentByte object which, once you get used to the inverted axis (Adobe's fault, not iText), goes pretty easy, or you can draw to a .Net image and then just embed it. If you do the latter, I'd recommend at least tripling the image resolution and then embedding it at a third of the size, effectively kicking up the DPI.
You can also try something like PDFsharp which, according to their site, has a very native feel for drawing.
I have a desktop app build using .net. I want it to support multilanguages. I am able to do that using resources. Issue is what should I do for images which have text? Should I include all images for separate languages? If so then this will make it difficult and also will increase its size.
I just read that in Android there is "9 patch image", isn't there something similar?
I wish to add background image, and write text on top of that. This background image should resize without change in quality of the image automatically to the size of text in that language.
I couldn't think of any way to avoid separate images with WinForms. WPF, no problem. Web app, no problem. I played around with both text and image on a Button control, but that does not scale fully. I tried using a label over a PIctureBox, but it is impossible to achieve transparency with a Label control. I also tried this using a WebBrowser control--such a thing could possibly work, but would take some further research and would probably change your deployment dramatically (since you would need to make the localization available from some http server).
So I think there is no easy way to do this--I could find nothing easier than maintaining the images separately.
In one of my projects, i had text displayed on top of images. Since the site was multilingual, so no text was part of the images. Instead text was displayed on top of the images, using css properties for absolute position. This had to be tested in all browsers, with multiple languages, as the text size varies in each language, this might break the UI. so enough space has to be provided for text considering all supported languages
Does anyone know a way to determine if a font is monospace and the width and height of a single character (only relevant if it is monospace).
The important requirement is that it works with mono and microsoft implementations of .net .
Thanks
First thing you need to choose which GUI Toolkit you are targeting.
Fonts aren't abstracted in a toolkit-independent way, AFAIK.
For WinForms, TextRenderer.MeasureText method used with "iii" and "www" strings can help you guess if the font is monospaced and which is the probable 'fixed' width of a char cell, bu it may not work right for very small point sizes...
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.