Changeset 1163

Show
Ignore:
Timestamp:
10/15/09 23:13:34 (11 months ago)
Author:
astrange
Message:

SSA: Fix toptitles being too low.

Ignoring the descent brings us closer to the
accurate positioning for them.

Especially improves [Mazui]_To_Aru_Kagaku_no_Railgun_-_02v2_[C1073458].mkv.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/Subtitles/SubATSUIRenderer.m

    r1140 r1163  
    633633 
    634634// XXX see comment for GetTypographicRectangleForLayout 
    635 static ATSUTextMeasurement GetLineHeight(ATSUTextLayout layout, UniCharArrayOffset lpos) 
    636 { 
    637         ATSUTextMeasurement ascent, descent; 
     635static ATSUTextMeasurement GetLineHeight(ATSUTextLayout layout, UniCharArrayOffset lpos, Boolean includeDescent) 
     636{ 
     637        ATSUTextMeasurement ascent = 0, descent = 0; 
    638638         
    639639        ATSUGetLineControl(layout, lpos, kATSULineAscentTag,  sizeof(ATSUTextMeasurement), &ascent,  NULL); 
    640         ATSUGetLineControl(layout, lpos, kATSULineDescentTag, sizeof(ATSUTextMeasurement), &descent, NULL); 
     640        if (includeDescent) ATSUGetLineControl(layout, lpos, kATSULineDescentTag, sizeof(ATSUTextMeasurement), &descent, NULL); 
    641641         
    642642        return ascent + descent; 
     
    667667                ATSUGetGlyphBounds(layout, 0, baseY, breaks[i], end-breaks[i], kATSUseDeviceOrigins, 1, &trap, &trapCount); 
    668668 
    669                 baseY += GetLineHeight(layout, breaks[i]) + extraHeight; 
     669                baseY += GetLineHeight(layout, breaks[i], YES) + extraHeight; 
    670670                 
    671671                rect.bottom = MAX(trap.lowerLeft.y, trap.lowerRight.y); 
     
    716716                CGContextStrokeRect(c, CGRectMake(FixedToFloat(penX) + pixRect.left, FixedToFloat(penY) + pixRect.top, pixRect.right - pixRect.left, pixRect.bottom - pixRect.top)); 
    717717                 
    718                 penY += GetLineHeight(layout, breaks[i]) + extraHeight; 
     718                penY += GetLineHeight(layout, breaks[i], YES) + extraHeight; 
    719719        } 
    720720} 
     
    733733                ATSUMeasureTextImage(layout, breaks[i], end-breaks[i], 0, baseY, &rect); 
    734734                 
    735                 baseY += GetLineHeight(layout, breaks[i]) + extraHeight; 
     735                baseY += GetLineHeight(layout, breaks[i], YES) + extraHeight; 
    736736                 
    737737                if (i == breakCount) largeRect = rect; 
     
    10591059                } 
    10601060 
    1061                 penY += breakc.direction * (GetLineHeight(layout, thisBreak) + FloatToFixed(extraHeight)); 
     1061                penY += breakc.direction * (GetLineHeight(layout, thisBreak, YES) + FloatToFixed(extraHeight)); 
    10621062        } 
    10631063                 
     
    11821182                                case kSubAlignmentTop: 
    11831183                                        if (!topPen || resetPens) { 
    1184                                                 penY = FloatToFixed(NSMaxY(marginRect)) - GetLineHeight(layout, kATSUFromTextBeginning); 
     1184                                                penY = FloatToFixed(NSMaxY(marginRect)) - GetLineHeight(layout, kATSUFromTextBeginning, NO); 
    11851185                                        } else penY = topPen; 
    11861186