MHEG5  18.9.0
MHEG5 Documentation
Classes | Macros | Typedefs | Enumerations | Functions
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"

Go to the source code of this file.

Classes

struct  _LineLimit
 
struct  _CharData
 
struct  s_properties
 

Macros

#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. More...
 
void * MG_DrawUKText (const TextString unistr, pDrawTextAttrib attrib, const VRect txt_box)
 Create Surface and draw text string on it and terminate freetype library. More...
 
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. More...
 
void * MG_DrawText (const TextString unistr, pDrawTextAttrib attrib, const VRect txt_box)
 Create Surface and draw text string on it and terminate freetype library. More...
 

Detailed Description

MHEG text render that uses the Freetype font library.

Date
28/05/2008
Author
Adam Sturtridge

Definition in file mg_drawtext.c.

Macro Definition Documentation

#define COLOUR_STACK_SIZE   18

Definition at line 46 of file mg_drawtext.c.

#define GLYPH_NDX (   x)    (x - 30)

Definition at line 103 of file mg_drawtext.c.

#define MAX_NUM_CHARS   64

Definition at line 107 of file mg_drawtext.c.

#define MAX_NUM_LINES   32

Definition at line 106 of file mg_drawtext.c.

#define MTRC_POSN (   mll,
  tls,
  mr,
  fsz 
)    mll + (PNTS_LS_LEN(tls) * mr) / fsz

Definition at line 110 of file mg_drawtext.c.

#define P_METRIC_POSITION (   pp)    MTRC_POSN(pp->metric_line_length, pp->total_letter_space, pp->metric_resn, pp->pnts_font_size)

Definition at line 126 of file mg_drawtext.c.

#define P_MTRC_2_PNTS (   pp,
  mtr 
)    ((mtr) * pp->pnts_font_size + pp->metric_resn - 1) / pp->metric_resn

Definition at line 123 of file mg_drawtext.c.

#define P_MTRC_2_SPXL (   pp,
  mtr 
)    P_PNTS_2_SPXL(pp, P_MTRC_2_PNTS(pp, mtr))

Definition at line 124 of file mg_drawtext.c.

#define P_PNTS_2_SPXL (   pp,
  pts 
)    ((((pts) * 45) + pp->pixel_par_x - 1) / pp->pixel_par_x)

Definition at line 122 of file mg_drawtext.c.

#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)

Definition at line 128 of file mg_drawtext.c.

#define P_SPIXEL_POSITION (   pp)    (((((P_POINTS_POSITION(pp)) * 45) + pp->pixel_par_x - 1) / pp->pixel_par_x) + pp->spxl_tab_start)

Definition at line 130 of file mg_drawtext.c.

#define PNTS_LS_LEN (   tls)    ((tls + 255) >> 8)

Definition at line 109 of file mg_drawtext.c.

#define S_METRIC_POSITION (   pp)    MTRC_POSN(pp.metric_line_length, pp.total_letter_space, pp.metric_resn, pp.pnts_font_size)

Definition at line 114 of file mg_drawtext.c.

#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)

Definition at line 116 of file mg_drawtext.c.

#define S_SPIXEL_POSITION (   pp)    (((((S_POINTS_POSITION(pp)) * 45) + pp.pixel_par_x - 1) / pp.pixel_par_x) + pp.spxl_tab_start)

Definition at line 118 of file mg_drawtext.c.

#define TRANSPARENT_COLOUR   0

Definition at line 51 of file mg_drawtext.c.

#define U_CTRL_A   0x01

Definition at line 56 of file mg_drawtext.c.

#define U_CTRL_B   0x02

Definition at line 57 of file mg_drawtext.c.

#define U_CTRL_C   0x03

Definition at line 58 of file mg_drawtext.c.

#define U_CTRL_D   0x04

Definition at line 59 of file mg_drawtext.c.

#define U_CTRL_E   0x05

Definition at line 60 of file mg_drawtext.c.

#define U_CTRL_F   0x06

Definition at line 61 of file mg_drawtext.c.

#define U_CTRL_FS   0x1C

Definition at line 79 of file mg_drawtext.c.

#define U_CTRL_G   0x07

Definition at line 62 of file mg_drawtext.c.

#define U_CTRL_GS   0x1D

Definition at line 80 of file mg_drawtext.c.

#define U_CTRL_H   0x08

Definition at line 63 of file mg_drawtext.c.

#define U_CTRL_K   0x0B

Definition at line 64 of file mg_drawtext.c.

#define U_CTRL_L   0x0C

Definition at line 65 of file mg_drawtext.c.

#define U_CTRL_N   0x0E

Definition at line 66 of file mg_drawtext.c.

#define U_CTRL_NULL   0x00

Definition at line 55 of file mg_drawtext.c.

#define U_CTRL_O   0x0F

Definition at line 67 of file mg_drawtext.c.

#define U_CTRL_P   0x10

Definition at line 68 of file mg_drawtext.c.

#define U_CTRL_Q   0x11

Definition at line 69 of file mg_drawtext.c.

#define U_CTRL_R   0x12

Definition at line 70 of file mg_drawtext.c.

#define U_CTRL_RS   0x1E

Definition at line 81 of file mg_drawtext.c.

#define U_CTRL_S   0x13

Definition at line 71 of file mg_drawtext.c.

#define U_CTRL_T   0x14

Definition at line 72 of file mg_drawtext.c.

#define U_CTRL_U   0x15

Definition at line 73 of file mg_drawtext.c.

#define U_CTRL_US   0x1F

Definition at line 82 of file mg_drawtext.c.

#define U_CTRL_V   0x16

Definition at line 74 of file mg_drawtext.c.

#define U_CTRL_W   0x17

Definition at line 75 of file mg_drawtext.c.

#define U_CTRL_X   0x18

Definition at line 76 of file mg_drawtext.c.

#define U_CTRL_Y   0x19

Definition at line 77 of file mg_drawtext.c.

#define U_CTRL_Z   0x1A

Definition at line 78 of file mg_drawtext.c.

#define UNICODE_APOSTROPHE_N   (0x0149)

Definition at line 92 of file mg_drawtext.c.

#define UNICODE_CR   (0x0d)

Definition at line 88 of file mg_drawtext.c.

#define UNICODE_ESC   (0x1b)

Definition at line 89 of file mg_drawtext.c.

#define UNICODE_FIGURE_SPACE   (0x2007)

Definition at line 91 of file mg_drawtext.c.

#define UNICODE_HARD_SPACE   (0xa0)

Definition at line 90 of file mg_drawtext.c.

#define UNICODE_HYPER_ANCHOR_END   (0x61)

Definition at line 94 of file mg_drawtext.c.

#define UNICODE_HYPER_ANCHOR_START   (0x41)

Definition at line 93 of file mg_drawtext.c.

#define UNICODE_HYPER_ATTRIB_END   (0x64)

Definition at line 98 of file mg_drawtext.c.

#define UNICODE_HYPER_ATTRIB_START   (0x44)

Definition at line 97 of file mg_drawtext.c.

#define UNICODE_LF   (0x0a)

Definition at line 87 of file mg_drawtext.c.

#define UNICODE_SPACE   (' ')

Definition at line 85 of file mg_drawtext.c.

#define UNICODE_TAB   ('\t')

Definition at line 86 of file mg_drawtext.c.

#define UNICODE_TEXT_COLOUR_END   (0x63)

Definition at line 96 of file mg_drawtext.c.

#define UNICODE_TEXT_COLOUR_START   (0x43)

Definition at line 95 of file mg_drawtext.c.

Typedef Documentation

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

Enumeration Type Documentation

Enumerator
NO_BREAK 
HAD_BREAK 
BREAKING 
NEW_LINE 
OVER_RUN 

Definition at line 158 of file mg_drawtext.c.

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

Definition at line 2178 of file mg_drawtext.c.

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

Definition at line 2275 of file mg_drawtext.c.

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

Definition at line 1953 of file mg_drawtext.c.

S16BIT MG_TextWidth ( const TextString  unistr,
pDrawTextAttrib  attrib 
)
Parameters
unistrUnicode String
attribAttributes on the string (including font data)
Returns
width of text in pixels

Definition at line 2124 of file mg_drawtext.c.

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

Definition at line 1163 of file mg_drawtext.c.