SVG-Fonts-0.4 released on Hackage

This library has been laying around in an unusable state on my harddrive for a long time, but now it is finally good enough to be used. In contrast to a lot of graphics libraries on Hackage it is not a binding. That means there were a lot of algorithms that had to be implemented. Although Haskell is often propagated as a language to write correct programs, algorithmic errors are as common as in other languages, because they cannot be catched by the type system. Debug.Trace, debugging with ghci is no alternative because they have no visual output and a list of hundred of floats is not helpful. In the future I plan to have a visual debugger for this.

But it works now. The interface should be easy to integrate into other libraries. Take a look at the following example:

main = do
  args <- getArgs
  let str = if null args then "Haskell" else head args
      resolution = (300, 300)
-- mode: INSIDE_V1_V2: the string is inside v1 v2 boundaries (height/length-relation not kept)
-- mode: INSIDE_V1: stay inside v1 boundary, size of v2 adjusted to height/length-relation
-- mode: INSIDE_V2: stay inside v2 boundary, size of v1 adjusted to height/length-relation
      mode = INSIDE_V2
-- spacing: MONO: Use mono spacing between glyphs
--          HADV: Every glyph has a unique constant horiz. advance
--          KERN: Same as HADV but sometimes overridden by kerning: i.e. the horizontal advance
--                in "VV" is bigger than in "VA"
      spacing = HADV
      gaw = makeOutlMap "../../../src/Test/GirlsareWeird.svg" resolution
      lin = makeOutlMap "../../../src/Test/LinLibertine.svg" resolution
      o = (0,0,1.1) -- origin
      v1 = (5,0,0) -- direction of char-advance
      v2 = (0,0,-1) -- height direction
      v3 = (0,0.2,0) -- extrusion

      f :: String -> [String]  -- assigning a property to every character by a unique string
      f str = replicate (length str) "p"
                              -- data CharProp = Prop (FontData, OutlineMap) String Textured
      prop :: Map.Map String CharProp
      prop = Map.fromList [("p", Prop lin "to3d" False)]
      -- transformation of a Geoemtry Node (i.e. triangulation)
      transf :: Map.Map String (Geometry -> Geometry)
      transf = Map.fromList [("to3d", to3d)]
      -- to3d: not the perfect solution since some points are generated twice
      to3d geom = ( ((extrude (0,0.1,0)).deleteHoles) geom ) `atop`
                    ( tri (translate (0,0.1,0) geom) )
      tri = (triangulate ketTri).deleteHoles

      tex = makeTexMap resolution prop transf
      node = displayString str "node" resolution prop transf mode spacing o v1 v2 f tex

  genCollada (lightedScene node) emptyAnim
  putStrLn "Collada File generated"

Line 30 shows that a integration into a drawing combinator library seems to be reasonable. I am a little bit proud that this library is lot smaller than freetype2 (something around 100KB against 4000KB)
and the only things that it cannot do (yet!) is Rastered Images, Autohinting, Unicode, and the big amount of file formats supported by freetype2.
Another difference is that the library consists of several small parts that can be used in many other places while a lot of C-libraries tend to be monolithic (like freetype2).
I have to admit that parsing ttf and the other formats is maybe more work then the what has been done so far.
Thanks to the developers of Blender who fixed a bug I described it is possible to load this file into Blender to generate a raytraced picture:

Example Rendering with Blender



GSoC proposal

A few days ago I made a short proposal for a GSoC project: trac

I hope to explain a little bit better why a 3d user interface for hackage is desirable und how to do it. Chrome, Firefox and Webkit (Apple) now support WebGL meaning that the following pictures should roughly be possible inside a browser:

A picture from a motorola campaign

A picture produced by the company gamr7: http://www.gamr7.com (with modifications)

The second picture was modified to illustrate the potential of visualization. The yellow lines show code and dependencies. Similar things have been done by others (I had this idea on my own): codecity . I want to do this in a very general way. I was able to convince the advisor of my diploma thesis to let me do half of it about visualization of flow networks. This was hard but he finally agreed (maybe because Haskell programmers are rare and he had a plan to translate flow networks into Haskell). In the visualization part I layed foundations to make a visualization like the above. I use symmetry classes (based on the book “the symmetries of things” ) and a way to produce smallest deviations of symmetry.

In what ways will this project benefit the wider Haskell community?  

At the end of the 3 month period:

  • The visualization will let programmers quicker find a library they need (see changes, etc. ), because the visualization algorithm is like reversed pattern recognition to produce most recognizable shapes.
  • The code size, popularity, dependencies, whatever the community demands can be integrated or left away
  • A general way to extend or change the visualization

=> Haskell could have an impressive package repository.

The people who implement WebGL in Browsers (like Google) could have a poster child application

After GSoC:

  • A framework could emerge that lets you show visualizations near to the library, the code, the code-line. This allows more freedom than opening a separate graphics window. I.e. it could be helpful sometimes to see how example data is transformed by a function
  • A visualization of data structures could be on the channels of flow networks as a first step and help debugging programs. I personally would enjoy it if I could find the bug in the triangulation algorithm of one of my libraries. That is very hard with a command line
  • Having an alternative to bindings to UI-libraries

What deliverables do you think are reasonable targets? Can you outline an approximate schedule of milestones?

Milestone 1

  • Change Sourcegraph to parse all libraries (not only one), the result should be a big graph of all code
  • Experiment with a spring layout for the placement of libraries. The springs could be dependencies
  • Maybe somewhere in the hierarchy Graphviz could be used for the layout: Convert the graph with Graphviz and parse the annotated dot files with language-dot
  • A data structure is generated from various data sources and then transformed into a collada file with my library collada-output

Milestone 2

  • Use a WebGL engine to display the collada file. The problems here are most likely the picking, zooming and following of a link
  • Integration into Hackage2 as an optinal link
  • Helping to finish Hackage2
  • Documentation, everything I have forgot

Why do you think you would be the best person to tackle this project?

I did the relevant libraries to prepare this, among it a library that is a complete reprogramming of Freetype2 (as mentioned above it is hard to find algorithmic errors). Other people who did shape generation (also here in the Haskell community) haven’t considered symmetry as thorougly as me. Maybe Cabal and GHC are more important but this visualization project could in the long term help to understand Cabal and GHC and there is also a lot to do.

Follow

Get every new post delivered to your Inbox.