Coder Social home page Coder Social logo

typegauge's Introduction

TYPEGAUGE
=========

Docs for Version 0.1

TypeGauge is a gem providing a very basic class that tries to guess whether a given input string represents a legitimate description of a dimension of a typeface. It knows about quite a few of the traditional names for type sizes (currently based entirely on http://en.wikipedia.org/wiki/Point_(typography)#Traditional_point-size_names).

It can be used on the type size and the line height; you might find it useful for some other measurement related to page layout.

If it's not happy it has three moderately descriptive errors which can be incorporated into code. My initial use case was as part of the validation process for a model and I wanted users to have some idea of what was wrong with their input.

If it's happy nothing much happens -- there isn't (yet) a public method for asking for a cleaned-up version of the string.

You can get a TypeGauge object to tell you the units in which the input value was supplied and you can convert its size to mm or to points (2 decimal places), which could be useful for sorting a number of measurements.

tg = TypeGauge.new('12 didot')
tg.unit => :didot
tg.to_mm => 4.5108
tg.to_point => 12.83


Let me know if you find it useful.


require 'future'
---------------

I would like to handle the case where there a single 'traditional' name maps to more than one 'modern' type size better. I can imagine a way, but for now I've simply left symbols that somebody might use (:uk, :us) in the TRADITIONAL_NAMES array. There is only one case at the moment but I am sure more will emerge from the typeracks...

It would be nice to convert 'modern' type sizes to traditional names. There are more ambiguities going that way.


Old iron[y]
-----------

I see nothing incongruous in writing software that is entirely dedicated to the measuring systems of a redundant technology such as letterpress. It makes me feel better :)


Ben Weiner

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.