freetype-rs icon indicating copy to clipboard operation
freetype-rs copied to clipboard

Render modes missing FT_RENDER_MODE_SDF

Open kantholz44mm opened this issue 2 years ago • 1 comments

As seen in the FreeType documentation, there is a render mode for creating SDFs. This enum is missing in the rust binding as of yet

kantholz44mm avatar Jul 17 '23 10:07 kantholz44mm

For anyone stumbling upon this you can set the render SDF flag with the following

let load_flags = freetype::face::LoadFlag::from_bits((0x1 << 2) | ((5 & 15) << 16)).unwrap();

Where:

  1. 0x1 << 2 is equivalent to LoadFlag::RENDER
  2. ((5 & 15) << 16) is equivalent to FT_LOAD_TARGET_(FT_RENDER_MODE_SDF) in C

Then you can use the load_flags with load_glyph() or load_char().

AustinEvansWX avatar Apr 29 '24 05:04 AustinEvansWX