freetype-devel
[Top][All Lists]
Advanced

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

Re: [ft-devel] [GSoC] [Doubt] Difference in Glyph Dimensions


From: Werner LEMBERG
Subject: Re: [ft-devel] [GSoC] [Doubt] Difference in Glyph Dimensions
Date: Tue, 18 Jul 2017 07:11:52 +0200 (CEST)

> When rendering glyphs, I came across same glyph having different
> dimensions (height / width) in different versions (I was comparing
> glyphs rendered by version 2.6.3 and the latest git version)

Changed dimensions count as major rendering difference.

> Note: I needed images to be of the same height / width to form
> sprite sheets.

Take the maximum value of the dimensions?

> As a solution, Till now, When I wanted to compare those, I added
> white lines (as padding) on the edges (rows / columns) of the
> smaller image to compensate for the difference and then did the
> comparison.

In general, any solution to compute stitches is valid IMHO.  Trying to
superposition the glyphs, then computing the corresponding padding is
a bonus option, to be used only if dimension changes are expected –
and usually they are not.

> [...]  This totally depends on the glyph itself.  I think there is
> no way to guess which sides to fill and by how much to align them.

You will find a lot of literature and code samples for image
alignment.  For our purposes it would be sufficient to apply shifting
– neither rotation, shearing, or any other image warping is needed.

> Turns out some glyphs have differences that are only changes in a
> particular dimension.  [...]

This is basically the same issue.

> Is it a bad Idea to do this (adding rows/columns)?

Well, it's another option to view differences.  Usually, you would
mark changed pixels.  If you apply image alignment, you have to mark
changed pixels *and* the image offsets – the latter might be pale
coloured horizontal and vertical stripes, say.

> What should I do for comparing these type of glyphs?  Should I
> *mark* these particular glyphs in the list-view web-page to show
> that the dimensions are different?

Yes.  The default algorithm might be as follows.

  . Compute the maximum of width and height.
  . Align the images with the lower left corner.
  . Compute a numerical delta value that represents the image
    difference; if the dimensions change, make all `new' pixels black
    so that the delta becomes large.


      old image   new image      use this to compute the delta value

                   00000              11111       00000
        0000       00000    ==>       00001       00000
        0110       01100              01101       01100
        0000       00000              00001       00000

         A           B                  A'          B


If you align images, the algorithm might be as follows.

  . Align images.
  . Compute a numerical delta value that represents the image
    difference:

      delta = image_diff(A, B)
              + x_weight * abs(width(B) - width(A))
              + y_weight * abs(height(B) - height(A))

> As this problem arises *only* when we want to highlight the pixels
> that are different, (adding effects/visualizations) we can skip
> doing that for these kind of glyphs and show the rendered glyphs
> only and glyph metrics comparison table.

Yes.  As mentioned above, aligning glyphs together with a different
delta computation algorithm is a bonus, not necessary in most cases.

> I've pushed code to generate the list-view web-page yesterday.
> (With sorting of columns as asked).  Is there anything to be added?
> I've attached a screen-shot of the list-view web-page.

Very nice!  Note that I'm travelling a lot the next days, so it might
take some time until I can try to compile your latest results and play
with them.

> Also, I will push the detailed comparison web-page code ASAP.

Thanks.  Note, however, that it is basically Arvinder's job to do
that, since he is responsible for the HTML, CSS, and Java(Script)
part.  So please stay in contact :-)

Arvinder wrote:

> I was wondering the same when I came across these similar but
> different-sized glyphs.  I think if glyph A is the same as A' except
> A' has a column of empty pixels inserted to the left of the actual
> glyph, A and A' will be visually different if rendered, for example,
> as part of a sentence.  So I think we should keep the glyphs intact
> for the comparison metric and image difference picture.  However, I
> agree for the sprites, maybe we can add the padding after making the
> diff images.

Yes.  However, metrics differences should be visualized somehow, see
above.


    Werner

reply via email to

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