[vlc-devel] [PATCH 1/2] freetype: fix subtitle text does not show correctly on OS/2
Thomas Guillem
thomas at gllm.fr
Mon Mar 1 14:06:51 UTC 2021
Hello,
Why not using the same commit message as your 3.0 patches?
Otherwise, LGTM
On Mon, Mar 1, 2021, at 13:28, KO Myung-Hun wrote:
> Updated.
>
> KO Myung-Hun wrote:
> > ---
> > modules/text_renderer/freetype/freetype.c | 42 +++++++++++++++++++-
> > modules/text_renderer/freetype/freetype.h | 3 +-
> > modules/text_renderer/freetype/text_layout.c | 7 ----
> > 3 files changed, 41 insertions(+), 11 deletions(-)
> >
> > diff --git a/modules/text_renderer/freetype/freetype.c b/modules/text_renderer/freetype/freetype.c
> > index 3303e46000..15c62e05a7 100644
> > --- a/modules/text_renderer/freetype/freetype.c
> > +++ b/modules/text_renderer/freetype/freetype.c
> > @@ -815,6 +815,44 @@ static void FreeStylesArray( text_style_t **pp_styles, size_t i_styles )
> > free( pp_styles );
> > }
> >
> > +#ifdef __OS2__
> > +# define ToUCS4( in, outsize ) ToUCS4(( in ), ( outsize ))
> > +
> > +static void *( ToUCS4 )( const char *in, size_t *outsize )
> > +{
> > + uint16_t *psz_ucs2;
> > + size_t i_ucs4_bytes;
> > + uni_char_t *psz_ucs4;
> > + int i_len;
> > +
> > + psz_ucs2 = ToCharset( FREETYPE_TO_UCS, in, outsize );
> > + if( !psz_ucs2 )
> > + return NULL;
> > +
> > + i_ucs4_bytes = *outsize * 2;
> > + /* Realloc including NULL-terminator */
> > + psz_ucs4 = realloc( psz_ucs2, i_ucs4_bytes + sizeof( *psz_ucs4 ));
> > + if( unlikely( !psz_ucs4 ) )
> > + {
> > + free( psz_ucs2 );
> > +
> > + return NULL;
> > + }
> > +
> > + psz_ucs2 = ( uint16_t * )psz_ucs4;
> > + i_len = i_ucs4_bytes / sizeof( *psz_ucs4 );
> > + /* Copy including NULL-terminator */
> > + for( int i = i_len; i >= 0; --i )
> > + psz_ucs4[ i ] = psz_ucs2[ i ];
> > +
> > + *outsize = i_ucs4_bytes;
> > +
> > + return psz_ucs4;
> > +}
> > +#else
> > +# define ToUCS4( in, outsize ) ToCharset( FREETYPE_TO_UCS, ( in ), ( outsize ))
> > +#endif
> > +
> > static size_t AddTextAndStyles( filter_sys_t *p_sys,
> > const char *psz_text, const char *psz_rt,
> > const text_style_t *p_style,
> > @@ -822,7 +860,7 @@ static size_t AddTextAndStyles( filter_sys_t *p_sys,
> > {
> > /* Convert chars to unicode */
> > size_t i_bytes;
> > - uni_char_t *p_ucs4 = ToCharset( FREETYPE_TO_UCS, psz_text, &i_bytes );
> > + uni_char_t *p_ucs4 = ToUCS4( psz_text, &i_bytes );
> > if( !p_ucs4 )
> > return 0;
> >
> > @@ -878,7 +916,7 @@ static size_t AddTextAndStyles( filter_sys_t *p_sys,
> > ruby_block_t *p_rubyblock = NULL;
> > if( psz_rt )
> > {
> > - p_ucs4 = ToCharset( FREETYPE_TO_UCS, psz_rt, &i_bytes );
> > + p_ucs4 = ToUCS4( psz_rt, &i_bytes );
> > if( !p_ucs4 )
> > return 0;
> > p_rubyblock = malloc(sizeof(ruby_block_t));
> > diff --git a/modules/text_renderer/freetype/freetype.h b/modules/text_renderer/freetype/freetype.h
> > index ee69304ab9..d41acabc21 100644
> > --- a/modules/text_renderer/freetype/freetype.h
> > +++ b/modules/text_renderer/freetype/freetype.h
> > @@ -56,11 +56,10 @@
> > # define FT_MulFix(v, s) (((v)*(s))>>16)
> > #endif
> >
> > +typedef uint32_t uni_char_t;
> > #ifdef __OS2__
> > -typedef uint16_t uni_char_t;
> > # define FREETYPE_TO_UCS "UCS-2LE"
> > #else
> > -typedef uint32_t uni_char_t;
> > # if defined(WORDS_BIGENDIAN)
> > # define FREETYPE_TO_UCS "UCS-4BE"
> > # else
> > diff --git a/modules/text_renderer/freetype/text_layout.c b/modules/text_renderer/freetype/text_layout.c
> > index baee972832..fe60784da9 100644
> > --- a/modules/text_renderer/freetype/text_layout.c
> > +++ b/modules/text_renderer/freetype/text_layout.c
> > @@ -760,17 +760,10 @@ static int ShapeParagraphHarfBuzz( filter_t *p_filter,
> >
> > hb_buffer_set_direction( p_run->p_buffer, p_run->direction );
> > hb_buffer_set_script( p_run->p_buffer, p_run->script );
> > -#ifdef __OS2__
> > - hb_buffer_add_utf16( p_run->p_buffer,
> > - p_paragraph->p_code_points + p_run->i_start_offset,
> > - p_run->i_end_offset - p_run->i_start_offset, 0,
> > - p_run->i_end_offset - p_run->i_start_offset );
> > -#else
> > hb_buffer_add_utf32( p_run->p_buffer,
> > p_paragraph->p_code_points + p_run->i_start_offset,
> > p_run->i_end_offset - p_run->i_start_offset, 0,
> > p_run->i_end_offset - p_run->i_start_offset );
> > -#endif
> > hb_shape( p_hb_font, p_run->p_buffer, 0, 0 );
> >
> > hb_font_destroy( p_hb_font );
>
> --
> KO Myung-Hun
>
> Using Mozilla SeaMonkey 2.7.2
> Under OS/2 Warp 4 for Korean with FixPak #15
> In VirtualBox v6.1.10 on Intel Core i7-3615QM 2.30GHz with 8GB RAM
>
> Korean OS/2 User Community : http://www.os2.kr/
>
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
>
> *Attachments:*
> * v2-0001-freetype-fix-subtitle-text-does-not-show-correctl.patch
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20210301/f0709054/attachment.html>
More information about the vlc-devel
mailing list