forked from Guad/NativeUI
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringMeasurer.cs
More file actions
Latest commit
121 lines (119 loc) · 2.83 KB
/
Copy pathStringMeasurer.cs
File metadata and controls
121 lines (119 loc) · 2.83 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
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
usingSystem.Collections.Generic;
namespaceNativeUI
{
publicstaticclassStringMeasurer
{
privatestaticreadonlyDictionary<char,int>CharMap=newDictionary<char,int>
{
{' ',6},
{'!',6},
{'"',6},
{'#',11},
{'$',10},
{'%',17},
{'&',13},
{'\'',4},
{'(',6},// ?
{')',6},// ?
{'*',7},// ?
{'+',10},
{',',4},
{'-',6},
{'.',4},
{'/',7},
{'0',12},
{'1',7},
{'2',11},
{'3',11},
{'4',11},
{'5',11},
{'6',12},
{'7',10},// ?
{'8',11},
{'9',11},
{':',5},
{';',4},
{'<',9},
{'=',9},
{'>',9},
{'?',10},
{'@',15},
{'A',12},
{'B',13},// 12?
{'C',14},
{'D',14},
{'E',12},
{'F',12},
{'G',15},
{'H',14},
{'I',5},
{'J',11},
{'K',13},
{'L',11},
{'M',16},
{'N',14},
{'O',16},
{'P',12},
{'Q',15},
{'R',13},
{'S',12},
{'T',11},
{'U',13},
{'V',12},
{'W',18},
{'X',11},
{'Y',11},
{'Z',12},
{'[',6},
{'\\',7},
{']',6},// 5?
{'^',9},
{'_',18},
{'`',8},
{'a',11},
{'b',12},
{'c',11},
{'d',12},
{'e',12},
{'f',5},// 6? 7?
{'g',13},
{'h',11},
{'i',4},
{'j',4},// 5?
{'k',10},
{'l',4},
{'m',18},
{'n',11},
{'o',12},
{'p',12},
{'q',12},
{'r',7},
{'s',9},// ?
{'t',5},
{'u',11},
{'v',10},
{'w',14},
{'x',9},// ?
{'y',10},
{'z',9},
{'{',6},
{'|',3},
{'}',6},
};
/// <summary>
/// Measures width of a 0.35 scale string.
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
publicstaticintMeasureString(stringinput)
{
intoutput=0;
for(inti=0;i<input.Length;i++)
{
if(!CharMap.ContainsKey(input[i]))continue;
output+=CharMap[input[i]]+1;
}
returnoutput;
}
}
}