Skip to content

Instantly share code, notes, and snippets.

@bauripalash
Created October 3, 2022 06:21
Show Gist options
  • Save bauripalash/56f8ba1b0e8f953c4acab4415656c2a6 to your computer and use it in GitHub Desktop.
Save bauripalash/56f8ba1b0e8f953c4acab4415656c2a6 to your computer and use it in GitHub Desktop.
Ide
package main
import (
"fmt"
"image/color"
"log"
"os"
_ "embed"
"gioui.org/app"
"gioui.org/font/opentype"
"gioui.org/io/system"
"gioui.org/layout"
"gioui.org/op"
"gioui.org/text"
"gioui.org/unit"
"gioui.org/widget"
"gioui.org/widget/material"
)
//go:embed kalpurush.ttf
var kalpurush []byte
func main() {
go func() {
w := app.NewWindow()
err := run(w)
if err != nil {
log.Fatal(err)
}
os.Exit(0)
}()
app.Main()
}
func run(w *app.Window) error {
face , err := opentype.Parse(kalpurush)
if err != nil{
fmt.Println("failed to parse kalpurush font")
}
fonts := []text.FontFace{
{ Font: text.Font{ Typeface: "Kalpurush" } , Face: face },
}
th := material.NewTheme(fonts)
var ops op.Ops
var sbtn widget.Clickable
var sed widget.Editor
for {
e := <-w.Events()
switch e := e.(type) {
case system.DestroyEvent:
return e.Err
case system.FrameEvent:
gtx := layout.NewContext(&ops, e)
layout.Flex{
Axis: layout.Vertical,
Spacing: layout.SpaceStart,
}.Layout(gtx,
layout.Rigid(
func(gtx layout.Context) layout.Dimensions {
ed := material.Editor(th, &sed, "Write")
sed.SingleLine = false
ed.Font.Typeface = "Noto Serif Bengali"
return ed.Layout(gtx)
},
),
layout.Rigid(
layout.Spacer{Height: unit.Dp(25)}.Layout,
),
layout.Rigid(
func(gtx layout.Context) layout.Dimensions {
btn := material.Button(th, &sbtn, "Start")
return btn.Layout(gtx)
},
),
layout.Rigid(
func(gtx layout.Context) layout.Dimensions {
lbl := material.Label(th , unit.Sp(12) , "hello" )
return lbl.Layout(gtx)
},
),
layout.Rigid(
layout.Spacer{Height: unit.Dp(25)}.Layout,
),
)
title := material.H1(th, "Hello, Gio")
maroon := color.NRGBA{R: 127, G: 0, B: 0, A: 255}
title.Color = maroon
title.Alignment = text.Middle
title.Layout(gtx)
e.Frame(gtx.Ops)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment