p_face = LoadFace( p_filter, p_current_style );
}
FT_Face p_current_face = p_face ? p_face : p_sys->p_face;
- if( !p_previous_style || p_previous_style->i_font_size != p_current_style->i_font_size )
+ if( !p_previous_style || p_previous_style->i_font_size != p_current_style->i_font_size ||
+ ((p_previous_style->i_style_flags ^ p_current_style->i_style_flags) & STYLE_HALFWIDTH) )
+
{
- if( FT_Set_Pixel_Sizes( p_current_face, 0, p_current_style->i_font_size ) )
+ int i_font_width = ( p_current_style->i_style_flags & STYLE_HALFWIDTH )
+ ? p_current_style->i_font_size / 2
+ : p_current_style->i_font_size;
+ if( FT_Set_Pixel_Sizes( p_current_face,
+ i_font_width,
+ p_current_style->i_font_size ) )
msg_Err( p_filter, "Failed to set font size to %d", p_current_style->i_font_size );
if( p_sys->p_stroker )
{
.x = pen.x + kerning.x,
.y = pen.y + kerning.y,
};
+
+ int i_font_width = ( p_current_style->i_style_flags & STYLE_HALFWIDTH )
+ ? p_current_style->i_font_size / 2
+ : p_current_style->i_font_size;
FT_Vector pen_shadow_new = {
- .x = pen_new.x + p_sys->f_shadow_vector_x * (p_current_style->i_font_size << 6),
+ .x = pen_new.x + p_sys->f_shadow_vector_x * (i_font_width << 6),
.y = pen_new.y + p_sys->f_shadow_vector_y * (p_current_style->i_font_size << 6),
};
+
FT_Glyph glyph;
FT_BBox glyph_bbox;
FT_Glyph outline;
p_region_in->p_style->i_style_flags & (STYLE_BOLD |
STYLE_ITALIC |
STYLE_UNDERLINE |
- STYLE_STRIKEOUT) );
+ STYLE_STRIKEOUT |
+ STYLE_HALFWIDTH) );
else
{
uint32_t i_font_color = var_InheritInteger( p_filter, "freetype-color" );
CFMutableAttributedStringRef p_attrString);
static void setFontAttibutes(char *psz_fontname, int i_font_size, uint32_t i_font_color,
- bool b_bold, bool b_italic, bool b_underline,
+ bool b_bold, bool b_italic, bool b_underline, bool b_halfwidth,
CFRange p_range, CFMutableAttributedStringRef p_attrString);
/*****************************************************************************
char *psz_string;
int i_font_size;
uint32_t i_font_color;
- bool b_bold, b_uline, b_italic;
+ bool b_bold, b_uline, b_italic, b_halfwidth;
vlc_value_t val;
- b_bold = b_uline = b_italic = FALSE;
+ b_bold = b_uline = b_italic = b_halfwidth = FALSE;
VLC_UNUSED(p_chroma_list);
p_sys->i_font_size = GetFontSize(p_filter);
b_italic = TRUE;
if (p_region_in->p_style->i_style_flags & STYLE_UNDERLINE)
b_uline = TRUE;
+ if (p_region_in->p_style->i_style_flags & STYLE_HALFWIDTH)
+ b_halfwidth = TRUE;
}
} else {
i_font_color = p_sys->i_font_color;
CFRelease(p_cfString);
len = CFAttributedStringGetLength(p_attrString);
- setFontAttibutes(p_sys->psz_font_name, i_font_size, i_font_color, b_bold, b_italic, b_uline,
+ setFontAttibutes(p_sys->psz_font_name, i_font_size, i_font_color, b_bold, b_italic, b_uline, b_halfwidth,
CFRangeMake(0, len), p_attrString);
RenderYUVA(p_filter, p_region_out, p_attrString);
}
static void setFontAttibutes(char *psz_fontname, int i_font_size, uint32_t i_font_color,
- bool b_bold, bool b_italic, bool b_underline,
+ bool b_bold, bool b_italic, bool b_underline, bool b_halfwidth,
CFRange p_range, CFMutableAttributedStringRef p_attrString)
{
CFStringRef p_cfString;
CTFontRef p_font;
+ int i_font_width = b_halfwidth ? i_font_size / 2 : i_font_size;
+ CGAffineTransform trans = CGAffineTransformMakeScale((float)i_font_width
+ / i_font_size, 1.0);
+
// fallback on default
if (!psz_fontname)
psz_fontname = (char *)DEFAULT_FONT;
kCFStringEncodingUTF8);
p_font = CTFontCreateWithName(p_cfString,
(float)i_font_size,
- NULL);
+ &trans);
CFRelease(p_cfString);
CFAttributedStringSetAttribute(p_attrString,
p_range,
setFontAttibutes(psz_fontname,
i_font_size,
i_font_color,
- b_bold, b_italic, b_uline,
+ b_bold, b_italic, b_uline, FALSE,
p_range,
p_attrString);
}
return p_context;
}
-static offscreen_bitmap_t *Compose(int i_text_align,
+static offscreen_bitmap_t *Compose( subpicture_region_t *p_region,
CFMutableAttributedStringRef p_attrString,
unsigned i_width,
unsigned i_height,
CGContextSetTextMatrix(p_context, CGAffineTransformIdentity);
- if (i_text_align == SUBPICTURE_ALIGN_RIGHT)
+ if (p_region->i_align & SUBPICTURE_ALIGN_RIGHT)
horiz_flush = 1.0;
- else if (i_text_align != SUBPICTURE_ALIGN_LEFT)
+ else if ((p_region->i_align & SUBPICTURE_ALIGN_LEFT) == 0)
horiz_flush = 0.5;
else
horiz_flush = 0.0;
double penOffset = CTLineGetPenOffsetForFlush(line, horiz_flush, (i_width - HORIZONTAL_MARGIN*2));
penPosition.x = HORIZONTAL_MARGIN + penOffset;
+ if (horiz_flush == 0.0)
+ penPosition.x = p_region->i_x;
penPosition.y -= ascent;
CGContextSetTextPosition(p_context, penPosition.x, penPosition.y);
CTLineDraw(line, p_context);
unsigned i_width = p_filter->fmt_out.video.i_visible_width;
unsigned i_height = p_filter->fmt_out.video.i_visible_height;
- unsigned i_text_align = p_region->i_align & 0x3;
if (!p_attrString) {
msg_Err(p_filter, "Invalid argument to RenderYUVA");
return VLC_EGENERIC;
}
- p_offScreen = Compose(i_text_align, p_attrString,
+ p_offScreen = Compose( p_region, p_attrString,
i_width, i_height, &i_textblock_height);
if (!p_offScreen) {