UTF-8 not working on windows
Closed this issue · 3 comments
UTF8 displays as "??" on windows, untested on other OS.
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\leafB\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=E:\gopath
set GOPROXY=
set GORACE=
set GOROOT=E:\Go
set GOTMPDIR=
set GOTOOLDIR=E:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=E:\TDM-GCC-64\bin\gcc.exe
set CXX=E:\TDM-GCC-64\bin\g++.exe
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=E:\babun\.babun\cygwin\tmp\go-build269235094=/tmp/go-build -gno-record-gcc-switches
Hello and thank you for your message!
Did you run the example without modification?
The example uses only the default font and character ranges of Dear ImGui.
If you want to display more characters, the application has to load a separate font file and enable the corresponding glyph ranges. This is what is meant by the text in the demo window "CJK text will only appear..." The referenced README.txt can be found in the Dear ImGui repository.
To get the characters shown (on Windows), you can modify the example in imgui-go_impl_glfw_gl3.go
in the function createFontsTexture()
.
Instead of
image := io.Fonts().TextureDataAlpha8()
you put
fontAtlas := io.Fonts()
var builder imgui.GlyphRangesBuilder
builder.AddExisting(fontAtlas.GlyphRangesDefault())
builder.AddExisting(fontAtlas.GlyphRangesChineseFull())
ranges := builder.Build()
fontAtlas.AddFontFromFileTTFV("C:\\windows\\fonts\\msgothic.ttc", 16, imgui.DefaultFontConfig, ranges.GlyphRanges)
fontAtlas.SetTexDesiredWidth(8192)
image := fontAtlas.TextureDataAlpha8()
Thank you very much. It is fixed. Also, may I ask where can I find document of Dear ImGui?
Great!
Dear ImGui is found here: https://github.com/ocornut/imgui . From there you can follow up on readme files, their Wiki, as well as the source (headers).
All the best!