Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions src/TTFFont.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import TTFGlyph from './glyph/TTFGlyph';
import CFFGlyph from './glyph/CFFGlyph';
import SBIXGlyph from './glyph/SBIXGlyph';
import COLRGlyph from './glyph/COLRGlyph';
import CBDTGlyph from './glyph/CBDTGlyph';
import GlyphVariationProcessor from './glyph/GlyphVariationProcessor';
import TTFSubset from './subset/TTFSubset';
import CFFSubset from './subset/CFFSubset';
Expand Down Expand Up @@ -414,6 +415,9 @@ export default class TTFFont {
} else if ((this.directory.tables.COLR) && (this.directory.tables.CPAL)) {
this._glyphs[glyph] = new COLRGlyph(glyph, characters, this);

} else if (this.directory.tables.CBLC || this.directory.tables.EBLC) {
this._glyphs[glyph] = new CBDTGlyph(glyph, characters, this);

} else {
this._getBaseGlyph(glyph, characters);
}
Expand Down
25 changes: 25 additions & 0 deletions src/glyph/CBDTGlyph.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Glyph from './Glyph';
import Path from './Path';

/**
* Represents a bitmap glyph in the CBDT/CBLC format (e.g. color emoji).
* CBDT glyphs are bitmap-based and have no vector outlines.
* Metrics (advanceWidth etc.) come from hmtx via the base Glyph._getMetrics().
*/
export default class CBDTGlyph extends Glyph {
type = 'CBDT';

_getPath() {
// CBDT glyphs are bitmap-based, no vector outlines
return new Path();
}

_getCBox() {
return this.path.cbox;
}

_getBBox() {
return this.path.bbox;
}
}

8 changes: 8 additions & 0 deletions src/glyph/COLRGlyph.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ export default class COLRGlyph extends Glyph {
get layers() {
let cpal = this._font.CPAL;
let colr = this._font.COLR;

// COLR v1 fonts (e.g. OpenMoji COLRv1) use paint-based records
// instead of v0 baseGlyphRecord. fontkit only supports v0, so
// return null to let callers fall back gracefully.
if (!colr || !colr.baseGlyphRecord) {
return null;
}

let low = 0;
let high = colr.baseGlyphRecord.length - 1;

Expand Down
8 changes: 7 additions & 1 deletion src/glyph/TTFGlyph.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,13 @@ export default class TTFGlyph extends Glyph {
if (glyph.numberOfContours < 0) {
// resolve composite glyphs
for (let component of glyph.components) {
let contours = this._font.getGlyph(component.glyphID)._getContours();
// In COLR fonts, getGlyph() may return a COLRGlyph which doesn't
// have _getContours(). Use _getBaseGlyph() to get the TTF outline.
let componentGlyph = this._font._getBaseGlyph(component.glyphID) || this._font.getGlyph(component.glyphID);
if (!componentGlyph || typeof componentGlyph._getContours !== 'function') {
continue;
}
let contours = componentGlyph._getContours();
for (let i = 0; i < contours.length; i++) {
let contour = contours[i];
for (let j = 0; j < contour.length; j++) {
Expand Down
Binary file added test/data/NotoColorEmoji/NotoColorEmoji.ttf
Binary file not shown.
92 changes: 92 additions & 0 deletions test/data/NotoColorEmoji/OFL.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
This Font Software is licensed under the SIL Open Font License,
Version 1.1.

This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL

-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font
creation efforts of academic and linguistic communities, and to
provide a free and open framework in which fonts may be shared and
improved in partnership with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply to
any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software
components as distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to,
deleting, or substituting -- in part or in whole -- any of the
components of the Original Version, by changing formats or by porting
the Font Software to a new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed,
modify, redistribute, and sell modified and unmodified copies of the
Font Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components, in
Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the
corresponding Copyright Holder. This restriction only applies to the
primary font name as presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created using
the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
13 changes: 13 additions & 0 deletions test/data/OpenMoji/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
OpenMoji
https://openmoji.org/

Copyright 2018-2024 OpenMoji project
https://github.com/hfg-gmuend/openmoji

OpenMoji graphics are licensed under the Creative Commons
Attribution-ShareAlike License 4.0 (CC BY-SA 4.0)

https://creativecommons.org/licenses/by-sa/4.0/

Attribution: All emojis designed by OpenMoji – the open-source emoji
and icon project. License: CC BY-SA 4.0
Binary file added test/data/OpenMoji/OpenMoji-color-cbdt.ttf
Binary file not shown.
Binary file added test/data/OpenMoji/OpenMoji-color-colr1_svg.ttf
Binary file not shown.
Binary file added test/data/OpenMoji/OpenMoji-color-glyf_colr_0.ttf
Binary file not shown.
39 changes: 39 additions & 0 deletions test/data/Twemoji/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
## License for the Code

Copyright 2016-2018, Mozilla Foundation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.



## License for the Visual Design

The Emoji art comes from [Twemoji](https://twitter.github.io/twemoji),
and is used and redistributed under the CC-BY-4.0
[license terms](https://github.com/twitter/twemoji#license)
offered by the Twemoji project.

### Creative Commons Attribution 4.0 International (CC BY 4.0)
https://creativecommons.org/licenses/by/4.0/

#### You are free to:
**Share** β€” copy and redistribute the material in any medium or format

**Adapt** β€” remix, transform, and build upon the material for any purpose, even commercially.

#### Under the following terms:
**Attribution** β€” You must give appropriate credit, provide a link to the license,
and indicate if changes were made.

**No additional restrictions** β€” You may not apply legal terms or technological measures
that legally restrict others from doing anything the license permits.
Binary file added test/data/Twemoji/Twemoji.Mozilla.ttf
Binary file not shown.
Loading