EDITOR PLUGIN: WFN-FontEditor

Started by Rulaman, Thu 27/06/2013 19:19:12

Previous topic - Next topic

Monsieur OUXX

#20
It's a bit cheeky but I have a few requests, I'll just post the list, from easier to harder:
- Bounding box : that each character has a rectangle around it. So that the end-user is sure if there is an actual character to click at that location (possibly entirely black) or if there is nothing
- Click detection: that the click on the characters is not pixel-perfect, but instead the whole rectangle can be clicked anywhere.
- Unsupported formats: that there is a clearer error message when one tries to open an unsupported font format (e.g. 256-characters SCI format)
- Silent "save": that the software's visual feedback is better when the user clicks on "save". For example, when no font is open, if you click on "save", nothing happens. Other example: As it is now, you can open one format, edit it, and then save it (in the same format). You can't save cross-format. When you click on "Save" you'd hope there would be something happening. For example, a popup telling you that you overwrote the actual file. Or an asterisk that was in front of the currently modified file's name (like in any text editor), and the asterisk would disappear. Any visual feedback.
- Non-obvious conversion options : The usual practice in other apps, when one wants to convert, is to "save as". Here, there's a "convert selected" button. ...Selected what? font or character? When I click on that button, nothing happens, but all the open fonts get closed.
- Non-English languages: That it supports 256 characters (possibly in ISO-xxxxx), rather than just 128.




 

Rulaman

Bounding box : The character has a black background, the field itself is dark gray. Look closer. (But the background can't changed at the moment. I must implement it.)

Click detection: You can click the whole character. I didn't see the spot.


Unsupported formats: You can only open FONT.* (SCI), or *.WFN. It isn't important, if the font contain 128 or 256 characters .

Silent "save": What should happen, when you click on save, and nothing is open? You know, that nothing is open. But okay, that's a point. You can save cross format, Use the stand alone variant and click convert. (Description in the manual.)

Non-obvious conversion options : I can't reproduce this bevahiour. Why should all fonts close? (Convert selected character doesn't make any sense. So what?) What did you expect, when you click on the "Convert selected" button? It saves the WFN font in SCI format, when highlighted in the list, or saves a WFN font in SCI format.

Non-English languages: You din't read the manual. It supports 256-character.

Here is a font with 256 character: http://www.adventuregamestudio.co.uk/forums/index.php?topic=48798.msg636465473#msg636465473


80 percent of your request don't make any sense in my opinion, or I didn't understand them.
Zak: Komm mit mir Sushi.
Zak: Come with me Sushi.

Daniel Eakins

#22
Quote from: Monsieur OUXX on Mon 28/10/2013 12:22:30
- Unsupported formats: that there is a clearer error message when one tries to open an unsupported font format (e.g. 256-characters SCI format)
Hi Monsieur OUXX. Font management in the various versions of AGS and related tools is very diverse and there are lots of compatibility issues to consider.

There is something very important to know concerning the "Import over this font" button in AGS. This button can be used to import fonts that are in the TTF format or in the SCI format (whether 128-character or 256-character). What's important to know is that when you import an SCI font in the editor, the editor actually modifies the file slightly, for the purpose of game development. The modified file is not an "original" SCI format anymore; it's a "custom AGS format".

The catch is that the "Import over this font" button can import "original" SCI fonts, but it cannot import "custom AGS format" fonts. Yeah, AGS cannot import its own format; this is a bug in the editor. The fonts that Rulaman linked to in his last post are actually instances of this "custom AGS format", which means that they cannot be imported in AGS using the "Import over this font" button -- this is an issue totally unrelated to the fact that they are 256-character.

The only way to import "custom AGS format" fonts in AGS is to directly replace one of the font files in your game's directory with your new font (renamed) in the Windows explorer. Close and reload your editor to see the change.

What I said above allows you to import any font in AGS. But of course, if you are using AGS 3.2.1 or lower, you will only be able to use the first 128 characters of the font. If you want to use all 256 characters, one way is to use the Draconian split branch of AGS, or the AGS 3.4.0 alpha version (or wait for the stable version of AGS 3.4.0).


EDIT: Another way to have 256-character fonts is to use Calin Leafshade's SpriteFont Renderer plugin. It's probably the best option if you don't want to change your AGS version.
We all have our time machines, don't we?

Monsieur OUXX

