MHEG5  15.3.0
source/graphics/src/mg_drawtext.c File Reference

MHEG text render that uses the Freetype font library. More...

#include <stdio.h>
#include <string.h>
#include "stb_osd.h"
#include "mg_font.h"
#include "mg_drawtext.h"
#include "glue_memory.h"
#include "glue_debug.h"
#include "mg_osd.h"
#include "osd_utils.h"
#include "glue_assert.h"

Data Structures

struct  _LineLimit
struct  _CharData
struct  s_properties

Defines

#define COLOUR_STACK_SIZE   18
#define TRANSPARENT_COLOUR   0
#define U_CTRL_NULL   0x00
#define U_CTRL_A   0x01
#define U_CTRL_B   0x02
#define U_CTRL_C   0x03
#define U_CTRL_D   0x04
#define U_CTRL_E   0x05
#define U_CTRL_F   0x06
#define U_CTRL_G   0x07
#define U_CTRL_H   0x08
#define U_CTRL_K   0x0B
#define U_CTRL_L   0x0C
#define U_CTRL_N   0x0E
#define U_CTRL_O   0x0F
#define U_CTRL_P   0x10
#define U_CTRL_Q   0x11
#define U_CTRL_R   0x12
#define U_CTRL_S   0x13
#define U_CTRL_T   0x14
#define U_CTRL_U   0x15
#define U_CTRL_V   0x16
#define U_CTRL_W   0x17
#define U_CTRL_X   0x18
#define U_CTRL_Y   0x19
#define U_CTRL_Z   0x1A
#define U_CTRL_FS   0x1C
#define U_CTRL_GS   0x1D
#define U_CTRL_RS   0x1E
#define U_CTRL_US   0x1F
#define UNICODE_SPACE   (' ')
#define UNICODE_TAB   ('\t')
#define UNICODE_LF   (0x0a)
#define UNICODE_CR   (0x0d)
#define UNICODE_ESC   (0x1b)
#define UNICODE_HARD_SPACE   (0xa0)
#define UNICODE_FIGURE_SPACE   (0x2007)
#define UNICODE_APOSTROPHE_N   (0x0149)
#define UNICODE_HYPER_ANCHOR_START   (0x41)
#define UNICODE_HYPER_ANCHOR_END   (0x61)
#define UNICODE_TEXT_COLOUR_START   (0x43)
#define UNICODE_TEXT_COLOUR_END   (0x63)
#define UNICODE_HYPER_ATTRIB_START   (0x44)
#define UNICODE_HYPER_ATTRIB_END   (0x64)
#define GLYPH_NDX(x)   (x - 30)
#define MAX_NUM_LINES   32
#define MAX_NUM_CHARS   64
#define PNTS_LS_LEN(tls)   ((tls + 255) >> 8)
#define MTRC_POSN(mll, tls, mr, fsz)   mll + (PNTS_LS_LEN(tls) * mr) / fsz
#define S_METRIC_POSITION(pp)   MTRC_POSN(pp.metric_line_length, pp.total_letter_space, pp.metric_resn, pp.pnts_font_size)
#define S_POINTS_POSITION(pp)   PNTS_LS_LEN(pp.total_letter_space) + ((pp.metric_line_length * pp.pnts_font_size + pp.metric_resn - 1) / pp.metric_resn)
#define S_SPIXEL_POSITION(pp)   (((((S_POINTS_POSITION(pp)) * 45) + pp.pixel_par_x - 1) / pp.pixel_par_x) + pp.spxl_tab_start)
#define P_PNTS_2_SPXL(pp, pts)   ((((pts) * 45) + pp->pixel_par_x - 1) / pp->pixel_par_x)
#define P_MTRC_2_PNTS(pp, mtr)   ((mtr) * pp->pnts_font_size + pp->metric_resn - 1) / pp->metric_resn
#define P_MTRC_2_SPXL(pp, mtr)   P_PNTS_2_SPXL(pp, P_MTRC_2_PNTS(pp, mtr))
#define P_METRIC_POSITION(pp)   MTRC_POSN(pp->metric_line_length, pp->total_letter_space, pp->metric_resn, pp->pnts_font_size)
#define P_POINTS_POSITION(pp)   PNTS_LS_LEN(pp->total_letter_space) + ((pp->metric_line_length * pp->pnts_font_size + pp->metric_resn - 1) / pp->metric_resn)
#define P_SPIXEL_POSITION(pp)   (((((P_POINTS_POSITION(pp)) * 45) + pp->pixel_par_x - 1) / pp->pixel_par_x) + pp->spxl_tab_start)

Typedefs

typedef struct _LineLimit LineLimit
typedef struct _CharData CharData
typedef struct s_properties S_PROPERTIES

Enumerations

enum  EBreakState {
  NO_BREAK, HAD_BREAK, BREAKING, NEW_LINE,
  OVER_RUN
}

Functions

void ProcessNewLine (S_PROPERTIES *pp, CharData *chars, S_FontSize *f_sz_data, U16BIT line_num, U8BIT justify)
 Process for adding a new line.
void * MG_DrawUKText (const TextString unistr, pDrawTextAttrib attrib, const VRect txt_box)
 Create Surface and draw text string on it and terminate freetype library.
S16BIT MG_TextWidth (const TextString unistr, pDrawTextAttrib attrib)
void MG_DrawScreenText (const TextString unistr, pDrawTextAttrib attrib, S_SURFACE *canvas)
 Single line text string drawn on existing Surface.
void * MG_DrawText (const TextString unistr, pDrawTextAttrib attrib, const VRect txt_box)
 Create Surface and draw text string on it and terminate freetype library.

Detailed Description

MHEG text render that uses the Freetype font library.

Date:
28/05/2008
Author:
Adam Sturtridge

Function Documentation

void MG_DrawScreenText ( const TextString  unistr,
pDrawTextAttrib  attrib,
S_SURFACE canvas 
)

Single line text string drawn on existing Surface.

Parameters:
unistrUnicode String
attribAttributes on the string (including font data)
canvasSurface
Returns:
n/a
void* MG_DrawText ( const TextString  unistr,
pDrawTextAttrib  attrib,
const VRect  txt_box 
)

Create Surface and draw text string on it and terminate freetype library.

Parameters:
unistrUnicode String
attribAttributes on the string (including font data)
txt_boxRectangle in SD pixel size
Returns:
pointer to surface, NULL if no text can be drawn in box
void* MG_DrawUKText ( const TextString  unistr,
pDrawTextAttrib  attrib,
const VRect  txt_box 
)

Create Surface and draw text string on it and terminate freetype library.

Parameters:
unistrUnicode String
attribAttributes on the string (including font data)
txt_boxRectangle in SD pixel size
Returns:
pointer to surface, NULL if no text can be drawn in box
S16BIT MG_TextWidth ( const TextString  unistr,
pDrawTextAttrib  attrib 
)
Parameters:
unistrUnicode String
attribAttributes on the string (including font data)
Returns:
width of text in pixels
void ProcessNewLine ( S_PROPERTIES pp,
CharData chars,
S_FontSize f_sz_data,
U16BIT  line_num,
U8BIT  justify 
)

Process for adding a new line.

Parameters:
.
Returns:
n/a
 All Data Structures Files Functions Variables Typedefs Defines