freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ft-devel] PCF: Issues with lazy copy in `ft_bitmap_glyph_init'


From: Werner LEMBERG
Subject: Re: [ft-devel] PCF: Issues with lazy copy in `ft_bitmap_glyph_init'
Date: Sat, 25 Aug 2018 19:14:48 +0200 (CEST)

> (2) Update the documentation:
> 
>       By default, `FT_Get_Glyph' can be used only once. If you
>       want more copies, use either `FT_Copy_Glyph' or call
>       `FT_GlyphSlot_Own_Bitmap' before calling `FT_Get_Glyph' again.

Oops!  This must rather be the following.

  By default, @FT_Get_Glyph can be used only once since it sometimes
  takes the ownership of the glyph slot's data.  If you want more
  copies, use either @FT_Copy_Glyph or call @FT_GlyphSlot_Own_Bitmap
  (after the first @FT_Get_Glyph call but before its corresponding
  call to @FT_Done_Glyph), followed by another call of @FT_Get_Glyph.


    Werner
#include <stdlib.h>

#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_BITMAP_H
#include FT_GLYPH_H

int main( void )
{
  FT_Library  library;
  FT_Face     face;
  FT_Glyph    glyph1, glyph2;
  

  (void) FT_Init_FreeType( &library );
  (void) FT_New_Face( library, "./sample.pcf", 0, &face );

  (void) FT_Load_Glyph( face, 0, 0 );

  (void) FT_Get_Glyph( face->glyph, &glyph1 );
  (void) FT_GlyphSlot_Own_Bitmap( face->glyph );
  (void) FT_Get_Glyph( face->glyph, &glyph2 );

  (void) FT_Done_Glyph( glyph1 );
  (void) FT_Done_Glyph( glyph2 );

  (void) FT_Done_FreeType( library );

  return EXIT_SUCCESS;
}

reply via email to

[Prev in Thread] Current Thread [Next in Thread]