Reverted metric precision

parent 69773c78
......@@ -211,7 +211,7 @@ texture_font_init(texture_font_t *self)
self->lcd_weights[3] = 0x40;
self->lcd_weights[4] = 0x10;
if (!texture_font_load_face(self, self->size))
if (!texture_font_load_face(self, self->size * 100.f))
return -1;
self->underline_position = self->face->underline_position / (float)(HRESf*HRESf) * self->size;
......@@ -229,9 +229,9 @@ texture_font_init(texture_font_t *self)
}
metrics = self->face->size->metrics;
self->ascender = (metrics.ascender) / 64.0;
self->descender = (metrics.descender) / 64.0;
self->height = (metrics.height) / 64.0;
self->ascender = (metrics.ascender >> 6) / 100.f;
self->descender = (metrics.descender >> 6) / 100.f;
self->height = (metrics.height >> 6) / 100.f;
self->linegap = self->height - self->ascender + self->descender;
/* NULL is a special glyph */
......@@ -401,45 +401,45 @@ texture_font_load_face( texture_font_t *self, float size )
__FILENAME__, __LINE__, FT_Errors[error].code, FT_Errors[error].message);
goto cleanup_face;
}
}
if( texture_is_color_font( self ) ) {
/* Select best size */
if (self->face->num_fixed_sizes == 0) {
freetype_error( error, "FT_Error (%s:%d) : no fixed size in color font\n",
__FILENAME__, __LINE__);
goto cleanup_face;
}
if( texture_is_color_font( self ) ) {
/* Select best size */
if (self->face->num_fixed_sizes == 0) {
freetype_error( error, "FT_Error (%s:%d) : no fixed size in color font\n",
__FILENAME__, __LINE__);
goto cleanup_face;
}
int best_match = 0;
int diff = abs((int)size - self->face->available_sizes[0].width);
for (int i = 1; i < self->face->num_fixed_sizes; ++i) {
int ndiff = abs((int)size - self->face->available_sizes[i].width);
if (ndiff < diff) {
best_match = i;
diff = ndiff;
}
int best_match = 0;
int diff = abs((int)size - self->face->available_sizes[0].width);
for (int i = 1; i < self->face->num_fixed_sizes; ++i) {
int ndiff = abs((int)size - self->face->available_sizes[i].width);
if (ndiff < diff) {
best_match = i;
diff = ndiff;
}
error = FT_Select_Size(self->face, best_match);
self->scale = self->size / self->face->available_sizes[best_match].width;
if(error) {
freetype_error( error, "FT_Error (%s:%d, code 0x%02x) : %s\n",
__FILENAME__, __LINE__, FT_Errors[error].code, FT_Errors[error].message);
goto cleanup_face;
}
} else {
/* Set char size */
error = FT_Set_Char_Size(self->face, (int)(size * HRES), 0, DPI * HRES, DPI);
}
error = FT_Select_Size(self->face, best_match);
self->scale = self->size / self->face->available_sizes[best_match].width;
if(error) {
freetype_error( error, "FT_Error (%s:%d, code 0x%02x) : %s\n",
__FILENAME__, __LINE__, FT_Errors[error].code, FT_Errors[error].message);
goto cleanup_face;
}
} else {
/* Set char size */
error = FT_Set_Char_Size(self->face, (int)(size * HRES), 0, DPI * HRES, DPI);
if(error) {
freetype_error( error, "FT_Error (%s:%d, code 0x%02x) : %s\n",
__FILENAME__, __LINE__, FT_Errors[error].code, FT_Errors[error].message);
goto cleanup_face;
}
if(error) {
freetype_error( error, "FT_Error (%s:%d, code 0x%02x) : %s\n",
__FILENAME__, __LINE__, FT_Errors[error].code, FT_Errors[error].message);
goto cleanup_face;
}
/* Set transform matrix */
FT_Set_Transform(self->face, &matrix, NULL);
}
/* Set transform matrix */
FT_Set_Transform(self->face, &matrix, NULL);
return 1;
......@@ -749,7 +749,7 @@ cleanup_stroker:
for( i = 0; i < src_h; i++ )
{
//difference between width and pitch: https://www.freetype.org/freetype2/docs/reference/ft2-basic_types.html#FT_Bitmap
memcpy( dst_ptr, src_ptr, ft_bitmap.width);
memcpy( dst_ptr, src_ptr, ft_bitmap.width << (self->atlas->depth == 4 ? 2 : 0));
dst_ptr += tgt_w * self->atlas->depth;
src_ptr += ft_bitmap.pitch;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment