freetype
[Top][All Lists]
Advanced

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

RE: [ft] Freetype stroke


From: Allan Yang, Jian Hua - SH
Subject: RE: [ft] Freetype stroke
Date: Wed, 2 Jan 2008 10:41:46 +0800

Easy :) , try following snippets:


Allan

-- Function start --  
  static FT_Error
  Render_Purfle( int  num_indices,
                 int  first_index )
  {
    int         start_x, start_y, step_x, step_y, x, y, old_x, old_y;
    int         i;
    FT_Size     size;
    FT_Stroker  stroker = NULL;


    error = FTDemo_Get_Size( handle, &size );

    if ( error )
    {
      /* probably a non-existent bitmap font size */
      return error;
    }

    INIT_SIZE( size, start_x, start_y, step_x, step_y, x, y );

    i = first_index;

    error = FT_Stroker_New( handle->library, &stroker );
    if ( error )
      goto Exit;

    FT_Stroker_Set( stroker, 64,
                    FT_STROKER_LINECAP_ROUND,
                    FT_STROKER_LINEJOIN_ROUND,
                    0 );

    while ( i < num_indices )
    {
      int           gindex;
      FT_GlyphSlot  slot;


      if ( handle->encoding == FT_ENCODING_NONE )
        gindex = i;
      else
        gindex = FTDemo_Get_Index( handle, i );

      error = FT_Load_Glyph( size->face, gindex,
                             handle->load_flags | FT_LOAD_NO_BITMAP );
      slot = size->face->glyph;

      if ( !error && slot->format == FT_GLYPH_FORMAT_OUTLINE )
      {
        FT_Glyph  glyph;

        error = FT_Get_Glyph( slot, &glyph );
        if ( error )
          goto Next;

        error = FT_Glyph_Stroke( &glyph, stroker, 1 );
        if ( error )
        {
          FT_Done_Glyph( glyph );
          goto Next;
        }

        grColor  color = { 255 };
        old_x = x;
        old_y = y;
        error = FTDemo_Draw_Glyph_Color( handle, display, glyph, &x, &y, color 
);
        x = old_x;
        y = old_y;
        FT_Done_Glyph( glyph );

        error = FTDemo_Draw_Index( handle, display, gindex, &x, &y );

        if ( error )
          status.Fail++;
        else if ( X_TOO_LONG( x, size, display ) )
        {
          x  = start_x;
          y += step_y;

          if ( Y_TOO_LONG( y, size, display ) )
            break;
        }
      }
      else
      {
Next:
        status.Fail++;
      }

      i++;
    }

  Exit:
    if ( stroker )
      FT_Stroker_Done( stroker );

    return error;
  }
-- Function end--



-----Original Message-----
From: address@hidden [mailto:address@hidden On Behalf Of Kuon
Sent: 2008年1月1日 22:32
To: Werner LEMBERG
Cc: address@hidden
Subject: Re: [ft] Freetype stroke


On Jan 1, 2008, at 3:11 AM, Werner LEMBERG wrote:

>
>> Now, I want a stroke around the glyphs (of n pixel wide, where n is
>> a float).  I could put it in the red channel for example (so I can
>> use it in GL fragment shader later to do whatever I want).
>
> The word `stroke' is misleading, I think, since this means something
> different in the font world.  You rather mean emboldening, don't you?
>
> Try the ftview demo program and press keys `2' to see FreeType's
> emboldening feature.


Actually, what I wanted was what you have when doing '3' in the ftview  
program.

My idea is to put the first (key '1' in ftview) bitmap (as I do now)  
in the gray channel, and the "stroke" bitmap (key '3' in ftview) in,  
let's say, the red channel.

I will look into the ftview source, thanks for the direction.

Best regards and happy new year

--
kuon

http://kuon.goyman.com
http://goyman.com



_______________________________________________
Freetype mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/freetype




reply via email to

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