Giter Club home page Giter Club logo

Comments (5)

rougier avatar rougier commented on May 26, 2024

What is the error you get? Did you check the example with TARGET_MONO?

from freetype-py.

kanryu avatar kanryu commented on May 26, 2024

@rougier What is the error you get? Did you check the example with TARGET_MONO?
bitmap.buffer is None.

I noticed that the program should be modified in this way.

import freetype

face = freetype.Face("mplus-1p-black.ttf")
face.set_char_size( 1500 )
flags = freetype.FT_LOAD_FLAGS['FT_LOAD_RENDER'] | freetype.FT_LOAD_FLAGS['FT_LOAD_MONOCHROME'] | freetype.FT_LOAD_TARGETS['FT_LOAD_TARGET_MONO']
face.load_char('S', flags)
bitmap = face.glyph.bitmap
print(bitmap.buffer) # OK

It certainly works if I fix this way, but since this fact can not be understood by reading freetype-py document, please introduce it in 'samples'. (The above source code will be donated to this project)

from freetype-py.

HinTak avatar HinTak commented on May 26, 2024

The Freetype documentation has this paragraph:

"If FT_LOAD_RENDER is also set, the glyph is rendered in the corresponding mode (i.e., the mode that matches the used algorithm best). An exception is FT_LOAD_TARGET_MONO since it implies FT_LOAD_MONOCHROME."

It implies the converse also: if you don't have FT_LOAD_RENDER, bitmap is not generated and you need to call FT_Render_Glyph manually to generate a bitmap.

This is at the bottom of FT_LOAD_TARGET_* 's description.

from freetype-py.

kanryu avatar kanryu commented on May 26, 2024

@HinTak I am discussing freetype-py, where freetype has nothing to do with it.

from freetype-py.

HinTak avatar HinTak commented on May 26, 2024

from freetype-py.

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.