[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/android c201043b4b 7/7: Update Android port
From: |
Po Lu |
Subject: |
feature/android c201043b4b 7/7: Update Android port |
Date: |
Wed, 8 Feb 2023 10:42:55 -0500 (EST) |
branch: feature/android
commit c201043b4b5aff8c4bdcebabb433c6668c2d566e
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
Update Android port
* src/sfnt.c (SCFS): Fix order of arguments.
(sfnt_normalize_vector): Make sure vx and vy are within a
reasonable range.
(sfnt_move): Don't move when vectors are orthogonal.
(main): Update.
---
src/sfnt.c | 33 +++++++++++++++++++++++++++++----
1 file changed, 29 insertions(+), 4 deletions(-)
diff --git a/src/sfnt.c b/src/sfnt.c
index 882df10210..1a5bac2258 100644
--- a/src/sfnt.c
+++ b/src/sfnt.c
@@ -6707,7 +6707,7 @@ sfnt_interpret_trap (struct sfnt_interpreter *interpreter,
c = POP (); \
p = POP (); \
\
- sfnt_interpret_scfs (interpreter, c, p); \
+ sfnt_interpret_scfs (interpreter, p, c); \
}
#define MD() \
@@ -7761,16 +7761,36 @@ sfnt_normalize_vector (sfnt_f26dot6 vx, sfnt_f26dot6 vy,
if (!vx && !vy)
{
- /* The MS scaler seems to do this. */
+ /* If vx and vy are both zero, then just project
+ horizontally. */
+
vector->x = 04000;
vector->y = 0;
return;
}
+ /* Scale vx and vy up if they won't at least make 1. */
+
+ while (!(vx < -32 || vx > 32) && !(vy < -32 || vy > 32))
+ {
+ vx = vx * 2;
+ vy = vy * 2;
+ }
+
/* Compute the magnitude of this vector. */
x_squared = sfnt_mul_f26dot6 (vx, vx);
y_squared = sfnt_mul_f26dot6 (vy, vy);
+ /* x_squared and y_squared can end up too large to fit in a 16.16
+ fixed. Scale both values down until they fit. */
+
+ while (x_squared > 0x200000 || y_squared > 0x200000
+ || x_squared < -0x200000 || y_squared < -0x200000)
+ {
+ x_squared /= 2;
+ y_squared /= 2;
+ }
+
/* Convert to 16.16 for greater precision. */
n = sfnt_add (x_squared, y_squared) * 1024;
@@ -8988,6 +9008,11 @@ sfnt_move (sfnt_f26dot6 *restrict x, sfnt_f26dot6
*restrict y,
dot_product = interpreter->state.vector_dot_product;
+ /* If the vectors are orthogonal, it is impossible to move anywhere,
+ so simply return. */
+ if (!dot_product)
+ return;
+
/* Not actually 26.6, but the multiply-divisions below cancel each
other out, so the result is 26.6. */
versor = interpreter->state.freedom_vector.x;
@@ -14718,8 +14743,8 @@ main (int argc, char **argv)
data[i]->format);
}
-#define FANCY_PPEM 20
-#define EASY_PPEM 20
+#define FANCY_PPEM 12
+#define EASY_PPEM 12
interpreter = NULL;
head = sfnt_read_head_table (fd, font);
- feature/android updated (bd55cca4b8 -> c201043b4b), Po Lu, 2023/02/08
- feature/android 7fb0df0ce2 3/7: Fix graphics state when instructing glyphs, Po Lu, 2023/02/08
- feature/android ad3def330c 2/7: Correctly round bearing values while computing pcm, Po Lu, 2023/02/08
- feature/android 6de4deb47e 6/7: Update Android port, Po Lu, 2023/02/08
- feature/android c201043b4b 7/7: Update Android port,
Po Lu <=
- feature/android 1a70941c8e 1/7: Improve text display on Android port, Po Lu, 2023/02/08
- feature/android 0bd4b7fdab 4/7: Update Android port, Po Lu, 2023/02/08
- feature/android 2c5e36e00b 5/7: Merge remote-tracking branch 'origin/master' into feature/android, Po Lu, 2023/02/08