~alcinnz/fontconfig-pure

866ea3d2d38b232014081d67c198a73620f1414c — Adrian Cochrane 1 year, 10 months ago 8abf298
Start implementing a seperate bridge module to Harfbuzz.
A fontconfig-harfbuzz/CHANGELOG.md => fontconfig-harfbuzz/CHANGELOG.md +5 -0
@@ 0,0 1,5 @@
# Revision history for fontconfig-harfbuzz

## 0.1.0.0 -- YYYY-mm-dd

* First version. Released on an unsuspecting world.

A fontconfig-harfbuzz/Data/Text/Glyphize/Choose.hs => fontconfig-harfbuzz/Data/Text/Glyphize/Choose.hs +23 -0
@@ 0,0 1,23 @@
module Data.Text.Glyphize.Choose where

import Data.Text.Glyphize (Font, createFace, createFontWithOptions,
                          Variation, FontOptions (..), defaultFontOptions)
import Graphics.Text.Font.Choose (Pattern, getValue0, getValue')
import qualified Data.ByteString as B

import System.IO.Unsafe (unsafePerformIO)

-- Warning: file-read sideeffect.
instantiatePattern :: Pattern -> [Variation] -> IO Font
instantiatePattern pat variations = createFontWithOptions options face
  where
    bytes = unsafePerformIO $ B.readFile $ getValue0 "file" pat
    face = createFace bytes $ fromMaybe 0 $ getValue' "index" pat
    options = foldl value2opt defaultFontOptions $ normalizePattern pat

    value2opt opts ("slant", (_, ValueInt x):_) = opts {optionSynthSlant = Just x}
    value2opt opts ("fontvariations", _:_) = opts {optionVariations = variations}
    value2opt opts ("size", (_, ValueDouble x):_) = opts {optionPtEm = Just x}
    value2opt opts ("pixelsize", (_, ValueDouble x):_) = opts {
        optionPPEm = Just (toEnum $ fromEnum x, toEnum $ fromEnum x)
      }

A fontconfig-harfbuzz/LICENSE => fontconfig-harfbuzz/LICENSE +20 -0
@@ 0,0 1,20 @@
Copyright (c) 2023 Adrian Cochrane

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

A fontconfig-harfbuzz/Setup.hs => fontconfig-harfbuzz/Setup.hs +2 -0
@@ 0,0 1,2 @@
import Distribution.Simple
main = defaultMain

R app/Main.hs => fontconfig-harfbuzz/app/Main.hs +1 -0
@@ 34,6 34,7 @@ main = do

    ft_With_FreeType $ \ft -> do
        inst <- instantiatePattern ft font (fromMaybe 12 $ getValue' "size" font, 20)
        let text = shape 

        displayCallback $= do
            clear [ ColorBuffer ]

A fontconfig-harfbuzz/fontconfig-harfbuzz.cabal => fontconfig-harfbuzz/fontconfig-harfbuzz.cabal +88 -0
@@ 0,0 1,88 @@
-- Initial fontconfig-harfbuzz.cabal generated by cabal init.  For further
-- documentation, see http://haskell.org/cabal/users-guide/

-- The name of the package.
name:                fontconfig-harfbuzz

-- The package version.  See the Haskell package versioning policy (PVP)
-- for standards guiding when and how versions should be incremented.
-- https://wiki.haskell.org/Package_versioning_policy
-- PVP summary:      +-+------- breaking API changes
--                   | | +----- non-breaking API additions
--                   | | | +--- code changes with no API change
version:             0.1.0.0

-- A short (one-line) description of the package.
synopsis:            Bridges from FontConfig to Harfbuzz.

-- A longer description of the package.
-- description:

-- The license under which the package is released.
license:             MIT

-- The file containing the license text.
license-file:        LICENSE

-- The package author(s).
author:              Adrian Cochrane

-- An email address to which users can send suggestions, bug reports, and
-- patches.
maintainer:          alcinnz@argonaut-constellation.org

-- A copyright notice.
-- copyright:

category:            Text

build-type:          Simple

-- Extra files to be distributed with the package, such as examples or a
-- README.
extra-source-files:  CHANGELOG.md

-- Constraint on the version of Cabal needed to build this package.
cabal-version:       >=1.10


library
  -- Modules exported by the library.
  -- exposed-modules:

  -- Modules included in this library but not exported.
  -- other-modules:

  -- LANGUAGE extensions used by modules in this package.
  -- other-extensions:

  -- Other library packages from which modules are imported.
  build-depends:       base >=4.12 && <4.13, fontconfig-pure, harfbuzz-pure

  -- Directories containing source files.
  hs-source-dirs:      .

  -- Base language which the package is written in.
  default-language:    Haskell2010


executable fontconfig-harfbuzz
  -- .hs or .lhs file containing the Main module.
  main-is:             Main.hs

  -- Modules included in this executable, other than Main.
  -- other-modules:

  -- LANGUAGE extensions used by modules in this package.
  -- other-extensions:

  -- Other library packages from which modules are imported.
  build-depends:       base >=4.12 && <4.13, typograffiti>=0.2, text, harfbuzz,
                        GLUT >= 2.7, gl, mtl, fontconfig-pure, freetype2

  -- Directories containing source files.
  hs-source-dirs:      app

  -- Base language which the package is written in.
  default-language:    Haskell2010


M fontconfig-pure.cabal => fontconfig-pure.cabal +0 -8
@@ 107,11 107,3 @@ test-suite test-fontconfig
  type: exitcode-stdio-1.0
  main-is: Test.hs
  build-depends: base >= 4.12 && <4.13, fontconfig-pure, hspec, QuickCheck

executable view-font
  main-is:             Main.hs
  build-depends:       base >=4.12 && <4.13, typograffiti>=0.2, text,
                        GLUT >= 2.7, gl, mtl, fontconfig-pure, freetype2
  hs-source-dirs:      app
  default-language:    Haskell2010