MCPcopy Create free account
hub / github.com/cjcliffe/CubicSDR / Drawer

Method Drawer

src/util/GLFont.cpp:873–904  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

871
872
873GLFont::Drawer::Drawer(int basicFontSize, double scaleFactor) {
874
875 //Selection of the final font: scan GLFont::fonts to find the biggest font such as
876 // its pixHeight <= basicFontSize * scaleFactor.
877 //then compute finalScaleFactor the zooming factor of renderingFont to reach a
878 //final font size of basicFontSize* scaleFactor:
879 renderingFontIndex = 0;
880
881 //try to align on an integer pixel size if the targetSize font is available
882 int targetSize = round(basicFontSize * scaleFactor);
883
884 fonts[0].loadFontOnce();
885
886 for (int i = 0; i < GLFONT_SIZE_MAX - 1; i++) {
887
888 fonts[i + 1].loadFontOnce();
889
890 if (fonts[i + 1].pixHeight <= targetSize) {
891
892 renderingFontIndex = i + 1;
893 }
894 else {
895 break;
896 }
897 } //end for
898
899 //
900 int rawSize = fonts[renderingFontIndex].pixHeight;
901
902 //targetSize may not be reached yet, so the effective rendering font: fonts[renderingFontIndex] must be scaled up a bit.
903 renderingFontScaleFactor = (double) targetSize / rawSize;
904}
905
906void GLFont::Drawer::drawString(const std::wstring& str, float xpos, float ypos, Align hAlign, Align vAlign, int vpx, int vpy, bool cacheable) const {
907

Callers

nothing calls this directly

Calls 1

loadFontOnceMethod · 0.80

Tested by

no test coverage detected