private void CreateCharacterGlyph(char lineCharacter, ref float totalGlyphWidth, float lineStartX) { Glyph characterGlyph = GetGlyphFromDictionary(lineCharacter); totalGlyphWidth += GetKerningFromDictionary(lineCharacter, lastGlyph); var newDrawInfo = PlaceGlyphInLine(characterGlyph, lineStartX, totalGlyphWidth); glyphs.Add(newDrawInfo); lastDrawData = newDrawInfo; totalGlyphWidth += (float)Math.Round(characterGlyph.AdvanceWidth); lastGlyph = characterGlyph; }
private GlyphDrawData PlaceGlyphInLine(Glyph characterGlyph, float lineStartX, float totalGlyphWidth) { var glyph = new GlyphDrawData(); var position = new Vector2D((lineStartX + totalGlyphWidth + characterGlyph.LeftSideBearing).Round(), lastDrawData.DrawArea.Top); glyph.DrawArea = new Rectangle(position, characterGlyph.UV.Size); glyph.UV = characterGlyph.PrecomputedFontMapUV; return(glyph); }
private void AddIndicesAndVerticesForGlyph(Batch2D batch, GlyphDrawData glyph) { batch.AddIndices(); batch.verticesColorUV[batch.verticesIndex++] = new VertexPosition2DColorUV( position + glyph.DrawArea.TopLeft, color, glyph.UV.TopLeft); batch.verticesColorUV[batch.verticesIndex++] = new VertexPosition2DColorUV( position + glyph.DrawArea.BottomLeft, color, glyph.UV.BottomLeft); batch.verticesColorUV[batch.verticesIndex++] = new VertexPosition2DColorUV( position + glyph.DrawArea.BottomRight, color, glyph.UV.BottomRight); batch.verticesColorUV[batch.verticesIndex++] = new VertexPosition2DColorUV( position + glyph.DrawArea.TopRight, color, glyph.UV.TopRight); }
private GlyphDrawData PlaceGlyphInLine(Glyph characterGlyph, float lineStartX, float totalGlyphWidth) { var glyph = new GlyphDrawData(); var position = new Vector2D((lineStartX + totalGlyphWidth + characterGlyph.LeftSideBearing).Round(), lastDrawData.DrawArea.Top); glyph.DrawArea = new Rectangle(position, characterGlyph.UV.Size); glyph.UV = characterGlyph.PrecomputedFontMapUV; return glyph; }
private static GlyphDrawData[] LoadGlyphDrawData(BinaryReader reader) { int count = reader.ReadByte(); if (count == 255) count = reader.ReadInt32(); var data = new GlyphDrawData[count]; if (count == 0) return data; var arrayType = reader.ReadByte(); var name = reader.ReadString(); for (int i = 0; i < count; i++) { data[i].DrawArea = LoadRectangle(reader); data[i].UV = LoadRectangle(reader); } return data; }