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 custom fonts #18

Closed
georgbachmann opened this issue Jan 12, 2017 · 4 comments
Closed

Define custom fonts #18

georgbachmann opened this issue Jan 12, 2017 · 4 comments

Comments

@georgbachmann
Copy link

Is there any way to define custom fonts to use for the output?
I'd need attributed strings where I can define which base-font to use, also which font for h1, h2, ...

Is that anyhow possible? I've seen you basically just give the input to cmark, but couldn't find any possibility to customize any font :(

Am I just missing something here?

@iwasrobbed
Copy link
Collaborator

@georgbachmann If you're rendering it as an attributed string, you should format it using NSAttributedString api's. More info https://developer.apple.com/reference/foundation/nsattributedstring

There are a lot of examples on StackOverflow as well for customizing attributed strings (e.g. rendering from html w/ custom fonts, etc) so I'd encourage exploring there first. This is just meant to be a presentation agnostic converter.

Duplicates #14

@georgbachmann
Copy link
Author

Sure, I am already reformatting the attributed string to match the style I need. I was just wondering if it's possible to create the attributed string already the way I want it to be. That would be the better solution I guess than having to reformat afterwards. Also that way I can only assume which type of text (h1, h2, h3, ...) I am changing based on the font it currently uses, which is not that super sexy, is it?
Anyway... for what I need, the NSAttributedString APIs are enough... cheers

@iwasrobbed
Copy link
Collaborator

iwasrobbed commented Jan 18, 2017

@georgbachmann Your best bet is to read the man pages for the underlying library cmark; there are unfortunately very limited options at present

Alternatively, rendering it as HTML may be faster and easier to style (but it depends on your UI rendering performance needs)

@iwasrobbed
Copy link
Collaborator

Please see the new AST functionality for rendering and customizing attributed strings: #132

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