Be a Supporter!

AS3 - turn off textfield anti-alias

  • 1,190 Views
  • 8 Replies
New Topic Respond to this Topic
NoLanLabs
NoLanLabs
  • Member since: May. 27, 2011
  • Offline.
Forum Stats
Supporter
Level 14
Game Developer
AS3 - turn off textfield anti-alias 2012-12-09 22:01:15 Reply

Is there any way to turn off anti-aliasing for a text field with AS3 code? Like, the equivalent of choosing "bitmap text" in the Flash IDE?

I can set the antiAliasType of the field to ADVANCED or NORMAL but there's no option for NONE. What's worse, there was no anti-aliasing before I embedded the font, but now that it's embedded I can't get the anti-alias to go away.

Anyone have any tips? This is really driving me nuts :/


Happy Robot Day 2014! Play our latest GAME! It's in 3-D!

egg82
egg82
  • Member since: Jun. 24, 2006
  • Offline.
Forum Stats
Supporter
Level 05
Game Developer
Response to AS3 - turn off textfield anti-alias 2012-12-09 23:30:00 Reply

At 12/9/12 10:01 PM, NoLanLabs wrote: Anyone have any tips? This is really driving me nuts :/

try this


Programming stuffs (tutorials and extras)
PM me (instead of MintPaw) if you're confuzzled.
thank Skaren for the sig :P

BBS Signature
NoLanLabs
NoLanLabs
  • Member since: May. 27, 2011
  • Offline.
Forum Stats
Supporter
Level 14
Game Developer
Response to AS3 - turn off textfield anti-alias 2012-12-10 19:55:35 Reply

At 12/9/12 11:30 PM, egg82 wrote:
At 12/9/12 10:01 PM, NoLanLabs wrote: Anyone have any tips? This is really driving me nuts :/
try this

That code sort of worked, but there's still a little bit of anti-alias I can't get rid of. I'm making a pixel art game so this is really messing up the look of everything.

I'm starting to think the only solution is to code my own text field and embed all the font's characters as separate bitmaps... :P

AS3 - turn off textfield anti-alias


Happy Robot Day 2014! Play our latest GAME! It's in 3-D!

egg82
egg82
  • Member since: Jun. 24, 2006
  • Offline.
Forum Stats
Supporter
Level 05
Game Developer
Response to AS3 - turn off textfield anti-alias 2012-12-10 21:26:02 Reply

look at the font. The font itself may be pixelated.

I assume you tried the "makePretty" function - use the second value, which is from 0 to 255 and see what works.


Programming stuffs (tutorials and extras)
PM me (instead of MintPaw) if you're confuzzled.
thank Skaren for the sig :P

BBS Signature
NoLanLabs
NoLanLabs
  • Member since: May. 27, 2011
  • Offline.
Forum Stats
Supporter
Level 14
Game Developer
Response to AS3 - turn off textfield anti-alias 2012-12-10 22:28:22 Reply

It's not the font... this picture shows it before (left) and after embedding the font. Only after embedding does the anti-alias show up. And I tried the makePretty function, that was as good as I could get.

This Adobe document says "Embedded fonts are anti-aliased, which means that their edges are smoothed for easier readability." So I kind of think I'm out of luck.

It's so frustrating though that it looks fine BEFORE I embed the font... it's like Flash CAN do it, it just doesn't want to... :(

AS3 - turn off textfield anti-alias


Happy Robot Day 2014! Play our latest GAME! It's in 3-D!

swishcheese
swishcheese
  • Member since: May. 12, 2007
  • Offline.
Forum Stats
Member
Level 14
Programmer
Response to AS3 - turn off textfield anti-alias 2012-12-10 23:48:53 Reply

Hmmm, I do not know if this is a terrible idea, but Im guessing you add this text to a bitmap or sprite? You could loop through and check every pixel in the bitmap. (or sprite's bitmapdata)

If the color of the a pixel is not alpha 1 and not white(or not the color of text), remove that pixel(change pixel to transparent). It will remove the excess, save time from making your own text field and importing each letter as bitmaps, but is not efficient.


BBS Signature
egg82
egg82
  • Member since: Jun. 24, 2006
  • Offline.
Forum Stats
Supporter
Level 05
Game Developer
Response to AS3 - turn off textfield anti-alias 2012-12-11 10:58:45 Reply

At 12/10/12 11:48 PM, swishcheese wrote: It will remove the excess, save time from making your own text field and importing each letter as bitmaps, but is not efficient.

yeah, that's not efficient at all.

if you want to go that route:
copyPixels() to a bitmapData, then do as swisscheese said.


Programming stuffs (tutorials and extras)
PM me (instead of MintPaw) if you're confuzzled.
thank Skaren for the sig :P

BBS Signature
NoLanLabs
NoLanLabs
  • Member since: May. 27, 2011
  • Offline.
Forum Stats
Supporter
Level 14
Game Developer
Response to AS3 - turn off textfield anti-alias 2012-12-12 22:15:47 Reply

At 12/10/12 11:48 PM, swishcheese wrote: Hmmm, I do not know if this is a terrible idea, but Im guessing you add this text to a bitmap or sprite? You could loop through and check every pixel in the bitmap. (or sprite's bitmapdata)

If the color of the a pixel is not alpha 1 and not white(or not the color of text), remove that pixel(change pixel to transparent). It will remove the excess, save time from making your own text field and importing each letter as bitmaps, but is not efficient.

I gave this a try and, as expected, it's ridiculously slow. Not a bad idea though.

It's probably just time for me to sit down, crank up the music, and make like fifty bitmaps for all the characters. It can't take more than a few hours.


Happy Robot Day 2014! Play our latest GAME! It's in 3-D!

MSGhero
MSGhero
  • Member since: Dec. 15, 2010
  • Online!
Forum Stats
Supporter
Level 16
Game Developer
Response to AS3 - turn off textfield anti-alias 2012-12-12 23:13:29 Reply

Here's something that does the looping through pixels stuff: https://github.com/Beeblerox/BitmapFont/tree/master/AS3-blit /src in conjunction with http://www.angelcode.com/products/bmfont/. BMFont converts the font file to a bitmap image (.png) and BitmapFont loads that in with a data file. I had mixed results, as it still looked pixellated to a degree, but when I looked at the ttf, it was pixellated there as well.