Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graphics DrawString behavies different in higher versions of iOS? #27075

Open
ljzj2 opened this issue Jan 11, 2025 · 3 comments
Open

Graphics DrawString behavies different in higher versions of iOS? #27075

ljzj2 opened this issue Jan 11, 2025 · 3 comments
Labels
area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing platform/iOS 🍎 t/bug Something isn't working
Milestone

Comments

@ljzj2
Copy link

ljzj2 commented Jan 11, 2025

Description

I use UIGraphics in iOS to drawString and it is different between lower and higher versions of iOS

in higher than ios17 it is different or seems that
gra.SetShouldAntialias(false); gra.SetShouldSmoothFonts(false);
is not working.

Steps to Reproduce

1.Create .net mAUI project
2. open MainPage and then add an Image and an Button.
3. if you click the button then create UIGraphics and then set imageResource to the image

this is the code:

UIGraphics.BeginImageContext(new CGSize(309, 60));

var gra = UIGraphics.GetCurrentContext();
gra.FillRect(new CGRect(0, 0, 309, 60));
gra.SetTextDrawingMode(CGTextDrawingMode.Fill);
gra.SetFillColor(UIColor.FromRGB(255, 255, 255).CGColor);

gra.SetShouldAntialias(false);
gra.SetShouldSmoothFonts(false);

var attributedString = new NSAttributedString(str, new CTStringAttributes
{
    Font = Font.ToCTFont(fontSize),
    ForegroundColor = UIColor.FromRGB(255, 255, 255).CGColor
});
attributedString.DrawString(new CGRect(0, 0, 309, 60));
img = gra.AsBitmapContext().Data;
UIGraphics.EndImageContext();

var image = UIGraphics.GetImageFromCurrentImageContext();

var file = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/origin.jpg";
var res = image.AsJPEG().Save(file, true);
image.Source = ImageSource.FromFile(file);

Link to public reproduction project repository

No response

Version with bug

8.0.100 SR10

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

No response

Did you find any workaround?

No

Relevant log output

@ljzj2 ljzj2 added the t/bug Something isn't working label Jan 11, 2025
@jfversluis jfversluis added area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing platform/iOS 🍎 s/try-latest-version Please try to reproduce the potential issue on the latest public version labels Jan 11, 2025
@jfversluis
Copy link
Member

Can you please verify you also see this on .NET 9?

@dotnet-policy-service dotnet-policy-service bot removed the s/try-latest-version Please try to reproduce the potential issue on the latest public version label Jan 11, 2025
@Ying-6
Copy link

Ying-6 commented Jan 13, 2025

Could you provide us with a sample project so we can investigate it further? Looking forward to your reply!

@StephaneDelcroix
Copy link
Contributor

/cc @rolfbjarne

@StephaneDelcroix StephaneDelcroix added this to the Backlog milestone Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing platform/iOS 🍎 t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants