-
Notifications
You must be signed in to change notification settings - Fork 17
/
JJTypesetter.m
44 lines (34 loc) · 895 Bytes
/
JJTypesetter.m
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
32
33
34
35
36
37
38
39
40
41
42
43
44
//
// JJTypesetter.m
// TextEdit
//
// Created by Jjgod Jiang on 8/31/09.
//
#import "JJTypesetter.h"
@implementation JJTypesetter
@synthesize enabled=_isEnabled;
- (void) fontDidChange: (NSFont *) font
{
if (! _isEnabled)
return;
NSLayoutManager *lm = [self layoutManager];
_lineHeight = [lm defaultLineHeightForFont: font];
_baselineOffset = [lm defaultBaselineOffsetForFont: font];
}
- (void) willSetLineFragmentRect:(NSRectPointer)lineRect
forGlyphRange:(NSRange)glyphRange
usedRect:(NSRectPointer)usedRect
baselineOffset:(CGFloat *)baselineOffset
{
if (! _isEnabled)
return;
if (! _lineHeight)
{
NSFont *font = [NSFont userFixedPitchFontOfSize:0.0];
[self fontDidChange: font];
}
lineRect->size.height = _lineHeight;
usedRect->size.height = _lineHeight;
*baselineOffset = _baselineOffset;
}
@end