42 #define FONT_ATTRIBUTES_DEFAULT_SIZE (24) 43 #define FONT_ATTRIBUTES_DEFAULT_LINESPACE (28) 44 #define FONT_ATTRIBUTES_DEFAULT_LETTERSPACE (0) 47 #define MINIMUM_BOX_DIMENSION 8 50 #define DEFAULT_LINK_COLOUR (RGBT(0x00, 0x00, 0xff, 0x00)) 51 #define DEFAULT_ACTIVE_LINK_COLOUR (RGBT(0xff, 0x00, 0x00, 0x00)) 52 #define DEFAULT_VISITED_LINK_COLOUR (RGBT(0x3f, 0x1f, 0x7f, 0x00)) 55 #define OBSCURED_INPUT_CHAR ('*') 58 static MHEG5String hk_font_name = {(U32BIT)14, (U8BIT *)
"rec://font/hk1"};
72 static int parseInt(
MHEG5String *
string,
int *offset)
79 localOffset = *offset;
85 if (string->data[localOffset] ==
'-')
93 else if (string->data[localOffset] ==
'+')
101 while ((localOffset < string->len) && (string->data[localOffset] <=
'9') &&
102 (string->data[localOffset] >=
'0'))
105 value = value * 10 + (int) (string->data[localOffset]) - (int)
'0';
112 *offset = localOffset;
164 U8BIT font_size, font_style;
167 int retSize = FONT_ATTRIBUTES_DEFAULT_SIZE;
168 int retLinespace = FONT_ATTRIBUTES_DEFAULT_LINESPACE;
169 int retLetterspace = FONT_ATTRIBUTES_DEFAULT_LETTERSPACE;
171 if (txt->visible.graphic_data)
174 txt->visible.graphic_data = NULL;
176 if ((txt->visible.boxSize[0] < MINIMUM_BOX_DIMENSION) ||
177 (txt->visible.boxSize[1] < MINIMUM_BOX_DIMENSION)
180 TRACE(TTEXT, (
"TxtBox is too small (%ld,%ld)", txt->visible.boxSize[0], txt->visible.boxSize[1]));
183 pBox->width = (U16BIT)txt->visible.boxSize[0];
184 pBox->height = (U16BIT)txt->visible.boxSize[1];
185 pBox->left = (S16BIT)txt->visible.position[0];
186 pBox->top = (S16BIT)txt->visible.position[1];
187 pStr->len = (U16BIT)txt->visible.ingredient.dataLen;
188 pStr->data = (U16BIT *)txt->visible.ingredient.data;
192 txt->visible.restricted = FALSE;
193 if (pBox->width > 720)
195 pBox->width = txt->visible.rect.right - pBox->left;
196 txt->visible.restricted = TRUE;
198 if (pBox->height > 576)
200 pBox->height = txt->visible.rect.bottom - pBox->top;
201 txt->visible.restricted = TRUE;
204 pAttrib->justify = (U8BIT)(txt->verticalJustification << 4) | (U8BIT)(txt->horizontalJustification);
205 if ((pAttrib->justify & JFY_HZ_MASK) == JUSTIFY_H_JUSTIFIED)
207 pAttrib->justify &= ~JUSTIFY_H_JUSTIFIED;
209 if (txt->textWrapping)
211 pAttrib->justify |= WRAP_WORDS;
214 if (txt->textColour.type == MHEG5NONE)
225 if (txt->backgroundColour.type == MHEG5NONE)
238 font_style = FONT_STYLE_PLAIN;
240 if (txt->font.referenced)
242 MHEG5Root *f_obj = MHEG5findObject( txt->font.ref.referenced.grp,
243 txt->font.ref.referenced.id );
245 if (f_obj != NULL && f_obj->clazz == MHEG5FONT)
247 if (((
MHEG5Font *)f_obj)->mg_fnt_index == INVALID_MG_FNT_INDEX)
252 font_index = ((
MHEG5Font *)f_obj)->mg_fnt_index;
255 else if (!txt->font.ref.included.len)
258 if (application->fontBody.referenced)
260 MHEG5Root *f_obj = MHEG5findObject( application->fontBody.ref.referenced.grp,
261 application->fontBody.ref.referenced.id );
263 if (f_obj != NULL && f_obj->clazz == MHEG5FONT)
265 if (((
MHEG5Font *)f_obj)->mg_fnt_index == INVALID_MG_FNT_INDEX)
270 font_index = ((
MHEG5Font *)f_obj)->mg_fnt_index;
275 if (!txt->font.referenced && txt->font.ref.included.len > 0)
277 pAttrib->font_name.zptr = txt->font.ref.included.data;
278 pAttrib->font_name.zlen = txt->font.ref.included.len;
280 else if (!application->fontBody.referenced && application->fontBody.ref.included.len)
282 pAttrib->font_name.zptr = application->fontBody.ref.included.data;
283 pAttrib->font_name.zlen = application->fontBody.ref.included.len;
287 pAttrib->font_name.zlen = 0;
288 pAttrib->font_name.zptr = NULL;
291 if (!txt->characterSetEncoded)
293 pAttrib->character_set = application->characterSet;
297 pAttrib->character_set = txt->characterSet;
304 fa = application->fontAttributes;
311 TRACE(TTEXT, (
"Short FA=(0x%x,0x%x,0x%x,0x%x,0x%x)",
312 fa.data[0], fa.data[1], fa.data[2], fa.data[3], fa.data[4], fa.data[5]))
314 if (fa.data[0] & 0x10)
320 font_style = FONT_STYLE_SQUARE;
327 retSize = fa.data[1];
328 retLinespace = fa.data[2];
329 retLetterspace = fa.data[3] * 256 + fa.data[4];
330 if (retLetterspace > 0x7FFF)
333 retLetterspace -= 0x10000;
340 TRACE(TTEXT, (
"Long FA=(%s)", fa.data))
343 if (MHEG5strncmp((
char *)fa.data, (
char *)
"square", 5) == 0)
345 font_style = FONT_STYLE_SQUARE;
349 while ((i < fa.len) && (fa.data[i] !=
'.'))
355 TRACE(TERROR, (
"Unexpected end of font attributes %.*s", (
int)fa.len, fa.data))
362 retSize = parseInt(&fa, &i);
363 if ((i >= fa.len) || (fa.data[i] !=
'.'))
365 TRACE(TERROR, (
"Unexpected end of font attributes or missing dot %.*s", (
int)fa.len, fa.data))
366 retSize = FONT_ATTRIBUTES_DEFAULT_SIZE;
373 retLinespace = parseInt(&fa, &i);
374 if ((i >= fa.len) || (fa.data[i] !=
'.'))
376 TRACE(TERROR, (
"Unexpected end of font attributes or missing dot %.*s", (
int)fa.len, fa.data))
377 retSize = FONT_ATTRIBUTES_DEFAULT_SIZE;
378 retLinespace = FONT_ATTRIBUTES_DEFAULT_LINESPACE;
385 retLetterspace = parseInt(&fa, &i);
388 TRACE(TERROR, (
"Expected end of font attributes %.*s", (
int)fa.len, fa.data))
389 retSize = FONT_ATTRIBUTES_DEFAULT_SIZE;
390 retLinespace = FONT_ATTRIBUTES_DEFAULT_LINESPACE;
391 retLetterspace = FONT_ATTRIBUTES_DEFAULT_LETTERSPACE;
429 else if (retSize < 31)
433 else if (retSize < 36)
445 pAttrib->font.fp.index = HK_FNT_MAGIC;
446 pAttrib->font.fp.size = font_size;
447 pAttrib->font.fp.style = font_style;
452 pAttrib->font.hdl =
MG_AllocateFont( font_index, font_size, font_style );
456 if (retLetterspace >= 32767)
458 pAttrib->letter_space = 32767;
460 else if (retLetterspace <= -32767)
462 pAttrib->letter_space = -32767;
466 pAttrib->letter_space = (S16BIT)retLetterspace;
470 if (retLinespace >= 255)
472 pAttrib->line_space = 255;
474 else if (retLinespace <= 0)
476 pAttrib->line_space = 0;
480 pAttrib->line_space = (U8BIT)retLinespace;
491 if (getBoxAndAttribs( txt, &box, &attrib, &str ))
493 if ((str.len > 0) && (str.data))
496 attrib.entry_point = -1;
497 txt->visible.graphic_data =
MG_DrawText( str, &attrib, box );
508 if (getBoxAndAttribs((
MHEG5Text *)entry, &box, &attrib, &str ))
510 if (entry->interactible.interactionStatus)
512 attrib.entry_point = (S16BIT)entry->entryPoint;
516 attrib.entry_point = -1;
520 if (cursor == CURSOR_REPLACE)
521 attrib.caret = ENTRY_OVERWRITE_CHAR;
524 attrib.caret = ENTRY_INSERT_CHAR;
526 if ((str.len > 0) || (attrib.entry_point != -1))
532 attrib.justify |= WRAP_WORDS;
537 attrib.justify &= ~(WRAP_WORDS | WRAP_VERTICAL);
549 if (entry->obscuredInput)
553 assert( str.len <= 255 );
556 for (i = 0; i != str.len; i++)
558 if (cursor == CURSOR_INSERT || i != attrib.entry_point - 1)
560 o_str[i] = OBSCURED_INPUT_CHAR;
564 o_str[i] = str.data[i];
568 entry->text.visible.graphic_data =
MG_DrawText( str, &attrib, box );
572 entry->text.visible.graphic_data =
MG_DrawText( str, &attrib, box );
585 if (getBoxAndAttribs((
MHEG5Text *)hypertxt, &box, &attrib, &str ))
587 if ((str.len > 0) && (str.data))
589 attrib.entry_point = -1;
590 attrib.p_ha = &hyp_atb;
591 hyp_atb.link_colour = DEFAULT_LINK_COLOUR;
592 hyp_atb.active_colour = DEFAULT_ACTIVE_LINK_COLOUR;
593 hyp_atb.visit_colour = DEFAULT_VISITED_LINK_COLOUR;
594 hyp_atb.markup_state = 0;
595 hyp_atb.anchor_wrap = FALSE;
596 if (hypertxt->interactible.interactionStatus)
599 if (hypertxt->focusPosition == 0)
604 hyp_atb.focus_position = 1;
608 hyp_atb.focus_position = (S16BIT)hypertxt->focusPosition;
614 hyp_atb.focus_position = 0;
616 hyp_atb.number_of_links = 0;
618 hypertxt->text.visible.graphic_data =
MG_DrawText( str, &attrib, box );
621 if (hyp_atb.anchor_wrap)
623 hypertxt->anchorWrappingFlag = MHEG5TRUE;
627 if (hypertxt->numberOfLinks == -1)
629 hypertxt->numberOfLinks = hyp_atb.number_of_links;
631 if (hypertxt->focusPosition == 0 && hypertxt->numberOfLinks > 0)
633 hypertxt->focusPosition = 1;
637 if (hypertxt->focusPosition != hypertxt->lastFocusPosition)
640 hypertxt->lastFocusPosition = hypertxt->focusPosition;
649 if (txt->backgroundColour.type == MHEG5NONE)
660 txt->visible.boxSize[0], txt->visible.boxSize[1],
664 if (txt->visible.graphic_data)
666 MG_OSDdisplayImage( txt->visible.graphic_data, overlap,
667 txt->visible.position[0], txt->visible.position[1] );
673 OSDColor borderColour;
674 OSDColor backgroundColour;
675 S16BIT left = (S16BIT)entry->text.visible.position[0];
676 S16BIT top = (S16BIT)entry->text.visible.position[1];
677 U16BIT width = (U16BIT)entry->text.visible.boxSize[0];
678 U16BIT height = (U16BIT)entry->text.visible.boxSize[1];
684 if (entry->interactible.highlightStatus && entry->interactible.engineResp)
686 if (entry->interactible.highlightRefColour.type == MHEG5NONE)
697 if (entry->text.backgroundColour.type == MHEG5NONE)
709 if (entry->text.backgroundColour.type == MHEG5NONE)
720 if (entry->text.visible.graphic_data)
722 MG_OSDdisplayImage( entry->text.visible.graphic_data, overlap, left, top );
MHEG5Bool MHEG5stringEqual(MHEG5String *s1, MHEG5String *s2)
Compare two Strings (case sensitive!)
MHEG5Bool MH5_SupportHDGraphics(void)
Returns whether supporting HD Graphics extension.
H_FontSize MG_AllocateFont(S16BIT fnt_index, U8BIT fnt_size, U8BIT fnt_style)
Allocate font of particular size from font file.
void MG_FreeData(void *data)
free surface buffer
OSDColor MHEG5displayColour(MHEG5Colour *colour)
Convert Generic Colour value to OSD specific value. If the generic colour is encoded as a string it i...
Implement the MHEG5 Font Class Font Class Defines a class to represent a character font used for rend...
Event handling. Implementation of a combined queue for events and actions. This is the eventsystem wh...
Implement functions to retrieve MHEG5objects by GroupID and ID.
Implementation of the MHEG5 Application Class Defines a set of Ingredient objects, which are shared within an application scope. Base class: Group Subclasses: None Status: Concrete class.
Mheg5 logging and debug printing.
void MG_OSDdisplayRectangle(S_REGION *overlap, int x, int y, int width, int height, int lineWidth, OSDColor lineColour, OSDColor fillColour)
Draw rectangle.
MHEG class interface to graphics text render.
void * MG_DrawText(const TextString unistr, pDrawTextAttrib attrib, const VRect txt_box)
Create Surface and draw text string on it and terminate freetype library.
void MHEG5sendEvent(MHEG5Root *source, MHEG5EventType event, MHEG5Int data)
Store an event in the asynchronous event queue.
MHEG5Bool MH5_SupportInteractionChannel(void)
Return whether Interaction channel is supported by current profile.
Definition of colour type for MHEG5 - settings and conversions.
Implement generic MHEG5-display functions - independent from the OSD These are generic functions used...
Interface to the MHEG text render that uses Freetype font library.
Engine support utility functions for MHEG5.
MHEG5Application * MHEG5getCurrentApplication(void)
<Function description>="">