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

Render small-caps font variant #1611

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions test/canvas.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,29 +447,34 @@ describe('Canvas', function () {
});

it('Context2d#font=small-caps', function () {
if (process.platform == 'win32'){
// the windows version of pango (< 1.37.1) is too old to support font varients
zbjornson marked this conversation as resolved.
Show resolved Hide resolved
this.skip();
}

registerFont('./examples/crimsonFont/Crimson-Bold.ttf', {family: 'Crimson'})
let canvas = createCanvas(200,200),
let canvas = createCanvas(200, 200),
ctx = canvas.getContext('2d');

// here is where the dot will appear above a lower-case 'i' (and be missing for small-caps)
let offsetX = 15, offsetY = -115;

ctx.font = "180px Crimson";
ctx.fillText('i', 20, 180);
let lcDottedI = ctx.getImageData(20+offsetX, 180+offsetY, 20,20).data;
let lcDottedI = ctx.getImageData(20 + offsetX, 180 + offsetY, 20, 20).data;
assert.equal(lcDottedI.some(p => p > 0), true);

ctx.save()

ctx.font = "small-caps 180px Crimson";
ctx.fillText('i', 80, 180);
let scEmptySpace = ctx.getImageData(80+offsetX, 180+offsetY, 20,20).data;
let scEmptySpace = ctx.getImageData(80 + offsetX, 180 + offsetY, 20, 20).data;
assert.equal(scEmptySpace.every(p => p == 0), true);

ctx.restore()

ctx.fillText('i', 140, 180);
let lcDottedAgain = ctx.getImageData(140+offsetX, 180+offsetY, 20,20).data;
let lcDottedAgain = ctx.getImageData(140 + offsetX, 180 + offsetY, 20, 20).data;
assert.equal(lcDottedAgain.some(p => p > 0), true);
});

Expand Down