I am facing display issues with winforms in window 10 OS. The fonts used for forms is 'Estrangelo Edessa’. In windows 10, this font doesn't come installed by default and hence text/content looks ugly (cutoff/improperly sized). So i am thinking to change the font that looks closer to 'Estrangelo Edessa' and will be native to windows 7, 8 and 10. Please suggest one such font.
I suggest trying Verdana or Lucida Sans Unicode as they have similar proportions to Estrangelo Edessa. Alternatively, Calibri is narrower but otherwise similar and nicer to read.
You may also want to look into having your forms size the controls so text is never cut off, just in case. For example, all WinForms controls have a PreferredSize property.
Related
I'm using a shared code to produce documents in Silverlight and WPF. But the output is different for the TextBlock alignment.
For example for a TextBlock of height 100, displaying a text in Arial with a FontSize of 100 :
In WPF the BaselineOffset is 92.16333
In Silverlight the BaselineOffset is 90.52667
This difference depends on the font family, for example if I replace Arial by Times New Roman :
In WPF the BaselineOffset is 91.23666
In Silverlight the BaselineOffset is 89,11
Is there a way to correct this behaviour and have the same alignment in WPF and Silverlight ?
Thanks for your help
Having worked in both WPF and Silverlight, I can confirm the rendering output of the same fonts at the same font size the output looks significantly different on screen.
In WPF you have a bit more control using RenderOptions i.e.:
RenderOptions.SetBitmapScalingMode(tb, BitmapScalingMode.NearestNeighbor);
RenderOptions.SetClearTypeHint(tb, ClearTypeHint.Auto);
RenderOptions.SetEdgeMode(tb, EdgeMode.Aliased);
You may need to play with values above to get as close as possible. Also as the renderoptions API is WPF only, if you're in a shared codebase you'd need to wrap it in a #if WPF directive..
I'm using the classic DrawString method to output text in a WinForms app. A typical call look like this:
g.DrawString(text, font, brush, new Rectangle(x, y, width, height), stringFormat);
If stringFormat.Trimming equals StringTrimming.EllipsisCharacter, the text suddenly "jumps" 1 pixel up if it is clipped and the rectangle of the same left/top/height is used:
This happens for many standards fonts like MS Sans Serif or Courier New, but does not happen for others like Segoe UI. And what is more strange, we can avoid this effect if we specify StringFormatFlags.DirectionRightToLeft for stringFormat.FormatFlags.
Is it a known issue of GDI+, and is there a workaround for that?
P.S. Tested all this in Win 8.1 Pro 64-bit, in an app compiled for .NET 4.0.
I cannot figure out how to determine how to render a specific OpenType font correctly in WPF (.NET 4.5 / VS2012 / Windows 8). I have a font installed on my computer called "DINPro-BlackItalic".
The file name is: DINPro-BlackItalic.otf
Windows reports the font name is: DINPro-BlackItalic
In WPF, I do something simple, like this:
<TextBlock Text="This is a sample sentence in DINPro-BlackItalic"
FontFamily="DinPro-BlackItalic" FontSize="24" />
or FontFamily="#DinPro-BlackItalic"
This doesn't work (clearly not italic) and it falls back to the default font. I've tried lots of other variations which do work for other fonts in the font directory.
For example, Comic Sans works: FontFamily="Comic Sans MS" (awesome...)
Now, this is why I am really confused: If I just guess at a different way to punctuate the font name, it renders correctly!
This works: FontFamily="Din Pro Black Italic"
In summary, here is a screen shot of different FontFamily settings in WPF:
Two questions:
1) How am I supposed to guess at the right way to tell WPF to render this font? It must have a canonical name registered somewhere but it isn't visible in the filename, file properties, or the Font Name that Windows reports after it has parsed the file.
2) What's worse is that if I'm attempting to render the same font in a desktop application and on the Web, browsers like Chrome on Windows and even IE expect "DINPro-BlackItalic" and will not render the spaced out version of the name. It seems that WPF and windows browsers make mutually exclusive decisions about which Font Name to use to index fonts. How do I work around this for arbitrary fonts?
You can pack the font with the Application, and you can refer it from the project directory.
Say if you place the font inside Fonts Directory in the Project.
You can add as follows,
<TextBlock FontFamily=”/Fonts/DINPro-BlackItalic.otf#DinPro-BlackItalic”/>
So you can be sure the, font gets deployed with the application.
Okay so I think i found the solution..
<TextBlock FontFamily=”/Fonts/DINPro-BlackItalic.otf#Din Pro”/>
or
<TextBlock FontFamily=”/Fonts/DINPro-BlackItalic.otf#Din Pro Black Italic”/>
Havn't tried your code, but This seemed to work for me.. Referencing the path of the file+fontname
Opentype files have a commen name they share. And this is where it gets tricky, because you can only see this name if you install the font on your pc, and check it in the familytree. Like you showed before in your question:
FontFamily="Din Pro Black Italic"
This is my experience, not 100% sure that i'm correct, only that it works for me :)
For WPF, Better to try it with designer for selecting the font for Textblock
For Browsers, It can be tried with Label or any other UI controls to display.
The syntax that works for me is:
/{Application Name};component/{Font Folder in Project}/#{Font Name (not filename)}
Example:
/ApplicationName;component/Fonts/#Proxima Nova Lt
When the Display Settings is set to either Small or Large the default font for a WinForm is set to Microsoft Sans Serif, 8.25pt. And everything on the form scales properly. However, when it is set to Medium it changes the default font to Microsoft Sans Serif, 7.8pt, which causes various breaking issues on the form.
Is there a specific reason why the font's size only changes on the Medium setting?
Yes, by default if you go past Medium (anything more than 125%) then Windows starts to help and emulates a video adapter set at 96 dots per inch. Same as Small. This works by Windows letting the program actually draw into an in-memory bitmap and rescaling the bitmap before blitting it to the screen. This is an appcompat feature and the result is in general not considered pretty, particularly text becomes 'fuzzy'. It does however help keep the program usable on very high resolution screens and prevents the main window from having the size of a postage stamp. Disabling this feature is the subject of this answer, otherwise the exact opposite of what you are looking for.
It works this way because 125% scaling has been around for a long time already, at least as far back as 2001 with the XP release. So programs are expected to know how to deal with it. Enabling automatic DPI scalling at 125% is not an option.
If I open a new project, and put a label or button on the main window, I get the Segoe UI font at size 12px.
Where is this coming from? Can I choose what I would like the default font / size to be? I had a good look around but can't find anything.
Thanks
The available fonts are set according to System.Windows.Media.Fonts.SystemFontFamilies.
If multiple versions of the same font family reside in the same directory, the Windows Presentation Foundation (WPF) font enumeration returns the most recent version of the font. If the version information does not provide resolution, the font with latest timestamp is returned. If the timestamp information is equivalent, the font file that is first in alphabetical order is returned.
There is also Fonts.SystemTypefaces.
Presumably it is possible to change the selected family or create your own. In fact it is, this post (WPF - Add Custom Font) gives more information on this.
I hope this helps.