SVGFonts-0.4: src/Test/Fonts.hs
module Main where
import Graphics.SVGFonts.ReadFont (displayString, makeOutlMap, makeTexMap, Mode(..), Spacing(..), CharProp(..))
import Graphics.Formats.Collada.ColladaTypes (Geometry)
import Graphics.Formats.Collada.GenerateObjects (lightedScene, lightedSceneNode, emptyAnim)
import Graphics.Formats.Collada.GenerateCollada (genCollada)
import Graphics.Formats.Collada.Transformations (extrude, atop, translate)
import Graphics.Triangulation.Triangulation (triangulate, deleteHoles)
import Graphics.Triangulation.KETTriangulation (ketTri)
import qualified Data.Map as Map
import System.Environment
main = do
args <- getArgs
let str = if (length args)>0 then head args else "Haskell" -- ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
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"
prop :: Map.Map String CharProp -- data CharProp = Prop (FontData, OutlineMap) String Textured
prop = Map.fromList [("p", Prop lin "to3d" False)]
transf :: Map.Map String (Geometry -> Geometry) -- transformation of a Geoemtry Node (i.e. triangulation)
transf = Map.fromList [("to3d", to3d)]
to3d geom = ( ((extrude (0,0.1,0)).deleteHoles) geom ) `atop` ( tri (translate (0,0.1,0) geom) ) -- not the perfect solution since some points are generated twice
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"