#23
Quote from: Daniel Eakins on Mon 28/10/2013 23:43:05
The fonts that Rulaman linked to in his last post are actually instances of this "custom AGS format", which means that they cannot be imported in AGS

Thank god there are guys who make sense of that gigantic mess! :D
Thanks a lot.

@Rulaman: don't get me wrong, your tool is awesome. Most of the confusion came from the bug I encountered (that was causing all the open fonts to close, and nothing to get converted). I cannot seem to reproduce that bug either. I would suspect it happens when the app cannot write the converted font to disk, for any permission reason.

Here are the answers to the other points:







Also, for all those interested in multilingual fonts, this page could come handy : http://www.adventuregamestudio.co.uk/wiki/Fonts
 

Crimson Wizard

@Monsieur OUXX, I can see the difference between "light grey" and "dark grey" even on your picture, so that might be difference in monitor gamma level.

I agree that the constrast between character background and main background is way too low. Different colors and/or grid lines will improve the look greatly.

Monsieur OUXX

Quote from: Crimson Wizard on Thu 14/11/2013 21:00:22
that might be difference in monitor gamma level

In order to make sure it wasn't the reason, I zoomed in using Photoshop! And I used the "magic wand" tool to see if it would select something I didn't see. I believe you guys, but I'm wondering: what kind of wizardry is this? :D
 

Rulaman

Hi Monsieur OUXX,

About your problem with the O, you have to click on the white part: I can't reproduce this.

The other "problem" with the black and dark gray parts, I call this a hidden feature  :grin:.
But you are right, if it is a problem, I could make it clearer (other color) or selectable.

The good part about this tool is, that I delivered the sources, so every one could modify it (If I stopped the support).
Zak: Komm mit mir Sushi.
Zak: Come with me Sushi.

Scavenger

I really like this tool, I didn't find any outstanding bugs, but I did find it kind of hard to use. Apart from the clearer selection as stated before, would it be possible to be able to select characters by typing in the letters in a text box? I find it kind of hard to crossreference the ASCII table and figure out which box I'm clicking on when I have an empty font (which usually have 1x1 hitboxes) and select them for editing. I'd like to know which character I'm on in case two characters are alike. If this function was in there already I'm not sure I was able to find it.

Also, would it be possible to add a test render of the font to see if the font reads correctly without having to run a test game in AGS? Something with pangrams, like
The Quick Brown Fox Jumped Over The Lazy Dog
Falsches Üben von Xylophonmusik quält jeden gröàŸeren Zwerg
El pingüino Wenceslao hizo kilómetros bajo exhaustiva lluvia y frío, añoraba a su querido cachorro.

Those contain most of the extended ASCII characters, I believe. Though just being able to type a word would be awesome.

This program is amazing, though, a real lifesaver for doing >128 characters!

Monsieur OUXX

Quote from: Rulaman on Fri 15/11/2013 16:46:19
The good part about this tool is, that I delivered the sources, so every one could modify it (If I stopped the support).

That's cool.
Could I be as cheeky as to do two more enhancement requests? and those are really important, I believe, in the prduction flow of anyone manipulaitng fonts:
1) to be able to open a 128-chars font and click somewhere to extend it to a 256-characters font (with the 128 extra slots being empty at first).
2) to be able to entirely copy a selected character, to some "clipboard", and then paste it into another character.

That's because most people working with extended Latin characters have to work with commn characters (e.g. "n") and turn them into special ones (e.g. "ñ").

If you did those two things, your tool would become the ultimate tool for AGS fonts.
 

Rulaman

Hi you two (Scavenger and Monsieur OUXX),

first the easier requests.

Monsieur OUXX: 2) You can already copy and paste a character by clicking in the character field on the letter with the right mouse. (Did I mention it in the manual?) You can even paste it in an graphic tool and paste it back, after edited.
Monsieur OUXX: 1) Yeah, I think it could be possible.

Scavenger: You find the underlaying character by stay a while on the character.
Scavenger: The test rendering font is possible. I think about it. (Fixed implemented and freely selectable)

I think I implement a littel change in the background color and the ability to save the few values (color, grid, …) as well.

Greetings

PS: Any futher requests?
Zak: Komm mit mir Sushi.
Zak: Come with me Sushi.

Monsieur OUXX

#30
Quote from: Rulaman on Sat 16/11/2013 20:11:24
PS: Any futher requests?

