Merge branch 'master' of https://github.com/mozilla/pdf.js into stats
This commit is contained in:
commit
41557d62c0
5
Makefile
5
Makefile
@ -38,6 +38,7 @@ PDF_JS_FILES = \
|
||||
worker.js \
|
||||
../external/jpgjs/jpg.js \
|
||||
jpx.js \
|
||||
bidi.js \
|
||||
$(NULL)
|
||||
|
||||
# make server
|
||||
@ -143,9 +144,9 @@ browser-test:
|
||||
# To install gjslint, see:
|
||||
#
|
||||
# <http://code.google.com/closure/utilities/docs/linter_howto.html>
|
||||
SRC_DIRS := . src utils web test examples/helloworld extensions/firefox \
|
||||
SRC_DIRS := src utils web test examples/helloworld extensions/firefox \
|
||||
extensions/firefox/components extensions/chrome test/unit
|
||||
GJSLINT_FILES = $(foreach DIR,$(SRC_DIRS),$(wildcard $(DIR)/*.js))
|
||||
GJSLINT_FILES = $(foreach DIR, $(SRC_DIRS), $(wildcard $(DIR)/*.js))
|
||||
lint:
|
||||
gjslint --nojsdoc $(GJSLINT_FILES)
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
# PDF.JS
|
||||
|
||||
|
||||
|
||||
pdf.js is an HTML5 technology experiment that explores building a faithful
|
||||
and efficient Portable Document Format (PDF) renderer without native code
|
||||
|
@ -1,18 +1,28 @@
|
||||
<!doctype html>
|
||||
<script>
|
||||
|
||||
function isPdfDownloadable(details) {
|
||||
return details.url.indexOf('pdfjs.action=download') >= 0;
|
||||
}
|
||||
|
||||
chrome.webRequest.onBeforeRequest.addListener(
|
||||
function(details) {
|
||||
if (isPdfDownloadable(details))
|
||||
return;
|
||||
|
||||
var viewerPage = 'content/web/viewer.html';
|
||||
var url = chrome.extension.getURL(viewerPage) + '?file=' + details.url;
|
||||
var url = chrome.extension.getURL(viewerPage) +
|
||||
'?file=' + encodeURIComponent(details.url);
|
||||
return { redirectUrl: url };
|
||||
},
|
||||
{
|
||||
urls: [
|
||||
"http://*/*.pdf",
|
||||
"file://*/*.pdf",
|
||||
"file://*/*.pdf"
|
||||
],
|
||||
types: [ "main_frame" ]
|
||||
},
|
||||
["blocking"]);
|
||||
|
||||
</script>
|
||||
|
||||
|
@ -124,6 +124,19 @@ PdfStreamConverter.prototype = {
|
||||
asyncConvertData: function(aFromType, aToType, aListener, aCtxt) {
|
||||
if (!Services.prefs.getBoolPref('extensions.pdf.js.active'))
|
||||
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
// Ignoring HTTP POST requests -- pdf.js has to repeat the request.
|
||||
var skipConversion = false;
|
||||
try {
|
||||
var request = aCtxt;
|
||||
request.QueryInterface(Ci.nsIHttpChannel);
|
||||
skipConversion = (request.requestMethod === 'POST');
|
||||
} catch (e) {
|
||||
// Non-HTTP request... continue normally.
|
||||
}
|
||||
if (skipConversion)
|
||||
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
// Store the listener passed to us
|
||||
this.listener = aListener;
|
||||
},
|
||||
|
26
external/shelljs/LICENSE
vendored
Normal file
26
external/shelljs/LICENSE
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
Copyright (c) 2012, Artur Adib <aadib@mozilla.com>
|
||||
All rights reserved.
|
||||
|
||||
You may use this project under the terms of the New BSD license as follows:
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of Artur Adib nor the
|
||||
names of the contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL ARTUR ADIB BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
316
external/shelljs/README.md
vendored
Normal file
316
external/shelljs/README.md
vendored
Normal file
@ -0,0 +1,316 @@
|
||||
# ShellJS - Unix shell commands for Node.js [](http://travis-ci.org/arturadib/shelljs)
|
||||
|
||||
ShellJS is a **portable** (Windows included) implementation of Unix shell commands on top of the Node.js API. You can use it to eliminate your shell script's dependency on Unix while still keeping its familiar and powerful commands.
|
||||
|
||||
The project is both [unit-tested](http://travis-ci.org/arturadib/shelljs) and battle-tested at Mozilla's [pdf.js](http://github.com/mozilla/pdf.js).
|
||||
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
require('shelljs/global');
|
||||
|
||||
// Copy files to release dir
|
||||
mkdir('-p', 'out/Release');
|
||||
cp('-R', 'lib/*.js', 'out/Release');
|
||||
|
||||
// Replace macros in each .js file
|
||||
cd('lib');
|
||||
for (file in ls('*.js')) {
|
||||
sed('-i', 'BUILD_VERSION', 'v0.1.2', file);
|
||||
sed('-i', /.*REMOVE_THIS_LINE.*\n/, '', file);
|
||||
sed('-i', /.*REPLACE_LINE_WITH_MACRO.*\n/, cat('macro.js'), file);
|
||||
}
|
||||
cd('..');
|
||||
|
||||
// Run external tool synchronously
|
||||
if (exec('git commit -am "Auto-commit"').code !== 0) {
|
||||
echo('Error: Git commit failed');
|
||||
exit(1);
|
||||
}
|
||||
```
|
||||
|
||||
### Global vs. Local
|
||||
|
||||
The example above uses the convenience script `shelljs/global` to reduce verbosity. If polluting your global namespace is not desirable, simply require `shelljs`.
|
||||
|
||||
Example:
|
||||
|
||||
```javascript
|
||||
var shell = require('shelljs');
|
||||
shell.echo('hello world');
|
||||
```
|
||||
|
||||
### Make tool
|
||||
|
||||
A convenience script `shelljs/make` is also provided to mimic the behavior of a Unix Makefile. In this case all shell objects are global, and command line arguments will cause the script to execute only the corresponding function in the global `target` object. To avoid redundant calls, target functions are executed only once per script.
|
||||
|
||||
Example:
|
||||
|
||||
```javascript
|
||||
//
|
||||
// Example file: make.js
|
||||
//
|
||||
require('shelljs/make');
|
||||
|
||||
target.all = function() {
|
||||
target.bundle();
|
||||
target.docs();
|
||||
}
|
||||
|
||||
// Bundle JS files
|
||||
target.bundle = function() {
|
||||
cd(__dirname);
|
||||
mkdir('build');
|
||||
cd('lib');
|
||||
cat('*.js').to('../build/output.js');
|
||||
}
|
||||
|
||||
// Generate docs
|
||||
target.docs = function() {
|
||||
cd(__dirname);
|
||||
mkdir('docs');
|
||||
cd('lib');
|
||||
for (file in ls('*.js')) {
|
||||
var text = grep('//@', file); // extract special comments
|
||||
text.replace('//@', ''); // remove comment tags
|
||||
text.to('docs/my_docs.md');
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
To run the target `all`, call the above script without arguments: `$ node make`. To run the target `docs`: `$ node make docs`, and so on.
|
||||
|
||||
### Installing
|
||||
|
||||
Via npm:
|
||||
|
||||
```bash
|
||||
$ npm install shelljs
|
||||
```
|
||||
|
||||
Or simply copy `shell.js` into your project's directory, and `require()` accordingly.
|
||||
|
||||
|
||||
<!--
|
||||
|
||||
DO NOT MODIFY BEYOND THIS POINT - IT'S AUTOMATICALLY GENERATED
|
||||
|
||||
-->
|
||||
|
||||
|
||||
# Command reference
|
||||
|
||||
|
||||
All commands run synchronously, unless otherwise stated.
|
||||
|
||||
|
||||
#### cd('dir')
|
||||
Changes to directory `dir` for the duration of the script
|
||||
|
||||
#### pwd()
|
||||
Returns the current directory.
|
||||
|
||||
#### ls([options ,] path [,path ...])
|
||||
#### ls([options ,] path_array)
|
||||
Available options:
|
||||
|
||||
+ `-R`: recursive
|
||||
+ `-a`: all files (include files beginning with `.`)
|
||||
|
||||
Examples:
|
||||
|
||||
```javascript
|
||||
ls('projs/*.js');
|
||||
ls('-R', '/users/me', '/tmp');
|
||||
ls('-R', ['/users/me', '/tmp']); // same as above
|
||||
```
|
||||
|
||||
Returns list of files in the given path, or in current directory if no path provided.
|
||||
For convenient iteration via `for (file in ls())`, the format returned is a hash object:
|
||||
`{ 'file1':null, 'dir1/file2':null, ...}`.
|
||||
|
||||
#### cp('[options ,] source [,source ...], dest')
|
||||
#### cp('[options ,] source_array, dest')
|
||||
Available options:
|
||||
|
||||
+ `-f`: force
|
||||
+ `-r, -R`: recursive
|
||||
|
||||
Examples:
|
||||
|
||||
```javascript
|
||||
cp('file1', 'dir1');
|
||||
cp('-Rf', '/tmp/*', '/usr/local/*', '/home/tmp');
|
||||
cp('-Rf', ['/tmp/*', '/usr/local/*'], '/home/tmp'); // same as above
|
||||
```
|
||||
|
||||
Copies files. The wildcard `*` is accepted.
|
||||
|
||||
#### rm([options ,] file [, file ...])
|
||||
#### rm([options ,] file_array)
|
||||
Available options:
|
||||
|
||||
+ `-f`: force
|
||||
+ `-r, -R`: recursive
|
||||
|
||||
Examples:
|
||||
|
||||
```javascript
|
||||
rm('-rf', '/tmp/*');
|
||||
rm('some_file.txt', 'another_file.txt');
|
||||
rm(['some_file.txt', 'another_file.txt']); // same as above
|
||||
```
|
||||
|
||||
Removes files. The wildcard `*` is accepted.
|
||||
|
||||
#### mv(source [, source ...], dest')
|
||||
#### mv(source_array, dest')
|
||||
Available options:
|
||||
|
||||
+ `f`: force
|
||||
|
||||
Examples:
|
||||
|
||||
```javascript
|
||||
mv('-f', 'file', 'dir/');
|
||||
mv('file1', 'file2', 'dir/');
|
||||
mv(['file1', 'file2'], 'dir/'); // same as above
|
||||
```
|
||||
|
||||
Moves files. The wildcard `*` is accepted.
|
||||
|
||||
#### mkdir([options ,] dir [, dir ...])
|
||||
#### mkdir([options ,] dir_array)
|
||||
Available options:
|
||||
|
||||
+ `p`: full path (will create intermediate dirs if necessary)
|
||||
|
||||
Examples:
|
||||
|
||||
```javascript
|
||||
mkdir('-p', '/tmp/a/b/c/d', '/tmp/e/f/g');
|
||||
mkdir('-p', ['/tmp/a/b/c/d', '/tmp/e/f/g']); // same as above
|
||||
```
|
||||
|
||||
Creates directories.
|
||||
|
||||
#### cat(file [, file ...])
|
||||
#### cat(file_array)
|
||||
|
||||
Examples:
|
||||
|
||||
```javascript
|
||||
var str = cat('file*.txt');
|
||||
var str = cat('file1', 'file2');
|
||||
var str = cat(['file1', 'file2']); // same as above
|
||||
```
|
||||
|
||||
Returns a string containing the given file, or a concatenated string
|
||||
containing the files if more than one file is given (a new line character is
|
||||
introduced between each file). Wildcard `*` accepted.
|
||||
|
||||
#### 'string'.to(file)
|
||||
|
||||
Examples:
|
||||
|
||||
```javascript
|
||||
cat('input.txt').to('output.txt');
|
||||
```
|
||||
|
||||
Analogous to the redirection operator `>` in Unix, but works with JavaScript strings (such as
|
||||
those returned by `cat`, `grep`, etc). _Like Unix redirections, `to()` will overwrite any existing file!_
|
||||
|
||||
#### sed([options ,] search_regex, replace_str, file)
|
||||
Available options:
|
||||
|
||||
+ `-i`: Replace contents of 'file' in-place. _Note that no backups will be created!_
|
||||
|
||||
Examples:
|
||||
|
||||
```javascript
|
||||
sed('-i', 'PROGRAM_VERSION', 'v0.1.3', 'source.js');
|
||||
sed(/.*DELETE_THIS_LINE.*\n/, '', 'source.js');
|
||||
```
|
||||
|
||||
Reads an input string from `file` and performs a JavaScript `replace()` on the input
|
||||
using the given search regex and replacement string. Returns the new string after replacement.
|
||||
|
||||
#### grep(regex_filter, file [, file ...])
|
||||
#### grep(regex_filter, file_array)
|
||||
|
||||
Examples:
|
||||
|
||||
```javascript
|
||||
grep('GLOBAL_VARIABLE', '*.js');
|
||||
```
|
||||
|
||||
Reads input string from given files and returns a string containing all lines of the
|
||||
file that match the given `regex_filter`. Wildcard `*` accepted.
|
||||
|
||||
#### which(command)
|
||||
|
||||
Examples:
|
||||
|
||||
```javascript
|
||||
var nodeExec = which('node');
|
||||
```
|
||||
|
||||
Searches for `command` in the system's PATH. On Windows looks for `.exe`, `.cmd`, and `.bat` extensions.
|
||||
Returns string containing the absolute path to the command.
|
||||
|
||||
#### echo(string [,string ...])
|
||||
|
||||
Examples:
|
||||
|
||||
```javascript
|
||||
echo('hello world');
|
||||
var str = echo('hello world');
|
||||
```
|
||||
|
||||
Prints string to stdout, and returns string with additional utility methods
|
||||
like `.to()`.
|
||||
|
||||
#### exit(code)
|
||||
Exits the current process with the given exit code.
|
||||
|
||||
#### env['VAR_NAME']
|
||||
Object containing environment variables (both getter and setter). Shortcut to process.env.
|
||||
|
||||
#### exec(command [, options] [, callback])
|
||||
Available options (all `false` by default):
|
||||
|
||||
+ `async`: Asynchronous execution. Needs callback.
|
||||
+ `silent`: Do not echo program output to console.
|
||||
|
||||
Examples:
|
||||
|
||||
```javascript
|
||||
var version = exec('node --version', {silent:true}).output;
|
||||
```
|
||||
|
||||
Executes the given `command` _synchronously_, unless otherwise specified.
|
||||
When in synchronous mode returns the object `{ code:..., output:... }`, containing the program's
|
||||
`output` (stdout + stderr) and its exit `code`. Otherwise the `callback` gets the
|
||||
arguments `(code, output)`.
|
||||
|
||||
## Non-Unix commands
|
||||
|
||||
|
||||
#### tempdir()
|
||||
Searches and returns string containing a writeable, platform-dependent temporary directory.
|
||||
Follows Python's [tempfile algorithm](http://docs.python.org/library/tempfile.html#tempfile.tempdir).
|
||||
|
||||
#### exists(path [, path ...])
|
||||
#### exists(path_array)
|
||||
Returns true if all the given paths exist.
|
||||
|
||||
#### error()
|
||||
Tests if error occurred in the last command. Returns `null` if no error occurred,
|
||||
otherwise returns string explaining the error
|
||||
|
||||
#### verbose()
|
||||
Enables all output (default)
|
||||
|
||||
#### silent()
|
||||
Suppresses all output, except for explict `echo()` calls
|
3
external/shelljs/global.js
vendored
Normal file
3
external/shelljs/global.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
var shell = require('./shell.js');
|
||||
for (cmd in shell)
|
||||
global[cmd] = shell[cmd];
|
46
external/shelljs/make.js
vendored
Normal file
46
external/shelljs/make.js
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
require('./global');
|
||||
|
||||
global.target = {};
|
||||
|
||||
// This ensures we only execute the script targets after the entire script has
|
||||
// been evaluated
|
||||
var args = process.argv.slice(2);
|
||||
setTimeout(function() {
|
||||
|
||||
if (args.length === 1 && args[0] === '--help') {
|
||||
console.log('Available targets:');
|
||||
for (t in target)
|
||||
console.log(' ' + t);
|
||||
return;
|
||||
}
|
||||
|
||||
// Wrap targets to prevent duplicate execution
|
||||
for (t in target) {
|
||||
(function(t, oldTarget){
|
||||
|
||||
// Wrap it
|
||||
target[t] = function(force) {
|
||||
if (oldTarget.done && !force)
|
||||
return;
|
||||
oldTarget.done = true;
|
||||
return oldTarget(arguments);
|
||||
}
|
||||
|
||||
})(t, target[t]);
|
||||
}
|
||||
|
||||
// Execute desired targets
|
||||
if (args.length > 0) {
|
||||
args.forEach(function(arg) {
|
||||
if (arg in target)
|
||||
target[arg]();
|
||||
else {
|
||||
console.log('no such target: ' + arg);
|
||||
exit(1);
|
||||
}
|
||||
});
|
||||
} else if ('all' in target) {
|
||||
target.all();
|
||||
}
|
||||
|
||||
}, 0);
|
12
external/shelljs/package.json
vendored
Normal file
12
external/shelljs/package.json
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
{ "name": "shelljs"
|
||||
, "version": "0.0.2pre1"
|
||||
, "author": "Artur Adib <aadib@mozilla.com>"
|
||||
, "description": "Portable Unix shell commands for Node.js"
|
||||
, "keywords": ["unix", "shell", "makefile", "make", "jake", "synchronous"]
|
||||
, "repository": "git://github.com/arturadib/shelljs"
|
||||
, "homepage": "http://github.com/arturadib/shelljs"
|
||||
, "main": "./shell.js"
|
||||
, "scripts": {
|
||||
"test": "node scripts/run-tests"
|
||||
}
|
||||
}
|
1207
external/shelljs/shell.js
vendored
Normal file
1207
external/shelljs/shell.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
409
make.js
Executable file
409
make.js
Executable file
@ -0,0 +1,409 @@
|
||||
#!/usr/bin/env node
|
||||
require('./external/shelljs/make');
|
||||
|
||||
var ROOT_DIR = __dirname + '/', // absolute path to project's root
|
||||
BUILD_DIR = 'build/',
|
||||
BUILD_TARGET = BUILD_DIR + 'pdf.js',
|
||||
FIREFOX_BUILD_DIR = BUILD_DIR + '/firefox/',
|
||||
EXTENSION_SRC_DIR = 'extensions/',
|
||||
GH_PAGES_DIR = BUILD_DIR + 'gh-pages/',
|
||||
REPO = 'git@github.com:mozilla/pdf.js.git',
|
||||
PYTHON_BIN = 'python2.7';
|
||||
|
||||
//
|
||||
// make all
|
||||
//
|
||||
target.all = function() {
|
||||
// Don't do anything by default
|
||||
echo('Please specify a target. Available targets:');
|
||||
for (t in target)
|
||||
if (t !== 'all') echo(' ' + t);
|
||||
};
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Production stuff
|
||||
//
|
||||
|
||||
//
|
||||
// make web
|
||||
// Generates the website for the project, by checking out the gh-pages branch underneath
|
||||
// the build directory, and then moving the various viewer files into place.
|
||||
//
|
||||
target.web = function() {
|
||||
target.production();
|
||||
target.extension();
|
||||
target.pagesrepo();
|
||||
|
||||
cd(ROOT_DIR);
|
||||
echo();
|
||||
echo('### Creating web site');
|
||||
|
||||
cp(BUILD_TARGET, GH_PAGES_DIR + BUILD_TARGET);
|
||||
cp('-R', 'web/*', GH_PAGES_DIR + '/web');
|
||||
cp(FIREFOX_BUILD_DIR + '/*.xpi', FIREFOX_BUILD_DIR + '/*.rdf',
|
||||
GH_PAGES_DIR + EXTENSION_SRC_DIR + 'firefox/');
|
||||
cp(GH_PAGES_DIR + '/web/index.html.template', GH_PAGES_DIR + '/index.html');
|
||||
mv('-f', GH_PAGES_DIR + '/web/viewer-production.html',
|
||||
GH_PAGES_DIR + '/web/viewer.html');
|
||||
cd(GH_PAGES_DIR);
|
||||
exec('git add -A');
|
||||
|
||||
echo();
|
||||
echo("Website built in " + GH_PAGES_DIR);
|
||||
echo("Don't forget to cd into " + GH_PAGES_DIR +
|
||||
" and issue 'git commit' to push changes.");
|
||||
};
|
||||
|
||||
//
|
||||
// make production
|
||||
// Creates production output (pdf.js, and corresponding changes to web/ files)
|
||||
//
|
||||
target.production = function() {
|
||||
target.bundle();
|
||||
target.viewer();
|
||||
};
|
||||
|
||||
//
|
||||
// make bundle
|
||||
// Bundles all source files into one wrapper 'pdf.js' file, in the given order.
|
||||
//
|
||||
|
||||
target.bundle = function() {
|
||||
cd(ROOT_DIR);
|
||||
echo();
|
||||
echo('### Bundling files into ' + BUILD_TARGET);
|
||||
|
||||
// File order matters
|
||||
var SRC_FILES =
|
||||
['core.js',
|
||||
'util.js',
|
||||
'canvas.js',
|
||||
'obj.js',
|
||||
'function.js',
|
||||
'charsets.js',
|
||||
'cidmaps.js',
|
||||
'colorspace.js',
|
||||
'crypto.js',
|
||||
'evaluator.js',
|
||||
'fonts.js',
|
||||
'glyphlist.js',
|
||||
'image.js',
|
||||
'metrics.js',
|
||||
'parser.js',
|
||||
'pattern.js',
|
||||
'stream.js',
|
||||
'worker.js',
|
||||
'../external/jpgjs/jpg.js',
|
||||
'jpx.js',
|
||||
'bidi.js'];
|
||||
|
||||
if (!exists(BUILD_DIR))
|
||||
mkdir(BUILD_DIR);
|
||||
|
||||
cd('src');
|
||||
var bundle = cat(SRC_FILES),
|
||||
bundleVersion = exec('git log --format="%h" -n 1',
|
||||
{silent: true}).output.replace('\n', '');
|
||||
|
||||
sed(/.*PDFJSSCRIPT_INCLUDE_ALL.*\n/, bundle, 'pdf.js')
|
||||
.to(ROOT_DIR + BUILD_TARGET);
|
||||
sed('-i', 'PDFJSSCRIPT_BUNDLE_VER', bundleVersion, ROOT_DIR + BUILD_TARGET);
|
||||
};
|
||||
|
||||
//
|
||||
// make viewer
|
||||
// Changes development <script> tags in our web viewer to use only 'pdf.js'.
|
||||
// Produces 'viewer-production.html'
|
||||
//
|
||||
target.viewer = function() {
|
||||
cd(ROOT_DIR);
|
||||
echo();
|
||||
echo('### Generating production-level viewer');
|
||||
|
||||
cd('web');
|
||||
// Remove development lines
|
||||
sed(/.*PDFJSSCRIPT_REMOVE_CORE.*\n/g, '', 'viewer.html')
|
||||
.to('viewer-production.html');
|
||||
// Introduce snippet
|
||||
sed('-i', /.*PDFJSSCRIPT_INCLUDE_BUILD.*\n/g, cat('viewer-snippet.html'),
|
||||
'viewer-production.html');
|
||||
};
|
||||
|
||||
//
|
||||
// make pagesrepo
|
||||
//
|
||||
// This target clones the gh-pages repo into the build directory. It deletes the current contents
|
||||
// of the repo, since we overwrite everything with data from the master repo. The 'make web' target
|
||||
// then uses 'git add -A' to track additions, modifications, moves, and deletions.
|
||||
target.pagesrepo = function() {
|
||||
cd(ROOT_DIR);
|
||||
echo();
|
||||
echo('### Creating fresh clone of gh-pages');
|
||||
|
||||
if (!exists(BUILD_DIR))
|
||||
mkdir(BUILD_DIR);
|
||||
|
||||
if (!exists(GH_PAGES_DIR)) {
|
||||
echo();
|
||||
echo('Cloning project repo...');
|
||||
echo('(This operation can take a while, depending on network conditions)');
|
||||
exec('git clone -b gh-pages --depth=1 ' + REPO + ' ' + ßGH_PAGES_DIR,
|
||||
{silent: true});
|
||||
echo('Done.');
|
||||
}
|
||||
|
||||
rm('-rf', GH_PAGES_DIR + '/*');
|
||||
mkdir('-p', GH_PAGES_DIR + '/web');
|
||||
mkdir('-p', GH_PAGES_DIR + '/web/images');
|
||||
mkdir('-p', GH_PAGES_DIR + BUILD_DIR);
|
||||
mkdir('-p', GH_PAGES_DIR + EXTENSION_SRC_DIR + '/firefox');
|
||||
};
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Extension stuff
|
||||
//
|
||||
|
||||
var EXTENSION_WEB_FILES =
|
||||
['web/images',
|
||||
'web/viewer.css',
|
||||
'web/viewer.js',
|
||||
'web/viewer.html',
|
||||
'web/viewer-production.html'],
|
||||
EXTENSION_BASE_VERSION = '4bb289ec499013de66eb421737a4dbb4a9273eda',
|
||||
EXTENSION_BUILD_NUMBER;
|
||||
|
||||
//
|
||||
// make extension
|
||||
//
|
||||
target.extension = function() {
|
||||
cd(ROOT_DIR);
|
||||
echo();
|
||||
echo('### Building extensions');
|
||||
|
||||
target.production();
|
||||
target.firefox();
|
||||
target.chrome();
|
||||
};
|
||||
|
||||
target.buildnumber = function() {
|
||||
cd(ROOT_DIR);
|
||||
echo();
|
||||
echo('### Getting extension build number');
|
||||
|
||||
// Build number is the number of commits since base version
|
||||
EXTENSION_BUILD_NUMBER = exec('git log --format=oneline ' +
|
||||
EXTENSION_BASE_VERSION + '..', {silent: true})
|
||||
.output.match(/\n/g).length; // get # of lines in git output
|
||||
|
||||
echo('Extension build number: ' + EXTENSION_BUILD_NUMBER);
|
||||
};
|
||||
|
||||
//
|
||||
// make firefox
|
||||
//
|
||||
target.firefox = function() {
|
||||
cd(ROOT_DIR);
|
||||
echo();
|
||||
echo('### Building Firefox extension');
|
||||
|
||||
var FIREFOX_BUILD_CONTENT_DIR = FIREFOX_BUILD_DIR + '/content/',
|
||||
FIREFOX_CONTENT_DIR = EXTENSION_SRC_DIR + '/firefox/content/',
|
||||
FIREFOX_EXTENSION_FILES_TO_COPY =
|
||||
['*.js',
|
||||
'*.rdf',
|
||||
'components'];
|
||||
FIREFOX_EXTENSION_FILES =
|
||||
['content',
|
||||
'*.js',
|
||||
'install.rdf',
|
||||
'components',
|
||||
'content'];
|
||||
FIREFOX_EXTENSION_NAME = 'pdf.js.xpi',
|
||||
FIREFOX_AMO_EXTENSION_NAME = 'pdf.js.amo.xpi';
|
||||
|
||||
target.production();
|
||||
target.buildnumber();
|
||||
cd(ROOT_DIR);
|
||||
|
||||
// Clear out everything in the firefox extension build directory
|
||||
rm('-rf', FIREFOX_BUILD_DIR);
|
||||
mkdir('-p', FIREFOX_BUILD_CONTENT_DIR);
|
||||
mkdir('-p', FIREFOX_BUILD_CONTENT_DIR + BUILD_DIR);
|
||||
mkdir('-p', FIREFOX_BUILD_CONTENT_DIR + '/web');
|
||||
|
||||
// Copy extension files
|
||||
cd('extensions/firefox');
|
||||
cp('-R', FIREFOX_EXTENSION_FILES_TO_COPY, ROOT_DIR + FIREFOX_BUILD_DIR);
|
||||
cd(ROOT_DIR);
|
||||
|
||||
// Copy a standalone version of pdf.js inside the content directory
|
||||
cp(BUILD_TARGET, FIREFOX_BUILD_CONTENT_DIR + BUILD_DIR);
|
||||
cp('-R', EXTENSION_WEB_FILES, FIREFOX_BUILD_CONTENT_DIR + '/web');
|
||||
rm(FIREFOX_BUILD_CONTENT_DIR + '/web/viewer-production.html');
|
||||
|
||||
// Copy over the firefox extension snippet so we can inline pdf.js in it
|
||||
cp('web/viewer-snippet-firefox-extension.html', FIREFOX_BUILD_CONTENT_DIR + '/web');
|
||||
|
||||
// Modify the viewer so it does all the extension-only stuff.
|
||||
cd(FIREFOX_BUILD_CONTENT_DIR + '/web');
|
||||
sed('-i', /.*PDFJSSCRIPT_INCLUDE_BUNDLE.*\n/, cat(ROOT_DIR + BUILD_TARGET), 'viewer-snippet-firefox-extension.html');
|
||||
sed('-i', /.*PDFJSSCRIPT_REMOVE_CORE.*\n/g, '', 'viewer.html');
|
||||
sed('-i', /.*PDFJSSCRIPT_REMOVE_FIREFOX_EXTENSION.*\n/g, '', 'viewer.html');
|
||||
sed('-i', /.*PDFJSSCRIPT_INCLUDE_FIREFOX_EXTENSION.*\n/, cat('viewer-snippet-firefox-extension.html'), 'viewer.html');
|
||||
cd(ROOT_DIR);
|
||||
|
||||
// We don't need pdf.js anymore since its inlined
|
||||
rm('-Rf', FIREFOX_BUILD_CONTENT_DIR + BUILD_DIR);
|
||||
|
||||
// Update the build version number
|
||||
sed('-i', /PDFJSSCRIPT_BUILD/, EXTENSION_BUILD_NUMBER, FIREFOX_BUILD_DIR + '/install.rdf');
|
||||
sed('-i', /PDFJSSCRIPT_BUILD/, EXTENSION_BUILD_NUMBER, FIREFOX_BUILD_DIR + '/update.rdf');
|
||||
|
||||
// Create the xpi
|
||||
cd(FIREFOX_BUILD_DIR);
|
||||
exec('zip -r ' + FIREFOX_EXTENSION_NAME + ' ' + FIREFOX_EXTENSION_FILES.join(' '));
|
||||
echo('extension created: ' + FIREFOX_EXTENSION_NAME);
|
||||
cd(ROOT_DIR);
|
||||
|
||||
// Build the amo extension too (remove the updateUrl)
|
||||
cd(FIREFOX_BUILD_DIR);
|
||||
sed('-i', /.*updateURL.*\n/, '', 'install.rdf');
|
||||
exec('zip -r ' + FIREFOX_AMO_EXTENSION_NAME + ' ' + FIREFOX_EXTENSION_FILES.join(' '));
|
||||
echo('AMO extension created: ' + FIREFOX_AMO_EXTENSION_NAME);
|
||||
cd(ROOT_DIR);
|
||||
};
|
||||
|
||||
//
|
||||
// make chrome
|
||||
//
|
||||
target.chrome = function() {
|
||||
cd(ROOT_DIR);
|
||||
echo();
|
||||
echo('### Building Chrome extension');
|
||||
|
||||
var CHROME_BUILD_DIR = BUILD_DIR + '/chrome/',
|
||||
CHROME_CONTENT_DIR = EXTENSION_SRC_DIR + '/chrome/content/',
|
||||
CHROME_BUILD_CONTENT_DIR = CHROME_BUILD_DIR + '/content/',
|
||||
CHROME_EXTENSION_FILES =
|
||||
['extensions/chrome/*.json',
|
||||
'extensions/chrome/*.html'];
|
||||
|
||||
target.production();
|
||||
target.buildnumber();
|
||||
cd(ROOT_DIR);
|
||||
|
||||
// Clear out everything in the chrome extension build directory
|
||||
rm('-Rf', CHROME_BUILD_DIR);
|
||||
mkdir('-p', CHROME_BUILD_CONTENT_DIR);
|
||||
mkdir('-p', CHROME_BUILD_CONTENT_DIR + BUILD_DIR);
|
||||
mkdir('-p', CHROME_BUILD_CONTENT_DIR + '/web');
|
||||
|
||||
// Copy extension files
|
||||
cp('-R', CHROME_EXTENSION_FILES, CHROME_BUILD_DIR);
|
||||
|
||||
// Copy a standalone version of pdf.js inside the content directory
|
||||
cp(BUILD_TARGET, CHROME_BUILD_CONTENT_DIR + BUILD_DIR);
|
||||
cp('-R', EXTENSION_WEB_FILES, CHROME_BUILD_CONTENT_DIR + '/web');
|
||||
mv('-f', CHROME_BUILD_CONTENT_DIR + '/web/viewer-production.html',
|
||||
CHROME_BUILD_CONTENT_DIR + '/web/viewer.html');
|
||||
};
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Test stuff
|
||||
//
|
||||
|
||||
//
|
||||
// make test
|
||||
//
|
||||
target.test = function() {
|
||||
target.browsertest();
|
||||
target.unittest();
|
||||
};
|
||||
|
||||
//
|
||||
// make browsertest
|
||||
//
|
||||
target.browsertest = function() {
|
||||
cd(ROOT_DIR);
|
||||
echo();
|
||||
echo('### Running browser tests');
|
||||
|
||||
var PDF_TEST = env['PDF_TEST'] || 'test_manifest.json',
|
||||
PDF_BROWSERS = env['PDF_BROWSERS'] || 'resources/browser_manifests/browser_manifest.json';
|
||||
|
||||
if (!exists('test/' + PDF_BROWSERS)) {
|
||||
echo('Browser manifest file test/' + PDF_BROWSERS + ' does not exist.');
|
||||
echo('Try copying one of the examples in test/resources/browser_manifests/');
|
||||
exit(1);
|
||||
}
|
||||
|
||||
cd('test');
|
||||
exec(PYTHON_BIN + ' test.py --reftest --browserManifestFile=' + PDF_BROWSERS +
|
||||
' --manifestFile=' + PDF_TEST, {async: true});
|
||||
};
|
||||
|
||||
//
|
||||
// make unittest
|
||||
//
|
||||
target.unittest = function() {
|
||||
cd(ROOT_DIR);
|
||||
echo();
|
||||
echo('### Running unit tests');
|
||||
|
||||
cd('test/unit');
|
||||
exec('make', {async: true});
|
||||
};
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Other
|
||||
//
|
||||
|
||||
//
|
||||
// make server
|
||||
//
|
||||
target.server = function() {
|
||||
cd(ROOT_DIR);
|
||||
echo();
|
||||
echo('### Starting local server');
|
||||
|
||||
cd('test');
|
||||
exec(PYTHON_BIN + ' -u test.py --port=8888', {async: true});
|
||||
};
|
||||
|
||||
//
|
||||
// make lint
|
||||
//
|
||||
target.lint = function() {
|
||||
cd(ROOT_DIR);
|
||||
echo();
|
||||
echo('### Linting JS files (this can take a while!)');
|
||||
|
||||
var LINT_FILES = 'src/*.js \
|
||||
web/*.js \
|
||||
test/*.js \
|
||||
test/unit/*.js \
|
||||
extensions/firefox/*.js \
|
||||
extensions/firefox/components/*.js \
|
||||
extensions/chrome/*.js';
|
||||
|
||||
exec('gjslint --nojsdoc ' + LINT_FILES);
|
||||
};
|
||||
|
||||
//
|
||||
// make clean
|
||||
//
|
||||
target.clean = function() {
|
||||
cd(ROOT_DIR);
|
||||
echo();
|
||||
echo('### Cleaning up project builds');
|
||||
|
||||
rm('-rf', BUILD_DIR);
|
||||
};
|
433
src/bidi.js
Normal file
433
src/bidi.js
Normal file
@ -0,0 +1,433 @@
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
|
||||
'use strict';
|
||||
|
||||
var bidi = PDFJS.bidi = (function bidiClosure() {
|
||||
// Character types for symbols from 0000 to 00FF.
|
||||
var baseTypes = [
|
||||
'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'S', 'B', 'S', 'WS',
|
||||
'B', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN',
|
||||
'BN', 'BN', 'B', 'B', 'B', 'S', 'WS', 'ON', 'ON', 'ET', 'ET', 'ET', 'ON',
|
||||
'ON', 'ON', 'ON', 'ON', 'ON', 'CS', 'ON', 'CS', 'ON', 'EN', 'EN', 'EN',
|
||||
'EN', 'EN', 'EN', 'EN', 'EN', 'EN', 'EN', 'ON', 'ON', 'ON', 'ON', 'ON',
|
||||
'ON', 'ON', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L',
|
||||
'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'ON', 'ON',
|
||||
'ON', 'ON', 'ON', 'ON', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L',
|
||||
'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L',
|
||||
'L', 'ON', 'ON', 'ON', 'ON', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'B', 'BN',
|
||||
'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN',
|
||||
'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN',
|
||||
'BN', 'CS', 'ON', 'ET', 'ET', 'ET', 'ET', 'ON', 'ON', 'ON', 'ON', 'L', 'ON',
|
||||
'ON', 'ON', 'ON', 'ON', 'ET', 'ET', 'EN', 'EN', 'ON', 'L', 'ON', 'ON', 'ON',
|
||||
'EN', 'L', 'ON', 'ON', 'ON', 'ON', 'ON', 'L', 'L', 'L', 'L', 'L', 'L', 'L',
|
||||
'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L',
|
||||
'L', 'ON', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L',
|
||||
'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L',
|
||||
'L', 'L', 'L', 'ON', 'L', 'L', 'L', 'L', 'L', 'L', 'L', 'L'
|
||||
];
|
||||
|
||||
// Character types for symbols from 0600 to 06FF
|
||||
var arabicTypes = [
|
||||
'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL',
|
||||
'CS', 'AL', 'ON', 'ON', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'AL',
|
||||
'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL',
|
||||
'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL',
|
||||
'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL',
|
||||
'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL',
|
||||
'AL', 'AL', 'AL', 'AL', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM',
|
||||
'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'AL', 'AL', 'AL', 'AL',
|
||||
'AL', 'AL', 'AL', 'AN', 'AN', 'AN', 'AN', 'AN', 'AN', 'AN', 'AN', 'AN',
|
||||
'AN', 'ET', 'AN', 'AN', 'AL', 'AL', 'AL', 'NSM', 'AL', 'AL', 'AL', 'AL',
|
||||
'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL',
|
||||
'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL',
|
||||
'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL',
|
||||
'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL',
|
||||
'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL',
|
||||
'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL',
|
||||
'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL',
|
||||
'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL',
|
||||
'AL', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM',
|
||||
'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'NSM', 'ON', 'NSM',
|
||||
'NSM', 'NSM', 'NSM', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL',
|
||||
'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL', 'AL'
|
||||
];
|
||||
|
||||
function isOdd(i) {
|
||||
return (i & 1) != 0;
|
||||
}
|
||||
|
||||
function isEven(i) {
|
||||
return (i & 1) == 0;
|
||||
}
|
||||
|
||||
function findUnequal(arr, start, value) {
|
||||
var j;
|
||||
for (var j = start, jj = arr.length; j < jj; ++j) {
|
||||
if (arr[j] != value)
|
||||
return j;
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
function setValues(arr, start, end, value) {
|
||||
for (var j = start; j < end; ++j) {
|
||||
arr[j] = value;
|
||||
}
|
||||
}
|
||||
|
||||
function reverseValues(arr, start, end) {
|
||||
for (var i = start, j = end - 1; i < j; ++i, --j) {
|
||||
var temp = arr[i];
|
||||
arr[i] = arr[j];
|
||||
arr[j] = temp;
|
||||
}
|
||||
}
|
||||
|
||||
function mirrorGlyphs(c) {
|
||||
/*
|
||||
# BidiMirroring-1.txt
|
||||
0028; 0029 # LEFT PARENTHESIS
|
||||
0029; 0028 # RIGHT PARENTHESIS
|
||||
003C; 003E # LESS-THAN SIGN
|
||||
003E; 003C # GREATER-THAN SIGN
|
||||
005B; 005D # LEFT SQUARE BRACKET
|
||||
005D; 005B # RIGHT SQUARE BRACKET
|
||||
007B; 007D # LEFT CURLY BRACKET
|
||||
007D; 007B # RIGHT CURLY BRACKET
|
||||
00AB; 00BB # LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
|
||||
00BB; 00AB # RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
|
||||
*/
|
||||
switch (c) {
|
||||
case '(':
|
||||
return ')';
|
||||
case ')':
|
||||
return '(';
|
||||
case '<':
|
||||
return '>';
|
||||
case '>':
|
||||
return '<';
|
||||
case ']':
|
||||
return '[';
|
||||
case '[':
|
||||
return ']';
|
||||
case '}':
|
||||
return '{';
|
||||
case '{':
|
||||
return '}';
|
||||
case '\u00AB':
|
||||
return '\u00BB';
|
||||
case '\u00BB':
|
||||
return '\u00AB';
|
||||
default:
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
return (function bidi(text, startLevel) {
|
||||
var str = text.str;
|
||||
var strLength = str.length;
|
||||
if (strLength == 0)
|
||||
return str;
|
||||
|
||||
// get types, fill arrays
|
||||
|
||||
var chars = new Array(strLength);
|
||||
var types = new Array(strLength);
|
||||
var oldtypes = new Array(strLength);
|
||||
var numBidi = 0;
|
||||
|
||||
for (var i = 0; i < strLength; ++i) {
|
||||
chars[i] = str.charAt(i);
|
||||
|
||||
var charCode = str.charCodeAt(i);
|
||||
var charType = 'L';
|
||||
if (charCode <= 0x00ff)
|
||||
charType = baseTypes[charCode];
|
||||
else if (0x0590 <= charCode && charCode <= 0x05f4)
|
||||
charType = 'R';
|
||||
else if (0x0600 <= charCode && charCode <= 0x06ff)
|
||||
charType = arabicTypes[charCode & 0xff];
|
||||
else if (0x0700 <= charCode && charCode <= 0x08AC)
|
||||
charType = 'AL';
|
||||
|
||||
if (charType == 'R' || charType == 'AL' || charType == 'AN')
|
||||
numBidi++;
|
||||
|
||||
oldtypes[i] = types[i] = charType;
|
||||
}
|
||||
|
||||
// detect the bidi method
|
||||
// if there are no rtl characters then no bidi needed
|
||||
// if less than 30% chars are rtl then string is primarily ltr
|
||||
// if more than 30% chars are rtl then string is primarily rtl
|
||||
if (numBidi == 0) {
|
||||
text.direction = 'ltr';
|
||||
return str;
|
||||
}
|
||||
|
||||
if (startLevel == -1) {
|
||||
if ((strLength / numBidi) < 0.3) {
|
||||
text.direction = 'ltr';
|
||||
startLevel = 0;
|
||||
} else {
|
||||
text.direction = 'rtl';
|
||||
startLevel = 1;
|
||||
}
|
||||
}
|
||||
|
||||
var levels = new Array(strLength);
|
||||
|
||||
for (var i = 0; i < strLength; ++i) {
|
||||
levels[i] = startLevel;
|
||||
}
|
||||
|
||||
var diffChars = new Array(strLength);
|
||||
var diffLevels = new Array(strLength);
|
||||
var diffTypes = new Array(strLength);
|
||||
|
||||
/*
|
||||
X1-X10: skip most of this, since we are NOT doing the embeddings.
|
||||
*/
|
||||
|
||||
var e = isOdd(startLevel) ? 'R' : 'L';
|
||||
var sor = e;
|
||||
var eor = sor;
|
||||
|
||||
/*
|
||||
W1. Examine each non-spacing mark (NSM) in the level run, and change the
|
||||
type of the NSM to the type of the previous character. If the NSM is at the
|
||||
start of the level run, it will get the type of sor.
|
||||
*/
|
||||
|
||||
var lastType = sor;
|
||||
for (var i = 0; i < strLength; ++i) {
|
||||
if (types[i] == 'NSM')
|
||||
types[i] = lastType;
|
||||
else
|
||||
lastType = types[i];
|
||||
}
|
||||
|
||||
/*
|
||||
W2. Search backwards from each instance of a European number until the
|
||||
first strong type (R, L, AL, or sor) is found. If an AL is found, change
|
||||
the type of the European number to Arabic number.
|
||||
*/
|
||||
|
||||
var lastType = sor;
|
||||
for (var i = 0; i < strLength; ++i) {
|
||||
var t = types[i];
|
||||
if (t == 'EN')
|
||||
types[i] = (lastType == 'AL') ? 'AN' : 'EN';
|
||||
else if (t == 'R' || t == 'L' || t == 'AL')
|
||||
lastType = t;
|
||||
}
|
||||
|
||||
/*
|
||||
W3. Change all ALs to R.
|
||||
*/
|
||||
|
||||
for (var i = 0; i < strLength; ++i) {
|
||||
var t = types[i];
|
||||
if (t == 'AL')
|
||||
types[i] = 'R';
|
||||
}
|
||||
|
||||
/*
|
||||
W4. A single European separator between two European numbers changes to a
|
||||
European number. A single common separator between two numbers of the same
|
||||
type changes to that type:
|
||||
*/
|
||||
|
||||
for (var i = 1; i < strLength - 1; ++i) {
|
||||
if (types[i] == 'ES' && types[i - 1] == 'EN' && types[i + 1] == 'EN')
|
||||
types[i] = 'EN';
|
||||
if (types[i] == 'CS' && (types[i - 1] == 'EN' || types[i - 1] == 'AN') &&
|
||||
types[i + 1] == types[i - 1])
|
||||
types[i] = types[i - 1];
|
||||
}
|
||||
|
||||
/*
|
||||
W5. A sequence of European terminators adjacent to European numbers changes
|
||||
to all European numbers:
|
||||
*/
|
||||
|
||||
for (var i = 0; i < strLength; ++i) {
|
||||
if (types[i] == 'EN') {
|
||||
// do before
|
||||
for (var j = i - 1; j >= 0; --j) {
|
||||
if (types[j] != 'ET')
|
||||
break;
|
||||
types[j] = 'EN';
|
||||
}
|
||||
// do after
|
||||
for (var j = i + 1; j < strLength; --j) {
|
||||
if (types[j] != 'ET')
|
||||
break;
|
||||
types[j] = 'EN';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
W6. Otherwise, separators and terminators change to Other Neutral:
|
||||
*/
|
||||
|
||||
for (var i = 0; i < strLength; ++i) {
|
||||
var t = types[i];
|
||||
if (t == 'WS' || t == 'ES' || t == 'ET' || t == 'CS')
|
||||
types[i] = 'ON';
|
||||
}
|
||||
|
||||
/*
|
||||
W7. Search backwards from each instance of a European number until the
|
||||
first strong type (R, L, or sor) is found. If an L is found, then change
|
||||
the type of the European number to L.
|
||||
*/
|
||||
|
||||
var lastType = sor;
|
||||
for (var i = 0; i < strLength; ++i) {
|
||||
var t = types[i];
|
||||
if (t == 'EN')
|
||||
types[i] = (lastType == 'L') ? 'L' : 'EN';
|
||||
else if (t == 'R' || t == 'L')
|
||||
lastType = t;
|
||||
}
|
||||
|
||||
/*
|
||||
N1. A sequence of neutrals takes the direction of the surrounding strong
|
||||
text if the text on both sides has the same direction. European and Arabic
|
||||
numbers are treated as though they were R. Start-of-level-run (sor) and
|
||||
end-of-level-run (eor) are used at level run boundaries.
|
||||
*/
|
||||
|
||||
for (var i = 0; i < strLength; ++i) {
|
||||
if (types[i] == 'ON') {
|
||||
var end = findUnequal(types, i + 1, 'ON');
|
||||
var before = sor;
|
||||
if (i > 0)
|
||||
before = types[i - 1];
|
||||
var after = eor;
|
||||
if (end + 1 < strLength)
|
||||
after = types[end + 1];
|
||||
if (before != 'L')
|
||||
before = 'R';
|
||||
if (after != 'L')
|
||||
after = 'R';
|
||||
if (before == after)
|
||||
setValues(types, i, end, before);
|
||||
i = end - 1; // reset to end (-1 so next iteration is ok)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
N2. Any remaining neutrals take the embedding direction.
|
||||
*/
|
||||
|
||||
for (var i = 0; i < strLength; ++i) {
|
||||
if (types[i] == 'ON')
|
||||
types[i] = e;
|
||||
}
|
||||
|
||||
/*
|
||||
I1. For all characters with an even (left-to-right) embedding direction,
|
||||
those of type R go up one level and those of type AN or EN go up two
|
||||
levels.
|
||||
I2. For all characters with an odd (right-to-left) embedding direction,
|
||||
those of type L, EN or AN go up one level.
|
||||
*/
|
||||
|
||||
for (var i = 0; i < strLength; ++i) {
|
||||
var t = types[i];
|
||||
if (isEven(levels[i])) {
|
||||
if (t == 'R') {
|
||||
levels[i] += 1;
|
||||
} else if (t == 'AN' || t == 'EN') {
|
||||
levels[i] += 2;
|
||||
}
|
||||
} else { // isOdd, so
|
||||
if (t == 'L' || t == 'AN' || t == 'EN') {
|
||||
levels[i] += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
L1. On each line, reset the embedding level of the following characters to
|
||||
the paragraph embedding level:
|
||||
|
||||
segment separators,
|
||||
paragraph separators,
|
||||
any sequence of whitespace characters preceding a segment separator or
|
||||
paragraph separator, and any sequence of white space characters at the end
|
||||
of the line.
|
||||
*/
|
||||
|
||||
// don't bother as text is only single line
|
||||
|
||||
/*
|
||||
L2. From the highest level found in the text to the lowest odd level on
|
||||
each line, reverse any contiguous sequence of characters that are at that
|
||||
level or higher.
|
||||
*/
|
||||
|
||||
// find highest level & lowest odd level
|
||||
|
||||
var highestLevel = -1;
|
||||
var lowestOddLevel = 99;
|
||||
for (var i = 0, ii = levels.length; i < ii; ++i) {
|
||||
var level = levels[i];
|
||||
if (highestLevel < level)
|
||||
highestLevel = level;
|
||||
if (lowestOddLevel > level && isOdd(level))
|
||||
lowestOddLevel = level;
|
||||
}
|
||||
|
||||
// now reverse between those limits
|
||||
|
||||
for (var level = highestLevel; level >= lowestOddLevel; --level) {
|
||||
// find segments to reverse
|
||||
var start = -1;
|
||||
for (var i = 0, ii = levels.length; i < ii; ++i) {
|
||||
if (levels[i] < level) {
|
||||
if (start >= 0) {
|
||||
reverseValues(chars, start, i);
|
||||
start = -1;
|
||||
}
|
||||
} else if (start < 0) {
|
||||
start = i;
|
||||
}
|
||||
}
|
||||
if (start >= 0) {
|
||||
reverseValues(chars, start, levels.length);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
L3. Combining marks applied to a right-to-left base character will at this
|
||||
point precede their base character. If the rendering engine expects them to
|
||||
follow the base characters in the final display process, then the ordering
|
||||
of the marks and the base character must be reversed.
|
||||
*/
|
||||
|
||||
// don't bother for now
|
||||
|
||||
/*
|
||||
L4. A character that possesses the mirrored property as specified by
|
||||
Section 4.7, Mirrored, must be depicted by a mirrored glyph if the resolved
|
||||
directionality of that character is R.
|
||||
*/
|
||||
|
||||
// don't mirror as characters are already mirrored in the pdf
|
||||
|
||||
// Finally, return string
|
||||
|
||||
var result = '';
|
||||
for (var i = 0, ii = chars.length; i < ii; ++i) {
|
||||
var ch = chars[i];
|
||||
if (ch != '<' && ch != '>')
|
||||
result += ch;
|
||||
}
|
||||
return result;
|
||||
});
|
||||
})();
|
@ -778,8 +778,16 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
||||
|
||||
x += charWidth;
|
||||
|
||||
text.str += glyph.unicode === ' ' ? '\u00A0' : glyph.unicode;
|
||||
text.length++;
|
||||
var glyphUnicode = glyph.unicode === ' ' ? '\u00A0' : glyph.unicode;
|
||||
var glyphUnicodeLength = glyphUnicode.length;
|
||||
//reverse an arabic ligature
|
||||
if (glyphUnicodeLength > 1 &&
|
||||
isRTLRangeFor(glyphUnicode.charCodeAt(0))) {
|
||||
for (var ii = glyphUnicodeLength - 1; ii >= 0; ii--)
|
||||
text.str += glyphUnicode[ii];
|
||||
} else
|
||||
text.str += glyphUnicode;
|
||||
text.length += glyphUnicodeLength;
|
||||
text.canvasWidth += charWidth;
|
||||
}
|
||||
current.x += x * textHScale2;
|
||||
@ -845,7 +853,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
||||
text.str += shownText.str;
|
||||
}
|
||||
text.canvasWidth += shownText.canvasWidth;
|
||||
text.length += e.length;
|
||||
text.length += shownText.length;
|
||||
}
|
||||
} else {
|
||||
malformed('TJ array element ' + e + ' is not string or num');
|
||||
|
@ -620,8 +620,18 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
||||
} else {
|
||||
// parsing hex UTF-16BE numbers
|
||||
var str = [];
|
||||
for (var i = 0, ii = token.length; i < ii; i += 4)
|
||||
str.push(parseInt(token.substr(i, 4), 16));
|
||||
for (var k = 0, kk = token.length; k < kk; k += 4) {
|
||||
var b = parseInt(token.substr(k, 4), 16);
|
||||
if (b <= 0x10) {
|
||||
k += 4;
|
||||
b = (b << 16) | parseInt(token.substr(k, 4), 16);
|
||||
b -= 0x10000;
|
||||
str.push(0xD800 | (b >> 10));
|
||||
str.push(0xDC00 | (b & 0x3FF));
|
||||
break;
|
||||
}
|
||||
str.push(b);
|
||||
}
|
||||
tokens.push(String.fromCharCode.apply(String, str));
|
||||
token = '';
|
||||
}
|
||||
|
667
src/fonts.js
667
src/fonts.js
@ -11,6 +11,7 @@ var kMaxWaitForFontFace = 1000;
|
||||
// Unicode Private Use Area
|
||||
var kCmapGlyphOffset = 0xE000;
|
||||
var kSizeOfGlyphArea = 0x1900;
|
||||
var kSymbolicFontGlyphOffset = 0xF000;
|
||||
|
||||
// PDF Glyph Space Units are one Thousandth of a TextSpace Unit
|
||||
// except for Type 3 fonts
|
||||
@ -32,269 +33,241 @@ var FontFlags = {
|
||||
};
|
||||
|
||||
var Encodings = {
|
||||
get ExpertEncoding() {
|
||||
return shadow(this, 'ExpertEncoding', ['', '', '', '', '', '', '', '', '',
|
||||
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
'', '', '', '', '', 'space', 'exclamsmall', 'Hungarumlautsmall', '',
|
||||
'dollaroldstyle', 'dollarsuperior', 'ampersandsmall', 'Acutesmall',
|
||||
'parenleftsuperior', 'parenrightsuperior', 'twodotenleader',
|
||||
'onedotenleader', 'comma', 'hyphen', 'period', 'fraction',
|
||||
'zerooldstyle', 'oneoldstyle', 'twooldstyle', 'threeoldstyle',
|
||||
'fouroldstyle', 'fiveoldstyle', 'sixoldstyle', 'sevenoldstyle',
|
||||
'eightoldstyle', 'nineoldstyle', 'colon', 'semicolon', 'commasuperior',
|
||||
'threequartersemdash', 'periodsuperior', 'questionsmall', '',
|
||||
'asuperior', 'bsuperior', 'centsuperior', 'dsuperior', 'esuperior', '',
|
||||
'', 'isuperior', '', '', 'lsuperior', 'msuperior', 'nsuperior',
|
||||
'osuperior', '', '', 'rsuperior', 'ssuperior', 'tsuperior', '', 'ff',
|
||||
'fi', 'fl', 'ffi', 'ffl', 'parenleftinferior', '', 'parenrightinferior',
|
||||
'Circumflexsmall', 'hyphensuperior', 'Gravesmall', 'Asmall', 'Bsmall',
|
||||
'Csmall', 'Dsmall', 'Esmall', 'Fsmall', 'Gsmall', 'Hsmall', 'Ismall',
|
||||
'Jsmall', 'Ksmall', 'Lsmall', 'Msmall', 'Nsmall', 'Osmall', 'Psmall',
|
||||
'Qsmall', 'Rsmall', 'Ssmall', 'Tsmall', 'Usmall', 'Vsmall', 'Wsmall',
|
||||
'Xsmall', 'Ysmall', 'Zsmall', 'colonmonetary', 'onefitted', 'rupiah',
|
||||
'Tildesmall', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
'', 'exclamdownsmall', 'centoldstyle', 'Lslashsmall', '', '',
|
||||
'Scaronsmall', 'Zcaronsmall', 'Dieresissmall', 'Brevesmall',
|
||||
'Caronsmall', '', 'Dotaccentsmall', '', '', 'Macronsmall', '', '',
|
||||
'figuredash', 'hypheninferior', '', '', 'Ogoneksmall', 'Ringsmall',
|
||||
'Cedillasmall', '', '', '', 'onequarter', 'onehalf', 'threequarters',
|
||||
'questiondownsmall', 'oneeighth', 'threeeighths', 'fiveeighths',
|
||||
'seveneighths', 'onethird', 'twothirds', '', '', 'zerosuperior',
|
||||
'onesuperior', 'twosuperior', 'threesuperior', 'foursuperior',
|
||||
'fivesuperior', 'sixsuperior', 'sevensuperior', 'eightsuperior',
|
||||
'ninesuperior', 'zeroinferior', 'oneinferior', 'twoinferior',
|
||||
'threeinferior', 'fourinferior', 'fiveinferior', 'sixinferior',
|
||||
'seveninferior', 'eightinferior', 'nineinferior', 'centinferior',
|
||||
'dollarinferior', 'periodinferior', 'commainferior', 'Agravesmall',
|
||||
'Aacutesmall', 'Acircumflexsmall', 'Atildesmall', 'Adieresissmall',
|
||||
'Aringsmall', 'AEsmall', 'Ccedillasmall', 'Egravesmall', 'Eacutesmall',
|
||||
'Ecircumflexsmall', 'Edieresissmall', 'Igravesmall', 'Iacutesmall',
|
||||
'Icircumflexsmall', 'Idieresissmall', 'Ethsmall', 'Ntildesmall',
|
||||
'Ogravesmall', 'Oacutesmall', 'Ocircumflexsmall', 'Otildesmall',
|
||||
'Odieresissmall', 'OEsmall', 'Oslashsmall', 'Ugravesmall', 'Uacutesmall',
|
||||
'Ucircumflexsmall', 'Udieresissmall', 'Yacutesmall', 'Thornsmall',
|
||||
'Ydieresissmall'
|
||||
]);
|
||||
},
|
||||
get MacExpertEncoding() {
|
||||
return shadow(this, 'MacExpertEncoding', ['', '', '', '', '', '', '', '',
|
||||
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
'', '', '', '', '', '', 'space', 'exclamsmall', 'Hungarumlautsmall',
|
||||
'centoldstyle', 'dollaroldstyle', 'dollarsuperior', 'ampersandsmall',
|
||||
'Acutesmall', 'parenleftsuperior', 'parenrightsuperior',
|
||||
'twodotenleader', 'onedotenleader', 'comma', 'hyphen', 'period',
|
||||
'fraction', 'zerooldstyle', 'oneoldstyle', 'twooldstyle',
|
||||
'threeoldstyle', 'fouroldstyle', 'fiveoldstyle', 'sixoldstyle',
|
||||
'sevenoldstyle', 'eightoldstyle', 'nineoldstyle', 'colon', 'semicolon',
|
||||
'', 'threequartersemdash', '', 'questionsmall', '', '', '', '',
|
||||
'Ethsmall', '', '', 'onequarter', 'onehalf', 'threequarters',
|
||||
'oneeighth', 'threeeighths', 'fiveeighths', 'seveneighths', 'onethird',
|
||||
'twothirds', '', '', '', '', '', '', 'ff', 'fi', 'fl', 'ffi', 'ffl',
|
||||
'parenleftinferior', '', 'parenrightinferior', 'Circumflexsmall',
|
||||
'hypheninferior', 'Gravesmall', 'Asmall', 'Bsmall', 'Csmall', 'Dsmall',
|
||||
'Esmall', 'Fsmall', 'Gsmall', 'Hsmall', 'Ismall', 'Jsmall', 'Ksmall',
|
||||
'Lsmall', 'Msmall', 'Nsmall', 'Osmall', 'Psmall', 'Qsmall', 'Rsmall',
|
||||
'Ssmall', 'Tsmall', 'Usmall', 'Vsmall', 'Wsmall', 'Xsmall', 'Ysmall',
|
||||
'Zsmall', 'colonmonetary', 'onefitted', 'rupiah', 'Tildesmall', '', '',
|
||||
'asuperior', 'centsuperior', '', '', '', '', 'Aacutesmall',
|
||||
'Agravesmall', 'Acircumflexsmall', 'Adieresissmall', 'Atildesmall',
|
||||
'Aringsmall', 'Ccedillasmall', 'Eacutesmall', 'Egravesmall',
|
||||
'Ecircumflexsmall', 'Edieresissmall', 'Iacutesmall', 'Igravesmall',
|
||||
'Icircumflexsmall', 'Idieresissmall', 'Ntildesmall', 'Oacutesmall',
|
||||
'Ogravesmall', 'Ocircumflexsmall', 'Odieresissmall', 'Otildesmall',
|
||||
'Uacutesmall', 'Ugravesmall', 'Ucircumflexsmall', 'Udieresissmall', '',
|
||||
'eightsuperior', 'fourinferior', 'threeinferior', 'sixinferior',
|
||||
'eightinferior', 'seveninferior', 'Scaronsmall', '', 'centinferior',
|
||||
'twoinferior', '', 'Dieresissmall', '', 'Caronsmall', 'osuperior',
|
||||
'fiveinferior', '', 'commainferior', 'periodinferior', 'Yacutesmall', '',
|
||||
'dollarinferior', '', 'Thornsmall', '', 'nineinferior', 'zeroinferior',
|
||||
'Zcaronsmall', 'AEsmall', 'Oslashsmall', 'questiondownsmall',
|
||||
'oneinferior', 'Lslashsmall', '', '', '', '', '', '', 'Cedillasmall', '',
|
||||
'', '', '', '', 'OEsmall', 'figuredash', 'hyphensuperior', '', '', '',
|
||||
'', 'exclamdownsmall', '', 'Ydieresissmall', '', 'onesuperior',
|
||||
'twosuperior', 'threesuperior', 'foursuperior', 'fivesuperior',
|
||||
'sixsuperior', 'sevensuperior', 'ninesuperior', 'zerosuperior', '',
|
||||
'esuperior', 'rsuperior', 'tsuperior', '', '', 'isuperior', 'ssuperior',
|
||||
'dsuperior', '', '', '', '', '', 'lsuperior', 'Ogoneksmall',
|
||||
'Brevesmall', 'Macronsmall', 'bsuperior', 'nsuperior', 'msuperior',
|
||||
'commasuperior', 'periodsuperior', 'Dotaccentsmall', 'Ringsmall'
|
||||
]);
|
||||
},
|
||||
get MacRomanEncoding() {
|
||||
return shadow(this, 'MacRomanEncoding', ['', '', '', '', '', '', '', '',
|
||||
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
'', '', '', '', '', '', 'space', 'exclam', 'quotedbl', 'numbersign',
|
||||
'dollar', 'percent', 'ampersand', 'quotesingle', 'parenleft',
|
||||
'parenright', 'asterisk', 'plus', 'comma', 'hyphen', 'period', 'slash',
|
||||
'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight',
|
||||
'nine', 'colon', 'semicolon', 'less', 'equal', 'greater', 'question',
|
||||
'at', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
|
||||
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
|
||||
'bracketleft', 'backslash', 'bracketright', 'asciicircum', 'underscore',
|
||||
'grave', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
|
||||
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
|
||||
'braceleft', 'bar', 'braceright', 'asciitilde', '', 'Adieresis', 'Aring',
|
||||
'Ccedilla', 'Eacute', 'Ntilde', 'Odieresis', 'Udieresis', 'aacute',
|
||||
'agrave', 'acircumflex', 'adieresis', 'atilde', 'aring', 'ccedilla',
|
||||
'eacute', 'egrave', 'ecircumflex', 'edieresis', 'iacute', 'igrave',
|
||||
'icircumflex', 'idieresis', 'ntilde', 'oacute', 'ograve', 'ocircumflex',
|
||||
'odieresis', 'otilde', 'uacute', 'ugrave', 'ucircumflex', 'udieresis',
|
||||
'dagger', 'degree', 'cent', 'sterling', 'section', 'bullet', 'paragraph',
|
||||
'germandbls', 'registered', 'copyright', 'trademark', 'acute',
|
||||
'dieresis', 'notequal', 'AE', 'Oslash', 'infinity', 'plusminus',
|
||||
'lessequal', 'greaterequal', 'yen', 'mu', 'partialdiff', 'summation',
|
||||
'product', 'pi', 'integral', 'ordfeminine', 'ordmasculine', 'Omega',
|
||||
'ae', 'oslash', 'questiondown', 'exclamdown', 'logicalnot', 'radical',
|
||||
'florin', 'approxequal', 'Delta', 'guillemotleft', 'guillemotright',
|
||||
'ellipsis', 'space', 'Agrave', 'Atilde', 'Otilde', 'OE', 'oe', 'endash',
|
||||
'emdash', 'quotedblleft', 'quotedblright', 'quoteleft', 'quoteright',
|
||||
'divide', 'lozenge', 'ydieresis', 'Ydieresis', 'fraction', 'currency',
|
||||
'guilsinglleft', 'guilsinglright', 'fi', 'fl', 'daggerdbl',
|
||||
'periodcentered', 'quotesinglbase', 'quotedblbase', 'perthousand',
|
||||
'Acircumflex', 'Ecircumflex', 'Aacute', 'Edieresis', 'Egrave', 'Iacute',
|
||||
'Icircumflex', 'Idieresis', 'Igrave', 'Oacute', 'Ocircumflex', 'apple',
|
||||
'Ograve', 'Uacute', 'Ucircumflex', 'Ugrave', 'dotlessi', 'circumflex',
|
||||
'tilde', 'macron', 'breve', 'dotaccent', 'ring', 'cedilla',
|
||||
'hungarumlaut', 'ogonek', 'caron'
|
||||
]);
|
||||
},
|
||||
get StandardEncoding() {
|
||||
return shadow(this, 'StandardEncoding', ['', '', '', '', '', '', '', '',
|
||||
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
'', '', '', '', '', '', 'space', 'exclam', 'quotedbl', 'numbersign',
|
||||
'dollar', 'percent', 'ampersand', 'quoteright', 'parenleft',
|
||||
'parenright', 'asterisk', 'plus', 'comma', 'hyphen', 'period', 'slash',
|
||||
'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight',
|
||||
'nine', 'colon', 'semicolon', 'less', 'equal', 'greater', 'question',
|
||||
'at', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
|
||||
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
|
||||
'bracketleft', 'backslash', 'bracketright', 'asciicircum', 'underscore',
|
||||
'quoteleft', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
|
||||
'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
|
||||
'braceleft', 'bar', 'braceright', 'asciitilde', '', '', '', '', '', '',
|
||||
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
'', '', '', '', '', '', '', '', '', '', 'exclamdown', 'cent', 'sterling',
|
||||
'fraction', 'yen', 'florin', 'section', 'currency', 'quotesingle',
|
||||
'quotedblleft', 'guillemotleft', 'guilsinglleft', 'guilsinglright', 'fi',
|
||||
'fl', '', 'endash', 'dagger', 'daggerdbl', 'periodcentered', '',
|
||||
'paragraph', 'bullet', 'quotesinglbase', 'quotedblbase', 'quotedblright',
|
||||
'guillemotright', 'ellipsis', 'perthousand', '', 'questiondown', '',
|
||||
'grave', 'acute', 'circumflex', 'tilde', 'macron', 'breve', 'dotaccent',
|
||||
'dieresis', '', 'ring', 'cedilla', '', 'hungarumlaut', 'ogonek', 'caron',
|
||||
'emdash', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
'AE', '', 'ordfeminine', '', '', '', '', 'Lslash', 'Oslash', 'OE',
|
||||
'ordmasculine', '', '', '', '', '', 'ae', '', '', '', 'dotlessi', '', '',
|
||||
'lslash', 'oslash', 'oe', 'germandbls'
|
||||
]);
|
||||
},
|
||||
get WinAnsiEncoding() {
|
||||
return shadow(this, 'WinAnsiEncoding', ['', '', '', '', '', '', '', '', '',
|
||||
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
'', '', '', '', '', 'space', 'exclam', 'quotedbl', 'numbersign',
|
||||
'dollar', 'percent', 'ampersand', 'quotesingle', 'parenleft',
|
||||
'parenright', 'asterisk', 'plus', 'comma', 'hyphen', 'period', 'slash',
|
||||
'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight',
|
||||
'nine', 'colon', 'semicolon', 'less', 'equal', 'greater', 'question',
|
||||
'at', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
|
||||
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
|
||||
'bracketleft', 'backslash', 'bracketright', 'asciicircum', 'underscore',
|
||||
'grave', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
|
||||
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
|
||||
'braceleft', 'bar', 'braceright', 'asciitilde', 'bullet', 'Euro',
|
||||
'bullet', 'quotesinglbase', 'florin', 'quotedblbase', 'ellipsis',
|
||||
'dagger', 'daggerdbl', 'circumflex', 'perthousand', 'Scaron',
|
||||
'guilsinglleft', 'OE', 'bullet', 'Zcaron', 'bullet', 'bullet',
|
||||
'quoteleft', 'quoteright', 'quotedblleft', 'quotedblright', 'bullet',
|
||||
'endash', 'emdash', 'tilde', 'trademark', 'scaron', 'guilsinglright',
|
||||
'oe', 'bullet', 'zcaron', 'Ydieresis', 'space', 'exclamdown', 'cent',
|
||||
'sterling', 'currency', 'yen', 'brokenbar', 'section', 'dieresis',
|
||||
'copyright', 'ordfeminine', 'guillemotleft', 'logicalnot', 'hyphen',
|
||||
'registered', 'macron', 'degree', 'plusminus', 'twosuperior',
|
||||
'threesuperior', 'acute', 'mu', 'paragraph', 'periodcentered',
|
||||
'cedilla', 'onesuperior', 'ordmasculine', 'guillemotright', 'onequarter',
|
||||
'onehalf', 'threequarters', 'questiondown', 'Agrave', 'Aacute',
|
||||
'Acircumflex', 'Atilde', 'Adieresis', 'Aring', 'AE', 'Ccedilla',
|
||||
'Egrave', 'Eacute', 'Ecircumflex', 'Edieresis', 'Igrave', 'Iacute',
|
||||
'Icircumflex', 'Idieresis', 'Eth', 'Ntilde', 'Ograve', 'Oacute',
|
||||
'Ocircumflex', 'Otilde', 'Odieresis', 'multiply', 'Oslash', 'Ugrave',
|
||||
'Uacute', 'Ucircumflex', 'Udieresis', 'Yacute', 'Thorn', 'germandbls',
|
||||
'agrave', 'aacute', 'acircumflex', 'atilde', 'adieresis', 'aring', 'ae',
|
||||
'ccedilla', 'egrave', 'eacute', 'ecircumflex', 'edieresis', 'igrave',
|
||||
'iacute', 'icircumflex', 'idieresis', 'eth', 'ntilde', 'ograve',
|
||||
'oacute', 'ocircumflex', 'otilde', 'odieresis', 'divide', 'oslash',
|
||||
'ugrave', 'uacute', 'ucircumflex', 'udieresis', 'yacute', 'thorn',
|
||||
'ydieresis'
|
||||
]);
|
||||
},
|
||||
get symbolsEncoding() {
|
||||
return shadow(this, 'symbolsEncoding', ['', '', '', '', '', '', '', '', '',
|
||||
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
'', '', '', '', '', 'space', 'exclam', 'universal', 'numbersign',
|
||||
'existential', 'percent', 'ampersand', 'suchthat', 'parenleft',
|
||||
'parenright', 'asteriskmath', 'plus', 'comma', 'minus', 'period',
|
||||
'slash', 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven',
|
||||
'eight', 'nine', 'colon', 'semicolon', 'less', 'equal', 'greater',
|
||||
'question', 'congruent', 'Alpha', 'Beta', 'Chi', 'Delta', 'Epsilon',
|
||||
'Phi', 'Gamma', 'Eta', 'Iota', 'theta1', 'Kappa', 'Lambda', 'Mu', 'Nu',
|
||||
'Omicron', 'Pi', 'Theta', 'Rho', 'Sigma', 'Tau', 'Upsilon', 'sigma1',
|
||||
'Omega', 'Xi', 'Psi', 'Zeta', 'bracketleft', 'therefore', 'bracketright',
|
||||
'perpendicular', 'underscore', 'radicalex', 'alpha', 'beta', 'chi',
|
||||
'delta', 'epsilon', 'phi', 'gamma', 'eta', 'iota', 'phi1', 'kappa',
|
||||
'lambda', 'mu', 'nu', 'omicron', 'pi', 'theta', 'rho', 'sigma', 'tau',
|
||||
'upsilon', 'omega1', 'omega', 'xi', 'psi', 'zeta', 'braceleft', 'bar',
|
||||
'braceright', 'similar', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
'', '', '', 'Euro', 'Upsilon1', 'minute', 'lessequal', 'fraction',
|
||||
'infinity', 'florin', 'club', 'diamond', 'heart', 'spade', 'arrowboth',
|
||||
'arrowleft', 'arrowup', 'arrowright', 'arrowdown', 'degree', 'plusminus',
|
||||
'second', 'greaterequal', 'multiply', 'proportional', 'partialdiff',
|
||||
'bullet', 'divide', 'notequal', 'equivalence', 'approxequal', 'ellipsis',
|
||||
'arrowvertex', 'arrowhorizex', 'carriagereturn', 'aleph', 'Ifraktur',
|
||||
'Rfraktur', 'weierstrass', 'circlemultiply', 'circleplus', 'emptyset',
|
||||
'intersection', 'union', 'propersuperset', 'reflexsuperset', 'notsubset',
|
||||
'propersubset', 'reflexsubset', 'element', 'notelement', 'angle',
|
||||
'gradient', 'registerserif', 'copyrightserif', 'trademarkserif',
|
||||
'product', 'radical', 'dotmath', 'logicalnot', 'logicaland', 'logicalor',
|
||||
'arrowdblboth', 'arrowdblleft', 'arrowdblup', 'arrowdblright',
|
||||
'arrowdbldown', 'lozenge', 'angleleft', 'registersans', 'copyrightsans',
|
||||
'trademarksans', 'summation', 'parenlefttp', 'parenleftex',
|
||||
'parenleftbt', 'bracketlefttp', 'bracketleftex', 'bracketleftbt',
|
||||
'bracelefttp', 'braceleftmid', 'braceleftbt', 'braceex', '',
|
||||
'angleright', 'integral', 'integraltp', 'integralex', 'integralbt',
|
||||
'parenrighttp', 'parenrightex', 'parenrightbt', 'bracketrighttp',
|
||||
'bracketrightex', 'bracketrightbt', 'bracerighttp', 'bracerightmid',
|
||||
'bracerightbt'
|
||||
]);
|
||||
},
|
||||
get zapfDingbatsEncoding() {
|
||||
return shadow(this, 'zapfDingbatsEncoding', ['', '', '', '', '', '', '',
|
||||
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
'', '', '', '', '', '', '', 'space', 'a1', 'a2', 'a202', 'a3', 'a4',
|
||||
'a5', 'a119', 'a118', 'a117', 'a11', 'a12', 'a13', 'a14', 'a15', 'a16',
|
||||
'a105', 'a17', 'a18', 'a19', 'a20', 'a21', 'a22', 'a23', 'a24', 'a25',
|
||||
'a26', 'a27', 'a28', 'a6', 'a7', 'a8', 'a9', 'a10', 'a29', 'a30', 'a31',
|
||||
'a32', 'a33', 'a34', 'a35', 'a36', 'a37', 'a38', 'a39', 'a40', 'a41',
|
||||
'a42', 'a43', 'a44', 'a45', 'a46', 'a47', 'a48', 'a49', 'a50', 'a51',
|
||||
'a52', 'a53', 'a54', 'a55', 'a56', 'a57', 'a58', 'a59', 'a60', 'a61',
|
||||
'a62', 'a63', 'a64', 'a65', 'a66', 'a67', 'a68', 'a69', 'a70', 'a71',
|
||||
'a72', 'a73', 'a74', 'a203', 'a75', 'a204', 'a76', 'a77', 'a78', 'a79',
|
||||
'a81', 'a82', 'a83', 'a84', 'a97', 'a98', 'a99', 'a100', '', '', '', '',
|
||||
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
'', '', '', '', '', '', '', '', '', '', '', '', 'a101', 'a102', 'a103',
|
||||
'a104', 'a106', 'a107', 'a108', 'a112', 'a111', 'a110', 'a109', 'a120',
|
||||
'a121', 'a122', 'a123', 'a124', 'a125', 'a126', 'a127', 'a128', 'a129',
|
||||
'a130', 'a131', 'a132', 'a133', 'a134', 'a135', 'a136', 'a137', 'a138',
|
||||
'a139', 'a140', 'a141', 'a142', 'a143', 'a144', 'a145', 'a146', 'a147',
|
||||
'a148', 'a149', 'a150', 'a151', 'a152', 'a153', 'a154', 'a155', 'a156',
|
||||
'a157', 'a158', 'a159', 'a160', 'a161', 'a163', 'a164', 'a196', 'a165',
|
||||
'a192', 'a166', 'a167', 'a168', 'a169', 'a170', 'a171', 'a172', 'a173',
|
||||
'a162', 'a174', 'a175', 'a176', 'a177', 'a178', 'a179', 'a193', 'a180',
|
||||
'a199', 'a181', 'a200', 'a182', '', 'a201', 'a183', 'a184', 'a197',
|
||||
'a185', 'a194', 'a198', 'a186', 'a195', 'a187', 'a188', 'a189', 'a190',
|
||||
'a191'
|
||||
]);
|
||||
}
|
||||
ExpertEncoding: ['', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
'space', 'exclamsmall', 'Hungarumlautsmall', '', 'dollaroldstyle',
|
||||
'dollarsuperior', 'ampersandsmall', 'Acutesmall', 'parenleftsuperior',
|
||||
'parenrightsuperior', 'twodotenleader', 'onedotenleader', 'comma',
|
||||
'hyphen', 'period', 'fraction', 'zerooldstyle', 'oneoldstyle',
|
||||
'twooldstyle', 'threeoldstyle', 'fouroldstyle', 'fiveoldstyle',
|
||||
'sixoldstyle', 'sevenoldstyle', 'eightoldstyle', 'nineoldstyle', 'colon',
|
||||
'semicolon', 'commasuperior', 'threequartersemdash', 'periodsuperior',
|
||||
'questionsmall', '', 'asuperior', 'bsuperior', 'centsuperior', 'dsuperior',
|
||||
'esuperior', '', '', 'isuperior', '', '', 'lsuperior', 'msuperior',
|
||||
'nsuperior', 'osuperior', '', '', 'rsuperior', 'ssuperior', 'tsuperior',
|
||||
'', 'ff', 'fi', 'fl', 'ffi', 'ffl', 'parenleftinferior', '',
|
||||
'parenrightinferior', 'Circumflexsmall', 'hyphensuperior', 'Gravesmall',
|
||||
'Asmall', 'Bsmall', 'Csmall', 'Dsmall', 'Esmall', 'Fsmall', 'Gsmall',
|
||||
'Hsmall', 'Ismall', 'Jsmall', 'Ksmall', 'Lsmall', 'Msmall', 'Nsmall',
|
||||
'Osmall', 'Psmall', 'Qsmall', 'Rsmall', 'Ssmall', 'Tsmall', 'Usmall',
|
||||
'Vsmall', 'Wsmall', 'Xsmall', 'Ysmall', 'Zsmall', 'colonmonetary',
|
||||
'onefitted', 'rupiah', 'Tildesmall', '', '', '', '', '', '', '', '', '',
|
||||
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
'', '', '', '', '', '', 'exclamdownsmall', 'centoldstyle', 'Lslashsmall',
|
||||
'', '', 'Scaronsmall', 'Zcaronsmall', 'Dieresissmall', 'Brevesmall',
|
||||
'Caronsmall', '', 'Dotaccentsmall', '', '', 'Macronsmall', '', '',
|
||||
'figuredash', 'hypheninferior', '', '', 'Ogoneksmall', 'Ringsmall',
|
||||
'Cedillasmall', '', '', '', 'onequarter', 'onehalf', 'threequarters',
|
||||
'questiondownsmall', 'oneeighth', 'threeeighths', 'fiveeighths',
|
||||
'seveneighths', 'onethird', 'twothirds', '', '', 'zerosuperior',
|
||||
'onesuperior', 'twosuperior', 'threesuperior', 'foursuperior',
|
||||
'fivesuperior', 'sixsuperior', 'sevensuperior', 'eightsuperior',
|
||||
'ninesuperior', 'zeroinferior', 'oneinferior', 'twoinferior',
|
||||
'threeinferior', 'fourinferior', 'fiveinferior', 'sixinferior',
|
||||
'seveninferior', 'eightinferior', 'nineinferior', 'centinferior',
|
||||
'dollarinferior', 'periodinferior', 'commainferior', 'Agravesmall',
|
||||
'Aacutesmall', 'Acircumflexsmall', 'Atildesmall', 'Adieresissmall',
|
||||
'Aringsmall', 'AEsmall', 'Ccedillasmall', 'Egravesmall', 'Eacutesmall',
|
||||
'Ecircumflexsmall', 'Edieresissmall', 'Igravesmall', 'Iacutesmall',
|
||||
'Icircumflexsmall', 'Idieresissmall', 'Ethsmall', 'Ntildesmall',
|
||||
'Ogravesmall', 'Oacutesmall', 'Ocircumflexsmall', 'Otildesmall',
|
||||
'Odieresissmall', 'OEsmall', 'Oslashsmall', 'Ugravesmall', 'Uacutesmall',
|
||||
'Ucircumflexsmall', 'Udieresissmall', 'Yacutesmall', 'Thornsmall',
|
||||
'Ydieresissmall'],
|
||||
MacExpertEncoding: ['', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
'space', 'exclamsmall', 'Hungarumlautsmall', 'centoldstyle',
|
||||
'dollaroldstyle', 'dollarsuperior', 'ampersandsmall', 'Acutesmall',
|
||||
'parenleftsuperior', 'parenrightsuperior', 'twodotenleader',
|
||||
'onedotenleader', 'comma', 'hyphen', 'period', 'fraction', 'zerooldstyle',
|
||||
'oneoldstyle', 'twooldstyle', 'threeoldstyle', 'fouroldstyle',
|
||||
'fiveoldstyle', 'sixoldstyle', 'sevenoldstyle', 'eightoldstyle',
|
||||
'nineoldstyle', 'colon', 'semicolon', '', 'threequartersemdash', '',
|
||||
'questionsmall', '', '', '', '', 'Ethsmall', '', '', 'onequarter',
|
||||
'onehalf', 'threequarters', 'oneeighth', 'threeeighths', 'fiveeighths',
|
||||
'seveneighths', 'onethird', 'twothirds', '', '', '', '', '', '', 'ff',
|
||||
'fi', 'fl', 'ffi', 'ffl', 'parenleftinferior', '', 'parenrightinferior',
|
||||
'Circumflexsmall', 'hypheninferior', 'Gravesmall', 'Asmall', 'Bsmall',
|
||||
'Csmall', 'Dsmall', 'Esmall', 'Fsmall', 'Gsmall', 'Hsmall', 'Ismall',
|
||||
'Jsmall', 'Ksmall', 'Lsmall', 'Msmall', 'Nsmall', 'Osmall', 'Psmall',
|
||||
'Qsmall', 'Rsmall', 'Ssmall', 'Tsmall', 'Usmall', 'Vsmall', 'Wsmall',
|
||||
'Xsmall', 'Ysmall', 'Zsmall', 'colonmonetary', 'onefitted', 'rupiah',
|
||||
'Tildesmall', '', '', 'asuperior', 'centsuperior', '', '', '', '',
|
||||
'Aacutesmall', 'Agravesmall', 'Acircumflexsmall', 'Adieresissmall',
|
||||
'Atildesmall', 'Aringsmall', 'Ccedillasmall', 'Eacutesmall', 'Egravesmall',
|
||||
'Ecircumflexsmall', 'Edieresissmall', 'Iacutesmall', 'Igravesmall',
|
||||
'Icircumflexsmall', 'Idieresissmall', 'Ntildesmall', 'Oacutesmall',
|
||||
'Ogravesmall', 'Ocircumflexsmall', 'Odieresissmall', 'Otildesmall',
|
||||
'Uacutesmall', 'Ugravesmall', 'Ucircumflexsmall', 'Udieresissmall', '',
|
||||
'eightsuperior', 'fourinferior', 'threeinferior', 'sixinferior',
|
||||
'eightinferior', 'seveninferior', 'Scaronsmall', '', 'centinferior',
|
||||
'twoinferior', '', 'Dieresissmall', '', 'Caronsmall', 'osuperior',
|
||||
'fiveinferior', '', 'commainferior', 'periodinferior', 'Yacutesmall', '',
|
||||
'dollarinferior', '', 'Thornsmall', '', 'nineinferior', 'zeroinferior',
|
||||
'Zcaronsmall', 'AEsmall', 'Oslashsmall', 'questiondownsmall',
|
||||
'oneinferior', 'Lslashsmall', '', '', '', '', '', '', 'Cedillasmall', '',
|
||||
'', '', '', '', 'OEsmall', 'figuredash', 'hyphensuperior', '', '', '', '',
|
||||
'exclamdownsmall', '', 'Ydieresissmall', '', 'onesuperior', 'twosuperior',
|
||||
'threesuperior', 'foursuperior', 'fivesuperior', 'sixsuperior',
|
||||
'sevensuperior', 'ninesuperior', 'zerosuperior', '', 'esuperior',
|
||||
'rsuperior', 'tsuperior', '', '', 'isuperior', 'ssuperior', 'dsuperior',
|
||||
'', '', '', '', '', 'lsuperior', 'Ogoneksmall', 'Brevesmall',
|
||||
'Macronsmall', 'bsuperior', 'nsuperior', 'msuperior', 'commasuperior',
|
||||
'periodsuperior', 'Dotaccentsmall', 'Ringsmall'],
|
||||
MacRomanEncoding: ['', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
'space', 'exclam', 'quotedbl', 'numbersign', 'dollar', 'percent',
|
||||
'ampersand', 'quotesingle', 'parenleft', 'parenright', 'asterisk', 'plus',
|
||||
'comma', 'hyphen', 'period', 'slash', 'zero', 'one', 'two', 'three',
|
||||
'four', 'five', 'six', 'seven', 'eight', 'nine', 'colon', 'semicolon',
|
||||
'less', 'equal', 'greater', 'question', 'at', 'A', 'B', 'C', 'D', 'E', 'F',
|
||||
'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U',
|
||||
'V', 'W', 'X', 'Y', 'Z', 'bracketleft', 'backslash', 'bracketright',
|
||||
'asciicircum', 'underscore', 'grave', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
|
||||
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
|
||||
'w', 'x', 'y', 'z', 'braceleft', 'bar', 'braceright', 'asciitilde', '',
|
||||
'Adieresis', 'Aring', 'Ccedilla', 'Eacute', 'Ntilde', 'Odieresis',
|
||||
'Udieresis', 'aacute', 'agrave', 'acircumflex', 'adieresis', 'atilde',
|
||||
'aring', 'ccedilla', 'eacute', 'egrave', 'ecircumflex', 'edieresis',
|
||||
'iacute', 'igrave', 'icircumflex', 'idieresis', 'ntilde', 'oacute',
|
||||
'ograve', 'ocircumflex', 'odieresis', 'otilde', 'uacute', 'ugrave',
|
||||
'ucircumflex', 'udieresis', 'dagger', 'degree', 'cent', 'sterling',
|
||||
'section', 'bullet', 'paragraph', 'germandbls', 'registered', 'copyright',
|
||||
'trademark', 'acute', 'dieresis', 'notequal', 'AE', 'Oslash', 'infinity',
|
||||
'plusminus', 'lessequal', 'greaterequal', 'yen', 'mu', 'partialdiff',
|
||||
'summation', 'product', 'pi', 'integral', 'ordfeminine', 'ordmasculine',
|
||||
'Omega', 'ae', 'oslash', 'questiondown', 'exclamdown', 'logicalnot',
|
||||
'radical', 'florin', 'approxequal', 'Delta', 'guillemotleft',
|
||||
'guillemotright', 'ellipsis', 'space', 'Agrave', 'Atilde', 'Otilde', 'OE',
|
||||
'oe', 'endash', 'emdash', 'quotedblleft', 'quotedblright', 'quoteleft',
|
||||
'quoteright', 'divide', 'lozenge', 'ydieresis', 'Ydieresis', 'fraction',
|
||||
'currency', 'guilsinglleft', 'guilsinglright', 'fi', 'fl', 'daggerdbl',
|
||||
'periodcentered', 'quotesinglbase', 'quotedblbase', 'perthousand',
|
||||
'Acircumflex', 'Ecircumflex', 'Aacute', 'Edieresis', 'Egrave', 'Iacute',
|
||||
'Icircumflex', 'Idieresis', 'Igrave', 'Oacute', 'Ocircumflex', 'apple',
|
||||
'Ograve', 'Uacute', 'Ucircumflex', 'Ugrave', 'dotlessi', 'circumflex',
|
||||
'tilde', 'macron', 'breve', 'dotaccent', 'ring', 'cedilla', 'hungarumlaut',
|
||||
'ogonek', 'caron'],
|
||||
StandardEncoding: ['', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
'space', 'exclam', 'quotedbl', 'numbersign', 'dollar', 'percent',
|
||||
'ampersand', 'quoteright', 'parenleft', 'parenright', 'asterisk', 'plus',
|
||||
'comma', 'hyphen', 'period', 'slash', 'zero', 'one', 'two', 'three',
|
||||
'four', 'five', 'six', 'seven', 'eight', 'nine', 'colon', 'semicolon',
|
||||
'less', 'equal', 'greater', 'question', 'at', 'A', 'B', 'C', 'D', 'E', 'F',
|
||||
'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U',
|
||||
'V', 'W', 'X', 'Y', 'Z', 'bracketleft', 'backslash', 'bracketright',
|
||||
'asciicircum', 'underscore', 'quoteleft', 'a', 'b', 'c', 'd', 'e', 'f',
|
||||
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u',
|
||||
'v', 'w', 'x', 'y', 'z', 'braceleft', 'bar', 'braceright', 'asciitilde',
|
||||
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 'exclamdown',
|
||||
'cent', 'sterling', 'fraction', 'yen', 'florin', 'section', 'currency',
|
||||
'quotesingle', 'quotedblleft', 'guillemotleft', 'guilsinglleft',
|
||||
'guilsinglright', 'fi', 'fl', '', 'endash', 'dagger', 'daggerdbl',
|
||||
'periodcentered', '', 'paragraph', 'bullet', 'quotesinglbase',
|
||||
'quotedblbase', 'quotedblright', 'guillemotright', 'ellipsis',
|
||||
'perthousand', '', 'questiondown', '', 'grave', 'acute', 'circumflex',
|
||||
'tilde', 'macron', 'breve', 'dotaccent', 'dieresis', '', 'ring', 'cedilla',
|
||||
'', 'hungarumlaut', 'ogonek', 'caron', 'emdash', '', '', '', '', '', '',
|
||||
'', '', '', '', '', '', '', '', '', '', 'AE', '', 'ordfeminine', '', '',
|
||||
'', '', 'Lslash', 'Oslash', 'OE', 'ordmasculine', '', '', '', '', '', 'ae',
|
||||
'', '', '', 'dotlessi', '', '', 'lslash', 'oslash', 'oe', 'germandbls'],
|
||||
WinAnsiEncoding: ['', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
|
||||
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
'space', 'exclam', 'quotedbl', 'numbersign', 'dollar', 'percent',
|
||||
'ampersand', 'quotesingle', 'parenleft', 'parenright', 'asterisk', 'plus',
|
||||
'comma', 'hyphen', 'period', 'slash', 'zero', 'one', 'two', 'three',
|
||||
'four', 'five', 'six', 'seven', 'eight', 'nine', 'colon', 'semicolon',
|
||||
'less', 'equal', 'greater', 'question', 'at', 'A', 'B', 'C', 'D', 'E', 'F',
|
||||
'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U',
|
||||
'V', 'W', 'X', 'Y', 'Z', 'bracketleft', 'backslash', 'bracketright',
|
||||
'asciicircum', 'underscore', 'grave', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
|
||||
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
|
||||
'w', 'x', 'y', 'z', 'braceleft', 'bar', 'braceright', 'asciitilde',
|
||||
'bullet', 'Euro', 'bullet', 'quotesinglbase', 'florin', 'quotedblbase',
|
||||
'ellipsis', 'dagger', 'daggerdbl', 'circumflex', 'perthousand', 'Scaron',
|
||||
'guilsinglleft', 'OE', 'bullet', 'Zcaron', 'bullet', 'bullet', 'quoteleft',
|
||||
'quoteright', 'quotedblleft', 'quotedblright', 'bullet', 'endash',
|
||||
'emdash', 'tilde', 'trademark', 'scaron', 'guilsinglright', 'oe', 'bullet',
|
||||
'zcaron', 'Ydieresis', 'space', 'exclamdown', 'cent', 'sterling',
|
||||
'currency', 'yen', 'brokenbar', 'section', 'dieresis', 'copyright',
|
||||
'ordfeminine', 'guillemotleft', 'logicalnot', 'hyphen', 'registered',
|
||||
'macron', 'degree', 'plusminus', 'twosuperior', 'threesuperior', 'acute',
|
||||
'mu', 'paragraph', 'periodcentered', 'cedilla', 'onesuperior',
|
||||
'ordmasculine', 'guillemotright', 'onequarter', 'onehalf', 'threequarters',
|
||||
'questiondown', 'Agrave', 'Aacute', 'Acircumflex', 'Atilde', 'Adieresis',
|
||||
'Aring', 'AE', 'Ccedilla', 'Egrave', 'Eacute', 'Ecircumflex', 'Edieresis',
|
||||
'Igrave', 'Iacute', 'Icircumflex', 'Idieresis', 'Eth', 'Ntilde', 'Ograve',
|
||||
'Oacute', 'Ocircumflex', 'Otilde', 'Odieresis', 'multiply', 'Oslash',
|
||||
'Ugrave', 'Uacute', 'Ucircumflex', 'Udieresis', 'Yacute', 'Thorn',
|
||||
'germandbls', 'agrave', 'aacute', 'acircumflex', 'atilde', 'adieresis',
|
||||
'aring', 'ae', 'ccedilla', 'egrave', 'eacute', 'ecircumflex', 'edieresis',
|
||||
'igrave', 'iacute', 'icircumflex', 'idieresis', 'eth', 'ntilde', 'ograve',
|
||||
'oacute', 'ocircumflex', 'otilde', 'odieresis', 'divide', 'oslash',
|
||||
'ugrave', 'uacute', 'ucircumflex', 'udieresis', 'yacute', 'thorn',
|
||||
'ydieresis'],
|
||||
symbolsEncoding: ['', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
'space', 'exclam', 'universal', 'numbersign', 'existential', 'percent',
|
||||
'ampersand', 'suchthat', 'parenleft', 'parenright', 'asteriskmath', 'plus',
|
||||
'comma', 'minus', 'period', 'slash', 'zero', 'one', 'two', 'three', 'four',
|
||||
'five', 'six', 'seven', 'eight', 'nine', 'colon', 'semicolon', 'less',
|
||||
'equal', 'greater', 'question', 'congruent', 'Alpha', 'Beta', 'Chi',
|
||||
'Delta', 'Epsilon', 'Phi', 'Gamma', 'Eta', 'Iota', 'theta1', 'Kappa',
|
||||
'Lambda', 'Mu', 'Nu', 'Omicron', 'Pi', 'Theta', 'Rho', 'Sigma', 'Tau',
|
||||
'Upsilon', 'sigma1', 'Omega', 'Xi', 'Psi', 'Zeta', 'bracketleft',
|
||||
'therefore', 'bracketright', 'perpendicular', 'underscore', 'radicalex',
|
||||
'alpha', 'beta', 'chi', 'delta', 'epsilon', 'phi', 'gamma', 'eta', 'iota',
|
||||
'phi1', 'kappa', 'lambda', 'mu', 'nu', 'omicron', 'pi', 'theta', 'rho',
|
||||
'sigma', 'tau', 'upsilon', 'omega1', 'omega', 'xi', 'psi', 'zeta',
|
||||
'braceleft', 'bar', 'braceright', 'similar', '', '', '', '', '', '', '',
|
||||
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
'', '', '', '', '', '', '', 'Euro', 'Upsilon1', 'minute', 'lessequal',
|
||||
'fraction', 'infinity', 'florin', 'club', 'diamond', 'heart', 'spade',
|
||||
'arrowboth', 'arrowleft', 'arrowup', 'arrowright', 'arrowdown', 'degree',
|
||||
'plusminus', 'second', 'greaterequal', 'multiply', 'proportional',
|
||||
'partialdiff', 'bullet', 'divide', 'notequal', 'equivalence',
|
||||
'approxequal', 'ellipsis', 'arrowvertex', 'arrowhorizex', 'carriagereturn',
|
||||
'aleph', 'Ifraktur', 'Rfraktur', 'weierstrass', 'circlemultiply',
|
||||
'circleplus', 'emptyset', 'intersection', 'union', 'propersuperset',
|
||||
'reflexsuperset', 'notsubset', 'propersubset', 'reflexsubset', 'element',
|
||||
'notelement', 'angle', 'gradient', 'registerserif', 'copyrightserif',
|
||||
'trademarkserif', 'product', 'radical', 'dotmath', 'logicalnot',
|
||||
'logicaland', 'logicalor', 'arrowdblboth', 'arrowdblleft', 'arrowdblup',
|
||||
'arrowdblright', 'arrowdbldown', 'lozenge', 'angleleft', 'registersans',
|
||||
'copyrightsans', 'trademarksans', 'summation', 'parenlefttp',
|
||||
'parenleftex', 'parenleftbt', 'bracketlefttp', 'bracketleftex',
|
||||
'bracketleftbt', 'bracelefttp', 'braceleftmid', 'braceleftbt', 'braceex',
|
||||
'', 'angleright', 'integral', 'integraltp', 'integralex', 'integralbt',
|
||||
'parenrighttp', 'parenrightex', 'parenrightbt', 'bracketrighttp',
|
||||
'bracketrightex', 'bracketrightbt', 'bracerighttp', 'bracerightmid',
|
||||
'bracerightbt'],
|
||||
zapfDingbatsEncoding: ['', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
'space', 'a1', 'a2', 'a202', 'a3', 'a4', 'a5', 'a119', 'a118', 'a117',
|
||||
'a11', 'a12', 'a13', 'a14', 'a15', 'a16', 'a105', 'a17', 'a18', 'a19',
|
||||
'a20', 'a21', 'a22', 'a23', 'a24', 'a25', 'a26', 'a27', 'a28', 'a6', 'a7',
|
||||
'a8', 'a9', 'a10', 'a29', 'a30', 'a31', 'a32', 'a33', 'a34', 'a35', 'a36',
|
||||
'a37', 'a38', 'a39', 'a40', 'a41', 'a42', 'a43', 'a44', 'a45', 'a46',
|
||||
'a47', 'a48', 'a49', 'a50', 'a51', 'a52', 'a53', 'a54', 'a55', 'a56',
|
||||
'a57', 'a58', 'a59', 'a60', 'a61', 'a62', 'a63', 'a64', 'a65', 'a66',
|
||||
'a67', 'a68', 'a69', 'a70', 'a71', 'a72', 'a73', 'a74', 'a203', 'a75',
|
||||
'a204', 'a76', 'a77', 'a78', 'a79', 'a81', 'a82', 'a83', 'a84', 'a97',
|
||||
'a98', 'a99', 'a100', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
'', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '',
|
||||
'', '', 'a101', 'a102', 'a103', 'a104', 'a106', 'a107', 'a108', 'a112',
|
||||
'a111', 'a110', 'a109', 'a120', 'a121', 'a122', 'a123', 'a124', 'a125',
|
||||
'a126', 'a127', 'a128', 'a129', 'a130', 'a131', 'a132', 'a133', 'a134',
|
||||
'a135', 'a136', 'a137', 'a138', 'a139', 'a140', 'a141', 'a142', 'a143',
|
||||
'a144', 'a145', 'a146', 'a147', 'a148', 'a149', 'a150', 'a151', 'a152',
|
||||
'a153', 'a154', 'a155', 'a156', 'a157', 'a158', 'a159', 'a160', 'a161',
|
||||
'a163', 'a164', 'a196', 'a165', 'a192', 'a166', 'a167', 'a168', 'a169',
|
||||
'a170', 'a171', 'a172', 'a173', 'a162', 'a174', 'a175', 'a176', 'a177',
|
||||
'a178', 'a179', 'a193', 'a180', 'a199', 'a181', 'a200', 'a182', '', 'a201',
|
||||
'a183', 'a184', 'a197', 'a185', 'a194', 'a198', 'a186', 'a195', 'a187',
|
||||
'a188', 'a189', 'a190', 'a191']
|
||||
};
|
||||
|
||||
/**
|
||||
@ -763,6 +736,16 @@ function getUnicodeRangeFor(value) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
function isRTLRangeFor(value) {
|
||||
var range = UnicodeRanges[13];
|
||||
if (value >= range.begin && value < range.end)
|
||||
return true;
|
||||
range = UnicodeRanges[11];
|
||||
if (value >= range.begin && value < range.end)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function isSpecialUnicode(unicode) {
|
||||
return (unicode <= 0x1F || (unicode >= 127 && unicode < kSizeOfGlyphArea)) ||
|
||||
(unicode >= kCmapGlyphOffset &&
|
||||
@ -823,6 +806,8 @@ var Font = (function FontClosure() {
|
||||
else
|
||||
this.rebuildToUnicode(properties);
|
||||
|
||||
this.toFontChar = this.buildToFontChar(this.toUnicode);
|
||||
|
||||
if (!file) {
|
||||
// The file data is not specified. Trying to fix the font name
|
||||
// to be used with the canvas.font.
|
||||
@ -1636,18 +1621,38 @@ var Font = (function FontClosure() {
|
||||
var locaData = loca.data;
|
||||
// removing the invalid glyphs
|
||||
var oldGlyfData = glyf.data;
|
||||
var newGlyfData = new Uint8Array(oldGlyfData.length);
|
||||
var oldGlyfDataLength = oldGlyfData.length;
|
||||
var newGlyfData = new Uint8Array(oldGlyfDataLength);
|
||||
var startOffset = itemDecode(locaData, 0);
|
||||
var writeOffset = 0;
|
||||
itemEncode(locaData, 0, writeOffset);
|
||||
for (var i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
|
||||
var endOffset = itemDecode(locaData, j);
|
||||
if (endOffset > oldGlyfDataLength) {
|
||||
// glyph end offset points outside glyf data, rejecting the glyph
|
||||
itemEncode(locaData, j, writeOffset);
|
||||
startOffset = endOffset;
|
||||
continue;
|
||||
}
|
||||
|
||||
var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset,
|
||||
newGlyfData, writeOffset);
|
||||
writeOffset += newLength;
|
||||
itemEncode(locaData, j, writeOffset);
|
||||
startOffset = endOffset;
|
||||
}
|
||||
|
||||
if (writeOffset == 0) {
|
||||
// glyf table cannot be empty -- redoing the glyf and loca tables
|
||||
// to have single glyph with one point
|
||||
var simpleGlyph = new Uint8Array(
|
||||
[0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, 0]);
|
||||
for (var i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize)
|
||||
itemEncode(locaData, j, simpleGlyph.length);
|
||||
glyf.data = simpleGlyph;
|
||||
return;
|
||||
}
|
||||
|
||||
glyf.data = newGlyfData.subarray(0, writeOffset);
|
||||
}
|
||||
|
||||
@ -1832,9 +1837,9 @@ var Font = (function FontClosure() {
|
||||
var unassignedUnicodeItems = [];
|
||||
for (var i = 1; i < numGlyphs; i++) {
|
||||
var cid = gidToCidMap[i] || i;
|
||||
var unicode = this.toUnicode[cid];
|
||||
if (!unicode || isSpecialUnicode(unicode) ||
|
||||
unicode in usedUnicodes) {
|
||||
var unicode = this.toFontChar[cid];
|
||||
if (!unicode || typeof unicode !== 'number' ||
|
||||
isSpecialUnicode(unicode) || unicode in usedUnicodes) {
|
||||
unassignedUnicodeItems.push(i);
|
||||
continue;
|
||||
}
|
||||
@ -1853,7 +1858,7 @@ var Font = (function FontClosure() {
|
||||
if (unusedUnicode >= kCmapGlyphOffset + kSizeOfGlyphArea)
|
||||
break;
|
||||
var unicode = unusedUnicode++;
|
||||
this.toUnicode[cid] = unicode;
|
||||
this.toFontChar[cid] = unicode;
|
||||
usedUnicodes[unicode] = true;
|
||||
glyphs.push({ unicode: unicode, code: cid });
|
||||
ids.push(i);
|
||||
@ -1864,9 +1869,20 @@ var Font = (function FontClosure() {
|
||||
var glyphs = cmapTable.glyphs;
|
||||
var ids = cmapTable.ids;
|
||||
var hasShortCmap = !!cmapTable.hasShortCmap;
|
||||
var toUnicode = this.toUnicode;
|
||||
var toFontChar = this.toFontChar;
|
||||
|
||||
if (toUnicode && toUnicode.length > 0) {
|
||||
if (hasShortCmap && ids.length == numGlyphs) {
|
||||
// Fixes the short cmap tables -- some generators use incorrect
|
||||
// glyph id.
|
||||
for (var i = 0, ii = ids.length; i < ii; i++)
|
||||
ids[i] = i;
|
||||
}
|
||||
|
||||
var unusedUnicode = kCmapGlyphOffset;
|
||||
var glyphNames = properties.glyphNames || [];
|
||||
var encoding = properties.baseEncoding;
|
||||
var differences = properties.differences;
|
||||
if (toFontChar && toFontChar.length > 0) {
|
||||
// checking if cmap is just identity map
|
||||
var isIdentity = true;
|
||||
for (var i = 0, ii = glyphs.length; i < ii; i++) {
|
||||
@ -1876,29 +1892,29 @@ var Font = (function FontClosure() {
|
||||
}
|
||||
}
|
||||
// if it is, replacing with meaningful toUnicode values
|
||||
if (isIdentity) {
|
||||
if (isIdentity && !this.isSymbolicFont) {
|
||||
var usedUnicodes = [], unassignedUnicodeItems = [];
|
||||
for (var i = 0, ii = glyphs.length; i < ii; i++) {
|
||||
var unicode = toUnicode[i + 1];
|
||||
if (!unicode || unicode in usedUnicodes) {
|
||||
var unicode = toFontChar[i + 1];
|
||||
if (!unicode || typeof unicode !== 'number' ||
|
||||
unicode in usedUnicodes) {
|
||||
unassignedUnicodeItems.push(i);
|
||||
continue;
|
||||
}
|
||||
glyphs[i].unicode = unicode;
|
||||
usedUnicodes[unicode] = true;
|
||||
}
|
||||
var unusedUnicode = kCmapGlyphOffset;
|
||||
for (var j = 0, jj = unassignedUnicodeItems.length; j < jj; j++) {
|
||||
var i = unassignedUnicodeItems[j];
|
||||
while (unusedUnicode in usedUnicodes)
|
||||
unusedUnicode++;
|
||||
var cid = i + 1;
|
||||
// override only if unicode mapping is not specified
|
||||
if (!(cid in toUnicode))
|
||||
toUnicode[cid] = unusedUnicode;
|
||||
if (!(cid in toFontChar))
|
||||
toFontChar[cid] = unusedUnicode;
|
||||
glyphs[i].unicode = unusedUnicode++;
|
||||
}
|
||||
this.useToUnicode = true;
|
||||
this.useToFontChar = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1910,9 +1926,11 @@ var Font = (function FontClosure() {
|
||||
var usedUnicodes = [];
|
||||
for (var i = 0, ii = glyphs.length; i < ii; i++) {
|
||||
var code = glyphs[i].unicode;
|
||||
var gid = ids[i];
|
||||
glyphs[i].unicode += kCmapGlyphOffset;
|
||||
toFontChar[code] = glyphs[i].unicode;
|
||||
|
||||
var glyphName = properties.baseEncoding[code];
|
||||
var glyphName = glyphNames[gid] || encoding[code];
|
||||
if (glyphName in GlyphsUnicode) {
|
||||
var unicode = GlyphsUnicode[glyphName];
|
||||
if (unicode in usedUnicodes)
|
||||
@ -1923,9 +1941,51 @@ var Font = (function FontClosure() {
|
||||
unicode: unicode,
|
||||
code: glyphs[i].code
|
||||
});
|
||||
ids.push(ids[i]);
|
||||
ids.push(gid);
|
||||
toFontChar[code] = unicode;
|
||||
}
|
||||
}
|
||||
this.useToFontChar = true;
|
||||
} else if (!this.isSymbolicFont && (this.hasEncoding ||
|
||||
properties.glyphNames || differences.length > 0)) {
|
||||
// Re-encode cmap encoding to unicode, based on the 'post' table data
|
||||
// diffrence array or base encoding
|
||||
var reverseMap = [];
|
||||
for (var i = 0, ii = glyphs.length; i < ii; i++)
|
||||
reverseMap[glyphs[i].unicode] = i;
|
||||
|
||||
for (var i = 0, ii = glyphs.length; i < ii; i++) {
|
||||
var code = glyphs[i].unicode;
|
||||
var changeCode = false;
|
||||
var gid = ids[i];
|
||||
|
||||
var glyphName = glyphNames[gid];
|
||||
if (!glyphName) {
|
||||
glyphName = differences[code] || encoding[code];
|
||||
changeCode = true;
|
||||
}
|
||||
if (glyphName in GlyphsUnicode) {
|
||||
var unicode = GlyphsUnicode[glyphName];
|
||||
if (!unicode || (unicode in reverseMap))
|
||||
continue; // unknown glyph name or its place is taken
|
||||
|
||||
glyphs[i].unicode = unicode;
|
||||
reverseMap[unicode] = i;
|
||||
if (changeCode)
|
||||
toFontChar[code] = unicode;
|
||||
}
|
||||
this.useToFontChar = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Moving all symbolic font glyphs into 0xF000 - 0xF0FF range.
|
||||
if (this.isSymbolicFont) {
|
||||
for (var i = 0, ii = glyphs.length; i < ii; i++) {
|
||||
var code = glyphs[i].unicode & 0xFF;
|
||||
var fontCharCode = kSymbolicFontGlyphOffset | code;
|
||||
glyphs[i].unicode = toFontChar[code] = fontCharCode;
|
||||
}
|
||||
this.useToFontChar = true;
|
||||
}
|
||||
|
||||
// remove glyph references outside range of avaialable glyphs
|
||||
@ -2028,12 +2088,12 @@ var Font = (function FontClosure() {
|
||||
properties.baseEncoding = encoding;
|
||||
}
|
||||
if (properties.subtype == 'CIDFontType0C') {
|
||||
var toUnicode = [];
|
||||
var toFontChar = [];
|
||||
for (var i = 0; i < charstrings.length; ++i) {
|
||||
var charstring = charstrings[i];
|
||||
toUnicode[charstring.code] = charstring.unicode;
|
||||
toFontChar[charstring.code] = charstring.unicode;
|
||||
}
|
||||
this.toUnicode = toUnicode;
|
||||
this.toFontChar = toFontChar;
|
||||
}
|
||||
|
||||
var fields = {
|
||||
@ -2128,6 +2188,19 @@ var Font = (function FontClosure() {
|
||||
return stringToArray(otf.file);
|
||||
},
|
||||
|
||||
buildToFontChar: function font_buildToFontChar(toUnicode) {
|
||||
var result = [];
|
||||
var unusedUnicode = kCmapGlyphOffset;
|
||||
for (var i = 0, ii = toUnicode.length; i < ii; i++) {
|
||||
var unicode = toUnicode[i];
|
||||
var fontCharCode = typeof unicode === 'object' ? unusedUnicode++ :
|
||||
unicode;
|
||||
if (typeof unicode !== 'undefined')
|
||||
result[i] = fontCharCode;
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
rebuildToUnicode: function font_rebuildToUnicode(properties) {
|
||||
var firstChar = properties.firstChar, lastChar = properties.lastChar;
|
||||
var map = [];
|
||||
@ -2263,7 +2336,7 @@ var Font = (function FontClosure() {
|
||||
},
|
||||
|
||||
charToGlyph: function fonts_charToGlyph(charcode) {
|
||||
var unicode, width, codeIRQueue;
|
||||
var fontCharCode, width, codeIRQueue;
|
||||
|
||||
var width = this.widths[charcode];
|
||||
|
||||
@ -2271,38 +2344,39 @@ var Font = (function FontClosure() {
|
||||
case 'CIDFontType0':
|
||||
if (this.noUnicodeAdaptation) {
|
||||
width = this.widths[this.unicodeToCID[charcode] || charcode];
|
||||
unicode = mapPrivateUseChars(charcode);
|
||||
fontCharCode = mapPrivateUseChars(charcode);
|
||||
break;
|
||||
}
|
||||
unicode = this.toUnicode[charcode] || charcode;
|
||||
fontCharCode = this.toFontChar[charcode] || charcode;
|
||||
break;
|
||||
case 'CIDFontType2':
|
||||
if (this.noUnicodeAdaptation) {
|
||||
width = this.widths[this.unicodeToCID[charcode] || charcode];
|
||||
unicode = mapPrivateUseChars(charcode);
|
||||
fontCharCode = mapPrivateUseChars(charcode);
|
||||
break;
|
||||
}
|
||||
unicode = this.toUnicode[charcode] || charcode;
|
||||
fontCharCode = this.toFontChar[charcode] || charcode;
|
||||
break;
|
||||
case 'Type1':
|
||||
var glyphName = this.differences[charcode] || this.encoding[charcode];
|
||||
if (!isNum(width))
|
||||
width = this.widths[glyphName];
|
||||
if (this.noUnicodeAdaptation) {
|
||||
unicode = mapPrivateUseChars(GlyphsUnicode[glyphName] || charcode);
|
||||
fontCharCode = mapPrivateUseChars(GlyphsUnicode[glyphName] ||
|
||||
charcode);
|
||||
break;
|
||||
}
|
||||
unicode = this.glyphNameMap[glyphName] ||
|
||||
fontCharCode = this.glyphNameMap[glyphName] ||
|
||||
GlyphsUnicode[glyphName] || charcode;
|
||||
break;
|
||||
case 'Type3':
|
||||
var glyphName = this.differences[charcode] || this.encoding[charcode];
|
||||
codeIRQueue = this.charProcIRQueues[glyphName];
|
||||
unicode = charcode;
|
||||
fontCharCode = charcode;
|
||||
break;
|
||||
case 'TrueType':
|
||||
if (this.useToUnicode) {
|
||||
unicode = this.toUnicode[charcode] || charcode;
|
||||
if (this.useToFontChar) {
|
||||
fontCharCode = this.toFontChar[charcode] || charcode;
|
||||
break;
|
||||
}
|
||||
var glyphName = this.differences[charcode] || this.encoding[charcode];
|
||||
@ -2311,16 +2385,17 @@ var Font = (function FontClosure() {
|
||||
if (!isNum(width))
|
||||
width = this.widths[glyphName];
|
||||
if (this.noUnicodeAdaptation) {
|
||||
unicode = GlyphsUnicode[glyphName] || charcode;
|
||||
fontCharCode = GlyphsUnicode[glyphName] || charcode;
|
||||
break;
|
||||
}
|
||||
if (!this.hasEncoding || this.isSymbolicFont) {
|
||||
unicode = this.useToUnicode ? this.toUnicode[charcode] : charcode;
|
||||
fontCharCode = this.useToFontChar ? this.toFontChar[charcode] :
|
||||
charcode;
|
||||
break;
|
||||
}
|
||||
|
||||
// MacRoman encoding address by re-encoding the cmap table
|
||||
unicode = glyphName in this.glyphNameMap ?
|
||||
fontCharCode = glyphName in this.glyphNameMap ?
|
||||
this.glyphNameMap[glyphName] : GlyphsUnicode[glyphName];
|
||||
break;
|
||||
default:
|
||||
@ -2336,7 +2411,7 @@ var Font = (function FontClosure() {
|
||||
width = (isNum(width) ? width : this.defaultWidth) * this.widthMultiplier;
|
||||
|
||||
return {
|
||||
fontChar: String.fromCharCode(unicode),
|
||||
fontChar: String.fromCharCode(fontCharCode),
|
||||
unicode: unicodeChars,
|
||||
width: width,
|
||||
codeIRQueue: codeIRQueue
|
||||
|
@ -1508,27 +1508,7 @@ var GlyphsUnicode = {
|
||||
dalet: 0x05D3,
|
||||
daletdagesh: 0xFB33,
|
||||
daletdageshhebrew: 0xFB33,
|
||||
dalethatafpatah: 0x05D305B2,
|
||||
dalethatafpatahhebrew: 0x05D305B2,
|
||||
dalethatafsegol: 0x05D305B1,
|
||||
dalethatafsegolhebrew: 0x05D305B1,
|
||||
dalethebrew: 0x05D3,
|
||||
dalethiriq: 0x05D305B4,
|
||||
dalethiriqhebrew: 0x05D305B4,
|
||||
daletholam: 0x05D305B9,
|
||||
daletholamhebrew: 0x05D305B9,
|
||||
daletpatah: 0x05D305B7,
|
||||
daletpatahhebrew: 0x05D305B7,
|
||||
daletqamats: 0x05D305B8,
|
||||
daletqamatshebrew: 0x05D305B8,
|
||||
daletqubuts: 0x05D305BB,
|
||||
daletqubutshebrew: 0x05D305BB,
|
||||
daletsegol: 0x05D305B6,
|
||||
daletsegolhebrew: 0x05D305B6,
|
||||
daletsheva: 0x05D305B0,
|
||||
daletshevahebrew: 0x05D305B0,
|
||||
dalettsere: 0x05D305B5,
|
||||
dalettserehebrew: 0x05D305B5,
|
||||
dalfinalarabic: 0xFEAA,
|
||||
dammaarabic: 0x064F,
|
||||
dammalowarabic: 0x064F,
|
||||
@ -1845,10 +1825,6 @@ var GlyphsUnicode = {
|
||||
finalkafdagesh: 0xFB3A,
|
||||
finalkafdageshhebrew: 0xFB3A,
|
||||
finalkafhebrew: 0x05DA,
|
||||
finalkafqamats: 0x05DA05B8,
|
||||
finalkafqamatshebrew: 0x05DA05B8,
|
||||
finalkafsheva: 0x05DA05B0,
|
||||
finalkafshevahebrew: 0x05DA05B0,
|
||||
finalmem: 0x05DD,
|
||||
finalmemhebrew: 0x05DD,
|
||||
finalnun: 0x05DF,
|
||||
@ -2037,14 +2013,7 @@ var GlyphsUnicode = {
|
||||
hakatakanahalfwidth: 0xFF8A,
|
||||
halantgurmukhi: 0x0A4D,
|
||||
hamzaarabic: 0x0621,
|
||||
hamzadammaarabic: 0x0621064F,
|
||||
hamzadammatanarabic: 0x0621064C,
|
||||
hamzafathaarabic: 0x0621064E,
|
||||
hamzafathatanarabic: 0x0621064B,
|
||||
hamzalowarabic: 0x0621,
|
||||
hamzalowkasraarabic: 0x06210650,
|
||||
hamzalowkasratanarabic: 0x0621064D,
|
||||
hamzasukunarabic: 0x06210652,
|
||||
hangulfiller: 0x3164,
|
||||
hardsigncyrillic: 0x044A,
|
||||
harpoonleftbarbup: 0x21BC,
|
||||
@ -2476,10 +2445,6 @@ var GlyphsUnicode = {
|
||||
lameddagesh: 0xFB3C,
|
||||
lameddageshhebrew: 0xFB3C,
|
||||
lamedhebrew: 0x05DC,
|
||||
lamedholam: 0x05DC05B9,
|
||||
lamedholamdagesh: '05DC 05B9 05BC',
|
||||
lamedholamdageshhebrew: '05DC 05B9 05BC',
|
||||
lamedholamhebrew: 0x05DC05B9,
|
||||
lamfinalarabic: 0xFEDE,
|
||||
lamhahinitialarabic: 0xFCCA,
|
||||
laminitialarabic: 0xFEDF,
|
||||
@ -2489,8 +2454,6 @@ var GlyphsUnicode = {
|
||||
lammedialarabic: 0xFEE0,
|
||||
lammeemhahinitialarabic: 0xFD88,
|
||||
lammeeminitialarabic: 0xFCCC,
|
||||
lammeemjeeminitialarabic: 'FEDF FEE4 FEA0',
|
||||
lammeemkhahinitialarabic: 'FEDF FEE4 FEA8',
|
||||
largecircle: 0x25EF,
|
||||
lbar: 0x019A,
|
||||
lbelt: 0x026C,
|
||||
@ -2787,7 +2750,6 @@ var GlyphsUnicode = {
|
||||
noonfinalarabic: 0xFEE6,
|
||||
noonghunnaarabic: 0x06BA,
|
||||
noonghunnafinalarabic: 0xFB9F,
|
||||
noonhehinitialarabic: 0xFEE7FEEC,
|
||||
nooninitialarabic: 0xFEE7,
|
||||
noonjeeminitialarabic: 0xFCD2,
|
||||
noonjeemisolatedarabic: 0xFC4B,
|
||||
@ -3159,27 +3121,7 @@ var GlyphsUnicode = {
|
||||
qof: 0x05E7,
|
||||
qofdagesh: 0xFB47,
|
||||
qofdageshhebrew: 0xFB47,
|
||||
qofhatafpatah: 0x05E705B2,
|
||||
qofhatafpatahhebrew: 0x05E705B2,
|
||||
qofhatafsegol: 0x05E705B1,
|
||||
qofhatafsegolhebrew: 0x05E705B1,
|
||||
qofhebrew: 0x05E7,
|
||||
qofhiriq: 0x05E705B4,
|
||||
qofhiriqhebrew: 0x05E705B4,
|
||||
qofholam: 0x05E705B9,
|
||||
qofholamhebrew: 0x05E705B9,
|
||||
qofpatah: 0x05E705B7,
|
||||
qofpatahhebrew: 0x05E705B7,
|
||||
qofqamats: 0x05E705B8,
|
||||
qofqamatshebrew: 0x05E705B8,
|
||||
qofqubuts: 0x05E705BB,
|
||||
qofqubutshebrew: 0x05E705BB,
|
||||
qofsegol: 0x05E705B6,
|
||||
qofsegolhebrew: 0x05E705B6,
|
||||
qofsheva: 0x05E705B0,
|
||||
qofshevahebrew: 0x05E705B0,
|
||||
qoftsere: 0x05E705B5,
|
||||
qoftserehebrew: 0x05E705B5,
|
||||
qparen: 0x24AC,
|
||||
quarternote: 0x2669,
|
||||
qubuts: 0x05BB,
|
||||
@ -3253,32 +3195,11 @@ var GlyphsUnicode = {
|
||||
reharmenian: 0x0580,
|
||||
rehfinalarabic: 0xFEAE,
|
||||
rehiragana: 0x308C,
|
||||
rehyehaleflamarabic: '0631 FEF3 FE8E 0644',
|
||||
rekatakana: 0x30EC,
|
||||
rekatakanahalfwidth: 0xFF9A,
|
||||
resh: 0x05E8,
|
||||
reshdageshhebrew: 0xFB48,
|
||||
reshhatafpatah: 0x05E805B2,
|
||||
reshhatafpatahhebrew: 0x05E805B2,
|
||||
reshhatafsegol: 0x05E805B1,
|
||||
reshhatafsegolhebrew: 0x05E805B1,
|
||||
reshhebrew: 0x05E8,
|
||||
reshhiriq: 0x05E805B4,
|
||||
reshhiriqhebrew: 0x05E805B4,
|
||||
reshholam: 0x05E805B9,
|
||||
reshholamhebrew: 0x05E805B9,
|
||||
reshpatah: 0x05E805B7,
|
||||
reshpatahhebrew: 0x05E805B7,
|
||||
reshqamats: 0x05E805B8,
|
||||
reshqamatshebrew: 0x05E805B8,
|
||||
reshqubuts: 0x05E805BB,
|
||||
reshqubutshebrew: 0x05E805BB,
|
||||
reshsegol: 0x05E805B6,
|
||||
reshsegolhebrew: 0x05E805B6,
|
||||
reshsheva: 0x05E805B0,
|
||||
reshshevahebrew: 0x05E805B0,
|
||||
reshtsere: 0x05E805B5,
|
||||
reshtserehebrew: 0x05E805B5,
|
||||
reversedtilde: 0x223D,
|
||||
reviahebrew: 0x0597,
|
||||
reviamugrashhebrew: 0x0597,
|
||||
@ -3477,7 +3398,6 @@ var GlyphsUnicode = {
|
||||
shaddadammaarabic: 0xFC61,
|
||||
shaddadammatanarabic: 0xFC5E,
|
||||
shaddafathaarabic: 0xFC60,
|
||||
shaddafathatanarabic: 0x0651064B,
|
||||
shaddakasraarabic: 0xFC62,
|
||||
shaddakasratanarabic: 0xFC5F,
|
||||
shade: 0x2592,
|
||||
@ -3674,7 +3594,6 @@ var GlyphsUnicode = {
|
||||
tchehfinalarabic: 0xFB7B,
|
||||
tchehinitialarabic: 0xFB7C,
|
||||
tchehmedialarabic: 0xFB7D,
|
||||
tchehmeeminitialarabic: 0xFB7CFEE4,
|
||||
tcircle: 0x24E3,
|
||||
tcircumflexbelow: 0x1E71,
|
||||
tcommaaccent: 0x0163,
|
||||
|
454
src/jpx.js
454
src/jpx.js
@ -1052,7 +1052,7 @@ var JpxImage = (function JpxImageClosure() {
|
||||
}
|
||||
r = 0;
|
||||
}
|
||||
error('JPX error: Out of packets');
|
||||
throw 'Out of packets';
|
||||
};
|
||||
}
|
||||
function ResolutionLayerComponentPositionIterator(context) {
|
||||
@ -1091,7 +1091,7 @@ var JpxImage = (function JpxImageClosure() {
|
||||
}
|
||||
l = 0;
|
||||
}
|
||||
error('JPX error: Out of packets');
|
||||
throw 'Out of packets';
|
||||
};
|
||||
}
|
||||
function buildPackets(context) {
|
||||
@ -1187,7 +1187,7 @@ var JpxImage = (function JpxImageClosure() {
|
||||
new ResolutionLayerComponentPositionIterator(context);
|
||||
break;
|
||||
default:
|
||||
error('JPX error: Unsupported progression order ' + progressionOrder);
|
||||
throw 'Unsupported progression order ' + progressionOrder;
|
||||
}
|
||||
}
|
||||
function parseTilePackets(context, data, offset, dataLength) {
|
||||
@ -1553,6 +1553,7 @@ var JpxImage = (function JpxImageClosure() {
|
||||
}
|
||||
|
||||
function JpxImage() {
|
||||
this.failOnCorruptedImage = false;
|
||||
}
|
||||
JpxImage.prototype = {
|
||||
load: function jpxImageLoad(url) {
|
||||
@ -1612,237 +1613,244 @@ var JpxImage = (function JpxImageClosure() {
|
||||
},
|
||||
parseCodestream: function jpxImageParseCodestream(data, start, end) {
|
||||
var context = {};
|
||||
var position = start;
|
||||
while (position < end) {
|
||||
var code = readUint16(data, position);
|
||||
position += 2;
|
||||
try {
|
||||
var position = start;
|
||||
while (position < end) {
|
||||
var code = readUint16(data, position);
|
||||
position += 2;
|
||||
|
||||
var length = 0, j;
|
||||
switch (code) {
|
||||
case 0xFF4F: // Start of codestream (SOC)
|
||||
context.mainHeader = true;
|
||||
break;
|
||||
case 0xFFD9: // End of codestream (EOC)
|
||||
break;
|
||||
case 0xFF51: // Image and tile size (SIZ)
|
||||
length = readUint16(data, position);
|
||||
var siz = {};
|
||||
siz.Xsiz = readUint32(data, position + 4);
|
||||
siz.Ysiz = readUint32(data, position + 8);
|
||||
siz.XOsiz = readUint32(data, position + 12);
|
||||
siz.YOsiz = readUint32(data, position + 16);
|
||||
siz.XTsiz = readUint32(data, position + 20);
|
||||
siz.YTsiz = readUint32(data, position + 24);
|
||||
siz.XTOsiz = readUint32(data, position + 28);
|
||||
siz.YTOsiz = readUint32(data, position + 32);
|
||||
var componentsCount = readUint16(data, position + 36);
|
||||
siz.Csiz = componentsCount;
|
||||
var components = [];
|
||||
j = position + 38;
|
||||
for (var i = 0; i < componentsCount; i++) {
|
||||
var component = {
|
||||
precision: (data[j] & 0x7F) + 1,
|
||||
isSigned: !!(data[j] & 0x80),
|
||||
XRsiz: data[j + 1],
|
||||
YRsiz: data[j + 1]
|
||||
};
|
||||
calculateComponentDimensions(component, siz);
|
||||
components.push(component);
|
||||
}
|
||||
context.SIZ = siz;
|
||||
context.components = components;
|
||||
calculateTileGrids(context, components);
|
||||
context.QCC = [];
|
||||
context.COC = [];
|
||||
break;
|
||||
case 0xFF5C: // Quantization default (QCD)
|
||||
length = readUint16(data, position);
|
||||
var qcd = {};
|
||||
j = position + 2;
|
||||
var sqcd = data[j++];
|
||||
var spqcdSize, scalarExpounded;
|
||||
switch (sqcd & 0x1F) {
|
||||
case 0:
|
||||
spqcdSize = 8;
|
||||
scalarExpounded = true;
|
||||
break;
|
||||
case 1:
|
||||
spqcdSize = 16;
|
||||
scalarExpounded = false;
|
||||
break;
|
||||
case 2:
|
||||
spqcdSize = 16;
|
||||
scalarExpounded = true;
|
||||
break;
|
||||
default:
|
||||
error('JPX error: Invalid SQcd value ' + sqcd);
|
||||
}
|
||||
qcd.noQuantization = spqcdSize == 8;
|
||||
qcd.scalarExpounded = scalarExpounded;
|
||||
qcd.guardBits = sqcd >> 5;
|
||||
var spqcds = [];
|
||||
while (j < length + position) {
|
||||
var spqcd = {};
|
||||
if (spqcdSize == 8) {
|
||||
spqcd.epsilon = data[j++] >> 3;
|
||||
spqcd.mu = 0;
|
||||
} else {
|
||||
spqcd.epsilon = data[j] >> 3;
|
||||
spqcd.mu = ((data[j] & 0x7) << 8) | data[j + 1];
|
||||
j += 2;
|
||||
var length = 0, j;
|
||||
switch (code) {
|
||||
case 0xFF4F: // Start of codestream (SOC)
|
||||
context.mainHeader = true;
|
||||
break;
|
||||
case 0xFFD9: // End of codestream (EOC)
|
||||
break;
|
||||
case 0xFF51: // Image and tile size (SIZ)
|
||||
length = readUint16(data, position);
|
||||
var siz = {};
|
||||
siz.Xsiz = readUint32(data, position + 4);
|
||||
siz.Ysiz = readUint32(data, position + 8);
|
||||
siz.XOsiz = readUint32(data, position + 12);
|
||||
siz.YOsiz = readUint32(data, position + 16);
|
||||
siz.XTsiz = readUint32(data, position + 20);
|
||||
siz.YTsiz = readUint32(data, position + 24);
|
||||
siz.XTOsiz = readUint32(data, position + 28);
|
||||
siz.YTOsiz = readUint32(data, position + 32);
|
||||
var componentsCount = readUint16(data, position + 36);
|
||||
siz.Csiz = componentsCount;
|
||||
var components = [];
|
||||
j = position + 38;
|
||||
for (var i = 0; i < componentsCount; i++) {
|
||||
var component = {
|
||||
precision: (data[j] & 0x7F) + 1,
|
||||
isSigned: !!(data[j] & 0x80),
|
||||
XRsiz: data[j + 1],
|
||||
YRsiz: data[j + 1]
|
||||
};
|
||||
calculateComponentDimensions(component, siz);
|
||||
components.push(component);
|
||||
}
|
||||
spqcds.push(spqcd);
|
||||
}
|
||||
qcd.SPqcds = spqcds;
|
||||
if (context.mainHeader)
|
||||
context.QCD = qcd;
|
||||
else {
|
||||
context.currentTile.QCD = qcd;
|
||||
context.currentTile.QCC = [];
|
||||
}
|
||||
break;
|
||||
case 0xFF5D: // Quantization component (QCC)
|
||||
length = readUint16(data, position);
|
||||
var qcc = {};
|
||||
j = position + 2;
|
||||
var cqcc;
|
||||
if (context.SIZ.Csiz < 257)
|
||||
cqcc = data[j++];
|
||||
else {
|
||||
cqcc = readUint16(data, j);
|
||||
j += 2;
|
||||
}
|
||||
var sqcd = data[j++];
|
||||
var spqcdSize, scalarExpounded;
|
||||
switch (sqcd & 0x1F) {
|
||||
case 0:
|
||||
spqcdSize = 8;
|
||||
scalarExpounded = true;
|
||||
break;
|
||||
case 1:
|
||||
spqcdSize = 16;
|
||||
scalarExpounded = false;
|
||||
break;
|
||||
case 2:
|
||||
spqcdSize = 16;
|
||||
scalarExpounded = true;
|
||||
break;
|
||||
default:
|
||||
error('JPX error: Invalid SQcd value ' + sqcd);
|
||||
}
|
||||
qcc.noQuantization = spqcdSize == 8;
|
||||
qcc.scalarExpounded = scalarExpounded;
|
||||
qcc.guardBits = sqcd >> 5;
|
||||
var spqcds = [];
|
||||
while (j < length + position) {
|
||||
var spqcd = {};
|
||||
if (spqcdSize == 8) {
|
||||
spqcd.epsilon = data[j++] >> 3;
|
||||
spqcd.mu = 0;
|
||||
} else {
|
||||
spqcd.epsilon = data[j] >> 3;
|
||||
spqcd.mu = ((data[j] & 0x7) << 8) | data[j + 1];
|
||||
j += 2;
|
||||
context.SIZ = siz;
|
||||
context.components = components;
|
||||
calculateTileGrids(context, components);
|
||||
context.QCC = [];
|
||||
context.COC = [];
|
||||
break;
|
||||
case 0xFF5C: // Quantization default (QCD)
|
||||
length = readUint16(data, position);
|
||||
var qcd = {};
|
||||
j = position + 2;
|
||||
var sqcd = data[j++];
|
||||
var spqcdSize, scalarExpounded;
|
||||
switch (sqcd & 0x1F) {
|
||||
case 0:
|
||||
spqcdSize = 8;
|
||||
scalarExpounded = true;
|
||||
break;
|
||||
case 1:
|
||||
spqcdSize = 16;
|
||||
scalarExpounded = false;
|
||||
break;
|
||||
case 2:
|
||||
spqcdSize = 16;
|
||||
scalarExpounded = true;
|
||||
break;
|
||||
default:
|
||||
throw 'Invalid SQcd value ' + sqcd;
|
||||
}
|
||||
spqcds.push(spqcd);
|
||||
}
|
||||
qcc.SPqcds = spqcds;
|
||||
if (context.mainHeader)
|
||||
context.QCC[cqcc] = qcc;
|
||||
else
|
||||
context.currentTile.QCC[cqcc] = qcc;
|
||||
break;
|
||||
case 0xFF52: // Coding style default (COD)
|
||||
length = readUint16(data, position);
|
||||
var cod = {};
|
||||
j = position + 2;
|
||||
var scod = data[j++];
|
||||
cod.entropyCoderWithCustomPrecincts = !!(scod & 1);
|
||||
cod.sopMarkerUsed = !!(scod & 2);
|
||||
cod.ephMarkerUsed = !!(scod & 4);
|
||||
var codingStyle = {};
|
||||
cod.progressionOrder = data[j++];
|
||||
cod.layersCount = readUint16(data, j);
|
||||
j += 2;
|
||||
cod.multipleComponentTransform = data[j++];
|
||||
|
||||
cod.decompositionLevelsCount = data[j++];
|
||||
cod.xcb = (data[j++] & 0xF) + 2;
|
||||
cod.ycb = (data[j++] & 0xF) + 2;
|
||||
var blockStyle = data[j++];
|
||||
cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);
|
||||
cod.resetContextProbabilities = !!(blockStyle & 2);
|
||||
cod.terminationOnEachCodingPass = !!(blockStyle & 4);
|
||||
cod.verticalyStripe = !!(blockStyle & 8);
|
||||
cod.predictableTermination = !!(blockStyle & 16);
|
||||
cod.segmentationSymbolUsed = !!(blockStyle & 32);
|
||||
cod.transformation = data[j++];
|
||||
if (cod.entropyCoderWithCustomPrecincts) {
|
||||
var precinctsSizes = {};
|
||||
qcd.noQuantization = spqcdSize == 8;
|
||||
qcd.scalarExpounded = scalarExpounded;
|
||||
qcd.guardBits = sqcd >> 5;
|
||||
var spqcds = [];
|
||||
while (j < length + position) {
|
||||
var precinctsSize = data[j];
|
||||
precinctsSizes.push({
|
||||
PPx: precinctsSize & 0xF,
|
||||
PPy: precinctsSize >> 4
|
||||
});
|
||||
var spqcd = {};
|
||||
if (spqcdSize == 8) {
|
||||
spqcd.epsilon = data[j++] >> 3;
|
||||
spqcd.mu = 0;
|
||||
} else {
|
||||
spqcd.epsilon = data[j] >> 3;
|
||||
spqcd.mu = ((data[j] & 0x7) << 8) | data[j + 1];
|
||||
j += 2;
|
||||
}
|
||||
spqcds.push(spqcd);
|
||||
}
|
||||
cod.precinctsSizes = precinctsSizes;
|
||||
}
|
||||
qcd.SPqcds = spqcds;
|
||||
if (context.mainHeader)
|
||||
context.QCD = qcd;
|
||||
else {
|
||||
context.currentTile.QCD = qcd;
|
||||
context.currentTile.QCC = [];
|
||||
}
|
||||
break;
|
||||
case 0xFF5D: // Quantization component (QCC)
|
||||
length = readUint16(data, position);
|
||||
var qcc = {};
|
||||
j = position + 2;
|
||||
var cqcc;
|
||||
if (context.SIZ.Csiz < 257)
|
||||
cqcc = data[j++];
|
||||
else {
|
||||
cqcc = readUint16(data, j);
|
||||
j += 2;
|
||||
}
|
||||
var sqcd = data[j++];
|
||||
var spqcdSize, scalarExpounded;
|
||||
switch (sqcd & 0x1F) {
|
||||
case 0:
|
||||
spqcdSize = 8;
|
||||
scalarExpounded = true;
|
||||
break;
|
||||
case 1:
|
||||
spqcdSize = 16;
|
||||
scalarExpounded = false;
|
||||
break;
|
||||
case 2:
|
||||
spqcdSize = 16;
|
||||
scalarExpounded = true;
|
||||
break;
|
||||
default:
|
||||
throw 'Invalid SQcd value ' + sqcd;
|
||||
}
|
||||
qcc.noQuantization = spqcdSize == 8;
|
||||
qcc.scalarExpounded = scalarExpounded;
|
||||
qcc.guardBits = sqcd >> 5;
|
||||
var spqcds = [];
|
||||
while (j < length + position) {
|
||||
var spqcd = {};
|
||||
if (spqcdSize == 8) {
|
||||
spqcd.epsilon = data[j++] >> 3;
|
||||
spqcd.mu = 0;
|
||||
} else {
|
||||
spqcd.epsilon = data[j] >> 3;
|
||||
spqcd.mu = ((data[j] & 0x7) << 8) | data[j + 1];
|
||||
j += 2;
|
||||
}
|
||||
spqcds.push(spqcd);
|
||||
}
|
||||
qcc.SPqcds = spqcds;
|
||||
if (context.mainHeader)
|
||||
context.QCC[cqcc] = qcc;
|
||||
else
|
||||
context.currentTile.QCC[cqcc] = qcc;
|
||||
break;
|
||||
case 0xFF52: // Coding style default (COD)
|
||||
length = readUint16(data, position);
|
||||
var cod = {};
|
||||
j = position + 2;
|
||||
var scod = data[j++];
|
||||
cod.entropyCoderWithCustomPrecincts = !!(scod & 1);
|
||||
cod.sopMarkerUsed = !!(scod & 2);
|
||||
cod.ephMarkerUsed = !!(scod & 4);
|
||||
var codingStyle = {};
|
||||
cod.progressionOrder = data[j++];
|
||||
cod.layersCount = readUint16(data, j);
|
||||
j += 2;
|
||||
cod.multipleComponentTransform = data[j++];
|
||||
|
||||
if (cod.sopMarkerUsed || cod.ephMarkerUsed ||
|
||||
cod.selectiveArithmeticCodingBypass ||
|
||||
cod.resetContextProbabilities ||
|
||||
cod.terminationOnEachCodingPass ||
|
||||
cod.verticalyStripe || cod.predictableTermination ||
|
||||
cod.segmentationSymbolUsed)
|
||||
error('JPX error: Unsupported COD options: ' + uneval(cod));
|
||||
cod.decompositionLevelsCount = data[j++];
|
||||
cod.xcb = (data[j++] & 0xF) + 2;
|
||||
cod.ycb = (data[j++] & 0xF) + 2;
|
||||
var blockStyle = data[j++];
|
||||
cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);
|
||||
cod.resetContextProbabilities = !!(blockStyle & 2);
|
||||
cod.terminationOnEachCodingPass = !!(blockStyle & 4);
|
||||
cod.verticalyStripe = !!(blockStyle & 8);
|
||||
cod.predictableTermination = !!(blockStyle & 16);
|
||||
cod.segmentationSymbolUsed = !!(blockStyle & 32);
|
||||
cod.transformation = data[j++];
|
||||
if (cod.entropyCoderWithCustomPrecincts) {
|
||||
var precinctsSizes = {};
|
||||
while (j < length + position) {
|
||||
var precinctsSize = data[j];
|
||||
precinctsSizes.push({
|
||||
PPx: precinctsSize & 0xF,
|
||||
PPy: precinctsSize >> 4
|
||||
});
|
||||
}
|
||||
cod.precinctsSizes = precinctsSizes;
|
||||
}
|
||||
|
||||
if (context.mainHeader)
|
||||
context.COD = cod;
|
||||
else {
|
||||
context.currentTile.COD = cod;
|
||||
context.currentTile.COC = [];
|
||||
}
|
||||
break;
|
||||
case 0xFF90: // Start of tile-part (SOT)
|
||||
length = readUint16(data, position);
|
||||
var tile = {};
|
||||
tile.index = readUint16(data, position + 2);
|
||||
tile.length = readUint32(data, position + 4);
|
||||
tile.dataEnd = tile.length + position - 2;
|
||||
tile.partIndex = data[position + 8];
|
||||
tile.partsCount = data[position + 9];
|
||||
if (cod.sopMarkerUsed || cod.ephMarkerUsed ||
|
||||
cod.selectiveArithmeticCodingBypass ||
|
||||
cod.resetContextProbabilities ||
|
||||
cod.terminationOnEachCodingPass ||
|
||||
cod.verticalyStripe || cod.predictableTermination ||
|
||||
cod.segmentationSymbolUsed)
|
||||
throw 'Unsupported COD options: ' + uneval(cod);
|
||||
|
||||
context.mainHeader = false;
|
||||
if (tile.partIndex == 0) {
|
||||
// reset component specific settings
|
||||
tile.COD = context.COD;
|
||||
tile.COC = context.COC.slice(0); // clone of the global COC
|
||||
tile.QCD = context.QCD;
|
||||
tile.QCC = context.QCC.slice(0); // clone of the global COC
|
||||
}
|
||||
context.currentTile = tile;
|
||||
break;
|
||||
case 0xFF93: // Start of data (SOD)
|
||||
var tile = context.currentTile;
|
||||
if (tile.partIndex == 0) {
|
||||
initializeTile(context, tile.index);
|
||||
buildPackets(context);
|
||||
}
|
||||
if (context.mainHeader)
|
||||
context.COD = cod;
|
||||
else {
|
||||
context.currentTile.COD = cod;
|
||||
context.currentTile.COC = [];
|
||||
}
|
||||
break;
|
||||
case 0xFF90: // Start of tile-part (SOT)
|
||||
length = readUint16(data, position);
|
||||
var tile = {};
|
||||
tile.index = readUint16(data, position + 2);
|
||||
tile.length = readUint32(data, position + 4);
|
||||
tile.dataEnd = tile.length + position - 2;
|
||||
tile.partIndex = data[position + 8];
|
||||
tile.partsCount = data[position + 9];
|
||||
|
||||
// moving to the end of the data
|
||||
length = tile.dataEnd - position;
|
||||
context.mainHeader = false;
|
||||
if (tile.partIndex == 0) {
|
||||
// reset component specific settings
|
||||
tile.COD = context.COD;
|
||||
tile.COC = context.COC.slice(0); // clone of the global COC
|
||||
tile.QCD = context.QCD;
|
||||
tile.QCC = context.QCC.slice(0); // clone of the global COC
|
||||
}
|
||||
context.currentTile = tile;
|
||||
break;
|
||||
case 0xFF93: // Start of data (SOD)
|
||||
var tile = context.currentTile;
|
||||
if (tile.partIndex == 0) {
|
||||
initializeTile(context, tile.index);
|
||||
buildPackets(context);
|
||||
}
|
||||
|
||||
parseTilePackets(context, data, position, length);
|
||||
break;
|
||||
case 0xFF64: // Comment (COM)
|
||||
length = readUint16(data, position);
|
||||
// skipping content
|
||||
break;
|
||||
default:
|
||||
error('JPX error: Unknown codestream code: ' + code.toString(16));
|
||||
// moving to the end of the data
|
||||
length = tile.dataEnd - position;
|
||||
|
||||
parseTilePackets(context, data, position, length);
|
||||
break;
|
||||
case 0xFF64: // Comment (COM)
|
||||
length = readUint16(data, position);
|
||||
// skipping content
|
||||
break;
|
||||
default:
|
||||
throw 'Unknown codestream code: ' + code.toString(16);
|
||||
}
|
||||
position += length;
|
||||
}
|
||||
position += length;
|
||||
} catch (e) {
|
||||
if (this.failOnCorruptedImage)
|
||||
error('JPX error: ' + e);
|
||||
else
|
||||
warn('JPX error: ' + e + '. Trying to recover');
|
||||
}
|
||||
this.tiles = transformComponents(context);
|
||||
this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;
|
||||
|
@ -120,17 +120,17 @@ var Parser = (function ParserClosure() {
|
||||
// parse image stream
|
||||
var startPos = stream.pos;
|
||||
|
||||
// searching for the /\sEI\s/
|
||||
// searching for the /EI\s/
|
||||
var state = 0, ch;
|
||||
while (state != 4 && (ch = stream.getByte()) != null) {
|
||||
switch (ch) {
|
||||
case 0x20:
|
||||
case 0x0D:
|
||||
case 0x0A:
|
||||
state = state === 3 ? 4 : 1;
|
||||
state = state === 3 ? 4 : 0;
|
||||
break;
|
||||
case 0x45:
|
||||
state = state === 1 ? 2 : 0;
|
||||
state = 2;
|
||||
break;
|
||||
case 0x49:
|
||||
state = state === 2 ? 3 : 0;
|
||||
|
@ -24,7 +24,8 @@ var files = [
|
||||
'stream.js',
|
||||
'worker.js',
|
||||
'../external/jpgjs/jpg.js',
|
||||
'jpx.js'
|
||||
'jpx.js',
|
||||
'bidi.js'
|
||||
];
|
||||
|
||||
// Load all the files.
|
||||
|
2
test/pdfs/.gitignore
vendored
2
test/pdfs/.gitignore
vendored
@ -19,7 +19,9 @@
|
||||
!issue840.pdf
|
||||
!scan-bad.pdf
|
||||
!freeculture.pdf
|
||||
!pdfkit_compressed.pdf
|
||||
!issue918.pdf
|
||||
!issue1249.pdf
|
||||
!smaskdim.pdf
|
||||
!type4psfunc.pdf
|
||||
!S2.pdf
|
||||
|
1
test/pdfs/issue1243.pdf.link
Normal file
1
test/pdfs/issue1243.pdf.link
Normal file
@ -0,0 +1 @@
|
||||
http://www.nsa.gov/public_info/_files/nash_letters/nash_letters1.pdf
|
BIN
test/pdfs/issue1249.pdf
Normal file
BIN
test/pdfs/issue1249.pdf
Normal file
Binary file not shown.
1
test/pdfs/issue1257.pdf.link
Normal file
1
test/pdfs/issue1257.pdf.link
Normal file
@ -0,0 +1 @@
|
||||
http://hse-econ.fi/tervio/MediocritiesAndSuperstars.pdf
|
BIN
test/pdfs/pdfkit_compressed.pdf
Normal file
BIN
test/pdfs/pdfkit_compressed.pdf
Normal file
Binary file not shown.
@ -417,6 +417,12 @@
|
||||
"link": true,
|
||||
"type": "eq"
|
||||
},
|
||||
{ "id": "issue1249-load",
|
||||
"file": "pdfs/issue1249.pdf",
|
||||
"md5": "4f81339fa09422a7db980f34ea963609",
|
||||
"rounds": 1,
|
||||
"type": "load"
|
||||
},
|
||||
{ "id": "liveprogramming",
|
||||
"file": "pdfs/liveprogramming.pdf",
|
||||
"md5": "7bd4dad1188232ef597d36fd72c33e52",
|
||||
@ -460,6 +466,12 @@
|
||||
"link": true,
|
||||
"type": "eq"
|
||||
},
|
||||
{ "id": "pdfkit_compressed",
|
||||
"file": "pdfs/pdfkit_compressed.pdf",
|
||||
"md5": "ffe9c571d0a1572e234253e6c7cdee6c",
|
||||
"rounds": 1,
|
||||
"type": "eq"
|
||||
},
|
||||
{ "id": "issue925",
|
||||
"file": "pdfs/issue925.pdf",
|
||||
"md5": "f58fe943090aff89dcc8e771bc0db4c2",
|
||||
@ -487,5 +499,21 @@
|
||||
"rounds": 1,
|
||||
"link": true,
|
||||
"type": "eq"
|
||||
},
|
||||
{ "id": "issue1243",
|
||||
"file": "pdfs/issue1243.pdf",
|
||||
"md5": "130c849b83513d5ac5e03c6421fc7489",
|
||||
"rounds": 1,
|
||||
"pageLimit": 2,
|
||||
"link": true,
|
||||
"type": "eq"
|
||||
},
|
||||
{ "id": "issue1257",
|
||||
"file": "pdfs/issue1257.pdf",
|
||||
"md5": "9111533826bc21ed774e8e01603a2f54",
|
||||
"rounds": 1,
|
||||
"pageLimit": 2,
|
||||
"link": true,
|
||||
"type": "eq"
|
||||
}
|
||||
]
|
||||
|
@ -23,6 +23,7 @@
|
||||
<script type="text/javascript" src="/src/worker.js"></script>
|
||||
<script type="text/javascript" src="/external/jpgjs/jpg.js"></script>
|
||||
<script type="text/javascript" src="/src/jpx.js"></script>
|
||||
<script type="text/javascript" src="/src/bidi.js"></script>
|
||||
<script type="text/javascript" src="driver.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
@ -22,6 +22,7 @@ load:
|
||||
- ../../src/pattern.js
|
||||
- ../../src/stream.js
|
||||
- ../../src/worker.js
|
||||
- ../../src/bidi.js
|
||||
- ../../external/jpgjs/jpg.js
|
||||
- ../unit/obj_spec.js
|
||||
- ../unit/function_spec.js
|
||||
|
@ -190,6 +190,11 @@ var StepperManager = (function StepperManagerClosure() {
|
||||
else
|
||||
stepper.panel.setAttribute('hidden', true);
|
||||
}
|
||||
var options = stepperChooser.options;
|
||||
for (var i = 0; i < options.length; ++i) {
|
||||
var option = options[i];
|
||||
option.selected = option.value == pageNumber;
|
||||
}
|
||||
},
|
||||
saveBreakPoints: function saveBreakPoints(pageNumber, bps) {
|
||||
breakPoints[pageNumber] = bps;
|
||||
@ -234,7 +239,7 @@ var Stepper = (function StepperClosure() {
|
||||
for (var i = 0; i < IRQueue.fnArray.length; i++) {
|
||||
var line = c('tr');
|
||||
line.className = 'line';
|
||||
line.id = 'idx' + i;
|
||||
line.dataset.idx = i;
|
||||
table.appendChild(line);
|
||||
var checked = this.breakPoints.indexOf(i) != -1;
|
||||
var args = IRQueue.argsArray[i] ? IRQueue.argsArray[i] : [];
|
||||
@ -299,13 +304,14 @@ var Stepper = (function StepperClosure() {
|
||||
},
|
||||
goTo: function goTo(idx) {
|
||||
var allRows = this.panel.getElementsByClassName('line');
|
||||
for (var x = 0; x < allRows.length; x++) {
|
||||
allRows[x].style.backgroundColor = null;
|
||||
}
|
||||
var row = document.getElementById('idx' + idx);
|
||||
if (row) {
|
||||
row.style.backgroundColor = 'rgb(251,250,207)';
|
||||
row.scrollIntoView();
|
||||
for (var x = 0, xx = allRows.length; x < xx; ++x) {
|
||||
var row = allRows[x];
|
||||
if (row.dataset.idx == idx) {
|
||||
row.style.backgroundColor = 'rgb(251,250,207)';
|
||||
row.scrollIntoView();
|
||||
} else {
|
||||
row.style.backgroundColor = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -419,12 +419,12 @@
|
||||
d="M 33.278212 34.94062 A 10.31934 2.320194 0 1 1 12.639532,34.94062 A 10.31934 2.320194 0 1 1 33.278212 34.94062 z"
|
||||
transform="matrix(1.550487,0,0,1.978714,-12.4813,-32.49103)" />
|
||||
<path
|
||||
style="font-size:59.901077px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125.00000%;writing-mode:lr-tb;text-anchor:start;fill:#75a1d0;fill-opacity:1.0000000;stroke:#3465a4;stroke-width:1.0000004px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000;font-family:Bitstream Vera Sans"
|
||||
style="fill:#75a1d0;fill-opacity:1.0000000;stroke:#3465a4;stroke-width:1.0000004px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000"
|
||||
d="M 27.514356,37.542682 L 27.514356,28.515722 L 37.492820,28.475543 L 37.492820,21.480219 L 27.523285,21.480219 L 27.514356,11.520049 L 20.498082,11.531210 L 20.502546,21.462362 L 10.512920,21.536022 L 10.477206,28.504561 L 20.511475,28.475543 L 20.518171,37.515896 L 27.514356,37.542682 z "
|
||||
id="text1314"
|
||||
sodipodi:nodetypes="ccccccccccccc" />
|
||||
<path
|
||||
style="font-size:59.901077px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125.00000%;writing-mode:lr-tb;text-anchor:start;opacity:0.40860215;fill:url(#linearGradient4975);fill-opacity:1.0000000;stroke:url(#linearGradient7922);stroke-width:1.0000006px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000;font-family:Bitstream Vera Sans"
|
||||
style="opacity:0.40860215;fill:url(#linearGradient4975);fill-opacity:1.0000000;stroke:url(#linearGradient7922);stroke-width:1.0000006px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000"
|
||||
d="M 26.498702,36.533920 L 26.498702,27.499738 L 36.501304,27.499738 L 36.494607,22.475309 L 26.507630,22.475309 L 26.507630,12.480335 L 21.512796,12.498193 L 21.521725,22.475309 L 11.495536,22.493166 L 11.468750,27.466256 L 21.533143,27.475185 L 21.519750,36.502670 L 26.498702,36.533920 z "
|
||||
id="path7076"
|
||||
sodipodi:nodetypes="ccccccccccccc" />
|
||||
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
@ -407,12 +407,12 @@
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer">
|
||||
<path
|
||||
style="font-size:59.901077px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125.00000%;writing-mode:lr-tb;text-anchor:start;fill:#75a1d0;fill-opacity:1.0000000;stroke:#3465a4;stroke-width:1.0000004px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000;font-family:Bitstream Vera Sans"
|
||||
style="fill:#75a1d0;fill-opacity:1.0000000;stroke:#3465a4;stroke-width:1.0000004px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000"
|
||||
d="M 27.514356,28.359472 L 39.633445,28.475543 L 39.633445,21.480219 L 27.523285,21.480219 L 20.502546,21.462362 L 8.5441705,21.489147 L 8.5084565,28.457686 L 20.511475,28.475543 L 27.514356,28.359472 z "
|
||||
id="text1314"
|
||||
sodipodi:nodetypes="ccccccccc" />
|
||||
<path
|
||||
style="font-size:59.901077px;font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;text-align:start;line-height:125.00000%;writing-mode:lr-tb;text-anchor:start;opacity:0.40860215;fill:url(#linearGradient4975);fill-opacity:1.0000000;stroke:url(#linearGradient7922);stroke-width:1.0000006px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000;font-family:Bitstream Vera Sans"
|
||||
style="opacity:0.40860215;fill:url(#linearGradient4975);fill-opacity:1.0000000;stroke:url(#linearGradient7922);stroke-width:1.0000006px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1.0000000"
|
||||
d="M 38.579429,27.484113 L 38.588357,22.475309 L 9.5267863,22.493166 L 9.5000003,27.466256 L 38.579429,27.484113 z "
|
||||
id="path7076"
|
||||
sodipodi:nodetypes="ccccc" />
|
||||
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 13 KiB |
@ -29,6 +29,7 @@
|
||||
<script type="text/javascript" src="../src/worker.js"></script> <!-- PDFJSSCRIPT_REMOVE_CORE -->
|
||||
<script type="text/javascript" src="../external/jpgjs/jpg.js"></script> <!-- PDFJSSCRIPT_REMOVE_CORE -->
|
||||
<script type="text/javascript" src="../src/jpx.js"></script> <!-- PDFJSSCRIPT_REMOVE_CORE -->
|
||||
<script type="text/javascript" src="../src/bidi.js"></script> <!-- PDFJSSCRIPT_REMOVE_CORE -->
|
||||
<script type="text/javascript">PDFJS.workerSrc = '../src/worker_loader.js';</script> <!-- PDFJSSCRIPT_REMOVE_CORE -->
|
||||
<script type="text/javascript" src="debugger.js"></script>
|
||||
<script type="text/javascript" src="viewer.js"></script>
|
||||
|
@ -1023,6 +1023,57 @@ var DocumentOutlineView = function documentOutlineView(outline) {
|
||||
}
|
||||
};
|
||||
|
||||
// optimised CSS custom property getter/setter
|
||||
var CustomStyle = (function CustomStyleClosure() {
|
||||
|
||||
// As noted on: http://www.zachstronaut.com/posts/2009/02/17/
|
||||
// animate-css-transforms-firefox-webkit.html
|
||||
// in some versions of IE9 it is critical that ms appear in this list
|
||||
// before Moz
|
||||
var prefixes = ['ms', 'Moz', 'Webkit', 'O'];
|
||||
var _cache = { };
|
||||
|
||||
function CustomStyle() {
|
||||
}
|
||||
|
||||
CustomStyle.getProp = function get(propName, element) {
|
||||
// check cache only when no element is given
|
||||
if (arguments.length == 1 && typeof _cache[propName] == 'string') {
|
||||
return _cache[propName];
|
||||
}
|
||||
|
||||
element = element || document.documentElement;
|
||||
var style = element.style, prefixed, uPropName;
|
||||
|
||||
// test standard property first
|
||||
if (typeof style[propName] == 'string') {
|
||||
return (_cache[propName] = propName);
|
||||
}
|
||||
|
||||
// capitalize
|
||||
uPropName = propName.charAt(0).toUpperCase() + propName.slice(1);
|
||||
|
||||
// test vendor specific properties
|
||||
for (var i = 0, l = prefixes.length; i < l; i++) {
|
||||
prefixed = prefixes[i] + uPropName;
|
||||
if (typeof style[prefixed] == 'string') {
|
||||
return (_cache[propName] = prefixed);
|
||||
}
|
||||
}
|
||||
|
||||
//if all fails then set to undefined
|
||||
return (_cache[propName] = 'undefined');
|
||||
}
|
||||
|
||||
CustomStyle.setProp = function set(propName, element, str) {
|
||||
var prop = this.getProp(propName);
|
||||
if (prop != 'undefined')
|
||||
element.style[prop] = str;
|
||||
}
|
||||
|
||||
return CustomStyle;
|
||||
})();
|
||||
|
||||
var TextLayerBuilder = function textLayerBuilder(textLayerDiv) {
|
||||
this.textLayerDiv = textLayerDiv;
|
||||
|
||||
@ -1052,12 +1103,13 @@ var TextLayerBuilder = function textLayerBuilder(textLayerDiv) {
|
||||
textLayerDiv.appendChild(textDiv);
|
||||
|
||||
if (textDiv.dataset.textLength > 1) { // avoid div by zero
|
||||
// Adjust div width (via letterSpacing) to match canvas text
|
||||
// Adjust div width to match canvas text
|
||||
// Due to the .offsetWidth calls, this is slow
|
||||
// This needs to come after appending to the DOM
|
||||
textDiv.style.letterSpacing =
|
||||
((textDiv.dataset.canvasWidth - textDiv.offsetWidth) /
|
||||
(textDiv.dataset.textLength - 1)) + 'px';
|
||||
var textScale = textDiv.dataset.canvasWidth / textDiv.offsetWidth;
|
||||
CustomStyle.setProp('transform' , textDiv,
|
||||
'scale(' + textScale + ', 1)');
|
||||
CustomStyle.setProp('transformOrigin' , textDiv, '0% 0%');
|
||||
}
|
||||
} // textLength > 0
|
||||
}
|
||||
@ -1097,7 +1149,8 @@ var TextLayerBuilder = function textLayerBuilder(textLayerDiv) {
|
||||
textDiv.style.fontSize = fontHeight + 'px';
|
||||
textDiv.style.left = text.geom.x + 'px';
|
||||
textDiv.style.top = (text.geom.y - fontHeight) + 'px';
|
||||
textDiv.textContent = text.str;
|
||||
textDiv.textContent = PDFJS.bidi(text, -1);
|
||||
textDiv.dir = text.direction;
|
||||
textDiv.dataset.textLength = text.length;
|
||||
this.textDivs.push(textDiv);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user