-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
BMGlyph.cs
88 lines (75 loc) · 1.26 KB
/
BMGlyph.cs
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
using System;
using System.Collections.Generic;
[Serializable]
public class BMGlyph
{
public int index;
public int x;
public int y;
public int width;
public int height;
public int offsetX;
public int offsetY;
public int advance;
public int channel;
public List<int> kerning;
public int GetKerning(int previousChar)
{
if (kerning != null && previousChar != 0)
{
int i = 0;
for (int count = kerning.Count; i < count; i += 2)
{
if (kerning[i] == previousChar)
{
return kerning[i + 1];
}
}
}
return 0;
}
public void SetKerning(int previousChar, int amount)
{
if (kerning == null)
{
kerning = new List<int>();
}
for (int i = 0; i < kerning.Count; i += 2)
{
if (kerning[i] == previousChar)
{
kerning[i + 1] = amount;
return;
}
}
kerning.Add(previousChar);
kerning.Add(amount);
}
public void Trim(int xMin, int yMin, int xMax, int yMax)
{
int num = x + width;
int num2 = y + height;
if (x < xMin)
{
int num3 = xMin - x;
x += num3;
width -= num3;
offsetX += num3;
}
if (y < yMin)
{
int num4 = yMin - y;
y += num4;
height -= num4;
offsetY += num4;
}
if (num > xMax)
{
width -= num - xMax;
}
if (num2 > yMax)
{
height -= num2 - yMax;
}
}
}