| 871 | |
| 872 | |
| 873 | GLFont::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 | |
| 906 | void GLFont::Drawer::drawString(const std::wstring& str, float xpos, float ypos, Align hAlign, Align vAlign, int vpx, int vpy, bool cacheable) const { |
| 907 |
nothing calls this directly
no test coverage detected