Re: FT Cache Subsystem: Custom caches

2023-11-07 Thread Alexei Podtelezhnikov
Hi Kelvin

If you only interested in subpixels shifts and intend to cache 3
positions, you can achieve using LCD rendering and
https://freetype.org/freetype2/docs/reference/ft2-lcd_rendering.html#ft_library_setlcdgeometry.
It is apparent that LCD rendering is essentially 3 traditional
antialiased bitmaps produced for shifted outlines and stacked
together. Therefore, you have it already for 1/3-pixel shifts by
default. Because everything is periodic, you can continue with the LCD
output and clever reading frame shifts for subpixel positioning too.

Theoretically, this should work.

There is also 
https://freetype.org/freetype2/docs/reference/ft2-sizing_and_scaling.html#ft_set_transform
.  Perhaps you should wrap it into
https://freetype.org/freetype2/docs/reference/ft2-cache_subsystem.html#ftc_face_requester.

Alexei



Re: FT Cache Subsystem: Custom caches

2023-11-02 Thread takase1121 via FreeType users
Hi, sorry for the confusion; I think its better if I explain my current 
approach first:

1. I create a FTC_Manager, FTC_CMapCache and FTC_ImageCache, and set them up.
2. I query a glyph ID from FTC_CMapCache.
3. I get a glyph image (almost always an outline in my case) from 
FTC_ImageCache.
4. I copy the FT_Glyph and perform translation and other transformation on it.
5. I rasterize the transformed FT_Glyph.
6. I use the rasterized bitmap.

I wasn't able to cache the rasterized glyph because FTC_SBitCache doesn't 
support transformations.

I am looking to do one of these things:

1. Being able to apply transformations in FTC_SBitCache.

The main reason I can't use FTC_SBitCache is that I need to modify the outline. 
I need to translate it for subpixel positioning, italicize, embolden and apply 
other transformations before rasterizing. I think this is a niche use case, so 
I'm not fully expecting the cache subsystem to support this.

2. Being able to extend / implement my own cache types.

Alternatively, I want to be able to implement a custom cache type, based on 
FTC_Manager. Based on the draft document in the previous email, this was 
possible, but didn't make it to release. This new cache would behave like 
FTC_SBitCache, but supports the various operations I need to do on the glyph 
outlines before rendering.

I hope this clears things up. I was looking for ways to avoid rolling my own 
cache if possible. Thanks.

Kelvin.

Re: FT Cache Subsystem: Custom caches

2023-10-30 Thread Werner LEMBERG


> I'm trying to use FreeType cache subsystem to render glyphs. I tried
> using FTC_SBitCache but I need to modify the outline before
> rendering (translate and transform) so I could only use
> FTC_ImageCache, modify the outline and render it.
> 
> Is there a way to extend the cache mechanism to create my own cache
> that supports all these features?

Extend in which way?  It's not clear to me what you want to cache...


Werner



FT Cache Subsystem: Custom caches

2023-10-24 Thread takase1121 via FreeType users
Hi,

I'm trying to use FreeType cache subsystem to render glyphs. I tried using 
FTC_SBitCache but I need to modify the outline before rendering (translate and 
transform) so I could only use FTC_ImageCache, modify the outline and render it.

Is there a way to extend the cache mechanism to create my own cache that 
supports all these features? I Googled and found draft document:

http://www.fifi.org/doc/libfreetype6/cache.html

It doesn't seem to work now. Are there any way to achieve that, or is this 
future planned for the future?

Kelvin

[ft] Cache sizes

2015-02-10 Thread Daniel Wressle
Salutations,

I was summoned to try to debug some really erratic and seemingly random issues 
we had with our font rendering. After many Red Bulls and debug output added
to both our code and the FreeType c-code I managed to figure out why most of 
them was occuring, but I do not understand why.

In short, as soon as we have more faces or sizes than the cache will allow, 
default being 2/2 as you already know, then strange things happens. First of all
we receive face object where the size pointer is NULL. This causes our 
GetKerning routine to fail, since there is no size data to work with. This will 
not occur if
we increase the size of the cache.

