Commit bf2f78ca authored by François Cartegnie's avatar François Cartegnie 🤞

vlc_subpicture: add missing text_align

no longer forces text to have same alignment as picture
parent f17a250a
......@@ -61,10 +61,12 @@ struct subpicture_region_t
int i_x; /**< position of region, relative to alignment */
int i_y; /**< position of region, relative to alignment */
int i_align; /**< alignment flags of region and content */
int i_align; /**< alignment flags of region */
int i_alpha; /**< transparency */
/* Parameters for text regions (p_picture to be rendered) */
text_segment_t *p_text; /**< subtitle text, made of a list of segments */
int i_text_align; /**< alignment flags of region content */
bool b_noregionbg; /**< render background under text only */
bool b_gridmode; /** if the decoder sends row/cols based output */
bool b_balanced_text; /** try to balance wrapped text lines */
......@@ -80,10 +82,8 @@ struct subpicture_region_t
#define SUBPICTURE_ALIGN_RIGHT 0x2
#define SUBPICTURE_ALIGN_TOP 0x4
#define SUBPICTURE_ALIGN_BOTTOM 0x8
#define SUBPICTURE_ALIGN_LEAVETEXT 0x10 /**< Align the subpicture, but not the text inside */
#define SUBPICTURE_ALIGN_MASK ( SUBPICTURE_ALIGN_LEFT|SUBPICTURE_ALIGN_RIGHT| \
SUBPICTURE_ALIGN_TOP |SUBPICTURE_ALIGN_BOTTOM| \
SUBPICTURE_ALIGN_LEAVETEXT )
SUBPICTURE_ALIGN_TOP |SUBPICTURE_ALIGN_BOTTOM )
/**
* This function will create a new subpicture region.
*
......
......@@ -507,7 +507,7 @@ static subpicture_t *Subtitle( decoder_t *p_dec, eia608_t *h, mtime_t i_pts )
/* The "leavetext" alignment is a special mode where the subpicture
region itself gets aligned, but the text inside it does not */
p_spu_sys->region.align = SUBPICTURE_ALIGN_TOP|SUBPICTURE_ALIGN_LEFT;
p_spu_sys->region.inner_align = SUBPICTURE_ALIGN_LEAVETEXT;
p_spu_sys->region.inner_align = SUBPICTURE_ALIGN_BOTTOM|SUBPICTURE_ALIGN_LEFT;
p_spu_sys->region.flags = UPDT_REGION_IGNORE_BACKGROUND | UPDT_REGION_USES_GRID_COORDINATES;
/* Set style defaults (will be added to segments if none set) */
......
......@@ -1036,8 +1036,8 @@ static void CEA708SpuConvert( const cea708_window_t *p_w,
[CEA708_ANCHOR_BOTTOM_RIGHT] = SUBPICTURE_ALIGN_BOTTOM|SUBPICTURE_ALIGN_RIGHT,
};
p_region->align = vlc_subpicture_aligns[p_w->anchor_point];
p_region->align |= SUBPICTURE_ALIGN_LEAVETEXT;
}
p_region->inner_align = SUBPICTURE_ALIGN_BOTTOM|SUBPICTURE_ALIGN_LEFT;
}
static subpicture_t *CEA708_BuildSubtitle( cea708_t *p_cea708 )
......
......@@ -75,6 +75,8 @@ static inline void SubpictureUpdaterSysRegionClean(subpicture_updater_sys_region
static inline void SubpictureUpdaterSysRegionInit(subpicture_updater_sys_region_t *p_updtregion)
{
memset(p_updtregion, 0, sizeof(*p_updtregion));
p_updtregion->align = SUBPICTURE_ALIGN_BOTTOM /* CENTER */;
p_updtregion->inner_align = SUBPICTURE_ALIGN_BOTTOM /* CENTER */;
}
static inline subpicture_updater_sys_region_t *SubpictureUpdaterSysRegionNew( )
......@@ -165,7 +167,8 @@ static void SubpictureTextUpdate(subpicture_t *subpic,
pp_last_region = &r->p_next;
r->p_text = text_segment_Copy( p_updtregion->p_segments );
r->i_align = p_updtregion->inner_align | p_updtregion->align; /* we do not support text align by itself */
r->i_align = p_updtregion->align;
r->i_text_align = p_updtregion->inner_align;
r->b_noregionbg = p_updtregion->flags & UPDT_REGION_IGNORE_BACKGROUND;
r->b_gridmode = p_updtregion->flags & UPDT_REGION_USES_GRID_COORDINATES;
......
......@@ -275,7 +275,7 @@ static FT_Vector GetAlignedOffset( const line_desc_t *p_line,
FT_Vector offsets = { 0, 0 };
const int i_text_width = p_textbbox->xMax - p_textbbox->xMin;
if ( p_line->i_width < i_text_width &&
(i_align & (SUBPICTURE_ALIGN_LEFT|SUBPICTURE_ALIGN_LEAVETEXT)) == 0 )
(i_align & SUBPICTURE_ALIGN_LEFT) == 0 )
{
/* Left offset to take into account alignment */
if( i_align & SUBPICTURE_ALIGN_RIGHT )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment