On Friday, 21 April 2017 02:21:55 UTC+3, saif wrote:
>
> image atlas will assume that all needed fonts will fit in "image.NewRGBA
> (image.Rect(0, 0, 1024, 1024))", right?
>

Not really, there are two fixes when you fill up the image:

1. Create an new atlas for new glyphs (switching during rendering as 
necessary) -- i.e. paging
2. Clear the current image and rerender glyphs -- i.e. removing glyphs that 
haven't been used for a while.

With the 2. the whole atlas should be a grid where you add/remove glyphs as 
needed and reupload as little as possible.

To avoid expensive rasterization there must be a cache somewhere -- there 
is no escaping from it. Whether you do it per-glyph, per-text and how you 
invalidate/update are just details... annoying little details.
 

> can i can call loadglyph(), when when a rune is needed? or should i call 
> LoadGlyphs() with all possible runes during initialization?
>
> i think this will be slow, if i will initialize LoadGlyphs() with asian 
> texts, right?
>

LoadGlyphs is there to preallocate a batch of glyphs.

loadGlyph is executed only once per glyph during the lifetime of the 
program. Of course when you are using asian text I suspect you will fill up 
the atlas rather quickly.

On Thursday, April 20, 2017 at 2:52:53 PM UTC+8, Egon wrote:
>>
>> On Tuesday, 18 April 2017 08:02:02 UTC+3, saif wrote:
>>>
>>> Hi,
>>>
>>> I like to ask for your suggestions.
>>>
>>> I found a nice project, and was trying to modify them but got stuck with 
>>> fonts.
>>> (github.com/dskinner/material)
>>>
>>> I like the fonts to be configurable, but when I tried to parse the fonts 
>>> at runtime, it seems slow.
>>>
>>> The idea from the example is to preparse fonts with 72 fontsize, then 
>>> create a a texture to be rendered.
>>> Is there a better way to do this?
>>>
>>
>>>
>>> Thanks,
>>> S
>>>
>>
>> Create a glyph or text atlas invalidating, updating, paging it as needed.
>>
>> For a basic glyph atlas 
>> https://gist.github.com/egonelbre/fbbf4651a4f75f8450fd4fc2244c283f -- 
>> you can of course use multiple pages and use better layouting algorithm to 
>> preserve memory.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to