aboutsummaryrefslogtreecommitdiffstats
path: root/libfonts_calculate_subpixel_order.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--libfonts_calculate_subpixel_order.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/libfonts_calculate_subpixel_order.c b/libfonts_calculate_subpixel_order.c
new file mode 100644
index 0000000..6d26921
--- /dev/null
+++ b/libfonts_calculate_subpixel_order.c
@@ -0,0 +1,60 @@
+/* See LICENSE file for copyright and license details. */
+#include "libfonts.h"
+
+
+enum libfonts_subpixel_order
+libfonts_calculate_subpixel_order(enum libfonts_subpixel_order unrotated, enum libfonts_orientation rotation)
+{
+ int rot;
+
+ switch (rotation) {
+ case LIBFONTS_ORIENTATION_UNKNOWN:
+ default:
+ switch (unrotated) {
+ case LIBFONTS_SUBPIXEL_ORDER_UNKNOWN:
+ case LIBFONTS_SUBPIXEL_ORDER_NONRGB:
+ case LIBFONTS_SUBPIXEL_ORDER_NONLINEAR:
+ case LIBFONTS_SUBPIXEL_ORDER_OTHER:
+ return unrotated;
+ default:
+ return LIBFONTS_SUBPIXEL_ORDER_UNKNOWN;
+ }
+ break;
+
+ case LIBFONTS_ORIENTATION_0_DEGREES_CLOCKWISE:
+ return unrotated;
+
+ case LIBFONTS_ORIENTATION_90_DEGREES_CLOCKWISE:
+ rot = 1;
+ break;
+
+ case LIBFONTS_ORIENTATION_180_DEGREES_CLOCKWISE:
+ rot = 2;
+ break;
+
+ case LIBFONTS_ORIENTATION_270_DEGREES_CLOCKWISE:
+ rot = 3;
+ break;
+
+ case LIBFONTS_ORIENTATION_OTHER:
+ switch (unrotated) {
+ case LIBFONTS_SUBPIXEL_ORDER_UNKNOWN:
+ case LIBFONTS_SUBPIXEL_ORDER_NONRGB:
+ case LIBFONTS_SUBPIXEL_ORDER_NONLINEAR:
+ return unrotated;
+ default:
+ return LIBFONTS_SUBPIXEL_ORDER_NONLINEAR;
+ }
+ break;
+ }
+
+ switch (unrotated) {
+ case LIBFONTS_SUBPIXEL_ORDER_UNKNOWN:
+ case LIBFONTS_SUBPIXEL_ORDER_NONRGB:
+ case LIBFONTS_SUBPIXEL_ORDER_NONLINEAR:
+ case LIBFONTS_SUBPIXEL_ORDER_OTHER:
+ return unrotated;
+ default:
+ return ((unrotated + rot) & 3) + (unrotated & ~3);
+ }
+}