Support fractional font sizes.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@23318 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
eugeni 2007-05-14 20:41:14 +00:00
parent b51b557529
commit 8513877fac
6 changed files with 19 additions and 17 deletions

View File

@ -347,7 +347,7 @@ void process_force_style(ass_track_t* track) {
COLORVAL(SecondaryColour)
COLORVAL(OutlineColour)
COLORVAL(BackColour)
INTVAL(FontSize)
FPVAL(FontSize)
INTVAL(Bold)
INTVAL(Italic)
INTVAL(Underline)
@ -435,7 +435,7 @@ static int process_style(ass_track_t* track, char *str)
// this will destroy SSA's TertiaryColour, but i'm not going to use it anyway
if (track->track_type == TRACK_TYPE_SSA)
target->OutlineColour = target->BackColour;
INTVAL(FontSize)
FPVAL(FontSize)
INTVAL(Bold)
INTVAL(Italic)
INTVAL(Underline)

View File

@ -31,7 +31,7 @@ void ass_font_cache_done(void);
typedef struct bitmap_hash_key_s {
char bitmap; // bool : true = bitmap, false = outline
ass_font_t* font;
int size; // font size
double size; // font size
uint32_t ch; // character code
unsigned outline; // border width, 16.16 fixed point value
int bold, italic;
@ -61,7 +61,7 @@ void ass_bitmap_cache_done(void);
// describes an outline glyph
typedef struct glyph_hash_key_s {
ass_font_t* font;
int size; // font size
double size; // font size
uint32_t ch; // character code
int bold, italic;
unsigned scale_x, scale_y; // 16.16

View File

@ -67,8 +67,9 @@ static void update_transform(ass_font_t* font)
{
int i;
FT_Matrix m;
m.xx = double_to_d16(font->scale_x);
m.yy = double_to_d16(font->scale_y);
double size_scale = font->size / (int)font->size;
m.xx = double_to_d16(font->scale_x * size_scale);
m.yy = double_to_d16(font->scale_y * size_scale);
m.xy = m.yx = 0;
for (i = 0; i < font->n_faces; ++i)
FT_Set_Transform(font->faces[i], &m, &font->v);
@ -132,7 +133,7 @@ ass_font_t* ass_font_new(ass_library_t* library, FT_Library ftlibrary, void* fc_
font.scale_x = font.scale_y = 1.;
font.v.x = font.v.y = 0;
font.size = 0;
font.size = 0.;
#ifdef HAVE_FONTCONFIG
font.charset = FcCharSetCreate();
@ -156,13 +157,14 @@ void ass_font_set_transform(ass_font_t* font, double scale_x, double scale_y, FT
/**
* \brief Set font size
**/
void ass_font_set_size(ass_font_t* font, int size)
void ass_font_set_size(ass_font_t* font, double size)
{
int i;
if (font->size != size) {
font->size = size;
for (i = 0; i < font->n_faces; ++i)
FT_Set_Pixel_Sizes(font->faces[i], 0, size);
FT_Set_Pixel_Sizes(font->faces[i], 0, (int)size);
update_transform(font);
}
}
@ -199,7 +201,7 @@ static void ass_font_reselect(void* fontconfig_priv, ass_font_t* font, uint32_t
font->faces[font->n_faces++] = face;
update_transform(font);
FT_Set_Pixel_Sizes(face, 0, font->size);
FT_Set_Pixel_Sizes(face, 0, (int)font->size);
}
#endif

View File

@ -40,7 +40,7 @@ typedef struct ass_font_s {
int n_faces;
double scale_x, scale_y; // current transform
FT_Vector v; // current shift
int size;
double size;
#ifdef HAVE_FONTCONFIG
FcCharSet* charset;
#endif
@ -48,7 +48,7 @@ typedef struct ass_font_s {
ass_font_t* ass_font_new(ass_library_t* library, FT_Library ftlibrary, void* fc_priv, ass_font_desc_t* desc);
void ass_font_set_transform(ass_font_t* font, double scale_x, double scale_y, FT_Vector* v);
void ass_font_set_size(ass_font_t* font, int size);
void ass_font_set_size(ass_font_t* font, double size);
void ass_font_get_asc_desc(ass_font_t* font, uint32_t ch, int* asc, int* desc);
FT_Glyph ass_font_get_glyph(void* fontconfig_priv, ass_font_t* font, uint32_t ch, ass_hinting_t hinting);
FT_Vector ass_font_get_kerning(ass_font_t* font, uint32_t c1, uint32_t c2);

View File

@ -137,7 +137,7 @@ typedef struct render_context_s {
ass_font_t* font;
char* font_path;
int font_size;
double font_size;
FT_Stroker stroker;
int alignment; // alignment overrides go here; if zero, style value will be used
@ -508,7 +508,7 @@ static inline int mystrcmp(char** p, const char* sample) {
double ass_internal_font_size_coeff = 0.8;
static void change_font_size(int sz)
static void change_font_size(double sz)
{
double size = sz * frame_context.font_scale;
@ -696,8 +696,8 @@ static char* parse_tag(char* p, double pwr) {
else
render_context.hspacing = render_context.style->Spacing;
} else if (mystrcmp(&p, "fs")) {
int val;
if (mystrtoi(&p, 10, &val))
double val;
if (mystrtod(&p, &val))
val = render_context.font_size * ( 1 - pwr ) + val * pwr;
else
val = render_context.style->FontSize;

View File

@ -32,7 +32,7 @@
typedef struct ass_style_s {
char* Name;
char* FontName;
int FontSize;
double FontSize;
uint32_t PrimaryColour;
uint32_t SecondaryColour;
uint32_t OutlineColour;