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

Add OTF Font in Xamarin.Forms #28

Closed
donmesserli opened this issue Jan 11, 2019 · 11 comments
Closed

Add OTF Font in Xamarin.Forms #28

donmesserli opened this issue Jan 11, 2019 · 11 comments
Labels
Resolution/Answered The provided question has been answered. Type/Question

Comments

@donmesserli
Copy link

donmesserli commented Jan 11, 2019

Is it possible to use a different OpenType font than the one included in the library without building the library from source? Are there calls my app can make to load and use a font? If so, can you provide instructions on how to do it?

@charlesroddie
Copy link
Collaborator

Yes see #20

@Happypig375 Happypig375 added Resolution/Answered The provided question has been answered. Resolution/Duplicate The issue or pull request is a duplicate of another one. labels Jan 12, 2019
@Happypig375
Copy link
Collaborator

Happypig375 commented Jan 13, 2019

@donmesserli Please respond if the referenced issue helped you 😀

@Happypig375 Happypig375 added the Status/4. Awaiting author confirmation Awaiting a confirmation from the author of this issue that this issue has been resolved as expected. label Jan 13, 2019
@donmesserli
Copy link
Author

I saw that question; but the answer is very terse. Can you provide a code snippet and tell me where in my application I need to call it?

@Happypig375 Happypig375 removed Resolution/Answered The provided question has been answered. Resolution/Duplicate The issue or pull request is a duplicate of another one. Status/4. Awaiting author confirmation Awaiting a confirmation from the author of this issue that this issue has been resolved as expected. labels Jan 14, 2019
@Happypig375
Copy link
Collaborator

Happypig375 commented Jan 15, 2019

CSharpMath.SkiaSharp.MathPainter painter = ...;
using (System.IO.Stream otf = ...)
    painter.LocalTypefaces.Add(new Typography.OpenFont.OpenFontReader().Read(otf));
//use painter as usual

@donmesserli
Copy link
Author

I'm doing this in Xamarin.Forms. Not using a painter.

@charlesroddie
Copy link
Collaborator

charlesroddie commented Jan 15, 2019

Then try CSharpMath.Settings.GlobalTypefaces as described in the linked issue.
If this doesn't work let us know and we can reopen.

@donmesserli
Copy link
Author

That's what I want to do; but I still need a code snippet.

@charlesroddie
Copy link
Collaborator

The code is as above with GlobalTypeFaces instead of painter.LocalTypefaces.

using (System.IO.Stream otf = System.IO.File.OpenRead fileName)
{
    CSharpMath.Settings.GlobalTypefaces.Add(new Typography.OpenFont.OpenFontReader().Read(otf));
}

Put this somewhere where it will be called when your app starts, i.e. before rendering happens.

@Happypig375
Copy link
Collaborator

Happypig375 commented Jan 16, 2019

Also applicable:

CSharpMath.Forms.MathView mathView = ...;
using (System.IO.Stream otf = ...)
    mathView.LocalTypefaces.Add(new Typography.OpenFont.OpenFontReader().Read(otf));

@Happypig375 Happypig375 added the Resolution/Answered The provided question has been answered. label Jan 16, 2019
@Happypig375
Copy link
Collaborator

@donmesserli Please respond if the answers helped you 😃

@donmesserli
Copy link
Author

Thank you! It was a lot of help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution/Answered The provided question has been answered. Type/Question
Projects
None yet
Development

No branches or pull requests

3 participants