Revision: 13545
http://sourceforge.net/p/foray/code/13545
Author: victormote
Date: 2025-04-29 21:01:37 +0000 (Tue, 29 Apr 2025)
Log Message:
-----------
Fix some signedness problems.
Modified Paths:
--------------
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap00Table.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java
trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap06Table.java
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap00Table.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap00Table.java 2025-04-29 19:38:33 UTC (rev 13544)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap00Table.java 2025-04-29 21:01:37 UTC (rev 13545)
@@ -91,7 +91,7 @@
public int encode(final int codePoint) {
if (codePoint > -1
&& codePoint < this.glyphIdArray.length) {
- return this.glyphIdArray[codePoint];
+ return Byte.toUnsignedInt(this.glyphIdArray[codePoint]);
} else {
return -1;
}
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java 2025-04-29 19:38:33 UTC (rev 13544)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap04Table.java 2025-04-29 21:01:37 UTC (rev 13545)
@@ -157,18 +157,19 @@
@Override
public int encode(final int codePoint) {
for (int segmentIndex = 0; segmentIndex < this.endCode.length; segmentIndex++) {
- if (Short.toUnsignedInt(this.endCode[segmentIndex]) >= codePoint) {
- if (this.startCode[segmentIndex] <= codePoint) {
+ final int unsignedEndCode = Short.toUnsignedInt(this.endCode[segmentIndex]);
+ if (unsignedEndCode >= codePoint) {
+ final int unsignedStartCode = Short.toUnsignedInt(this.startCode[segmentIndex]);
+ if (unsignedStartCode <= codePoint) {
if (this.noncontiguousIndexes[segmentIndex] == null) {
/* Contiguous range. */
- final int provisionalIndex =
- codePoint +
- this.idDelta[segmentIndex];
+ final int unsignedIdDelta = this.idDelta[segmentIndex];
+ final int provisionalIndex = codePoint + unsignedIdDelta;
return provisionalIndex % Character.MAX_VALUE;
} else {
/* Non-contiguous range. */
final short[] glyphIndexes = this.noncontiguousIndexes[segmentIndex];
- return glyphIndexes[codePoint - Short.toUnsignedInt(this.startCode[segmentIndex])];
+ return Short.toUnsignedInt(glyphIndexes[codePoint - unsignedStartCode]);
}
} else {
/* Since the segments are sorted by ending index, none of the remaining segments qualify. */
Modified: trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap06Table.java
===================================================================
--- trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap06Table.java 2025-04-29 19:38:33 UTC (rev 13544)
+++ trunk/foray/foray-font/src/main/java/org/foray/font/ttf/table/Cmap06Table.java 2025-04-29 21:01:37 UTC (rev 13545)
@@ -102,10 +102,11 @@
@Override
public int encode(final int codePoint) {
- if (codePoint >= this.firstCode
- && codePoint < (this.firstCode + this.glyphIndexArray.length)) {
- final int index = codePoint + this.firstCode;
- return this.glyphIndexArray[index];
+ final int unsignedFirstCode = Short.toUnsignedInt(this.firstCode);
+ if (codePoint >= unsignedFirstCode
+ && codePoint < (unsignedFirstCode + this.glyphIndexArray.length)) {
+ final int index = codePoint + unsignedFirstCode;
+ return Short.toUnsignedInt(this.glyphIndexArray[index]);
} else {
return -1;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|