freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Freetype-devel] Re: GSOC - Distance Fields


From: Anuj Verma
Subject: Re: [Freetype-devel] Re: GSOC - Distance Fields
Date: Wed, 15 Jul 2020 09:51:18 +0530

Hello All,

>> The basic sdf module is done, now that is left is to
>> optimize it, fix bugs etc. I will start by optimizing it.
>> I have decided to test three optimization method:
>> * Bounding box (BB)
>> * Subdivisions
>> * And also a coarse grid method that Behdad suggested.

I have added all the optimization modes to the module.
By far the fastest method is to subdivide the curve into
a number of line segments.The coarse grid method is
the slowest unless I am doing something wrong.
[
  Behdad, I divided the grid into 8x8 coarse grid and then
  to find the relevant edges of the coarse grid I am using
  the spread value and the half diagonal of the coarse grid.
  So if any edge's nearest distance to a coarse grid is greater
  then spread + ( coarse grid diagonal length / 2 ) I discard it.
  It works well and for each coarse grid I am getting around
  4 edges, but it's still pretty slower than the bounding box and
  the subdivision method. If you need more details please let
  me know.
]
The major downside of the BB and subdivision methods is
that they require a considerable amount of memory usage
(almost 3x of the size of bitmap) because we need to keep
a track of the distances and signs of all the grid points.

>> The image is upside down in linux maybe because in linux the y = 0
>> is at the the top which is different from windows. I'll fix it soon
>> while adding bilinear filtering.

I have updated the demo, added bilinear filtering, shape
reconstruction and has all optimization modes which can
be toggled. I have attached the new list of keys.
(https://github.com/preversewharf45/ft2sdf-demo)

For now I would like to hold the outline implementation for
now and go to the bitmap implementation. After that the module
can be used to generate SDF from bitmaps directly. It will be
pretty fast and will not require any additional memory other than
the bitmap itself at a cost of reduced accuracy. However there
are a few issues.

* `FT_Render_Glyph_Internal' break if the glyph format is already
   a bitmap.
   ```
    case FT_GLYPH_FORMAT_BITMAP:   /* already a bitmap, don't do anything */
      break;
   ```
* `FT_Lookup_Renderer' uses renderer format which is currently
  `FT_GLYPH_FORMAT_OUTLINE' for the `sdf' module. How can
   make it accept both outline and bitmap glyph format ?

I don't like the idea of changing the internals of freetype so is there
any other way in which this can be done ?

Thanks in advance,
Anuj

Attachment: keys.txt
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]