Re: 686975 Black box when converting to tiff

"Igor V. Melichev" <[email protected]>
Newsgroups gmane.comp.printing.ghostscript.patches
Message-ID <[email protected]>
The suggested change doesn't look good.

The old formula in g2o drops few fraction bits with rounding.
If h->g2o_fraction_bits < _fixed_shift, it should add fraction
bits (i.e. multiply by a power of 2), and there is no need for a rounding.
Thus the code should be like this :

private inline fixed o2d(const t1_hinter *h, t1_hinter_space_coord v)
{
    return h->g2o_fraction_bits > _fixed_shift ?
    ((v >> (h->g2o_fraction_bits - _fixed_shift - 1)) + 1) >> 1 :
   v << (_fixed_shift - h->g2o_fraction_bits);
}

But this patch still doesn't look good.
h->g2o_fraction_bits is too small when CTM is too big.
If CTM is too big, the flag disable_hinting to be set and o2d must not call.
Please check what is the glyph size in the device pixels.
If it is big (1000 pixels or so), the line 587 to be improved.

If you're not comfortable with this bug, change the assignment to me.

Igor.

----- Original Message ----- 
From: "Jeong Kim" <[email protected]>
To: <[email protected]>
Sent: Monday, January 12, 2004 3:29 AM
Subject: [gs-code-review] 686975 Black box when converting to tiff


> Reviewers,
>
> The reason why a black box appears when the given file is converted
> into tiff format is due to the invalid glyph data in the file.
> If you convert this file into pdf with Acrobat Distiller, you can see a
> black
> line which is located at the position of the bottom line of the black
> rectangle.
>
> Therefore, the problem is not the black rectangle but a difference between
> results
> at low and high resolution.
> This difference is related with new Type1 hinter.
>
> With NEW_TYPE1_HINTER = 0, at both low and high resolution
> the black rectangle appears. Again there is no difference between
> the outputs at any resolution.
>
> With NEW_TYPE1_HINTER = 1, fraction bits are used to increase
> accuracy and this makes difference between low and high resolution.
>
> gxhintn.c
> --
> private inline fixed o2d(const t1_hinter *h, t1_hinter_space_coord v)
> {
>     return ((v >> (h->g2o_fraction_bits - _fixed_shift - 1)) + 1) >> 1;
> }
>
> In line 283 - gxhintn.c, 'v' is shifted by the value of
> 'h->g2o_fraction_bits - _fixed_shift - 1'. But in the case of 'h-
> >g2o_fraction_bits'
> is less or equal than the value of _fixed_shift, 'v' is attempted to be
> shifted
> by
> a negative value and 'v' is set as zero.
>
> So I did a simple patch work for this problem as follows.
>
> private inline fixed o2d(const t1_hinter *h, t1_hinter_space_coord v)
> {
>     return ((h->g2o_fraction_bits > _fixed_shift) ?
> ((v >> (h->g2o_fraction_bits - _fixed_shift - 1)) + 1) >> 1 :
> ((v << (_fixed_shift - h->g2o_fraction_bits + 1)) + 1) >> 1);
> }
>
> Log:
> With new Type1 Hinter, fraction bits are used to increase accuracy and
this
> makes difference between results at low and high resolution.
> Now Fixed. 686975.
>
> Jeong
>
> Index: src/gxhintn.c
> ===================================================================
> RCS file: /cvs/ghostscript/gs/src/gxhintn.c,v
> retrieving revision 1.41
> diff -C2 -r1.41 gxhintn.c
> *** src/gxhintn.c 7 Jan 2004 11:12:59 -0000 1.41
> --- src/gxhintn.c 12 Jan 2004 00:22:01 -0000
> ***************
> *** 280,284 ****
>
>   private inline fixed o2d(const t1_hinter *h, t1_hinter_space_coord v)
> ! {   return ((v >> (h->g2o_fraction_bits - _fixed_shift - 1)) + 1) >> 1;
>   }
>
> --- 280,287 ----
>
>   private inline fixed o2d(const t1_hinter *h, t1_hinter_space_coord v)
> ! {
> !     return ((h->g2o_fraction_bits > _fixed_shift) ?
> ! ((v >> (h->g2o_fraction_bits - _fixed_shift - 1)) + 1) >> 1 :
> ! ((v << (_fixed_shift - h->g2o_fraction_bits + 1)) + 1) >> 1);
>   }
>
> _______________________________________________
> gs-code-review mailing list
> [email protected]
> http://www.ghostscript.com/mailman/listinfo/gs-code-review
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.