Giter Site home page Giter Site logo

Comments (4)

campadrenalin avatar campadrenalin commented on September 24, 2024

I'm going to try to fix the TTF font issue, using the Font.js library. This lets us measure font metrics for a given text at any size, which lets us cache metrics for individual characters, and render text to canvas directly with fillText, rather than as glyphs.

from love-webplayer.

ghoulsblade avatar ghoulsblade commented on September 24, 2024

awesome progress overall =) sorry i've been inactive, was away from home on a business trip.
ttf with canvas draw : hmm sounds like a potential performance bottleneck,
if it's not much effort a caching of the canvas for the same text would be good,
i suspect love loads the glyphs into a texture and blits from there or something,
rather than rendering the same text 30+ times per second using a ttf lib.
But not top priority i guess.

from love-webplayer.

campadrenalin avatar campadrenalin commented on September 24, 2024

Heh. After writing that, I figured out that fillText only works on 2D contexts. So while we can use it to populate textures, it's useless for directly rendering to the canvas. So the two different font types will share a common architecture after all.

They will differ a bit in that the TTF fonts will use an array of textures, and render characters to them as needed, striking a balance between preallocation and being able to add an arbitrary number of glyphs to the cache on demand. All the common code will be in cLoveFont, but thanks to the way Weblua supports handles, I'm able to do image fonts and TTF fonts separately as the cLoveImageFont and cLoveFontFace classes. This allows a nice, straightforward separation between common code, image-specific code, and fontface-specific code.

from love-webplayer.

campadrenalin avatar campadrenalin commented on September 24, 2024

Font.js turned out to be a bust, but I was able to get equivalent functionality from canvas.measureText. TTF fonts are now working with Weblua as demonstrated by the demo page. In case I haven't already made enough warnings about this, I seriously overhauled the entire love.font.js library. It's better but will probably take some getting used to.

from love-webplayer.

Related Issues (15)

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.