NSATSTypesetter Line computation problem

  • In my application i use a custom text container to lay text around a
    hole, the problem occurs when i have two holes side by side.
    In this case the line would be broken down in to three line fragments.
    The problem occurs when the rightmost fragment has bigger font than
    the ones on the left.

    I lhave overridden NSATSTypesetter's
    "getLineFragmentRect: usedRect: remainingRect:
    forStartingGlyphAtIndex: proposedRect: lineSpacing:
    paragraphSpacingBefore: paragraphSpacingAfter: " method
    and i just log the rectangle values after i call super

    This is the first case where the first line has no intersecting holes,
    it behaves fine
    Here is the log for the same:

    2008-08-19 13:01:04.952 testApp[6033:813] Logging Rect Info...
    2008-08-19 13:01:04.953 testApp[6033:813] Proposed Rect: {{0, 0}, {1e
    +07, 11}}
    2008-08-19 13:01:04.954 testApp[6033:813] LineFragment Rect: {{0, 0},
    {482, 11}}
    2008-08-19 13:01:04.960 testApp[6033:813] Remaining Rect: {{0, 0}, {0,
    0}}
    2008-08-19 13:01:04.963 testApp[6033:813] ____________________
    2008-08-19 13:01:04.964 testApp[6033:813] Logging Rect Info...
    2008-08-19 13:01:04.969 testApp[6033:813] Proposed Rect: {{0, 11}, {1e
    +07, 11}}
    2008-08-19 13:01:04.972 testApp[6033:813] LineFragment Rect: {{0, 11},
    {110.664, 11}}
    2008-08-19 13:01:04.979 testApp[6033:813] Remaining Rect: {{190.664,
    11}, {291.336, 11}}
    2008-08-19 13:01:04.979 testApp[6033:813] ____________________
    2008-08-19 13:01:04.980 testApp[6033:813] Logging Rect Info...
    2008-08-19 13:01:04.982 testApp[6033:813] Proposed Rect: {{0, 11}, {1e
    +07, 106}}
    2008-08-19 13:01:04.982 testApp[6033:813] LineFragment Rect: {{0, 11},
    {30.6669, 106}}
    2008-08-19 13:01:04.983 testApp[6033:813] Remaining Rect: {{110.667,
    11}, {371.333, 106}}
    2008-08-19 13:01:04.983 testApp[6033:813] ____________________
    2008-08-19 13:01:04.984 testApp[6033:813] Logging Rect Info...
    2008-08-19 13:01:04.984 testApp[6033:813] Proposed Rect: {{0, 11}, {1e
    +07, 106}}
    2008-08-19 13:01:04.985 testApp[6033:813] LineFragment Rect: {{0, 11},
    {30.6669, 106}}
    2008-08-19 13:01:04.985 testApp[6033:813] Remaining Rect: {{110.667,
    11}, {371.333, 106}}
    2008-08-19 13:01:04.986 testApp[6033:813] ____________________
    2008-08-19 13:01:04.986 testApp[6033:813] Logging Rect Info...
    2008-08-19 13:01:04.987 testApp[6033:813] Proposed Rect: {{0, 11}, {1e
    +07, 106}}
    2008-08-19 13:01:04.987 testApp[6033:813] LineFragment Rect: {{0, 11},
    {30.6669, 106}}
    2008-08-19 13:01:04.988 testApp[6033:813] Remaining Rect: {{110.667,
    11}, {371.333, 106}}
    2008-08-19 13:01:04.988 testApp[6033:813] ____________________
    2008-08-19 13:01:04.989 testApp[6033:813] Logging Rect Info...
    2008-08-19 13:01:04.990 testApp[6033:813] Proposed Rect: {{110.667,
    11}, {1e+07, 11}}
    2008-08-19 13:01:04.990 testApp[6033:813] LineFragment Rect:
    {{190.664, 11}, {291.336, 106}}
    2008-08-19 13:01:04.991 testApp[6033:813] Remaining Rect: {{0, 0}, {0,
    0}}
    2008-08-19 13:01:04.991 testApp[6033:813] ____________________
    2008-08-19 13:01:04.993 testApp[6033:813] Logging Rect Info...
    2008-08-19 13:01:04.993 testApp[6033:813] Proposed Rect: {{190.664,
    11}, {1e+07, 106}}
    2008-08-19 13:01:04.994 testApp[6033:813] LineFragment Rect:
    {{190.665, 11}, {291.336, 106}}
    2008-08-19 13:01:04.994 testApp[6033:813] Remaining Rect: {{0, 0}, {0,
    0}}
    2008-08-19 13:01:04.995 testApp[6033:813] ____________________

    The problem occurs when the hole in the centre is moved op and
    intersects with the first line
    Log for this is:

    2008-08-19 13:04:13.884 testApp[6033:813] Logging Rect Info...
    2008-08-19 13:04:13.885 testApp[6033:813] Proposed Rect: {{0, 0}, {1e
    +07, 11}}
    2008-08-19 13:04:13.886 testApp[6033:813] LineFragment Rect: {{0, 0},
    {110.664, 11}}
    2008-08-19 13:04:13.886 testApp[6033:813] Remaining Rect: {{190.664,
    0}, {291.336, 11}}
    2008-08-19 13:04:13.887 testApp[6033:813] ____________________
    2008-08-19 13:04:13.891 testApp[6033:813] Logging Rect Info...
    2008-08-19 13:04:13.891 testApp[6033:813] Proposed Rect: {{190.664,
    0}, {1e+07, 11}}
    2008-08-19 13:04:13.892 testApp[6033:813] LineFragment Rect:
    {{190.664, 0}, {291.336, 11}}
    2008-08-19 13:04:13.892 testApp[6033:813] Remaining Rect: {{0, 0}, {0,
    0}}
    2008-08-19 13:04:13.892 testApp[6033:813] ____________________
    2008-08-19 13:04:13.893 testApp[6033:813] Logging Rect Info...
    2008-08-19 13:04:13.894 testApp[6033:813] Proposed Rect: {{0, 11}, {1e
    +07, 11}}
    2008-08-19 13:04:13.894 testApp[6033:813] LineFragment Rect: {{0, 11},
    {110.664, 11}}
    2008-08-19 13:04:13.894 testApp[6033:813] Remaining Rect: {{190.664,
    11}, {291.336, 11}}
    2008-08-19 13:04:13.895 testApp[6033:813] ____________________
    2008-08-19 13:04:13.895 testApp[6033:813] Logging Rect Info...
    2008-08-19 13:04:13.896 testApp[6033:813] Proposed Rect: {{190.664,
    11}, {1e+07, 11}}
    2008-08-19 13:04:13.896 testApp[6033:813] LineFragment Rect:
    {{190.664, 11}, {291.336, 11}}
    2008-08-19 13:04:13.899 testApp[6033:813] Remaining Rect: {{0, 0}, {0,
    0}}
    2008-08-19 13:04:13.909 testApp[6033:813] ____________________
    2008-08-19 13:04:13.914 testApp[6033:813] Logging Rect Info...
    2008-08-19 13:04:13.915 testApp[6033:813] Proposed Rect: {{190.664,
    11}, {1e+07, 106}}
    2008-08-19 13:04:13.915 testApp[6033:813] LineFragment Rect:
    {{190.664, 11}, {291.336, 106}}
    2008-08-19 13:04:13.916 testApp[6033:813] Remaining Rect: {{0, 0}, {0,
    0}}
    2008-08-19 13:04:13.916 testApp[6033:813] ____________________

    The problem is that after it computes the first line fragment for the
    second line, it should again call the first line frag with bigger
    height but it doesn't do so, instead it directly sets the line frag.
    for the first line fragment and never comes back to it.
    So if you refer the above code, after the third log, it should again
    call with Proposed Rect {{0, 11}, {1e+07, 106}}, but it doesn't do so
    as it has already set the line frag. for it

    I'd really appreciate if anyone could help me with this.
    Thanks
    Chaitanya
previous month august 2008 next month
MTWTFSS
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Go to today