Skip to content

Commit

Permalink
Prevent unwanted font face changes
Browse files Browse the repository at this point in the history
When a character appears in the text, that is not in the default font
face, it is looked up in the spare faces of the font. Moreover, the
default range also began to be baked from the spare face. I made that
only characters that are not in the default face are baked from the
spare face.
  • Loading branch information
Gliese852 committed May 18, 2020
1 parent 97f0641 commit b28ed58
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/pigui/PiGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,16 @@ Instance::Instance() :
// TODO: clang-format doesn't like list initializers inside function calls
// clang-format off
PiFont uiheading("orbiteer", {
PiFace("Orbiteer-Bold.ttf", 1.0), // imgui only supports 0xffff, not 0x10ffff
PiFace("DejaVuSans.ttf", /*18.0/20.0*/ 1.2),
PiFace("wqy-microhei.ttc", 1.0),
PiFace("Orbiteer-Bold.ttf", 1.0) // imgui only supports 0xffff, not 0x10ffff
PiFace("wqy-microhei.ttc", 1.0)
});
AddFontDefinition(uiheading);

PiFont guifont("pionillium", {
PiFace("PionilliumText22L-Medium.ttf", 1.0),
PiFace("DejaVuSans.ttf", 13.0 / 14.0),
PiFace("wqy-microhei.ttc", 1.0),
PiFace("PionilliumText22L-Medium.ttf", 1.0)
PiFace("wqy-microhei.ttc", 1.0)
});
AddFontDefinition(guifont);
// clang-format on
Expand Down Expand Up @@ -199,7 +199,8 @@ ImFont *Instance::AddFont(const std::string &name, int size)

PiFont &pifont = iter->second;
pifont.setPixelsize(size);
pifont.faces().back().addGlyph(0x20); // only add space
// only add space to the first face, this will be the default face, faces without ranges are not baked
pifont.faces()[0].addGlyph(0x20);
m_pi_fonts[std::make_pair(name, size)] = pifont;

m_should_bake_fonts = true;
Expand Down

0 comments on commit b28ed58

Please sign in to comment.