05-03-2015, 01:22 PM | #1 |
Banned
Posts: 272
Karma: 1224588
Join Date: Sep 2014
Device: Sony PRS 650
|
Create a CSS-file from fonts
Hi,
i created a very very simple plugin. It just iterates through the font files and creates a StyleFont.css file in the book. Last edited by rubeus; 03-30-2016 at 04:27 AM. |
05-03-2015, 02:05 PM | #2 |
Grand Sorcerer
Posts: 27,968
Karma: 198535232
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Cool. I added your plugin to the sticky list of plugins. Thanks for contributing.
I don't know much about fonts/fontfiles in general, but it does seem like the most straightforward way to manipulate/query font files in Python is through third-party library-modules -- which makes things harder to distribute to other users. I do know calibre does some font manipulation stuff (subsetting and such) perhaps there's something there that can offer some enlightenment. |
Advert | |
|
05-09-2015, 08:37 AM | #3 |
Banned
Posts: 272
Karma: 1224588
Join Date: Sep 2014
Device: Sony PRS 650
|
New Version in #1
I'm trying to guess some values derived from the filename |
05-23-2015, 05:24 AM | #4 |
Banned
Posts: 272
Karma: 1224588
Join Date: Sep 2014
Device: Sony PRS 650
|
New Version 020 in #1
With the help of Doitso the plugin is able to read the fontname directly from the file. Weight and style are derived from the fontname. If the fontname cant be read, the filename is taken into account. Last edited by rubeus; 05-23-2015 at 05:27 AM. |
11-30-2015, 09:54 AM | #5 |
Banned
Posts: 272
Karma: 1224588
Join Date: Sep 2014
Device: Sony PRS 650
|
The new version 0.3.0 requires Python 3.x and the PIL libraries. This is present if you are using sigil from version 0.9.1 or newer and use the built-in python interpreter
I will leave the old one(0.2.0 for Python 2.7) in the first post, but it will not be maintained any longer (by me) |
Advert | |
|
12-18-2015, 08:16 AM | #6 |
Wizard
Posts: 1,035
Karma: 11227159
Join Date: Mar 2013
Location: Guben, Brandenburg, Germany
Device: Kobo Clara 2E, Tolino Shine 3
|
Useful tool, thank you! I hope to avoid error messages by implementing fonts that sometimes occur, in the future!
|
12-19-2015, 01:03 PM | #7 |
Banned
Posts: 272
Karma: 1224588
Join Date: Sep 2014
Device: Sony PRS 650
|
Minor Bugfixes in #1
|
01-11-2016, 02:51 PM | #8 |
Banned
Posts: 272
Karma: 1224588
Join Date: Sep 2014
Device: Sony PRS 650
|
Additinal bugfix in #1
|
01-20-2016, 01:05 AM | #9 |
Member
Posts: 16
Karma: 10
Join Date: Dec 2015
Device: sigil
|
Hello everyone,
I have following error and I don't know how to fix it : Code:
Status: failed Traceback (most recent call last): File "C:\Python34\lib\site-packages\PIL\ImageFont.py", line 239, in truetype return FreeTypeFont(font, size, index, encoding) File "C:\Python34\lib\site-packages\PIL\ImageFont.py", line 132, in __init__ "", size, index, encoding, self.font_bytes) OSError: unknown file format During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Program Files (x86)\Sigil8\plugin_launchers\\python\launcher.py", line 135, in launch self.exitcode = target_script.run(container) File "C:\Users\Andry\AppData\Local\sigil-ebook\sigil\plugins\AddStyleFont\plugin.py", line 17, in run font_object = ImageFont.truetype(BytesIO(bk.readfile(id))) File "C:\Python34\lib\site-packages\PIL\ImageFont.py", line 241, in truetype ttf_filename = os.path.basename(font) File "C:\Python34\lib\ntpath.py", line 246, in basename return split(p)[1] File "C:\Python34\lib\ntpath.py", line 217, in split d, p = splitdrive(p) File "C:\Python34\lib\ntpath.py", line 159, in splitdrive if len(p) > 1: TypeError: object of type '_io.BytesIO' has no len() Error: object of type '_io.BytesIO' has no len() Python version : 3.4.0 x86 OS : Windows 7 x64 Can anyone help me please ? Only one computer generate this error. Others works fine. Thanks for answer ! Last edited by hantsaniala; 01-20-2016 at 03:03 AM. |
01-20-2016, 02:14 AM | #10 |
Banned
Posts: 272
Karma: 1224588
Join Date: Sep 2014
Device: Sony PRS 650
|
The one throwing the exception does not have the library PIL installed or is not using the internal Python interpreter or has a wrong version of Sigil.
|
01-20-2016, 03:03 AM | #11 | |
Member
Posts: 16
Karma: 10
Join Date: Dec 2015
Device: sigil
|
Quote:
Code:
pip install Pillow Other computer with the same installation works fine. |
|
01-20-2016, 04:21 AM | #12 |
Banned
Posts: 272
Karma: 1224588
Join Date: Sep 2014
Device: Sony PRS 650
|
If they work fine they don't have the same installation.
|
06-10-2016, 10:03 AM | #13 |
Enthusiast
Posts: 28
Karma: 15448
Join Date: Apr 2010
Location: Leiden
Device: iRex DR800S, Kindle DX, Kobo H2O, Kobo Aura One, Kobo Forma, Kobo Sage
|
There is no longer a download link.
Reason? |
06-10-2016, 10:09 AM | #14 |
Sigil Developer
Posts: 8,110
Karma: 5450184
Join Date: Nov 2009
Device: many
|
rubeus was banned from MR because of his repeated attacks against newbie posters contrary to repeated requests that he stop. My guess he has removed all of his plugins which is of course his right. I will remove them from the plugin index.
So unless he has posted them on some personal page someplace, you are out of luck. Sorry about that but we simply can not have newbie questions being verbally attacked in our own help forums. |
06-10-2016, 11:50 AM | #15 |
Grand Sorcerer
Posts: 5,636
Karma: 23191067
Join Date: Dec 2010
Device: Kindle PW2
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Accessing fonts from CSS | JSWolf | Kobo Reader | 11 | 07-03-2015 10:49 AM |
How to invoke different fonts in CSS 2.3.1? | xuyn2003 | Kobo Reader | 32 | 01-06-2013 09:52 PM |
working with fonts in css | jayz | Kindle Formats | 9 | 10-29-2012 04:09 PM |
Possible to embed fonts in CSS of .lit file? | tanzer21 | Calibre | 9 | 06-30-2010 07:26 PM |
Suggestion: let's create typographic CSS | sic | Sony Reader | 2 | 08-20-2007 07:17 PM |