Skip to content

Commit

Permalink
someone said TTF
Browse files Browse the repository at this point in the history
  • Loading branch information
dd01da0465b4542f8f8af4ecedc149ed committed Jan 14, 2021
1 parent cf2f2f5 commit 72db2c4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions osu!stream/Graphics/Renderers/NativeTextRendererAndroid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Android.Graphics;
using OpenTK;
using OpenTK.Graphics;
using osum.AssetManager;
using osum.Helpers;

namespace osum.Graphics.Renderers
Expand All @@ -18,6 +19,7 @@ internal override pTexture CreateText(string text, float size, Vector2 restrictB
{
Canvas canvas = new Canvas();

// The bitmap size should be more flexible, but we're just hardcoding to 1024x1024 for now.
using (Bitmap bitmap = Bitmap.CreateBitmap(1024, 1024, Bitmap.Config.Argb8888))
{
canvas.SetBitmap(bitmap);
Expand All @@ -29,6 +31,7 @@ internal override pTexture CreateText(string text, float size, Vector2 restrictB

canvas.DrawPaint(paint);

paint.SetTypeface(Typeface.CreateFromAsset(NativeAssetManagerAndroid.manager, bold ? @"Skins/Default/Futura-CondensedExtraBold.ttf" : @"Skins/Default/Futura-Medium.ttf"));
paint.SetARGB(255, 255, 255, 255);
paint.TextSize = size;

Expand All @@ -42,8 +45,6 @@ internal override pTexture CreateText(string text, float size, Vector2 restrictB

using (Bitmap resized = Bitmap.CreateBitmap(bitmap, 0, 0, textBounds.Width(), textBounds.Height()))
{
resized.SetConfig(Bitmap.Config.Argb8888);

pTexture tex = pTexture.FromRawBytes(resized.LockPixels(), resized.Width, resized.Height);
resized.UnlockPixels();
return tex;
Expand Down
2 changes: 2 additions & 0 deletions osu!stream/osu!stream_android.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@
<AndroidNativeLibrary Include="Libraries\Android\x86_64\libbass.so" />
<AndroidNativeLibrary Include="Libraries\Android\x86_64\libbass_aac.so" />
<None Include="Properties\AndroidManifest.xml" />
<AndroidAsset Include="Skins\Default\Futura-CondensedExtraBold.ttf" />
<AndroidAsset Include="Skins\Default\Futura-Medium.ttf" />
</ItemGroup>
<ItemGroup>
<Compile Include="AssetManager\NativeAssetManager.cs" />
Expand Down

0 comments on commit 72db2c4

Please sign in to comment.