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

Define and implement consistent behavior for Font loading #137

Closed
madronalabs opened this issue Feb 24, 2019 · 2 comments
Closed

Define and implement consistent behavior for Font loading #137

madronalabs opened this issue Feb 24, 2019 · 2 comments

Comments

@madronalabs
Copy link
Contributor

LoadFont() does different things on the various backends. In nanovg it throws if a font is not found, it's unimplemented for Canvas, etc. One consistent way for it to work would be:

  • if the Font is already cached in the given backend, return true
  • attempt to load the Font from the a resource or, failing that, the installed fonts
  • if successful, cache the font for lookup by name in the backend and return true
  • else return false

Canvas doesn't actually cache fonts itself but can return true iff the font is installed, which will allow consistent behavior. Other backends may have other quirks, can these all be accommodated by the above?

@AlexHarker
Copy link
Collaborator

I'm working on this at the moment. It definitely needs to be consistent. I haven't got to canvas yet, so I'm not quite sure what will happen there, but Cairo and AGG are fine (NanoVG I also need to complete).

The issue with this (and the etc request) is that the LoadFont signature as it is might not cover all of this. As I understand it LoadFont will load a single face, but IText has a style option, which is ignored by NanoVG right now.

In cairo and AGG I am ignoring the style field when its a font loaded from disk, and I cache installed fonts on the fly using the style field as well. It would be good to be able to load them all ahead of time, but we might need multiple LoadFont() type methods or overloads. For ttc if it is a collection I presume we might need a way to select from the collection also? What would that look like?

@AlexHarker
Copy link
Collaborator

This will be coved by #36 (but hasn't been done yet). However, I'm closing to clean-up the issues list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants