[HarfBuzz] Getting character bitmap

Behdad Esfahbod behdad at behdad.org
Sun Jan 15 21:48:25 UTC 2023


Hi Sagar,

I suggest you follow an example piece of code, like:

  https://github.com/lxnt/ex-sdl-freetype-harfbuzz


behdad
http://behdad.org/


On Sun, Jan 15, 2023 at 11:47 AM Sagar Acharya <sagaracharya at tutanota.com>
wrote:

> Thanks a lot for the quick help.
>
> I decided to go ahead with Freetype for C.
>
> Since I'm new to C, I don't quite know how to connect function Char_Index
> output to FT_Bitmap. I'm new to reading such C documentation.
>
> //===================================================================#include
> <ft2build.h>
> #include FT_FREETYPE_H
>
> void main()
> {
> FT_Library library;
> FT_Face face;
> FT_Error error;
> FT_UInt glyph_index;
> FT_Bitmap bmp;
>
> int width=200;
> int height=200;
>
> error = FT_Init_FreeType(&library);
> error = FT_New_Face(library, "/path/to/ttf", 0, &face);
> error = FT_Set_Char_Size(face, 0, 16*64, 200, 200);
>
> glyph_index = FT_Get_Char_Index(face, 0x41);
>
> error = FT_Render_Glyph(face->glyph, FT_RENDER_MODE_MONO);
> printf("%d\n", error);
> }
> //===========================
> Thanking you
> Sagar Acharya
>
>
>
> Jan 13, 2023, 19:06 by behdad at behdad.org:
>
> > Hi Sagar,
> >
> > HarfBuzz does not have a rasterizer so you can't get that from HarfBuzz.
> You have two options:
> >
> >   1. Use FreeType library,
> >
> >   2. If you have a graphics library with a rasterizer capable of
> handling the moveTo/lineTo/curveTo model, you can use the hb-draw API to
> draw to it.
> >
> > Hope that helps,
> >
> > behdad
> > http://behdad.org/
> >
> >
> > On Fri, Jan 13, 2023 at 10:06 AM Sagar Acharya <>
> sagaracharya at tutanota.com> > wrote:
> >
> >> I have ttf file of the font that I want the bitmap of. In black and
> white mapped to 0 and 1, I want a set of 16x16 set of all characters.
> >>
> >>  How do I do it?
> >>
> >>  1110001111
> >>  1111101111
> >>  1110001111
> >>  1110101111
> >>  1110001111
> >>
> >>  Something like above. How do I get it from ttf?
> >>  Thanking you
> >>  Sagar Acharya
> >>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/harfbuzz/attachments/20230115/d731fc27/attachment.htm>


More information about the HarfBuzz mailing list