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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto generated font from Randall's handwriting #17

Merged
merged 2 commits into from Jun 15, 2017

Conversation

pelson
Copy link
Member

@pelson pelson commented Jun 14, 2017

As mentioned in #16, I have been playing with the handwriting sample provided by Randall, to see if we can auto-generate a decent font.

This PR pulls all of my work together. It:

  • generates a new font-family, "xkcd Script", so that both the existing "xkcd" and "xkcd Script" may both be installed at the same time
  • builds reproducibly on Travis using a docker container I prepared locally, containing:
    • pango
    • fontforge
    • python 2 (issues with python 3 and fontforge 馃槩)
    • scikit-image
  • pushes any changes to the font back into the repo (using doctr) so that we can have the built products alongside the code (e.g. the font itself, samples etc.)
    • a deploy key for ipython/xkcd-font will need to be created, and put in ``.github/deploy_key.enc in the format required by doctr

Recommended way of reviewing: Take a look around the branch at https://github.com/pelson/xkcd-font/tree/xkcd-script-v3

Here is the "handwriting sample" re-generated using the xkcd-script font:
Handwriting sample

There were a number of issues along the way:

  • I'm currently unable to re-build the Dockerfile without getting Seg Faults (I guess something has moved under my feet, perhaps in conda-forge wrt. X11 but not confirmed. I sank several hours trying to fix, and in the end stuck with the image that I produced locally/originally). As a result, the Docker file is a bit embarrassing 馃槈 .
  • I'm getting unexpected exit codes:
    • When generating the sfd file (but not when generating the exact same ttf file) I got 139 (SegFault from docker)
    • When generating the samples. I got 141 when generating the handwriting sample with non-ascii characters.

Known places where the work can be improved:

  • There are glyphs in "xkcd" which could be copied into "xkcd Script"
  • The code quality is very low - I have intentionally not refined it, and it shouldn't be hard to do
  • The pipe character is currently the same as an "I" - I needed to do this to be able to put together the <| and |> ligatures. A font MUST have a glyph for each of the characters it has ligatures for.
  • The glyph linewidth is too thick - some refinement of the potrace process (ppm -> svg) will be needed
  • The glyphs spacing is too wide (necessary because the linewidth is currently so big). The ligatures therefore look a little too close, which of course they aren't because they are exactly spaced as per Randall's xkcd handwriting.
  • Ligature spacing is too wide

Proposal: All of the above are known issues, I do not recommend improving the font in this PR, instead I'm keen to lay the foundations (i.e. merge), and iteratively improve (i.e. with small PRs)

Future decisions (I propose we resolve this after this PR):

  • Do we need 2 fonts - should it just be "xkcd" and that's that? What about the fact that "xkcd" is significantly more uniform (perhaps unrealistically so)?
  • Do we keep the build products inside the repo?
  • Do we pull pelson/fontbuilder into the ipython namespace on Docker hub?

CI building with TravisCI.
Code to generates reproducible fonts.
pelson/xkcd-font

The docs were built from the branch 'xkcd-script-v3' against the commit
22ed754.

The Travis build that generated this commit is at
https://travis-ci.org/pelson/xkcd-font/jobs/242709510.

The doctr command that was run is

    /home/travis/virtualenv/python3.6.1/bin/doctr deploy --built-docs . --deploy-branch-name xkcd-script-v3 . --key-path .github/deploy_key.enc --no-require-master --no-sync
@pelson
Copy link
Member Author

pelson commented Jun 14, 2017

Incidentally, I tested I could have "xkcd", "xkcd Script" and "Humor Sans" all installed and used within matplotlib with:

import matplotlib.pyplot as plt
import matplotlib.font_manager


xkcd_regular = matplotlib.font_manager.FontProperties(family='xkcd', size=40)
xkcd_script = matplotlib.font_manager.FontProperties(family='xkcd Script', size=40)
humour_sans = matplotlib.font_manager.FontProperties(family='Humor Sans', size=40)

fig = plt.figure(figsize=(12.5, 3), dpi=100)
text = 'Hello XKCD world. BETTER?'
plt.figtext(0.01, 0.7, text + ' (xkcd)', transform=fig.transFigure, fontproperties=xkcd_regular)
plt.figtext(0.01, 0.4, text + ' (xkcd Script)', transform=fig.transFigure, fontproperties=xkcd_script)
plt.figtext(0.01, 0.1, text + ' (Humor Sans)', transform=fig.transFigure, fontproperties=humour_sans)
plt.show()

And got:
mpl

Note: Matplotlib cannot currently do ligatures, as can be seen in the word "BETTER".

@pelson
Copy link
Member Author

pelson commented Jun 14, 2017

Things I'd like to do next, preferably in another PR 馃槈 :

  • Get doctr working on ipython/xkcd-font
  • Re-rename "xkcd-uniform" back to "xkcd" (docs and folder structure only, xkcd-uniform isn't in the font itself)
  • Tweak and refine the READMEs a lot more, including generating a preview of "xkcd"
  • Put together a CONTRIBUTING.md guide

@rgbkrk
Copy link
Member

rgbkrk commented Jun 14, 2017

Proposal: All of the above are known issues, I do not recommend improving the font in this PR, instead I'm keen to lay the foundations (i.e. merge), and iteratively improve (i.e. with small PRs)

I'm sold on that.

@takluyver
Copy link
Member

馃憤 for merging and doing further improvements in another PR.

@rgbkrk rgbkrk merged commit f6da86b into ipython:master Jun 15, 2017
@pelson
Copy link
Member Author

pelson commented Jun 16, 2017

馃帀 - thanks for moving it forwards guys.

@pelson pelson deleted the xkcd-script-v3 branch June 16, 2017 07:37
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.

None yet

3 participants