Git Product home page Git Product logo

sparks's Introduction

A typeface for creating sparklines in text.

Get the font files here. (.zip file, 5.2MB)

To quickly include the fonts in your web page you may wish to use our stylesheet which defines all the font-faces and links to the relevant files hosted on github.

  <link href="https://tools.aftertheflood.com/sparks/styles/font-faces.css" rel="stylesheet" />

See it working on our website or in one of our interactive notebook examples


Sparks GIF

Sparks uses OpenType's contextual alternates feature to perform simple replacement operations on numbers. It works on both the desktop and the web where it works without Javascript, though it does require a modern-ish web browser that can make use of OpenType features in text. At the moment it is compatible with Microsoft Word (2010 and later), Apple Pages, Adobe Creative Cloud applications, Chrome 33+, Safari 6+, Firefox 4+, and Internet Explorer 10+. (See: http://stateofwebtype.com/ for a fuller listing of browser compatibility.)

There are currently three variations: bars, dots, and dot-lines (line charts with tiny dots at the joints between segments), each of which has five weight variants.

All three of the variants use a fixed scale of 0–100. If your data only goes to e.g., 10, you'll need to first translate your numbers to be out of 100, otherwise you'll end up rendering an especially tiny chart.

The contextual alternates feature (calt) is baked into OpenType and Sparks simply leverages this feature in an unconventional way. It takes strings like 123{30,60,90}456 and outputs a sparkline. The example of 123{30,60,90}456 would have with three datapoints of 30, 60, and 90 framed by 123 and 456. Spaces after the commas will prevent the numbers from being transformed. Numbers outside of the brackets are never transformed.

Using Sparks

On the web

