-
-
Notifications
You must be signed in to change notification settings - Fork 72
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
DrawText throws System.NotSupportedException: Specified method is not supported. #331
Comments
The stack trace is explicit here indicating that the method within the CFF font parser is not supported. You’ll need to provide the font and text. |
var font = SystemFonts.Get("PingFang SC"); I have read the Font from OS |
We’ll need it to replicate the issue. Otherwise you’ll have to debug and implement the method yourself. |
Thank you so much! |
@JimBobSquarePants I try to use the Windows operating system to call this API, and the result can be returned normally without throwing an exception. But when I use the Mac operating system, this exception is thrown. |
Windows is likely using a TTF version of the font. |
I see, I should use generic font files like woff, woff2. Is it right? |
@JimBobSquarePants I am very sorry to bother you again. The font problem has been solved, but there is a new problem, that is, only Chinese text can be rendered in the Mac OS environment, and English and numbers cannot be rendered. Do you need to set some attribute values? var fontCollection = new FontCollection();
var fontFamily = fontCollection.Add("PingFangSC.woff2");
var img = new Image<Rgba32>(1960, 180, Rgba32.ParseHex("#FF0000FF"));
img.Mutate(g => {
var textFont = fontFamily.CreateFont(128, FontStyle.Regular);
var paths = TextBuilder.GenerateGlyphs("中文文本-ABCD-1234", new TextOptions(textFont) {
Origin = new Vector2(980, 90),
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Center,
TextAlignment = TextAlignment.Center,
Font = textFont
});
g.Fill(Color.Black, paths);
}); |
Please do not pollute issues with non-related questions. Please use the discussion channels in the future. In answer to your actual issue. Yes, you can use alternative font formats, but we want to be able to fully support CFF fonts, so we require you to provide us with the font file that is causing issues in order to debug the issue, otherwise you can submit a PR. In answer to your second question. The chosen font must not contain English characters, you have to provide fallback font families. |
First of all thank you very much for your patience in answering. It's my first time to raise Issues on GitHub. I don't have a good experience. I'm very sorry for the inconvenience. I have successfully solved my problem by carefully reading the API documentation. Thanks again for your help. Thank you so much! |
Hi @gokeiyou Could you please provide me the original font from the issue. You should be able to zip it up and add it. |
Managed to get a copy of the font here. The field is @brianpopow You seem to have had a significant attempt at CFF2 support. What would you say is missing? I might be able to fill the gaps. |
Yes I think a major part of the parsing is done already in the branch bp/cff2. Unfortunately its to long ago since I last touched it, that I cant remember exactly whats missing. I think there was a problem with parsing One deltaSet entry should look like this:
|
@JimBobSquarePants I think it would be good, if we open a WIP PR for the cff2 branch and gather all info and what needs to be done there. I will do that tomorrow. |
Prerequisites
DEBUG
andRELEASE
modeImageSharp version
SixLabors.ImageSharp/2.1.3
Other ImageSharp packages and versions
SixLabors.ImageSharp.Drawing/1.0.0-beta15;Fonts/1.0.0-beta18
Environment (Operating system, version and so on)
macOS Ventura 13.1
.NET Framework version
.NET 7
Description
Steps to Reproduce
Images
No response
The text was updated successfully, but these errors were encountered: