Code Monkey home page Code Monkey logo

Comments (3)

vladimirgamalyan avatar vladimirgamalyan commented on July 2, 2024

I don't think it will be useless, so I'm in.
BTW, does the GPU also require even width? I know some GPU likes 32-bit aligned addresses, but never heard about even numbers.
It would be nice to cover more cases, so I'd like more info how the GPU uses font textures.

from fontbm.

phoddie avatar phoddie commented on July 2, 2024

I don't think it will be useless, so I'm in.

Cool. I'll make some time to work on that.

BTW, does the GPU also require even width?

It does not.

I know some GPU likes 32-bit aligned addresses, but never heard about even numbers. It would be nice to cover more cases, so I'd like more info how the GPU uses font textures.

The GPU we are experimenting with is from the FTDI EVE series. They are quite constrained: just 1 MB of texture memory and an 8 KB display list. Both of those constraints are relevant to the even alignment support. To minimize the texture memory used by fonts, we store them as 4-bit gray pixels, so each byte contains two pixels. To draw the glyphs, we use the BITMAP_SOURCE command, which takes the starting address of the bitmap, along with the BITMAP_SIZE command to define the width and height of the bitmap to draw. When the glyph has an odd x offset, the starting address of the bitmap is one pixel (4 bits) before the start of the glyph. To render it correctly, we set a clip using the SCISSOR_* commands (and eventually restore the clip) to exclude the that pixel. The scissor commands use more of the limited display list, which in turn limits how many glyphs can be rendered on a single screen.

I admit it is a strange case, but it is very cool that fontbm makes it so straightforward to make optimal use of the very limited display list (in addition to fontbm providing the smallest glyph atlas size we've seen from any tool, which saves texture memory too!)

For completeness, I should mention that the GPU has another way of storing fonts, basically as a vertical column of constant size glyphs. Less display list memory is required render these, but it is a very inefficient use of texture memory. We don't have plans to use this approach.

from fontbm.

phoddie avatar phoddie commented on July 2, 2024

Closing this issue as the PR to implement it has been merged. (Thank you!)

from fontbm.

Related Issues (20)

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.