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

Create a custom theme #47

Closed
ghost opened this issue May 14, 2018 · 4 comments
Closed

Create a custom theme #47

ghost opened this issue May 14, 2018 · 4 comments
Labels

Comments

@ghost
Copy link

ghost commented May 14, 2018

Hi Raspu,
Thank you for your amazing work.
I have a question: is it possible to create a custom theme?
Or in another way, is it possible to change the font and the color of the text? Because I have read something about it on other issues but I haven't understood it very well
Thank you for your patience

@raspu
Copy link
Owner

raspu commented May 14, 2018

Hi @AaronLatnok I am glad you like it :).

You can always modify the font of a theme, if you see the Theme class there's 3 properties you can use to modify this:

    /// Regular font to be used by this theme
    open var codeFont : RPFont!
    /// Bold font to be used by this theme
    open var boldCodeFont : RPFont!
    /// Italic font to be used by this theme
    open var italicCodeFont : RPFont!

And, if you want to get the font variations automatically populated from a regular font you can also use: open func setCodeFont(_ font: RPFont) and it will try to populate those 3 properties. By the way, RPFont is just an Alias for UIFont or NSFont (depending on the platform).

Now, even if there's no public API for modifying the color of the fonts, you can still achieve this by modifying directly the CSS theme files that are included with the project, they are just regular CSS files, that you can easily de-minify and change as you wish.

Let me know if you need a more elaborated example on how to do this.

Best!

@raspu raspu added the question label May 14, 2018
@ghost
Copy link
Author

ghost commented May 15, 2018

Thank you so much Raspu, you helped me a lot! Done it without any problem
I have a last doubt: is it possibile delete themes and languages? In my app I want to show just few themes and seven coding languages. I tried to delete what I don't need from the project but the app crashes, so I have looked for some dependencies but I didn't find them (I typed the name of the files, but in truth I don't know what to search exactly)

Thanks a lot for the patience and a huge thanks for the help, I started to learn Swift just a month ago and for me everything is new

@raspu
Copy link
Owner

raspu commented May 15, 2018

Hi, I am glad you were able to make it work!

About removing themes and languages, did you try just deleting the JS files and the CSS files? I never tried this myself tbh... If that doesn't work you can always make a list of theme and languages yourself and present that as the only option to the user, no need of modifying the library itself... But if you really need to avoid including those files in your project you'll probably need to build a new delivery from the original highlighter.js, but I am not really sure if there's any option for limiting the langs or themes... (If you try this, make sure to build it with the CDN option). Let me know if you make it work, if not I can try to make build myself...

Best!

@raspu
Copy link
Owner

raspu commented May 24, 2018

Hi @AaronLatnok, I am going to close this issue for now, feel free to re-open it if you have more questions.

@raspu raspu closed this as completed May 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant