BLF: Subpixel Positioning, Anti-aliasing, Hinting #105441

Merged
Harley Acheson merged 11 commits from Harley/blender:Subpixel into main 2023-09-21 22:43:24 +02:00
4 changed files with 2 additions and 20 deletions
Showing only changes of commit d704598d48 - Show all commits

View File

@ -348,8 +348,6 @@ enum {
BLF_BAD_FONT = 1 << 16,
/** This font is managed by the FreeType cache subsystem. */
BLF_CACHED = 1 << 17,
/** For legacy DejaVu. No hinting and half-pixel too tight. */
BLF_LEGACY_SPACING = 1 << 18,
};
#define BLF_DRAW_STR_DUMMY_MAX 1024

View File

@ -360,13 +360,6 @@ BLI_INLINE ft_pix blf_kerning(FontBLF *font, const GlyphBLF *g_prev, const Glyph
{
ft_pix adjustment = 0;
if (font->flags & BLF_LEGACY_SPACING) {
if (font->flags & BLF_HINTING_NONE || !g_prev || g_prev->c == ' ') {
return 0;
}
adjustment -= 32;
}
/* Small adjust if there is hinting. */
adjustment += g->lsb_delta - ((g_prev) ? g_prev->rsb_delta : 0);
@ -420,10 +413,6 @@ BLI_INLINE GlyphBLF *blf_glyph_from_utf8_and_step(FontBLF *font,
BLI_INLINE ft_pix blf_pen_advance(FontBLF *font, ft_pix v, ft_pix step)
{
if (font->flags & BLF_LEGACY_SPACING && font->flags & BLF_HINTING_NONE) {
/* DejaVu with no hinting, so truncate pen position to match old spacing. */
return (v + step) & ~63;
}
return v + step;
}
@ -1433,11 +1422,6 @@ bool blf_ensure_face(FontBLF *font)
font->face_flags = font->face->face_flags;
if (font->face && STREQ(font->face->family_name, "DejaVu Sans")) {
/* So our legacy font can keep its too-tight spacing. */
font->flags |= BLF_LEGACY_SPACING;
}
if (FT_HAS_MULTIPLE_MASTERS(font)) {
FT_Get_MM_Var(font->face, &(font->variations));
}

View File

@ -1159,7 +1159,7 @@ static void blf_glyph_calc_rect_test(rcti *rect, GlyphBLF *g, const int x, const
/* Intentionally check with `g->advance`, because this is the
* width used by BLF_width. This allows that the text slightly
* overlaps the clipping border to achieve better alignment. */
rect->xmin = x;
rect->xmin = x + g->pos[0];
rect->xmax = rect->xmin + MIN2(ft_pix_to_int(g->advance_x), g->dims[0]);
rect->ymin = y;
rect->ymax = rect->ymin - g->dims[1];

View File

@ -1656,7 +1656,7 @@ float UI_text_clip_middle_ex(const uiFontStyle *fstyle,
strwidth = BLF_width(fstyle->uifont_id, str, max_len);
}
//BLI_assert((strwidth <= okwidth) || (okwidth <= 0.0f));
BLI_assert((strwidth <= okwidth) || (okwidth <= 0.0f));
return strwidth;
}