First implementation of scaling for retina display
Introduce a new approach that discriminate coordinates in points and pixels. Now all the logic from the Lua side and in rencache is to always use points. The coordinates are converted to pixels only within the renderer, in the file renderer.c. In this way the application logic does not need to care about the scaling of the retina displays. For non-retina display the scaling between points and pixels is equal to one so nothing will change. There is nevertheless a change that leak into the Lua side. The subpixel coordinates are in sub-pixel, not sub-points so they are scaled by the retina scaling factor. But no change in the code is required because the subpixel scaling factor take into account the retina scaling, when present. Because the retina scaling factor is not know when the application starts but only when a window is actually available we introduce a mechanism to render the font with a given scaling factor only from the renderer when they are needed. We use therefore FontDesc to describe the font information but without actually rasterizing the font at a given scale.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
#ifndef FONT_DESC_H
|
||||
#define FONT_DESC_H
|
||||
|
||||
typedef struct RenFont RenFont;
|
||||
|
||||
// FIXME: find a better name for the struct below
|
||||
struct FontScaled {
|
||||
RenFont *font;
|
||||
short int scale;
|
||||
};
|
||||
typedef struct FontScaled FontScaled;
|
||||
|
||||
#define FONT_SCALE_ARRAY_MAX 2
|
||||
|
||||
struct FontDesc {
|
||||
char *filename;
|
||||
float size;
|
||||
unsigned int options;
|
||||
short int tab_size;
|
||||
// FIXME: find a better name for the array below
|
||||
FontScaled fonts_scale[FONT_SCALE_ARRAY_MAX];
|
||||
short int fonts_scale_length;
|
||||
short int recent_font_scale_index; /* More recently scale used. */
|
||||
};
|
||||
typedef struct FontDesc FontDesc;
|
||||
|
||||
int font_desc_get_tab_size(FontDesc *font_desc);
|
||||
void font_desc_set_tab_size(FontDesc *font_desc, int tab_size);
|
||||
void font_desc_free(FontDesc *font_desc);
|
||||
RenFont *font_desc_get_font_at_scale(FontDesc *font_desc, int scale);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user