26 #error This file should be included from mg_drawtext.c 29 static void RenderGlyphFn( TDColor *pixel, U8BIT *grey_src, U16BIT height,
30 U8BIT width, U8BIT pitch, U16BIT stride, OSDColor full_col
32 , TDColor *cnvs_min, TDColor *cnvs_max
37 TDColor td_col = MakeTDColor(full_col);
39 CalcColorArray(td_col);
43 if (IsOpaqueColor(td_col))
47 for (x = width; x--; grey_src++, pixel++)
49 U32BIT grey_val = GreyValue( *grey_src );
51 assert((pixel >= cnvs_min) && (pixel < cnvs_max));
53 if (grey_val == SRC_FORE_MAX)
59 CombineAlphaColour( *pixel, grey_val, full_col, td_col )
70 for (x = width; x--; grey_src++, pixel++)
72 U32BIT grey_val = GreyValue( *grey_src );
74 assert((pixel >= cnvs_min) && (pixel < cnvs_max));
76 CombineAlphaColour( *pixel, grey_val, full_col, td_col )
85 FT_Face the_face, U8BIT vt_justify, U8BIT hz_justify,
86 U16BIT line_space, S16BIT sd_top, U16BIT sd_height,
87 U16BIT total_lines, U16BIT avail_lines,
S_SURFACE *canvas )
89 U32BIT m_size, pixel_line_start;
90 TDColor *text_origin, *line_origin, *char_origin;
93 S32BIT left, right, ctop, avail_width, hd_top;
94 U16BIT line_num, char_ndx, cheight, buff_stride;
98 TDColor *cnvs_min, *cnvs_max;
104 avail_width = canvas->width;
105 text_origin = (TDColor *)canvas->col_buff;
106 buff_stride = (U16BIT)(canvas->buff_pitch /
sizeof(TDColor));
108 cnvs_min = text_origin;
109 m_size = buff_stride;
110 m_size *= canvas->height;
111 cnvs_max = &text_origin[m_size];
113 canvas->opaque = FALSE;
114 hd_top = (sd_top * mg_ctxt.osd_y.mlt) / mg_ctxt.osd_y.div;
115 sd_top += sz_data->bb_sd_top;
116 hd_top += sz_data->bound_box.top;
120 if (total_lines > avail_lines)
122 line_num = total_lines - avail_lines;
123 while (disp_lines->line_num < line_num)
125 char_ndx = disp_lines->end_ndx;
128 cheight = avail_lines - 1;
132 cheight = total_lines - 1;
134 cheight = (cheight * line_space) + sz_data->bb_sd_height;
135 assert( cheight <= sd_height );
136 if (cheight < sd_height)
138 sd_top += sd_height - cheight;
142 case JUSTIFY_V_CENTRE:
143 if (total_lines > avail_lines)
145 total_lines = avail_lines;
147 cheight = ((total_lines - 1) * line_space) + sz_data->bb_sd_height;
148 assert( cheight <= sd_height );
149 if (cheight < sd_height)
151 sd_top += (sd_height - cheight) >> 1;
156 case JUSTIFY_V_START:
157 if (total_lines > avail_lines)
159 total_lines = avail_lines;
162 while (line_num != total_lines)
164 if (line_num == disp_lines->line_num)
166 pixel_line_start = (sd_top * mg_ctxt.osd_y.mlt) / mg_ctxt.osd_y.div;
167 if (pixel_line_start < (U32BIT)hd_top)
169 pixel_line_start = 0;
170 line_origin = text_origin;
174 pixel_line_start -= hd_top;
175 line_origin = text_origin + (pixel_line_start * buff_stride);
180 right = disp_lines->position + disp_lines->l_width;
181 left = right - avail_width;
183 case JUSTIFY_H_CENTRE:
184 left = disp_lines->position;
186 left += (disp_lines->l_width + 1 - avail_width) >> 1;
187 right += (disp_lines->l_width + avail_width) >> 1;
190 case JUSTIFY_H_START:
191 left = disp_lines->position;
192 right = left + avail_width;
195 for (char_ndx = disp_lines->start_ndx; char_ndx != disp_lines->end_ndx; char_ndx++)
197 pCharInfo = char_data + char_ndx;
198 if ((pCharInfo->real_position >= left) &&
199 ((pCharInfo->real_position + pCharInfo->width) <= right) &&
200 NotTransparent(pCharInfo->colour))
203 ctop = sz_data->bound_box.top;
204 if (pCharInfo->gf_ndx != 0)
206 load_flags = FT_LOAD_RENDER;
216 if (pCharInfo->uni_chr == 0x00e3 ||
217 pCharInfo->uni_chr == 0x00f1 ||
218 pCharInfo->uni_chr == 0x00f5)
220 load_flags |= FT_LOAD_NO_AUTOHINT;
222 if (FT_Load_Glyph( the_face, pCharInfo->gf_ndx, load_flags ) != 0)
229 assert( pCharInfo->width == the_face->glyph->bitmap.width );
230 if (the_face->glyph->bitmap.pitch < 0)
231 m_size = -the_face->glyph->bitmap.pitch;
233 m_size = the_face->glyph->bitmap.pitch;
234 ctop -= the_face->glyph->bitmap_top;
235 cheight = the_face->glyph->bitmap.rows;
236 src_buff = the_face->glyph->bitmap.buffer;
241 c_sbit = &sz_data->sbit_cache[pCharInfo->uni_chr - FIRST_CACHE_CHAR];
242 m_size = c_sbit->width;
244 src_buff = (U8BIT *)&sz_data->sbit_cache[CHAR_CACHE_SIZE];
245 src_buff += c_sbit->bmp_ndx;
246 cheight = c_sbit->height;
248 assert( sz_data->bound_box.height >= cheight );
249 char_origin = line_origin;
252 if ((pixel_line_start + ctop + cheight) > canvas->height)
254 ctop = canvas->height - (cheight + pixel_line_start);
256 char_origin += ctop * buff_stride;
258 char_origin += pCharInfo->real_position - left;
260 RenderGlyphFn( char_origin, src_buff, cheight, pCharInfo->width, (U8BIT)m_size, buff_stride, pCharInfo->colour
269 sd_top += line_space;
Definition: mg_drawtext.c:137
Definition: mg_drawtext.c:146