2017-01-02 22:53:31 -06:00
|
|
|
// 2 january 2017
|
2016-01-12 00:12:35 -06:00
|
|
|
#import "uipriv_darwin.h"
|
2017-01-06 22:53:23 -06:00
|
|
|
#import "draw.h"
|
2016-01-12 00:12:35 -06:00
|
|
|
|
2017-01-23 10:43:03 -06:00
|
|
|
@interface lineInfo : NSObject
|
|
|
|
@property NSRange glyphRange;
|
|
|
|
@property NSRange characterRange;
|
|
|
|
@property NSRect lineRect;
|
2017-01-23 14:07:28 -06:00
|
|
|
@property NSRect lineUsedRect;
|
|
|
|
@property NSRect glyphBoundingRect;
|
2017-01-23 10:43:03 -06:00
|
|
|
@property CGFloat baselineOffset;
|
2017-01-24 00:04:08 -06:00
|
|
|
@property double ascent;
|
|
|
|
@property double descent;
|
|
|
|
@property double leading;
|
2017-01-23 10:43:03 -06:00
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation lineInfo
|
|
|
|
@end
|
2017-01-17 11:02:42 -06:00
|
|
|
|
2017-01-02 22:53:31 -06:00
|
|
|
struct uiDrawTextLayout {
|
2017-01-23 10:43:03 -06:00
|
|
|
// NSTextStorage is subclassed from NSMutableAttributedString
|
|
|
|
NSTextStorage *attrstr;
|
|
|
|
NSTextContainer *container;
|
|
|
|
NSLayoutManager *layoutManager;
|
2017-01-17 11:02:42 -06:00
|
|
|
|
|
|
|
// the width as passed into uiDrawTextLayout constructors
|
2017-01-02 22:53:31 -06:00
|
|
|
double width;
|
2017-01-17 11:02:42 -06:00
|
|
|
|
2017-01-23 10:43:03 -06:00
|
|
|
#if 0 /* TODO */
|
2017-01-17 11:02:42 -06:00
|
|
|
// the *actual* size of the frame
|
2017-01-05 20:36:07 -06:00
|
|
|
// note: technically, metrics returned from frame are relative to CGPathGetPathBoundingBox(tl->path)
|
|
|
|
// however, from what I can gather, for a path created by CGPathCreateWithRect(), like we do (with a NULL transform), CGPathGetPathBoundingBox() seems to just return the standardized form of the rect used to create the path
|
|
|
|
// (this I confirmed through experimentation)
|
|
|
|
// so we can just use tl->size for adjustments
|
|
|
|
// we don't need to adjust coordinates by any origin since our rect origin is (0, 0)
|
2017-01-03 22:59:23 -06:00
|
|
|
CGSize size;
|
2017-01-23 10:43:03 -06:00
|
|
|
#endif
|
2017-01-17 11:02:42 -06:00
|
|
|
|
2017-01-23 10:43:03 -06:00
|
|
|
NSMutableArray<lineInfo *> *lineInfo;
|
2017-01-17 11:02:42 -06:00
|
|
|
|
|
|
|
// for converting CFAttributedString indices to byte offsets
|
2017-01-07 19:09:44 -06:00
|
|
|
size_t *u16tou8;
|
|
|
|
size_t nu16tou8; // TODO I don't like the casing of this name
|
2016-01-12 00:12:35 -06:00
|
|
|
};
|
|
|
|
|
2017-01-23 10:43:03 -06:00
|
|
|
static NSFont *fontdescToNSFont(uiDrawFontDescriptor *fd)
|
2017-01-03 11:18:17 -06:00
|
|
|
{
|
2017-01-23 10:43:03 -06:00
|
|
|
NSFontDescriptor *desc;
|
|
|
|
NSFont *font;
|
2017-01-03 11:18:17 -06:00
|
|
|
|
2017-01-23 10:43:03 -06:00
|
|
|
desc = fontdescToNSFontDescriptor(fd);
|
|
|
|
font = [NSFont fontWithDescriptor:desc size:fd->Size];
|
|
|
|
[desc release];
|
2017-01-03 11:18:17 -06:00
|
|
|
return font;
|
|
|
|
}
|
|
|
|
|
2017-01-23 10:43:03 -06:00
|
|
|
static NSTextStorage *attrstrToTextStorage(uiAttributedString *s, uiDrawFontDescriptor *defaultFont)
|
2016-01-12 00:12:35 -06:00
|
|
|
{
|
2017-01-23 10:43:03 -06:00
|
|
|
NSString *nsstr;
|
|
|
|
NSMutableDictionary *defaultAttrs;
|
|
|
|
NSTextStorage *attrstr;
|
2016-01-12 00:12:35 -06:00
|
|
|
|
2017-01-23 10:43:03 -06:00
|
|
|
nsstr = [[NSString alloc] initWithCharacters:attrstrUTF16(s)
|
|
|
|
length:attrstrUTF16Len(s)];
|
2016-01-12 00:46:28 -06:00
|
|
|
|
2017-01-23 10:43:03 -06:00
|
|
|
defaultAttrs = [NSMutableDictionary new];
|
|
|
|
[defaultAttrs setObject:fontdescToNSFont(defaultFont)
|
|
|
|
forKey:NSFontAttributeName];
|
2017-01-17 11:02:42 -06:00
|
|
|
|
2017-01-23 10:43:03 -06:00
|
|
|
attrstr = [[NSTextStorage alloc] initWithString:nsstr
|
|
|
|
attributes:defaultAttrs];
|
|
|
|
[defaultAttrs release];
|
|
|
|
[nsstr release];
|
2017-01-17 11:02:42 -06:00
|
|
|
|
2017-01-23 10:43:03 -06:00
|
|
|
[attrstr beginEditing];
|
|
|
|
// TODO copy in the attributes
|
|
|
|
[attrstr endEditing];
|
2017-01-17 11:02:42 -06:00
|
|
|
|
2017-01-23 10:43:03 -06:00
|
|
|
return attrstr;
|
2017-01-17 11:02:42 -06:00
|
|
|
}
|
|
|
|
|
2017-01-23 10:43:03 -06:00
|
|
|
// TODO fine-tune all the properties
|
2017-01-02 22:53:31 -06:00
|
|
|
uiDrawTextLayout *uiDrawNewTextLayout(uiAttributedString *s, uiDrawFontDescriptor *defaultFont, double width)
|
2016-01-12 00:46:28 -06:00
|
|
|
{
|
2017-01-03 22:59:23 -06:00
|
|
|
uiDrawTextLayout *tl;
|
|
|
|
CGFloat cgwidth;
|
2017-01-23 10:43:03 -06:00
|
|
|
// TODO correct type?
|
|
|
|
NSUInteger index;
|
2017-01-03 22:59:23 -06:00
|
|
|
|
|
|
|
tl = uiNew(uiDrawTextLayout);
|
2017-01-23 10:43:03 -06:00
|
|
|
tl->attrstr = attrstrToTextStorage(s, defaultFont);
|
2017-01-03 22:59:23 -06:00
|
|
|
tl->width = width;
|
|
|
|
|
2017-01-23 10:43:03 -06:00
|
|
|
// TODO the documentation on the size property implies this might not be necessary?
|
2017-01-03 22:59:23 -06:00
|
|
|
cgwidth = (CGFloat) width;
|
|
|
|
if (cgwidth < 0)
|
|
|
|
cgwidth = CGFLOAT_MAX;
|
2017-01-23 10:43:03 -06:00
|
|
|
// TODO rename to tl->textContainer
|
|
|
|
tl->container = [[NSTextContainer alloc] initWithSize:NSMakeSize(cgwidth, CGFLOAT_MAX)];
|
|
|
|
// TODO pull the reference for this
|
|
|
|
[tl->container setLineFragmentPadding:0];
|
|
|
|
|
|
|
|
tl->layoutManager = [[NSLayoutManager alloc] init];
|
|
|
|
|
|
|
|
[tl->layoutManager addTextContainer:tl->container];
|
|
|
|
[tl->attrstr addLayoutManager:tl->layoutManager];
|
|
|
|
// and force a re-layout (TODO get source
|
|
|
|
[tl->layoutManager glyphRangeForTextContainer:tl->container];
|
|
|
|
|
|
|
|
// TODO equivalent of CTFrameProgression for RTL/LTR?
|
|
|
|
|
|
|
|
// now collect line information; see https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/TextLayout/Tasks/CountLines.html
|
|
|
|
tl->lineInfo = [NSMutableArray<lineInfo *> new];
|
|
|
|
index = 0;
|
|
|
|
while (index < [tl->layoutManager numberOfGlyphs]) {
|
|
|
|
NSRange glyphRange;
|
2017-01-24 00:04:08 -06:00
|
|
|
__block lineInfo *li;
|
2017-01-23 10:43:03 -06:00
|
|
|
|
|
|
|
li = [lineInfo new];
|
2017-01-24 00:04:08 -06:00
|
|
|
li.lineRect = [tl->layoutManager lineFragmentRectForGlyphAtIndex:index effectiveRange:&glyphRange];
|
2017-01-23 10:43:03 -06:00
|
|
|
li.glyphRange = glyphRange;
|
|
|
|
li.characterRange = [tl->layoutManager characterRangeForGlyphRange:li.glyphRange actualGlyphRange:NULL];
|
2017-01-23 14:07:28 -06:00
|
|
|
li.lineUsedRect = [tl->layoutManager lineFragmentUsedRectForGlyphAtIndex:index effectiveRange:NULL];
|
|
|
|
li.glyphBoundingRect = [tl->layoutManager boundingRectForGlyphRange:li.glyphRange inTextContainer:tl->container];
|
2017-01-23 10:43:03 -06:00
|
|
|
// and this is from http://www.cocoabuilder.com/archive/cocoa/308568-how-to-get-baseline-info.html and http://www.cocoabuilder.com/archive/cocoa/199283-height-and-location-of-text-within-line-in-nslayoutmanager-ignoring-spacing.html
|
|
|
|
li.baselineOffset = [[tl->layoutManager typesetter] baselineOffsetInLayoutManager:tl->layoutManager glyphIndex:index];
|
2017-01-24 00:04:08 -06:00
|
|
|
li.ascent = 0;
|
|
|
|
li.descent = 0;
|
|
|
|
li.leading = 0;
|
|
|
|
// imitate what AppKit actually does (or seems to)
|
|
|
|
[tl->attrstr enumerateAttributesInRange:li.characterRange options:0 usingBlock:^(NSDictionary<NSString *,id> *attrs, NSRange range, BOOL *stop) {
|
|
|
|
NSFont *f;
|
2017-01-24 09:36:13 -06:00
|
|
|
NSRect boundingRect;
|
|
|
|
double v, realAscent, realDescent, realLeading;
|
|
|
|
BOOL skipAdjust, doAdjust;
|
2017-01-24 00:04:08 -06:00
|
|
|
|
|
|
|
f = (NSFont *) [attrs objectForKey:NSFontAttributeName];
|
|
|
|
if (f == nil) {
|
|
|
|
f = [NSFont fontWithName:@"Helvetica" size:12.0];
|
|
|
|
if (f == nil)
|
|
|
|
f = [NSFont systemFontOfSize:12.0];
|
|
|
|
}
|
|
|
|
|
2017-01-24 09:36:13 -06:00
|
|
|
boundingRect = [f boundingRectForFont];
|
|
|
|
realAscent = [f ascender];
|
|
|
|
realDescent = -[f descender];
|
|
|
|
realLeading = [f leading];
|
|
|
|
skipAdjust = NO;
|
|
|
|
doAdjust = NO;
|
|
|
|
if (NSMaxY(boundingRect) <= realAscent) {
|
|
|
|
// ascent entirely within bounding box
|
|
|
|
// don't do anything if there's leading; I'm guessing it's a combination of both of the reasons to skip below... (least sure of this one)
|
|
|
|
if (realLeading != 0)
|
|
|
|
skipAdjust = YES;
|
|
|
|
// does the descent slip outside the bounding box?
|
|
|
|
if (-realDescent <= NSMinY(boundingRect))
|
|
|
|
// yes — I guess we should assume accents don't collide with the previous line's descent, though I'm not as sure of that as I am about the else clause below...
|
|
|
|
skipAdjust = YES;
|
|
|
|
} else {
|
|
|
|
// ascent outside bounding box — ascent does not include accents
|
|
|
|
// only skip adjustment if there isn't leading (apparently some fonts use the previous line's leading for accents? :/ )
|
|
|
|
if (realLeading != 0)
|
|
|
|
skipAdjust = YES;
|
|
|
|
}
|
|
|
|
if (!skipAdjust) {
|
|
|
|
UniChar ch = 0xC0;
|
|
|
|
CGGlyph glyph;
|
|
|
|
|
|
|
|
// there does not seem to be an AppKit API for this...
|
|
|
|
if (CTFontGetGlyphsForCharacters((CTFontRef) f, &ch, &glyph, 1) != false) {
|
|
|
|
NSRect bbox;
|
|
|
|
|
|
|
|
bbox = [f boundingRectForGlyph:glyph];
|
|
|
|
if (NSMaxY(bbox) > realAscent)
|
|
|
|
doAdjust = YES;
|
|
|
|
if (-realDescent > NSMinY(bbox))
|
|
|
|
doAdjust = YES;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// TODO vertical
|
2017-01-24 00:04:08 -06:00
|
|
|
|
2017-01-24 09:36:13 -06:00
|
|
|
v = [f ascender];
|
|
|
|
// TODO get this one back out
|
|
|
|
if (doAdjust)
|
|
|
|
v += 0.2 * ([f ascender] + [f descender]);
|
|
|
|
//v = floor(v + 0.5);
|
2017-01-24 00:04:08 -06:00
|
|
|
if (li.ascent < v)
|
|
|
|
li.ascent = v;
|
|
|
|
|
2017-01-24 09:36:13 -06:00
|
|
|
v = -[f descender];// floor(-[f descender] + 0.5);
|
2017-01-24 00:04:08 -06:00
|
|
|
if (li.descent < v)
|
|
|
|
li.descent = v;
|
|
|
|
|
2017-01-24 09:36:13 -06:00
|
|
|
v = [f leading];//floor([f leading] + 0.5);
|
2017-01-24 00:04:08 -06:00
|
|
|
if (li.leading < v)
|
|
|
|
li.leading = v;
|
|
|
|
}];
|
2017-01-24 09:36:13 -06:00
|
|
|
li.ascent = floor(li.ascent + 0.5);
|
|
|
|
li.descent = floor(li.descent + 0.5);
|
|
|
|
li.leading = floor(li.leading + 0.5);
|
2017-01-23 10:43:03 -06:00
|
|
|
[tl->lineInfo addObject:li];
|
|
|
|
[li release];
|
|
|
|
index = glyphRange.location + glyphRange.length;
|
2017-01-04 22:50:08 -06:00
|
|
|
}
|
|
|
|
|
2017-01-07 19:09:44 -06:00
|
|
|
// and finally copy the UTF-16 to UTF-8 index conversion table
|
|
|
|
tl->u16tou8 = attrstrCopyUTF16ToUTF8(s, &(tl->nu16tou8));
|
|
|
|
|
2017-01-03 22:59:23 -06:00
|
|
|
return tl;
|
2016-01-12 00:12:35 -06:00
|
|
|
}
|
|
|
|
|
2017-01-02 22:53:31 -06:00
|
|
|
void uiDrawFreeTextLayout(uiDrawTextLayout *tl)
|
2016-01-12 00:12:35 -06:00
|
|
|
{
|
2017-01-07 19:09:44 -06:00
|
|
|
uiFree(tl->u16tou8);
|
2017-01-23 10:43:03 -06:00
|
|
|
[tl->lineInfo release];
|
|
|
|
[tl->layoutManager release];
|
|
|
|
[tl->container release];
|
|
|
|
[tl->attrstr release];
|
2017-01-03 11:18:17 -06:00
|
|
|
uiFree(tl);
|
2016-01-12 00:12:35 -06:00
|
|
|
}
|
|
|
|
|
2017-01-06 22:53:23 -06:00
|
|
|
// TODO document that (x,y) is the top-left corner of the *entire frame*
|
2017-01-02 22:53:31 -06:00
|
|
|
void uiDrawText(uiDrawContext *c, uiDrawTextLayout *tl, double x, double y)
|
2016-01-15 19:18:53 -06:00
|
|
|
{
|
2017-01-23 10:43:03 -06:00
|
|
|
NSGraphicsContext *gc;
|
2017-01-06 22:53:23 -06:00
|
|
|
|
2017-01-23 10:43:03 -06:00
|
|
|
CGContextFlush(c->c); // just to be safe
|
|
|
|
[NSGraphicsContext saveGraphicsState];
|
|
|
|
gc = [NSGraphicsContext graphicsContextWithGraphicsPort:c->c flipped:YES];
|
|
|
|
[NSGraphicsContext setCurrentContext:gc];
|
2017-01-06 22:53:23 -06:00
|
|
|
|
2017-01-23 10:43:03 -06:00
|
|
|
// TODO is this the right point?
|
|
|
|
// TODO does this draw with the proper default styles?
|
|
|
|
[tl->layoutManager drawGlyphsForGlyphRange:[tl->layoutManager glyphRangeForTextContainer:tl->container]
|
|
|
|
atPoint:NSMakePoint(x, y)];
|
2017-01-06 22:53:23 -06:00
|
|
|
|
2017-01-23 10:43:03 -06:00
|
|
|
[gc flushGraphics]; // just to be safe
|
|
|
|
[NSGraphicsContext restoreGraphicsState];
|
|
|
|
// TODO release gc?
|
2016-01-15 19:18:53 -06:00
|
|
|
}
|
|
|
|
|
2017-01-23 10:43:03 -06:00
|
|
|
// TODO update all of these {
|
2017-01-05 16:56:47 -06:00
|
|
|
// TODO document that the width and height of a layout is not necessarily the sum of the widths and heights of its constituent lines; this is definitely untrue on OS X, where lines are placed in such a way that the distance between baselines is always integral
|
2017-01-20 15:36:44 -06:00
|
|
|
// TODO width doesn't include trailing whitespace...
|
|
|
|
// TODO figure out how paragraph spacing should play into this
|
2017-01-23 10:43:03 -06:00
|
|
|
// }
|
2017-01-02 22:53:31 -06:00
|
|
|
void uiDrawTextLayoutExtents(uiDrawTextLayout *tl, double *width, double *height)
|
2016-01-16 12:34:22 -06:00
|
|
|
{
|
2017-01-23 10:43:03 -06:00
|
|
|
NSRect r;
|
|
|
|
|
|
|
|
// see https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/TextLayout/Tasks/StringHeight.html
|
|
|
|
r = [tl->layoutManager usedRectForTextContainer:tl->container];
|
|
|
|
*width = r.size.width;
|
|
|
|
*height = r.size.height;
|
2016-01-16 12:34:22 -06:00
|
|
|
}
|
|
|
|
|
2017-01-02 22:53:31 -06:00
|
|
|
int uiDrawTextLayoutNumLines(uiDrawTextLayout *tl)
|
2016-01-16 12:34:22 -06:00
|
|
|
{
|
2017-01-23 10:43:03 -06:00
|
|
|
return [tl->lineInfo count];
|
2016-01-16 12:34:22 -06:00
|
|
|
}
|
2016-01-15 21:48:38 -06:00
|
|
|
|
2017-01-02 22:53:31 -06:00
|
|
|
void uiDrawTextLayoutLineByteRange(uiDrawTextLayout *tl, int line, size_t *start, size_t *end)
|
2016-01-15 19:18:53 -06:00
|
|
|
{
|
2017-01-23 10:43:03 -06:00
|
|
|
lineInfo *li;
|
2017-01-04 22:50:08 -06:00
|
|
|
|
2017-01-23 10:43:03 -06:00
|
|
|
li = (lineInfo *) [tl->lineInfo objectAtIndex:line];
|
|
|
|
*start = tl->u16tou8[li.characterRange.location];
|
|
|
|
*end = tl->u16tou8[li.characterRange.location + li.characterRange.length];
|
2016-01-15 19:18:53 -06:00
|
|
|
}
|
|
|
|
|
2017-01-02 22:53:31 -06:00
|
|
|
void uiDrawTextLayoutLineGetMetrics(uiDrawTextLayout *tl, int line, uiDrawTextLayoutLineMetrics *m)
|
2016-01-12 00:12:35 -06:00
|
|
|
{
|
2017-01-23 10:43:03 -06:00
|
|
|
lineInfo *li;
|
|
|
|
|
|
|
|
li = (lineInfo *) [tl->lineInfo objectAtIndex:line];
|
|
|
|
|
|
|
|
m->X = li.lineRect.origin.x;
|
|
|
|
m->Y = li.lineRect.origin.y;
|
2017-01-23 14:07:28 -06:00
|
|
|
// if we use li.lineRect here we get the whole line, not just the part with stuff in it
|
|
|
|
m->Width = li.lineUsedRect.size.width;
|
2017-01-23 10:43:03 -06:00
|
|
|
m->Height = li.lineRect.size.height;
|
|
|
|
|
|
|
|
// TODO is this correct?
|
2017-01-23 13:31:39 -06:00
|
|
|
m->BaselineY = (m->Y + m->Height) - li.baselineOffset;
|
2017-01-24 00:04:08 -06:00
|
|
|
m->Ascent = li.ascent;
|
|
|
|
m->Descent = li.descent;
|
|
|
|
m->Leading = li.leading;
|
2017-01-23 10:43:03 -06:00
|
|
|
|
|
|
|
// TODO
|
|
|
|
m->ParagraphSpacingBefore = 0;
|
|
|
|
m->LineHeightSpace = 0;
|
|
|
|
m->LineSpacing = 0;
|
|
|
|
m->ParagraphSpacing = 0;
|
2016-01-12 00:12:35 -06:00
|
|
|
}
|
|
|
|
|
2017-01-07 19:09:44 -06:00
|
|
|
void uiDrawTextLayoutHitTest(uiDrawTextLayout *tl, double x, double y, uiDrawTextLayoutHitTestResult *result)
|
2016-05-23 00:11:43 -05:00
|
|
|
{
|
2017-01-23 10:43:03 -06:00
|
|
|
#if 0 /* TODO */
|
2017-01-17 11:02:42 -06:00
|
|
|
CFIndex i;
|
2017-01-17 12:05:40 -06:00
|
|
|
CTLineRef line;
|
2017-01-17 11:02:42 -06:00
|
|
|
CFIndex pos;
|
2017-01-07 19:09:44 -06:00
|
|
|
|
2017-01-17 11:02:42 -06:00
|
|
|
if (y >= 0) {
|
|
|
|
for (i = 0; i < tl->nLines; i++) {
|
|
|
|
double ltop, lbottom;
|
2017-01-07 19:09:44 -06:00
|
|
|
|
2017-01-17 11:02:42 -06:00
|
|
|
ltop = tl->lineMetrics[i].Y;
|
|
|
|
lbottom = ltop + tl->lineMetrics[i].Height;
|
|
|
|
if (y >= ltop && y < lbottom)
|
2017-01-07 19:09:44 -06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
result->YPosition = uiDrawTextLayoutHitTestPositionInside;
|
2017-01-17 11:02:42 -06:00
|
|
|
if (i == tl->nLines) {
|
|
|
|
i--;
|
|
|
|
result->YPosition = uiDrawTextLayoutHitTestPositionAfter;
|
2017-01-07 19:09:44 -06:00
|
|
|
}
|
2017-01-17 11:02:42 -06:00
|
|
|
} else {
|
|
|
|
i = 0;
|
|
|
|
result->YPosition = uiDrawTextLayoutHitTestPositionBefore;
|
2017-01-07 19:09:44 -06:00
|
|
|
}
|
2017-01-17 12:05:40 -06:00
|
|
|
result->Line = i;
|
2017-01-17 11:02:42 -06:00
|
|
|
|
|
|
|
result->XPosition = uiDrawTextLayoutHitTestPositionInside;
|
|
|
|
if (x < tl->lineMetrics[i].X) {
|
2017-01-17 12:05:40 -06:00
|
|
|
result->XPosition = uiDrawTextLayoutHitTestPositionBefore;
|
2017-01-17 11:02:42 -06:00
|
|
|
// and forcibly return the first character
|
|
|
|
x = tl->lineMetrics[i].X;
|
|
|
|
} else if (x > (tl->lineMetrics[i].X + tl->lineMetrics[i].Width)) {
|
2017-01-17 12:05:40 -06:00
|
|
|
result->XPosition = uiDrawTextLayoutHitTestPositionAfter;
|
2017-01-17 11:02:42 -06:00
|
|
|
// and forcibly return the last character
|
|
|
|
x = tl->lineMetrics[i].X + tl->lineMetrics[i].Width;
|
|
|
|
}
|
|
|
|
|
|
|
|
line = (CTLineRef) CFArrayGetValueAtIndex(tl->lines, i);
|
2017-01-17 12:05:40 -06:00
|
|
|
// TODO copy the part from the docs about this point
|
|
|
|
pos = CTLineGetStringIndexForPosition(line, CGPointMake(x, 0));
|
2017-01-17 11:02:42 -06:00
|
|
|
if (pos == kCFNotFound) {
|
|
|
|
// TODO
|
|
|
|
}
|
2017-01-17 12:05:40 -06:00
|
|
|
result->Pos = tl->u16tou8[pos];
|
2017-01-23 10:43:03 -06:00
|
|
|
#endif
|
2016-05-23 00:11:43 -05:00
|
|
|
}
|
|
|
|
|
2017-01-02 22:53:31 -06:00
|
|
|
void uiDrawTextLayoutByteRangeToRectangle(uiDrawTextLayout *tl, size_t start, size_t end, uiDrawTextLayoutByteRangeRectangle *r)
|
2016-04-19 15:06:50 -05:00
|
|
|
{
|
|
|
|
}
|