[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: RE: Re: [ft] Monochrome Bitmap Trouble
From: |
Paresh Deshmukh |
Subject: |
RE: RE: Re: [ft] Monochrome Bitmap Trouble |
Date: |
Thu, 22 Sep 2005 08:36:25 UT |
Hi,
I change the code according to suggestions. I am using MSMINCHO.TTF file for
font generation and getting all English alphabets bitmap. But how to transform
character is still unclear.
Also please tell me how can I get JAPANESE character from MSMINCHO.TTF.
Thanks
>
> Hello,
>
> > I cannot send you the real program. But this is based on the
> > tutorial step-1.
> > The addition is only that...image buffer is copied to print buffer.
> >
>
> I have some small comments regarding your source code, though no
> real solution to provide.
>
> a/ never call free(NULL), since the behaviour of such call is
> undefined. On some platforms this will either crash your
> program, or silently trash your heap structures.
>
> in all cases, free(NULL) has strictly no usefulness.
>
> b/ the 'pitch' field of a FT_Bitmap structure can be negative,
> so your code should deal with it:
>
> pitch = slot->bitmap.pitch;
> if ( pitch < 0 ) pitch = -pitch;
>
> c/ you don't need to call memset and memcpy in a loop,
> a simple:
>
> memcpy( bitmap, bitmap.buffer, pitch*slot->bitmap.rows )
>
> will do exactly the same thing, since you're copying all
> bytes from the original.
>
>
> Apart from that, you should really tell us which font you're using,
> and what kind of results you're having ?? Some screenshots or dumps
> of distorted characters might help.
>
> Have you tried disabling hinting to see if this changes anything ?
>
> Regards,
>
> - David Turner
> - The FreeType Project (www.freetype.org)
>
>
>
> > I also tried similar code as of
> > John Churchill
> > Subject: [Freetype] Distorted characters
> > Date: Fri, 23 Aug 2002 02:24:20 -0700 (PDT)
> >
> > void InitFont() {
> > FT_UInt index;
> > FT_GlyphSlot slot;
> > int pitch, start;
> > unsigned char *bitmap, i;
> >
> > if ( FT_Init_FreeType(&Library) ) {
> > printf("Failed to init freetype.\n");
> > exit(1);
> > }
> >
> > if ( FT_New_Face(Library, "/arial.ttf", 0, &face) )
> > printf("Unable to load font.\n");
> >
> > if ( FT_Set_Char_Size(face, 0, 22*64, 300,300) )
> > printf("Unable to set character size.\n");
> >
> >
> > for (i = 'A'; i < 'A' + 4; i++) {
> > index = FT_Get_Char_Index(face, i);
> >
> > if ( FT_Load_Glyph(face, index, FT_LOAD_DEFAULT) )
> > printf("Unable to load glyph face.\n");
> >
> > if ( FT_Render_Glyph(face->glyph,
> > ft_render_mode_mono) )
> > printf("Unable to render glyph\n");
> >
> > slot = face->glyph;
> > pitch = slot->bitmap.pitch;
> >
> > bitmap = (unsigned char *)
> > malloc(slot->bitmap.rows * pitch);
> >
> > if (bitmap == NULL) {
> > printf("Out of memory.\n");
> > free(bitmap);
> > FT_Done_FreeType(Library);
> > exit(1);
> > }
> > memset(bitmap, 0, slot->bitmap.rows * pitch);
> >
> > for (start=0; start < slot->bitmap.rows; start++)
> > memcpy(bitmap + pitch *
> > start,slot->bitmap.buffer + start * pitch, pitch);
> > }
> >
> > /*Cpying bitmap to print buffer*/
> >
> > free(bitmap);
> >
> > }
> >
> > FT_Done_FreeType(Library);
> > }
> >
> > This code works for me and giving me proper and all
> > characters without any
> > garbage. Please comment where Im wrong in first code.
> >
> >
> >
> >
> > _______________________________________________
> > Freetype mailing list
> > address@hidden
> > http://lists.nongnu.org/mailman/listinfo/freetype
> >