-
-
Save sysrpl/8af6e5a9d62cc2f2a1c40f9a9ae13b64 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// InternalWrite optionally writes the line 2 times, optionally with a shadow, then in color | |
procedure TFontWriter.InternalWrite(const Line: string; Scale, Col, Row: Float); | |
procedure Draw(const Lead, Base: TColorF; OX, OY: Float); | |
var | |
O, K, CX, CY: Float; | |
I: Integer; | |
begin | |
O := Opacity; | |
K := (FStore.Kerning * Scale) / 2; | |
OX := OX * Scale + Origin.X; | |
OY := OY * Scale + Origin.Y; | |
// FStore has a map of the height and width of each glyph | |
CX := Col * FStore.Map[$20].Width * Scale + OX; | |
CY := Row * FStore.Map[$20].Height * Scale + OY; | |
// Here is the for loop that itterates over each char in the line | |
for I := 1 to Length(Line) do | |
begin | |
if (Line[I] < '!') or (Line[I] > '}') then | |
begin | |
CX := CX + FStore.Map[$20].Width * Scale; | |
Continue; | |
end; | |
with FStore.Map[Ord(Line[I])] do | |
begin | |
// World commands populate a vertex buffer with sufficient room | |
World | |
.Vert(CX + Width * Scale + K, CY) | |
.Color(Lead.Red, Lead.Green, Lead.Blue, Lead.Alpha * O) | |
.TexCoord(B.X, A.Y) | |
.Vert(CX - K, CY) | |
.TexCoord(A.X, A.Y) | |
.Vert(CX - K, CY + Height * Scale) | |
.Color(Base.Red, Base.Green, Base.Blue, Base.Alpha * O) | |
.TexCoord(A.X, B.Y) | |
.Vert(CX + Width * Scale + K, CY + Height * Scale) | |
.TexCoord(B.X, B.Y); | |
CX := CX + Width * Scale; | |
end; | |
end; | |
end; | |
begin | |
if (Scale = 0) or (Line = '') then Exit; | |
if FShadows then | |
Draw(ShadowColor, ShadowColor, ShadowOffset.X, ShadowOffset.Y); | |
Draw(LeadColor, BaseColor, 0, 0); | |
end; | |