Scale font sizes, for better accuracy.

svn path=/trunk/netsurf/; revision=8657
This commit is contained in:
John Mark Bell 2009-07-21 16:55:35 +00:00
parent 4ff22c67df
commit 6e13c2fb0a
8 changed files with 20 additions and 12 deletions

View File

@ -270,12 +270,12 @@ struct OutlineFont *ami_open_outline_font(const plot_font_style_t *fstyle)
ysize = fstyle->size;
if(ysize < (option_font_min_size / 10))
ysize = option_font_min_size / 10;
if(ysize < (option_font_min_size / 10) * FONT_SIZE_SCALE)
ysize = (option_font_min_size / 10) * FONT_SIZE_SCALE;
if(ESetInfo(&ofont->olf_EEngine,
OT_DeviceDPI,(72<<16) | 72,
OT_PointHeight,(ysize<<16),
OT_PointHeight,(ysize<<16)/FONT_SIZE_SCALE,
TAG_END) == OTERR_Success)
{
return ofont;

View File

@ -365,7 +365,7 @@ void nsbeos_style_to_font(BFont &font, const plot_font_style_t *style)
}
//fprintf(stderr, "nsbeos_style_to_font: value %f unit %d\n", style->font_size.value.length.value, style->font_size.value.length.unit);
size = fstyle->size;
size = fstyle->size / FONT_SIZE_SCALE;
//XXX: pango stuff ?
if (size < abs(option_font_min_size / 10))

View File

@ -104,12 +104,17 @@ typedef unsigned long plot_font_flags_t;
#define FONTF_OBLIQUE 2
#define FONTF_SMALLCAPS 4
/**
* Scaling factor for font sizes
*/
#define FONT_SIZE_SCALE 1024
/**
* Font style for plotting
*/
typedef struct {
plot_font_generic_family_t family; /**< Generic family to plot with */
int size; /**< Font size, in points */
int size; /**< Font size, in points * FONT_SIZE_SCALE */
int weight; /**< Font weight: value in range [100,900] as per CSS */
plot_font_flags_t flags; /**< Font flags */
colour background; /**< Background colour to blend to, if appropriate */

View File

@ -336,7 +336,7 @@ bool haru_nsfont_apply_style(const plot_font_style_t *fstyle,
LOG(("Setting font: %s", font_name));
#endif
size = fstyle->size;
size = fstyle->size;
if (font != NULL)
size *= pdf_text_scale;
@ -344,6 +344,8 @@ bool haru_nsfont_apply_style(const plot_font_style_t *fstyle,
if (size <= 0)
return true;
size /= FONT_SIZE_SCALE;
if (size > HPDF_MAX_FONTSIZE)
size = HPDF_MAX_FONTSIZE;

View File

@ -262,7 +262,7 @@ static void fb_fill_scalar(const plot_font_style_t *fstyle, FTC_Scaler srec)
srec->face_id = (FTC_FaceID)fb_faces[selected_face];
srec->width = srec->height = fstyle->size * 64;
srec->width = srec->height = (fstyle->size * 64) / FONT_SIZE_SCALE;
srec->pixel = 0;
srec->x_res = srec->y_res = 72;

View File

@ -304,10 +304,10 @@ PangoFontDescription *nsfont_style_to_description(
size = fstyle->size;
if (size < (unsigned)abs(option_font_min_size / 10))
size = option_font_min_size / 10;
if (size < (unsigned)abs(option_font_min_size / 10) * FONT_SIZE_SCALE)
size = (option_font_min_size / 10) * FONT_SIZE_SCALE;
size *= PANGO_SCALE;
size = (size * PANGO_SCALE) / FONT_SIZE_SCALE;
if (fstyle->flags & FONTF_ITALIC)
style = PANGO_STYLE_ITALIC;

View File

@ -35,7 +35,8 @@ void font_plot_style_from_css(const struct css_style *css,
plot_font_style_t *fstyle)
{
fstyle->family = plot_font_generic_family(css->font_family);
fstyle->size = css_len2pt(&css->font_size.value.length, css);
fstyle->size =
css_len2pt(&css->font_size.value.length, css) * FONT_SIZE_SCALE;
fstyle->weight = plot_font_weight(css->font_weight);
fstyle->flags = plot_font_flags(css->font_style, css->font_variant);
fstyle->foreground = css->color;

View File

@ -425,7 +425,7 @@ void nsfont_read_style(const plot_font_style_t *fstyle,
rufl_WEIGHT_900
};
*font_size = fstyle->size * 16.;
*font_size = (fstyle->size * 16) / FONT_SIZE_SCALE;
if (*font_size < option_font_min_size * 1.6)
*font_size = option_font_min_size * 1.6;
if (1600 < *font_size)