When using Sparks as a webfont you may wish to explicitly enable the calt feature. Contextual ligatures are enabled by default in most modern browsers but in order to support older browsers you can use the following CSS (example pilfered from Adobe's Syntax for OpenType features in CSS page):

.yourClass {
  font-variant-ligatures: contextual;
  -moz-font-feature-settings: "calt";
  -webkit-font-feature-settings: "calt";
  font-feature-settings: "calt";
}

For more on this see the example code in the tests folder.

In MS Word

If you are using MS Word you need to enable the "Use Contextual Alternates" feature for it to be able to draw the sparklines. You can do that simply by heading to "Format > Font > Advanced" and enabling it.

In Adobe Illustrator

Turn on contextual alternates from the OpenType panel menu (Window > Type > OpenType). Here's a screenshot.

In Adobe InDesign

Sometimes contextual alternates are activated by default and sometimes they are not. We have no idea why. Use the OpenType menu to make sure they are turned on, which can be found in the options menu of the character palette (Character > Options > OpenType > Contextual Alternates). Here's a screenshot.

How it works: the OpenType code

Inside the font files the code that powers the replacement operation for the bar and dot variations works like this:

feature calt {

  ignore sub zero' comma space;
  sub braceleft' zero' braceright' by chart.000;
  sub braceleft' zero' comma' by chart.000;
  sub zero' comma' by chart.000;
  sub zero' braceright' by chart.000;

} calt;

while the code for the dot-line variation is a bit more complicated, and looks sort of like this:

@theDots [ dot.000 dot.001 ... dot.100 ];
@linesTo000 [ line.000.000 line.001.000 ... line.100.000 ];
# 100 more those classes, one for each possible position.

feature calt {

  lookup dotsIgnore {
    ignore sub zero' comma space;
    # ... repeat for all 100 other numbers.
  } dotsIgnore;

  lookup DotsSolo {
    sub braceleft' zero' braceright' by dot.100;
    # ... repeat for all 100 other numbers.
  } dotsSolo;

  lookup dotsInitial {
    sub braceleft' zero' comma' by dot.000;
    # ... repeat for all 100 other numbers.
  } dotsInitial;

  lookup dotsMiddle {
    sub zero' comma' by dot.000;
    # ... repeat for all 100 other numbers.
  } dotsMiddle;

  lookup dotsFinal {
    sub zero' braceright' by dot.000;
    # ... repeat for all 100 other numbers.
  } dotsFinal;

  lookup linesAll {
    sub @theDots' dot.000 by @linesTo000;
    # ... repeat for all 100 other positions.
  } linesAll;

} calt;

In theory the dot-line variation could be just like the bar and dot variations with only a single round of glyph substitutions, however because the dot-line fonts are plotting connections rather than single positions you would end up with many lines of code (almost 11k). Fine in the abstract, but it turns out that OpenType has a limit for how many lines of code can be in a single lookup table (around 3k – everything in a lookup table has to fit into 16 bits, because reasons), so compilation fails. There are definitely many ways around this, but it is a headache. The dot-line version sorts the problem by

  • first setting up classes for both the dots and the lines
  • then substituting numbers for the appropriate dot glyph (just like in the bar and dot variants, however here the sequence is a lot more important)
  • and finally substituting the first of every pair of dots with the appropriate line

This works because OpenType substitution is a linear process in which each rule reads the output of the previous rule, so you can chain substitutions. (So many caveats to that statement, but that's a story for another day. For more information on how weird OpenType glyph substitution is check out this amazing blogpost.)


About us

After the flood is a design consultancy based in London. We work with global corporations like Google, Nikkei and Ford to solve business problems that combine our understanding of AI and data as a material with unique user insight. Our consulting model means guaranteed access to our top team. Our approach is user-centred and lean, showing progress to clients and working with a variety of expert partners.

License

Sparks has been distributed under the SIL Open Font License.

sparks's People

Contributors

kubami avatar michaelgallagher avatar ryan-copperleaf avatar tomgp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sparks's Issues

admitted values

It seems to me that bar chart and dot-line chart allow only integer values between 0 and 100 and between 0 and 10, respectively, while other numbers are not recognized.
Am I right? Is this documented somewhere?

Add examples

This seems pretty sweet! I'd love if you could add some example images (and how-to usage code snippets) in the README.md.

Sparks files

Hi everyone, the hosted link Sparks is down, so here's an alternate link to download the font.

Thanks so much for all your hard work, and good luck with your future projects!
AtF Spark.zip

Inkscape & Scribus support?

Inkscape only offers the "Normal" weight but can render it. Is this a bug with Inkscape 0.92.2 ?

image

Scribus is able to detect all styles but does not seem to render them. is that a bug in Scribus 1.4.6 ?

image

Licensing

I might be interested in packaging this for my Linux distribution, but I'm not sure under what license I am allowed to redistribute it? "Free to use and modify" is a bit vague.

Empty sparklines

Right, when you don't have any items between brackets, the brackets themselves are rendered. It'd be nice if {} act like an empty space, maybe? This way we don't have to wrap/check for empty lists.

Rendering numbers with decimals

Using Illustrator 2018, I have a set of numbers with decimals. {33.6,35.7,37.4}

Instead of creating the graph, it creates a small square where the decimal is, and a dot for the number that is after the decimal. Did I miss something or is it just the font limitation? Thanks!

screen shot 2018-06-25 at 3 34 54 pm

Does not work in Adobe Illustrator

Thank you for this great tool. The README said these fonts will work with Illustrator. However, when I installed and tried Spark in my AI file, nothing happens.

Am I doing something wrong?

Use the full height to draw sparklines

I know very little about typography, so bear with me. I'm looking to use this font instead of the Unicode block characters (▁▂▃▄▅▆▇█), and in comparing them, I'm finding that they don't line up. Here's an example of what I'm talking about: https://codepen.io/anon/pen/QaxXGj?editors=1100 (spark bar medium font on the left, Unicode blocks on the right)

spark font height

I realize that this is more of an artistic decision, given that these are supposed to be used inline with other text, but perhaps there can be an alternative version that uses the full height?

Does work in Word 2010

Thanks for the great tool!
I tried using AtF Spark in Word 2010 after turning on contextual alternates: it doesn't work.
In the readme, I've noted that it works in Word 2011.
Is the fact that it's not working in Word 2010 related to Word 2010 or to the current definition of the font?

line-medium broken on web pages

Every other font seems to be working beautifully but for some reason .spark-line-medium breaks (see screenshot).

spark-line-medium-screenshot

CSS:
.spark-line-medium { font-family: "spark-line-medium"; letter-spacing: 0em; }

Provide some examples

Please provide some examples with images how your sparklines look like. Also placing a link to wikipedia wouldn't hurt either. I did not know what sparklines are and your readme does not lift this confusion.

Regular text corrupted in Word 2016

The contextual alternatives are working, but the regular text is not. Any ideas?

image

Microsoft Office 365 ProPlus
Version 1609
Word 2016 MSO (16.0.7329.1054) 32-bit

Add gif/image to README and link to site

Thanks for the awesome project!

I think the majority of the people who first stumble upon this font are interested in seeing it before reading about it. When I opened the repo I scanned the README for demo images and when I didn't find any I wanted to check out the site but there wasn't any link in the top of the repo (where they usually are).

Because there already are demo images in the site, adding it to the readme (and also the website link to the top of the repo) would take less than a minute.

Thanks

Dot-line medium broken in Apple Pages

All styles seem to work well in Apple Pages except Dot-line medium. This may be an Apple problem, but thought I'd report it in case there's anything that can be done.

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.