Comments (17)
Hey @chrissimpkins thanks for reply!
Let me know if you have any problems with it.
Probably because I'm new to python, but I am having trouble with fonttools dependency...
if we do add the font renaming to this tool, best to create option to specify name on command line or automate it in some fashion based upon the change in the line spacing?
100% could have optional flag to specify name, like:
font-line percent 120 ~/Downloads/Menlo-Regular.ttf --name="Menlo LG 120"
Or something similar?
from font-line.
@jesseleite great! enjoy!
from font-line.
On the to do list! I have actually been considering a standalone tool to rename fonts because we need this for other things.
Here is a Python script that will accomplish this until it is in this tool or we have a standalone renaming tool (that will likely be based on the script in the repo below):
https://github.com/chrissimpkins/fontname.py
Let me know if you have any problems with it. Instructions are on the repository readme page.
Note that the script renames the fonts without writing to new file paths so create copies if you intend to keep previous names.
Assuming that the font has all the namerecords correcly set, I'd do the following:
- Get old_family_name from nameID 16, and if it's not present use nameID 1 as fallback
- Set new_family_name = old_family_name + linegap (or whatever)
- Replace the old_family_name with new_family_name in nameIDs 1, 3, 4, 6, 16, 18 (at least these ones, but better in all nemerecords) and CFF names
Since some namerecords contain spaces and other don't, a double replacement is needed:
new_string = old_string.replace(old_family_name, new_family_name).replace(old_family_name.replace(" ", ""), new_family_name.replace(" ", ""))
But I'd not to this by default, leaving the choice to the user.
Anyway, I tested this script yesterday for the first time and it's superb!
from font-line.
Yes! I will add an option to allow the user choose if changing the family name or leave it as is.
from font-line.
This is a great idea Anton. It would also be useful to modify the name in case you want to re-release a modified version of a open font licensed font with a reserved font name. This is not difficult. Will leave this open to remind me to do it when I get back to work on this tool.
from font-line.
We just discussed this over here source-foundry/Hack#345 (comment).
I am interested in whether anyone has thoughts about whether we should support an automated approach (e.g. add integer that indicates the percent UPM value passed at the command line to the current font family name - Coolfont 25, Coolfont 15) or user specified at the command line so that you can change the font family name to anything that you would like in order to create your own naming scheme. Either approach should permit side-by-side installs of fonts with different line spacing settings.
Let me know what you think. I am prepared to add this if there is interest in it.
from font-line.
@chrissimpkins Would love to rename font so I could have multiple line heights installed as well.
How hard would this be to add?
from font-line.
On the to do list! I have actually been considering a standalone tool to rename fonts because we need this for other things.
Here is a Python script that will accomplish this until it is in this tool or we have a standalone renaming tool (that will likely be based on the script in the repo below):
https://github.com/chrissimpkins/fontname.py
Let me know if you have any problems with it. Instructions are on the repository readme page.
Note that the script renames the fonts without writing to new file paths so create copies if you intend to keep previous names.
from font-line.
@jesseleite if we do add the font renaming to this tool, best to create option to specify name on command line or automate it in some fashion based upon the change in the line spacing?
from font-line.
@jesseleite strange. Mind dropping into the Python2 and Python3 REPL to check the import?:
$ python2
> import fontTools
$ python3
> import fontTools
from font-line.
Incidentally, you should already have fontTools installed if you are using font-line... It is a dependency and is automatically installed with the font-line install. Maybe it is installed under Py3 for some reason? Let's see what the above shows and can troubleshoot from there.
from font-line.
100% could have optional flag to specify name
👍 thanks for the feedback!
from font-line.
Ahh it was python2
I needed to run. Thanks 👍
from font-line.
you must default to python3. this is a good thing! time to get rid of py2...
work as a separate install?
from font-line.
Yeah learning :) I did get it to work though, thanks!
from font-line.
Assuming that the font has all the namerecords correcly set, I'd do the following:
Get old_family_name from nameID 16, and if it's not present use nameID 1 as fallback
Set new_family_name = old_family_name + linegap (or whatever)
Replace the old_family_name with new_family_name in nameIDs 1, 3, 4, 6, 16, 18 (at least these ones, but better in all nemerecords) and CFF names
Since some namerecords contain spaces and other don't, a double replacement is needed:new_string = old_string.replace(old_family_name, new_family_name).replace(old_family_name.replace(" ", ""), new_family_name.replace(" ", ""))
But I'd not to this by default, leaving the choice to the user.
Anyway, I tested this script yesterday for the first time and it's superb!
Something that you intend to support in ftCLI?
from font-line.
Done, seems working:
from font-line.
Related Issues (20)
- Fix version string reporting in report command HOT 1
- In `modify_linegap_percent()`, shouldn't all the `int()` functions be `round()` instead?
- Add support for Markdown formatted metrics list
- Add support for JSON formatted metrics standard output
- Fix License link in ToC
- Better error handling? Crashes when an attribute is not present HOT 12
- Add test font for missing attribute issue
- pip install fails due to permission error HOT 2
- shebang issue HOT 4
- Eliminate Python 2.7 support
- font-line will be upgrading to Py3.6+ support only! HOT 1
- Option to modify ┬ │ ┼ ┴ ├ ┤┘└┌ ┐ glyph heights HOT 7
- Font weight changed after changing the interline spacing HOT 16
- Dependabot couldn't authenticate with https://pypi.python.org/simple/ HOT 1
- Add metrics warning to report tool for values that values fall within yMin / yMax HOT 1
- Allow negative percents HOT 10
- Percent command does not properly calculate line spacing when fonts define TypoAscender + TypoDescender > UPM HOT 13
- Report data modification and writing back to fontfile! HOT 6
- Capital height and X height in Metrics Report. Feasible? HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from font-line.