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

Improve default aesthetics of plot #33

Merged
merged 9 commits into from
Aug 16, 2019
Merged

Improve default aesthetics of plot #33

merged 9 commits into from
Aug 16, 2019

Conversation

KarthikRIyer
Copy link
Owner

@KarthikRIyer KarthikRIyer commented Jul 14, 2019

#32
I've just enabled grid at the moment. I'm opening the PR just to track the progress.

@KarthikRIyer
Copy link
Owner Author

@BradLarson I have used the default fonts for text in both svg and agg. To support a different font I think I'll have to make significant changes in AGG atleast. I am looking into it now.

@KarthikRIyer
Copy link
Owner Author

KarthikRIyer commented Jul 14, 2019

@BradLarson @marcrasi what would be our purpose of rendering SVGs? I mean, why would the end user want to use SVG? Will he/she view it in a browser?
Why I'm asking this is because, on searching, the ways I'm getting, to use custom fonts in an SVG are using CSS like here: https://graphicdesign.stackexchange.com/a/10735
This doesn't work on the default image viewer in Ubuntu, but works in a browser.

@BradLarson
Copy link
Collaborator

@KarthikRIyer - My primary driver for SVGs was to help make sure the interface was generic enough to support very different kinds of rendering. You don't have access to Core Graphics readily on your end, so this seemed like a good proxy.

I can see a vector backend renderer like this being used for the web as the primary target, so if you want to focus on ways of making that work for custom fonts, that might be a good first step. We can figure out later if something more general is needed for other applications we'd come across.

@KarthikRIyer
Copy link
Owner Author

@BradLarson @marcrasi I am now able to use custom fonts in both renderers. But it still needs polishing. I am using the default font used in matplotlib i.e. DejaVuSans. What I need to figure out next is how to set it as the default font. Now I've hardcoded everything. For AGG the font needs to be present in the directory from where the executable is executed and for SVG the font file needs to be in the same directory as the image.

@KarthikRIyer
Copy link
Owner Author

KarthikRIyer commented Jul 28, 2019

@BradLarson @marcrasi I've changed the default font to Roboto-Regular. For SVG images I'm getting the font from the google fonts API. DejaVuSans wasn't available on google fonts, and trying to use the url for that font from anywhere else gave me a CORS error. That's why I decided to go for goggle fonts. So if the end user needs to use a different font he/she needs to pass the name of any font available on google fonts.

For AGG, I'm not sure how I can get a font to be default. I have to pass in the path of the font to the renderer. Right now the font is in the topmost directory of the library, from where we run the command swift build. So it will work only when any executable is executed form there. To bundle the font with the library I thought I could use an online tool to convert the ttf file to a char array and then load it from memory. But AGG doesn't provide any methods to do that. So right now I'm trying to understand AGG's code and will see if I can implement my own method to load the font from memory.

What do you think? Is there a simpler way of achieving this? Or some way we can get the path to the ttf file in the library's directory irrespective of where we execute it from?

@KarthikRIyer
Copy link
Owner Author

Also I'm getting this:

'CFreeType' /home/karthik/swiftplot/.build/checkouts/CFreeType: warning: system packages are deprecated; use system library targets instead

I did as given here but it's still the same.

Link to CFreeType repo where I made the changes: https://github.com/KarthikRIyer/CFreeType

@KarthikRIyer
Copy link
Owner Author

#29
@BradLarson @marcrasi please review. Next I'll move to implementing a CoreGraphics Renderer and simultaneously fix other problems we might notice.

@KarthikRIyer
Copy link
Owner Author

Also @BradLarson any ideas on how to go about getting it to build on Mac? I believe once FreeType is installed this should build. But I've been unable to install FreeType on Mac.

@KarthikRIyer
Copy link
Owner Author

Merging now.

@KarthikRIyer KarthikRIyer merged commit c6be29a into master Aug 16, 2019
@KarthikRIyer KarthikRIyer deleted the def_aesthetics branch January 11, 2020 07:23
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

Successfully merging this pull request may close these issues.

3 participants