Coder Social home page Coder Social logo

Medal style bug about wzcomparerr2 HOT 3 CLOSED

kagamia avatar kagamia commented on July 3, 2024
Medal style bug

from wzcomparerr2.

Comments (3)

Kagamia avatar Kagamia commented on July 3, 2024

There' re two difference between these version:
1> low-level text renderer engine, GDI or GDI+
2> Graphics.TextRenderingHint, ClearType or AntiAlias

I've wrote a standalone program to compare them, here is it:

	var bmp = new Bitmap(500,300);
	var g = Graphics.FromImage(bmp);
	g.Clear(Color.DarkSlateGray);
	int y = 20;
	var font = new Font("Arial", 11f, FontStyle.Regular, GraphicsUnit.Pixel);
	var fmt = StringFormat.GenericTypographic.Clone() as StringFormat;
	
	string text = "Ambition 90, Willpower 90, Charm 90 EXP can be obtained once when equipped.";
	
	foreach(System.Drawing.Text.TextRenderingHint trh in Enum.GetValues(typeof(System.Drawing.Text.TextRenderingHint))) {
		g.TextRenderingHint = trh;
		g.DrawString(trh.ToString(), font, Brushes.White, 0, y);
		g.DrawString(text, font, Brushes.Orange, 20, y+12);
		TextRenderer.DrawText(g, text, font, new Point(20, y+24), Color.Orange);
		y+=36;
	}

8afd8a2d0708283810a1a381b899a9014d08f17f

In short words,

g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit; 

makes texts more clear.
The advance of space character in GDI is a bit shorter than those in GDI+.

Font fallback in GDI+ looks better than GDI, that's why I use GDI+ mainly in CMS version.

GearGraphics.DrawString could be replaced with new version if there's no serious bugs. It support both GDI and GDI+ text rendering engine, but it measures with GDI+ and fixed-pitch fallback function.

So, how you merge these code is depend on what you like. :)

from wzcomparerr2.

Sunaries avatar Sunaries commented on July 3, 2024

@Kagamia Using AntiAliasGridFit makes the font not similar to official GMS version. You can definitely see the font has changed even though it is Arial.

You can see the difference in the images I posted in this issue. Do you see the differences in the font style?
The first two images resemble the font style GMS uses.

However, a friend of mine came with a 'messy' (so he says) solution:

In GearTooltipRender2.cs line 1290 till 1294, the following is changed:

            if (!string.IsNullOrEmpty(medalName))
            {
                var brush = new SolidBrush(color);
                g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
                TextRenderer.DrawText(g, medalName, font, new Point(130 - width / 2, picH -2), color);
                g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault;
                brush.Dispose();

Is there a more robust way to do this? Because this code basically resets the TextRenderingHint back to system default after drawing the medalName text.

from wzcomparerr2.

Kagamia avatar Kagamia commented on July 3, 2024

Yes you get the right way. 👍

Usually, alter and recovery statement is written like this:

var oldVal = g.TextRenderingHint;
g.TextRenderingHint = blablabla
// draw...
g.TextRenderingHint = oldVal;

from wzcomparerr2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.