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

Problem with custom font and rich texts. #133

Open
2ant opened this issue Jul 8, 2022 · 11 comments
Open

Problem with custom font and rich texts. #133

2ant opened this issue Jul 8, 2022 · 11 comments

Comments

@2ant
Copy link

2ant commented Jul 8, 2022

Hi, thanks for GeonBit, i learning to use it and monogame and i managed to use font overide to get this :

image

but when i try this :

image

i get that :

image

i would like that result :

image

which i got with two normal paragraphs and some spaces.

Why do the {{GOLD}} change the spaces between characters only in rich text ?

@RonenNess
Copy link
Owner

Interesting, looks like a bug. Is the {{GOLD}} the only difference? All other parameters are the same?

If you add {{DEFAULT}} at the end of the text, does it somehow solve it?

@2ant
Copy link
Author

2ant commented Jul 8, 2022

{{GOLD}} is the only difference and {{DEFAULT}} does not solve this.

When i run this code :

Paragraph paragraph = new Paragraph(text: " item grade :",  anchor: Anchor.TopLeft, color: Color.White, scale: 1f, size: new Vector2(1280, 720));
paragraph.FontOverride = Game1.ActionFigure;
panel2.AddChild(paragraph);
             
paragraph = new Paragraph(text: "                     legendary", anchor: Anchor.TopLeft, color: Color.Gold, scale: 1f, size: new Vector2(1280, 720));
paragraph.FontOverride = Game1.ActionFigure;
panel2.AddChild(paragraph);

var richParagraph = new RichParagraph(" item grade : {{GOLD}}legendary{{DEFAULT}}", Anchor.TopLeft, scale: 1f);
richParagraph.FontOverride = Game1.ActionFigure;
panel.AddChild(richParagraph);

I get this result :

image

@MrCapitalG
Copy link
Contributor

Is the font you are using a monospaced font? I know in the past I have run into trouble when I wasn't using monospaced fonts as GeonBit.UI is designed for those types of fonts.

I tested your code using the standard font and it looked as expected.

@2ant
Copy link
Author

2ant commented Jul 9, 2022

It seems that the font i use here and another one i was planning on using are not monospaced.

I a newbie in all of this, what are my options ?

Is there a simple way that i could use to achieve the same result as as rich paragraph ?

i think the best i can achieve is this :

image

Which give me this result :

image

Thanks for your time

@RonenNess
Copy link
Owner

Hi, thanks @MrCapitalG, good catch ;)

@2ant you can try looking for a monospace version of your font maybe it exists out there. Alternatively, you can try using this:

https://github.com/cpitclaudel/monospacifier

Haven't tried it myself just found it, but it has a lot of stars so it's probably decent enough.

@2ant
Copy link
Author

2ant commented Jul 9, 2022

Could not use monospacifier due to my inexperience.

I tried modifying the font with another software, tried other versions of the font and i get the "Cannot use non-monospace fonts!" error everytime.

The only font that i was able to use is the images earlier.

All the other versions of that font that i found gave me the error.

@MrCapitalG
Copy link
Contributor

@2ant If your able to share/attach your font, I'd be happy to give a shot at trying to make it a monospace font using that python tool.

@2ant
Copy link
Author

2ant commented Jul 9, 2022

This is the one i managed to use : ActionFigure BB_0.zip

But i would like to use this one too : Friend or Foe Tall BB.zip

but i get the "non-monospace" error with it

Thank you again for your help

@MrCapitalG
Copy link
Contributor

MrCapitalG commented Jul 9, 2022

Hey @2ant I've attached a monospacified version of that ActionFigure font that appears to work pretty well. Sorry for the long name of the file, it's just what the monospacifier program produced, I'm sure there's control over naming it somewhere in that application. Keep in mind I wouldn't expect any program that claims to do this, is going to be able to do it perfectly I'd still expect some glyph overlapping here or there but it's a lot better and does provide at least a gateway to bringing non-monospaced fonts into GeonBit.UI.

000ActionFigureTeddyBear_monospacified_for_000ActionFigureTeddyBear.zip

GeonBit UI Examples_2022-07-09_14-26-47

@2ant
Copy link
Author

2ant commented Jul 9, 2022

@MrCapitalG Thank you, i will do more tests but i tried it with 2 color tag and it works !

Was it complicated to monospacify the font ?

I may need help in the far future to do other fonts.

In the meantime i will try to use some fonts from here :

https://en.wikipedia.org/wiki/List_of_monospaced_typefaces

and here :

https://hail2u.github.io/mn/

Thank you all for your help, i will be back with more questions when i progress on my project.

@MrCapitalG
Copy link
Contributor

It wasn't at all obvious but once I figured it out it wasn't bad, I'll try to list out the steps I took. Mind you, you'll need Python installed on your machine. I'm also assuming a windows platform here as that is what I'm using.

  1. Download and install the latest Windows release for FontForge as monospacifier is dependent upon this application
  2. Execute the 'fontforge-console.bat' file found in C:\Program Files (x86)\FontForgeBuilds; as I understand it this sets up the path on your machine so you can run fontforge as a python library from the command prompt
  3. Download or simply copy/paste the monospacifier python script from https://github.com/cpitclaudel/monospacifier/blob/master/monospacifier.py and save it on your machine in the C:\Program Files (x86)\FontForgeBuilds\bin directory
  4. Now create two folders; you can name them whatever you like but I went with 'inputs' and 'references' in that same C:\Program Files (x86)\FontForgeBuilds\bin folder
  5. Now I just copied the non-monospaced font(s) into each of these directories
  6. Finally issue the command
    ffpython monospacifier.py --inputs ./inputs/* --references ./references/ActionFigureBB_0.ttf and press enter, it should then generate your monospaced version in the C:\Program Files (x86)\FontForgeBuilds\bin

I don't fully understand the inputs and references folders; it seems to use a variety of fonts to actually build monospaced fonts or something, so I'm nearly positive I could be doing this better. The project suggests looking at their MAKE file to see how they do things.

Anyway once you have your monospaced version of the font, you just install into your monogame font like any other.

There IS a flag to rename the font it looks like --rename 'from' 'to' so use that so you don't get silly long font names :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants