Open Geo5 opened 9 months ago
so, if index 0 is the only case, fix here should be easy to do. It just needs some extra stuff in style setter to extend fonts
field to a slice of fonts and push them all instead of only one font.
If I remember correctly I put index 0 there because I was too lazy to apply something more complex :smile:.
So you suggest making this
https://github.com/AllenDang/giu/blob/304f0b9ed27bd1e4e246308b2326900c3a26f5fd/StyleSetter.go#L16
a slice of fonts and maybe adding a new function like this
https://github.com/AllenDang/giu/blob/304f0b9ed27bd1e4e246308b2326900c3a26f5fd/Style.go#L43
which takes a slice of fonts and just calls PushFont
for all of them?
Yeah and This https://github.com/AllenDang/giu/blob/304f0b9ed27bd1e4e246308b2326900c3a26f5fd/StyleSetter.go#L62 should apply to all default fonts
Also there is no need to add me method - setfont can be modified SetFont(fonrs .. FontInfo)
I can get to work on this
if I push multiple fonts, doesn't it just use the font on top of the stack? How does it then render the button with the icon?
I suppose that when you push multiple fonts it tries to use this on top of the stack, then it tries the next and so on...
iirc there was something like MergeMode
(?)
Maybe this is important?
Is there by chance any way to view the current fonts on the stack?
no idea... You can search in cimgui_funcs.go in cimgui-go repo but I'm affraid that no...
Well i wrote something, but it doesn't work. If you want to take a look, its here.
Bruh I read the read the source code all the way to dear imgui source and have no idea
Still have to figure out why does it work withou setting the font size... I will think about it.
What happend?
If one is adding fonts containing e.g. icons or other special charactes with
FontAtlas.SetDefaultFont(...)
and usesStyleSetter.SetFontSize(...).To(...)
afterwards, only text/characters/glyphs contained in the last added default font are shown.This seems to be, because new default fonts are prepended to the list of default fonts here in SetDefaultFont(...) and the
StyleSetter.SetFontSize(...)
uses index 0 of the default fonts.The minimal example does currently not show any icon at all, because of #711 but looks as follows on v0.7.0:
I don't have any idea, how this could be fixed, because as far as i understand the magic happens by merging the default fonts in
rebuildFontAtlas
, which is not done for the extra fonts (which StyleSetter uses to do the styling)Code example
```golang package main import ( iconFonts "github.com/juliettef/IconFontCppHeaders" g "github.com/AllenDang/giu" ) var IconFont = iconFonts.IconsForkAwesome func Icon(name string) string { ret, ok := IconFont.Icons[name] if !ok { panic(name + " icon not found") } return ret } func loop() { g.SingleWindow().Layout( g.Style().SetFontSize(30).To( g.Label("Content line"), g.Label("Content line "+Icon("Check")), ), g.Button("Normal button"), g.Button("Normal button"+Icon("Check")), ) } func main() { wnd := g.NewMasterWindow("Multiple fonts and icons", 600, 400, g.MasterWindowFlagsNotResizable) // Change the default font to include icons g.Context.FontAtlas.SetDefaultFont("forkawesome-webfont.ttf", 20) wnd.Run(loop) } ```main.go
To Reproduce
Version
master
OS
Linux