字库破解
This commit is contained in:
parent
4f0caf8199
commit
7d59cdb1e7
6778
charmap.txt
6778
charmap.txt
File diff suppressed because it is too large
Load Diff
BIN
graphics/fonts/chinese_normal.png
Normal file
BIN
graphics/fonts/chinese_normal.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 194 KiB |
BIN
graphics/fonts/chinese_small.png
Normal file
BIN
graphics/fonts/chinese_small.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 203 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 5.5 KiB |
@ -272,6 +272,11 @@ $(FONTGFXDIR)/frlg_male.fwjpnfont: $(FONTGFXDIR)/japanese_frlg_male.png
|
||||
$(FONTGFXDIR)/frlg_female.fwjpnfont: $(FONTGFXDIR)/japanese_frlg_female.png
|
||||
$(GFX) $< $@
|
||||
|
||||
$(FONTGFXDIR)/chinese_small.latfont: $(FONTGFXDIR)/chinese_small.png
|
||||
$(GFX) $< $@
|
||||
|
||||
$(FONTGFXDIR)/chinese_normal.latfont: $(FONTGFXDIR)/chinese_normal.png
|
||||
$(GFX) $< $@
|
||||
|
||||
### Miscellaneous ###
|
||||
|
||||
|
||||
11
include/chinese_text.h
Normal file
11
include/chinese_text.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef CHINESE_TEXT_H
|
||||
#define CHINESE_TEXT_H
|
||||
|
||||
bool8 IsChineseChar(u16 currChar, u16 nextChar, u8 fontId, bool32 isJapanese);
|
||||
void DecompressGlyph_Chinese(u16 ChineseChar, u8 fontId);
|
||||
u8 GetChineseFontWidthFunc(u8 fontId);
|
||||
|
||||
extern const u16 gFontSmallChineseGlyphs[]; //汉字小字体字模
|
||||
extern const u16 gFontNormalChineseGlyphs[]; //汉字大字体字模
|
||||
|
||||
#endif //CHINESE_TEXT_H
|
||||
73
src/chinese_text.c
Normal file
73
src/chinese_text.c
Normal file
@ -0,0 +1,73 @@
|
||||
#include "global.h"
|
||||
#include "text.h"
|
||||
#include "chinese_text.h"
|
||||
|
||||
//检测是否为汉字编码
|
||||
bool8 IsChineseChar(u16 currChar, u16 nextChar, u8 fontId, bool32 isJapanese)
|
||||
{
|
||||
if( isJapanese != TRUE && //排除日文
|
||||
fontId != FONT_BRAILLE && //排除盲文
|
||||
currChar >= 0x01 && currChar <= 0x1E && //检查汉字编码双字节高位是否满足要求
|
||||
currChar != 0x06 && currChar != 0x1B && //检查汉字编码双字节高位是否满足要求
|
||||
nextChar <= 0xF6) //检查汉字编码双字节低位是否满足要求
|
||||
return TRUE;
|
||||
return FALSE; //不符合汉字编码条件
|
||||
}
|
||||
|
||||
//仅在通过IsChineseChar检测后使用
|
||||
void DecompressGlyph_Chinese(u16 ChineseChar, u8 fontId)
|
||||
{
|
||||
const u16 *glyphs;
|
||||
u16 glyphId, hi, lo;
|
||||
|
||||
//汉字编码转换为字模索引编号
|
||||
hi = ChineseChar >> 8;
|
||||
lo = ChineseChar & 0xFF;
|
||||
if (hi > 0x1B)
|
||||
hi -= 0x01;
|
||||
if (hi > 0x06)
|
||||
hi -= 0x01;
|
||||
hi -= 0x01;
|
||||
glyphId = (hi << 8) | lo;
|
||||
|
||||
//根据字体类别选择字体库及宽高数据
|
||||
if (fontId == FONT_SMALL || fontId == FONT_SMALL_NARROW)
|
||||
glyphs = gFontSmallChineseGlyphs + (0x20 * glyphId);
|
||||
else
|
||||
glyphs = gFontNormalChineseGlyphs + (0x20 * glyphId);
|
||||
|
||||
gCurGlyph.width = GetChineseFontWidthFunc(fontId);
|
||||
gCurGlyph.height = gCurGlyph.width + 3;
|
||||
|
||||
//将汉字字模存入内存
|
||||
DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop);
|
||||
DecompressGlyphTile(glyphs + 0x8, gCurGlyph.gfxBufferTop + 8);
|
||||
DecompressGlyphTile(glyphs + 0x10, gCurGlyph.gfxBufferBottom);
|
||||
DecompressGlyphTile(glyphs + 0x18, gCurGlyph.gfxBufferBottom + 8);
|
||||
}
|
||||
|
||||
//仅在通过IsChineseChar检测后使用
|
||||
u8 GetChineseFontWidthFunc(u8 fontId)
|
||||
{
|
||||
//根据字体类别返回字体宽度
|
||||
switch(fontId)
|
||||
{
|
||||
case FONT_SMALL:
|
||||
case FONT_SMALL_NARROW:
|
||||
return 10;
|
||||
case FONT_NORMAL:
|
||||
case FONT_SHORT:
|
||||
case FONT_SHORT_COPY_1:
|
||||
case FONT_SHORT_COPY_2:
|
||||
case FONT_SHORT_COPY_3:
|
||||
case FONT_NARROW:
|
||||
return 12;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//汉字小字字库
|
||||
ALIGNED(4) const u16 gFontSmallChineseGlyphs [] = INCBIN_U16("graphics/fonts/chinese_small.latfont");
|
||||
|
||||
//汉字大字字库
|
||||
ALIGNED(4) const u16 gFontNormalChineseGlyphs [] = INCBIN_U16("graphics/fonts/chinese_normal.latfont");
|
||||
@ -494,22 +494,22 @@ const struct Ability gAbilitiesInfo[ABILITIES_COUNT] =
|
||||
|
||||
[ABILITY_OVERGROW] =
|
||||
{
|
||||
.name = _("Overgrow"),
|
||||
.description = COMPOUND_STRING("Ups Grass moves in a pinch."),
|
||||
.name = _("茂盛"),
|
||||
.description = COMPOUND_STRING("HP低时强化草属性招式"),
|
||||
.aiRating = 5,
|
||||
},
|
||||
|
||||
[ABILITY_BLAZE] =
|
||||
{
|
||||
.name = _("Blaze"),
|
||||
.description = COMPOUND_STRING("Ups Fire moves in a pinch."),
|
||||
.name = _("猛火"),
|
||||
.description = COMPOUND_STRING("HP低时强化火属性招式"),
|
||||
.aiRating = 5,
|
||||
},
|
||||
|
||||
[ABILITY_TORRENT] =
|
||||
{
|
||||
.name = _("Torrent"),
|
||||
.description = COMPOUND_STRING("Ups Water moves in a pinch."),
|
||||
.name = _("激流"),
|
||||
.description = COMPOUND_STRING("HP低时强化水属性招式"),
|
||||
.aiRating = 5,
|
||||
},
|
||||
|
||||
|
||||
@ -149,7 +149,7 @@ ALIGNED(4) const u8 gFontNormalLatinGlyphWidths[] = {
|
||||
3, 6, 6, 6, 6, 6, 6, 6, 6, 6, 3, 6, 6, 6, 6, 6,
|
||||
8, 6, 6, 6, 6, 6, 6, 6, 3, 6, 6, 6, 6, 6, 6, 3,
|
||||
6, 6, 6, 6, 6, 8, 6, 6, 6, 6, 6, 6, 9, 7, 6, 3,
|
||||
3, 3, 3, 3, 10, 8, 3, 3, 7, 3, 3, 3, 3, 3, 3, 3,
|
||||
3, 3, 3, 3, 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 3,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
6, 6, 4, 8, 8, 8, 7, 8, 8, 4, 6, 6, 4, 4, 3, 3,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 6, 3, 3, 3, 3, 3, 3, 6,
|
||||
|
||||
73
src/text.c
73
src/text.c
@ -12,6 +12,7 @@
|
||||
#include "menu.h"
|
||||
#include "dynamic_placeholder_text_util.h"
|
||||
#include "fonts.h"
|
||||
#include "chinese_text.h"
|
||||
|
||||
static u16 RenderText(struct TextPrinter *);
|
||||
static u32 RenderFont(struct TextPrinter *);
|
||||
@ -1236,40 +1237,38 @@ static u16 RenderText(struct TextPrinter *textPrinter)
|
||||
return RENDER_FINISH;
|
||||
}
|
||||
|
||||
switch (subStruct->fontId)
|
||||
if (IsChineseChar(currChar, *textPrinter->printerTemplate.currentChar, subStruct->fontId, textPrinter->japanese))
|
||||
{
|
||||
//合并字节获取汉字双字节编码
|
||||
currChar = (currChar << 8) | *textPrinter->printerTemplate.currentChar;
|
||||
textPrinter->printerTemplate.currentChar++;
|
||||
DecompressGlyph_Chinese(currChar, subStruct->fontId);
|
||||
}
|
||||
else
|
||||
{
|
||||
case FONT_SMALL:
|
||||
DecompressGlyph_Small(currChar, textPrinter->japanese);
|
||||
break;
|
||||
case FONT_NORMAL:
|
||||
DecompressGlyph_Normal(currChar, textPrinter->japanese);
|
||||
break;
|
||||
case FONT_SHORT:
|
||||
case FONT_SHORT_COPY_1:
|
||||
case FONT_SHORT_COPY_2:
|
||||
case FONT_SHORT_COPY_3:
|
||||
DecompressGlyph_Short(currChar, textPrinter->japanese);
|
||||
break;
|
||||
case FONT_NARROW:
|
||||
DecompressGlyph_Narrow(currChar, textPrinter->japanese);
|
||||
break;
|
||||
case FONT_SMALL_NARROW:
|
||||
DecompressGlyph_SmallNarrow(currChar, textPrinter->japanese);
|
||||
break;
|
||||
case FONT_NARROWER:
|
||||
DecompressGlyph_Narrower(currChar, textPrinter->japanese);
|
||||
break;
|
||||
case FONT_SMALL_NARROWER:
|
||||
DecompressGlyph_SmallNarrower(currChar, textPrinter->japanese);
|
||||
break;
|
||||
case FONT_SHORT_NARROW:
|
||||
DecompressGlyph_ShortNarrow(currChar, textPrinter->japanese);
|
||||
break;
|
||||
case FONT_SHORT_NARROWER:
|
||||
DecompressGlyph_ShortNarrower(currChar, textPrinter->japanese);
|
||||
break;
|
||||
case FONT_BRAILLE:
|
||||
break;
|
||||
switch (subStruct->fontId)
|
||||
{
|
||||
case FONT_SMALL:
|
||||
DecompressGlyph_Small(currChar, textPrinter->japanese);
|
||||
break;
|
||||
case FONT_NORMAL:
|
||||
DecompressGlyph_Normal(currChar, textPrinter->japanese);
|
||||
break;
|
||||
case FONT_SHORT:
|
||||
case FONT_SHORT_COPY_1:
|
||||
case FONT_SHORT_COPY_2:
|
||||
case FONT_SHORT_COPY_3:
|
||||
DecompressGlyph_Short(currChar, textPrinter->japanese);
|
||||
break;
|
||||
case FONT_NARROW:
|
||||
DecompressGlyph_Narrow(currChar, textPrinter->japanese);
|
||||
break;
|
||||
case FONT_SMALL_NARROW:
|
||||
DecompressGlyph_SmallNarrow(currChar, textPrinter->japanese);
|
||||
break;
|
||||
case FONT_BRAILLE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CopyGlyphToWindow(textPrinter);
|
||||
@ -1612,7 +1611,13 @@ s32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing)
|
||||
case CHAR_PROMPT_CLEAR:
|
||||
break;
|
||||
default:
|
||||
glyphWidth = func(*str, isJapanese);
|
||||
if (IsChineseChar(*str, str[1], fontId, isJapanese))
|
||||
{
|
||||
glyphWidth = GetChineseFontWidthFunc(fontId);
|
||||
++str;
|
||||
}
|
||||
else
|
||||
glyphWidth = func(*str, isJapanese);
|
||||
if (minGlyphWidth > 0)
|
||||
{
|
||||
if (glyphWidth < minGlyphWidth)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user