From 46b2eb55f37cc2fe3eaadf128d46b73c5c9035e8 Mon Sep 17 00:00:00 2001 From: temidaradev Date: Thu, 16 Jan 2025 15:29:16 +0300 Subject: [PATCH] font fix --- README.md | 19 ++++++++++++++++--- i18n/README_jp.md | 19 ++++++++++++++++--- i18n/README_sk.md | 19 ++++++++++++++++--- i18n/README_tr.md | 21 +++++++++++++++++---- 4 files changed, 65 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 6a7f518..eb3dcd9 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/i18n/README_jp.md b/i18n/README_jp.md index 0f4c039..a9810fa 100644 --- a/i18n/README_jp.md +++ b/i18n/README_jp.md @@ -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 diff --git a/i18n/README_sk.md b/i18n/README_sk.md index 1c1401f..a50fc7f 100644 --- a/i18n/README_sk.md +++ b/i18n/README_sk.md @@ -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 diff --git a/i18n/README_tr.md b/i18n/README_tr.md index 5a8c306..cdefeea 100644 --- a/i18n/README_tr.md +++ b/i18n/README_tr.md @@ -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