Exemple #1
0
/**
 * \brief Parse the tail of Dialogue line
 * \param track track
 * \param event parsed data goes here
 * \param str string to parse, zero-terminated
 * \param n_ignored number of format options to skip at the beginning
*/
static int process_event_tail(ASS_Track *track, ASS_Event *event,
                              char *str, int n_ignored)
{
    char *token;
    char *tname;
    char *p = str;
    int i;
    ASS_Event *target = event;

    char *format = strdup(track->event_format);
    char *q = format;           // format scanning pointer

    if (track->n_styles == 0) {
        // add "Default" style to the end
        // will be used if track does not contain a default style (or even does not contain styles at all)
        int sid = ass_alloc_style(track);
        set_default_style(&track->styles[sid]);
        track->default_style = sid;
    }

    for (i = 0; i < n_ignored; ++i) {
        NEXT(q, tname);
    }

    while (1) {
        NEXT(q, tname);
        if (strcasecmp(tname, "Text") == 0) {
            char *last;
            event->Text = strdup(p);
            if (*event->Text != 0) {
                last = event->Text + strlen(event->Text) - 1;
                if (last >= event->Text && *last == '\r')
                    *last = 0;
            }
            ass_msg(track->library, MSGL_DBG2, "Text = %s", event->Text);
            event->Duration -= event->Start;
            free(format);
            return 0;           // "Text" is always the last
        }
        NEXT(p, token);

        ALIAS(End, Duration)    // temporarily store end timecode in event->Duration
        if (0) {            // cool ;)
            INTVAL(Layer)
            STYLEVAL(Style)
            STRVAL(Name)
            STRVAL(Effect)
            INTVAL(MarginL)
            INTVAL(MarginR)
            INTVAL(MarginV)
            TIMEVAL(Start)
            TIMEVAL(Duration)
        }
    }
    free(format);
    return 1;
}
Exemple #2
0
/***********************************
* create new list of gem fonts to reconfigure ttf-gdos for the new gem fonts, 
* then call fontwid.app
*/
static void call_fontwid( void )
{
FILE_NAME *const pf0 = calloc( gem_font_count, sizeof(FILE_NAME) );
register FILE_NAME * pf = pf0;
char *const gempath = ((char**)pInfo)[-1];	/* use ttf-gdos hook */
register int16 i;
int16 r;
int16 save_nr_gemfonts = pInfo->nr_gemfonts;
FILE_NAME *save_gem_font_ptr;

   /******************
   * fontwid saves only 20 chars of file path (including null at end)
   * we need 3 chars for the file name
   */
   #define MAX_PATH_LEN 17
   #define STR(s) #s
   #define STRVAL(s) STR(s)

   if( pInfo->len_gem_path < MAX_PATH_LEN ) {

      /** this fills ttf-gdos info structure with the gem fonts **/
      pInfo->nr_gemfonts = gem_font_count;
      save_gem_font_ptr = ((FILE_NAME**)pInfo)[-2];
      ((FILE_NAME**)pInfo)[-2] = pf0;
      for( i=0; i<gem_font_count; i++, pf++ ) {
	 FONT_FILE_NAME( &pf[0][0], i );
      } /* for */
   
      r = Pexec( 0, "fontwid.app", NULL, NULL );
      if( r != 0 ) {
	 sprintf( err_string, "[3][error while running fontwid.app|%s][OK]", strerror(-r) );
	 form_alert(1, err_string );
      } /* if */
      pInfo->nr_gemfonts = save_nr_gemfonts;;
      ((void**)pInfo)[-2] = save_gem_font_ptr;
   } else {
      sprintf( err_string,
               "[3][gem path '%.*s'|must be less than " STRVAL(MAX_PATH_LEN) " chars][OK]",
	       pInfo->len_gem_path, gempath );
      form_alert(1, err_string );
   } /* if */
   free( pf0 );
   
} /* call_fontwid() */
Exemple #3
0
/**
 * \brief Parse command line style overrides (--ass-force-style option)
 * \param track track to apply overrides to
 * The format for overrides is [StyleName.]Field=Value
 */
void ass_process_force_style(ASS_Track *track)
{
    char **fs, *eq, *dt, *style, *tname, *token;
    ASS_Style *target;
    int sid;
    char **list = track->library->style_overrides;

    if (!list)
        return;

    for (fs = list; *fs; ++fs) {
        eq = strrchr(*fs, '=');
        if (!eq)
            continue;
        *eq = '\0';
        token = eq + 1;

        if (!strcasecmp(*fs, "PlayResX"))
            track->PlayResX = atoi(token);
        else if (!strcasecmp(*fs, "PlayResY"))
            track->PlayResY = atoi(token);
        else if (!strcasecmp(*fs, "Timer"))
            track->Timer = ass_atof(token);
        else if (!strcasecmp(*fs, "WrapStyle"))
            track->WrapStyle = atoi(token);
        else if (!strcasecmp(*fs, "ScaledBorderAndShadow"))
            track->ScaledBorderAndShadow = parse_bool(token);
        else if (!strcasecmp(*fs, "Kerning"))
            track->Kerning = parse_bool(token);

        dt = strrchr(*fs, '.');
        if (dt) {
            *dt = '\0';
            style = *fs;
            tname = dt + 1;
        } else {
            style = NULL;
            tname = *fs;
        }
        for (sid = 0; sid < track->n_styles; ++sid) {
            if (style == NULL
                || strcasecmp(track->styles[sid].Name, style) == 0) {
                target = track->styles + sid;
                if (0) {
                    STRVAL(FontName)
                    COLORVAL(PrimaryColour)
                    COLORVAL(SecondaryColour)
                    COLORVAL(OutlineColour)
                    COLORVAL(BackColour)
                    FPVAL(FontSize)
                    INTVAL(Bold)
                    INTVAL(Italic)
                    INTVAL(Underline)
                    INTVAL(StrikeOut)
                    FPVAL(Spacing)
                    INTVAL(Angle)
                    INTVAL(BorderStyle)
                    INTVAL(Alignment)
                    INTVAL(MarginL)
                    INTVAL(MarginR)
                    INTVAL(MarginV)
                    INTVAL(Encoding)
                    FPVAL(ScaleX)
                    FPVAL(ScaleY)
                    FPVAL(Outline)
                    FPVAL(Shadow)
                }
            }
        }
        *eq = '=';
        if (dt)
            *dt = '.';
    }