文件浏览器及数码相框 -2.3.2-freetype_arm-1

交叉编译:
tar xjf freetype-2.4.10.tar.bz2
./configure --host=arm-linux
make
make DESTDIR=$PWD/tmp install

find -name stdio.h

平时使用#include<stdio.h>路径    ./arm-linux/include/stdio.h

编译出来的头文件应该放入:
/work/tools/gcc-3.4.5-glibc-2.3.6/arm-linux/include

编译出来的库文件应该放入:
/work/tools/gcc-3.4.5-glibc-2.3.6/arm-linux/lib

把tmp/usr/local/lib/*  复制到 /work/tools/gcc-3.4.5-glibc-2.3.6/arm-linux/lib
sudo cp * /work/tools/gcc-3.4.5-glibc-2.3.6/arm-linux/lib -d -rf
cp *so* /work/nfs_root/fs_mini_mdev_new/lib –d

cd /work/tools/gcc-3.4.5-glibc-2.3.6/arm-linux/lib


把tmp/usr/local/include/*  复制到 /work/tools/gcc-3.4.5-glibc-2.3.6/arm-linux/include
cp *  /work/tools/gcc-3.4.5-glibc-2.3.6/arm-linux/include  -rf
cp *so* /work/nfs_root/fs_mini_mdev/lib –d


 

错误

/arm-linux/include/ft2build.h:56:38: freetype/config/ftheader.h

freetype/config/ftheader.h
freetype2/freetype/config/ftheader.h

将freetype2/freetype移动到当前目录

mv freetype2/freetype .

编译

arm-linux-gcc -finput-charset=GBK -fexec-charset=GBK -o example1 example1.c  -lfreetype  -lm

在开发板上运行

陈志朋arm

用函数转化文件编码方式

iconv -f GBK -t UTF-8 show_font.c

查看错误

编译

arm-linux-gcc -finput-charset=GBK -fexec-charset=GBK -o show_font show_font.c  -lfreetype -lm

wchar_t * chinese_str = L"";
    
    
      FT_Library    library;
      FT_Face       face;
    FT_Vector     pen;                    /* untransformed origin  */
    FT_GlyphSlot  slot;

    int error;
    
    if(argc != 2)
    {
        printf("Usage : %s <font_file>
",argv[0]);
        return -1;
    }

freetype初始化

/* ÏÔʾʸÁ¿ÎÄ×Ö */
    
  error = FT_Init_FreeType( &library );              /* initialize library */
  /* error handling omitted */

  error = FT_New_Face( library, argv[1], 0, &face ); /* create face object */
  /* error handling omitted */

 slot = face->glyph;
    
  FT_Set_Pixel_Sizes(face, 24, 0);

 
    
  /*È·¶¨×ø±ê
  *lcd_x = var.xres / 2 + 32 + 32 
  *lcd_y = var.yres / 2
  *µÑ¿¨¶û×ø±ê
  *x = lcd_x = var.xres / 2 + 32 + 32 
  *y = var.yres -  var.yres / 2
  */
  
  pen.x = ( var.xres / 2 + 32 + 32 ) * 64;
  pen.y = ( var.yres -  var.yres / 2 - 16) * 64;

  /* set transformation */
  FT_Set_Transform( face, 0, &pen );

  /* load glyph image into the slot (erase previous one) */

  error = FT_Load_Char( face, chinese_str[0], FT_LOAD_RENDER );
  if ( error )
  {
      printf("FT_Load_Char error
");
    return -1;
  }
   /* now, draw to our target surface (convert position) */
   draw_bitmap( &slot->bitmap,
                 slot->bitmap_left,
                 var.yres - slot->bitmap_top );

描画图

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;

    printf("x = %d, y = %d
", x, y);
    
  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 >= var.xres || j >= var.yres )
        continue; 

    //  image[j][i] |= bitmap->buffer[q * bitmap->width + p];

        lcd_put_pixel(i, j, bitmap->buffer[q * bitmap->width + p]);
    }
  }
}

旋转angle角度

第三个参数为角度

添加头文件   #include <stdlib.h>

angle = ( 1.0 * strtoul(argv[2], NULL, 0) / 360 ) * 3.14159 * 2;      /* use 25 degrees     */

  /* 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 );
原文地址:https://www.cnblogs.com/CZM-/p/5323073.html