From fc2d68224a8d32c78cb38678c49ed126d6a4d51b Mon Sep 17 00:00:00 2001 From: Jaro Date: Sat, 18 Feb 2023 21:31:43 +0100 Subject: [PATCH] Add explicit scale to test font. --- test/Data/Text/ParagraphLayout/FontLoader.hs | 25 ++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/test/Data/Text/ParagraphLayout/FontLoader.hs b/test/Data/Text/ParagraphLayout/FontLoader.hs index ecf0f52..8e247bb 100644 --- a/test/Data/Text/ParagraphLayout/FontLoader.hs +++ b/test/Data/Text/ParagraphLayout/FontLoader.hs @@ -3,15 +3,32 @@ module Data.Text.ParagraphLayout.FontLoader (loadUbuntuRegular) where import Data.ByteString (readFile) import Data.Text.Glyphize (Font + ,FontOptions(optionPPEm, optionScale) ,createFace - ,createFont + ,createFontWithOptions + ,defaultFontOptions ) -import Prelude (IO, return) +import Prelude (IO, Int, Maybe(Just), String, Word, return) import System.FilePath (()) +ubuntuRegularPath :: String +ubuntuRegularPath = "assets" "fonts" "ubuntu" "Ubuntu-R.ttf" + +-- TODO: Figure out if this affects hinting! +testingPixelSize :: (Word, Word) +testingPixelSize = (24, 24) + +-- This controls the output units. +-- The default is "unscaled", which uses the value of `faceUpem` in both axes. +testingScale :: (Int, Int) +testingScale = (1000, 1000) + loadUbuntuRegular :: IO Font loadUbuntuRegular = do - ttf <- readFile ("assets" "fonts" "ubuntu" "Ubuntu-R.ttf") + ttf <- readFile ubuntuRegularPath let face = createFace ttf 0 - let font = createFont face + let font = createFontWithOptions (defaultFontOptions { + optionPPEm = Just testingPixelSize, + optionScale = Just testingScale + }) face return font -- 2.30.2