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

Error when importing two fonts of the same family #178

Closed
SirePi opened this issue Mar 14, 2015 · 5 comments
Closed

Error when importing two fonts of the same family #178

SirePi opened this issue Mar 14, 2015 · 5 comments
Labels
Bug It's broken and should be fixed Core Area: Duality runtime or launcher Usability Related to API and UI usability
Milestone

Comments

@SirePi
Copy link
Member

SirePi commented Mar 14, 2015

Following the conversation here, I made a couple tests and I found that if you import a font inside Duality, remove the font, then try to import the same font or even another in the same family, Duality will refuse to import the file with a generic "file type not supported" error message.

(for this test I have used 'Arial Black' and 'Arial Italic' from the Windows' Font directory)
How to reproduce:

  • Open a fresh copy of Duality
  • Import (drag and drop) Arial Black in the project. The font will be imported.
  • Remove Arial Black from the project.
  • Import Arial Italic in the project. It won't work and you will get the error.

Restarting the editor fixes the issue, until you do it again :)

@AdamsLair AdamsLair added Bug It's broken and should be fixed Core Area: Duality runtime or launcher Arguable Benefit-to-cost ratio unclear labels Mar 14, 2015
@AdamsLair AdamsLair added this to the General Improvements milestone Mar 14, 2015
@AdamsLair AdamsLair removed the Arguable Benefit-to-cost ratio unclear label Mar 14, 2015
@AdamsLair
Copy link
Collaborator

Yep, this is kind of "expected" behavior, although not really the one that is preferable. There definitely should be done something about it, but I am not yet sure how to handle this.

  • Duality uses an internal cache for Font families. This is provided by .Net and there's nothing Duality actually does with it, except adding Font data.
  • It doesn't support adding the same Font family multiple times and I'm not even sure that this should be supported either.
  • The error is caused by the fact that each imported Font remains in that cache and it won't allow to add the same family multiple times.

One way to handle this would be to keep a PrivateFontCollection for each Font, or instantiate it temporarily and get rid of it again later.

Will need to investigate whether this is a good solution.

@SirePi
Copy link
Member Author

SirePi commented Mar 14, 2015

Hmm.. I understand where this is coming from.
I agree that it shouldn't be that big of a deal.. I only noticed that because I imported the wrong font style and wanted to import another one (a quite rare case I think)

Maybe it could be enough to put an appropriate warning message if the PrivateFontCollection already contains the Family of the new font. Something like "Cannot import this font now, please restart to rebuild font cache."

EDIT
As a matter of fact if I import Arial Black, restart the editor, and import Arial Italic, it works... strange

@AdamsLair
Copy link
Collaborator

I'm sure there must be a way to do this properly - I'm just not sure, which one it is yet. In any case, thanks for pointing this out. :) It's bad usability and it needs to be addressed.

@AdamsLair AdamsLair added the Usability Related to API and UI usability label Mar 14, 2015
@AdamsLair
Copy link
Collaborator

This should be addressed in the course of getting rid of System.Drawing in v2.0 and making Duality Fonts full bitmap fonts.

@AdamsLair
Copy link
Collaborator

This has been fixed in the course of the above mentioned issue. Closing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug It's broken and should be fixed Core Area: Duality runtime or launcher Usability Related to API and UI usability
Development

No branches or pull requests

1 participant