Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better Font Handling #6

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,28 @@ and then you can use that function easily like this: `var Tile = esset.GetMultip

## DrawText

For fonts you have to embed fonts seperataly like this:
For fonts you have to embed fonts seperataly and you should add a `text.Face` variable like this:

```
//go:embed path/to/your/font.ttf
var MyFont []byte
var FontFaceS text.Face
var FontFaceM text.Face
var FontFaceM text.Face
```

No need to create a special DrawOptions for this. Just enter X and Y after font size. Lastly add your color.
Then for not loading the font each time you should put `GetFont()` function into `init()` function which is in your main file (contains `Game{}`) like this:

After that you can use `esset.DrawText` func like this: `esset.UseFont(screen, assets.MyFont, "wassup", 24, 100, 50, color.White)`
```
func init() {
assets.FontFaceS, _ = esset.GetFont(assets.MyFont, 48)
}
```

After setting up the `GetFont()` function you are ready to use the `DrawText()` function

No need to create a special DrawOptions for this. Just (screen, text, fontSize, posX, posY, text.Face, color)

You can use `esset.DrawText` func like this: `esset.DrawText(screen, "wassup", 16, 100, 50, assets.FontFaceS, color.White)`

Much thanks to [@m110](https://github.com/m110) for source support <3
19 changes: 16 additions & 3 deletions i18n/README_jp.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,28 @@ var assets embed.FS

## DrawText

フォントの場合は、次のようにフォントを個別に埋め込む必要があります。
フォントの場合は、フォントを個別に埋め込む必要があり、次のように `text.Face` 変数を追加する必要があります:

```
//go:embed path/to/your/font.ttf
var MyFont []byte
var FontFaceS text.Face
var FontFaceM text.Face
var FontFaceM text.Face
```

このための特別な DrawOptions を作成する必要はありません。フォント サイズの後に X と Y を入力するだけです。最後に色を追加します。
次に、フォントを毎回ロードしないようにするには、次のように、メイン ファイル (`Game{}` を含む) にある `init()` 関数に `GetFont()` 関数を配置する必要があります:

その後、`esset.DrawText` 関数を次のように使用できます: `esset.DrawText(screen, asset.MyFont, "wassup", 24, 100, 50, color.White)`
```
func init() {
assets.FontFaceS, _ = esset.GetFont(assets.MyFont, 48)
}
```

`GetFont()` 関数を設定したら、`DrawText()` 関数を使用する準備が整います

このために特別な DrawOptions を作成する必要はありません。 (screen、text、fontSize、posX、posY、text.Face、color) だけです

`esset.DrawText` 関数は次のように使用できます: `esset.DrawText(screen、"こんにちわ", 16, 100, 50, assets.FontFaceS, color.White)`

ソースサポートをしてくれた [@m110](https://github.com/m110) に感謝します <3
19 changes: 16 additions & 3 deletions i18n/README_sk.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,28 @@ a potom môžete jednoducho použiť túto funkciu takto: `var Tile = esset.GetM

## DrawText

Pre písma ich musíte vložiť oddelene takto:
Pre fonty musíte vkladať fonty samostatne a mali by ste pridať premennú `text.Face` takto:

```
//go:embed path/to/your/font.ttf
var MyFont []byte
var FontFaceS text.Face
var FontFaceM text.Face
var FontFaceM text.Face
```

Na to nie je potrebné vytvárať špeciálne možnosti DrawOptions. Stačí zadať X a Y po veľkosti písma. Nakoniec pridajte svoju farbu.
Potom, aby ste nenačítali písmo zakaždým, mali by ste vložiť funkciu `GetFont()` do funkcie `init()`, ktorá je vo vašom hlavnom súbore (obsahuje `Game{}`) takto:

Potom môžete použiť `esset.DrawText` funkciu takto: `esset.DrawText(screen, assets.MyFont, "wassup", 24, 100, 50, color.White)`
```
func init() {
assets.FontFaceS, _ = esset.GetFont(assets.MyFont, 48)
}
```

Po nastavení funkcie `GetFont()` ste pripravení použiť funkciu `DrawText()`

Na to nie je potrebné vytvárať špeciálne možnosti DrawOptions. Len (screen, text, font size, posX, posY, text.Face, color)

Funkciu `esset.DrawText` môžete použiť takto: `esset.DrawText(screen, "wassup", 16, 100, 50, assets.FontFaceS, color.White)`

Veľmi vďaka pre [@m110](https://github.com/m110) za podporu so zdrojom <3
21 changes: 17 additions & 4 deletions i18n/README_tr.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,28 @@ ve sonra bu işlevi şu şekilde kolayca kullanabilirsiniz: `var Tile = esset.Ge

## DrawText

Yazı tipleri için yazı tiplerini ayrı ayrı gömmeniz gerekir:
Yazı tipleri için yazı tiplerini ayrı ayrı gömmelisiniz ve bunun gibi bir `text.Face` değişkeni eklemelisiniz:

```
//go:embed font/OpenSans-Medium.ttf
//go:embed path/to/your/font.ttf
var MyFont []byte
var FontFaceS text.Face
var FontFaceM text.Face
var FontFaceM text.Face
```

Bunun için ayrı bir DrawOptions oluşturmaya gerek yok. Font büyüklüğünden sonra X ve Y ekleyin. Son olarak renginizi ekleyin.
Daha sonra yazı tipini her seferinde yüklememek için `GetFont()` fonksiyonunu ana dosyanızda bulunan `init()` fonksiyonuna (`Game{}` içerir) şu şekilde koymalısınız:

Bundan sonra `esset.DrawText` fonksiyonunu şu şekilde kullanabilirsiniz: `esset.DrawText(screen, asset.MyFont, "naber", 24, 100, 50, color.White)`
```
func init() {
assets.FontFaceS, _ = esset.GetFont(assets.MyFont, 48)
}
```

`GetFont()` fonksiyonunu ayarladıktan sonra `DrawText()` fonksiyonunu kullanmaya hazırsınız

Bunun için özel bir DrawOptions oluşturmanıza gerek yok. Sadece (screen, text, fontSize, posX, posY, text.Face, color)

`esset.DrawText` fonksiyonunu şu şekilde kullanabilirsiniz: `esset.DrawText(screen, "naber", 16, 100, 50, assets.FontFaceS, color.White)`

Çok teşekkürler Kaynak desteği için [@m110](https://github.com/m110) <3
Loading