kenji123 / as3captionslib

An AS3 library for various subtitle formats.
http://www.kenshisoft.com/projects-resos/as3captionslib/
GNU General Public License v3.0
5 stars 1 forks source link

font creation #1

Open ludicch opened 10 years ago

ludicch commented 10 years ago

for me i had to change the regExp to accept files generated by Aegisub editor:

            var styleV5RegExp:RegExp = /(.*),(.*),(\d*),&H(.{0,8}?),&H(.{0,8}?),&H(.{0,8}?),&H(.{0,8}?),(-?\d),(-?\d),(-?\d),(-?\d),(\d*),(\d*),(\d*\.?\d*?),(\d*\.?\d*?),(\d*),(\d*\.?\d*?),(\d*\.?\d*?),(\d*),(\d*),(\d*),(\d*),(\d*)$/im;
            var eventV5RegExp:RegExp = /(\d),(\d:\d\d:\d\d.\d\d),(\d:\d\d:\d\d.\d\d),(.*?),(.*?),(\d{1,4}),(\d{1,4}),(\d{1,4}),(.*?),(.*)$/i;

i also had a problem with the missing a description how to generate fonts. however in the meantime i solved the issue.

also i wondered what license your library is based on. there is a gpl and a lgpl file in the code, but it's no specified what applies.

thanks

kenji123 commented 10 years ago

Thanks. I was aware of the parsing issue, just haven't had time to commit the fix. If you want, you can do a pull request for those changes and I'll merge it with master. If not, I'll commit those changes this weekend.

Yeah. Again, busy with other stuff. I'll try to do some kind of guide for that soon, as there are a few things to consider when creating proper fonts to use with the library. In the mean time take a look at this python script which basically automates the process. I've only tested it on Linux, but with some effort Windows and Mac OS X should work, too. Dependencies for it are here (exclude mkvtoolnix).

The license is LGPL. Both files are there cause last I checked it's a requirement to have both files distributed together, or something like that.

ludicch commented 10 years ago

thanks for the info's.

i have some special requirements for the usage of the subtitles. i use it for speech bubbles. i needed to modify a bit and add some features. i have added a individual width limit to the text.

in ASSRenderer.as

            // added this
            var effectParms:Array = event.effect.split(";");
            for each (var parm:String in effectParms) {
                if (parm.length == 0) {
                    continue;
                }
                // limit width of string
                if (parm.substr(0,1) == "w") {
                    var wrapMaxWidth:int = parseInt(parm.substr(1), 10);
                    marginRect.width = Math.min(wrapMaxWidth, marginRect.width);                    
                }
            }
            // the code is added before (line 1100)
            caption.makeLines(caption_ ? caption.getMarginRect() : marginRect);

i can now add a list of tags (w400) to the effects to individually limit the width. now it sometimes happends that the last line is cut off. likely because the height is not accordingly updated. do you have a simple idea how to better implement a individual width maximum?

the width and height calculated and available when the "onCaptionDisplayed" is fired is quite a bit off for top aligned subtitles. i use this information to add the speech-bubble in the background when a label is displayed. maybe it's correct as well and my interpretation of the alignment is wrong. i can well live with the data by using middle and bottom aligned texts. however it may indicate a problem.

kenji123 commented 10 years ago
  1. For custom widths make sure that the subtitle script you're using has wrap style set to 1 or 2 (depending on if you use/want \N and \n). You didn't mention it so, I'm just stating it. This could be the cause of the last line missing.
  2. How are you accessing the width and height values? For .ass you should access the rectangle object like so:
private function myEventHandler(event:ICaption):void {
    // this returns a rectangle object that should have the correct width and height values
    ((ASSCaption)event).getRect();
}
  1. Are you're visually comparing a preview in Aegisub and the output from the library? If so, are you already using custom fonts? This could be one possible reason. DefineFont4 that is used by TextLine does not return correct font height (size) for fonts. DefineFont3 (not supported by TextLine, only TextField) does. as3captionslib checks for a DefineFont3 loaded font just for a correct font height before falling back to DefineFont4. If you're just using device fonts, the font height would be correct regardless. Otherwise, there may indeed be a bug when it comes to top aligned subtitles.