Git Product home page Git Product logo

fontyfruity's People

Contributors

acowley avatar alexmingoia avatar cobbpg avatar hsyl20 avatar lancelet avatar schell avatar taktoa avatar twinside avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

fontyfruity's Issues

Kerning

Great library. Rasterific is really useful for me. It would be nice if the kerning table was applied to the horizontal info so that drawing text with Rasterific was properly kerned. If I have time I will attempt to add this, but it may take me a while as I'm not familiar with TTF format.

fail to load ttf

I have tried to render fonts from http://www.1001freefonts.com but usually I got this kind of error message:
"table cmap format 0 : invalid size. Failed reading at byte position 2134"

e.g.
http://www.1001freefonts.com/ubuntu_mono.font

bash-3.2$ ./Gui UbuntuMono-Regular.ttf
Gui: table cmap format 0 : invalid size. Failed reading at byte position 6278

Gui.hs:
import Control.Applicative( (<$>) )
import Codec.Picture
import Graphics.Text.TrueType( loadFontFile )
import Graphics.Rasterific
import Graphics.Rasterific.Texture
import System.Directory( createDirectoryIfMissing )
import System.FilePath( (</>) )
import System.Environment
outFolder = "."

textExample :: IO ()
textExample = do
[fname] <- getArgs
fontErr <- loadFontFile fname
case fontErr of
Left err -> putStrLn err
Right font ->
writePng (outFolder </> "text_example.png") .
renderDrawing 640 480 (PixelRGBA8 255 255 255 255)
. withTexture (uniformTexture $ PixelRGBA8 0 0 0 255) $
printTextAt font 12 (V2 20 40) "A simple text test!"

main = textExample

Expose font baseline info

I reported an issue in Chart that is due to a limitation of the diagrams-rasterific backend. My understanding is that diagrams wants the origin Y coordinate of some text to be the baseline height of the rendered text, FontyFruity exposes the full string bounding box, and Rasterific's printTextAt takes the desired baseline height. I think, then, the issue is that it is not clear how to locate the bounding box returned by stringBoundingBox with respect to the baseline height given to printTextAt. What is needed to improve diagrams compatibility is the difference between the top of the bounding box and the baseline.

Thanks for any assistance!

Release 0.5.3 to hackage

Hey there - I'd like to release a new library to hackage that depends on descriptorOf, which is not up on hackage yet. Can you upload the current version to hackage?

Alternatively, I'll upload if you give me permission :)

Thanks!

Support GHC 8.8

GHC 8.8 implements the final part of the MonadFail proposal. The impact of this on FontyFruity is that the put method can no longer call fail to indicate that put is not implemented. (In turn because Data.Binary.Put.Put does not implement a MonadFail instance.)

I have raised PR #25 that addresses this issue by replacing fail with error.

I'm willing to have a go at implementing any alternative solution if this approach is not acceptable.

Composition offsets are doubly scaled

I believe you need to use fromIntegral instead of toFloat on these lines to get the correctly scaled offset. You can easily test by checking out accented characters like áéöÁÉÖ in Arial or Times New Roman.

Sadly, this still doesn’t seem to be enough to fix other characters, like í, but that might be related to other flags, e.g. using metrics from a different character.

invalid ttf: (table cmap format 0)

Can not load http://www.1001freefonts.com/muddy_tractor.font

error message:
....
NUL\CAN\255\171\NUL\SOH\NUL\CAN\255;\NUL\STX\NUL\n\NUL\ACK\NUL\ACK\NUL\NUL\NUL\v\NUL\DC1\NUL\SOH\NUL\DC3\NUL\DC3\NUL\b\NUL\CAN\NUL\CAN\NUL\t\NUL+\NUL+\NUL\n\NUL-\NUL1\NUL\v\NUL3\NUL6\NUL\DLE\NUL8\NULE\NUL\DC4\NULT\NULT\NUL"\NUL\190\NUL\191\NUL#\NUL\NUL",4282,"table cmap format 0, invalid size: 47104")

Hackage documentation missing.

The documentation for the latest version of this package is missing on Hackage. They've been pending on Hackage for some time, this usually indicated that Hackage wasn't able to build the package.

Is it possible for you to manually upload the package using cabal upload --doc, please?

Thanks!

Text bounding box

Can we have functions

textWidth :: Font -> Int -> String -> Double

textHeight :: Font -> Int -> Double

Which take a font, point size (and in the case of width, string of text) and return the width and height of the string in points?

Reposting Twinside/Rasterific#8

Sometimes adding characters reduces the height of the bounding box

According to stringBoundingBox the string "I am a pretty long string" has a bounding box that is smaller in height than the string "I am a pretty long string-". It seems that adding the last '-' character is causing stringBoundingBox to return a larger _yMin, which in turn makes the height smaller. Here are some renderings of the strings along with their bounding boxes (in white).

screenshot 2015-06-02 17 40 24

screenshot 2015-06-02 17 42 29

getStringCurveAtPoint is interfering with other IO operations

I'm not completely sure of this one but I think that FontyFruity's usafePerformIO (http://hackage.haskell.org/package/FontyFruity-0.4/docs/src/Graphics-Text-TrueType.html#getOrFail) may be causing some other IO operations to fail. I'm reading a ttf font, calling getStringCurveAtPoint 72 (0,0) [(font, 12, "0")], reading some glsl shader files, compiling those shaders and then rendering the contours with those shaders.

    Right font <- loadFontFile "/Users/schell/Library/Fonts/UbuntuMono-R.ttf"
    let cm = getCharacterGlyphsAndMetrics font '0'
        vs = getStringCurveAtPoint 72 (0,0) [(font, 12, "0")]
        bs = fontyToBeziers vs
    print cm
    bezr <- newBezRenderer window bs

Everything works fine until I change to getStringCurveAtPoint 72 (0,0) [(font, 32, "0")] at which point my shaders can't compile because of a syntax error. I can alternatively add an extra line to the end of my fragment shader which fixes this problem, but it seems that something is not quite right. I know the shaders are correct and I'm guessing that somehow trash bytes are being read by opengl.
Deleting "print cm" or inserting other IO has unexpected effects as well.

buildCache fails (resource exhausted)

buildCache is failing about half the time I call it at the beginning of my app. Here is the exception:

/Library/Fonts/Telugu Sangam MN.ttc: openBinaryFile: resource exhausted (Too many open files)

The exact font it errs on is different (almost) every time. I'm running on Mac OS X 10.11.2 and ghc 7.10.2.

Unicode encoding is not necessarily used by default and there’s no way to ask for it

Since the glyph mapping tables are sorted according to format only, there’s no guarantee that the Unicode translation will be preferred when interpreting a character code. One example is this font, where code points below 256 are picked up by the wrong table (PlatformMacintosh), and many other fonts yield the exact some undesired result.

Probably the easiest solution would be to consider the platform when sorting the character maps for findCharGlyph and make sure the Unicode mapping ends up being the head of the list.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.