-
-
Save Papierkorb/ca6e8ae4e4aee2eb2c085655f96d8916 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
private def build_vertices : Array(Vertex) | |
vertices = [ ] of Vertex | |
texture_size = @font.texture_for(@size).size | |
baseline = 0 | |
@lines.each do |line| | |
baseline += line.top | |
colors = @formatter.format(line.text, @default_color) | |
build_line_vertices(vertices, line, colors, baseline, texture_size) | |
end | |
vertices | |
end | |
# Inner loop split into own function. | |
private def build_line_vertices(vertices, line, colors, baseline, texture_size) | |
prev_glyph = nil | |
advance = 0 | |
line.glyphs.zip(colors) do |glyph, color| | |
kerning = 0 # Ternary Conditions always have the issue of "wtf is the else? .. ah there it is *scroll*" | |
kerning = @font.get_kerning(prev_glyph.code, glyph.code, @size) if prev_glyph | |
create_glyph_vertices(vertices, glyph, color, advance, baseline, texture_size) | |
advance += glyph.advance + kerning | |
prev_glyph = glyph | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment