/// <summary> /// Запускается из PrecacheColor. /// </summary> /// <param name="c">Буква шрифта.</param> /// <returns>Один визуальный образ буквы.</returns> GlyphInfo CreateGlyph(Pair <char, Color> c) { FontGlyph glyph = font.CreateGlyph(c.First); if (glyph.Data == null) { return(new GlyphInfo { Sprite = null, Advance = 0, Offset = int2.Zero }); } var s = builder.Allocate(glyph.Size); var g = new GlyphInfo { Sprite = s, Advance = glyph.Advance, Offset = glyph.Bearing, fg = glyph }; //var dest = s.Sheet.GetData(); //var destStride = s.Sheet.Size.Width * 4; //for (var j = 0; j < s.Size.Y; j++) //{ // for (var i = 0; i < s.Size.X; i++) // { // // тут происходит копирование байтов из глифа в "p", а после в dest общий массив текстуры. // var p = glyph.Data[j * glyph.Size.Width + i]; // if (p != 0) // { // var q = destStride * (j + s.Bounds.Top) + 4 * (i + s.Bounds.Left); // var pmc = Util.PremultiplyAlpha(Color.FromArgb(p, c.Second)); // dest[q] = pmc.B; // dest[q + 1] = pmc.G; // dest[q + 2] = pmc.R; // dest[q + 3] = pmc.A; // } // } //} //s.Sheet.CommitBufferedData(); return(g); }
GlyphInfo CreateGlyph(Pair <char, Color> c) { var glyph = font.CreateGlyph(c.First, size, deviceScale); if (glyph.Data == null) { return(new GlyphInfo { Sprite = null, Advance = 0, Offset = int2.Zero }); } var s = builder.Allocate(glyph.Size); var g = new GlyphInfo { Sprite = s, Advance = glyph.Advance, Offset = glyph.Offset }; var dest = s.Sheet.GetData(); var destStride = s.Sheet.Size.Width * 4; for (var j = 0; j < s.Size.Y; j++) { for (var i = 0; i < s.Size.X; i++) { var p = glyph.Data[j * glyph.Size.Width + i]; if (p != 0) { var q = destStride * (j + s.Bounds.Top) + 4 * (i + s.Bounds.Left); var pmc = Util.PremultiplyAlpha(Color.FromArgb(p, c.Second)); dest[q] = pmc.B; dest[q + 1] = pmc.G; dest[q + 2] = pmc.R; dest[q + 3] = pmc.A; } } } s.Sheet.CommitBufferedData(); return(g); }