Skip to content

Commit 4199cfb

Browse files
author
Fraser J. Gordon
committed
Merge branch 'feature-better-fonts' of https://github.com/runrevfraser/livecode into feature-better-fonts-7.0
Conflicts: engine/src/buttondraw.cpp engine/src/coretextfonts.cpp engine/src/graphic.cpp engine/src/line.cpp engine/src/line.h engine/src/mblflst.cpp engine/src/mbliphonedc.mm engine/src/osxflst.cpp
2 parents 2f2c26b + 7e345e2 commit 4199cfb

23 files changed

Lines changed: 365 additions & 87 deletions

engine/engine.xcodeproj/project.pbxproj

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,6 +1722,25 @@
17221722
768D66A41762087500F203A3 /* mbliphonetextmessaging.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = mbliphonetextmessaging.mm; path = src/mbliphonetextmessaging.mm; sourceTree = "<group>"; };
17231723
7269EC371A13D1DE000723DB /* linux-theme.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "linux-theme.cpp"; path = "src/linux-theme.cpp"; sourceTree = "<group>"; };
17241724
7269EC421A162199000723DB /* windows-theme.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "windows-theme.cpp"; path = "src/windows-theme.cpp"; sourceTree = "<group>"; };
1725+
7269EC5F1A1CE64C000723DB /* mblandroidnotification.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = mblandroidnotification.cpp; path = src/mblandroidnotification.cpp; sourceTree = "<group>"; };
1726+
7269EC601A1CE64C000723DB /* mblandroidplayer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = mblandroidplayer.cpp; path = src/mblandroidplayer.cpp; sourceTree = "<group>"; };
1727+
7269EC611A1CE64C000723DB /* mblandroidscroller.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = mblandroidscroller.cpp; path = src/mblandroidscroller.cpp; sourceTree = "<group>"; };
1728+
7269EC621A1CE64C000723DB /* mblandroidsensor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = mblandroidsensor.cpp; path = src/mblandroidsensor.cpp; sourceTree = "<group>"; };
1729+
7269EC631A1CE64C000723DB /* mblandroidsound.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = mblandroidsound.cpp; path = src/mblandroidsound.cpp; sourceTree = "<group>"; };
1730+
7269EC641A1CE64C000723DB /* mblandroidstore.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = mblandroidstore.cpp; path = src/mblandroidstore.cpp; sourceTree = "<group>"; };
1731+
7269EC651A1CE64C000723DB /* mblandroidtextmessaging.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = mblandroidtextmessaging.cpp; path = src/mblandroidtextmessaging.cpp; sourceTree = "<group>"; };
1732+
7269EC661A1CE64C000723DB /* mblandroidtypeface.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = mblandroidtypeface.cpp; path = src/mblandroidtypeface.cpp; sourceTree = "<group>"; };
1733+
7269EC671A1CE64C000723DB /* mblandroidtypeface.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = mblandroidtypeface.h; path = src/mblandroidtypeface.h; sourceTree = "<group>"; };
1734+
7269EC681A1CE684000723DB /* mblandroidad.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = mblandroidad.cpp; path = src/mblandroidad.cpp; sourceTree = "<group>"; };
1735+
7269EC691A1CE684000723DB /* mblandroidalert.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = mblandroidalert.cpp; path = src/mblandroidalert.cpp; sourceTree = "<group>"; };
1736+
7269EC6A1A1CE684000723DB /* mblandroidbrowser.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = mblandroidbrowser.cpp; path = src/mblandroidbrowser.cpp; sourceTree = "<group>"; };
1737+
7269EC6B1A1CE684000723DB /* mblandroidbusyindicator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = mblandroidbusyindicator.cpp; path = src/mblandroidbusyindicator.cpp; sourceTree = "<group>"; };
1738+
7269EC6C1A1CE684000723DB /* mblandroidcalendar.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = mblandroidcalendar.cpp; path = src/mblandroidcalendar.cpp; sourceTree = "<group>"; };
1739+
7269EC6D1A1CE684000723DB /* mblandroidcontact.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = mblandroidcontact.cpp; path = src/mblandroidcontact.cpp; sourceTree = "<group>"; };
1740+
7269EC6E1A1CE684000723DB /* mblandroidcontrol.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = mblandroidcontrol.cpp; path = src/mblandroidcontrol.cpp; sourceTree = "<group>"; };
1741+
7269EC6F1A1CE684000723DB /* mblandroidcontrol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = mblandroidcontrol.h; path = src/mblandroidcontrol.h; sourceTree = "<group>"; };
1742+
7269EC701A1CE684000723DB /* mblandroidfont.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = mblandroidfont.cpp; path = src/mblandroidfont.cpp; sourceTree = "<group>"; };
1743+
7269EC711A1CE684000723DB /* mblandroidinput.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = mblandroidinput.cpp; path = src/mblandroidinput.cpp; sourceTree = "<group>"; };
17251744
72B67C501A0BBDF600BB2594 /* mac-theme.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = "mac-theme.mm"; path = "src/mac-theme.mm"; sourceTree = "<group>"; };
17261745
76CCAA7B198003B000C79271 /* mac-qt-recorder.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = "mac-qt-recorder.mm"; path = "src/mac-qt-recorder.mm"; sourceTree = "<group>"; };
17271746
76CCAA7D19800EFE00C79271 /* platform-recorder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "platform-recorder.cpp"; path = "src/platform-recorder.cpp"; sourceTree = "<group>"; };
@@ -2525,6 +2544,25 @@
25252544
768D668E176207CB00F203A3 /* mblandroidstore.cpp */,
25262545
768D668F176207CB00F203A3 /* mblandroidtextmessaging.cpp */,
25272546
4DD54D15134F591500981610 /* com */,
2547+
7269EC681A1CE684000723DB /* mblandroidad.cpp */,
2548+
7269EC691A1CE684000723DB /* mblandroidalert.cpp */,
2549+
7269EC6A1A1CE684000723DB /* mblandroidbrowser.cpp */,
2550+
7269EC6B1A1CE684000723DB /* mblandroidbusyindicator.cpp */,
2551+
7269EC6C1A1CE684000723DB /* mblandroidcalendar.cpp */,
2552+
7269EC6D1A1CE684000723DB /* mblandroidcontact.cpp */,
2553+
7269EC6E1A1CE684000723DB /* mblandroidcontrol.cpp */,
2554+
7269EC6F1A1CE684000723DB /* mblandroidcontrol.h */,
2555+
7269EC701A1CE684000723DB /* mblandroidfont.cpp */,
2556+
7269EC711A1CE684000723DB /* mblandroidinput.cpp */,
2557+
7269EC5F1A1CE64C000723DB /* mblandroidnotification.cpp */,
2558+
7269EC601A1CE64C000723DB /* mblandroidplayer.cpp */,
2559+
7269EC611A1CE64C000723DB /* mblandroidscroller.cpp */,
2560+
7269EC621A1CE64C000723DB /* mblandroidsensor.cpp */,
2561+
7269EC631A1CE64C000723DB /* mblandroidsound.cpp */,
2562+
7269EC641A1CE64C000723DB /* mblandroidstore.cpp */,
2563+
7269EC651A1CE64C000723DB /* mblandroidtextmessaging.cpp */,
2564+
7269EC661A1CE64C000723DB /* mblandroidtypeface.cpp */,
2565+
7269EC671A1CE64C000723DB /* mblandroidtypeface.h */,
25282566
4DD54D20134F591500981610 /* mblandroid.java */,
25292567
4DD54D21134F591500981610 /* mblandroid.cpp */,
25302568
4DD54D22134F591500981610 /* mblandroid.h */,

