Re: possible bug in BDF generation, with correction

[email protected] Sat, 21 Nov 2015 12:42:16 -0600 (CST)
Newsgroups gmane.comp.fonts.fontforge.devel
Message-ID <[email protected]>
On Sat, 21 Nov 2015, Pierre Hanser wrote:
> when generating a BDF from a ttf font, if it's only BW with no grey
> level, you cannot save it

Can you be much more specific about the circumstances under which this
occurs?  I have no trouble generating BDFs from black-and-white TTF input
using FontForge.  What steps are you following, and what font are you
starting with?

> it's enough to add 1 line in savefont.c:WriteBitmaps:
>
>     for ( i=0; sizes[i]!=0; ++i ) {
>
> +        if ((sizes[i]>>16) == 0)sizes[i] = 0x10000 | sizes[i];
> +
> 	for ( bdf=sf->bitmaps; bdf!=NULL &&
> 		(bdf->pixelsize!=(sizes[i]&0xffff) || BDFDepth(bdf)!=(sizes[i]>>16));
> 		bdf=bdf->next )

This idiom of comparing the high bits of a sizes[] entry against the
return value of BDFDepth occurs many times throughout the FontForge code -
so do they ALL need to be changed the same way?  Before concluding that,
I'd like to find out how a sizes[] entry with all zeroes in the high bits
was created in the first place.  It may not be a mistake (the all-zeros
value may have been created on purpose for some reason), and if it is a
mistake, the problem is most likely at that point in the code, not
everywhere the entries are read.

> another point that seems strange to me is at the beginning of the same
> function:
>
>     for ( i=0; sizes[i]!=0; ++i );
>     ff_progress_change_stages(i);
>
> the ';' after the for is suspicious but I've not investigated.

I think this loop is intended to search for a zero entry in the sizes[]
array, and in that case the semicolon is not a mistake.  When the loop
terminates, i will be the index of the zero entry.

-- 
Matthew Skala
[email protected]                 People before principles.
http://ansuz.sooke.bc.ca/

------------------------------------------------------------------------------
_______________________________________________
fontforge-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fontforge-devel
http://fontforge.10959.n7.nabble.com/Developer-f3.html