日志:关于freetype dropout control
freetype2对于dropout control 的控制比较粗糙。具体问题表现在verdana 10号字体的"7"字,Simsun的10号字体的"t"和"7"字。还有比如Tahoma 小字体的"c"字,往往会缺了头或者尾巴。这些问题在AA后变得不明显,所以也就被人忽略了。读了一会代码,发现如果把dropout control变成4,上述问题就会消失,但是同时也多了很多“毛刺”,比如verdana的"8"和"6"就出现了不该有的点。看来这个问题还不是这么简单。
相关的代码在src/raster/ftraster.c里:
line 2125
-------------------------------------------
/* Drop-out control */
e1 = CEILING( x1 );
e2 = FLOOR( x2 );
if ( e1 > e2 )
{
if ( e1 == e2 + ras.precision )
{
switch ( ras.dropOutControl )
{
case 1:
e1 = e2;
break;
case 4:
e1 = CEILING( (x1 + x2 + 1) / 2 );
break;
case 2:
case 5:
/* Drop-out Control Rule #4 */
/* The spec is not very clear regarding rule #4.It */
/* presents a method that is way too costly to implement*/
/* while the general idea seems to get rid of `stubs'. */
/* */
/* Here, we only get rid of stubs recognized if: */
/* */
/*upper stub: */
/* */
/* - P_Left and P_Right are in the same contour */
/* - P_Right is the successor of P_Left in that contour */
/* - y is the top of P_Left and P_Right */
/* */
/*lower stub: */
/* */
/* - P_Left and P_Right are in the same contour */
/* - P_Left is the successor of P_Right in that contour */
/* - y is the bottom of P_Left */
/* */
/* FIXXXME: uncommenting this line solves the disappearing */
/* bit problem in the `7' of verdana 10pts, but */
/* makes a new one in the `C' of arial 14pts */
#if 0
if ( x2 - x1 < ras.precision_half )
#endif
{
/* upper stub test */
if ( left->next == right && left->height <= 0 )
return;
/* lower stub test */
if ( right->next == left && left->start == y )
return;
}
/* check that the rightmost pixel isn't set */
e1 = TRUNC( e1 );
c1 = (Short)( e1 >> 3 );
f1 = (Short)( e1 &7 );
if ( e1 >= 0 && e1 < ras.bWidth &&
ras.bTarget[ras.traceOfs + c1] & ( 0x80 >> f1 ) )
return;
if ( ras.dropOutControl == 2 )
e1 = e2;
else
e1 = CEILING( ( x1 + x2 + 1 ) / 2 );
break;
default:
return;/* unsupported mode */
}
}
else
return;
}
e1 = TRUNC( e1 );
if ( e1 >= 0 && e1 < ras.bWidth )
{
c1 = (Short)( e1 >> 3 );
f1 = (Short)( e1 & 7 );
if ( ras.gray_min_x > c1 ) ras.gray_min_x = c1;
if ( ras.gray_max_x < c1 ) ras.gray_max_x = c1;
ras.bTarget[ras.traceOfs + c1] |= (char)( 0x80 >> f1 );
}
}
相关资料:
MSDN的简介
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dnargdi/html/msdn_truetype.asp
Truetype 标准文件(word)
http://www.microsoft.com/typography/tt/ttf_spec/ttch01.doc?fname= &fsize=
页:
[1]