| 1 | |
|---|
| 2 | #include "DHL_OSAL.h" |
|---|
| 3 | #include "DHL_DBG.h" |
|---|
| 4 | |
|---|
| 5 | #include "DHL_Graphic.h" |
|---|
| 6 | |
|---|
| 7 | #include "utfAPI.h" |
|---|
| 8 | |
|---|
| 9 | #include "DMG_Util.h" |
|---|
| 10 | #include "grp_jungle.h" |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | //#include "EIA_708_B_13.h" |
|---|
| 14 | //#include "EIA_708_B_14.h" |
|---|
| 15 | //#include "EIA_708_B_15.h" |
|---|
| 16 | |
|---|
| 17 | #include "EIA_708_B_17.h" |
|---|
| 18 | #include "EIA_708_B_19.h" |
|---|
| 19 | #include "EIA_708_B_21.h" |
|---|
| 20 | //#include "EIA_708_B_23.h" |
|---|
| 21 | //#include "EIA_708_B_25.h" |
|---|
| 22 | //#include "EIA_708_B_26.h" |
|---|
| 23 | //#include "EIA_708_B_28.h" |
|---|
| 24 | //#include "EIA_708_B_30.h" |
|---|
| 25 | //#include "EIA_708_B_32.h" |
|---|
| 26 | //#include "EIA_708_B_OL.h" |
|---|
| 27 | #include "JUNGR_FONT_UNI.h" |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | //#include <string.h> |
|---|
| 31 | //#include <string.h> |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | DHL_MODULE("GRP_JG", 0); |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | #define CH_BLANK 0x20 |
|---|
| 38 | #define MAX_CH_W (p_reg_font_attr.size*8/10) |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | static UT_FC p_reg_fc; |
|---|
| 42 | static Jungle_FontAttr p_reg_font_attr; |
|---|
| 43 | |
|---|
| 44 | |
|---|
| 45 | |
|---|
| 46 | /* antialias dhl graphic¿¡¼ ±×´ë·Î °¡Á®¿È */ |
|---|
| 47 | static UINT32 p_antialias_argb8888_pixels(UINT32 bg_pixel, UINT32 fg_pixel, int alpha) |
|---|
| 48 | { |
|---|
| 49 | int a1,r1,g1,b1; |
|---|
| 50 | int a2,r2,g2,b2; |
|---|
| 51 | |
|---|
| 52 | /* no change */ |
|---|
| 53 | if (alpha <= 0) |
|---|
| 54 | return bg_pixel; |
|---|
| 55 | else if (alpha >= 255) |
|---|
| 56 | return fg_pixel; |
|---|
| 57 | |
|---|
| 58 | DHL_DECOMPOSE_ARGB8888(bg_pixel,a1,r1,g1,b1); |
|---|
| 59 | DHL_DECOMPOSE_ARGB8888(fg_pixel,a2,r2,g2,b2); |
|---|
| 60 | |
|---|
| 61 | /* blend them */ |
|---|
| 62 | DHL_BLEND(r1,r2,alpha); |
|---|
| 63 | DHL_BLEND(g1,g2,alpha); |
|---|
| 64 | DHL_BLEND(b1,b2,alpha); |
|---|
| 65 | DHL_BLEND(a1,a2,alpha); /* TODO: is this right? */ |
|---|
| 66 | |
|---|
| 67 | return DHL_COMPOSE_ARGB8888(a1,r1,g1,b1); |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| 70 | |
|---|
| 71 | static UINT32 p_antialias_argb4444_pixels(UINT32 bg_pixel, UINT32 fg_pixel, int alpha) |
|---|
| 72 | { |
|---|
| 73 | int a1,r1,g1,b1; |
|---|
| 74 | int a2,r2,g2,b2; |
|---|
| 75 | |
|---|
| 76 | /* no change */ |
|---|
| 77 | if (alpha <= 0) |
|---|
| 78 | return bg_pixel; |
|---|
| 79 | else if (alpha >= 255) |
|---|
| 80 | return fg_pixel; |
|---|
| 81 | |
|---|
| 82 | DHL_DECOMPOSE_ARGB4444(bg_pixel,a1,r1,g1,b1); |
|---|
| 83 | DHL_DECOMPOSE_ARGB4444(fg_pixel,a2,r2,g2,b2); |
|---|
| 84 | |
|---|
| 85 | /* blend them */ |
|---|
| 86 | DHL_BLEND(r1,r2,alpha); |
|---|
| 87 | DHL_BLEND(g1,g2,alpha); |
|---|
| 88 | DHL_BLEND(b1,b2,alpha); |
|---|
| 89 | DHL_BLEND(a1,a2,alpha); |
|---|
| 90 | |
|---|
| 91 | return DHL_COMPOSE_ARGB4444(a1,r1,g1,b1); |
|---|
| 92 | } |
|---|
| 93 | |
|---|
| 94 | |
|---|
| 95 | static UINT32 p_antialias_rgb565_pixels(UINT32 bg_pixel, UINT32 fg_pixel, int alpha) |
|---|
| 96 | { |
|---|
| 97 | int a1,r1,g1,b1; |
|---|
| 98 | int a2,r2,g2,b2; |
|---|
| 99 | |
|---|
| 100 | /* no change */ |
|---|
| 101 | if (alpha <= 0) |
|---|
| 102 | return bg_pixel; |
|---|
| 103 | else if (alpha >= 255) |
|---|
| 104 | return fg_pixel; |
|---|
| 105 | |
|---|
| 106 | DHL_DECOMPOSE_RGB565(bg_pixel,r1,g1,b1); |
|---|
| 107 | DHL_DECOMPOSE_RGB565(fg_pixel,r2,g2,b2); |
|---|
| 108 | |
|---|
| 109 | /* blend them */ |
|---|
| 110 | DHL_BLEND(r1,r2,alpha); |
|---|
| 111 | DHL_BLEND(g1,g2,alpha); |
|---|
| 112 | DHL_BLEND(b1,b2,alpha); |
|---|
| 113 | |
|---|
| 114 | return DHL_COMPOSE_RGB565(r1,g1,b1); |
|---|
| 115 | } |
|---|
| 116 | |
|---|
| 117 | |
|---|
| 118 | static UINT32 p_antialias_argb1555_pixels(UINT32 bg_pixel, UINT32 fg_pixel, int alpha) |
|---|
| 119 | { |
|---|
| 120 | int a1,r1,g1,b1; |
|---|
| 121 | int a2,r2,g2,b2; |
|---|
| 122 | |
|---|
| 123 | /* no change */ |
|---|
| 124 | if (alpha <= 0) |
|---|
| 125 | return bg_pixel; |
|---|
| 126 | else if (alpha >= 255) |
|---|
| 127 | return fg_pixel; |
|---|
| 128 | |
|---|
| 129 | DHL_DECOMPOSE_ARGB1555(bg_pixel,a1,r1,g1,b1); |
|---|
| 130 | DHL_DECOMPOSE_ARGB1555(fg_pixel,a2,r2,g2,b2); |
|---|
| 131 | |
|---|
| 132 | /* blend them */ |
|---|
| 133 | DHL_BLEND(r1,r2,alpha); |
|---|
| 134 | DHL_BLEND(g1,g2,alpha); |
|---|
| 135 | DHL_BLEND(b1,b2,alpha); |
|---|
| 136 | DHL_BLEND(a1,a2,alpha); |
|---|
| 137 | |
|---|
| 138 | return DHL_COMPOSE_ARGB1555(a1,r1,g1,b1); |
|---|
| 139 | } |
|---|
| 140 | |
|---|
| 141 | |
|---|
| 142 | #define USE_FONT_CACHE 1 |
|---|
| 143 | |
|---|
| 144 | |
|---|
| 145 | #if USE_FONT_CACHE |
|---|
| 146 | |
|---|
| 147 | #define MAX_NUM_FONT_BUF 128 |
|---|
| 148 | #define MAX_SIZE_FONT_CACHE (30*30) /* ÃÖ´ë ±Û²ÃÀº 30À̰í 30 ³Ñ¾î°¡¸é caching ¾ÈÇÔ */ |
|---|
| 149 | |
|---|
| 150 | static struct { |
|---|
| 151 | UINT16 ch; |
|---|
| 152 | INT8 width; |
|---|
| 153 | INT8 height; |
|---|
| 154 | INT8 sx; |
|---|
| 155 | INT8 sy; |
|---|
| 156 | INT8 ox; |
|---|
| 157 | INT8 oy; |
|---|
| 158 | INT8 bSize; |
|---|
| 159 | UINT8 data[MAX_SIZE_FONT_CACHE]; |
|---|
| 160 | } p_font_buf[MAX_NUM_FONT_BUF]; |
|---|
| 161 | |
|---|
| 162 | static int p_font_buf_idx; |
|---|
| 163 | |
|---|
| 164 | static void p_put_cache(UINT16 ch, int width, int height, int sx, int sy, |
|---|
| 165 | int ox, int oy, int bSize, UINT8 *pdata) |
|---|
| 166 | { |
|---|
| 167 | p_font_buf[p_font_buf_idx].ch=ch; |
|---|
| 168 | p_font_buf[p_font_buf_idx].width=width; |
|---|
| 169 | p_font_buf[p_font_buf_idx].height=height; |
|---|
| 170 | p_font_buf[p_font_buf_idx].sx=sx; |
|---|
| 171 | p_font_buf[p_font_buf_idx].sy=sy; |
|---|
| 172 | p_font_buf[p_font_buf_idx].ox=ox; |
|---|
| 173 | p_font_buf[p_font_buf_idx].oy=oy; |
|---|
| 174 | p_font_buf[p_font_buf_idx].bSize=bSize; |
|---|
| 175 | memcpy(p_font_buf[p_font_buf_idx].data, pdata, bSize*sy); |
|---|
| 176 | |
|---|
| 177 | if(++p_font_buf_idx>=MAX_NUM_FONT_BUF) p_font_buf_idx=0; |
|---|
| 178 | } |
|---|
| 179 | |
|---|
| 180 | static int p_get_cache_idx(UINT16 ch) |
|---|
| 181 | { |
|---|
| 182 | int i; |
|---|
| 183 | |
|---|
| 184 | for(i=0; i<MAX_NUM_FONT_BUF; i++) { |
|---|
| 185 | if(ch==p_font_buf[i].ch) return i; |
|---|
| 186 | } |
|---|
| 187 | |
|---|
| 188 | return -1; |
|---|
| 189 | } |
|---|
| 190 | |
|---|
| 191 | static void p_init_cache() |
|---|
| 192 | { |
|---|
| 193 | int i; |
|---|
| 194 | |
|---|
| 195 | for(i=0; i<MAX_NUM_FONT_BUF; i++) { |
|---|
| 196 | p_font_buf[i].ch=(UINT16)-1; |
|---|
| 197 | } |
|---|
| 198 | p_font_buf_idx=0; |
|---|
| 199 | } |
|---|
| 200 | |
|---|
| 201 | |
|---|
| 202 | #endif /* USE_FONT_CACHE */ |
|---|
| 203 | |
|---|
| 204 | |
|---|
| 205 | int Jungle_PrintCh(tDHL_PlaneID id, int x, int y, UINT16 ch, UINT32 c_font) |
|---|
| 206 | { |
|---|
| 207 | int i, j; |
|---|
| 208 | int x_margin; |
|---|
| 209 | |
|---|
| 210 | UINT8 *p; |
|---|
| 211 | UT_IMAGE image; |
|---|
| 212 | |
|---|
| 213 | UINT32 color, c_edge, c_bg; |
|---|
| 214 | |
|---|
| 215 | int ch_width, ch_height; |
|---|
| 216 | int ch_sx, ch_sy, ch_ox, ch_oy, bsize; |
|---|
| 217 | UINT8 *pdata; |
|---|
| 218 | |
|---|
| 219 | void *plane_addr; |
|---|
| 220 | int plane_pitch; |
|---|
| 221 | tDHL_PixelType pixel_type; |
|---|
| 222 | |
|---|
| 223 | dprint(2, " %s, x(%d), y(%d), ch(0x%x:%c), font_color(0x%x)\n", |
|---|
| 224 | __FUNCTION__, x, y, ch, ch, c_font); |
|---|
| 225 | |
|---|
| 226 | if(ch==0) return 0; /* ch°¡ 0ÀÌ¸é ¹Ù·Î returnÇØ¹ö¸°´Ù. */ |
|---|
| 227 | |
|---|
| 228 | if(DHL_OK!=DHL_GetPlaneMemory(id, &plane_addr) |
|---|
| 229 | || DHL_OK!=DHL_GetPlanePitch(id, &plane_pitch)) { |
|---|
| 230 | dprint(0, "%s : plane is not inited yet\n", __FUNCTION__); |
|---|
| 231 | return 0; |
|---|
| 232 | } |
|---|
| 233 | |
|---|
| 234 | DHL_GetPlanePixelType(id, &pixel_type); |
|---|
| 235 | |
|---|
| 236 | if(ch>=0xac00) { /* ÇѱÛÀ̸é ÀÚµ¿ º¯È¯*/ |
|---|
| 237 | ut_SetFont(&p_reg_fc, 100); |
|---|
| 238 | } |
|---|
| 239 | |
|---|
| 240 | #if USE_FONT_CACHE |
|---|
| 241 | { |
|---|
| 242 | int cache_idx=p_get_cache_idx(ch); |
|---|
| 243 | |
|---|
| 244 | if(cache_idx>=0) { |
|---|
| 245 | ch_width=p_font_buf[cache_idx].width; |
|---|
| 246 | ch_height=p_font_buf[cache_idx].height; |
|---|
| 247 | ch_sx=p_font_buf[cache_idx].sx; |
|---|
| 248 | ch_sy=p_font_buf[cache_idx].sy; |
|---|
| 249 | ch_ox=p_font_buf[cache_idx].ox; |
|---|
| 250 | ch_oy=p_font_buf[cache_idx].oy; |
|---|
| 251 | bsize=p_font_buf[cache_idx].bSize; |
|---|
| 252 | pdata=p_font_buf[cache_idx].data; |
|---|
| 253 | |
|---|
| 254 | goto label_font_drawing; |
|---|
| 255 | } |
|---|
| 256 | } |
|---|
| 257 | #endif |
|---|
| 258 | |
|---|
| 259 | ut_GetCharImage(&p_reg_fc, ch, &image); |
|---|
| 260 | if(image.type != _UT_IMAGE_TYPE_BITMAP_65) { |
|---|
| 261 | ut_GetCharImage(&p_reg_fc, CH_BLANK, &image); |
|---|
| 262 | } |
|---|
| 263 | |
|---|
| 264 | if(image.type != _UT_IMAGE_TYPE_BITMAP_65) { |
|---|
| 265 | dprint(0, "getting image from jungle font engine failed!!!(0x%x:%c)\n", ch, ch); |
|---|
| 266 | if(ch>=0xac00) { /* ¿ø·¡´ë·Î º¯°æ */ |
|---|
| 267 | ut_SetFont(&p_reg_fc, p_reg_font_attr.font_style); |
|---|
| 268 | } |
|---|
| 269 | return 0; |
|---|
| 270 | } |
|---|
| 271 | |
|---|
| 272 | ch_width=image.width; |
|---|
| 273 | ch_height=image.height; |
|---|
| 274 | ch_sx=image.bbox.sx; |
|---|
| 275 | ch_sy=image.bbox.sy; |
|---|
| 276 | ch_ox=image.bbox.ox; |
|---|
| 277 | ch_oy=image.bbox.oy; |
|---|
| 278 | bsize=image.bSize; |
|---|
| 279 | pdata=image.data; |
|---|
| 280 | |
|---|
| 281 | #if USE_FONT_CACHE |
|---|
| 282 | p_put_cache(ch, ch_width, ch_height, ch_sx, ch_sy, ch_ox, ch_oy, bsize, pdata); |
|---|
| 283 | #endif |
|---|
| 284 | |
|---|
| 285 | label_font_drawing : |
|---|
| 286 | |
|---|
| 287 | if(ch>=0xac00) { /* ¿ø·¡´ë·Î º¯°æ */ |
|---|
| 288 | ut_SetFont(&p_reg_fc, p_reg_font_attr.font_style); |
|---|
| 289 | } |
|---|
| 290 | |
|---|
| 291 | #if 0 |
|---|
| 292 | x_margin=MAX_CH_W*1/20; //sizeÀÇ 1/10ÀÌ marginÀÌ µÊ |
|---|
| 293 | #else |
|---|
| 294 | x_margin=0; |
|---|
| 295 | #endif |
|---|
| 296 | |
|---|
| 297 | dprint(2, "plane_addr(0x%x), plane_pitch(%d), pixel_type(%d)\n", |
|---|
| 298 | plane_addr, plane_pitch, pixel_type); |
|---|
| 299 | |
|---|
| 300 | if(p_reg_font_attr.is_underline) { //underline |
|---|
| 301 | DHL_DrawHLine(id, x, y+p_reg_font_attr.size*(1-x_margin), ch_width+x_margin*2, c_font); |
|---|
| 302 | } |
|---|
| 303 | |
|---|
| 304 | if(pixel_type==eDHL_PIXELTYPE_ARGB4444) { |
|---|
| 305 | c_font=DHL_COMPOSE_ARGB4444(c_font>>24, (c_font>>16)&0xff, (c_font>>8)&0xff, c_font&0xff); |
|---|
| 306 | } |
|---|
| 307 | else if(pixel_type==eDHL_PIXELTYPE_RGB565) { |
|---|
| 308 | c_font=DHL_COMPOSE_RGB565((c_font>>16)&0xff, (c_font>>8)&0xff, c_font&0xff); |
|---|
| 309 | } |
|---|
| 310 | else if(pixel_type==eDHL_PIXELTYPE_ARGB1555) { |
|---|
| 311 | c_font=DHL_COMPOSE_ARGB1555(c_font>>24, (c_font>>16)&0xff, (c_font>>8)&0xff, c_font&0xff); |
|---|
| 312 | } |
|---|
| 313 | |
|---|
| 314 | c_edge=p_reg_font_attr.c_edge; |
|---|
| 315 | |
|---|
| 316 | if(pixel_type==eDHL_PIXELTYPE_ARGB4444) { |
|---|
| 317 | c_edge=DHL_COMPOSE_ARGB4444(c_edge>>24, (c_edge>>16)&0xff, (c_edge>>8)&0xff, c_edge&0xff); |
|---|
| 318 | } |
|---|
| 319 | else if(pixel_type==eDHL_PIXELTYPE_RGB565) { |
|---|
| 320 | c_edge=DHL_COMPOSE_RGB565((c_edge>>16)&0xff, (c_edge>>8)&0xff, c_edge&0xff); |
|---|
| 321 | } |
|---|
| 322 | else if(pixel_type==eDHL_PIXELTYPE_ARGB1555) { |
|---|
| 323 | c_edge=DHL_COMPOSE_ARGB1555(c_edge>>24, (c_edge>>16)&0xff, (c_edge>>8)&0xff, c_edge&0xff); |
|---|
| 324 | } |
|---|
| 325 | |
|---|
| 326 | if(ch>=0x200 && !p_reg_font_attr.is_unicode) { |
|---|
| 327 | //¿Ï¼ºÇüÀ» unicode·Î º¯°æÇÔ. |
|---|
| 328 | ch=DMG_Ksx1001toUnicode(ch); |
|---|
| 329 | } |
|---|
| 330 | |
|---|
| 331 | for(j=0, p=pdata; j<ch_sy; j++, p+=bsize) { |
|---|
| 332 | for(i=0; i<ch_sx; i++) { |
|---|
| 333 | |
|---|
| 334 | if(p[i]==0) continue; |
|---|
| 335 | if(p[i]>=_UT_IMAGE_TYPE_BITMAP_65_SMOOTH_COLOR_CORNER) continue; |
|---|
| 336 | |
|---|
| 337 | if(pixel_type==eDHL_PIXELTYPE_ARGB8888) { |
|---|
| 338 | |
|---|
| 339 | c_bg=DHL_GET_PIXEL32(plane_addr, plane_pitch, x+ch_ox+x_margin+i, |
|---|
| 340 | y+p_reg_font_attr.size-ch_oy-j); |
|---|
| 341 | if(p[i]==_UT_IMAGE_TYPE_BITMAP_65_SHADOW_COLOR) |
|---|
| 342 | color=c_edge; |
|---|
| 343 | else |
|---|
| 344 | color=p_antialias_argb8888_pixels(c_bg, c_font, p[i]*4); |
|---|
| 345 | DHL_SET_PIXEL32(plane_addr, plane_pitch, x+ch_ox+x_margin+i, |
|---|
| 346 | y+p_reg_font_attr.size-ch_oy-j, color); |
|---|
| 347 | } |
|---|
| 348 | else if(pixel_type==eDHL_PIXELTYPE_ARGB4444) { |
|---|
| 349 | c_bg=DHL_GET_PIXEL16(plane_addr, plane_pitch, x+ch_ox+x_margin+i, |
|---|
| 350 | y+p_reg_font_attr.size-ch_oy-j); |
|---|
| 351 | if(p[i]==_UT_IMAGE_TYPE_BITMAP_65_SHADOW_COLOR) |
|---|
| 352 | color=c_edge; |
|---|
| 353 | else |
|---|
| 354 | color=p_antialias_argb4444_pixels(c_bg, c_font, p[i]*4); |
|---|
| 355 | DHL_SET_PIXEL16(plane_addr, plane_pitch, x+ch_ox+x_margin+i, |
|---|
| 356 | y+p_reg_font_attr.size-ch_oy-j, color); |
|---|
| 357 | } |
|---|
| 358 | else if(pixel_type==eDHL_PIXELTYPE_RGB565) { |
|---|
| 359 | c_bg=DHL_GET_PIXEL16(plane_addr, plane_pitch, x+ch_ox+x_margin+i, |
|---|
| 360 | y+p_reg_font_attr.size-ch_oy-j); |
|---|
| 361 | if(p[i]==_UT_IMAGE_TYPE_BITMAP_65_SHADOW_COLOR) |
|---|
| 362 | color=c_edge; |
|---|
| 363 | else |
|---|
| 364 | color=p_antialias_rgb565_pixels(c_bg, c_font, p[i]*4); |
|---|
| 365 | DHL_SET_PIXEL16(plane_addr, plane_pitch, x+ch_ox+x_margin+i, |
|---|
| 366 | y+p_reg_font_attr.size-ch_oy-j, color); |
|---|
| 367 | } |
|---|
| 368 | else if(pixel_type==eDHL_PIXELTYPE_ARGB1555) { |
|---|
| 369 | c_bg=DHL_GET_PIXEL16(plane_addr, plane_pitch, x+ch_ox+x_margin+i, |
|---|
| 370 | y+p_reg_font_attr.size-ch_oy-j); |
|---|
| 371 | if(p[i]==_UT_IMAGE_TYPE_BITMAP_65_SHADOW_COLOR) |
|---|
| 372 | color=c_edge; |
|---|
| 373 | else |
|---|
| 374 | color=p_antialias_argb1555_pixels(c_bg, c_font, p[i]*4); |
|---|
| 375 | DHL_SET_PIXEL16(plane_addr, plane_pitch, x+ch_ox+x_margin+i, |
|---|
| 376 | y+p_reg_font_attr.size-ch_oy-j, color); |
|---|
| 377 | } |
|---|
| 378 | } |
|---|
| 379 | } |
|---|
| 380 | |
|---|
| 381 | DHL_PostDraw(id, x, y, ch_width+x_margin*2, p_reg_font_attr.size); |
|---|
| 382 | |
|---|
| 383 | return ch_width+x_margin*2; |
|---|
| 384 | } |
|---|
| 385 | |
|---|
| 386 | |
|---|
| 387 | int Jungle_GetChWidth(UINT16 ch) |
|---|
| 388 | { |
|---|
| 389 | int ch_width, ch_height; |
|---|
| 390 | int ch_sx, ch_sy, ch_ox, ch_oy, bsize; |
|---|
| 391 | UINT8 *pdata; |
|---|
| 392 | |
|---|
| 393 | UT_IMAGE image; |
|---|
| 394 | |
|---|
| 395 | if(ch>=0xac00) { /* ÇѱÛÀ̸é ÀÚµ¿ º¯È¯*/ |
|---|
| 396 | ut_SetFont(&p_reg_fc, 100); |
|---|
| 397 | } |
|---|
| 398 | |
|---|
| 399 | #if USE_FONT_CACHE |
|---|
| 400 | { |
|---|
| 401 | int cache_idx=p_get_cache_idx(ch); |
|---|
| 402 | |
|---|
| 403 | if(cache_idx>=0) { |
|---|
| 404 | ch_width=p_font_buf[cache_idx].width; |
|---|
| 405 | ch_height=p_font_buf[cache_idx].height; |
|---|
| 406 | ch_sx=p_font_buf[cache_idx].sx; |
|---|
| 407 | ch_sy=p_font_buf[cache_idx].sy; |
|---|
| 408 | ch_ox=p_font_buf[cache_idx].ox; |
|---|
| 409 | ch_oy=p_font_buf[cache_idx].oy; |
|---|
| 410 | bsize=p_font_buf[cache_idx].bSize; |
|---|
| 411 | pdata=p_font_buf[cache_idx].data; |
|---|
| 412 | |
|---|
| 413 | goto label_font_drawing; |
|---|
| 414 | } |
|---|
| 415 | } |
|---|
| 416 | #endif |
|---|
| 417 | |
|---|
| 418 | ut_GetCharImage(&p_reg_fc, ch, &image); |
|---|
| 419 | if(image.type == _UT_IMAGE_TYPE_NULL_GLYPH) { |
|---|
| 420 | ut_GetCharImage(&p_reg_fc, CH_BLANK, &image); |
|---|
| 421 | } |
|---|
| 422 | |
|---|
| 423 | ch_width=image.width; |
|---|
| 424 | ch_height=image.height; |
|---|
| 425 | ch_sx=image.bbox.sx; |
|---|
| 426 | ch_sy=image.bbox.sy; |
|---|
| 427 | ch_ox=image.bbox.ox; |
|---|
| 428 | ch_oy=image.bbox.oy; |
|---|
| 429 | bsize=image.bSize; |
|---|
| 430 | pdata=image.data; |
|---|
| 431 | |
|---|
| 432 | if (ch_sx + ch_ox > ch_width) ch_width = ch_sx + ch_ox; // 2012.10.10 megakiss newcon2 #2194 Handwritten font broken solve |
|---|
| 433 | |
|---|
| 434 | #if USE_FONT_CACHE |
|---|
| 435 | p_put_cache(ch, ch_width, ch_height, ch_sx, ch_sy, ch_ox, ch_oy, bsize, pdata); |
|---|
| 436 | #endif |
|---|
| 437 | |
|---|
| 438 | label_font_drawing : |
|---|
| 439 | |
|---|
| 440 | if(ch>=0xac00) { /* ¿ø·¡´ë·Î º¯°æ */ |
|---|
| 441 | ut_SetFont(&p_reg_fc, p_reg_font_attr.font_style); |
|---|
| 442 | } |
|---|
| 443 | |
|---|
| 444 | return ch_width+(MAX_CH_W*1/20)*2; |
|---|
| 445 | } |
|---|
| 446 | |
|---|
| 447 | |
|---|
| 448 | int Jungle_GetChHeight(UINT16 ch) |
|---|
| 449 | { |
|---|
| 450 | int ch_width, ch_height; |
|---|
| 451 | int ch_sx, ch_sy, ch_ox, ch_oy, bsize; |
|---|
| 452 | UINT8 *pdata; |
|---|
| 453 | |
|---|
| 454 | UT_IMAGE image; |
|---|
| 455 | |
|---|
| 456 | if(ch>=0xac00) { /* ÇѱÛÀ̸é ÀÚµ¿ º¯È¯*/ |
|---|
| 457 | ut_SetFont(&p_reg_fc, 100); |
|---|
| 458 | } |
|---|
| 459 | |
|---|
| 460 | #if USE_FONT_CACHE |
|---|
| 461 | { |
|---|
| 462 | int cache_idx=p_get_cache_idx(ch); |
|---|
| 463 | |
|---|
| 464 | if(cache_idx>=0) { |
|---|
| 465 | ch_width=p_font_buf[cache_idx].width; |
|---|
| 466 | ch_height=p_font_buf[cache_idx].height; |
|---|
| 467 | ch_sx=p_font_buf[cache_idx].sx; |
|---|
| 468 | ch_sy=p_font_buf[cache_idx].sy; |
|---|
| 469 | ch_ox=p_font_buf[cache_idx].ox; |
|---|
| 470 | ch_oy=p_font_buf[cache_idx].oy; |
|---|
| 471 | bsize=p_font_buf[cache_idx].bSize; |
|---|
| 472 | pdata=p_font_buf[cache_idx].data; |
|---|
| 473 | |
|---|
| 474 | goto label_font_drawing; |
|---|
| 475 | } |
|---|
| 476 | } |
|---|
| 477 | #endif |
|---|
| 478 | |
|---|
| 479 | ut_GetCharImage(&p_reg_fc, ch, &image); |
|---|
| 480 | if(image.type == _UT_IMAGE_TYPE_NULL_GLYPH) |
|---|
| 481 | ut_GetCharImage(&p_reg_fc, CH_BLANK, &image); |
|---|
| 482 | |
|---|
| 483 | ch_width=image.width; |
|---|
| 484 | ch_height=image.height; |
|---|
| 485 | ch_sx=image.bbox.sx; |
|---|
| 486 | ch_sy=image.bbox.sy; |
|---|
| 487 | ch_ox=image.bbox.ox; |
|---|
| 488 | ch_oy=image.bbox.oy; |
|---|
| 489 | bsize=image.bSize; |
|---|
| 490 | pdata=image.data; |
|---|
| 491 | |
|---|
| 492 | #if USE_FONT_CACHE |
|---|
| 493 | p_put_cache(ch, ch_width, ch_height, ch_sx, ch_sy, ch_ox, ch_oy, bsize, pdata); |
|---|
| 494 | #endif |
|---|
| 495 | |
|---|
| 496 | label_font_drawing : |
|---|
| 497 | |
|---|
| 498 | if(ch>=0xac00) { /* ¿ø·¡´ë·Î º¯°æ */ |
|---|
| 499 | ut_SetFont(&p_reg_fc, p_reg_font_attr.font_style); |
|---|
| 500 | } |
|---|
| 501 | |
|---|
| 502 | return ch_height*11/10; //¾à 1.1¹è¸¦ Ű¿î Å©±â |
|---|
| 503 | } |
|---|
| 504 | |
|---|
| 505 | |
|---|
| 506 | void Jungle_GetFontAttr(Jungle_FontAttr *pfont_attr) |
|---|
| 507 | { |
|---|
| 508 | memcpy(pfont_attr, &p_reg_font_attr, sizeof(*pfont_attr)); |
|---|
| 509 | } |
|---|
| 510 | |
|---|
| 511 | |
|---|
| 512 | |
|---|
| 513 | void Jungle_SetFontAttr(Jungle_FontAttr *pfont_attr) |
|---|
| 514 | { |
|---|
| 515 | BOOL bchanged=FALSE; |
|---|
| 516 | |
|---|
| 517 | if(pfont_attr->size!=p_reg_font_attr.size) { |
|---|
| 518 | ut_SetSize(&p_reg_fc, pfont_attr->size, pfont_attr->size); |
|---|
| 519 | bchanged=TRUE; |
|---|
| 520 | } |
|---|
| 521 | |
|---|
| 522 | if(pfont_attr->is_bold!=p_reg_font_attr.is_bold) { |
|---|
| 523 | ut_SetBold(&p_reg_fc, pfont_attr->is_bold?1:0); |
|---|
| 524 | bchanged=TRUE; |
|---|
| 525 | } |
|---|
| 526 | |
|---|
| 527 | if(pfont_attr->is_italic!=p_reg_font_attr.is_italic) { |
|---|
| 528 | ut_SetItalic(&p_reg_fc, pfont_attr->is_italic?1:0); |
|---|
| 529 | bchanged=TRUE; |
|---|
| 530 | } |
|---|
| 531 | |
|---|
| 532 | if(pfont_attr->font_style!=p_reg_font_attr.font_style) { |
|---|
| 533 | ut_SetFont(&p_reg_fc, pfont_attr->font_style); |
|---|
| 534 | bchanged=TRUE; |
|---|
| 535 | } |
|---|
| 536 | |
|---|
| 537 | if(pfont_attr->edge_type!=p_reg_font_attr.edge_type) { |
|---|
| 538 | int edge_type=pfont_attr->edge_type; //edge type 4´Â 16, 5´Â 14·Î º¯È¯ÇØÁà¾ß ÇÔ. |
|---|
| 539 | |
|---|
| 540 | if(edge_type==4) edge_type=16; |
|---|
| 541 | else if(edge_type==5) edge_type=14; |
|---|
| 542 | |
|---|
| 543 | ut_SetEdgeType(&p_reg_fc, edge_type); |
|---|
| 544 | bchanged=TRUE; |
|---|
| 545 | } |
|---|
| 546 | |
|---|
| 547 | if(bchanged) { |
|---|
| 548 | memcpy(&p_reg_font_attr, pfont_attr, sizeof(p_reg_font_attr)); |
|---|
| 549 | p_init_cache(); //font°¡ º¯°æµÇ¾úÀ¸¹Ç·Î ÆùÆ® cache ÃʱâÈ. |
|---|
| 550 | } |
|---|
| 551 | } |
|---|
| 552 | |
|---|
| 553 | |
|---|
| 554 | |
|---|
| 555 | static void *p_jg_malloc(unsigned int size) |
|---|
| 556 | { |
|---|
| 557 | return DHL_OS_Malloc(size); |
|---|
| 558 | } |
|---|
| 559 | |
|---|
| 560 | static void p_jg_free(void *ptr) |
|---|
| 561 | { |
|---|
| 562 | DHL_OS_Free(&ptr); |
|---|
| 563 | } |
|---|
| 564 | |
|---|
| 565 | |
|---|
| 566 | void Jungle_FontInit(Jungle_FontAttr *pfont_attr) |
|---|
| 567 | { |
|---|
| 568 | ut_InitFontManager(p_jg_malloc, p_jg_free, 0, 0, 0, 0); |
|---|
| 569 | |
|---|
| 570 | ut_InitFontContext(&p_reg_fc, 0, 0); |
|---|
| 571 | |
|---|
| 572 | //ut_AddFont(EIA_708_B_13); |
|---|
| 573 | //ut_AddFont(EIA_708_B_14); |
|---|
| 574 | //ut_AddFont(EIA_708_B_15); |
|---|
| 575 | ut_AddFont(EIA_708_B_17); |
|---|
| 576 | ut_AddFont(EIA_708_B_19); |
|---|
| 577 | ut_AddFont(EIA_708_B_21); |
|---|
| 578 | //ut_AddFont(EIA_708_B_23); |
|---|
| 579 | //ut_AddFont(EIA_708_B_25); |
|---|
| 580 | //ut_AddFont(EIA_708_B_26); |
|---|
| 581 | //ut_AddFont(EIA_708_B_28); |
|---|
| 582 | //ut_AddFont(EIA_708_B_30); |
|---|
| 583 | //ut_AddFont(EIA_708_B_32); |
|---|
| 584 | //ut_AddFont(EIA_708_B_OL); |
|---|
| 585 | |
|---|
| 586 | ut_AddFont(JUNGR_FONT); |
|---|
| 587 | |
|---|
| 588 | ut_SetSize(&p_reg_fc, pfont_attr->size, 0); |
|---|
| 589 | ut_SetBold(&p_reg_fc, 0); |
|---|
| 590 | ut_SetItalic(&p_reg_fc, 0); |
|---|
| 591 | ut_SetFont(&p_reg_fc, 0); |
|---|
| 592 | ut_SetEdgeType(&p_reg_fc, 0); |
|---|
| 593 | |
|---|
| 594 | Jungle_SetFontAttr(pfont_attr); |
|---|
| 595 | } |
|---|
| 596 | |
|---|
| 597 | |
|---|
| 598 | |
|---|
| 599 | #if 0 |
|---|
| 600 | ___Debug___() |
|---|
| 601 | #endif |
|---|
| 602 | |
|---|
| 603 | |
|---|