Add option to disable X axis font's pre-scaling
If used pre-scaling along X null the effect of the font's hinting.
This commit is contained in:
parent
4d3693479d
commit
3c3662b3ba
|
@ -20,8 +20,8 @@ public:
|
||||||
// Conventional LUT values: (1./3., 2./9., 1./9.)
|
// Conventional LUT values: (1./3., 2./9., 1./9.)
|
||||||
// The values below are fine tuned as in the Elementary Plot library.
|
// The values below are fine tuned as in the Elementary Plot library.
|
||||||
|
|
||||||
FR_Impl(bool hinting, bool kerning, bool subpixel, float gamma_value) :
|
FR_Impl(bool hinting, bool kerning, bool subpixel, bool prescale_x, float gamma_value) :
|
||||||
m_renderer(hinting, kerning, subpixel),
|
m_renderer(hinting, kerning, subpixel, prescale_x),
|
||||||
m_gamma_lut(double(gamma_value)),
|
m_gamma_lut(double(gamma_value)),
|
||||||
m_lcd_lut(0.448, 0.184, 0.092),
|
m_lcd_lut(0.448, 0.184, 0.092),
|
||||||
m_subpixel(subpixel)
|
m_subpixel(subpixel)
|
||||||
|
@ -40,10 +40,11 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
FR_Renderer *FR_Renderer_New(unsigned int flags, float gamma) {
|
FR_Renderer *FR_Renderer_New(unsigned int flags, float gamma) {
|
||||||
bool hinting = ((flags & FR_HINTING) != 0);
|
bool hinting = ((flags & FR_HINTING) != 0);
|
||||||
bool kerning = ((flags & FR_KERNING) != 0);
|
bool kerning = ((flags & FR_KERNING) != 0);
|
||||||
bool subpixel = ((flags & FR_SUBPIXEL) != 0);
|
bool subpixel = ((flags & FR_SUBPIXEL) != 0);
|
||||||
return new FR_Impl(hinting, kerning, subpixel, gamma);
|
bool prescale_x = ((flags & FR_PRESCALE_X) != 0);
|
||||||
|
return new FR_Impl(hinting, kerning, subpixel, prescale_x, gamma);
|
||||||
}
|
}
|
||||||
|
|
||||||
FR_Bitmap* FR_Bitmap_New(FR_Renderer *font_renderer, int width, int height) {
|
FR_Bitmap* FR_Bitmap_New(FR_Renderer *font_renderer, int width, int height) {
|
||||||
|
|
|
@ -18,9 +18,10 @@ struct FR_Impl;
|
||||||
typedef struct FR_Impl FR_Renderer;
|
typedef struct FR_Impl FR_Renderer;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
FR_HINTING = 1 << 0,
|
FR_HINTING = 1 << 0,
|
||||||
FR_KERNING = 1 << 2,
|
FR_KERNING = 1 << 1,
|
||||||
FR_SUBPIXEL = 1 << 3,
|
FR_SUBPIXEL = 1 << 2,
|
||||||
|
FR_PRESCALE_X = 1 << 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -27,6 +27,7 @@ class font_renderer_alpha
|
||||||
bool m_hinting;
|
bool m_hinting;
|
||||||
bool m_kerning;
|
bool m_kerning;
|
||||||
bool m_subpixel;
|
bool m_subpixel;
|
||||||
|
bool m_prescale_x;
|
||||||
|
|
||||||
bool m_font_loaded;
|
bool m_font_loaded;
|
||||||
|
|
||||||
|
@ -37,12 +38,13 @@ class font_renderer_alpha
|
||||||
public:
|
public:
|
||||||
typedef agg::pixfmt_alpha8::color_type color_type;
|
typedef agg::pixfmt_alpha8::color_type color_type;
|
||||||
|
|
||||||
font_renderer_alpha(bool hinting, bool kerning, bool subpixel):
|
font_renderer_alpha(bool hinting, bool kerning, bool subpixel, bool prescale_x):
|
||||||
m_feng(),
|
m_feng(),
|
||||||
m_fman(m_feng),
|
m_fman(m_feng),
|
||||||
m_hinting(hinting),
|
m_hinting(hinting),
|
||||||
m_kerning(kerning),
|
m_kerning(kerning),
|
||||||
m_subpixel(subpixel),
|
m_subpixel(subpixel),
|
||||||
|
m_prescale_x(prescale_x),
|
||||||
m_font_loaded(false),
|
m_font_loaded(false),
|
||||||
m_curves(m_fman.path_adaptor()),
|
m_curves(m_fman.path_adaptor()),
|
||||||
m_trans(m_curves, m_mtx)
|
m_trans(m_curves, m_mtx)
|
||||||
|
@ -77,7 +79,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_font_height(double height) {
|
void set_font_height(double height) {
|
||||||
const double scale_x = 100.0;
|
const double scale_x = (m_prescale_x ? 100.0 : 1.0);
|
||||||
m_feng.height(height);
|
m_feng.height(height);
|
||||||
if (m_subpixel) {
|
if (m_subpixel) {
|
||||||
const int subpixel_scale = 3;
|
const int subpixel_scale = 3;
|
||||||
|
@ -92,7 +94,7 @@ public:
|
||||||
RenSolid& ren_solid, const color_type color,
|
RenSolid& ren_solid, const color_type color,
|
||||||
int codepoint, double& x, double& y, int subpixel_scale)
|
int codepoint, double& x, double& y, int subpixel_scale)
|
||||||
{
|
{
|
||||||
const double scale_x = 100;
|
const double scale_x = (m_prescale_x ? 100.0 : 1.0);
|
||||||
|
|
||||||
// Represent the delta in x scaled by scale_x.
|
// Represent the delta in x scaled by scale_x.
|
||||||
double x_delta = 0;
|
double x_delta = 0;
|
||||||
|
|
|
@ -149,7 +149,7 @@ RenFont* ren_load_font(const char *filename, float size) {
|
||||||
font->size = size;
|
font->size = size;
|
||||||
|
|
||||||
const float gamma = 1.5;
|
const float gamma = 1.5;
|
||||||
font->renderer = FR_Renderer_New(FR_HINTING | FR_SUBPIXEL, gamma);
|
font->renderer = FR_Renderer_New(FR_HINTING | FR_SUBPIXEL | FR_PRESCALE_X, gamma);
|
||||||
if (FR_Load_Font(font->renderer, filename)) {
|
if (FR_Load_Font(font->renderer, filename)) {
|
||||||
free(font);
|
free(font);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue