mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-22 09:23:16 +00:00
blitstr2: codegen: generate rustfmt-compatible code
Generate code that can be put through rustfmt without being altered. This removes an issue where the font tables can be rearraged by simply running `rustfmt` on the repository. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
9ebf8eb2fc
commit
22546710df
2 changed files with 13 additions and 12 deletions
|
|
@ -79,6 +79,9 @@ func ConvertPatternToRust(pattern BlitPattern) string {
|
|||
ceilRow += 1
|
||||
}
|
||||
for i := uint32(0); i < ceilRow; i++ {
|
||||
if i != 0 {
|
||||
patternStr += " "
|
||||
}
|
||||
start := i * wordsPerRow
|
||||
end := min(uint32(len(pattern.Words)), (i+1)*wordsPerRow)
|
||||
line := pattern.Words[start:end]
|
||||
|
|
@ -86,9 +89,8 @@ func ConvertPatternToRust(pattern BlitPattern) string {
|
|||
for _, word := range line {
|
||||
s = append(s, fmt.Sprintf("0x%08x", word))
|
||||
}
|
||||
patternStr += strings.Join(s, ", ") + ","
|
||||
patternStr += strings.Join(s, ", ") + ",\n"
|
||||
}
|
||||
patternStr += "\n"
|
||||
return patternStr
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -144,10 +144,10 @@ pub const GLYPHS: [u32; {{.GS.GlyphsLen}}] = [
|
|||
/// Widths for proportional glyphs
|
||||
pub const WIDTHS: [u8; {{.GS.WidthsLen}}] = [
|
||||
{{.GS.Widths}}];
|
||||
{{end}}`
|
||||
{{end}}
|
||||
`
|
||||
|
||||
const loaderFileTemplate = `
|
||||
// DO NOT MAKE EDITS HERE because this file is automatically generated.
|
||||
const loaderFileTemplate = `// DO NOT MAKE EDITS HERE because this file is automatically generated.
|
||||
// To make changes, see <xous_root>/services/graphics-server/src/blitstr2/codegen/main.go
|
||||
|
||||
{{.Font.Legal}}
|
||||
|
|
@ -160,15 +160,14 @@ const loaderFileTemplate = `
|
|||
/// Pixels are packed in row-major order with LSB of first pixel word
|
||||
/// containing the top left pixel. Bit of 0 means clear, 1 means set
|
||||
pub static {{.FontName}}_GLYPHS: [u32; {{.GS.GlyphsLen}}] = [
|
||||
{{.GS.Glyphs}}];
|
||||
{{if .GS.Widths}}
|
||||
{{end}}`
|
||||
{{.GS.Glyphs}}];{{if .GS.Widths}}{{end}}
|
||||
`
|
||||
|
||||
const loadermodTemplate = `// DO NOT MAKE EDITS HERE because this file is automatically generated.
|
||||
// The order of these modules affects the link order in the loader, which is referred to in the graphics engine.
|
||||
// To make changes, see <xous_root>/services/graphics-server/src/blitstr2/codegen/main.go
|
||||
|
||||
{{range $f := .FontDir}}pub mod {{$f.Name}};
|
||||
{{range $f := .FontDir}}
|
||||
pub mod {{$f.Name}};
|
||||
{{end}}`
|
||||
|
||||
const fontmapTemplate = `// DO NOT MAKE EDITS HERE because this file is automatically generated.
|
||||
|
|
|
|||
Loading…
Reference in a new issue