Hi everyone,
I’m new to Julia and I’m trying to contribute to BioJulia. For the package I’m working on I need to print to the console in a custom font as I need to convert text to a set of specific symbols available in that font.
How can I include this font in my package so I can print to the console using it and everyone who adds that package will also be able to see the text in the correct font?
Thanks
1 Like
Do the symbols have standard Unicode encodings? If so, that should free you from tying yourself to a particular font.
3 Likes
I believe not. It’s called Ambiscript and it was created as a font of unique symbols.
The Julia REPL per se has nothing to do with fonts, it just emits character codes, your terminal converts that into a visual rendering using fonts. If you are using some kind of a text terminal, you should be able to set the font for that (outside Julia). Then, assuming it handles UTF8 (most should do these days) you just print the right character codes. Perhaps defining constants for them would help.
1 Like
Are you referring to the font on this page? That won’t work well - at least, if you change the terminal’s font to that you won’t be able to read ordinary text…
1 Like
Looks like such a cool way to visualize DNA, though.
1 Like
If you’re using IJulia with the Jupyter notebook interface, which runs in the browser, you can emit HTML output, and use HTML directives to control the font.
2 Likes
Note that IJulia automatically calls display
on the result of executing a cell. So you can either have the cell end with an HTML("<font ...>")
object or call display("text/html", "<font ...>")
— no need for display(HTML(...))
.
2 Likes
That’s perfect! Can I ask how you imported/registered the font so it knew what you meant by DNABold?
Most people probably do the same steps as described at some length for the three main platforms here. I load fonts using a font manager (Linotype’s FontExplorerPro), which is probably atypical…
You can usually find the names by looking at the details of the font. Often, the PostScript name seems to be the one that works, although I suspect that too may be platform-dependent.
1 Like
For use in IJulia, you could also use @font-face
CSS which would mean that the user wouldn’t have to manually install the font.
1 Like
Ahh thank you that’s very helpful. The output is directly to the Julia console so would these solutions be compatible with that? I’ll let you know how I get along with figuring it out.
And Stevengi, is it possible to output CSS formatted text to the Julia console for display in the console?
I don’t think that’s possible, if you mean the Terminal app on a Mac, for example.
1 Like
I wonder if it might be possible to use a build script with BinDeps.jl to install the fonts? Wouldn’t help the terminal case, of course.
1 Like
No, you need a browser to handle HTML and CSS, so you need IJulia or similar.
1 Like
The best (though admittedly not short-term) solution would be to submit a proposal to include the characters in Unicode.
1 Like