author | KUDr |
Thu, 30 Nov 2006 17:12:10 +0000 | |
changeset 5189 | c3f55e80901c |
parent 5154 | 80955f08ffc7 |
child 5218 | aae5f36a5256 |
permissions | -rw-r--r-- |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
1 |
/* $Id$ */ |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
2 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
3 |
#include "stdafx.h" |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
4 |
#include "openttd.h" |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
5 |
#include "functions.h" |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
6 |
#include "macros.h" |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
7 |
#include "debug.h" |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
8 |
#include "table/sprites.h" |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
9 |
#include "table/control_codes.h" |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
10 |
#include "spritecache.h" |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
11 |
#include "gfx.h" |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
12 |
#include "string.h" |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
13 |
#include "fontcache.h" |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
14 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
15 |
#ifdef WITH_FREETYPE |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
16 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
17 |
#include <ft2build.h> |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
18 |
#include FT_FREETYPE_H |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
19 |
#include FT_GLYPH_H |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
20 |
|
5117
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
21 |
#ifdef WITH_FONTCONFIG |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
22 |
#include <fontconfig/fontconfig.h> |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
23 |
#endif |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
24 |
|
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
25 |
static FT_Library _library = NULL; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
26 |
static FT_Face _face_small = NULL; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
27 |
static FT_Face _face_medium = NULL; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
28 |
static FT_Face _face_large = NULL; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
29 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
30 |
FreeTypeSettings _freetype; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
31 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
32 |
enum { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
33 |
FACE_COLOUR = 1, |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
34 |
SHADOW_COLOUR = 2, |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
35 |
}; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
36 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
37 |
|
5117
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
38 |
/** |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
39 |
* Loads the freetype font. |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
40 |
* First type to load the fontname as if it were a path. If that fails, |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
41 |
* try to resolve the filename of the font using fontconfig, where the |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
42 |
* format is 'font family name' or 'font family name, font style'. |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
43 |
*/ |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
44 |
static void LoadFreeTypeFont(const char *font_name, FT_Face *face, const char *type) |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
45 |
{ |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
46 |
FT_Error error; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
47 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
48 |
if (strlen(font_name) == 0) return; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
49 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
50 |
error = FT_New_Face(_library, font_name, 0, face); |
5117
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
51 |
#ifdef WITH_FONTCONFIG |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
52 |
/* Failed to load the font, so try it with fontconfig */ |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
53 |
if (error != FT_Err_Ok) { |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
54 |
if (!FcInit()) { |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
55 |
ShowInfoF("Unable to load font configuration"); |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
56 |
} else { |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
57 |
FcPattern *match; |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
58 |
FcPattern *pat; |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
59 |
FcFontSet *fs; |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
60 |
FcResult result; |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
61 |
char *font_style; |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
62 |
char *font_family; |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
63 |
|
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
64 |
/* Split & strip the font's style */ |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
65 |
font_family = strdup(font_name); |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
66 |
font_style = strchr(font_family, ','); |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
67 |
if (font_style != NULL) { |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
68 |
font_style[0] = '\0'; |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
69 |
font_style++; |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
70 |
while (*font_style == ' ' || *font_style == '\t') font_style++; |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
71 |
} |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
72 |
|
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
73 |
/* Resolve the name and populate the information structure */ |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
74 |
pat = FcNameParse((FcChar8*)font_family); |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
75 |
if (font_style != NULL) FcPatternAddString(pat, FC_STYLE, (FcChar8*)font_style); |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
76 |
FcConfigSubstitute(0, pat, FcMatchPattern); |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
77 |
FcDefaultSubstitute(pat); |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
78 |
fs = FcFontSetCreate(); |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
79 |
match = FcFontMatch(0, pat, &result); |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
80 |
|
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
81 |
if (fs != NULL && match != NULL) { |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
82 |
int i; |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
83 |
FcChar8 *family; |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
84 |
FcChar8 *style; |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
85 |
FcChar8 *file; |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
86 |
FcFontSetAdd(fs, match); |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
87 |
|
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
88 |
for (i = 0; error != FT_Err_Ok && i < fs->nfont; i++) { |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
89 |
/* Try the new filename */ |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
90 |
if (FcPatternGetString(fs->fonts[i], FC_FILE, 0, &file) == FcResultMatch && |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
91 |
FcPatternGetString(fs->fonts[i], FC_FAMILY, 0, &family) == FcResultMatch && |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
92 |
FcPatternGetString(fs->fonts[i], FC_STYLE, 0, &style) == FcResultMatch) { |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
93 |
|
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
94 |
/* The correct style? */ |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
95 |
if (font_style != NULL && strcasecmp(font_style, (char*)style) != 0) continue; |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
96 |
|
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
97 |
/* Font config takes the best shot, which, if the family name is spelled |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
98 |
* wrongly a 'random' font, so check whether the family name is the |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
99 |
* same as the supplied name */ |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
100 |
if (strcasecmp(font_family, (char*)family) == 0) { |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
101 |
error = FT_New_Face(_library, (char *)file, 0, face); |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
102 |
} |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
103 |
} |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
104 |
} |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
105 |
} |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
106 |
|
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
107 |
free(font_family); |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
108 |
FcPatternDestroy(pat); |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
109 |
FcFontSetDestroy(fs); |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
110 |
FcFini(); |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
111 |
} |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
112 |
} |
a4a7fd847b77
(svn r7196) -Feature: use fontconfig so one can set the font family name in openttd.cfg instead of the full path to the font.
rubidium
parents:
5108
diff
changeset
|
113 |
#endif |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
114 |
if (error == FT_Err_Ok) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
115 |
/* Attempt to select the unicode character map */ |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
116 |
error = FT_Select_Charmap(*face, ft_encoding_unicode); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
117 |
if (error == FT_Err_Ok) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
118 |
/* Success */ |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
119 |
return; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
120 |
} else if (error == FT_Err_Invalid_CharMap_Handle) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
121 |
/* Try to pick a different character map instead. We default to |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
122 |
* the first map, but platform_id 0 encoding_id 0 should also |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
123 |
* be unicode (strange system...) */ |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
124 |
FT_CharMap found = (*face)->charmaps[0]; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
125 |
int i; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
126 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
127 |
for (i = 0; i < (*face)->num_charmaps; i++) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
128 |
FT_CharMap charmap = (*face)->charmaps[i]; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
129 |
if (charmap->platform_id == 0 && charmap->encoding_id == 0) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
130 |
found = charmap; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
131 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
132 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
133 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
134 |
if (found != NULL) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
135 |
error = FT_Set_Charmap(*face, found); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
136 |
if (error == FT_Err_Ok) return; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
137 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
138 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
139 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
140 |
FT_Done_Face(*face); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
141 |
*face = NULL; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
142 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
143 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
144 |
ShowInfoF("Unable to use '%s' for %s font, FreeType reported error 0x%X, using sprite font instead", font_name, type, error); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
145 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
146 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
147 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
148 |
void InitFreeType(void) |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
149 |
{ |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
150 |
if (strlen(_freetype.small_font) == 0 && strlen(_freetype.medium_font) == 0 && strlen(_freetype.large_font) == 0) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
151 |
DEBUG(freetype, 1) ("[FreeType] No font faces specified, using sprite fonts instead"); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
152 |
return; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
153 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
154 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
155 |
if (FT_Init_FreeType(&_library) != FT_Err_Ok) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
156 |
ShowInfoF("Unable to initialize FreeType, using sprite fonts instead"); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
157 |
return; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
158 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
159 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
160 |
DEBUG(freetype, 2) ("[FreeType] Initialized"); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
161 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
162 |
/* Load each font */ |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
163 |
LoadFreeTypeFont(_freetype.small_font, &_face_small, "small"); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
164 |
LoadFreeTypeFont(_freetype.medium_font, &_face_medium, "medium"); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
165 |
LoadFreeTypeFont(_freetype.large_font, &_face_large, "large"); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
166 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
167 |
/* Set each font size */ |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
168 |
if (_face_small != NULL) FT_Set_Pixel_Sizes(_face_small, 0, _freetype.small_size); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
169 |
if (_face_medium != NULL) FT_Set_Pixel_Sizes(_face_medium, 0, _freetype.medium_size); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
170 |
if (_face_large != NULL) FT_Set_Pixel_Sizes(_face_large, 0, _freetype.large_size); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
171 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
172 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
173 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
174 |
static FT_Face GetFontFace(FontSize size) |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
175 |
{ |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
176 |
switch (size) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
177 |
default: NOT_REACHED(); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
178 |
case FS_NORMAL: return _face_medium; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
179 |
case FS_SMALL: return _face_small; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
180 |
case FS_LARGE: return _face_large; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
181 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
182 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
183 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
184 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
185 |
typedef struct GlyphEntry { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
186 |
Sprite *sprite; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
187 |
byte width; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
188 |
} GlyphEntry; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
189 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
190 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
191 |
/* The glyph cache. This is structured to reduce memory consumption. |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
192 |
* 1) There is a 'segment' table for each font size. |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
193 |
* 2) Each segment table is a discrete block of characters. |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
194 |
* 3) Each block contains 256 (aligned) characters sequential characters. |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
195 |
* |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
196 |
* The cache is accessed in the following way: |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
197 |
* For character 0x0041 ('A'): _glyph_ptr[FS_NORMAL][0x00][0x41] |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
198 |
* For character 0x20AC (Euro): _glyph_ptr[FS_NORMAL][0x20][0xAC] |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
199 |
* |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
200 |
* Currently only 256 segments are allocated, "limiting" us to 65536 characters. |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
201 |
* This can be simply changed in the two functions Get & SetGlyphPtr. |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
202 |
*/ |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
203 |
static GlyphEntry **_glyph_ptr[FS_END]; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
204 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
205 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
206 |
static GlyphEntry *GetGlyphPtr(FontSize size, WChar key) |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
207 |
{ |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
208 |
if (_glyph_ptr[size] == NULL) return NULL; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
209 |
if (_glyph_ptr[size][GB(key, 8, 8)] == NULL) return NULL; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
210 |
return &_glyph_ptr[size][GB(key, 8, 8)][GB(key, 0, 8)]; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
211 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
212 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
213 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
214 |
static void SetGlyphPtr(FontSize size, WChar key, const GlyphEntry *glyph) |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
215 |
{ |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
216 |
if (_glyph_ptr[size] == NULL) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
217 |
DEBUG(freetype, 3) ("[FreeType] Allocating root glyph cache for size %u", size); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
218 |
_glyph_ptr[size] = calloc(256, sizeof(**_glyph_ptr)); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
219 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
220 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
221 |
if (_glyph_ptr[size][GB(key, 8, 8)] == NULL) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
222 |
DEBUG(freetype, 3) ("[FreeType] Allocating glyph cache for range 0x%02X00, size %u", GB(key, 8, 8), size); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
223 |
_glyph_ptr[size][GB(key, 8, 8)] = calloc(256, sizeof(***_glyph_ptr)); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
224 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
225 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
226 |
DEBUG(freetype, 4) ("[FreeType] Set glyph for unicode character 0x%04X, size %u", key, size); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
227 |
_glyph_ptr[size][GB(key, 8, 8)][GB(key, 0, 8)].sprite = glyph->sprite; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
228 |
_glyph_ptr[size][GB(key, 8, 8)][GB(key, 0, 8)].width = glyph->width; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
229 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
230 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
231 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
232 |
const Sprite *GetGlyph(FontSize size, WChar key) |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
233 |
{ |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
234 |
FT_Face face = GetFontFace(size); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
235 |
FT_GlyphSlot slot; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
236 |
GlyphEntry new_glyph; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
237 |
GlyphEntry *glyph; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
238 |
Sprite *sprite; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
239 |
int width; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
240 |
int height; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
241 |
int x; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
242 |
int y; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
243 |
int y_adj; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
244 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
245 |
assert(IsPrintable(key)); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
246 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
247 |
/* Bail out if no face loaded, or for our special characters */ |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
248 |
if (face == NULL || (key >= SCC_SPRITE_START && key <= SCC_SPRITE_END)) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
249 |
SpriteID sprite = GetUnicodeGlyph(size, key); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
250 |
if (sprite == 0) sprite = GetUnicodeGlyph(size, '?'); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
251 |
return GetSprite(sprite); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
252 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
253 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
254 |
/* Check for the glyph in our cache */ |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
255 |
glyph = GetGlyphPtr(size, key); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
256 |
if (glyph != NULL && glyph->sprite != NULL) return glyph->sprite; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
257 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
258 |
slot = face->glyph; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
259 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
260 |
FT_Load_Char(face, key, FT_LOAD_DEFAULT); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
261 |
FT_Render_Glyph(face->glyph, FT_RENDER_MODE_MONO); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
262 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
263 |
/* Add 1 pixel for the shadow on the medium font. Our sprite must be at least 1x1 pixel */ |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
264 |
width = max(1, slot->bitmap.width + (size == FS_NORMAL)); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
265 |
height = max(1, slot->bitmap.rows + (size == FS_NORMAL)); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
266 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
267 |
/* FreeType has rendered the glyph, now we allocate a sprite and copy the image into it */ |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
268 |
sprite = calloc(width * height + 8, 1); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
269 |
sprite->info = 1; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
270 |
sprite->width = width; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
271 |
sprite->height = height; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
272 |
sprite->x_offs = slot->bitmap_left; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
273 |
// XXX 2 should be determined somehow... it's right for the normal face |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
274 |
y_adj = (size == FS_NORMAL) ? 2 : 0; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
275 |
sprite->y_offs = GetCharacterHeight(size) - slot->bitmap_top - y_adj; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
276 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
277 |
/* Draw shadow for medium size */ |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
278 |
if (size == FS_NORMAL) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
279 |
for (y = 0; y < slot->bitmap.rows; y++) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
280 |
for (x = 0; x < slot->bitmap.width; x++) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
281 |
if (HASBIT(slot->bitmap.buffer[(x / 8) + y * slot->bitmap.pitch], 7 - (x % 8))) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
282 |
sprite->data[1 + x + (1 + y) * sprite->width] = SHADOW_COLOUR; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
283 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
284 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
285 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
286 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
287 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
288 |
for (y = 0; y < slot->bitmap.rows; y++) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
289 |
for (x = 0; x < slot->bitmap.width; x++) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
290 |
if (HASBIT(slot->bitmap.buffer[(x / 8) + y * slot->bitmap.pitch], 7 - (x % 8))) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
291 |
sprite->data[x + y * sprite->width] = FACE_COLOUR; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
292 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
293 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
294 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
295 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
296 |
new_glyph.sprite = sprite; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
297 |
new_glyph.width = (slot->advance.x >> 6) + (size != FS_NORMAL); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
298 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
299 |
SetGlyphPtr(size, key, &new_glyph); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
300 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
301 |
return sprite; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
302 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
303 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
304 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
305 |
uint GetGlyphWidth(FontSize size, WChar key) |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
306 |
{ |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
307 |
FT_Face face = GetFontFace(size); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
308 |
GlyphEntry *glyph; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
309 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
310 |
if (face == NULL || (key >= SCC_SPRITE_START && key <= SCC_SPRITE_END)) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
311 |
SpriteID sprite = GetUnicodeGlyph(size, key); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
312 |
if (sprite == 0) sprite = GetUnicodeGlyph(size, '?'); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
313 |
return SpriteExists(sprite) ? GetSprite(sprite)->width + (size != FS_NORMAL) : 0; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
314 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
315 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
316 |
glyph = GetGlyphPtr(size, key); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
317 |
if (glyph == NULL || glyph->sprite == NULL) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
318 |
GetGlyph(size, key); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
319 |
glyph = GetGlyphPtr(size, key); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
320 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
321 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
322 |
return glyph->width; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
323 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
324 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
325 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
326 |
#endif /* WITH_FREETYPE */ |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
327 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
328 |
/* Sprite based glyph mapping */ |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
329 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
330 |
#include "table/unicode.h" |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
331 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
332 |
static SpriteID **_unicode_glyph_map[FS_END]; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
333 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
334 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
335 |
/** Get the SpriteID of the first glyph for the given font size */ |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
336 |
static SpriteID GetFontBase(FontSize size) |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
337 |
{ |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
338 |
switch (size) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
339 |
default: NOT_REACHED(); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
340 |
case FS_NORMAL: return SPR_ASCII_SPACE; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
341 |
case FS_SMALL: return SPR_ASCII_SPACE_SMALL; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
342 |
case FS_LARGE: return SPR_ASCII_SPACE_BIG; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
343 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
344 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
345 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
346 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
347 |
SpriteID GetUnicodeGlyph(FontSize size, uint32 key) |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
348 |
{ |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
349 |
if (_unicode_glyph_map[size][GB(key, 8, 8)] == NULL) return 0; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
350 |
return _unicode_glyph_map[size][GB(key, 8, 8)][GB(key, 0, 8)]; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
351 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
352 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
353 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
354 |
void SetUnicodeGlyph(FontSize size, uint32 key, SpriteID sprite) |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
355 |
{ |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
356 |
if (_unicode_glyph_map[size] == NULL) _unicode_glyph_map[size] = calloc(256, sizeof(*_unicode_glyph_map[size])); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
357 |
if (_unicode_glyph_map[size][GB(key, 8, 8)] == NULL) _unicode_glyph_map[size][GB(key, 8, 8)] = calloc(256, sizeof(**_unicode_glyph_map[size])); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
358 |
_unicode_glyph_map[size][GB(key, 8, 8)][GB(key, 0, 8)] = sprite; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
359 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
360 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
361 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
362 |
void InitializeUnicodeGlyphMap(void) |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
363 |
{ |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
364 |
FontSize size; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
365 |
SpriteID base; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
366 |
SpriteID sprite; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
367 |
uint i; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
368 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
369 |
for (size = FS_NORMAL; size != FS_END; size++) { |
5153
3c82ff1acd6f
(svn r7248) -Codechange: Support reinitializing the unicode glyph map.
peter1138
parents:
5117
diff
changeset
|
370 |
/* Clear out existing glyph map if it exists */ |
3c82ff1acd6f
(svn r7248) -Codechange: Support reinitializing the unicode glyph map.
peter1138
parents:
5117
diff
changeset
|
371 |
if (_unicode_glyph_map[size] != NULL) { |
3c82ff1acd6f
(svn r7248) -Codechange: Support reinitializing the unicode glyph map.
peter1138
parents:
5117
diff
changeset
|
372 |
for (i = 0; i < 256; i++) { |
3c82ff1acd6f
(svn r7248) -Codechange: Support reinitializing the unicode glyph map.
peter1138
parents:
5117
diff
changeset
|
373 |
if (_unicode_glyph_map[size][i] != NULL) free(_unicode_glyph_map[size][i]); |
3c82ff1acd6f
(svn r7248) -Codechange: Support reinitializing the unicode glyph map.
peter1138
parents:
5117
diff
changeset
|
374 |
} |
5154 | 375 |
free(_unicode_glyph_map[size]); |
5153
3c82ff1acd6f
(svn r7248) -Codechange: Support reinitializing the unicode glyph map.
peter1138
parents:
5117
diff
changeset
|
376 |
_unicode_glyph_map[size] = NULL; |
3c82ff1acd6f
(svn r7248) -Codechange: Support reinitializing the unicode glyph map.
peter1138
parents:
5117
diff
changeset
|
377 |
} |
3c82ff1acd6f
(svn r7248) -Codechange: Support reinitializing the unicode glyph map.
peter1138
parents:
5117
diff
changeset
|
378 |
|
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
379 |
base = GetFontBase(size); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
380 |
for (i = ASCII_LETTERSTART; i < 256; i++) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
381 |
sprite = base + i - ASCII_LETTERSTART; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
382 |
if (!SpriteExists(sprite)) continue; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
383 |
SetUnicodeGlyph(size, i, sprite); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
384 |
SetUnicodeGlyph(size, i + SCC_SPRITE_START, sprite); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
385 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
386 |
for (i = 0; i < lengthof(_default_unicode_map); i++) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
387 |
sprite = base + _default_unicode_map[i].key - ASCII_LETTERSTART; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
388 |
SetUnicodeGlyph(size, _default_unicode_map[i].code, sprite); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
389 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
390 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
391 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
diff
changeset
|
392 |