static void MCFontDrawTextCallback(MCFontRef p_font, MCStringRef p_text, MCRange p_range, font_draw_text_context *ctxt) { MCGFont t_font; t_font = MCFontStructToMCGFont(p_font->fontstruct); // MW-2013-12-04: [[ Bug 11535 ]] Pass through the fixed advance. t_font . fixed_advance = p_font -> fixed_advance; // The drawing is done on the UTF-16 form of the text MCGContextDrawPlatformText(ctxt->m_gcontext, MCStringGetCharPtr(p_text) + p_range.offset, p_range.length*2, MCGPointMake(ctxt->x, ctxt->y), t_font, ctxt->rtl); // The draw position needs to be advanced // MM-2014-04-16: [[ Bug 11964 ]] Pass through the scale of the context to make sure the measurment is correct. ctxt -> x += MCGContextMeasurePlatformText(NULL, MCStringGetCharPtr(p_text) + p_range.offset, p_range.length*2, t_font, MCGContextGetDeviceTransform(ctxt->m_gcontext)); }
int32_t MCNativeControlUserYLocFromDeviceYLoc(int32_t p_device_y_loc) { MCGPoint t_loc; t_loc = MCNativeControlUserPointFromDevicePoint(MCGPointMake(0.0f, (MCGFloat) p_device_y_loc)); return (int32_t) t_loc . y; }
static void MCFontDrawTextCallback(MCFontRef p_font, const char *p_text, uint32_t p_length, bool p_is_unicode, font_draw_text_context *ctxt) { MCGFont t_font; t_font = MCFontStructToMCGFont(p_font->fontstruct); // MW-2013-12-04: [[ Bug 11535 ]] Pass through the fixed advance. t_font . fixed_advance = p_font -> fixed_advance; // MW-2013-12-04: [[ Bug 11549 ]] Make sure unicode text is short-aligned. MCExecPoint ep; ep . setsvalue(MCString(p_text, p_length)); if (!p_is_unicode) ep . nativetoutf16(); else if ((((uintptr_t)ep . getsvalue() . getstring()) & 1) != 0) ep . grabsvalue(); MCGContextDrawPlatformText(ctxt->m_gcontext, (unichar_t *) ep . getsvalue() . getstring(), ep . getsvalue() . getlength(), MCGPointMake(ctxt->x, ctxt->y), t_font); // The draw position needs to be advanced. Can this be done more efficiently? ctxt -> x += MCGContextMeasurePlatformText(NULL, (unichar_t*)ep.getsvalue().getstring(), ep.getsvalue().getlength(), t_font); }
int32_t MCNativeControlUserXLocFromDeviceXLoc(int32_t p_device_x_loc) { MCGPoint t_loc; t_loc = MCNativeControlUserPointFromDevicePoint(MCGPointMake((MCGFloat) p_device_x_loc, 0.0f)); return (int32_t) t_loc . x; }