~jaro/balkon

7a0c775ef33b7238228cd6583c18a447cddfe186 — Jaro 1 year, 8 months ago 84f9c76
Rename golden files for easier tracking.
30 files changed, 37 insertions(+), 51 deletions(-)

M .gitignore
R .golden/{loremIpsum20emPaginated/golden => paginatedParagraphLayout/loremIpsum20em.golden}
R .golden/{spannedArabicFiller20emPaginated/golden => paginatedParagraphLayout/spannedArabicFiller20em.golden}
R .golden/{arabicFiller20em/golden => paragraphLayout/arabicFiller20em.golden}
R .golden/{czechHelloParagraph/golden => paragraphLayout/czechHello.golden}
R .golden/{czechHelloParagraphNarrow/golden => paragraphLayout/czechHelloParagraphNarrow.golden}
R .golden/{czechHelloParagraphUltraNarrow/golden => paragraphLayout/czechHelloParagraphUltraNarrow.golden}
R .golden/{devanagariParagraph/golden => paragraphLayout/devanagari.golden}
R .golden/{devanagariAccentParagraph/golden => paragraphLayout/devanagariAccent.golden}
R .golden/{devanagariPrefixedAccentParagraph/golden => paragraphLayout/devanagariPrefixedAccent.golden}
R .golden/{hardBreaksLTRParagraph/golden => paragraphLayout/hardBreaksLTR.golden}
R .golden/{hardBreaksRTLParagraph/golden => paragraphLayout/hardBreaksRTL.golden}
R .golden/{ligatureParagraph/golden => paragraphLayout/ligature.golden}
R .golden/{ligatureParagraphBreak1/golden => paragraphLayout/ligatureParagraphBreak1.golden}
R .golden/{ligatureParagraphBreak2/golden => paragraphLayout/ligatureParagraphBreak2.golden}
R .golden/{lineHeightLarger/golden => paragraphLayout/lineHeightLarger.golden}
R .golden/{lineHeightNormal/golden => paragraphLayout/lineHeightNormal.golden}
R .golden/{lineHeightSmaller/golden => paragraphLayout/lineHeightSmaller.golden}
R .golden/{loremIpsum100em/golden => paragraphLayout/loremIpsum100em.golden}
R .golden/{loremIpsum20em/golden => paragraphLayout/loremIpsum20em.golden}
R .golden/{manySpacesParagraph/golden => paragraphLayout/manySpaces.golden}
R .golden/{mixedLanguageLTRParagraph/golden => paragraphLayout/mixedLanguageLTR.golden}
R .golden/{mixedScriptWordsParagraph/golden => paragraphLayout/mixedScriptWords.golden}
R .golden/{spannedArabicFiller20em/golden => paragraphLayout/spannedArabicFiller20em.golden}
R .golden/{spannedLoremIpsum20em/golden => paragraphLayout/spannedLoremIpsum20em.golden}
R .golden/shapedRuns/{spannedLoremIpsum20em/fontInfo => spannedLoremIpsum20em.fontInfo}
R .golden/shapedRuns/{spannedLoremIpsum20em/golden => spannedLoremIpsum20em.golden}
M TESTING.md
M balkon.cabal
M test/Data/Text/ParagraphLayoutSpec.hs
M .gitignore => .gitignore +1 -0
@@ 1,3 1,4 @@
/dist/
/dist-newstyle/
/.golden/**/actual
/.golden/**/*.actual

