View Single Post
Old 10-29-2018, 02:10 PM   #99
PoP
 curly᷂͓̫̙᷊̥̮̾ͯͤͭͬͦͨ ʎʌɹnɔ
PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.PoP ought to be getting tired of karma fortunes by now.
 
PoP's Avatar
 
Posts: 3,018
Karma: 50506927
Join Date: Dec 2010
Location: ♁ ᴺ₄₅°₃₀' ᵂ₇₃°₃₇' ±₆₀"
Device: K3₃.₄.₃ PW3&4₅.₁₃.₃
Just to play, I wanted to include:

Code:
cd /mnt/us/tcc
tcc -Iinclude -Iinclude/freetype2/freetype -Iinclude/freetype2 -Iinclude/fbink -L/mnt/us/linkfonts/lib/autohint -lfreetype -L/mnt/us/usbnet/bin -lfbink -o  fbinkpantspatrol fbinkpantspatrol.c
and see if I could call fbink to draw the FT glyphs,

Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include <ft2build.h>
#include FT_FREETYPE_H

#include <fbink.h>

  int main( )
  {
    FT_Library       font_library;
    FT_Face          font_face;
    FT_Bitmap        bitmap;
    FT_GlyphSlot     cur_glyph;
    FT_Glyph_Metrics glyph_metrics;

    int  glyph_ind;
    int  num_chars;
    char char_name[256];
    
    int x;

// What a FBInk config should look like. Perfectly sane when fully zero-initialized.
//struct FBIink_config {
// 	short int row;             // y axis (i.e., line), counts down from the bottom of the screen if negative
//	short int col;             // x axis (i.e., column), counts down from the right edge of the screen if negative
//	uint8_t   fontmult;        // Font scaling multiplier (i.e., 4 -> x4), 0 means automatic.
//	uint8_t   fontname;        // Request a specific font (c.f., FONT_INDEX_T enum)
// 	bool      is_inverted;     // Invert colors
//	bool      is_flashing;     // Request a black flash on refresh
//	bool      is_cleared;      // Clear the screen beforehand (honors is_inverted)
// 	bool      is_centered;     // Center the text (horizontally)
//	short int hoffset;         // Horizontal offset (in pixels) for text position
// 	short int voffset;         // Vertical offset (in pixels) for text position
//	bool      is_halfway;      // Vertically center the text, honoring row offsets
// 	bool      is_padded;       // Pad the text with blanks (on the left, or on both sides if is_centered)
// 	uint8_t   fg_color;        // Requested foreground color for text (c.f., FG_COLOR_INDEX_T enum)
// 	uint8_t   bg_color;        // Requested background color for text (c.f., BG_COLOR_INDEX_T enum)
//	bool      is_overlay;      // Don't draw bg, use inverse of fb's underlying pixel as pen fg color
//	bool      is_bgless;       // Don't draw bg (mutually exclusive with is_overlay)
// 	bool      is_fgless;       // Don't draw fg (takes precendence over is_overlay/is_bgless)
// 	bool      is_quiet;        // Hide fbink_init()'s hardware setup info (sent to stderr)
//	bool      ignore_alpha;    // Ignore any potential alpha channel in source image (i.e., flatten the image)
//	uint8_t   halign;    // Horizontal alignment of images (NONE/LEFT, CENTER, EDGE/RIGHT; c.f., ALIGN_INDEX_T enum)
// 	uint8_t   valign;    // Vertical alignment of images (NONE/TOP, CENTER, EDGE/BOTTOM; c.f., ALIGN_INDEX_T enum)
//};

FBInkConfig fbink_config = { 0 };
int fbfd = FBFD_AUTO;

//fbink_init API
//fbink_init(int fbfd, const FBInkConfig* fbink_config)
fbink_init(fbfd, &fbink_config);


    if ( FT_Init_FreeType( &font_library ) )
      exit( 1 );
    if ( FT_New_Face( font_library, "pantspatrol.ttf", 0 , &font_face ) )
      exit( 1 );
    if ( FT_Set_Char_Size( font_face , 0 , 768 , 300 , 300 ) )
      exit( 1 );

    num_chars = (int)font_face->num_glyphs;
    FT_Set_Transform( font_face , NULL , NULL );

    for ( glyph_ind = 0 ; glyph_ind < num_chars; glyph_ind++ )
    {
      if ( FT_Load_Glyph( font_face, glyph_ind, FT_LOAD_DEFAULT ) )
        exit( 1 );
      cur_glyph = font_face->glyph;
      if ( cur_glyph->format != FT_GLYPH_FORMAT_BITMAP )
        if ( FT_Render_Glyph( font_face->glyph, FT_RENDER_MODE_MONO ) )
          exit( 1 );
      if ( FT_Get_Glyph_Name( font_face, glyph_ind, char_name, 16 ) )
        exit( 1 );

      bitmap = cur_glyph->bitmap;
      x=glyph_metrics.horiBearingX / 64;

//  fbink_print_raw_data API
//    fbink_print_raw_data(int fbfd,
//			 unsigned char* data,
//			 const int w,
//			 const int h ,
//			 const size_t len,
//			 short int x_off,
//			 short int y_off,
//			 const FBInkConfig* fbink_config)

      fbink_print_raw_data(fbfd, &bitmap, bitmap.width, bitmap.rows, bitmap.width*bitmap.rows, x, -glyph_metrics. horiBearingY / 64, &fbink_config);
      
      x=x+glyph_metrics.horiAdvance / 64;
      glyph_metrics = cur_glyph->metrics;

      printf( "Glyph %d  name %s %ld %ld %ld %d %d\n",
              glyph_ind,
              char_name,
              glyph_metrics.horiBearingX / 64,
              glyph_metrics.horiBearingY / 64,
              glyph_metrics.horiAdvance / 64,
              bitmap.width , bitmap.rows );
    }

    return 0;
  }
at the risk of exposing my limited coding ability

Last edited by PoP; 11-01-2018 at 03:11 PM. Reason: spelling
PoP is offline   Reply With Quote