Q1: Are we doing something wrong? I would assume that the cache/MRU in FT would 
discard the least used node and then insert the new one, and hand us that. Why 
are we 
getting face objects with NULL size pointers when this happens? Have I 
misunderstood something? The easy solution is to just crank up the size of the 
cache but before
we do that I would like to know that we are not grossly misusing the whole idea 
of the cache.

Q2: The 2/2 defaults seem awfully low, but the manual and most information I've 
come across seem to agree that the cache should not be increased unless 
absolutely required. I guess the outcome of Q1 will decide that in our case, 
but what is  your experience when it comes to these numbers?

To my limited experience and knowledge it would seem a waste to even have a 
cache if we have to make it at least as big as all our faces and sizes 
combined, kind of like making your browser cache big enough to store the entire 
contents of the Internet.

I am assuming that I am missing out on something here. It is quite possible 
that we are doing something wrong on our end but I have verified that the size 
pointer is indeed NULL  using printfs in the FreeType code and that the font we 
are using is the same one as when we just increase the cache and stuff 
worksTM.

I will keep on investigating this matter but I thought I would consult this 
mailing list just to make sure I am not overlooking something blatantly obvious.

King Regards,
Daniel


___
Freetype mailing list
Freetype@nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype


Re: [ft] Cache sizes

2015-02-10 Thread Werner LEMBERG

Hello Daniel!


 In short, as soon as we have more faces or sizes than the cache will
 allow, default being 2/2 as you already know, then strange things
 happens.  First of all we receive face object where the size pointer
 is NULL.  This causes our GetKerning routine to fail, since there is
 no size data to work with.  This will not occur if we increase the
 size of the cache.

Given that FreeType's cache code is still in beta, there might be
bugs.

 Q1: Are we doing something wrong?

I don't think so.  However, it would tremendously help us if you could
provide a simple demo program (to be run on the console) that exhibits
the problems you are experiencing.


Werner

___
Freetype mailing list
Freetype@nongnu.org
https://lists.nongnu.org/mailman/listinfo/freetype


[ft] Cache management tutorial

2010-09-06 Thread Iñaki Castillo Arteta
Hi.

Is there any specific cache management tutorial out there?

 

By the way, is the cache manager *officialy* supported?

 

Regards.

Inaki.

 

 

 

 

 

___
Freetype mailing list
Freetype@nongnu.org
http://lists.nongnu.org/mailman/listinfo/freetype


Re: [ft-devel] Determining Upper Bound of memory consumption for a system using FT cache subsystem

2010-04-01 Thread David Turner
I think you are misunderstood. The cache subsystem memory bounding only
accounts for the objects stored in the cache itself (i.e. glyph outlines,
bitmaps, charmaps), but not the FT_Face and FT_Size objects themselves.
Iirc, you can purge the latter if you want without purging the cache objects
themselves.

Trying to memory-bound the FT_Face and FT_Size objects themselves is pretty
impossible due to the nature of the font format we're trying to support.

Also, the memory bounding does not account for malloc-specific memory block
padding and other stuff like that, so even getting an absolutely correct
estimates of all the bytes consumed is impossible.

Hope this helps.

- David Turner

2010/3/10 Maggy Anastasia maggymaggyma...@gmail.com

 Dear FreeType Developers,

 I have a few questions regarding freetype memory consumption upper bound; I
 am using Freetyper version 2.3.7

 (1) static array: currently we know that all memory consumption by freetype
 is done through malloc calls and its variants. However, is there any other
 memory used in freetype, such as global arrays, which are used for memory
 allocation? If so, do they need any kind of configuration?

 (2) Is there a way for determining the upper bound of memory usage for
 freetype when cache is being used. I know that we can set the upper bound
 for cache nodes (glyph image, cmap, sbitchace, etc.), but is there a way to
 determine the memory consumption for FT_FACE and FT_SIZE? From what I have
 seen regarding this, we can only limit the number of FT_FACE and FT_SIZE;
 however, how to determine the memory requirements for a given number of
 allowable FT_FACE and FT_SIZE. I am using freetype for an embedded system at
 the moment, thus, memory is really a constraint, and it's very important for
 me to be able to determine the size of the heap.


 best regards

 Maggy Anastasia Suryanto

 ___
 Freetype-devel mailing list
 Freetype-devel@nongnu.org
 http://lists.nongnu.org/mailman/listinfo/freetype-devel


