diagrams / SVGFonts

Fonts from the SVG-Font format
http://hackage.haskell.org/package/SVGFonts
Other
20 stars 12 forks source link

Ligatures for Hasklig #25

Open tonyday567 opened 6 years ago

tonyday567 commented 6 years ago

I followed the instructions for converting a font to SVG for the Hasklig font, specifically Hasklig-Regular.otf that was part of the 1.1 release downloadable from here.

The method worked well but, alas, there were no ligature effects. Code to reproduce:

import qualified Data.Text.Lazy.IO as Text
import Graphics.Text
import Diagrams.Backend.SVG
import qualified Diagrams.Prelude as D
import Graphics.SVGFonts

toSvg = D.renderDia SVG (SVGOptions (D.mkSizeSpec (D.V2 (Just 600) (Just 400))) Nothing "id" [] True)

toFile f = Text.writeFile f . prettyText

toDia f = textSVG_ (TextOpts f INSIDE_H KERN False 0.1 0.1)

main = do
  font <- loadFont "other/Hasklig-Regular.svg"
  toFile "example.svg" . toSvg . toDia font $ "0123 <* <*> <$> <| |> <|> <> <- -> => >>= =<< :: ++ /= =="

Any thoughts?

Tony

tkvogt commented 6 years ago

It seems fontforge doesn't generate any ligatures from the otf file.

ygale commented 4 years ago

When converting to an SVG font, FontForge doesn't include glyphs that are constructed using code. For example, if the font constructs ligatures by assembling them from shared fragments, they won't show up in the SVG font. You'll only get ligatures that are fully specified with their own outline graphics. I'm guessing that's what happened here.

However, you do get all the fragments. They appear in the SVG font as glyphs that are not bound to any Unicode sequence. Perhaps you can figure out how to assemble them yourself using diagrams code.