Once upon a time, about last October, the thought of a freetype testsuite appeared yet again on the list.
I've been working on a function in fontforge to make fontforge's testsuite (such as it is) more capable, and I realized that this same thing could be used to test freetype. If anyone cares to. The idea is essentially what Ulrich was suggesting: you create a set of bitmaps for a font with a "good" version of the library, and then with later versions you generate new bitmaps and compare against the originals. I've written two fontforge scripts which I'm attaching. One builds up an sfd file of a font and inserts bitmaps, the other loads that in, builds up new bitmaps, and tests that they are similar. $ fontforge -script SetupBitmapTest.pe ARIAL.TTF 12 13 14 15 16 17 18 19 Created: ArialMTBitmaps.sfd <install a new version of freetype to be tested> $ fontforge -script TestBitmaps.pe ArialMTBitmaps.sfd Ok The first can take as arguments: * An integer (=> a bitmap strike at that pixelsize with depth 1) * <int>'@'<int> (=> a strike at first int pixelsize, depth of second) * a filename (containing a bitmap strike) In the first two cases fontforge will use freetype to rasterize the font to produce a strike of a given pixelsize/depth. In the third case it will load a pregenerated strike (somehow obtained from another rasterizer?) The test script just takes one argument: the name of an sfd file containing bitmaps to be tested. Bitmaps of depth 1 are tested for exact pixel matches. Bitmaps of depth 8 are tested to make sure that pixels are with in 2 (out of 256) of the corresponding pixel in the original strike -- this can be adjusted by editing the script, I don't know what a good value is here). This method has a potential drawback: fontforge never rasterizes the original font. Instead it regenerates the font from its internal copy of the splines and metadata. Currently I don't have any way to pass rasterization flags to freetype, but if there is any interest in this approach I could easily add this ability. Is this worth pursuing? (these scripts only work with the fontforge currently in the cvs tree, none of the released versions support this yet)
#/usr/local/bin/fontforge # First argument should be an sfd file containing an outline font and a # set of "good" bitmap strikes. # This checks that rasterizing using the current rasterizer will produce the # same (or very similar) results. Open($1) sizes = $bitmaps Reencode("Original") /* Make sure no holes in encoding */ SelectAll() Copy() BitmapsRegen(sizes) CompareGlyphs(-1,-1,.01) Print("Ok") /* Otherwise we will die in CompareGlyphs with an error */
#/usr/local/bin/fontforge # First argument is the filename of an outline font to be tested. May be in # any format fontforge supports. # Subsequent arguments should be either: # * A number (indicates a pixelsize of depth 1) # * Two numbers with an @ between them (pixelsize at depth) # * File name containing a bitmap/greymap strike # Output will be an sfd file named <fontname>"Bitmaps.sfd" if ( $argc<3 ) Error("Too few arguments") endif Open($1) i = 2; cnt = 0 while ( i<$argc ) if ( Strskipint($argv[i])!=0 ) ++cnt; endif ++i endloop if ( cnt!=0 ) bitmaps = Array(cnt) cnt = 0 i = 2; while ( i<$argc ) if ( Strskipint($argv[i])!=0 ) pixelsize = Strtol($argv[i]); end_pos = Strskipint($argv[i]) if ( Strsub($argv[i],end_pos,end_pos+1)=="@" ) depth = Strtol(Strsub($argv[i],end_pos+1)) else depth = 1 endif bitmaps[cnt++] = (depth * 65536) | pixelsize endif ++i endloop BitmapsAvail(bitmaps); endif i = 2; while ( i<$argc ) if ( Strskipint($argv[i])==0 ) Import($argv[i]) endif ++i endloop Save($fontname+"Bitmaps.sfd") Print( "Created: " + $fontname + "Bitmaps.sfd")
_______________________________________________ Freetype-devel mailing list Freetype-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/freetype-devel