Skip to content

Commit

Permalink
Fixed compile error in sample project
Browse files Browse the repository at this point in the history
Added custom font to sample
  • Loading branch information
vchelaru committed Jan 13, 2024
1 parent a4c030e commit 272b8d3
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Gum/Wireframe/CustomSetPropertyOnRenderable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ BitmapFont GetAndCreateFontIfNecessary()
{
var fontFileName = GetFontFileName();

var font = LoaderManager.Self.TryGetCachedDisposable<BitmapFont>(fontFileName);
var font = LoaderManager.Self.GetDisposable(fontFileName) as BitmapFont;

// no cache, does it need to be created?
if (font == null)
Expand Down Expand Up @@ -749,7 +749,7 @@ public static void UpdateToFontValues(IText text, GraphicalUiElement graphicalUi

if (!string.IsNullOrEmpty(graphicalUiElement.CustomFontFile))
{
font = loaderManager.TryGetCachedDisposable<BitmapFont>(graphicalUiElement.CustomFontFile);
font = loaderManager.GetDisposable(graphicalUiElement.CustomFontFile) as BitmapFont;
if (font == null)
{
// so normally we would just let the content loader check if the file exists but since we're not going to
Expand Down Expand Up @@ -784,7 +784,7 @@ public static void UpdateToFontValues(IText text, GraphicalUiElement graphicalUi
#endif


font = loaderManager.TryGetCachedDisposable<BitmapFont>(fullFileName);
font = loaderManager.GetDisposable(fullFileName) as BitmapFont;
if (font == null || font.Texture?.IsDisposed == true)
{
// so normally we would just let the content loader check if the file exists but since we're not going to
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
info face="Peaberry" size=16 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=2,2
common lineHeight=28 base=13 scaleW=247 scaleH=275 pages=1 packed=0
page id=0 file="WhitePeaberryOutline.png"
chars count=95
char id=32 x=46 y=236 width=0 height=0 xoffset=0 yoffset=30 xadvance=5 page=0 chnl=0 letter="space"
char id=33 x=2 y=32 width=17 height=26 xoffset=-2 yoffset=5 xadvance=7 page=0 chnl=0 letter="!"
char id=34 x=150 y=213 width=20 height=18 xoffset=-3 yoffset=5 xadvance=9 page=0 chnl=0 letter="""
char id=35 x=192 y=32 width=23 height=24 xoffset=-4 yoffset=6 xadvance=11 page=0 chnl=0 letter="#"
char id=36 x=208 y=2 width=21 height=26 xoffset=-3 yoffset=5 xadvance=10 page=0 chnl=0 letter="$"
char id=37 x=166 y=32 width=24 height=24 xoffset=-4 yoffset=6 xadvance=12 page=0 chnl=0 letter="%"
char id=38 x=177 y=60 width=22 height=24 xoffset=-3 yoffset=6 xadvance=11 page=0 chnl=0 letter="&"
char id=39 x=112 y=213 width=17 height=19 xoffset=0 yoffset=5 xadvance=9 page=0 chnl=0 letter="'"
char id=40 x=65 y=2 width=18 height=28 xoffset=-2 yoffset=5 xadvance=8 page=0 chnl=0 letter="("
char id=41 x=85 y=2 width=18 height=28 xoffset=-2 yoffset=5 xadvance=8 page=0 chnl=0 letter=")"
char id=42 x=178 y=164 width=21 height=22 xoffset=-2 yoffset=5 xadvance=11 page=0 chnl=0 letter="*"
char id=43 x=76 y=190 width=21 height=21 xoffset=-2 yoffset=7 xadvance=11 page=0 chnl=0 letter="+"
char id=44 x=131 y=213 width=17 height=19 xoffset=-3 yoffset=14 xadvance=6 page=0 chnl=0 letter=","
char id=45 x=25 y=236 width=19 height=15 xoffset=-1 yoffset=12 xadvance=10 page=0 chnl=0 letter="-"
char id=46 x=217 y=213 width=17 height=17 xoffset=-3 yoffset=13 xadvance=6 page=0 chnl=0 letter="."
char id=47 x=67 y=32 width=19 height=25 xoffset=-4 yoffset=5 xadvance=7 page=0 chnl=0 letter="/"
char id=48 x=2 y=86 width=21 height=24 xoffset=-3 yoffset=6 xadvance=10 page=0 chnl=0 letter="0"
char id=49 x=25 y=86 width=21 height=24 xoffset=-3 yoffset=6 xadvance=10 page=0 chnl=0 letter="1"
char id=50 x=48 y=86 width=21 height=24 xoffset=-3 yoffset=6 xadvance=10 page=0 chnl=0 letter="2"
char id=51 x=71 y=86 width=21 height=24 xoffset=-3 yoffset=6 xadvance=10 page=0 chnl=0 letter="3"
char id=52 x=94 y=86 width=21 height=24 xoffset=-3 yoffset=6 xadvance=10 page=0 chnl=0 letter="4"
char id=53 x=117 y=86 width=21 height=24 xoffset=-3 yoffset=6 xadvance=10 page=0 chnl=0 letter="5"
char id=54 x=140 y=86 width=21 height=24 xoffset=-3 yoffset=6 xadvance=10 page=0 chnl=0 letter="6"
char id=55 x=163 y=86 width=21 height=24 xoffset=-3 yoffset=6 xadvance=10 page=0 chnl=0 letter="7"
char id=56 x=186 y=86 width=21 height=24 xoffset=-3 yoffset=6 xadvance=10 page=0 chnl=0 letter="8"
char id=57 x=209 y=86 width=21 height=24 xoffset=-3 yoffset=6 xadvance=10 page=0 chnl=0 letter="9"
char id=58 x=159 y=164 width=17 height=23 xoffset=-3 yoffset=8 xadvance=6 page=0 chnl=0 letter=":"
char id=59 x=109 y=32 width=17 height=25 xoffset=-3 yoffset=8 xadvance=6 page=0 chnl=0 letter=";"
char id=60 x=71 y=164 width=20 height=24 xoffset=-3 yoffset=5 xadvance=9 page=0 chnl=0 letter="<"
char id=61 x=90 y=213 width=20 height=19 xoffset=-3 yoffset=8 xadvance=9 page=0 chnl=0 letter="="
char id=62 x=93 y=164 width=20 height=24 xoffset=-3 yoffset=5 xadvance=9 page=0 chnl=0 letter=">"
char id=63 x=160 y=2 width=21 height=27 xoffset=-3 yoffset=5 xadvance=10 page=0 chnl=0 letter="?"
char id=64 x=217 y=32 width=23 height=24 xoffset=-4 yoffset=8 xadvance=11 page=0 chnl=0 letter="@"
char id=65 x=2 y=60 width=23 height=24 xoffset=-4 yoffset=6 xadvance=11 page=0 chnl=0 letter="A"
char id=66 x=2 y=112 width=21 height=24 xoffset=-3 yoffset=6 xadvance=10 page=0 chnl=0 letter="B"
char id=67 x=25 y=112 width=21 height=24 xoffset=-3 yoffset=6 xadvance=10 page=0 chnl=0 letter="C"
char id=68 x=48 y=112 width=21 height=24 xoffset=-3 yoffset=6 xadvance=10 page=0 chnl=0 letter="D"
char id=69 x=71 y=112 width=21 height=24 xoffset=-3 yoffset=6 xadvance=10 page=0 chnl=0 letter="E"
char id=70 x=94 y=112 width=21 height=24 xoffset=-3 yoffset=6 xadvance=10 page=0 chnl=0 letter="F"
char id=71 x=117 y=112 width=21 height=24 xoffset=-3 yoffset=6 xadvance=10 page=0 chnl=0 letter="G"
char id=72 x=140 y=112 width=21 height=24 xoffset=-3 yoffset=6 xadvance=10 page=0 chnl=0 letter="H"
char id=73 x=163 y=112 width=21 height=24 xoffset=-3 yoffset=6 xadvance=10 page=0 chnl=0 letter="I"
char id=74 x=186 y=112 width=21 height=24 xoffset=-3 yoffset=6 xadvance=10 page=0 chnl=0 letter="J"
char id=75 x=201 y=60 width=22 height=24 xoffset=-3 yoffset=6 xadvance=11 page=0 chnl=0 letter="K"
char id=76 x=209 y=112 width=21 height=24 xoffset=-3 yoffset=6 xadvance=10 page=0 chnl=0 letter="L"
char id=77 x=27 y=60 width=23 height=24 xoffset=-4 yoffset=6 xadvance=11 page=0 chnl=0 letter="M"
char id=78 x=2 y=138 width=21 height=24 xoffset=-3 yoffset=6 xadvance=10 page=0 chnl=0 letter="N"
char id=79 x=52 y=60 width=23 height=24 xoffset=-4 yoffset=6 xadvance=11 page=0 chnl=0 letter="O"
char id=80 x=25 y=138 width=21 height=24 xoffset=-3 yoffset=6 xadvance=10 page=0 chnl=0 letter="P"
char id=81 x=183 y=2 width=23 height=26 xoffset=-4 yoffset=6 xadvance=11 page=0 chnl=0 letter="Q"
char id=82 x=48 y=138 width=21 height=24 xoffset=-3 yoffset=6 xadvance=10 page=0 chnl=0 letter="R"
char id=83 x=71 y=138 width=21 height=24 xoffset=-3 yoffset=6 xadvance=10 page=0 chnl=0 letter="S"
char id=84 x=94 y=138 width=21 height=24 xoffset=-3 yoffset=6 xadvance=10 page=0 chnl=0 letter="T"
char id=85 x=117 y=138 width=21 height=24 xoffset=-3 yoffset=6 xadvance=10 page=0 chnl=0 letter="U"
char id=86 x=77 y=60 width=23 height=24 xoffset=-4 yoffset=6 xadvance=11 page=0 chnl=0 letter="V"
char id=87 x=102 y=60 width=23 height=24 xoffset=-4 yoffset=6 xadvance=11 page=0 chnl=0 letter="W"
char id=88 x=127 y=60 width=23 height=24 xoffset=-4 yoffset=6 xadvance=11 page=0 chnl=0 letter="X"
char id=89 x=152 y=60 width=23 height=24 xoffset=-4 yoffset=6 xadvance=11 page=0 chnl=0 letter="Y"
char id=90 x=140 y=138 width=21 height=24 xoffset=-3 yoffset=6 xadvance=10 page=0 chnl=0 letter="Z"
char id=91 x=105 y=2 width=17 height=28 xoffset=-3 yoffset=5 xadvance=6 page=0 chnl=0 letter="["
char id=92 x=88 y=32 width=19 height=25 xoffset=-4 yoffset=5 xadvance=7 page=0 chnl=0 letter="\"
char id=93 x=124 y=2 width=17 height=28 xoffset=-3 yoffset=5 xadvance=6 page=0 chnl=0 letter="]"
char id=94 x=201 y=164 width=23 height=21 xoffset=-4 yoffset=5 xadvance=11 page=0 chnl=0 letter="^"
char id=95 x=2 y=236 width=21 height=15 xoffset=-3 yoffset=18 xadvance=10 page=0 chnl=0 letter="_"
char id=96 x=197 y=213 width=18 height=17 xoffset=-4 yoffset=5 xadvance=6 page=0 chnl=0 letter="`"
char id=97 x=52 y=190 width=22 height=21 xoffset=-4 yoffset=9 xadvance=10 page=0 chnl=0 letter="a"
char id=98 x=163 y=138 width=21 height=24 xoffset=-3 yoffset=6 xadvance=10 page=0 chnl=0 letter="b"
char id=99 x=25 y=213 width=20 height=21 xoffset=-3 yoffset=9 xadvance=9 page=0 chnl=0 letter="c"
char id=100 x=186 y=138 width=21 height=24 xoffset=-3 yoffset=6 xadvance=10 page=0 chnl=0 letter="d"
char id=101 x=47 y=213 width=20 height=21 xoffset=-3 yoffset=9 xadvance=9 page=0 chnl=0 letter="e"
char id=102 x=209 y=138 width=21 height=24 xoffset=-3 yoffset=6 xadvance=10 page=0 chnl=0 letter="f"
char id=103 x=21 y=32 width=21 height=25 xoffset=-3 yoffset=9 xadvance=10 page=0 chnl=0 letter="g"
char id=104 x=2 y=164 width=21 height=24 xoffset=-3 yoffset=6 xadvance=10 page=0 chnl=0 letter="h"
char id=105 x=128 y=32 width=17 height=25 xoffset=-1 yoffset=5 xadvance=8 page=0 chnl=0 letter="i"
char id=106 x=2 y=2 width=19 height=28 xoffset=-2 yoffset=5 xadvance=9 page=0 chnl=0 letter="j"
char id=107 x=115 y=164 width=20 height=24 xoffset=-2 yoffset=6 xadvance=10 page=0 chnl=0 letter="k"
char id=108 x=147 y=32 width=17 height=25 xoffset=-1 yoffset=5 xadvance=8 page=0 chnl=0 letter="l"
char id=109 x=2 y=190 width=23 height=21 xoffset=-4 yoffset=9 xadvance=11 page=0 chnl=0 letter="m"
char id=110 x=99 y=190 width=21 height=21 xoffset=-3 yoffset=9 xadvance=10 page=0 chnl=0 letter="n"
char id=111 x=122 y=190 width=21 height=21 xoffset=-3 yoffset=9 xadvance=10 page=0 chnl=0 letter="o"
char id=112 x=25 y=164 width=21 height=24 xoffset=-3 yoffset=9 xadvance=10 page=0 chnl=0 letter="p"
char id=113 x=48 y=164 width=21 height=24 xoffset=-3 yoffset=9 xadvance=10 page=0 chnl=0 letter="q"
char id=114 x=145 y=190 width=21 height=21 xoffset=-3 yoffset=9 xadvance=10 page=0 chnl=0 letter="r"
char id=115 x=69 y=213 width=19 height=21 xoffset=-2 yoffset=9 xadvance=9 page=0 chnl=0 letter="s"
char id=116 x=137 y=164 width=20 height=24 xoffset=-3 yoffset=6 xadvance=9 page=0 chnl=0 letter="t"
char id=117 x=168 y=190 width=21 height=21 xoffset=-3 yoffset=9 xadvance=10 page=0 chnl=0 letter="u"
char id=118 x=191 y=190 width=21 height=21 xoffset=-3 yoffset=9 xadvance=10 page=0 chnl=0 letter="v"
char id=119 x=27 y=190 width=23 height=21 xoffset=-4 yoffset=9 xadvance=11 page=0 chnl=0 letter="w"
char id=120 x=214 y=190 width=21 height=21 xoffset=-3 yoffset=9 xadvance=10 page=0 chnl=0 letter="x"
char id=121 x=44 y=32 width=21 height=25 xoffset=-3 yoffset=9 xadvance=10 page=0 chnl=0 letter="y"
char id=122 x=2 y=213 width=21 height=21 xoffset=-3 yoffset=9 xadvance=10 page=0 chnl=0 letter="z"
char id=123 x=23 y=2 width=19 height=28 xoffset=-4 yoffset=5 xadvance=7 page=0 chnl=0 letter="{"
char id=124 x=143 y=2 width=15 height=28 xoffset=-3 yoffset=5 xadvance=4 page=0 chnl=0 letter="|"
char id=125 x=44 y=2 width=19 height=28 xoffset=-4 yoffset=5 xadvance=7 page=0 chnl=0 letter="}"
char id=126 x=172 y=213 width=23 height=17 xoffset=-4 yoffset=10 xadvance=11 page=0 chnl=0 letter="~"
kernings count=0
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions Samples/MonoGameGumInCode/MonoGameGumInCode/Game1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ private static void CreateLayout()
nineSlice.Height = 48;
container.Children.Add(nineSlice);

var customText = new TextRuntime();
customText.Width = 300;
customText.UseCustomFont = true;
customText.CustomFontFile = "WhitePeaberryOutline/WhitePeaberryOutline.fnt";
customText.Text = "Hello, I am using a custom font.\nPretty cool huh?";
container.Children.Add(customText);

}

private static void AddText(ContainerRuntime container, string text)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
<None Update="Content\Frame.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Content\WhitePeaberryOutline\WhitePeaberryOutline.fnt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Content\WhitePeaberryOutline\WhitePeaberryOutline.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Target Name="RestoreDotnetTools" BeforeTargets="Restore">
<Message Text="Restoring dotnet tools" Importance="High" />
Expand Down

0 comments on commit 272b8d3

Please sign in to comment.