Hello Guest

Author Topic: Can tk2dtextmesh support all unicode characters?  (Read 9531 times)

seamas

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 2
    • View Profile
Can tk2dtextmesh support all unicode characters?
« on: August 14, 2012, 12:00:15 pm »
I want to create a tk2dtextmesh object, and to show player's name(maybe Chinese). There are so many Chinese characters, if I export Textures using BMFont that support all these Chinese characters, I will get several Textures.
In 2dtoolkit, when I create a Font, I can use only one Texture, is that right?
So, how can I solve this problem, or another method to show unicode characters that compatible with 2dtoolkit?

Thank you!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Can tk2dtextmesh support all unicode characters?
« Reply #1 on: August 14, 2012, 06:30:09 pm »
So how big are these textures? You can obviously make the texture bigger in BMFont, but you don't want to make it too big...
This is solveable with a bit of work, but the reason it doesn't support atlas spanning is mainly for performance - it will take up to N draw calls, N being the number of textures you use in the atlas.

Let me know and I can possibly advice the best course of action. Its definitely fixable, just need to work out the exact issue.

shepelt

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Can tk2dtextmesh support all unicode characters?
« Reply #2 on: October 22, 2012, 03:58:06 pm »
It's a common problem for CJK characters.

Since simplified Chinese charset requires more than 4,000 glyphs to render, a single texture would be too constraining.
Same goes for both Japanese (with Kanji) and Korean.
Even if you could cram all the glyphs into one texture, it wouldn't look pretty (i.e. row resolution)

I think people interested in the atlas-spanning font support wouldn't mind the increase in number of draw calls.
They can always fall back to using single-atlas font if optimization becomes critical.

If that is still a major problem, I think you could use an empty texture as a cache to keep frequently rendered letters in one texture (using some kind of LRU policy, combined with  GetPixels, SetPixels unity API calls) to speed things up a bit. Since the number of letters that can be rendered in one screen is limited, this could be a viable solution.

p.s. one guy exported 28100 glyphs on 4096x4096 texture using BMfont.
« Last Edit: October 22, 2012, 04:05:46 pm by shepelt »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Can tk2dtextmesh support all unicode characters?
« Reply #3 on: October 22, 2012, 10:12:09 pm »
Updating pixels at runtime isn't exactly the fastest route - as the managed->unmanaged switch costs a fair bit. I'll look into a native plugin solution for this (though Unity4 supports this already) on iOS.

shepelt

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Can tk2dtextmesh support all unicode characters?
« Reply #4 on: October 23, 2012, 01:21:00 am »
I think dynamic rendering would be overkill for 2d toolkit, especially when unity 4 already supports it.
I still think Atlas-spanning bitmap font is not a bad idea, considering its advantages (i.e. more control over how they look and stuff...) but I guess most games do fine without it... (provided dynamic rendering works)
BTW thanks for the prompt reply. 2d toolkit is the first unity extenstion I have purchased and I'm beginning to feel that it is worth every penny :)

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Can tk2dtextmesh support all unicode characters?
« Reply #5 on: October 23, 2012, 09:14:49 am »
I'll look into this soon after 1.90 at earliest. You can already import text meshes into sprite collections, so spanning should be possible with a bit of love. Obviously the runtime stuff will be quite a bit more inefficient, but that's unavoidable.

ixorastudios

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Can tk2dtextmesh support all unicode characters?
« Reply #6 on: January 21, 2013, 08:14:05 am »
Hi unikron,

I urgently need the use of chinese font characters and it will span across multiple atlas sheets. Could you advice on which method and tk2d code should i adjust to get this to work? I dont mind sharing you my soln after im done with this.

On a separete topic, I am trying to create a GUI layer on top of the tk2d stuff. However, I am stuck at the clipping issues as I find it hard to clip a panel with alot of child tk2d clipped sprites. You mentioned you have some idea on how to work on this. Mind sharing?

Regards

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Can tk2dtextmesh support all unicode characters?
« Reply #7 on: January 23, 2013, 02:04:03 pm »
@ixorastudios,
Replied to your post in the private support forum

cz460909

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Can tk2dtextmesh support all unicode characters?
« Reply #8 on: June 04, 2013, 03:14:09 am »
I got a idea, it may be a little boring method, that's it, look at me:
we get the NGUI & 2dtoolkit in one project, then get a NGUI panel, and a UILabel on it, and there has been a method to display chinese character in NGUI,however, I think it will be better to work with "pure" 2dtoolkit.
 ::)

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Can tk2dtextmesh support all unicode characters?
« Reply #9 on: June 04, 2013, 10:46:42 am »
Have you tried packed fonts?
http://unikronsoftware.com/2dtoolkit/doc/2.00/advanced/packed_fonts.html

tk2d doesn't support dynamic fonts yet, as its a Unity 4.x feature and we're still committed to supporting 3.x. We'll support it when we switch to 4.x as the primary dev environment.