public void DrawText(UText textObject, Point location, UBrush defBrush, UTextDrawOptions opt, bool clientRendering) { var tl = CreateTextElements(textObject); foreach (var ord in textObject.SafeGetStyleRanges) { if (ord.bgOverride != null) { foreach (var r in HitTextRange(ord.start, ord.length, location, textObject)) { FillRectangle(r, ord.bgOverride); } } } if (clientRendering) { // set default foreground brush tl.textRenderer.defaultEffect.fgBrush = CreateBrush(defBrush); // Draw the text (foreground & background in the client renderer) tl.textLayout.Draw(new Object[] { location, textObject }, tl.textRenderer, location.X, location.Y); } else { // Use D2D implimentation of text layout rendering realRenderer.renderTarget.DrawTextLayout(D2DTr.tr(location), tl.textLayout, CreateBrush(defBrush)); } }
public void DrawText(UText textObject, NoForms.Common.Point location, UBrush defBrush, UTextDrawOptions opt, bool clientRendering) { var tl = glyphRunner.GetTextInfo(textObject); foreach (var glyphrun in tl.glyphRuns) { var style = glyphrun.run.drawStyle; UFont font = style != null ? (style.fontOverride ?? textObject.font) : textObject.font; FontStyle fs = (font.bold ? FontStyle.Bold: 0) | (font.italic ? FontStyle.Italic: 0); var sdgFont = Translate(font); UBrush brsh = style != null ? (style.fgOverride ?? defBrush) : defBrush; if (style != null && style.bgOverride != null) { FillRectangle(new NoForms.Common.Rectangle(glyphrun.location, glyphrun.run.runSize), style.bgOverride); } realRenderer.graphics.DrawString(glyphrun.run.content, sdgFont, CreateBrush(brsh), SDGTr.trF(location + glyphrun.location), StringFormat.GenericTypographic); } }
public void DrawText(UText textObject, NoForms.Common.Point location, UBrush defBrush, UTextDrawOptions opt, bool clientRendering) { GLTextStore <sdg.Font> GLds = GetTextData(textObject); //when uninitialised, all members wll be null/-1. we need to run a pass of the generator thing if (GLds.texture_for_blitting == -1) { var tl = GLds.tinfo = glyphRunner.GetTextInfo(textObject); float l = float.MaxValue, t = float.MaxValue, b = float.MinValue, r = float.MinValue; // if empty if (tl.glyphRuns.Count == 0) { return; } // Calculate the render rectangle foreach (var gr in tl.glyphRuns) { var p1 = gr.location; var p2 = new Point(p1.X + gr.run.runSize.width, p1.Y + gr.run.runSize.height); if (p1.X < l) { l = p1.X; } if (p2.X < l) { l = p2.X; } if (p1.Y < t) { t = p1.Y; } if (p2.Y < t) { t = p2.Y; } if (p2.X > r) { r = p2.X; } if (p1.X > r) { r = p1.X; } if (p2.Y > b) { b = p2.Y; } if (p1.Y > b) { b = p1.Y; } } Rectangle rrect = new Rectangle(new Point(l, t), new Point(r, b), true); System.Diagnostics.Debug.Assert(rrect.width > 0 && rrect.height > 0); // ensure we have the software buffer EnsureStoredData(textObject, new Size(r - l, b - t)); // we will draw black onto transparent background, and handle brushes when rendering to blitting texture GLds.renderOffset = new Point(l, t); GLds.sbb_context.Clear(sdg.Color.Transparent); foreach (var glyphrun in tl.glyphRuns) { var style = glyphrun.run.drawStyle; UFont font = style != null ? (style.fontOverride ?? textObject.font) : textObject.font; sdg.FontStyle fs = (font.bold ? sdg.FontStyle.Bold : 0) | (font.italic ? sdg.FontStyle.Italic : 0); var sdgFont = FTR(font); // render at 0,0 because we cropped to the minimum drawing area of glyphs... GLds.sbb_context.DrawString(glyphrun.run.content, sdgFont, sdg.Brushes.Black, PTR(glyphrun.location - GLds.renderOffset), sdg.StringFormat.GenericTypographic); } // now copy into the blit mask GLds.texture_for_blitting = GL.GenTexture(); LoadBitmapIntoTexture(GLds.texture_for_blitting, GLds.softbitbuf); } // draw background... foreach (var glyphrun in GLds.tinfo.glyphRuns) { var style = glyphrun.run.drawStyle; UBrush brsh = style != null ? (style.fgOverride ?? defBrush) : defBrush; if (style != null && style.bgOverride != null) { FillRectangle(new NoForms.Common.Rectangle(location + glyphrun.location + GLds.renderOffset, glyphrun.run.runSize), style.bgOverride); } } // use blit mask to create a blitting texture, using the Util fbo (FIXME? but no multithreads...) //throw new NotImplementedException(); // blit the buffer (FIXME thats not blitting) FIXME needs seperate (what about masked tezture alpbas!) var gs = GLds.softbitbuf.Size; Rectangle rr = new Rectangle(location + GLds.renderOffset, new Size(gs.Width, gs.Height)); int st = rel.renderData.sofwareBuffer.Count; bufferTexRect(rr, new Rectangle(0, 0, 1, 1)); int cnt = rel.renderData.sofwareBuffer.Count - st; rel.renderData.bufferInfo.Add(new RenderInfo(st, cnt, ArrayData.Vertex | ArrayData.Color | ArrayData.Texture, PrimitiveType.Quads, GLds.texture_for_blitting)); }