summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/FontExtensionData.cs
blob: 8978b88bdeac50d979e45376810ff889478ef7a2 (plain)
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
using System;
using System.Collections.Generic;
using UnityEngine;

[CreateAssetMenu]
public class FontExtensionData : ScriptableObject
{
	public string FontName;

	public List<KerningPair> kernings = new List<KerningPair>();

	public List<OffsetAdjustment> Offsets = new List<OffsetAdjustment>();

	public void AdjustKernings(FontData target)
	{
		for (int i = 0; i < this.kernings.Count; i++)
		{
			KerningPair kerningPair = this.kernings[i];
			Dictionary<int, float> dictionary;
			if (target.kernings.TryGetValue((int)kerningPair.First, out dictionary))
			{
				float num;
				if (dictionary.TryGetValue((int)kerningPair.Second, out num))
				{
					dictionary[(int)kerningPair.Second] = num + (float)kerningPair.Pixels;
				}
				else
				{
					dictionary[(int)kerningPair.Second] = (float)kerningPair.Pixels;
				}
			}
			else
			{
				Dictionary<int, float> dictionary2 = new Dictionary<int, float>();
				dictionary2[(int)kerningPair.Second] = (float)kerningPair.Pixels;
				target.kernings[(int)kerningPair.First] = dictionary2;
			}
		}
	}

	public void AdjustOffsets(FontData target)
	{
		for (int i = 0; i < this.Offsets.Count; i++)
		{
			OffsetAdjustment offsetAdjustment = this.Offsets[i];
			int index;
			if (target.charMap.TryGetValue((int)offsetAdjustment.Char, out index))
			{
				Vector3 value = target.offsets[index];
				value.x += (float)offsetAdjustment.OffsetX;
				value.y += (float)offsetAdjustment.OffsetY;
				target.offsets[index] = value;
			}
		}
	}
}