Compare commits

..

No commits in common. "b0672ec8ee0e78ef52cc44b4df5d4402015a1320" and "3127aad09a3a2d07a8f01e84cec2119c8c991b22" have entirely different histories.

2 changed files with 7 additions and 42 deletions

View File

@ -1,35 +0,0 @@
package fallbackFaces
import "golang.org/x/image/font"
import "git.tebibyte.media/tomo/tomo"
import "golang.org/x/image/font/basicfont"
import "git.tebibyte.media/tomo/backend/style"
type faceSet struct {
regular font.Face
bold font.Face
italic font.Face
boldItalic font.Face
}
// New creates a new fallback face set.
func New () style.FaceSet {
// TODO maybe pre-generate different variations of this face
return &faceSet {
regular: basicfont.Face7x13,
bold: basicfont.Face7x13,
italic: basicfont.Face7x13,
boldItalic: basicfont.Face7x13,
}
}
func (this *faceSet) Face (face tomo.Face) font.Face {
bold := face.Weight >= 500
italic := face.Italic >= 0.1 || face.Slant >= 0.1
switch {
case bold && italic: return this.boldItalic
case bold: return this.bold
case italic: return this.italic
default: return this.regular
}
}

View File

@ -412,23 +412,23 @@ func generateSource (data []byte, width int) map[tomo.Icon] canvas.Texture {
return source
}
type iconSet struct {
type iconTheme struct {
texturesSmall map[tomo.Icon] canvas.Texture
texturesLarge map[tomo.Icon] canvas.Texture
}
// New creates a new fallback icon set.
// New creates a new fallback icon theme.
func New () style.IconSet {
return new(iconSet)
return new(iconTheme)
}
func (this *iconSet) ensure () {
func (this *iconTheme) ensure () {
if this.texturesSmall != nil { return }
this.texturesSmall = generateSource(atlasSmallBytes, 16)
this.texturesLarge = generateSource(atlasLargeBytes, 32)
}
func (this *iconSet) selectSource (size tomo.IconSize) map[tomo.Icon] canvas.Texture {
func (this *iconTheme) selectSource (size tomo.IconSize) map[tomo.Icon] canvas.Texture {
if size == tomo.IconSizeSmall {
return this.texturesSmall
} else {
@ -436,7 +436,7 @@ func (this *iconSet) selectSource (size tomo.IconSize) map[tomo.Icon] canvas.Tex
}
}
func (this *iconSet) Icon (icon tomo.Icon, size tomo.IconSize) canvas.Texture {
func (this *iconTheme) Icon (icon tomo.Icon, size tomo.IconSize) canvas.Texture {
this.ensure()
source := this.selectSource(size)
if texture, ok := source[icon]; ok {
@ -445,7 +445,7 @@ func (this *iconSet) Icon (icon tomo.Icon, size tomo.IconSize) canvas.Texture {
return nil
}
func (this *iconSet) MimeIcon (mime data.Mime, size tomo.IconSize) canvas.Texture {
func (this *iconTheme) MimeIcon (mime data.Mime, size tomo.IconSize) canvas.Texture {
this.ensure()
source := this.selectSource(size)
if mime == data.M("inode", "directory") {