Skip to content

Commit

Permalink
Fixes for Jest's scope, codepage, vertical line artifacting.
Browse files Browse the repository at this point in the history
Fixed jest scope to only look in src folder.
Fixed codepage library patches.
Added padding to glyph cache to fix vertical line artifacting.
  • Loading branch information
ILOVEPIE committed Apr 16, 2024
1 parent ee5e07e commit 233f61d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Sync object
const config = {
verbose: true,
testMatch: ["**/__tests__/**/*.test.js"],
globals: {
"sabre": {
"include": function () {},
Expand Down
4 changes: 2 additions & 2 deletions scripts/commands/update-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ if [ ! -d "$TEMP_DIR/codepage" ]; then
rm -rf "$TEMP_DIR/codepage"
git clone "https://git.sheetjs.com/sheetjs/js-codepage.git" "$TEMP_DIR/codepage"
fi
CUR_DIR ="$PWD"
CUR_DIR="$PWD"
cd "$TEMP_DIR/codepage"
printf '%s\n' "Building codepage dependency..." | tee -a $LOG_FILE
git pull 2>&1 | tee -a $LOG_FILE
make 2>&1 | tee -a $LOG_FILE
bash make.sh "$TOOL_DATA_DIR/codepage.csv" "$TEMP_DIR/codepage.js" cptable 2>&1 | tee -a $LOG_FILE
printf '%s\n' '(function(){' > "$PROJECT_SOURCE_DIR/lib/codepage.js"
cat "$TEMP_DIR/codepage.js" "$TEMP_DIR/codepage/cputils.js" | sed "s#require\('./cptable'\)#cptable#" | sed 's#root\.cptable#root["cptable"]#' | sed 's#cptable = factory(cptable)#root["cptable"] = factory(cptable)#' | sed 's#cpt\.utils#cpt["utils"]#' | sed 's#{ decode: decode, encode: encode, hascp: hascp, magic: magic, cache:cache }#{ "decode": decode, "encode": encode, "hascp": hascp, "magic": magic, "cache":cache }#' >> "$PROJECT_SOURCE_DIR/lib/codepage.js"
cat "$TEMP_DIR/codepage.js" "$TEMP_DIR/codepage/cputils.js" | sed "s#require\('./cptable'\)#cptable#" | sed 's#root\.cptable#root["cptable"]#' | sed 's#cptable = factory(cptable)#root["cptable"] = factory(cptable)#' | sed 's#cpt\.utils#cpt["utils"]#' | sed 's#\.enc#["enc"]#' | sed 's#\.dec#["dec"]#' | sed 's#{ decode: decode, encode: encode, hascp: hascp, magic: magic, cache:cache }#{ "decode": decode, "encode": encode, "hascp": hascp, "magic": magic, "cache":cache }#' >> "$PROJECT_SOURCE_DIR/lib/codepage.js"
printf '%s\n' '}).call(sabre);' >> "$PROJECT_SOURCE_DIR/lib/codepage.js"
rm -f "$TEMP_DIR/codepage.js"
printf '%s\n' "Finished building codepage dependency." | tee -a $LOG_FILE
Expand Down
12 changes: 6 additions & 6 deletions src/lib/codepage.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion src/renderer-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3033,8 +3033,12 @@ const renderer_prototype = global.Object.create(Object, {
* @return {?Array<number>} Results of allocation attempt.
*/
value: function _allocateCacheSpace (requiredWidth, requiredHeight, extraSpace) {
const spacing = 10;
let spacingX, spacingY;
requiredWidth = requiredWidth / this._getCacheWidth();
requiredHeight = requiredHeight / this._getCacheHeight();
requiredWidth += (spacingX = spacing / this._getCacheWidth());
requiredHeight += (spacingY = spacing / this._getCacheHeight());
let result = null;
for(let i = 0; i < this._cacheAvailability.length; i++) {
const area = this._cacheAvailability[i];
Expand All @@ -3056,7 +3060,7 @@ const renderer_prototype = global.Object.create(Object, {
params.push({x:minx,y:miny,x2:maxx,y2:maxy});
}
this._cacheAvailability.splice.apply(this._cacheAvailability,params);
result = [area.x,area.y,requiredWidth,requiredHeight];
result = [area.x+spacingX/2,area.y+spacingY/2,requiredWidth-spacingX,requiredHeight-spacingY];
break;
}
}
Expand Down

0 comments on commit 233f61d

Please sign in to comment.