This is an experimental package used to render open source fonts to polygons using Go.
As of version v0.18.0
, all fonts have been moved to separate repos
due to the original repo being just too huge.
They are now organized by the first letter of the name of the font:
github.com/gmlewis/go-fonts-a/fonts/aaarghnormal
...
github.com/gmlewis/go-fonts-b/fonts/baloo
...
github.com/gmlewis/go-fonts-z/fonts/znikomitno24
To use one or more fonts within a Go program, import the main package and the font(s) you want, like this:
import (
"github.com/gmlewis/go-fonts/fonts"
_ "github.com/gmlewis/go-fonts-u/fonts/ubuntumonoregular"
)
Then render the text to polygons and use them however you want:
xPos, yPos, xScale, yScale := 0.0, 0.0, 1.0, 1.0
message := "Sample from ubuntumonoregular"
render, err := fonts.Text(xPos, yPos, xScale, yScale, message, "ubuntumonoregular", &fonts.Center)
if err != nil {
log.Fatal(err)
}
log.Printf("MBB: %v", render.MBB)
for i, poly := range render.Polygons {
log.Printf("Polygon #%v/%v has %v points. MBB: %v", i+1, len(render.Polygons), len(poly.Pts), poly.MBB)
// ...
}
See https://github.com/gmlewis/go-gerber or https://github.com/gmlewis/blackjack for example applications that use this package.
Enjoy!
Please note that all fonts have their own licenses which are included in their respective directories.
Copyright 2019-2024 Glenn M. Lewis. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.