SVGFonts-1.0: Fonts from the SVG-Font format

Graphics.SVGFonts.RasterFont

Synopsis

Documentation

commandsToRasterPoints :: [PathCommand] -> F2 -> F2 -> [[F2P]]Source

Convert path-commands to outline points, which consist of bitmaps (resolution 16x16) of lines that go through the pixel (subpixel rasterization)

bitmasks :: (X, Y) -> [F2] -> [F2P]Source

Every tuple of consecutive outline points builds a line that is rasterized and cut into little bitmasks

line :: Int -> Int -> (Int, Int) -> (Int, Int) -> UArray (Int, Int) Word16Source

Bresenham line algorithm, adjusted to produce only one y value per row The data structure for the line is a 2d array of bits, in x-direction a sequence of word16s nx,ny are the size as multiples of 16, draw line from (xa, ya) to (xb, yb)

bitmask :: Int -> Int -> UArray (Int, Int) Word16 -> BitmaskSource

Slice out a single bitmask from an array of bitmasks (this should be an unboxed array of unboxed arrays, but since this is not so easy in Haskell, one 2d-array with a supersampled y-coordinate (*16) is used) the x-supersampling are the bits in the Word16

borderToTex :: (Int, Int) -> [(Int, Int, Bitmask)] -> (V4, V4) -> TGADataSource

Border points to texture

sortSpans :: [(Int, Int, Bitmask)] -> [(Int, Int, Bitmask)]Source

Sorting so that the lowest y comes first, equal ys then the lowest x comes first

overlaps :: [(Int, Int, Bitmask)] -> [(Int, Int, Bitmask)]Source

Assuming the list of bitmasks is sorted, two consecutive bitmasks can be on the same position this happens if a line ends in pixel and a new line starts in the same pixel

orBm :: Bitmask -> Bitmask -> BitmaskSource

Bitwise oring two Bitmasks

fillSpans :: (Int, Int) -> [(Int, Int, Bitmask)] -> ByteStringSource

Fill a bitmask with 1s if the bit/subpixel is inside a polygon, (the bitmask was filled before with subpixels of outline drawing of the polygon). The bitmask is an array of 16 word16 where the x-direction are the bit position in the word16s. Horizontal(x-direction) lines are drawn if the line is inside the polygon, called a span (see Jordan curve theorem). A subpixel marks the beginnig or the end of a span depending on the state of the line. At the beginning all lines are white, if one intersects a subpixel it becomes black until it hits a subpixel again. The states at the end of the lines are stored for the next pixel in fillSpans. If these state bits are all one or all zero and the next bitmask is completely zero then fewer calculations need to be done.

fillBitmask :: Bitmask -> Word16 -> BitmaskSource

Assuming a single line passes through a Bitmask, set all points right to this line to 1

bitSum :: Bitmask -> Word16Source

The sum of all bits in a Bitmask, 16 rows with 16 bits each => between 0 and 255

endBits :: Bitmask -> Word16Source

Return the the rightmost column of a bitmask

bits :: Word16 -> Word16Source

Count the number of 1-bits with divide and conquer it can be done a little bit faster, but for the beginning it should just be correct see Hacker's Delight by Henry S. Warren, Addison Wesley for bit counting fst line: starting to count the 1's in 2-tuples: 0x55 = 01010101 2nd line: 4 tuples: 0x33 = 0011001100

showBits :: Word16 -> StringSource

Show a binary representation of a Word16

createTexture :: (Int, Int) -> TGAData -> String -> IO (TextureObject, String)Source

OpenGL specific texture

type F2P = (X, Y, AA)Source

data AA Source

Constructors

NB

No Bitmask

B Bitmask 

Instances

type BitmaskSource

Arguments

 = UArray Int Word16

A Bitmask contains 256 values: An Array of 16 Word16

ftrace :: String -> a -> aSource

Like trace from Debug.Trace but into a file