1

Topic: MeasureString strikes...

Is such more low. On Windows 7 it produces: 5,195313 5,097656 On Windows 10 it produces: 5,0 5,097656 1. In what the reason? 2. How to correct? PS in the real project the font "DFKai-SB" undertakes from a delivered file. I.e. there are no problems with mismatch of versions of a font on various OS. using System; using System. Collections. Generic; using System. Linq; using System. Text. RegularExpressions; using System. Drawing; using System. Drawing. Text; namespace Rextester {public class Program {static public float MeasureDisplayStringWidth (Graphics graphics, string text, Font font) {StringFormat format = StringFormat. GenericTypographic. Clone () as StringFormat; format. FormatFlags | = StringFormatFlags. MeasureTrailingSpaces; RectangleF rect = new System. Drawing. RectangleF (0, 0, 1000, 1000); var ranges = new System. Drawing. CharacterRange (0, text. Length); Region [] regions = new Region [1]; format. SetMeasurableCharacterRanges (new [] {ranges}); regions = graphics. MeasureCharacterRanges (text, font, rect, format); rect = regions [0].GetBounds (graphics); return rect. Width;} public static void Main (string [] args) {var text = ""; var font = new Font ("DFKai-SB", 10f, FontStyle. Bold, GraphicsUnit. Point); using (var tmpImg = new Bitmap (1, 1)) {tmpImg. SetResolution (96, 96); using (var graphics = Graphics. FromImage (tmpImg)) {graphics. PageUnit = GraphicsUnit. Point; graphics. TextRenderingHint = TextRenderingHint. AntiAlias; using (var stringFormat = (StringFormat) StringFormat. GenericTypographic. Clone ()) {stringFormat. FormatFlags | = StringFormatFlags. MeasureTrailingSpaces; var size = graphics. MeasureString (text, font, int. MaxValue, stringFormat); Console. WriteLine (size. Width); Console. WriteLine (MeasureDisplayStringWidth (graphics, text, font));}}}}}}

2

Re: MeasureString strikes...

Hello, StatujaLeha, you wrote: SL> Is such more low. To be updated on.net 4.7, then to check up results with different adjustments of scaling in compatibility adjustments. Does not help -  most likely in  GDI, instead of with Frejmvorke.

3

Re: MeasureString strikes...

Hello, Sinix, you wrote: ... Did not win the Line 1 and 3 - Windows 7, two others - Windows 10. First two lines without gaps between letters, in two last between letters on a gap. An output: a gap any especial

4

Re: MeasureString strikes...

Hello, StatujaLeha. Graphics. DrawString uses GDI +. It was used by default to.NET 2.0 And that if to use TextRenderer. MeasureText? It uses GDI. Also it is considered that provides better quality. It is used by default with.NET 2.0

5

Re: MeasureString strikes...

Hello, koodeer, you wrote: K> And that if to use TextRenderer. MeasureText? It uses GDI. Also it is considered that provides better quality. It is used by default with.NET 2.0 Here it is possible to look with examples. https://stackoverflow.com/a/23230570 In a variant cleartype I would tell that one in one. In a variant antialiased differences are noticeable visually, the result at GDI + is better. I more now am am excited with rendering variants, workers as on various. net Frameworks versions (2/3/4/Core), and under various . And that it is identical As I understood, neither System. Drawing. Graphics, nor System. Windows. Forms. TextRenderer in.NET Core will not be (are fastened on GDI + and GDI-> can work only under Windows), therefore it is necessary to look somewhere else. While found here such post, but personally still tried nothing: https://blogs.msdn.microsoft.com/dotnet … rocessing/ So if who has a live experience I will be grateful for the response.