Bug 691593

Summary: char_width when call FT_Set_Char_Size
Product: MuPDF Reporter: Flint Ning <flintning>
Component: mupdfAssignee: Tor Andersson <tor.andersson>
Status: RESOLVED INVALID    
Severity: minor    
Priority: P4    
Version: unspecified   
Hardware: PC   
OS: All   
Customer: Word Size: ---

Description Flint Ning 2010-09-06 08:27:03 UTC
At the end of loadsimplefont function in pdf_font.c, when no Widths defined in Font Dict, mupdf tries to construct hmtx from font program. The codes of getting advances of glyphs:
504:	else
505:	{
506:		fterr = FT_Set_Char_Size(face, 1000, 1000, 72, 72);
507:		if (fterr)
508:			fz_warn("freetype set character size: %s", ft_errorstring(fterr));
509:		for (i = 0; i < 256; i++)
510:		{
511:			pdf_addhmtx(fontdesc, i, i, ftwidth(fontdesc, i));
512:		}
513:	}

As descibed in FreeType2 doc, the unit of char_width and char_height in FT_Set_Char_Size is "26.6 fractional points". So, char_width and char_height should be 1000*64, not 1000.
Comment 1 Tor Andersson 2011-02-02 15:48:24 UTC
The metrics from ftwidth are not adjusted from fixed point either, so two wrongs make a right in this case. I don't set the character size to 1000*64 because that causes integer overflow problems with some fonts. If you can point me to a specific file that exhibits a bug caused by this, feel free to reopen the bug and attach the PDF.