summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/fontwrapper-ft.cc
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2012-07-09 00:48:14 +0200
committerAdam Borowski <kilobyte@angband.pl>2012-07-09 00:48:14 +0200
commitadef487f6c1f76020ffa2bc7fb41d92f871415f0 (patch)
treea8a53d1a83cc80105f6e04cd7a725a0f64af829c /crawl-ref/source/fontwrapper-ft.cc
parentc921272717ab49549faccb5f47bcb8af49ffa4d5 (diff)
downloadcrawl-ref-adef487f6c1f76020ffa2bc7fb41d92f871415f0.tar.gz
crawl-ref-adef487f6c1f76020ffa2bc7fb41d92f871415f0.zip
Force a flush if we get 255 glyph substitutions in a text block.
Diffstat (limited to 'crawl-ref/source/fontwrapper-ft.cc')
-rw-r--r--crawl-ref/source/fontwrapper-ft.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/crawl-ref/source/fontwrapper-ft.cc b/crawl-ref/source/fontwrapper-ft.cc
index cfeeccfa3a..6785bc6901 100644
--- a/crawl-ref/source/fontwrapper-ft.cc
+++ b/crawl-ref/source/fontwrapper-ft.cc
@@ -313,6 +313,7 @@ unsigned int FTFontWrapper::map_unicode(ucs_t uchar)
m_glyphmap[uchar] = c;
load_glyph(c, uchar);
+ n_subst++;
dprintf("mapped %d (%x; %lc) to %d\n", uchar, uchar, uchar, c);
}
@@ -371,6 +372,7 @@ void FTFontWrapper::render_textblock(unsigned int x_pos, unsigned int y_pos,
ASSERT(m_buf);
m_buf->clear();
+ n_subst = 0;
float texcoord_dy = (float)m_max_advance.y / (float)m_tex.height();
@@ -418,12 +420,26 @@ void FTFontWrapper::render_textblock(unsigned int x_pos, unsigned int y_pos,
i++;
adv.x += m_glyphs[c].advance - m_glyphs[c].offset;
+
+ // See if we need to flush prematurely.
+ if (n_subst == MAX_GLYPHS - 1)
+ {
+ draw_m_buf(x_pos, y_pos, drop_shadow);
+ m_buf->clear();
+ n_subst = 0;
+ }
}
adv.x = 0;
adv.y += m_max_advance.y;
}
+ draw_m_buf(x_pos, y_pos, drop_shadow);
+}
+
+void FTFontWrapper::draw_m_buf(unsigned int x_pos, unsigned int y_pos,
+ bool drop_shadow)
+{
if (!m_buf->size())
return;