Skip to content

Commit 9760973

Browse files
author
David C. Lonie
committed
Fix conic point identification in the path renderer.
The numeric value of FT_CURVE_TAG_CONIC is 0, so the translation to local ControlType failed when testing if (fttag & FT_CURVE_TAG_CONIC) { ... } Replaced the translation with a more robust approach. This wasn't readily apparent using the fonts embedded in VTK, as those fonts consist entirely of linear and cubic curves. Also fixed this functiont to use the pen_[xy] variables, which account for kerning. Change-Id: Ibcd7d28365ecad22d62073dc8bbf89405478f791
1 parent 2c7d13c commit 9760973

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

Rendering/FreeType/vtkFreeTypeTools.cxx

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1964,22 +1964,31 @@ bool vtkFreeTypeTools::RenderCharacter(CharType character, int &x, int &y,
19641964
FT_Vector ftvec = outline->points[point];
19651965
char fttag = outline->tags[point];
19661966
controlType tag = FIRST_POINT;
1967-
if (fttag & FT_CURVE_TAG_ON)
1968-
{
1969-
tag = ON_POINT;
1970-
}
1971-
else if (fttag & FT_CURVE_TAG_CUBIC)
1972-
{
1973-
tag = CUBIC_POINT;
1974-
}
1975-
else if (fttag & FT_CURVE_TAG_CONIC)
1967+
1968+
// Mask the tag and convert to our known-good control types:
1969+
// (0x3 mask is because these values often have trailing garbage --
1970+
// see note above controlType enum).
1971+
switch (fttag & 0x3)
19761972
{
1977-
tag = CONIC_POINT;
1973+
case (FT_CURVE_TAG_ON & 0x3): // 0b01
1974+
tag = ON_POINT;
1975+
break;
1976+
case (FT_CURVE_TAG_CUBIC & 0x3): // 0b11
1977+
tag = CUBIC_POINT;
1978+
break;
1979+
case (FT_CURVE_TAG_CONIC & 0x3): // 0b00
1980+
tag = CONIC_POINT;
1981+
break;
1982+
default:
1983+
vtkWarningMacro("Invalid control code returned from FreeType: "
1984+
<< static_cast<int>(fttag) << " (masked: "
1985+
<< static_cast<int>(fttag & 0x3));
1986+
return false;
19781987
}
19791988

19801989
double vec[2];
1981-
vec[0] = ftvec.x / 64.0 + x;
1982-
vec[1] = ftvec.y / 64.0 + y;
1990+
vec[0] = ftvec.x / 64.0 + pen_x;
1991+
vec[1] = ftvec.y / 64.0 + pen_y;
19831992

19841993
// Handle the first point here, unless it is a CONIC point, in which
19851994
// case the switches below handle it.

0 commit comments

Comments
 (0)