libjass icon indicating copy to clipboard operation
libjass copied to clipboard

Font Rendering with @prefixed in front

Open Denoder opened this issue 8 years ago • 6 comments

There's a problem where fonts has @ in front of their names and doesnt get loaded

Example:

http://prntscr.com/dpx2ba

Denoder avatar Dec 31 '16 00:12 Denoder

What exactly is the problem? Do you have an example page I can access?

Arnavion avatar Dec 31 '16 02:12 Arnavion

I temporarily fixed it by doing this:

            Object.defineProperty(Style.prototype, "fontName", {
                /**
                 * The name of this style's font.
                 *
                 * @type {string}
                 */
                get: function () {
                    return this._fontName.replace('@','');
                },
                enumerable: true,
                configurable: true
            });

Basically, when its getting the FontName from the .ass file there are fonts with @ infront of the font name (like @Arial) this would lead to naming the font-family css selector "with" the @ symbol in front of the name.

Denoder avatar Dec 31 '16 03:12 Denoder

As far as I can tell every place that sets the font-family CSS property will quote the font name, so there shouldn't be a problem.

If your change makes it work, it sounds like even though the font file wants a font named @foo the actual font installed on your system is named foo. Is there some ASS feature that the @ in font names is supposed to be ignored?

Arnavion avatar Dec 31 '16 03:12 Arnavion

Okay, I see there is some special meaning to leading @ https://github.com/libass/libass/blob/8b898d6b/libass/ass_parse.c#L107

Arnavion avatar Dec 31 '16 03:12 Arnavion

so do i just leave my change?

Denoder avatar Dec 31 '16 10:12 Denoder

What you have will work. I think a better place to strip the leading @ will be in SpanStyles when setting the CSS property (in case there is some reason to keep the @ around for something else), but the end result will be the same for now.

Arnavion avatar Jan 03 '17 21:01 Arnavion