Skip to content

Commit 642d992

Browse files
committed
Add custom LCD filter weights
1 parent c1294d1 commit 642d992

File tree

3 files changed

+49
-2
lines changed

3 files changed

+49
-2
lines changed

doc/source/api.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,15 @@ TrueType information
134134
TT_WEIGHT_CLASS
135135
TT_FS_SELECTION
136136

137+
LCD Filtering
138+
-------------
139+
140+
.. autosummary::
141+
:toctree: _generated
142+
143+
set_lcd_filter
144+
set_lcd_filter_weights
145+
137146
Basic Types
138147
-----------
139148

docstrings/lcd.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,10 @@
4141
Parameters
4242
----------
4343
44-
filter : `RENDER_MODE` constant
44+
filter : `LCD_FILTER` constant
4545
4646
Notes
4747
-----
48-
4948
This feature is always disabled by default. Clients must make an
5049
explicit call to this function with a `filter` value other than
5150
`LCD_FILTER.NONE` in order to enable it.
@@ -57,6 +56,23 @@
5756
FreeType.
5857
"""
5958

59+
set_lcd_filter_weights = """
60+
Enable LCD filter with custom weights.
61+
62+
Parameters
63+
----------
64+
a, b, c, d, e : int
65+
The filter weights
66+
67+
Notes
68+
-----
69+
Due to PATENTS covering subpixel rendering, this function doesn't do
70+
anything except raising `NotImplementedError` if the configuration
71+
macro ``FT_CONFIG_OPTION_SUBPIXEL_RENDERING`` is not defined in your
72+
build of the library, which should correspond to all default builds of
73+
FreeType.
74+
"""
75+
6076

6177
LCD_FILTER = """
6278
Identifies various types of LCD filters.

src/freetypy.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,30 @@ py_set_lcd_filter(PyObject *self, PyObject *args, PyObject *kwargs)
9191
}
9292

9393

94+
PyObject *
95+
py_set_lcd_filter_weights(PyObject *self, PyObject *args, PyObject *kwargs)
96+
{
97+
char filters[5];
98+
99+
static char *kwlist[] = {"filter", NULL};
100+
101+
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "bbbbb:set_lcd_filter_weights", kwlist,
102+
&filters[0], &filters[1], &filters[2],
103+
&filters[3], &filters[4])) {
104+
return NULL;
105+
}
106+
107+
if (ftpy_exc(FT_Library_SetLcdFilterWeights(get_ft_library(), filters))) {
108+
return NULL;
109+
}
110+
111+
Py_RETURN_NONE;
112+
}
113+
114+
94115
static PyMethodDef module_methods[] = {
95116
{"set_lcd_filter", (PyCFunction)py_set_lcd_filter, METH_VARARGS|METH_KEYWORDS, doc_set_lcd_filter},
117+
{"set_lcd_filter_weights", (PyCFunction)py_set_lcd_filter_weights, METH_VARARGS|METH_KEYWORDS, doc_set_lcd_filter_weights},
96118
{NULL} /* Sentinel */
97119
};
98120

0 commit comments

Comments
 (0)