summaryrefslogtreecommitdiff
path: root/src/renderer/tr_font.c
diff options
context:
space:
mode:
authorZack Middleton <zturtleman@gmail.com>2012-04-07 02:53:42 +0000
committerTim Angus <tim@ngus.net>2013-01-12 20:21:19 +0000
commit713752f0fc4242987eb27efc8e825dce14f440eb (patch)
tree614a90483f22febadf53cc3eabff04724e1776fd /src/renderer/tr_font.c
parentbee5f4f9f34f29e4c2ce8088da718b6030a4f496 (diff)
Fixed some issues found using clang static analyzer.
Diffstat (limited to 'src/renderer/tr_font.c')
-rw-r--r--src/renderer/tr_font.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/renderer/tr_font.c b/src/renderer/tr_font.c
index 54a832d8..78a9c6e9 100644
--- a/src/renderer/tr_font.c
+++ b/src/renderer/tr_font.c
@@ -291,10 +291,10 @@ static glyphInfo_t *RE_ConstructGlyphInfo(unsigned char *imageOut, int *xOut, in
glyph.t2 = glyph.t + (float)scaled_height / 256;
*xOut += scaled_width + 1;
- }
- ri.Free(bitmap->buffer);
- ri.Free(bitmap);
+ ri.Free(bitmap->buffer);
+ ri.Free(bitmap);
+ }
return &glyph;
}
@@ -341,13 +341,12 @@ void RE_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font) {
image_t *image;
qhandle_t h;
float max;
+ float glyphScale;
#endif
void *faceData;
int i, len;
char name[1024];
- float dpi = 72; //
- float glyphScale = 72.0f / dpi; // change the scale to be relative to 1 based on 72 dpi ( so dpi of 144 means a scale of .5 )
-
+ float dpi = 72;
if (!fontName) {
ri.Printf(PRINT_ALL, "RE_RegisterFont: called with empty name\n");
@@ -357,8 +356,6 @@ void RE_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font) {
if (pointSize <= 0) {
pointSize = 12;
}
- // we also need to adjust the scale based on point size relative to 48 points as the ui scaling is based on a 48 point font
- glyphScale *= 48.0f / pointSize;
// make sure the render thread is stopped
R_SyncRenderThread();
@@ -450,7 +447,7 @@ void RE_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font) {
maxHeight = 0;
for (i = GLYPH_START; i < GLYPH_END; i++) {
- glyph = RE_ConstructGlyphInfo(out, &xOut, &yOut, &maxHeight, face, (unsigned char)i, qtrue);
+ RE_ConstructGlyphInfo(out, &xOut, &yOut, &maxHeight, face, (unsigned char)i, qtrue);
}
xOut = 0;
@@ -515,6 +512,12 @@ void RE_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font) {
}
}
+ // change the scale to be relative to 1 based on 72 dpi ( so dpi of 144 means a scale of .5 )
+ glyphScale = 72.0f / dpi;
+
+ // we also need to adjust the scale based on point size relative to 48 points as the ui scaling is based on a 48 point font
+ glyphScale *= 48.0f / pointSize;
+
registeredFont[registeredFontCount].glyphScale = glyphScale;
font->glyphScale = glyphScale;
Com_Memcpy(&registeredFont[registeredFontCount++], font, sizeof(fontInfo_t));