R .golden/loremIpsum20emPaginated/golden => .golden/paginatedParagraphLayout/loremIpsum20em.golden +0 -0
R .golden/spannedArabicFiller20emPaginated/golden => .golden/paginatedParagraphLayout/spannedArabicFiller20em.golden +0 -0
R .golden/arabicFiller20em/golden => .golden/paragraphLayout/arabicFiller20em.golden +0 -0
R .golden/czechHelloParagraph/golden => .golden/paragraphLayout/czechHello.golden +0 -0
R .golden/czechHelloParagraphNarrow/golden => .golden/paragraphLayout/czechHelloParagraphNarrow.golden +0 -0
R .golden/czechHelloParagraphUltraNarrow/golden => .golden/paragraphLayout/czechHelloParagraphUltraNarrow.golden +0 -0
R .golden/devanagariParagraph/golden => .golden/paragraphLayout/devanagari.golden +0 -0
R .golden/devanagariAccentParagraph/golden => .golden/paragraphLayout/devanagariAccent.golden +0 -0
R .golden/devanagariPrefixedAccentParagraph/golden => .golden/paragraphLayout/devanagariPrefixedAccent.golden +0 -0
R .golden/hardBreaksLTRParagraph/golden => .golden/paragraphLayout/hardBreaksLTR.golden +0 -0
R .golden/hardBreaksRTLParagraph/golden => .golden/paragraphLayout/hardBreaksRTL.golden +0 -0
R .golden/ligatureParagraph/golden => .golden/paragraphLayout/ligature.golden +0 -0
R .golden/ligatureParagraphBreak1/golden => .golden/paragraphLayout/ligatureParagraphBreak1.golden +0 -0
R .golden/ligatureParagraphBreak2/golden => .golden/paragraphLayout/ligatureParagraphBreak2.golden +0 -0
R .golden/lineHeightLarger/golden => .golden/paragraphLayout/lineHeightLarger.golden +0 -0
R .golden/lineHeightNormal/golden => .golden/paragraphLayout/lineHeightNormal.golden +0 -0
R .golden/lineHeightSmaller/golden => .golden/paragraphLayout/lineHeightSmaller.golden +0 -0
R .golden/loremIpsum100em/golden => .golden/paragraphLayout/loremIpsum100em.golden +0 -0
R .golden/loremIpsum20em/golden => .golden/paragraphLayout/loremIpsum20em.golden +0 -0
R .golden/manySpacesParagraph/golden => .golden/paragraphLayout/manySpaces.golden +0 -0
R .golden/mixedLanguageLTRParagraph/golden => .golden/paragraphLayout/mixedLanguageLTR.golden +0 -0
R .golden/mixedScriptWordsParagraph/golden => .golden/paragraphLayout/mixedScriptWords.golden +0 -0
R .golden/spannedArabicFiller20em/golden => .golden/paragraphLayout/spannedArabicFiller20em.golden +0 -0
R .golden/spannedLoremIpsum20em/golden => .golden/paragraphLayout/spannedLoremIpsum20em.golden +0 -0
R .golden/shapedRuns/spannedLoremIpsum20em/fontInfo => .golden/shapedRuns/spannedLoremIpsum20em.fontInfo +0 -0
R .golden/shapedRuns/spannedLoremIpsum20em/golden => .golden/shapedRuns/spannedLoremIpsum20em.golden +0 -0
M TESTING.md => TESTING.md +5 -5
@@ 28,11 28,11 @@ Steps:

  4. Verify that `git status` reports no differences.

  5. Verify that a file named `actual` was generated by automated tests in
     the directory `.golden/shapedRuns/spannedLoremIpsum20em/`.
  5. Verify that a file named `spannedLoremIpsum20em.actual` was generated by
     automated tests in the directory `.golden/shapedRuns/`.

      - For example by running the command
        `ls -l .golden/shapedRuns/spannedLoremIpsum20em/actual`
        `ls -l .golden/shapedRuns/spannedLoremIpsum20em.actual`
        and checking the file's modification time.




@@ 54,9 54,9 @@ Steps:

  1. Run Typograffiti with the font path, face index, pixel size,
     and scale set according to the contents of the file
     `.golden/shapedRuns/spannedLoremIpsum20em/fontInfo` from Balkón,
     `.golden/shapedRuns/spannedLoremIpsum20em.fontInfo` from Balkón,
     and with input set to be read from the file
     `.golden/shapedRuns/spannedLoremIpsum20em/golden` from Balkón.
     `.golden/shapedRuns/spannedLoremIpsum20em.golden` from Balkón.

  2. Verify that text is displayed in the output window.


