@@ -950,9 +950,15 @@ void MCBlock::split(findex_t p_index)
950950void MCBlock::drawstring (MCDC *dc, coord_t x, coord_t p_cell_left, coord_t p_cell_right, int2 y, findex_t start, findex_t length, Boolean image, uint32_t style)
951951{
952952 // MW-2012-02-16: [[ FontRefs ]] Fetch the font metrics we need to draw.
953- int32_t t_ascent, t_descent;
953+ coord_t t_ascent, t_descent, t_leading, t_xheight ;
954954 t_ascent = MCFontGetAscent (m_font);
955955 t_descent = MCFontGetDescent (m_font);
956+ t_leading = MCFontGetLeading (m_font);
957+ t_xheight = MCFontGetXHeight (m_font);
958+
959+ // Width for strike-through/underline lines. Factor is arbitrary...
960+ coord_t t_strikewidth;
961+ t_strikewidth = ceilf (MCFontGetAscent (m_font)/16 );
956962
957963 // MW-2012-01-25: [[ ParaStyles ]] Fetch the vGrid setting from the owning paragraph.
958964 if (parent -> getvgrid ())
@@ -1011,9 +1017,17 @@ void MCBlock::drawstring(MCDC *dc, coord_t x, coord_t p_cell_left, coord_t p_cel
10111017 if (t_next_index - t_index > 0 )
10121018 {
10131019 if ((style & FA_UNDERLINE ) != 0 )
1014- dc -> drawline (x, y + 1 , x + t_width, y + 1 );
1020+ {
1021+ MCRectangle t_underlinerect;
1022+ t_underlinerect = MCU_make_rect (x, y + t_strikewidth, t_width, t_strikewidth);
1023+ dc -> fillrect (t_underlinerect);
1024+ }
10151025 if ((style & FA_STRIKEOUT ) != 0 )
1016- dc -> drawline (x, y - (t_ascent >> 1 ), x + t_width, y - (t_ascent >> 1 ));
1026+ {
1027+ MCRectangle t_strikerect;
1028+ t_strikerect = MCU_make_rect (x, y - (t_xheight / 2 ) - (t_strikewidth / 2 ), t_width, t_strikewidth);
1029+ dc -> fillrect (t_strikerect);
1030+ }
10171031 if ((style & FA_BOX ) != 0 )
10181032 {
10191033 // MW-2012-09-04: [[ Bug 9759 ]] Adjust any pattern origin to scroll with text.
@@ -1111,9 +1125,17 @@ void MCBlock::drawstring(MCDC *dc, coord_t x, coord_t p_cell_left, coord_t p_cel
11111125
11121126 // Apply strike/underline.
11131127 if ((style & FA_UNDERLINE ) != 0 )
1114- dc -> drawline (t_line_x, y + 1 , t_line_x + t_line_width, y + 1 );
1128+ {
1129+ MCRectangle t_underlinerect;
1130+ t_underlinerect = MCU_make_rect (t_line_x, y + t_strikewidth, t_line_width, t_strikewidth);
1131+ dc -> fillrect (t_underlinerect);
1132+ }
11151133 if ((style & FA_STRIKEOUT ) != 0 )
1116- dc -> drawline (t_line_x, y - (t_ascent >> 1 ), t_line_x + t_line_width, y - (t_ascent >> 1 ));
1134+ {
1135+ MCRectangle t_strikerect;
1136+ t_strikerect = MCU_make_rect (t_line_x, y - (t_xheight / 2 ) - (t_strikewidth / 2 ), t_line_width, t_strikewidth);
1137+ dc -> fillrect (t_strikerect);
1138+ }
11171139 }
11181140}
11191141
@@ -1889,7 +1911,7 @@ uint2 MCBlock::getascent(void)
18891911 if (flags & F_HAS_IMAGE && atts->image != NULL )
18901912 return MCU_max (0 , atts->image ->getrect ().height - shift + 2 );
18911913 else
1892- return MCU_max (0 , heightfromsize (MCFontGetAscent (m_font)) - MCFontGetDescent (m_font) - shift);
1914+ return MCU_max (0 , heightfromsize (ceilf ( MCFontGetAscent (m_font))) - uint2 ( ceilf ( MCFontGetDescent (m_font)) ) - shift);
18931915}
18941916
18951917uint2 MCBlock::getdescent (void )
@@ -1898,7 +1920,35 @@ uint2 MCBlock::getdescent(void)
18981920 if (flags & F_HAS_IMAGE && atts->image != NULL )
18991921 return MCU_max (0 , shift);
19001922 else
1901- return MCU_max (0 , MCFontGetDescent (m_font) + shift);
1923+ return MCU_max (0 , uint2 (ceilf (MCFontGetDescent (m_font))) + shift);
1924+ }
1925+
1926+ coord_t MCBlock::GetAscent () const
1927+ {
1928+ int2 shift = flags & F_HAS_SHIFT ? atts->shift : 0 ;
1929+ // MW-2007-07-05: [[ Bug 1943 ]] - Images do not have correct ascent height *MIGHT NEED REVERSION*
1930+ if (flags & F_HAS_IMAGE && atts->image != NULL )
1931+ return MCU_max (0 , atts->image ->getrect ().height - shift + 2 );
1932+ else
1933+ return MCU_max (0 .0f , MCFontGetAscent (m_font) - shift);
1934+ }
1935+
1936+ coord_t MCBlock::GetDescent () const
1937+ {
1938+ int2 shift = flags & F_HAS_SHIFT ? atts->shift : 0 ;
1939+ if (flags & F_HAS_IMAGE && atts->image != NULL )
1940+ return MCU_max (0 , shift);
1941+ else
1942+ return MCU_max (0 .0f , MCFontGetDescent (m_font) + shift);
1943+ }
1944+
1945+ coord_t MCBlock::GetLeading () const
1946+ {
1947+ int2 shift = flags & F_HAS_SHIFT ? atts->shift : 0 ;
1948+ if (flags & F_HAS_IMAGE && atts->image != NULL )
1949+ return GetAscent ()+GetDescent ();
1950+ else
1951+ return MCFontGetLeading (m_font);
19021952}
19031953
19041954void MCBlock::freeatts ()
0 commit comments