Yes, since you ask! :) Starting editing a WFN/SCI font from a TTF font. I suppose (it's only a guess) it shouldn't be too hard, since AGS is able to open them and to render them as bitmaps.

Quote from: Rulaman on Sat 16/11/2013 20:11:24
Monsieur OUXX: 1) Yeah, I think it could be possible.

If you implement that: could you add a little label somewhere (anywhere!) saying: "you're currently working with a genuine 128-char SCI file", or "you're currently working with an AGS-only 256-characters SCI file" ? (or something similar). Once you know thet 256-char format is custom to AGS, it seems obvious, but before that it sounds like a puzzle to solve.
 

Rulaman

A bugfix release is out.

Additional features:

Since 1.2.0.1:
- save the selection field background color                                (p/s)
- save the state of the grid option                                             (p/s)
- save the render text                                                                (p/s)
- render the font in an example text                                          (p/s)
- change the color of the selection field with right click on it      (p/s)
- extend the font to 256 character                                             (p/s)
- show, if a font is 128 or 256 characters                                   (p/s)

Download: http://www.file-upload.net/download-8333852/WFN-FontEditor-V1.2.0.1.7z.html
Zak: Komm mit mir Sushi.
Zak: Come with me Sushi.

Crimson Wizard

#32
Is it possible to add few more things to the plugin?
1. Display the code of current character and total number of characters in font.
2. Next/Prev character commands.
3. Goto character (number) command. Alternatively, an option to display character codes in the main view.
4. (Maybe optionally) arrange characters in the uniform grid (aligned strictly by columns & rows). This will make it much easier to overview the font and find characters.
5. Some way to set same size to all characters in font.

Also, I don't really understand, how saving fonts works in plugin? It looks like font always got saved when pane is closed, which makes it impossible to undo changes; unless I miss something. Also, the pane's title shows asteriks (*) sometimes even though I did no changes, and - opposite - does not show it after I did some.


EDIT: Bug found in plugin code:
Spoiler

Code: csharp

                        if ( bmpData.Width <= 8 )
			{
				bytesPerLine = 1;
			}
			else if ( bmpData.Width <= 16 )
			{
				bytesPerLine = 2;
			}
			else if ( bmpData.Width <= 32 )
			{
				bytesPerLine = 3;
			}

[close]
This is incorrect, 3 bytes are for width = 24, and 4 bytes for width 32.
The general formula (used in AGS code) is:
Quote
bytesPerLine = (bmpData.Width - 1) / 8 + 1

Crimson Wizard

#33
I found two more bugs:
1. If you copy anything to the Windows clipboard (e.g. text), then right click on font character and select "Paste", the plugin will throw an exception:
Quote
System.NullReferenceException:
   ÃÂ² Indexed.Image.CopyToBpp(Bitmap b, Int32 bpp)
   ÃÂ² AGS.Plugin.FontEditor.FontEditorPane.MenuPasteClicked(Object sender, EventArgs e)

2. There's a bad bug, but it's a strange one, because it occured only on one computer, and did not on another.
If you extend a 128-character font to 256-characters, and edit only several characters in the middle of the second part, then they never be displayed. It appears that as soon as there's a non-edited character in font, the plugin saves all following characters with Width = 0 and Height = 0, even though some of them have contents (I found this detail only by debugging AGS).

Rulaman

Hi Crimson Wizard,

i'll look into it, when I have the time.
Zak: Komm mit mir Sushi.
Zak: Come with me Sushi.

Crimson Wizard

#35
Another bug: if I create new font, it does not appear under plugin node, so I can't choose it for editing until I reload the project.

UPD I found the bug that breaks font format when there's at least 1 non-edited character, created by extending 128-char font to 256-char. PMed Rulaman about details.
Interesting, the Draconian edition still works well with bad format, because of the way it loads font (it does not parse it, but loads as whole data chunk, same as AGS 3.2.1 did). My reimplementation fails though :).

Alan v.Drake

Quote from: Crimson Wizard on Tue 18/03/2014 08:15:51
[...] Interesting, the Draconian edition still works well with bad format, [...]

I guess it is the zero width/height characters that break this plugin and (I assume) your new code.
In fact I had been wondering why it wouldn't load my font, then realized that the empty characters (due to me importing a bitmap from radiant's fontedit) were blowing up the plugin due to trying to make an invalid 0x0 Bitmap.

- Alan

Crimson Wizard

