Re: [HarfBuzz] Getting character bitmap

2023-01-15 Thread Werner LEMBERG


> I suggest that you go through the FreeType tutorial at
> 
>   https://freetype.org/freetype2/docs/tutorial/index.html
> 
> It comes with examples that you can adapt to your needs.

I forgot to mention the FreeType demo programs.  You can download a
tarball from

  https://download.savannah.gnu.org/releases/freetype/ft2demos-2.12.1.tar.xz


Werner



FWD: Re: [HarfBuzz] Getting character bitmap

2023-01-15 Thread Sagar Acharya via FreeType users
Any help is appreciated in code below to convert the glyph to 0 and 1 based 
bitmap as shown at the end.

>
> 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 
> #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();
> error = FT_New_Face(library, "/path/to/ttf", 0, );
> 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 beh...@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 <>> 
>> sagaracha...@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?
>>>
>>> 111000
>>> 10
>>> 111000
>>> 111010
>>> 111000
>>>
>>> Something like above. How do I get it from ttf?
>>> Thanking you
>>> Sagar Acharya
>>>
>
>



Re: [HarfBuzz] Getting character bitmap

2023-01-15 Thread Werner LEMBERG

> Any help is appreciated in code below to convert the glyph to 0
> and 1 based bitmap as shown at the end.
>>
>> 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.

I suggest that you go through the FreeType tutorial at

  https://freetype.org/freetype2/docs/tutorial/index.html

It comes with examples that you can adapt to your needs.  If you have
more specific questions (and no, we won't write the code for you)
please ask here.


Werner