praydog/REFramework

imgui unable to display Chinese characters?

Closed this issue · 9 comments

It shows chinese characters as ?, is there a way to fix?

Example Solution:
Place font file under reframework/fonts

local FONT_NAME = "NotoSansSC-Regular.otf"
local FONT_SIZE = 18

local CHINESE_GLYPH_RANGES = {
    0x0020, 0x00FF, -- Basic Latin + Latin Supplement
    0x2000, 0x206F, -- General Punctuation
    0x3000, 0x30FF, -- CJK Symbols and Punctuations, Hiragana, Katakana
    0x31F0, 0x31FF, -- Katakana Phonetic Extensions
    0xFF00, 0xFFEF, -- Half-width characters
    0x4e00, 0x9FAF, -- CJK Ideograms
    0,
}

local font = imgui.load_font(FONT_NAME, FONT_SIZE, CHINESE_GLYPH_RANGES)

re.on_frame(function()
    imgui.push_font(font)
    imgui.begin_window("asdasfsaf")
    imgui.text("こんにちは、私の日本語がとてもいいじゃない")
    imgui.end_window()
    imgui.pop_font()
end)

CJK_font.zip

Thanks to praydog!

Hello, is this issue solved? I have no idea of where to find Chinese version for this solution.

Hello, is this issue solved? I have no idea of where to find Chinese version for this solution.

#457 (comment)

Do you means that I can replace the font file with Chinese font to solve this problem?

Directly using the zip file can show jp font in my reframework

I think this issue haven't been solved and might not been closed yet.

the solution is literally here...

All you need is to find a font set lol

https://github.com/googlefonts/noto-cjk

good !

示例解决方案:将字体文件放在reframework/fonts

local FONT_NAME = "NotoSansSC-Regular.otf"
local FONT_SIZE = 18

local CHINESE_GLYPH_RANGES = {
    0x0020, 0x00FF, -- Basic Latin + Latin Supplement
    0x2000, 0x206F, -- General Punctuation
    0x3000, 0x30FF, -- CJK Symbols and Punctuations, Hiragana, Katakana
    0x31F0, 0x31FF, -- Katakana Phonetic Extensions
    0xFF00, 0xFFEF, -- Half-width characters
    0x4e00, 0x9FAF, -- CJK Ideograms
    0,
}

local font = imgui.load_font(FONT_NAME, FONT_SIZE, CHINESE_GLYPH_RANGES)

re.on_frame(function()
    imgui.push_font(font)
    imgui.begin_window("asdasfsaf")
    imgui.text("こんにちは、私の日本語がとてもいいじゃない")
    imgui.end_window()
    imgui.pop_font()
end)

CJK_font.zip

感谢 praydog!

Example Solution: Place font file under reframework/fonts

local FONT_NAME = "NotoSansSC-Regular.otf"
local FONT_SIZE = 18

local CHINESE_GLYPH_RANGES = {
    0x0020, 0x00FF, -- Basic Latin + Latin Supplement
    0x2000, 0x206F, -- General Punctuation
    0x3000, 0x30FF, -- CJK Symbols and Punctuations, Hiragana, Katakana
    0x31F0, 0x31FF, -- Katakana Phonetic Extensions
    0xFF00, 0xFFEF, -- Half-width characters
    0x4e00, 0x9FAF, -- CJK Ideograms
    0,
}

local font = imgui.load_font(FONT_NAME, FONT_SIZE, CHINESE_GLYPH_RANGES)

re.on_frame(function()
    imgui.push_font(font)
    imgui.begin_window("asdasfsaf")
    imgui.text("こんにちは、私の日本語がとてもいいじゃない")
    imgui.end_window()
    imgui.pop_font()
end)

CJK_font.zip

Thanks to praydog!

You're a genius! Thank you very much!