Quote from: Alan v.Drake on Fri 21/03/2014 18:04:04
Quote from: Crimson Wizard on Tue 18/03/2014 08:15:51
[...] Interesting, the Draconian edition still works well with bad format, [...]

I guess it is the zero width/height characters that break this plugin and (I assume) your new code.
No, zero size is safely handled.
There was simply an incorrect size of data created for new blank characters in the plugin.

abstauber

Unfortunately the stand-alone editor crashes when I try to load anything.
Spoiler

Informationen über das Aufrufen von JIT-Debuggen
anstelle dieses Dialogfelds finden Sie am Ende dieser Meldung.

************** Ausnahmetext **************
System.NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
   bei AGS.Plugin.FontEditor.FontEditorPane..ctor(String filepath, String filename, String fontname)
   bei WFN_FontEditor.MainWindow.FontListBox_SelectedIndexChanged(Object sender, EventArgs e)
   bei System.Windows.Forms.ListBox.OnSelectedIndexChanged(EventArgs e)
   bei System.Windows.Forms.ListBox.WmReflectCommand(Message& m)
   bei System.Windows.Forms.ListBox.WndProc(Message& m)
   bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   bei System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Geladene Assemblys **************
mscorlib
    Assembly-Version: 2.0.0.0.
    Win32-Version: 2.0.50727.3655 (GDR.050727-3600).
    CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll.
----------------------------------------
WFN-FontEditor
    Assembly-Version: 1.2.0.1.
    Win32-Version: 1.2.0.1.
    CodeBase: file:///D:/Eigene%20Dateien/AGS-3.3.0/WFN-FontEditor-V1.2.0.1/standalone/WFN-FontEditor.exe.
----------------------------------------
System.Windows.Forms
    Assembly-Version: 2.0.0.0.
    Win32-Version: 2.0.50727.3645 (GDR.050727-3600).
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll.
----------------------------------------
System
    Assembly-Version: 2.0.0.0.
    Win32-Version: 2.0.50727.3644 (GDR.050727-3600).
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll.
----------------------------------------
System.Drawing
    Assembly-Version: 2.0.0.0.
    Win32-Version: 2.0.50727.3644 (GDR.050727-3600).
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll.
----------------------------------------
AGS.Plugin.FontEditor
    Assembly-Version: 1.2.0.1.
    Win32-Version: 1.2.0.1.
    CodeBase: file:///D:/Eigene%20Dateien/AGS-3.3.0/WFN-FontEditor-V1.2.0.1/standalone/AGS.Plugin.FontEditor.DLL.
----------------------------------------
AGS.Types
    Assembly-Version: 3.2.1.111.
    Win32-Version: 3.2.1.111.
    CodeBase: file:///D:/Eigene%20Dateien/AGS-3.3.0/WFN-FontEditor-V1.2.0.1/standalone/AGS.Types.DLL.
----------------------------------------
System.Xml
    Assembly-Version: 2.0.0.0.
    Win32-Version: 2.0.50727.3654 (GDR.050727-3600).
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll.
----------------------------------------
mscorlib.resources
    Assembly-Version: 2.0.0.0.
    Win32-Version: 2.0.50727.3655 (GDR.050727-3600).
    CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll.
----------------------------------------
System.Windows.Forms.resources
    Assembly-Version: 2.0.0.0.
    Win32-Version: 2.0.50727.3053 (netfxsp.050727-3000).
    CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms.resources/2.0.0.0_de_b77a5c561934e089/System.Windows.Forms.resources.dll.
----------------------------------------

************** JIT-Debuggen **************
Um das JIT-Debuggen (Just-In-Time) zu aktivieren, muss in der
Konfigurationsdatei der Anwendung oder des Computers
(machine.config) der jitDebugging-Wert im Abschnitt system.windows.forms festgelegt werden.
Die Anwendung muss mit aktiviertem Debuggen kompiliert werden.

Zum Beispiel:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

Wenn das JIT-Debuggen aktiviert ist, werden alle nicht behandelten
Ausnahmen an den JIT-Debugger gesendet, der auf dem
Computer registriert ist, und nicht in diesem Dialogfeld behandelt.
[close]
Apart from the reported bugs, it works fine inside the editor.

Rulaman

Hi @all,

sorry for the delay but my pc crashed and now I haev VS only at work.
So it may take longer than I expected.
Zak: Komm mit mir Sushi.
Zak: Come with me Sushi.

SMF spam blocked by CleanTalk