Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
tkarabela committed May 5, 2024
2 parents 2497833 + f3b178f commit ed2257e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
7 changes: 5 additions & 2 deletions pysubs2/formats/substation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import logging
import re
import warnings
from numbers import Number
from typing import Any, Union, Optional, Dict, Tuple, List, TextIO

from .base import FormatBase
Expand Down Expand Up @@ -352,8 +351,12 @@ def field_to_string(f: str, v: Any, line: Union[SSAEvent, SSAStyle]) -> str:
return str(alignment.value)
elif isinstance(v, bool):
return "-1" if v else "0"
elif isinstance(v, (str, Number)):
elif isinstance(v, int):
return str(v)
elif isinstance(v, float):
return str(int(v) if v.is_integer() else v)
elif isinstance(v, str):
return v
elif isinstance(v, Color):
if format_ == "ass":
return color_to_ass_rgba(v)
Expand Down
2 changes: 1 addition & 1 deletion tests/data/subtitle_with_attached_fonts_pysubs2_ref.ass
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ PlayResY: 0

[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Default,Arial,20.0,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100.0,100.0,0.0,0.0,1,2.0,2.0,2,10,10,10,1
Style: Default,Arial,20,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,2,2,2,10,10,10,1

[Fonts]
fontname: EBGaramond08-Italic_0.ttf
Expand Down
2 changes: 1 addition & 1 deletion tests/data/subtitle_with_attached_images_pysubs2_ref.ass
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ YCbCr Matrix: None

[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Default,Arial,48.0,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100.0,100.0,0.0,0.0,1,2.0,2.0,2,10,10,10,1
Style: Default,Arial,48,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,2,2,2,10,10,10,1

[Graphics]
filename: github.jpg
Expand Down
12 changes: 6 additions & 6 deletions tests/formats/test_substation.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Default,Arial,20.0,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100.0,100.0,0.0,0.0,1,2.0,2.0,2,10,10,10,1
Style: topleft,Arial,20.0,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,-1,0,0,0,100.0,100.0,0.0,0.0,1,2.0,2.0,7,10,10,10,1
Style: left,Arial,20.0,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100.0,100.0,0.0,0.0,1,2.0,2.0,4,10,10,10,1
Style: Default,Arial,20,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,2,2,2,10,10,10,1
Style: topleft,Arial,20,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,-1,0,0,0,100,100,0,0,1,2,2,7,10,10,10,1
Style: left,Arial,20,&H00FFFFFF,&H000000FF,&H00000000,&H00000000,0,0,0,0,100,100,0,0,1,2,2,4,10,10,10,1
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Expand All @@ -44,9 +44,9 @@
[V4 Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, TertiaryColour, BackColour, Bold, Italic, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, AlphaLevel, Encoding
Style: Default,Arial,20.0,16777215,255,0,0,0,0,1,2.0,2.0,2,10,10,10,0,1
Style: topleft,Arial,20.0,16777215,255,0,0,-1,0,1,2.0,2.0,5,10,10,10,0,1
Style: left,Arial,20.0,16777215,255,0,0,0,0,1,2.0,2.0,9,10,10,10,0,1
Style: Default,Arial,20,16777215,255,0,0,0,0,1,2,2,2,10,10,10,0,1
Style: topleft,Arial,20,16777215,255,0,0,-1,0,1,2,2,5,10,10,10,0,1
Style: left,Arial,20,16777215,255,0,0,0,0,1,2,2,9,10,10,10,0,1
[Events]
Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Expand Down

0 comments on commit ed2257e

Please sign in to comment.