M balkon.cabal => balkon.cabal +2 -26
@@ 68,32 68,8 @@ extra-doc-files:
-- or a tutorial module.
extra-source-files:
    cabal.project,
    .golden/arabicFiller20em/golden,
    .golden/czechHelloParagraph/golden,
    .golden/czechHelloParagraphNarrow/golden,
    .golden/czechHelloParagraphUltraNarrow/golden,
    .golden/devanagariAccentParagraph/golden,
    .golden/devanagariParagraph/golden,
    .golden/devanagariPrefixedAccentParagraph/golden,
    .golden/hardBreaksLTRParagraph/golden,
    .golden/hardBreaksRTLParagraph/golden,
    .golden/ligatureParagraph/golden,
    .golden/ligatureParagraphBreak1/golden,
    .golden/ligatureParagraphBreak2/golden,
    .golden/lineHeightLarger/golden,
    .golden/lineHeightNormal/golden,
    .golden/lineHeightSmaller/golden,
    .golden/loremIpsum100em/golden,
    .golden/loremIpsum20em/golden,
    .golden/loremIpsum20emPaginated/golden,
    .golden/manySpacesParagraph/golden,
    .golden/mixedLanguageLTRParagraph/golden,
    .golden/mixedScriptWordsParagraph/golden,
    .golden/shapedRuns/spannedLoremIpsum20em/fontInfo,
    .golden/shapedRuns/spannedLoremIpsum20em/golden,
    .golden/spannedArabicFiller20em/golden,
    .golden/spannedArabicFiller20emPaginated/golden,
    .golden/spannedLoremIpsum20em/golden,
    .golden/**/*.fontInfo,
    .golden/**/*.golden,
    assets/fonts/plex/IBMPlexSansArabic-Regular.ttf,
    assets/fonts/plex/OFL.txt,
    assets/fonts/sarala/OFL.txt,

M test/Data/Text/ParagraphLayoutSpec.hs => test/Data/Text/ParagraphLayoutSpec.hs +29 -20
@@ 4,7 4,7 @@ import Data.Text.Glyphize (Font)

import Test.Hspec
import Test.Hspec.Golden
import System.FilePath ((</>))
import System.FilePath ((<.>), (</>))
import Data.Text.ParagraphLayout
import Data.Text.ParagraphLayout.FontLoader
import Data.Text.ParagraphLayout.Internal.Plain.ParagraphLayout


@@ 14,6 14,15 @@ import Data.Text.ParagraphLayout.Rect

type Page = (PageContinuity, ParagraphLayout)

goldenLayoutDir :: FilePath
goldenLayoutDir = ".golden" </> "paragraphLayout"

goldenPagesDir :: FilePath
goldenPagesDir = ".golden" </> "paginatedParagraphLayout"

goldenShapedRunsDir :: FilePath
goldenShapedRunsDir = ".golden" </> "shapedRuns"

class ShouldBeGolden a where
    shouldBeGolden :: a -> FilePath -> Golden a



@@ 23,8 32,8 @@ instance ShouldBeGolden ParagraphLayout where
        , encodePretty = show
        , writeToFile = \ path -> writeFile path . prettyShow
        , readFromFile = \ path -> readFile path >>= return . read
        , goldenFile = ".golden" </> name </> "golden"
        , actualFile = Just (".golden" </> name </> "actual")
        , goldenFile = goldenLayoutDir </> name <.> "golden"
        , actualFile = Just (goldenLayoutDir </> name <.> "actual")
        , failFirstTime = True
        }



@@ 34,8 43,8 @@ instance ShouldBeGolden Pages where
        , encodePretty = show . getPages
        , writeToFile = \ path -> writeFile path . prettyShow
        , readFromFile = \ path -> readFile path >>= return . Pages . read
        , goldenFile = ".golden" </> name </> "golden"
        , actualFile = Just (".golden" </> name </> "actual")
        , goldenFile = goldenPagesDir </> name <.> "golden"
        , actualFile = Just (goldenPagesDir </> name <.> "actual")
        , failFirstTime = True
        }



@@ 45,13 54,13 @@ instance ShouldBeGolden ShapedRuns where
        , encodePretty = show . getShapedRuns
        , writeToFile = \ path -> writeFile path . prettyShow
        , readFromFile = \ path -> readFile path >>= return . ShapedRuns . read
        , goldenFile = ".golden" </> "shapedRuns" </> name </> "golden"
        , actualFile = Just (".golden" </> "shapedRuns" </> name </> "actual")
        , goldenFile = goldenShapedRunsDir </> name <.> "golden"
        , actualFile = Just (goldenShapedRunsDir </> name <.> "actual")
        , failFirstTime = True
        }

fontInfoPath :: String -> FilePath
fontInfoPath name = ".golden" </> "shapedRuns" </> name </> "fontInfo"
fontInfoPath name = goldenShapedRunsDir </> name <.> "fontInfo"

