Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix typos #31

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions FontyFruity.cabal
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
-- Initial FontyFruity.cabal generated by cabal init. For further
-- documentation, see http://haskell.org/cabal/users-guide/
-- documentation, see https://haskell.org/cabal/users-guide/

name: FontyFruity
version: 0.5.3.5
synopsis: A true type file format loader
description:
An haskell Truetype file parser.
An haskell TrueType file parser.
.
You can load a font file and extract some curves to be
drawed with a library like Rasterific .
drawn with a library like Rasterific .
license: BSD3
license-file: LICENSE
author: Vincent Berthoux
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FontyFruity
===========

[![Hackage](https://img.shields.io/hackage/v/FontyFruity.svg)](http://hackage.haskell.org/package/FontyFruity)
[![Hackage](https://img.shields.io/hackage/v/FontyFruity.svg)](https://hackage.haskell.org/package/FontyFruity)

An haskell Truetype file parser.
An haskell TrueType file parser.

You can load a font file and extract some curves
to be drawn with a library like [Rasterific](https://github.com/Twinside/Rasterific) .
Expand Down
4 changes: 2 additions & 2 deletions changelog
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ v0.5.3.4 September 2018
* Fix: GHC 8.6.1 compat

v0.5.3.3 June 2017
* Fix: Composite glyph positionning (patch from hsyl20)
* Fix: Composite glyph positioning (patch from hsyl20)
* Fix: glyph lookup (patch from hsyl20)

v0.5.3.2 May 2016
Expand All @@ -17,7 +17,7 @@ v0.5.3.2 May 2016
v0.5.3(.1) February 2016
* Fix: bug when trying to scan a directory
* Addition: exposing descriptorOf function
* Enhancement: Made FontDescriptor strictier.
* Enhancement: Made FontDescriptor stricter.

v0.5.2 August 2015
* Fix: GHC 7.4 compilation
Expand Down
24 changes: 12 additions & 12 deletions src/Graphics/Text/TrueType.hs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ getFontNameAndStyle =
where
isNecessaryForName v = v == "name" || v == "head"

-- | This function will search in the system for truetype
-- | This function will search in the system for TrueType
-- files and index them in a cache for further fast search.
buildCache :: IO FontCache
buildCache = buildFontCache loader
Expand Down Expand Up @@ -285,7 +285,7 @@ pixelSizeInPointAtDpi pixelSize dpi =

glyphOfStrings :: Font -> String -> [(Glyph, HorizontalMetric)]
glyphOfStrings Font { _fontMap = Just mapping
, _fontGlyph = Just glyphes
, _fontGlyph = Just glyphs
, _fontKerning = Just kernPairs
, _fontHorizontalMetrics = Just hmtx } str =
fetcher <$> glyphIndexPairs
Expand All @@ -295,7 +295,7 @@ glyphOfStrings Font { _fontMap = Just mapping
kerning l r = getKerningValue (fromIntegral l) (fromIntegral r) kernPairs
kern l r m = m { _hmtxAdvanceWidth = _hmtxAdvanceWidth m + kerning l r }
metrics = _glyphMetrics hmtx
fetcher (l, r) = (glyphes V.! l, kern l r (metrics V.! l))
fetcher (l, r) = (glyphs V.! l, kern l r (metrics V.! l))
glyphOfStrings _ _ = []

-- | Return the number of pixels relative to the point size.
Expand Down Expand Up @@ -349,15 +349,15 @@ getStringCurveAtPoint :: Dpi -- ^ Dot per inch of the output.
-> (Float, Float) -- ^ Initial position of the baseline.
-> [(Font, PointSize, String)] -- ^ Text to draw
-> [[VU.Vector (Float, Float)]] -- ^ List of contours for each char
getStringCurveAtPoint dpi initPos lst = snd $ mapAccumL go initPos glyphes where
glyphes = concat [(font, size,)
getStringCurveAtPoint dpi initPos lst = snd $ mapAccumL go initPos glyphs where
glyphs = concat [(font, size,)
<$> glyphOfStrings font str | (font, size, str) <- lst]

toPixel (font, pointSize, _) = toPixelCoord font pointSize dpi
toCoord (font, pointSize, _) = toFCoord font pointSize dpi

maximumSize = maximum [ toPixel p . _glfYMax $ _glyphHeader glyph
| p@(_, _, (glyph, _)) <- glyphes ]
| p@(_, _, (glyph, _)) <- glyphs ]

go (xf, yf) p@(font, pointSize, (glyph, metric)) = ((toPixel p $ xi + advance, yf), curves)
where
Expand All @@ -373,16 +373,16 @@ getStringCurveAtPoint dpi initPos lst = snd $ mapAccumL go initPos glyphes where
-- the glyph geometry for further external manipulation.
getGlyphForStrings :: Dpi -> [(Font, PointSize, String)]
-> [[VU.Vector (Float, Float)]]
getGlyphForStrings dpi lst = go <$> glyphes where
glyphes = concat
getGlyphForStrings dpi lst = go <$> glyphs where
glyphs = concat
[(font, size,) <$> glyphOfStrings font str | (font, size, str) <- lst]

toCoord (font, pointSize, _) = toFCoord font pointSize dpi

maximumSize :: Float
maximumSize =
maximum [ toPixelCoord font pointSize dpi . _glfYMax $ _glyphHeader glyph
| (font, pointSize, (glyph, _)) <- glyphes ]
| (font, pointSize, (glyph, _)) <- glyphs ]

go p@(font, pointSize, (glyph, _metric)) =
getGlyphIndexCurvesAtPointSizeAndPos
Expand Down Expand Up @@ -469,7 +469,7 @@ isPlaceholder Font { _fontMap = Just fontMap } character =
findCharGlyph fontMap 0 character == 0
isPlaceholder Font { _fontMap = Nothing } _ = True

-- | Retrive the glyph contours and associated transformations.
-- | Retrieve the glyph contours and associated transformations.
-- The coordinate system is assumed to be the TTF one (y upward).
-- No transformation is performed.
getCharacterGlyphsAndMetrics :: Font
Expand Down Expand Up @@ -513,8 +513,8 @@ getCharacterGlyphs allGlyphs allMetrics glyphIndex =
case _glyphContent (allGlyphs V.! glyphIndex) of
GlyphEmpty -> mempty
GlyphComposite compositions _ -> V.concatMap expandComposition compositions
GlyphSimple countour ->
V.singleton . RawGlyph mempty glyphIndex $ extractFlatOutline countour
GlyphSimple contour ->
V.singleton . RawGlyph mempty glyphIndex $ extractFlatOutline contour
where
recurse = getCharacterGlyphs allGlyphs allMetrics

Expand Down
2 changes: 1 addition & 1 deletion src/Graphics/Text/TrueType/Bytecode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ evaluate instrs =
byteExec (IfElse thenBody _) (_:stack) = byteExec (thenBody ++ instr) stack
byteExec (Function functionBody : instr) (id:stack) =
modify (\s -> s { _stFunctions = M.add id functionBody }) >> byteExec instr stack
byteExec (Sequence intructions : rest) stack = go instructions stack >>= byteExec rest
byteExec (Sequence instructions : rest) stack = go instructions stack >>= byteExec rest

#endif

2 changes: 1 addition & 1 deletion src/Graphics/Text/TrueType/CharacterMap.hs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ instance Binary CharacterMaps where
startIndex <- bytesRead
versionNumber <- getWord16be
when (versionNumber /= 0)
(fail "Characte map - invalid version number")
(fail "Character map - invalid version number")
tableCount <- fromIntegral <$> getWord16be
let descFetcher = (,,) <$> get <*> getWord16be <*> getWord32be
third (_, _, t) = t
Expand Down
2 changes: 1 addition & 1 deletion src/Graphics/Text/TrueType/FontFolders.hs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ instance Binary FontDescriptor where
--
-- FontCache is an instance of binary, to get okish
-- performance you should save it in a file somewhere
-- instead of rebuilding it everytime!
-- instead of rebuilding it every time!
--
-- The font cache is dependent on the version
-- of rasterific, you must rebuild it for every
Expand Down
2 changes: 1 addition & 1 deletion src/Graphics/Text/TrueType/FontType.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import Graphics.Text.TrueType.Name

-- | Type representing a font.
data Font = Font
{ -- | Field discribing various offsets/positions of table
{ -- | Field describing various offsets/positions of table
-- inside the font file. Not available for reading.
_fontOffsetTable :: !OffsetTable
, _fontTables :: ![(B.ByteString, B.ByteString)]
Expand Down
12 changes: 6 additions & 6 deletions src/Graphics/Text/TrueType/LanguageIds.hs
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ data MacPlatformId
| MacSpecificUninterpreted
deriving (Eq, Ord, Show)

macSpecifcIdList :: [MacPlatformId]
macSpecifcIdList =
macSpecificIdList :: [MacPlatformId]
macSpecificIdList =
[ MacSpecificRoman, MacSpecificJapanese, MacSpecificChineseTraditional
, MacSpecificKorean, MacSpecificArabic, MacSpecificHebrew
, MacSpecificGreek, MacSpecificRussian, MacSpecificRSymbol
Expand All @@ -154,19 +154,19 @@ prepareSpecificMaps lst = (toWord, toPlatform)
toWord = M.fromList $ zip lst [0 ..]
toPlatform = M.fromList $ zip [0 ..] lst

mapSpecifcIdMaps :: ( M.Map MacPlatformId Word16
mapSpecificIdMaps :: ( M.Map MacPlatformId Word16
, M.Map Word16 MacPlatformId )
mapSpecifcIdMaps = prepareSpecificMaps macSpecifcIdList
mapSpecificIdMaps = prepareSpecificMaps macSpecificIdList

instance Binary MacPlatformId where
get = finder <$> getWord16be
where
(_, to) = mapSpecifcIdMaps
(_, to) = mapSpecificIdMaps
finder v = M.findWithDefault MacSpecificUninterpreted v to

put v = putWord16be val
where
(from, _) = mapSpecifcIdMaps
(from, _) = mapSpecificIdMaps
val = M.findWithDefault 32 v from

data MacLanguage
Expand Down
10 changes: 5 additions & 5 deletions src/Graphics/Text/TrueType/Name.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ instance Binary NameTable where
return . NameTable . V.fromListN (fromIntegral count) $ map fetcher records

data NameRecords = NameRecords
{ _nrPlatoformId :: {-# UNPACK #-} !Word16
{ _nrPlatformId :: {-# UNPACK #-} !Word16
, _nrPlatformSpecificId :: {-# UNPACK #-} !Word16
, _nrLanguageId :: {-# UNPACK #-} !Word16
, _nrNameId :: {-# UNPACK #-} !Word16
Expand Down Expand Up @@ -85,19 +85,19 @@ fontFamilyName (NameTable { _ntRecords = records }) =
platformToWord PlatformWindows
selectorWin0 r =
_nrNameId r == fontFamilyId &&
_nrPlatoformId r == windowsPlatform &&
_nrPlatformId r == windowsPlatform &&
_nrPlatformSpecificId r == 0

selectorWin1 r =
_nrNameId r == fontFamilyId &&
_nrPlatoformId r == windowsPlatform &&
_nrPlatformId r == windowsPlatform &&
_nrPlatformSpecificId r == 1

macPlatform =
platformToWord PlatformMacintosh
selectorMac r =
_nrNameId r == fontFamilyId &&
_nrPlatoformId r == macPlatform &&
_nrPlatformId r == macPlatform &&
_nrPlatformSpecificId r == 0

unicodePlatform =
Expand All @@ -106,7 +106,7 @@ fontFamilyName (NameTable { _ntRecords = records }) =
unicodePlatformSpecificToId UnicodeBMPOnly2_0
selectorUnicode r =
_nrNameId r == fontFamilyId &&
_nrPlatoformId r == unicodePlatform &&
_nrPlatformId r == unicodePlatform &&
_nrPlatformSpecificId r == semanticUnicode2

instance Binary NameRecords where
Expand Down