- if (encounteredUnrenderedGlyph && callback != null) Scheduler.add(new Scheduler.Task() { public void perform() {
- for(int i=0; i<text.length(); i++) {
- Glyph g = glyphs[text.charAt(i)];
- if (g == null || g.p == null) { Scheduler.add(this); return; }
- }
- callback.perform();
- }});
- if (!latinCharsPreloaded) for(int i=32; i<128; i++) glyphsToBeRendered.append(glyphs[i] = new Glyph((char)i, this));
- if (!latinCharsPreloaded || encounteredUnrenderedGlyph) Scheduler.add(glyphRenderingTask);
- latinCharsPreloaded = true;
- return ((((long)width) << 32) | (long)(height & 0xffffffffL));
+ if (!encounteredUnrenderedGlyph) return ((((long)width) << 32) | (long)(height & 0xffffffffL));
+
+ if (callback != null) Scheduler.add(new Scheduler.Task() {
+ public void perform() throws Exception {
+ // FEATURE this isn't terribly efficient... perhaps the task should go on the last glyph?
+ for(int i=0; i<text.length(); i++) {
+ Glyph g = glyphs[text.charAt(i)];
+ if (g == null || !g.isLoaded) { Scheduler.add(this); return; }
+ }
+ callback.perform();
+ }});
+
+ // preload the Latin-1 charset with low priority (we'll probably want it)
+ if (!latinCharsPreloaded) {
+ for(int i=48; i<57; i++) glyphsToBeRendered.append(glyphs[i] = Platform.createGlyph(this, (char)i));
+ for(int i=32; i<47; i++) glyphsToBeRendered.append(glyphs[i] = Platform.createGlyph(this, (char)i));
+ for(int i=57; i<128; i++) glyphsToBeRendered.append(glyphs[i] = Platform.createGlyph(this, (char)i));
+ latinCharsPreloaded = true;
+ }
+ if (!glyphRenderingTaskIsScheduled) {
+ Scheduler.add(glyphRenderingTask);
+ glyphRenderingTaskIsScheduled = true;
+ }
+ return -1;