コード例 #1
0
ファイル: TextConverter.cs プロジェクト: whztt07/DeltaEngine
		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;
		}
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: FontRenderer.cs プロジェクト: whztt07/DeltaEngine
		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);
		}
コード例 #4
0
 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);
 }
コード例 #5
0
        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;
        }
コード例 #6
0
ファイル: TextConverter.cs プロジェクト: whztt07/DeltaEngine
		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;
		}
コード例 #7
0
ファイル: Scene.cs プロジェクト: whztt07/DeltaEngine
		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;
		}