___
Freetype-devel mailing list
Freetype-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/freetype-devel


Re: [ft-devel] Determining Upper Bound of memory consumption for a system using FT cache subsystem

2010-03-15 Thread Maggy Anastasia
Hi Werner

Thanks alot for the reply. I have looked at your suggestion and tried to
understand how it works.
I have one question regarding this. I understand that after we set env
variable FT2_ALLOC_COUNT_MAX and FT2_DEBUG_MEMORY on runtime, the value for
FT2_ALLOC_COUNT_MAX will be assigned to  table-alloc_total_max inside
ft_mem_debug_init() (in ftdbgmem.c). This value will later on be used to
bound the memory allocation. However I am confused that inside function
ft_mem_debug_alloc() there is the following check:

 if ( table-bound_total 
 table-alloc_total_max - table-alloc_current  (FT_ULong)size )
  return NULL;

Does the above check aim to bound memory allocation to up to
table-alloc_total_max? If that is the case, should the check be the
following instead:

 if ( table-bound_total 
 table-alloc_total_max - table-alloc_current  (FT_ULong)size )
  return NULL;

Please let me know if I understand wrongly.

best regards

Maggy Anastasia Suryanto
On Sat, Mar 13, 2010 at 8:06 PM, Werner LEMBERG w...@gnu.org wrote:


  (1) static array: currently we know that all memory consumption by
  freetype is done through malloc calls and its variants. However, is
  there any other memory used in freetype, such as global arrays,
  which are used for memory allocation? If so, do they need any kind
  of configuration?

 Yes, there are static arrays, see for example src/psnames/pstables.h.
 However, they can be put into read-only memory since all of them are
 tagged with the `const' modifier.

  (2) Is there a way for determining the upper bound of memory usage
  for freetype when cache is being used.  I know that we can set the
  upper bound for cache nodes (glyph image, cmap, sbitchace, etc.),
  but is there a way to determine the memory consumption for FT_FACE
  and FT_SIZE?  From what I have seen regarding this, we can only
  limit the number of FT_FACE and FT_SIZE; however, how to determine
  the memory requirements for a given number of allowable FT_FACE and
  FT_SIZE. I am using freetype for an embedded system at the moment,
  thus, memory is really a constraint, and it's very important for me
  to be able to determine the size of the heap.

 I suggest that you use the FreeType memory debugger (see the
 FT_DEBUG_MEMORY option in docs/DEBUG).  For debugging, the heap size
 can be limited with the FT2_ALLOC_TOTAL_MAX environment variable.  Its
 results can be then used for your own memory allocation routines.


Werner

___
Freetype-devel mailing list
Freetype-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/freetype-devel


Re: [ft-devel] Determining Upper Bound of memory consumption for a system using FT cache subsystem

2010-03-15 Thread Werner LEMBERG
 Does the above check aim to bound memory allocation to up to
 table-alloc_total_max? If that is the case, should the check be the
 following instead:

  if ( table-bound_total 
  table-alloc_total_max - table-alloc_current  (FT_ULong)size )
   return NULL;

Honestly, I've never used this.  David Turner has written the code,
but he has no more time to handle FreeType issues.  It's easily
possible that you've found a bug.  Please test whether your patch is
the right one.


Werner


___
Freetype-devel mailing list
Freetype-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/freetype-devel


Re: [ft-devel] Determining Upper Bound of memory consumption for a system using FT cache subsystem

2010-03-13 Thread Werner LEMBERG

 (1) static array: currently we know that all memory consumption by
 freetype is done through malloc calls and its variants. However, is
 there any other memory used in freetype, such as global arrays,
 which are used for memory allocation? If so, do they need any kind
 of configuration?

Yes, there are static arrays, see for example src/psnames/pstables.h.
However, they can be put into read-only memory since all of them are
tagged with the `const' modifier.

 (2) Is there a way for determining the upper bound of memory usage
 for freetype when cache is being used.  I know that we can set the
 upper bound for cache nodes (glyph image, cmap, sbitchace, etc.),
 but is there a way to determine the memory consumption for FT_FACE
 and FT_SIZE?  From what I have seen regarding this, we can only
 limit the number of FT_FACE and FT_SIZE; however, how to determine
 the memory requirements for a given number of allowable FT_FACE and
 FT_SIZE. I am using freetype for an embedded system at the moment,
 thus, memory is really a constraint, and it's very important for me
 to be able to determine the size of the heap.

