Blender V2.61 - r43446
Defines | Functions | Variables

blf_font.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ft2build.h>
#include "MEM_guardedalloc.h"
#include "DNA_vec_types.h"
#include "BLI_blenlib.h"
#include "BLI_linklist.h"
#include "BLI_math.h"
#include "BIF_gl.h"
#include "BLF_api.h"
#include "blf_internal_types.h"
#include "blf_internal.h"

Go to the source code of this file.

Defines

#define BLF_UTF8_NEXT_FAST(_font, _g, _str, _i, _c, _glyph_ascii_table)
#define BLF_KERNING_VARS(_font, _has_kerning, _kern_mode)
#define BLF_KERNING_STEP(_font, _kern_mode, _g_prev, _g, _delta, _pen_x)

Functions

int blf_font_init (void)
void blf_font_exit (void)
void blf_font_size (FontBLF *font, int size, int dpi)
static void blf_font_ensure_ascii_table (FontBLF *font)
void blf_font_draw (FontBLF *font, const char *str, unsigned int len)
void blf_font_draw_ascii (FontBLF *font, const char *str, unsigned int len)
void blf_font_buffer (FontBLF *font, const char *str)
void blf_font_boundbox (FontBLF *font, const char *str, rctf *box)
void blf_font_width_and_height (FontBLF *font, const char *str, float *width, float *height)
float blf_font_width (FontBLF *font, const char *str)
float blf_font_height (FontBLF *font, const char *str)
float blf_font_fixed_width (FontBLF *font)
void blf_font_free (FontBLF *font)
static void blf_font_fill (FontBLF *font)
FontBLFblf_font_new (const char *name, const char *filename)
void blf_font_attach_from_mem (FontBLF *font, const unsigned char *mem, int mem_size)
FontBLFblf_font_new_from_mem (const char *name, unsigned char *mem, int mem_size)

Variables

static FT_Library ft_lib

Detailed Description

Definition in file blf_font.c.


Define Documentation

#define BLF_KERNING_STEP (   _font,
  _kern_mode,
  _g_prev,
  _g,
  _delta,
  _pen_x 
)
Value:
{                                                                             \
    if (_g_prev) {                                                            \
        _delta.x= _delta.y= 0;                                                \
        if (FT_Get_Kerning((_font)->face,                                     \
                           (_g_prev)->idx,                                    \
                           (_g)->idx,                                         \
                           _kern_mode,                                        \
                           &(_delta)) == 0)                                   \
        {                                                                     \
            _pen_x += delta.x >> 6;                                           \
        }                                                                     \
    }                                                                         \
}                                                                             \

Definition at line 145 of file blf_font.c.

Referenced by blf_font_boundbox(), blf_font_draw(), and blf_font_draw_ascii().

#define BLF_KERNING_VARS (   _font,
  _has_kerning,
  _kern_mode 
)
Value:
const short _has_kerning= FT_HAS_KERNING((_font)->face);                  \
    const FT_UInt _kern_mode= (_has_kerning == 0) ? 0 :                       \
                             (((_font)->flags & BLF_KERNING_DEFAULT) ?        \
                              ft_kerning_default : FT_KERNING_UNFITTED)       \

Definition at line 138 of file blf_font.c.

Referenced by blf_font_boundbox(), blf_font_draw(), and blf_font_draw_ascii().

#define BLF_UTF8_NEXT_FAST (   _font,
  _g,
  _str,
  _i,
  _c,
  _glyph_ascii_table 
)
Value:
if(((_c)= (_str)[_i]) < 0x80) {                                           \
        _g= (_glyph_ascii_table)[_c];                                         \
        _i++;                                                                 \
    }                                                                         \
    else if ((_c= BLI_str_utf8_as_unicode_step(_str, &(_i)))!=BLI_UTF8_ERR) { \
        if ((_g= blf_glyph_search((_font)->glyph_cache, _c)) == NULL) {       \
            _g= blf_glyph_add(_font,                                          \
                              FT_Get_Char_Index((_font)->face, _c), _c);      \
        }                                                                     \
    }                                                                         \

Definition at line 125 of file blf_font.c.

Referenced by blf_font_boundbox(), and blf_font_draw().


Function Documentation

void blf_font_attach_from_mem ( FontBLF font,
const unsigned char *  mem,
int  mem_size 
)

Definition at line 548 of file blf_font.c.

References FontBLF::face.

Referenced by BLF_metrics_attach().

void blf_font_boundbox ( FontBLF font,
const char *  str,
rctf box 
)
void blf_font_buffer ( FontBLF font,
const char *  str 
)

Definition at line 215 of file blf_font.c.

References FontBLF::b_col, g, GlyphCacheBLF::glyph_ascii_table, FontBLF::glyph_cache, i, NULL, and FontBLF::pos.

Referenced by BLF_draw_buffer().

void blf_font_draw ( FontBLF font,
const char *  str,
unsigned int  len 
)
void blf_font_draw_ascii ( FontBLF font,
const char *  str,
unsigned int  len 
)
static void blf_font_ensure_ascii_table ( FontBLF font) [static]
void blf_font_exit ( void  )

Definition at line 66 of file blf_font.c.

References ft_lib.

Referenced by BLF_exit().

static void blf_font_fill ( FontBLF font) [static]
float blf_font_fixed_width ( FontBLF font)
void blf_font_free ( FontBLF font)
float blf_font_height ( FontBLF font,
const char *  str 
)

Definition at line 425 of file blf_font.c.

References FontBLF::aspect, BLF_ASPECT, blf_font_boundbox(), FontBLF::flags, rctf::ymax, and rctf::ymin.

Referenced by BLF_height().

int blf_font_init ( void  )

Definition at line 61 of file blf_font.c.

References ft_lib.

Referenced by BLF_init().

FontBLF* blf_font_new ( const char *  name,
const char *  filename 
) [read]
FontBLF* blf_font_new_from_mem ( const char *  name,
unsigned char *  mem,
int  mem_size 
) [read]
void blf_font_size ( FontBLF font,
int  size,
int  dpi 
)
float blf_font_width ( FontBLF font,
const char *  str 
)

Definition at line 411 of file blf_font.c.

References FontBLF::aspect, BLF_ASPECT, blf_font_boundbox(), FontBLF::flags, rctf::xmax, and rctf::xmin.

Referenced by BLF_width().

void blf_font_width_and_height ( FontBLF font,
const char *  str,
float *  width,
float *  height 
)

Variable Documentation

FT_Library ft_lib [static]