Hi,

Can anyone help me with this problem ?

I have a feeling that this problem is happening because of some minor
mistake. But, I have been unable to rectify it.

Thanks a lot.



On Thu, Mar 7, 2013 at 2:49 PM, Parth Kanungo <[email protected]>wrote:

> Here is the sample code that I used.
> Please change the value of inFileName[], when you run the program.
> The output is generated in a output.txt file.
> I observed it by enabling WORD-WRAP in the Notepad++ and then, zooming out.
>
>
>
> /* example1.c                                                      */
> /*                                                                 */
> /* This small program shows how to print a string with the */
> /* FreeType 2 library.                                             */
>
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <conio.h>
> #include <string.h>
> #include <math.h>
>
> #include "ft2build.h"
> #include FT_FREETYPE_H
>
>
> #define WIDTH   640
> #define HEIGHT  480
>
>
>
> /* origin is the upper left corner */
> unsigned char image[HEIGHT][WIDTH];
>
> /* Replace this function with something useful. */
>
> void
> draw_bitmap( FT_Bitmap*  bitmap,
> FT_Int      x,
> FT_Int      y)
> {
> FT_Int  i, j, p, q;
> FT_Int  x_max = x + bitmap->width;
> FT_Int  y_max = y + bitmap->rows;
>
> int val = 0;
> for ( i = x, p = 0; i < x_max; i++, p++ )
> {
>  for ( j = y, q = 0; j < y_max; j++, q++ )
> {
> if ( i < 0      || j < 0       ||
>  i >= WIDTH || j >= HEIGHT )
> continue;
>
> image[j][i] |= bitmap->buffer[q * bitmap->width + p];
>  if(bitmap->buffer[q * bitmap->width + p] > 0) {
> val |= bitmap->buffer[q * bitmap->width + p];
>  }
> }
> }
> }
>
>
> void
> show_image( void )
> {
> int  i, j;
>
>     FILE *fp1 = fopen("Output.txt", "w");
>  for ( i = 0; i < HEIGHT; i++ )
> {
> for ( j = 0; j < WIDTH; j++ )
>  /* putchar( image[i][j] == 0 ? ' '
> : image[i][j] < 128 ? '+'
>  : '*' );
> putchar( '\n' );
> */
> {
>  if(image[i][j] == 0)
> fprintf(fp1, "%c", ' ');
> else if (image[i][j] < 128)
>  fprintf(fp1, "%c", '+');
> else
> fprintf(fp1, "%c", '*');
>  }
> fprintf(fp1, "%c", '\n');
> }
>  fclose(fp1);
> }
>
>
> int main( int     argc, char**  argv )
> {
> FT_Library    library;
>  FT_Face       face;
>
> FT_GlyphSlot  slot;
> FT_Matrix     matrix;                 /* transformation matrix */
>  FT_Vector     pen;                    /* untransformed origin  */
> FT_Error      error;
>
> char         fontName[256];
> char
> inFileName[]="D:\\FREETYPE\\freetype-2.4.2\\freetype-2.4.2\\builds\\win32\\vc2005\\arial.ttf";
>  char         text[] = "Font Experts";
>
> double        angle;
>  int           target_height;
> int           n, num_chars;
>
>
>
>
> num_chars     = strlen( (char*)text );
> angle         = 0;//( 25.0 / 360 ) * 3.14159 * 2;      /* use 25 degrees
>   */
>  target_height = HEIGHT;
>
> error = FT_Init_FreeType( &library );              /* initialize library */
>  if(error)
> {
> fprintf ( stderr, "FT_Init_FreeType: failed" );
>  exit( 1 );
> }
>
> error = FT_New_Face( library, inFileName, 0, &face );/* create face object
> */
>  if(error)
> {
> fprintf ( stderr, "FT_New_Face: failed" );
>  exit( 1 );
> }
>
> /* use 50pt at 100dpi */
>  error = FT_Set_Char_Size( face, 50 * 64, 0,
> 100, 0 );                /* set character size */
>  /* error handling omitted */
>
> slot = face->glyph;
>
>  /* set up matrix */
> matrix.xx = (FT_Fixed)( cos( angle ) * 0x10000L );
> matrix.xy = (FT_Fixed)(-sin( angle ) * 0x10000L );
>  matrix.yx = (FT_Fixed)( sin( angle ) * 0x10000L );
> matrix.yy = (FT_Fixed)( cos( angle ) * 0x10000L );
>
> /* the pen position in 26.6 cartesian space coordinates; */
> /* start at (300,200) relative to the upper left corner  */
>  pen.x = 300 * 64;
> pen.y = ( target_height - 200 ) * 64;
>
> for ( n = 0; n < num_chars; n++ )
>  {
> /* set transformation */
> FT_Set_Transform( face, &matrix, &pen );
>
> /* load glyph image into the slot (erase previous one) */
> error = FT_Load_Char( face, text[n], FT_LOAD_RENDER );
>  if ( error )
> continue;                 /* ignore errors */
>
>  /* now, draw to our target surface (convert position) */
> draw_bitmap( &slot->bitmap,
>  slot->bitmap_left,
> target_height - slot->bitmap_top );
>
>  /* increment pen position */
> pen.x += slot->advance.x;
> pen.y += slot->advance.y;
>  }
>
> show_image();
>
> FT_Done_Face    ( face );
>  FT_Done_FreeType( library );
> return 0;
> }
>
> /* EOF */
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> On Thu, Mar 7, 2013 at 11:10 AM, suzuki toshiya <
> [email protected]> wrote:
>
>> Hi,
>>
>> Could you post some sample source that you could display a blank screen?
>>
>> Regards,
>> mpsuzuki
>>
>> Parth Kanungo wrote:
>> > Hi all,
>> >
>> > I used the sample code on the FreeType Documentation Page (PART-1). To
>> run
>> > the code, when I used the libraries from GTK+ bundle, my output was
>> perfect.
>> >
>> > However, when I created freetype.lib myself from the downloaded source
>> code
>> > and used it, the output showed a blank screen.
>> >
>> > To ensure that there was no version mismatch, I checked from the GTK
>> > website (http://www.gtk.org/download/win32.php) and found that GTK+
>> bundle
>> > currently uses freetype 2.4.2 version. Hence, I used that version of
>> > freetype to build the freetype.lib. But, I still face the same issue.
>> >
>> > Can anyone help me out here ?
>> >
>> >
>> > Thanks a lot.
>> >
>> >
>> > ------------------------------------------------------------------------
>> >
>> > _______________________________________________
>> > Freetype mailing list
>> > [email protected]
>> > https://lists.nongnu.org/mailman/listinfo/freetype
>>
>>
>
>
> --
> Parth Kanungo
> Software Engineer,
> Samsung R&D Institute Delhi
> Sector-62, Noida
>
> "Life would be flat without dreams. I think it's really important to dream
> – and then to chase those dreams. I really believe in this because it's
> this dreaming that makes me work so hard." - Sachin Tendulkar
>



-- 
Parth
_______________________________________________
Freetype mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/freetype

Reply via email to