freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Code for scaling FreeType glyphs


From: Paul Sheer
Subject: Code for scaling FreeType glyphs
Date: Mon, 17 Oct 2022 18:47:02 -0500

Hi,

I thought someone might find my implementation here useful:

https://github.com/paulsheer/cooledit/blob/master/widget/aafont.c

This will load glyphs, and force them to xterm style width where
unicode double-wide chars are exactly 2X that of single-width glyphs.
It will properly scale the glyph to fit in a fixed-width bounding box
using correct application of the alpha-channel and with sub-pixel
rendering.

This allows you to use any font as a terminal font, a fixed-width
font, or a proportional-font. (This does not yet implement zero-width
joining characters.)

The prototypes are analogous to XDrawString etc. "Aa" stands for "anti-aliased".

typedef C_wchar_t  int;
int XAaTextWidth (const struct aa_font *f, const char *utf8_string,
int length, int *descent, int scale);
int XAaTextWidth16 (const struct aa_font *f, XChar2b * s, C_wchar_t *
swc, int length, int *descent, int scale);
int XAaDrawImageString (Display * display, Drawable d, GC gc, const
struct aa_font *f, int x, int y, char *utf8_string, int length, int
scale);
int XAaDrawImageString16 (Display * display, Drawable d, GC gc, const
struct aa_font *f, int x, int y, XChar2b * wc, C_wchar_t * swc, int
length, int scale);

Paul



reply via email to

[Prev in Thread] Current Thread [Next in Thread]