~alcinnz/fontconfig-pure

ref: 484b1482a58e27db9fc806dd1d95b2e880b06a03 fontconfig-pure/lib/Graphics/Text/Font/Choose/Weight.hs -rw-r--r-- 1.5 KiB
484b1482 — Adrian Cochrane Test & fix langset comparisons. 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{-# LANGUAGE CApiFFI #-}
-- | Convert between OpenType & FontConfig weight scales.
module Graphics.Text.Font.Choose.Weight(weightFromOpenTypeDouble,
        weightToOpenTypeDouble, weightFromOpenType, weightToOpenType) where

-- | Returns an double value to use with FC_WEIGHT, from an double in the 1..1000 range,
-- resembling the numbers from OpenType specification's OS2 usWeight numbers,
-- which are also similar to CSS font-weight numbers.
-- If input is negative, zero, or greater than 1000, returns -1.
-- This function linearly interpolates between various FC_WEIGHT_* constants.
-- As such, the returned value does not necessarily match any of the predefined constants.
foreign import capi "fontconfig/fontconfig.h FcWeightFromOpenTypeDouble"
    weightFromOpenTypeDouble :: Double -> Double
-- | the inverse of FcWeightFromOpenType. If the input is less than FC_WEIGHT_THIN
-- or greater than FC_WEIGHT_EXTRABLACK, returns -1.
-- Otherwise returns a number in the range 1 to 1000.
foreign import capi "fontconfig/fontconfig.h FcWeightToOpenTypeDouble"
    weightToOpenTypeDouble :: Double -> Double
-- | Like weightFromOpenTypeDouble but with integer arguments. Use the other function instead.
foreign import capi "fontconfig/fontconfig.h FcWeightFromOpenType"
    weightFromOpenType :: Int -> Int
-- | Like weightToOpenTypeDouble but with integer arguments. Use the other function instead.
foreign import capi "fontconfig/fontconfig.h FcWeightToOpenType" 
    weightToOpenType :: Int -> Int