| 417 | } |
| 418 | |
| 419 | static int add_style(hb_subtitle_style_context_t *ctx, |
| 420 | char ** style, ssa_style_indices_t *field_indices) |
| 421 | { |
| 422 | const char * name; |
| 423 | const char * value; |
| 424 | int size; |
| 425 | uint32_t rgb; |
| 426 | uint32_t alpha; |
| 427 | uint32_t flag; |
| 428 | int style_index; |
| 429 | |
| 430 | if (style == NULL) |
| 431 | { |
| 432 | return 0; |
| 433 | } |
| 434 | if (ctx->styles_count + 1 > ctx->styles_size) |
| 435 | { |
| 436 | void * tmp; |
| 437 | ctx->styles_size = (ctx->styles_count + 1) * 2; |
| 438 | |
| 439 | tmp = realloc(ctx->styles, ctx->styles_size * |
| 440 | sizeof(hb_subtitle_style_t)); |
| 441 | if (tmp == NULL) |
| 442 | { |
| 443 | return 1; |
| 444 | } |
| 445 | ctx->styles = tmp; |
| 446 | } |
| 447 | style_index = ctx->styles_count; |
| 448 | |
| 449 | name = field_value(style, field_indices->style_name_index); |
| 450 | if (name == NULL) |
| 451 | { |
| 452 | name = "Default"; |
| 453 | } |
| 454 | if (!strcasecmp(name, "Default")) |
| 455 | { |
| 456 | ctx->style_default = style_index; |
| 457 | ctx->event_style_default = ctx->style_default; |
| 458 | } |
| 459 | ctx->styles[style_index].name = strdup(name); |
| 460 | |
| 461 | value = field_value(style, field_indices->font_name_index); |
| 462 | if (value == NULL) |
| 463 | { |
| 464 | value = HB_FONT_SANS; |
| 465 | } |
| 466 | ctx->styles[style_index].font_name = strdup(value); |
| 467 | |
| 468 | value = field_value(style, field_indices->font_size_index); |
| 469 | if (value == NULL) |
| 470 | { |
| 471 | size = 72; |
| 472 | } |
| 473 | else |
| 474 | { |
| 475 | size = strtol(value, NULL, 0); |
| 476 | } |
no test coverage detected