engine/src/MCBlock.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ class MCBlock : public MCDLlist
171171
void reset();
172172
uint2 getascent(void);
173173
uint2 getdescent(void);
174+
coord_t GetAscent() const;
175+
coord_t GetDescent() const;
176+
coord_t GetLeading() const;
174177
void freeatts();
175178
void freerefs();
176179
void openimage();

engine/src/block.cpp

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -950,9 +950,15 @@ void MCBlock::split(findex_t p_index)
950950
void 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

18951917
uint2 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

19041954
void MCBlock::freeatts()

engine/src/buttondraw.cpp

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -411,17 +411,31 @@ void MCButton::draw(MCDC *dc, const MCRectangle& p_dirty, bool p_isolated, bool
411411
/* UNCHECKED */ MCStringSplit(t_label, MCSTR("\n"), nil, kMCCompareExact, &lines);
412412
uindex_t nlines = MCArrayGetCount(*lines);
413413

414-
uint2 fheight;
415-
fheight = gettextheight();
416-
417-
int32_t fascent, fdescent;
418-
fascent = MCFontGetAscent(m_font);
419-
fdescent = MCFontGetDescent(m_font);
414+
coord_t fascent, fdescent, fleading, fxheight;
415+
fascent = MCFontGetAscent(m_font);
416+
fdescent = MCFontGetDescent(m_font);
417+
fleading = MCFontGetLeading(m_font);
418+
fxheight = MCFontGetXHeight(m_font);
419+
420+
coord_t fheight;
421+
fheight = fascent + fdescent + fleading;
422+
423+
coord_t sx, sy, theight;
424+
if (nlines == 1)
425+
{
426+
// Centre things on the middle of the ascent
427+
sx = shadowrect.x + leftmargin + borderwidth - DEFAULT_BORDER;
428+
sy = roundf(centery + (fascent-fdescent)/2);
429+
theight = fascent;
430+
}
431+
else
432+
{
433+
// Centre things by centring the bounding box of the text
434+
sx = shadowrect.x + leftmargin + borderwidth - DEFAULT_BORDER;
435+
sy = centery - (nlines * fheight / 2) + fleading/2 + fascent;
436+
theight = nlines * fheight;
437+
}
420438

421-
int2 sx = shadowrect.x + leftmargin + borderwidth - DEFAULT_BORDER;
422-
int2 sy = centery - (nlines * fheight >> 1) + fascent + fdescent - 2;
423-
uint2 theight = nlines == 1 ? fascent : nlines * fheight;
424-
425439
// MW-2014-06-19: [[ IconGravity ]] Use old method of calculating icon location if gravity is none.
426440
if (flags & F_SHOW_ICON && icons != NULL && icons->curicon != NULL && m_icon_gravity == kMCGravityNone)
427441
{
@@ -433,9 +447,9 @@ void MCButton::draw(MCDC *dc, const MCRectangle& p_dirty, bool p_isolated, bool
433447
- (icons->curicon->getrect().width >> 1);
434448
break;
435449
case F_ALIGN_CENTER:
436-
centery -= (theight >> 1) + 1;
437-
sy = shadowrect.y + shadowrect.height - bottommargin - theight
438-
+ fascent - fdescent - 1;
450+
centery -= (theight / 2) + 1;
451+
sy = shadowrect.y + shadowrect.height - bottommargin - theight
452+
+ fascent - fdescent - 1;
439453
break;
440454
case F_ALIGN_RIGHT:
441455
centerx = shadowrect.x + leftmargin
@@ -449,9 +463,9 @@ void MCButton::draw(MCDC *dc, const MCRectangle& p_dirty, bool p_isolated, bool
449463
icondrawed = True;
450464
}
451465

452-
uint2 starty = sy;
466+
coord_t starty = sy;
453467
uint2 i;
454-
uint2 twidth = 0;
468+
coord_t twidth = 0;
455469

456470
dc->save();
457471
dc->cliprect(t_content_rect);
@@ -464,7 +478,7 @@ void MCButton::draw(MCDC *dc, const MCRectangle& p_dirty, bool p_isolated, bool
464478
/* UNCHECKED */ MCArrayFetchValueAtIndex(*lines, i + 1, lineval);
465479
MCStringRef line = (MCStringRef)(lineval);
466480
// MM-2014-04-16: [[ Bug 11964 ]] Pass through the transform of the stack to make sure the measurment is correct for scaled text.
467-
twidth = MCFontMeasureText(m_font, line, getstack() -> getdevicetransform());
481+
twidth = MCFontMeasureTextFloat(m_font, line, getstack() -> getdevicetransform());
468482

469483
// Mnemonic position calculation
470484
uindex_t t_mnemonic = 0;
@@ -494,7 +508,7 @@ void MCButton::draw(MCDC *dc, const MCRectangle& p_dirty, bool p_isolated, bool
494508
}
495509
break;
496510
case F_ALIGN_CENTER:
497-
sx = centerx - (twidth >> 1);
511+
sx = floorf(centerx - (twidth / 2));
498512
if (menumode == WM_OPTION || menumode == WM_COMBO)
499513
sx -= optionrect.width;
500514
// MH-2007-03-16 [[ Bug 3598 ]] Centering of the label did not work correctly on mac os classic and non vista windows option buttons.
@@ -639,10 +653,10 @@ void MCButton::drawlabel(MCDC *dc, int2 sx, int sy, uint2 twidth, const MCRectan
639653
if (getstyleint(flags) == F_MENU && menumode == WM_OPTION
640654
&& MClook != LF_WIN95)
641655
sx += 2;
642-
if (MCaqua && IsMacLFAM()
656+
/*if (MCaqua && IsMacLFAM()
643657
&& (getstyleint(flags) == F_STANDARD || getstyleint(flags) == F_MENU
644658
&& menumode == WM_OPTION))
645-
sy--;
659+
sy--;*/
646660

647661
drawdirectionaltext(dc, sx, sy, p_label, m_font);
648662

engine/src/coretextfonts.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,14 @@ bool coretext_font_destroy(void *p_font)
229229
return true;
230230
}
231231

232-
bool coretext_font_get_metrics(void *p_font, float& r_ascent, float& r_descent)
232+
233+
bool coretext_font_get_metrics(void *p_font, float& r_ascent, float& r_descent, float& r_leading, float& r_xheight)
233234
{
234-
r_ascent = CTFontGetAscent((CTFontRef) p_font);
235-
r_descent = CTFontGetDescent((CTFontRef) p_font);
236-
235+
r_ascent = CTFontGetAscent((CTFontRef) p_font);
236+
r_descent = CTFontGetDescent((CTFontRef) p_font);
237+
r_leading = CTFontGetLeading((CTFontRef) p_font);
238+
r_xheight = CTFontGetXHeight((CTFontRef) p_font);
239+
237240
return true;
238241
}
239242

engine/src/fieldf.cpp

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
3939
#include "globals.h"
4040
#include "mctheme.h"
4141
#include "redraw.h"
42+
#include "line.h"
4243

4344
#include "context.h"
4445

@@ -1024,10 +1025,46 @@ void MCField::drawrect(MCDC *dc, const MCRectangle &dirty)
10241025
d = fixedd;
10251026
}
10261027

1028+
// Calculate the total heights of all paragraphs for vertical centring
1029+
// purposes (this is currently only for combo box entry fields)
1030+
if (parent && parent->gettype() == CT_BUTTON)
1031+
{
1032+
coord_t t_totalpgheight;
1033+
t_totalpgheight = 0.0f;
1034+
MCParagraph* t_pg = pgptr;
1035+
do
1036+
{
1037+
t_totalpgheight += pgptr->getheight(fixedheight);
1038+
t_pg = t_pg->next();
1039+
}
1040+
while (t_pg != paragraphs);
1041+
1042+
// Single-line fields look better when centred slightly differently
1043+
bool t_single_line;
1044+
t_single_line = paragraphs->next() == paragraphs && t_pg->getlines()->next() == t_pg->getlines();
1045+
if (t_single_line)
1046+
{
1047+
t_totalpgheight -= paragraphs->getlines()->GetLeading();
1048+
}
1049+
1050+
// Adjust the drawing y coordinate to account for centring
1051+
if (t_totalpgheight < getfheight())
1052+
{
1053+
// Amount of unused space in the field
1054+
coord_t t_spare;
1055+
t_spare = getfheight() - t_totalpgheight;
1056+
1057+
if (t_single_line)
1058+
y += t_spare/2 + (paragraphs->getlines()->GetAscent() - paragraphs->getlines()->GetDescent())/4;
1059+
else
1060+
y += t_spare/2;
1061+
}
1062+
}
1063+
10271064
int32_t pgheight;
10281065
do
10291066
{
1030-
pgheight = pgptr->getheight(fixedheight);
1067+
pgheight = pgptr->getheight(fixedheight);
10311068

10321069
// MW-2012-03-15: [[ Bug 10069 ]] A paragraph might render a grid line above or below
10331070
// so make sure we render paragraphs above and below the apparant limits.

engine/src/font.cpp

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,22 +219,38 @@ bool MCFontHasPrinterMetrics(MCFontRef self)
219219
return (self -> style & kMCFontStylePrinterMetrics) != 0;
220220
}
221221

222-
int32_t MCFontGetAscent(MCFontRef self)
222+
coord_t MCFontGetAscent(MCFontRef self)
223223
{
224224
// MW-2013-12-19: [[ Bug 11559 ]] If the font has a nil font, do nothing.
225225
if (self -> fontstruct == nil)
226226
return 0;
227227

228-
return self -> fontstruct -> ascent;
228+
return self -> fontstruct -> m_ascent;
229229
}
230230

231-
int32_t MCFontGetDescent(MCFontRef self)
231+
coord_t MCFontGetDescent(MCFontRef self)
232232
{
233233
// MW-2013-12-19: [[ Bug 11559 ]] If the font has a nil font, do nothing.
234234
if (self -> fontstruct == nil)
235235
return 0;
236236

237-
return self -> fontstruct -> descent;
237+
return self -> fontstruct -> m_descent;
238+
}
239+
240+
coord_t MCFontGetLeading(MCFontRef self)
241+
{
242+
if (self -> fontstruct == nil)
243+
return 0;
244+
245+
return self -> fontstruct -> m_leading;
246+
}
247+
248+
coord_t MCFontGetXHeight(MCFontRef self)
249+
{
250+
if (self -> fontstruct == nil)
251+
return 0;
252+
253+
return self -> fontstruct -> m_xheight;
238254
}
239255

240256
void MCFontBreakText(MCFontRef p_font, MCStringRef p_text, MCRange p_range, MCFontBreakTextCallback p_callback, void *p_callback_data, bool p_rtl)
@@ -437,6 +453,12 @@ int32_t MCFontMeasureText(MCFontRef p_font, MCStringRef p_text, const MCGAffineT
437453
return MCFontMeasureTextSubstring(p_font, p_text, t_range, p_transform);
438454
}
439455

456+
MCGFloat MCFontMeasureTextFloat(MCFontRef p_font, MCStringRef p_text, const MCGAffineTransform &p_transform)
457+
{
458+
MCRange t_range = MCRangeMake(0, MCStringGetLength(p_text));
459+
return MCFontMeasureTextSubstringFloat(p_font, p_text, t_range, p_transform);
460+
}
461+
440462
MCGFloat MCFontMeasureTextSubstringFloat(MCFontRef p_font, MCStringRef p_string, MCRange p_range, const MCGAffineTransform &p_transform)
441463
{
442464
font_measure_text_context ctxt;

0 commit comments

Comments
 (0)