summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt1
-rw-r--r--res/fonts/LICENSE_NanumGothic.txt96
-rw-r--r--res/fonts/NanumGothic-Regular.ttfbin0 -> 4091796 bytes
-rw-r--r--src/ui/text.c45
-rw-r--r--src/ui/text.h9
5 files changed, 144 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9bdb8de4..9e105f02 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -71,6 +71,7 @@ set (EMBED_RESOURCES
71 res/fonts/Literata-Bold-opsz=36.ttf 71 res/fonts/Literata-Bold-opsz=36.ttf
72 res/fonts/Literata-ExtraLight-opsz=18.ttf 72 res/fonts/Literata-ExtraLight-opsz=18.ttf
73 res/fonts/Literata-LightItalic-opsz=10.ttf 73 res/fonts/Literata-LightItalic-opsz=10.ttf
74 res/fonts/NanumGothic-Regular.ttf
74 res/fonts/NotoEmoji-Regular.ttf 75 res/fonts/NotoEmoji-Regular.ttf
75 res/fonts/Nunito-ExtraBold.ttf 76 res/fonts/Nunito-ExtraBold.ttf
76 res/fonts/Nunito-ExtraLight.ttf 77 res/fonts/Nunito-ExtraLight.ttf
diff --git a/res/fonts/LICENSE_NanumGothic.txt b/res/fonts/LICENSE_NanumGothic.txt
new file mode 100644
index 00000000..69ff4015
--- /dev/null
+++ b/res/fonts/LICENSE_NanumGothic.txt
@@ -0,0 +1,96 @@
1Copyright (c) 2010, NHN Corporation (http://www.nhncorp.com),
2with Reserved Font Name Nanum, Naver Nanum, NanumGothic, Naver
3NanumGothic, NanumMyeongjo, Naver NanumMyeongjo, NanumBrush, Naver
4NanumBrush, NanumPen, Naver NanumPen.
5
6This Font Software is licensed under the SIL Open Font License, Version 1.1.
7This license is copied below, and is also available with a FAQ at:
8http://scripts.sil.org/OFL
9
10
11-----------------------------------------------------------
12SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
13-----------------------------------------------------------
14
15PREAMBLE
16The goals of the Open Font License (OFL) are to stimulate worldwide
17development of collaborative font projects, to support the font creation
18efforts of academic and linguistic communities, and to provide a free and
19open framework in which fonts may be shared and improved in partnership
20with others.
21
22The OFL allows the licensed fonts to be used, studied, modified and
23redistributed freely as long as they are not sold by themselves. The
24fonts, including any derivative works, can be bundled, embedded,
25redistributed and/or sold with any software provided that any reserved
26names are not used by derivative works. The fonts and derivatives,
27however, cannot be released under any other type of license. The
28requirement for fonts to remain under this license does not apply
29to any document created using the fonts or their derivatives.
30
31DEFINITIONS
32"Font Software" refers to the set of files released by the Copyright
33Holder(s) under this license and clearly marked as such. This may
34include source files, build scripts and documentation.
35
36"Reserved Font Name" refers to any names specified as such after the
37copyright statement(s).
38
39"Original Version" refers to the collection of Font Software components as
40distributed by the Copyright Holder(s).
41
42"Modified Version" refers to any derivative made by adding to, deleting,
43or substituting -- in part or in whole -- any of the components of the
44Original Version, by changing formats or by porting the Font Software to a
45new environment.
46
47"Author" refers to any designer, engineer, programmer, technical
48writer or other person who contributed to the Font Software.
49
50PERMISSION & CONDITIONS
51Permission is hereby granted, free of charge, to any person obtaining
52a copy of the Font Software, to use, study, copy, merge, embed, modify,
53redistribute, and sell modified and unmodified copies of the Font
54Software, subject to the following conditions:
55
561) Neither the Font Software nor any of its individual components,
57in Original or Modified Versions, may be sold by itself.
58
592) Original or Modified Versions of the Font Software may be bundled,
60redistributed and/or sold with any software, provided that each copy
61contains the above copyright notice and this license. These can be
62included either as stand-alone text files, human-readable headers or
63in the appropriate machine-readable metadata fields within text or
64binary files as long as those fields can be easily viewed by the user.
65
663) No Modified Version of the Font Software may use the Reserved Font
67Name(s) unless explicit written permission is granted by the corresponding
68Copyright Holder. This restriction only applies to the primary font name as
69presented to the users.
70
714) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
72Software shall not be used to promote, endorse or advertise any
73Modified Version, except to acknowledge the contribution(s) of the
74Copyright Holder(s) and the Author(s) or with their explicit written
75permission.
76
775) The Font Software, modified or unmodified, in part or in whole,
78must be distributed entirely under this license, and must not be
79distributed under any other license. The requirement for fonts to
80remain under this license does not apply to any document created
81using the Font Software.
82
83TERMINATION
84This license becomes null and void if any of the above conditions are
85not met.
86
87DISCLAIMER
88THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
89EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
90MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
91OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
92COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
93INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
94DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
95FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
96OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/res/fonts/NanumGothic-Regular.ttf b/res/fonts/NanumGothic-Regular.ttf
new file mode 100644
index 00000000..6e4dd874
--- /dev/null
+++ b/res/fonts/NanumGothic-Regular.ttf
Binary files differ
diff --git a/src/ui/text.c b/src/ui/text.c
index 08c89e47..7f784dec 100644
--- a/src/ui/text.c
+++ b/src/ui/text.c
@@ -80,9 +80,9 @@ iChar char_Glyph(const iGlyph *d) {
80 80
81iDefineTypeConstructionArgs(Glyph, (iChar ch), ch) 81iDefineTypeConstructionArgs(Glyph, (iChar ch), ch)
82 82
83/*-----------------------------------------------------------------------------------------------*/ 83 /*-----------------------------------------------------------------------------------------------*/
84 84
85struct Impl_Font { 85 struct Impl_Font {
86 iBlock * data; 86 iBlock * data;
87 stbtt_fontinfo font; 87 stbtt_fontinfo font;
88 float scale; 88 float scale;
@@ -92,8 +92,9 @@ struct Impl_Font {
92 iHash glyphs; 92 iHash glyphs;
93 iBool isMonospaced; 93 iBool isMonospaced;
94 iBool manualKernOnly; 94 iBool manualKernOnly;
95 enum iFontId symbolsFont; /* font to use for symbols */ 95 enum iFontId symbolsFont; /* font to use for symbols */
96 enum iFontId japaneseFont; /* font to use for Japanese glyphs */ 96 enum iFontId japaneseFont; /* font to use for Japanese glyphs */
97 enum iFontId koreanFont; /* font to use for Korean glyphs */
97 uint32_t indexTable[128 - 32]; 98 uint32_t indexTable[128 - 32];
98}; 99};
99 100
@@ -109,9 +110,10 @@ static void init_Font(iFont *d, const iBlock *data, int height, float scale, enu
109 d->vertOffset = height * (1.0f - scale) / 2; 110 d->vertOffset = height * (1.0f - scale) / 2;
110 int ascent; 111 int ascent;
111 stbtt_GetFontVMetrics(&d->font, &ascent, NULL, NULL); 112 stbtt_GetFontVMetrics(&d->font, &ascent, NULL, NULL);
112 d->baseline = (int) ascent * d->scale; 113 d->baseline = (int) ascent * d->scale;
113 d->symbolsFont = symbolsFont; 114 d->symbolsFont = symbolsFont;
114 d->japaneseFont = regularJapanese_FontId; 115 d->japaneseFont = regularJapanese_FontId;
116 d->koreanFont = regularKorean_FontId;
115 d->isMonospaced = iFalse; 117 d->isMonospaced = iFalse;
116 memset(d->indexTable, 0xff, sizeof(d->indexTable)); 118 memset(d->indexTable, 0xff, sizeof(d->indexTable));
117} 119}
@@ -247,6 +249,15 @@ static void initFonts_Text_(iText *d) {
247 { &fontKosugiMaruRegular_Embedded, textSize * 1.333f, 1.0f, bigSymbols_FontId }, 249 { &fontKosugiMaruRegular_Embedded, textSize * 1.333f, 1.0f, bigSymbols_FontId },
248 { &fontKosugiMaruRegular_Embedded, textSize * 1.666f, 1.0f, largeSymbols_FontId }, 250 { &fontKosugiMaruRegular_Embedded, textSize * 1.666f, 1.0f, largeSymbols_FontId },
249 { &fontKosugiMaruRegular_Embedded, textSize * 2.000f, 1.0f, hugeSymbols_FontId }, 251 { &fontKosugiMaruRegular_Embedded, textSize * 2.000f, 1.0f, hugeSymbols_FontId },
252 /* korean fonts */
253 { &fontNanumGothicRegular_Embedded, fontSize_UI, 1.0f, defaultSymbols_FontId },
254 { &fontNanumGothicRegular_Embedded, monoSize * 0.750, 1.0f, monospaceSmallSymbols_FontId },
255 { &fontNanumGothicRegular_Embedded, monoSize, 1.0f, monospaceSymbols_FontId },
256 { &fontNanumGothicRegular_Embedded, textSize, 1.0f, symbols_FontId },
257 { &fontNanumGothicRegular_Embedded, textSize * 1.200f, 1.0f, mediumSymbols_FontId },
258 { &fontNanumGothicRegular_Embedded, textSize * 1.333f, 1.0f, bigSymbols_FontId },
259 { &fontNanumGothicRegular_Embedded, textSize * 1.666f, 1.0f, largeSymbols_FontId },
260 { &fontNanumGothicRegular_Embedded, textSize * 2.000f, 1.0f, hugeSymbols_FontId },
250 }; 261 };
251 iForIndices(i, fontData) { 262 iForIndices(i, fontData) {
252 iFont *font = &d->fonts[i]; 263 iFont *font = &d->fonts[i];
@@ -262,7 +273,6 @@ static void initFonts_Text_(iText *d) {
262 /* Japanese script. */ { 273 /* Japanese script. */ {
263 /* Everything defaults to the regular sized japanese font, so these are just 274 /* Everything defaults to the regular sized japanese font, so these are just
264 the other sizes. */ 275 the other sizes. */
265 /* TODO: Add these to the table above... */
266 font_Text_(default_FontId)->japaneseFont = defaultJapanese_FontId; 276 font_Text_(default_FontId)->japaneseFont = defaultJapanese_FontId;
267 font_Text_(defaultMedium_FontId)->japaneseFont = defaultJapanese_FontId; 277 font_Text_(defaultMedium_FontId)->japaneseFont = defaultJapanese_FontId;
268 font_Text_(defaultMonospace_FontId)->japaneseFont = defaultJapanese_FontId; 278 font_Text_(defaultMonospace_FontId)->japaneseFont = defaultJapanese_FontId;
@@ -270,11 +280,22 @@ static void initFonts_Text_(iText *d) {
270 font_Text_(monospace_FontId)->japaneseFont = monospaceJapanese_FontId; 280 font_Text_(monospace_FontId)->japaneseFont = monospaceJapanese_FontId;
271 font_Text_(medium_FontId)->japaneseFont = mediumJapanese_FontId; 281 font_Text_(medium_FontId)->japaneseFont = mediumJapanese_FontId;
272 font_Text_(big_FontId)->japaneseFont = bigJapanese_FontId; 282 font_Text_(big_FontId)->japaneseFont = bigJapanese_FontId;
273// font_Text_(bigBold_FontId)->japaneseFont = bigJapanese_FontId;
274 font_Text_(largeBold_FontId)->japaneseFont = largeJapanese_FontId; 283 font_Text_(largeBold_FontId)->japaneseFont = largeJapanese_FontId;
275 font_Text_(largeLight_FontId)->japaneseFont = largeJapanese_FontId; 284 font_Text_(largeLight_FontId)->japaneseFont = largeJapanese_FontId;
276 font_Text_(hugeBold_FontId)->japaneseFont = hugeJapanese_FontId; 285 font_Text_(hugeBold_FontId)->japaneseFont = hugeJapanese_FontId;
277 } 286 }
287 /* Korean script. */ {
288 font_Text_(default_FontId)->koreanFont = defaultKorean_FontId;
289 font_Text_(defaultMedium_FontId)->koreanFont = defaultKorean_FontId;
290 font_Text_(defaultMonospace_FontId)->koreanFont = defaultKorean_FontId;
291 font_Text_(monospaceSmall_FontId)->koreanFont = monospaceSmallKorean_FontId;
292 font_Text_(monospace_FontId)->koreanFont = monospaceKorean_FontId;
293 font_Text_(medium_FontId)->koreanFont = mediumKorean_FontId;
294 font_Text_(big_FontId)->koreanFont = bigKorean_FontId;
295 font_Text_(largeBold_FontId)->koreanFont = largeKorean_FontId;
296 font_Text_(largeLight_FontId)->koreanFont = largeKorean_FontId;
297 font_Text_(hugeBold_FontId)->koreanFont = hugeKorean_FontId;
298 }
278 gap_Text = iRound(gap_UI * d->contentFontSize); 299 gap_Text = iRound(gap_UI * d->contentFontSize);
279} 300}
280 301
@@ -491,6 +512,13 @@ iLocalDef iFont *characterFont_Font_(iFont *d, iChar ch, uint32_t *glyphIndex) {
491 return emoji; 512 return emoji;
492 } 513 }
493 } 514 }
515 /* Could be Korean. */
516 if (ch > 0x3000) {
517 iFont *korean = font_Text_(d->koreanFont);
518 if (korean != d && (*glyphIndex = glyphIndex_Font_(korean, ch)) != 0) {
519 return korean;
520 }
521 }
494 /* Japanese perhaps? */ 522 /* Japanese perhaps? */
495 if (ch > 0x3040) { 523 if (ch > 0x3040) {
496 iFont *japanese = font_Text_(d->japaneseFont); 524 iFont *japanese = font_Text_(d->japaneseFont);
@@ -501,6 +529,9 @@ iLocalDef iFont *characterFont_Font_(iFont *d, iChar ch, uint32_t *glyphIndex) {
501 /* Fall back to Symbola for anything else. */ 529 /* Fall back to Symbola for anything else. */
502 iFont *font = font_Text_(d->symbolsFont); 530 iFont *font = font_Text_(d->symbolsFont);
503 *glyphIndex = glyphIndex_Font_(font, ch); 531 *glyphIndex = glyphIndex_Font_(font, ch);
532 if (!*glyphIndex) {
533 fprintf(stderr, "failed to find %08x (%lc)\n", ch, ch); fflush(stderr);
534 }
504 return font; 535 return font;
505} 536}
506 537
diff --git a/src/ui/text.h b/src/ui/text.h
index 87f69300..35f48528 100644
--- a/src/ui/text.h
+++ b/src/ui/text.h
@@ -72,6 +72,15 @@ enum iFontId {
72 bigJapanese_FontId, 72 bigJapanese_FontId,
73 largeJapanese_FontId, 73 largeJapanese_FontId,
74 hugeJapanese_FontId, 74 hugeJapanese_FontId,
75 /* korean script */
76 defaultKorean_FontId,
77 monospaceSmallKorean_FontId,
78 monospaceKorean_FontId,
79 regularKorean_FontId,
80 mediumKorean_FontId,
81 bigKorean_FontId,
82 largeKorean_FontId,
83 hugeKorean_FontId,
75 max_FontId, 84 max_FontId,
76 85
77 /* Meta: */ 86 /* Meta: */