shapedRuns' :: ParagraphLayout -> ShapedRuns
shapedRuns' = ShapedRuns . shapedRuns


@@ 112,7 121,7 @@ spec = do
            it "applies hard breaks correctly" $ do
                let opts = ParagraphOptions font Normal 6000
                let result = layoutPlain $ hardBreaksRTLParagraph opts
                result `shouldBeGolden` "hardBreaksRTLParagraph"
                result `shouldBeGolden` "hardBreaksRTL"

        describe "with Devanagari font" $ do
            font <- runIO $ loadFont devanagariFont 0 testingOptions


@@ 127,7 136,7 @@ spec = do
                    x_size (paragraphRect result) `shouldBe` 645

                it "is golden" $ do
                    result `shouldBeGolden` "devanagariAccentParagraph"
                    result `shouldBeGolden` "devanagariAccent"

            describe "lone accent character after prefix" $ do
                let


@@ 139,12 148,12 @@ spec = do
                    x_size (paragraphRect result) `shouldBe` 0

                it "is golden" $ do
                    result `shouldBeGolden` "devanagariPrefixedAccentParagraph"
                    result `shouldBeGolden` "devanagariPrefixedAccent"

            it "handles input without wrapping" $ do
                let opts = ParagraphOptions font Normal 9000
                let result = layoutPlain $ devanagariParagraph opts
                result `shouldBeGolden` "devanagariParagraph"
                result `shouldBeGolden` "devanagari"

        describe "with Latin font" $ do
            -- Note: This font does not contain Japanese glyphs.


@@ 163,12 172,12 @@ spec = do
            it "handles Czech hello" $ do
                let opts = ParagraphOptions font Normal 8000
                let result = layoutPlain $ czechHelloParagraph opts
                result `shouldBeGolden` "czechHelloParagraph"
                result `shouldBeGolden` "czechHello"

            it "renders an \"ffi\" ligature" $ do
                let opts = ParagraphOptions font Normal 8000
                let result = layoutPlain $ ligatureParagraph opts
                result `shouldBeGolden` "ligatureParagraph"
                result `shouldBeGolden` "ligature"

            it "breaks an \"ffi\" ligature into \"ff\" + \"i\"" $ do
                let opts = ParagraphOptions font Normal 2418


@@ 183,7 192,7 @@ spec = do
            it "handles mixed languages in LTR layout" $ do
                let opts = ParagraphOptions font Normal 8000
                let result = layoutPlain $ mixedLanguageLTRParagraph opts
                result `shouldBeGolden` "mixedLanguageLTRParagraph"
                result `shouldBeGolden` "mixedLanguageLTR"

            it "handles normal line height" $ do
                let opts = ParagraphOptions font Normal 8000


@@ 234,17 243,17 @@ spec = do
            it "wraps mixed-script words correctly" $ do
                let opts = ParagraphOptions font Normal 6000
                let result = layoutPlain $ mixedScriptWordsParagraph opts
                result `shouldBeGolden` "mixedScriptWordsParagraph"
                result `shouldBeGolden` "mixedScriptWords"

            it "trims spaces around lines" $ do
                let opts = ParagraphOptions font Normal 6000
                let result = layoutPlain $ manySpacesParagraph opts
                result `shouldBeGolden` "manySpacesParagraph"
                result `shouldBeGolden` "manySpaces"

            it "applies hard breaks correctly" $ do
                let opts = ParagraphOptions font Normal 5000
                let result = layoutPlain $ hardBreaksLTRParagraph opts
                result `shouldBeGolden` "hardBreaksLTRParagraph"
                result `shouldBeGolden` "hardBreaksLTR"

    describe "paginate" $ do



@@ 262,7 271,7 @@ spec = do
                        , pageWidows = 2
                        }
                    pages = paginateAll popts pl
                Pages pages `shouldBeGolden` "spannedArabicFiller20emPaginated"
                Pages pages `shouldBeGolden` "spannedArabicFiller20em"

        describe "with Latin font" $ do
            font <- runIO $ loadFont latinFont 0 testingOptions


@@ 278,7 287,7 @@ spec = do
                        , pageWidows = 3
                        }
                    pages = paginateAll popts pl
                Pages pages `shouldBeGolden` "loremIpsum20emPaginated"
                Pages pages `shouldBeGolden` "loremIpsum20em"

    describe "shaped runs for demo" $ do