[<<] [<] Page 1 of 1 [>] [>>] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subject:
Re: [nanogui] TrueType not using specified background - PATCH
From: Junior ####@####.#### Date: 16 Jun 2008 20:27:55 -0000 Message-Id: <DC38462AC7E.0000032Eejr@inbox.com> --- microwin/src/engine/font_freetype2.c 2007-09-13 00:43:27.000000000 -0500 +++ ft-microwin/src/engine/font_freetype2.c 2008-06-16 10:23:11.000000000 -0500 @@ -117,7 +117,6 @@ #define HAVE_FREETYPE_2_CACHE 1 #endif - /* * Enable the Freetype 2 character map cache. Only applicable if * FreeType 2 itself is enabled, and HAVE_FREETYPE_2_CACHE is also @@ -878,7 +877,7 @@ pf->imagedesc.flags = FT_LOAD_DEFAULT; if (!(pf->fontattr & MWTF_ANTIALIAS)) { - pf->imagedesc.flags |= (FT_LOAD_MONOCHROME | FT_LOAD_TARGET_MONO); + pf->imagedesc.flags |= (FT_LOAD_MONOCHROME | FT_LOAD_TARGET_MONO | FT_LOAD_TARGET_LCD); } #else pf->imagedesc.type = ((pf->fontattr & MWTF_ANTIALIAS) @@ -1136,6 +1135,9 @@ int last_glyph_code = 0; /* Used for kerning */ driver_gc_t blit_instructions; int blit_op; + MWCOORD fnt_h; + MWCOORD fnt_w; + MWCOORD fnt_b; assert(pf); assert(psd); @@ -1198,8 +1200,22 @@ FT_Render_Mode render_mode = (pf->fontattr & MWTF_ANTIALIAS) ? ft_render_mode_normal : ft_render_mode_mono; + DPRINTF("Nano-X-Freetype2: freetype2_drawtext() using SLOW routine\n"); + + freetype2_gettextsize(pfont, text, cc, flags, &fnt_w, &fnt_h, &fnt_b); + if (gr_usebg) + { + if (flags & MWTF_BOTTOM) { + psd->FillRect(psd, ax, ay-fnt_h-(fnt_b>>1), ax+fnt_w, ay, gr_background); + } + else if(flags & MWTF_TOP) { + psd->FillRect(psd, ax, ay, ax+fnt_w, ay+fnt_h+(fnt_b>>1), gr_background); + } + else { + psd->FillRect(psd, ax, ay-fnt_h, ax+fnt_w, ay+(fnt_b>>1), gr_background); + } + } - /*DPRINTF("Nano-X-Freetype2: freetype2_drawtext() using SLOW routine\n"); */ pos.x = 0; for (i = 0; i < cc; i++) { curchar = LOOKUP_CHAR(pf, face, str[i]); @@ -1209,7 +1225,7 @@ ft_kerning_default, &kerning_delta); - //DPRINTF("Nano-X-Freetype2: freetype2_drawtext(): kerning_delta.x=%d, /64=%d\n", (int)kerning_delta.x, (int)kerning_delta.x/64); + /*DPRINTF("Nano-X-Freetype2: freetype2_drawtext(): kerning_delta.x=%d, /64=%d\n", (int)kerning_delta.x, (int)kerning_delta.x/64);*/ pos.x += kerning_delta.x & (~63); } last_glyph_code = curchar; @@ -1232,7 +1248,6 @@ //DPRINTF("Nano-X-Freetype2: freetype2_drawtext(): glyph->advance.x=%d, >>16=%d\n", (int)glyph->advance.x, (int)glyph->advance.x>>16); pos.x += (glyph->advance.x >> 10) & (~63); - //if (pf->fontrotation) { // rotate the glyph image now.. FT_Glyph_Transform(glyph, &pf->matrix, 0); > -----Original Message----- > From: ####@####.#### > Sent: Fri, 13 Jun 2008 13:26:16 -0800 > To: ####@####.#### ####@####.#### > Subject: Re: [nanogui] TrueType not using specified background > > > >> -----Original Message----- >> From: ####@####.#### >> Sent: Fri, 13 Jun 2008 08:28:49 -0800 >> To: ####@####.#### ####@####.#### >> Subject: Re: [nanogui] TrueType not using specified background >> >>> -----Original Message----- >>> From: ####@####.#### >>> Sent: Thu, 12 Jun 2008 19:54:19 -0600 >>> To: ####@####.#### ####@####.#### >>> Subject: Re: [nanogui] TrueType not using specified background >>> >>>> Is their some design reason why truetype fonts do not use the >>>> background >>>> color specified in gc? >>> The other bitmap fonts do use it but I'm not sure why not ttf fonts. >>> >>> Sounds like a bug, although interesting nobody has found it... try >>> modifying >>> the src/demo/nanox fontdemo?.c app that draws text around a circle, >>> lets use a non-white background. Thinking about this I'll bet that >>> all TTF drawing occurs without drawing any background... >>> >>> >>>> Is this something the that needs to be done in nano-X devfonts code or >>>> is >>>> it something that I need to build into the freetype library? >>> >>> No, this would be done in the devfont.c code. There are two options: >>> when the background is set to ON, then you can either clear the >>> background with a GdFillRect first, then let the engine draw >>> the glyph foreground bits only, or have the engine draw the glyph >>> foreground and background bits. I suggest using the former; internal >>> builtin fonts are displayed using the latter (its pretty slow drawing >>> each bit, TTF uses a blit unlike builtin fonts) >>> >>> Since TTF allows text to be displayed at an angle, I'm betting that >>> this is why its not implemented. The simple case would be to >>> implement it only for non-angled text only. >> >> Hi Greg, >> I added the lines to GdDrawAreaInternal since it appears that only >> freetype2 uses this function: >> >> if (gr_usebg) >> { >> psd->FillRect(psd, x, y, x + width - 1, y + height - 1, >> gr_background); >> } >> >> This is a start with two problems: >> The first problem here is that the bitmap is not fixed and only where >> the >> fonts are drawn the background is drawn. >> If I can use FillRect on the entire string length then I can clear the >> area before writing the text. >> This is not easy because the space character (0x20) is not written as a >> blank space, it onlu advances the cursor. >> Is their a way round this? >> The other problem is I'll need to define a total height which would be >> considering all the characters in the string. >> Is their a method already implemented to do this? > > Hi Greg, > I think I'm almost their. I haven't determing how efficient this patch is > yet but so far it seems the best way to do it. > I've added this to freetype2_drawtext: > > freetype2_gettextsize(pfont, text, cc, flags, &fnt_w, &fnt_h, > &fnt_b); > if (gr_usebg) > { > psd->FillRect(psd, ax, ay-fnt_b-4, ax+fnt_w, ay+fnt_h-4, > gr_background); > } > I'm trying to iron out some issues with TFTOP, TFBOTTOM & TFBASELINE. The > above is for BASELINE and I think when it's done I'll have to add some > condition statements to take care of the others. > Any comments? > > Regards,. > Jr. > > > > > > > > >> Thanks, >> Jr. >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: ####@####.#### >> For additional commands, e-mail: ####@####.#### > > ____________________________________________________________ > FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on > your desktop! > Check it out at http://www.inbox.com/marineaquarium > > --------------------------------------------------------------------- > To unsubscribe, e-mail: ####@####.#### > For additional commands, e-mail: ####@####.#### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subject:
Re: [nanogui] TrueType not using specified background - PATCH
From: "Greg Haerr" ####@####.#### Date: 19 Jun 2008 04:40:02 -0000 Message-Id: <027201c8d1c5$fcf86980$2f01a8c0@HaydenLake> Your patch looks ok on inspection, except it will fail if the text is drawn on an angle. You should test this witht the fontdemo[12].c program on the distribution (which likely doesn't currently draw the background). I can't add the patch without testing with rotation. Also, it would be better to include the gettextsize call withing the gr_usebg block, and also to calcuate the x,y,w,h values once and then make a single call to psd->FillRect for code size. Regards, Greg --- microwin/src/engine/font_freetype2.c 2007-09-13 00:43:27.000000000 -0500 +++ ft-microwin/src/engine/font_freetype2.c 2008-06-16 10:23:11.000000000 -0500 @@ -117,7 +117,6 @@ #define HAVE_FREETYPE_2_CACHE 1 #endif - /* * Enable the Freetype 2 character map cache. Only applicable if * FreeType 2 itself is enabled, and HAVE_FREETYPE_2_CACHE is also @@ -878,7 +877,7 @@ pf->imagedesc.flags = FT_LOAD_DEFAULT; if (!(pf->fontattr & MWTF_ANTIALIAS)) { - pf->imagedesc.flags |= (FT_LOAD_MONOCHROME | FT_LOAD_TARGET_MONO); + pf->imagedesc.flags |= (FT_LOAD_MONOCHROME | FT_LOAD_TARGET_MONO | FT_LOAD_TARGET_LCD); } #else pf->imagedesc.type = ((pf->fontattr & MWTF_ANTIALIAS) @@ -1136,6 +1135,9 @@ int last_glyph_code = 0; /* Used for kerning */ driver_gc_t blit_instructions; int blit_op; + MWCOORD fnt_h; + MWCOORD fnt_w; + MWCOORD fnt_b; assert(pf); assert(psd); @@ -1198,8 +1200,22 @@ FT_Render_Mode render_mode = (pf->fontattr & MWTF_ANTIALIAS) ? ft_render_mode_normal : ft_render_mode_mono; + DPRINTF("Nano-X-Freetype2: freetype2_drawtext() using SLOW routine\n"); + + freetype2_gettextsize(pfont, text, cc, flags, &fnt_w, &fnt_h, &fnt_b); + if (gr_usebg) + { + if (flags & MWTF_BOTTOM) { + psd->FillRect(psd, ax, ay-fnt_h-(fnt_b>>1), ax+fnt_w, ay, gr_background); + } + else if(flags & MWTF_TOP) { + psd->FillRect(psd, ax, ay, ax+fnt_w, ay+fnt_h+(fnt_b>>1), gr_background); + } + else { + psd->FillRect(psd, ax, ay-fnt_h, ax+fnt_w, ay+(fnt_b>>1), gr_background); + } + } - /*DPRINTF("Nano-X-Freetype2: freetype2_drawtext() using SLOW routine\n"); */ pos.x = 0; for (i = 0; i < cc; i++) { curchar = LOOKUP_CHAR(pf, face, str[i]); @@ -1209,7 +1225,7 @@ ft_kerning_default, &kerning_delta); - //DPRINTF("Nano-X-Freetype2: freetype2_drawtext(): kerning_delta.x=%d, /64=%d\n", (int)kerning_delta.x, (int)kerning_delta.x/64); + /*DPRINTF("Nano-X-Freetype2: freetype2_drawtext(): kerning_delta.x=%d, /64=%d\n", (int)kerning_delta.x, (int)kerning_delta.x/64);*/ pos.x += kerning_delta.x & (~63); } last_glyph_code = curchar; @@ -1232,7 +1248,6 @@ //DPRINTF("Nano-X-Freetype2: freetype2_drawtext(): glyph->advance.x=%d, >>16=%d\n", (int)glyph->advance.x, (int)glyph->advance.x>>16); pos.x += (glyph->advance.x >> 10) & (~63); - //if (pf->fontrotation) { // rotate the glyph image now.. FT_Glyph_Transform(glyph, &pf->matrix, 0); > -----Original Message----- > From: ####@####.#### > Sent: Fri, 13 Jun 2008 13:26:16 -0800 > To: ####@####.#### ####@####.#### > Subject: Re: [nanogui] TrueType not using specified background > > > >> -----Original Message----- >> From: ####@####.#### >> Sent: Fri, 13 Jun 2008 08:28:49 -0800 >> To: ####@####.#### ####@####.#### >> Subject: Re: [nanogui] TrueType not using specified background >> >>> -----Original Message----- >>> From: ####@####.#### >>> Sent: Thu, 12 Jun 2008 19:54:19 -0600 >>> To: ####@####.#### ####@####.#### >>> Subject: Re: [nanogui] TrueType not using specified background >>> >>>> Is their some design reason why truetype fonts do not use the >>>> background >>>> color specified in gc? >>> The other bitmap fonts do use it but I'm not sure why not ttf fonts. >>> >>> Sounds like a bug, although interesting nobody has found it... try >>> modifying >>> the src/demo/nanox fontdemo?.c app that draws text around a circle, >>> lets use a non-white background. Thinking about this I'll bet that >>> all TTF drawing occurs without drawing any background... >>> >>> >>>> Is this something the that needs to be done in nano-X devfonts code or >>>> is >>>> it something that I need to build into the freetype library? >>> >>> No, this would be done in the devfont.c code. There are two options: >>> when the background is set to ON, then you can either clear the >>> background with a GdFillRect first, then let the engine draw >>> the glyph foreground bits only, or have the engine draw the glyph >>> foreground and background bits. I suggest using the former; internal >>> builtin fonts are displayed using the latter (its pretty slow drawing >>> each bit, TTF uses a blit unlike builtin fonts) >>> >>> Since TTF allows text to be displayed at an angle, I'm betting that >>> this is why its not implemented. The simple case would be to >>> implement it only for non-angled text only. >> >> Hi Greg, >> I added the lines to GdDrawAreaInternal since it appears that only >> freetype2 uses this function: >> >> if (gr_usebg) >> { >> psd->FillRect(psd, x, y, x + width - 1, y + height - 1, >> gr_background); >> } >> >> This is a start with two problems: >> The first problem here is that the bitmap is not fixed and only where >> the >> fonts are drawn the background is drawn. >> If I can use FillRect on the entire string length then I can clear the >> area before writing the text. >> This is not easy because the space character (0x20) is not written as a >> blank space, it onlu advances the cursor. >> Is their a way round this? >> The other problem is I'll need to define a total height which would be >> considering all the characters in the string. >> Is their a method already implemented to do this? > > Hi Greg, > I think I'm almost their. I haven't determing how efficient this patch is > yet but so far it seems the best way to do it. > I've added this to freetype2_drawtext: > > freetype2_gettextsize(pfont, text, cc, flags, &fnt_w, &fnt_h, > &fnt_b); > if (gr_usebg) > { > psd->FillRect(psd, ax, ay-fnt_b-4, ax+fnt_w, ay+fnt_h-4, > gr_background); > } > I'm trying to iron out some issues with TFTOP, TFBOTTOM & TFBASELINE. The > above is for BASELINE and I think when it's done I'll have to add some > condition statements to take care of the others. > Any comments? > > Regards,. > Jr. > > > > > > > > >> Thanks, >> Jr. >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: ####@####.#### >> For additional commands, e-mail: ####@####.#### > > ____________________________________________________________ > FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on > your desktop! > Check it out at http://www.inbox.com/marineaquarium > > --------------------------------------------------------------------- > To unsubscribe, e-mail: ####@####.#### > For additional commands, e-mail: ####@####.#### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[<<] [<] Page 1 of 1 [>] [>>] |