-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRules.m
More file actions
57 lines (46 loc) · 1.32 KB
/
Rules.m
File metadata and controls
57 lines (46 loc) · 1.32 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
//
// Rules.m
// CoreText
//
// Created by Matthys Strydom on 2011/02/07.
// Copyright 2011 Polymorph Systems. All rights reserved.
//
#import "Rules.h"
@implementation DefaultSettingRule
-(struct DrawingParameters) adjustParameters:(struct DrawingParameters)par{
// The default rule does nothing to the initial setting.
NSLog(@"Default rule: not changing any parameters");
return par;
}
-(bool) canMakeFurtherAdjustment:(struct DrawingParameters)par {
// This can only be tried once, so no further adjustment is made.
return NO;
}
@end
@implementation ReduceFontSizeRule
-(ReduceFontSizeRule*) init:(int)minSize:(int)interval{
self = [super init];
if (self) {
MinFontSize = minSize;
FontReductionInterval = interval;
}
return self;
}
-(struct DrawingParameters) adjustParameters:(struct DrawingParameters)par{
int currentFont = par.FontSize;
if (currentFont < MinFontSize) {
NSLog(@"Got font size that is smaller than min font size. Initial definition is invalid");
return par;
}
int newFont = currentFont - FontReductionInterval;
if (newFont < MinFontSize) {
newFont = MinFontSize;
}
par.FontSize = newFont;
NSLog(@"Font reduction: Reducing from %i to %i", currentFont, newFont);
return par;
}
-(bool) canMakeFurtherAdjustment:(struct DrawingParameters)par {
return par.FontSize > MinFontSize;
}
@end