Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amazon linux cannot render text #10

Closed
vsarpe opened this issue May 11, 2017 · 4 comments
Closed

Amazon linux cannot render text #10

vsarpe opened this issue May 11, 2017 · 4 comments

Comments

@vsarpe
Copy link

vsarpe commented May 11, 2017

I have an Linux AWS EC2 instance imaged with "Amazon Linux AMI 2017.03.0.20170417 x86_64 HVM GP2". I am trying to generate avatars with letters based on initials.

My code:

const Canvas = require('canvas-prebuilt');
...
const canvas = new Canvas(size, size);
const ctx = canvas.getContext('2d');

ctx.fillStyle = colours[colourIndex - 1];
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.font = Math.round(canvas.width / 2) + "px Arial";                                                                                                                                                                                                                                                                   
ctx.textAlign = "center";                                                                                                                                                                                                                                                                                               
ctx.fillStyle = "#FF0000";                                                                                                                                                                                                                                                                                              
ctx.fillText(initials, size / 2, size / 1.5);     
...

On my OSX, it renders the image correctly. However, on the ec2-instance, it draws the background correctly, the the letters show up as unrecognized characters (□□) in small font.

No errors at all during npm install or when running my code. What could be missing?

@vsarpe vsarpe closed this as completed May 11, 2017
@vsarpe
Copy link
Author

vsarpe commented May 11, 2017

I somehow missed the first issue regarding font on Linux.

@chearon
Copy link
Member

chearon commented May 11, 2017

Yeah sorry, I need to reopen that, because it is currently still an issue.

A while back I re-did the builds so that fonts worked correctly on Linux (which is why #6 is closed), but those builds depended on a very new version of Glib and broke everyone else's builds in Travis, which are on a very old version of Ubuntu (see all the madness in #8).

So I'm sort of stuck in a dilemma where I can't support fonts without ditching old versions of linux, and haven't yet figured out what to do

@chearon
Copy link
Member

chearon commented May 11, 2017

Actually @vsarpe did you try npm install canvas-prebuilt@1.6.5-prerelease.1? that one should have the new build, but you need to have a later version of GLib

@vsarpe
Copy link
Author

vsarpe commented May 11, 2017

What version glib would be required for that build? Currently, I have glibc 2.17.

I get the following error:

module.js:597
  return process.dlopen(module, path._makeLong(filename));
                 ^

Error: libpcre.so.3: cannot open shared object file: No such file or directory
    at Error (native)
    at Object.Module._extensions..node (module.js:597:18)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/ec2-user/clickdishes-backend/node_modules/canvas-prebuilt/canvas/lib/bindings.js:3:18)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/ec2-user/clickdishes-backend/node_modules/canvas-prebuilt/canvas/lib/canvas.js:13:14)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/ec2-user/clickdishes-backend/utils/avatarUtils.js:3:16)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)

libpcre is also latest (from amazon).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants