Basic changes to support multiple charsets in the future

master
Eduardo Bart 12 years ago
parent affe641a1f
commit fdea7f3d66

3
.gitignore vendored

@ -24,6 +24,7 @@ CMakeLists.txt.user*
*.log
*.bak
*.swp
*.pic
.lvimrc
.clang_complete
config.otml
@ -33,4 +34,4 @@ config.otml
otclient.map
otclient.layout
LOCALTODO
tags
tags

@ -1,5 +1,6 @@
locale = {
name = "en",
charset = "cp1252",
languageName = "English",
-- translations are not needed because everything is already in english

@ -2,6 +2,7 @@
locale = {
name = "es",
charset = "cp1252",
languageName = "Español",
translation = {

@ -5,6 +5,7 @@
locale = {
name = "pl",
charset = "cp1250",
languageName = "Polski",
translation = {

@ -1,5 +1,6 @@
locale = {
name = "pt",
charset = "cp1252",
languageName = "Português",
-- As traduções devem vir sempre em ordem alfabética.

@ -2,6 +2,7 @@
locale = {
name = "sv",
charset = "cp1252",
languageName = "Svenska",
translation = {

@ -1,8 +1,7 @@
Font
name: terminus-14px-bold
texture: terminus-14px-bold.png
height: 16
y-offset: 2
texture: terminus-14px-bold.png
glyph-size: 16 16
fixed-glyph-width: 8

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

@ -1,8 +1,6 @@
Font
name: verdana-11px-antialised
texture: verdana-11px-antialised.png
texture: verdana-11px-antialised_cp1252.png
height: 14
glyph-size: 16 16
glyph-widths:
32: 4
space-width: 4

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

@ -1,8 +1,6 @@
Font
name: verdana-11px-monochrome
texture: verdana-11px-monochrome.png
texture: verdana-11px-monochrome_cp1252.png
height: 14
glyph-size: 16 16
glyph-widths:
32: 2
space-width: 4

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

@ -1,232 +1,8 @@
Font
name: verdana-11px-rounded
texture: verdana-11px-rounded.png
height: 14
texture: verdana-11px-rounded_cp1252.png
height: 16
glyph-size: 16 16
spacing: -1 0
glyph-widths:
32: 4
33: 4
34: 7
35: 9
36: 8
37: 10
38: 10
39: 4
40: 6
41: 6
42: 8
43: 9
44: 4
45: 7
46: 4
47: 8
48: 8
49: 6
50: 8
51: 8
52: 8
53: 8
54: 8
55: 8
56: 8
57: 8
58: 5
59: 5
60: 10
61: 10
62: 10
63: 7
64: 10
65: 9
66: 8
67: 8
68: 9
69: 8
70: 8
71: 9
72: 9
73: 6
74: 7
75: 8
76: 8
77: 10
78: 9
79: 9
80: 8
81: 9
82: 9
83: 8
84: 10
85: 9
86: 8
87: 10
88: 8
89: 8
90: 8
91: 6
92: 8
93: 6
94: 11
95: 9
96: 7
97: 8
98: 8
99: 7
100: 8
101: 8
102: 7
103: 8
104: 8
105: 4
106: 6
107: 8
108: 4
109: 10
110: 8
111: 8
112: 8
113: 8
114: 7
115: 7
116: 7
117: 8
118: 8
119: 10
120: 8
121: 8
122: 7
123: 8
124: 5
125: 8
126: 9
127: 13
128: 8
129: 13
130: 4
131: 8
132: 6
133: 13
134: 8
135: 8
136: 7
137: 20
138: 8
139: 6
140: 13
141: 13
142: 7
143: 13
144: 13
145: 4
146: 4
147: 6
148: 6
149: 8
150: 8
151: 12
152: 7
153: 11
154: 7
155: 6
156: 13
157: 13
158: 7
159: 9
160: 4
161: 5
162: 8
163: 8
164: 8
165: 8
166: 7
167: 8
168: 7
169: 12
170: 7
171: 9
172: 11
173: 6
174: 12
175: 8
176: 7
177: 11
178: 7
179: 7
180: 7
181: 8
182: 8
183: 5
184: 7
185: 7
186: 7
187: 9
188: 15
189: 15
190: 15
191: 7
192: 10
193: 10
194: 10
195: 10
196: 10
197: 10
198: 13
199: 8
200: 7
201: 7
202: 7
203: 7
204: 5
205: 5
206: 5
207: 5
208: 10
209: 8
210: 9
211: 9
212: 9
213: 9
214: 9
215: 11
216: 9
217: 8
218: 9
219: 8
220: 8
221: 9
222: 9
223: 8
224: 8
225: 8
226: 8
227: 8
228: 8
229: 8
230: 12
231: 6
232: 8
233: 8
234: 8
235: 8
236: 5
237: 5
238: 3
239: 3
240: 8
241: 8
242: 8
243: 8
244: 8
245: 8
246: 8
247: 11
248: 8
249: 8
250: 8
251: 8
252: 8
253: 8
254: 8
255: 8
y-offset: -2
spacing: -1 -3
space-width: 4

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

@ -53,6 +53,7 @@ Application::Application()
m_appName = "application";
m_appCompactName = "app";
m_appVersion = "none";
m_charset = "cp1252";
m_stopping = false;
}

@ -52,6 +52,7 @@ public:
const std::string& getCompactName() { return m_appCompactName; }
const std::string& getVersion() { return m_appVersion; }
std::string getCharset() { return m_charset; }
std::string getBuildCompiler() { return BUILD_COMPILER; }
std::string getBuildDate();
std::string getBuildRevision() { return BUILD_REVISION; }
@ -64,6 +65,7 @@ public:
protected:
void registerLuaFunctions();
std::string m_charset;
std::string m_appName;
std::string m_appCompactName;
std::string m_appVersion;

@ -36,6 +36,7 @@ void BitmapFont::load(const OTMLNodePtr& fontNode)
m_yOffset = fontNode->valueAt("y-offset", 0);
m_firstGlyph = fontNode->valueAt("first-glyph", 32);
m_glyphSpacing = fontNode->valueAt("spacing", Size(0,0));
int spaceWidth = fontNode->valueAt("space-width", glyphSize.width());
// load font texture
m_texture = g_textures.getTexture(textureFile);
@ -47,14 +48,21 @@ void BitmapFont::load(const OTMLNodePtr& fontNode)
calculateGlyphsWidthsAutomatically(Image::load(textureFile), glyphSize);
}
// 32 and 160 are spaces ( )
m_glyphsSize[32].setWidth(spaceWidth);
m_glyphsSize[160].setWidth(spaceWidth);
// new line actually has a size that will be useful in multiline algorithm
m_glyphsSize[(uchar)'\n'] = Size(1, m_glyphHeight);
// read custom widths
/*
if(OTMLNodePtr node = fontNode->get("glyph-widths")) {
for(const OTMLNodePtr& child : node->children())
m_glyphsSize[stdext::safe_cast<int>(child->tag())].setWidth(child->value<int>());
}
*/
// calculate glyphs texture coords
int numHorizontalGlyphs = m_texture->getSize().width() / glyphSize.width();
@ -268,12 +276,8 @@ void BitmapFont::calculateGlyphsWidthsAutomatically(const ImagePtr& image, const
if(texturePixels[(y * image->getSize().width() * 4) + (x*4) + 3] != 0)
filledPixels++;
}
if(filledPixels > 0) {
if(filledPixels > 0)
width = x - glyphCoords.left() + 1;
width += m_glyphSpacing.width();
if(m_glyphHeight >= 16 && filledPixels >= m_glyphHeight/3)
width += 1;
}
}
// store glyph size
m_glyphsSize[glyph].resize(width, m_glyphHeight);

Loading…
Cancel
Save