-
Notifications
You must be signed in to change notification settings - Fork 6
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
Glyph table sort order #26
Comments
We could enable to inject some custom function via the options that allows selection and order of the glyphs that go into the table. The signature would look something like this: /**
* `this` is the GlyphTable.
* returns: `glyphOrder` an array of glyph indexes
*/
function customGlyphOrder( ) {
var glyphOrder = [];
this._font; // the opentype.js font object
this._options; // the options can be used to modify the behavior
...
return glyphOrder;
} It could be also useful to allow some <div class="glyph-table" data-glyphorder="lowercase"></div> To interperet the function customGlyphOrder( ) {
// this._options.glyphorder === 'lowercase';
} What do you think? |
To give some context, the current default order would be created like this (compare https://github.com/graphicore/specimenTools/blob/master/lib/widgets/GlyphTable.js#L174): function customGlyphOrder( ) {
var glyphOrder = [], i, l;
for(i=0,l=this._font.glyphNames.names.length;i<l;i++)
glyphOrder.push(i);
return glyphOrder;
} |
That is great, with the data attribute, the same way you do with de xHeight, select, order. |
What's the deal with For the sake of simplicity, I'd just provide one attribute <div class="glyph-table" data-glyphorder='{select: "lowercase", order: "a-z"}'></div> function customGlyphOrder( ) {
options = JSON.parse(this._options.glyphorder);
// options.select === 'lowercase'
// options.order === '"a-z'
} Or a separated string: <div class="glyph-table" data-glyphorder="lowercase, a-z"></div> function customGlyphOrder( ) {
options = this._options.glyphorder.split(',')
.map(function(str){return str.trim();})
select = options[0]; // === 'lowercase'
order = options[1]; // === 'a-z'
} |
The best would be to filter through data attribute |
I'm suggesting that you'll implement this yourself. It's hard to get this right for all possible fonts. But, for one foundry, its probably feasible. |
So in the "_initCells" function i can call the customGlyphOrder to change the order, but on the this._font.glyphNames.names i only have unicode, so i should implement depending on the range unicode? |
Yes. It's not implemented yet, but you will be able to define your own
You can use all of |
Thx, i'll do that. |
Ok, I'll implement this. What is the deal with "xHeight"? |
The way you give parameters here https://graphicore.github.io/mdlFontSpecimen/ |
It's underway #27 I modified the example/simple to test this, here's a gist: https://gist.github.com/graphicore/5d8fe09b990ce20d10a4eac3301948dc Notes: index.html Attributes starting with <div class="glyph-table" data-glyphtable-contains="A"></div> main.js: I'm only showing the interesting parts here.
function customGlyphOrder() {
//jshint validthis:true
var glyphOrder = [], i, l, name;
for(i=0,l=this._font.glyphNames.names.length;i<l;i++) {
name = this._font.glyphNames.names[i];
if(name.indexOf(this._dataAttributes.contains) !== -1)
glyphOrder.push(i);
}
return glyphOrder;
}
var glyphTablesOptions = {
glyphTable: {
glyphOrderFunc: customGlyphOrder
}
};
factories = [
...
, ['glyph-table', GlyphTables, glyphTablesOptions]
...
]; |
When you confirm that this is sufficient, I will merge. :-) |
Hi,
a client of mine asks me if i can manage the glyph table sort order, or at least have a glyph table per font variation (uppercase, lowercase, aåáâã, xyzåáâã).
The text was updated successfully, but these errors were encountered: