Resolved Core Text pain by not even thinking about lines in terms of boxes.
This commit is contained in:
parent
dfaf640101
commit
3910ff1a13
|
@ -119,12 +119,16 @@ void uiDrawFreeTextLayout(uiDrawTextLayout *tl)
|
||||||
uiFree(tl);
|
uiFree(tl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO what is y, the top-left corner, bottom-left corner, topmost baseline, or bottommost baseline?
|
||||||
void uiDrawText(uiDrawContext *c, uiDrawTextLayout *tl, double x, double y)
|
void uiDrawText(uiDrawContext *c, uiDrawTextLayout *tl, double x, double y)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiDrawTextLayoutExtents(uiDrawTextLayout *tl, double *width, double *height)
|
void uiDrawTextLayoutExtents(uiDrawTextLayout *tl, double *width, double *height)
|
||||||
{
|
{
|
||||||
|
// TODO how exactly do we adjust this by CGPathGetPathBoundingBox(tl->path)?
|
||||||
|
*width = tl->size.width;
|
||||||
|
*height = tl->size.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
int uiDrawTextLayoutNumLines(uiDrawTextLayout *tl)
|
int uiDrawTextLayoutNumLines(uiDrawTextLayout *tl)
|
||||||
|
@ -157,13 +161,12 @@ void uiDrawTextLayoutLineGetMetrics(uiDrawTextLayout *tl, int line, uiDrawTextLa
|
||||||
CTFrameGetLineOrigins(tl->frame, range, &origin);
|
CTFrameGetLineOrigins(tl->frame, range, &origin);
|
||||||
// TODO how exactly do we adjust this by CGPathGetPathBoundingBox(tl->path)?
|
// TODO how exactly do we adjust this by CGPathGetPathBoundingBox(tl->path)?
|
||||||
m->X = origin.x;
|
m->X = origin.x;
|
||||||
m->Y = origin.y;
|
m->BaselineY = origin.y;
|
||||||
// TODO is m->Y the baseline position?
|
// TODO m->Y is flipped
|
||||||
// TODO is m->Y flipped?
|
|
||||||
|
|
||||||
lr = getline(tl, line);
|
lr = getline(tl, line);
|
||||||
// though CTLineGetTypographicBounds() returns 0 on error, it also returns 0 on an empty string, so we can't reasonably check for error
|
// though CTLineGetTypographicBounds() returns 0 on error, it also returns 0 on an empty string, so we can't reasonably check for error
|
||||||
m->Width = CTLineGetTypographicBounds(lr, ascent, descent, leading);
|
m->Width = CTLineGetTypographicBounds(lr, &ascent, &descent, &leading);
|
||||||
m->Ascent = ascent;
|
m->Ascent = ascent;
|
||||||
m->Descent = descent;
|
m->Descent = descent;
|
||||||
m->Leading = leading;
|
m->Leading = leading;
|
||||||
|
|
|
@ -90,10 +90,12 @@ typedef struct uiDrawTextLayoutLineMetrics uiDrawTextLayoutLineMetrics;
|
||||||
typedef struct uiDrawTextLayoutByteRangeRectangle uiDrawTextLayoutByteRangeRectangle;
|
typedef struct uiDrawTextLayoutByteRangeRectangle uiDrawTextLayoutByteRangeRectangle;
|
||||||
|
|
||||||
struct uiDrawTextLayoutLineMetrics {
|
struct uiDrawTextLayoutLineMetrics {
|
||||||
|
// TODO figure out if this is correct regardless of both alignment and writing direction
|
||||||
double X;
|
double X;
|
||||||
double Y;
|
double BaselineY;
|
||||||
double Width;
|
double Width;
|
||||||
// height = ascent + descent + leading (TODO formally document)
|
// top-left Y = baseline Y - ascent
|
||||||
|
// height = ascent + descent + leading (TODO formally document all this)
|
||||||
double Ascent;
|
double Ascent;
|
||||||
double Descent;
|
double Descent;
|
||||||
double Leading;
|
double Leading;
|
||||||
|
|
Loading…
Reference in New Issue