I suggest that you use the FreeType memory debugger (see the
FT_DEBUG_MEMORY option in docs/DEBUG).  For debugging, the heap size
can be limited with the FT2_ALLOC_TOTAL_MAX environment variable.  Its
results can be then used for your own memory allocation routines.


Werner


___
Freetype-devel mailing list
Freetype-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/freetype-devel


[ft-devel] Determining Upper Bound of memory consumption for a system using FT cache subsystem

2010-03-10 Thread Maggy Anastasia
Dear FreeType Developers,

I have a few questions regarding freetype memory consumption upper bound; I
am using Freetyper version 2.3.7

(1) static array: currently we know that all memory consumption by freetype
is done through malloc calls and its variants. However, is there any other
memory used in freetype, such as global arrays, which are used for memory
allocation? If so, do they need any kind of configuration?

(2) Is there a way for determining the upper bound of memory usage for
freetype when cache is being used. I know that we can set the upper bound
for cache nodes (glyph image, cmap, sbitchace, etc.), but is there a way to
determine the memory consumption for FT_FACE and FT_SIZE? From what I have
seen regarding this, we can only limit the number of FT_FACE and FT_SIZE;
however, how to determine the memory requirements for a given number of
allowable FT_FACE and FT_SIZE. I am using freetype for an embedded system at
the moment, thus, memory is really a constraint, and it's very important for
me to be able to determine the size of the heap.


best regards

Maggy Anastasia Suryanto
___
Freetype-devel mailing list
Freetype-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/freetype-devel


FW: [ft] cache manager

2006-07-27 Thread Kristján V . Jónsson

Hi there.
I am reposting this to the list since I got not a single response.  Maybe 
something went wrong.  These are issues of some importance.
1) is important in our application since the node ID is actually a strong 
reference to an application object that needs to be released when the CM 
doesn't know about it any more.
2) is perhaps more important.  The CM is only truly useful if one can hook into 
its loading and transformation stage to provide custom slanting and embolding 
and perhaps other effects.  Somewhere in the archives someone mentioned 
subclassing in this context.  Any more infor on that?

K 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kristján V. 
Jónsson
Sent: 3. júlí 2006 14:17
To: freetype@nongnu.org
Subject: [ft] cache manager

 
Hello there.
I am new to this list although I have been using freetype for a while now.
So, please excuse me if this has been covered before.

I use the cache manager interface to freetype for convenience.  However, there 
are two things there which I find sorely missing:

1) I need CM to tell me when a node goes out of cache.
2) I need to be able to hook into the glyph rendering process so that I can 
provide gransformations for the glyph before caching.  This is to allow me to 
embolden and slant the glyph, for example.

Is there a way to do this?  Or is it simple to enhance freetype to support this?

Cheers,

Kristjan


___
Freetype mailing list
Freetype@nongnu.org
http://lists.nongnu.org/mailman/listinfo/freetype


___
Freetype mailing list
Freetype@nongnu.org
http://lists.nongnu.org/mailman/listinfo/freetype


Re: [ft] cache

2005-10-04 Thread Werner LEMBERG

   Freetype has a big branch of cache functions, that described in
   part of manual, named Cache Sub-System.  I doubt, if I don't say
   FTC_Manager_New, FTC_SBitCache_New etc., if I dont't work with
   freetype through FTC_Manager_LookupSize, FTC_SBitCache_Lookup
   etc., is nothing cashe using in freetype?  Or freetype optimize
   its work itself??

FreeType can be used without the cache sub-system (which is still
experimental; right now it is going to be rewritten), but then you
should do the caching by yourself.  Since rendering is a quite time
consuming process, you'll get a great performance improvement.


Werner


___
Freetype mailing list
Freetype@nongnu.org
http://lists.nongnu.org/mailman/listinfo/freetype