MobileRead Forums

MobileRead Forums (https://www.mobileread.com/forums/index.php)
-   Plugins (https://www.mobileread.com/forums/forumdisplay.php?f=268)
-   -   ePUB Optimizer (https://www.mobileread.com/forums/showthread.php?t=252010)

JSWolf 12-04-2014 03:49 PM

Quote:

Originally Posted by Toxaris (Post 2993671)
No, not until I can find a good way to determine if a picture is grayscale or color.

That's actually easier then you think due to the way the images get processed with the profiles.

What you do is copy all of the images. Run with the RGB profile and any image that come out with 0 bytes is greyscale. Then take just those images (the original versions) and run them through the greyscale profile. Then put everything back where they came from and done. You can also do it in reverse as well. RGB processed with the greyscale profile also come out 0 bytes.

An ePub (the one I sent you) I just optimized (using the profiles) came out with the images totaling 334KB. The same images using ePUBOptimizer came out to be 340KB. I know 6KB isn't a lot, but it does add up.

I'd be happy to test if you decide to do it this way.

roger64 12-10-2014 10:34 AM

Hi

About ttf and otf

FontShrinker dealt only with ttf fonts.

EPUB Optimizer has been issued quite recently. Can it subset now otf fonts or there is no hope about it?

Toxaris 12-10-2014 04:28 PM

It uses the same core and for now it remains ttf only. In theory it should also support otf, but it is a hit and miss. If I find the cause, I might be able to also support otf.

roger64 12-10-2014 08:23 PM

Thanks and good luck.

Toxaris 12-11-2014 02:59 AM

It seems that they are multiple types of otf fonts. Some of them resemble ttf and those work fine. Others resemble Type 1 and those give issues apparently. If I find the solution, I will of course implement this.

JSWolf 12-16-2014 01:43 PM

Quote:

Originally Posted by Toxaris (Post 2999510)
It seems that they are multiple types of otf fonts. Some of them resemble ttf and those work fine. Others resemble Type 1 and those give issues apparently. If I find the solution, I will of course implement this.

I know that ePUBOptimizer won't subset OTF fonts, but could you make it so if an OTF font is not used that it gets removed? Thanks.

Toxaris 12-16-2014 02:28 PM

New version of the plugin is out. With big thanks to KevinH I can now garantuee it will also work on OSX. I will adapt the first post to reflect the changes.

Toxaris 12-16-2014 02:30 PM

Quote:

Originally Posted by JSWolf (Post 3003974)
I know that ePUBOptimizer won't subset OTF fonts, but could you make it so if an OTF font is not used that it gets removed? Thanks.

I could. Perhaps in the new version. I am still working on supporting OTF fonts.

JSWolf 12-16-2014 03:19 PM

Quote:

Originally Posted by Toxaris (Post 3004009)
I could. Perhaps in the new version. I am still working on supporting OTF fonts.

Even if you don't end up supporting OTF, removing unused OTF would help.

Toxaris 01-27-2015 05:13 PM

New version of the plugin is out. There was a serious bug in the ePUBOptimizer program which is solved now (don't worry, if you haven't noticed, the bug was not for you...). New is a change in the way of working. If from one font family multiple fonts are delivered, the actual usage per font is checked. However, if only one font for that font family is delivered, the usage of the complete font family is checked, not taking bold/italic into account. This is less strict perhaps, but resembles more the actual usage of fonts in ePUB I guess.

Turtle91 03-01-2015 01:45 AM

Man...I disappear for a little bit and you guys go and do all kinds of really cool things... ;)

Toxaris,
I got this unhandled exception message when I ran the plugin on my shell/default epub saying that ':first-letter' has an invalid token:


Quote:

Status: success

Processing C:\Users\Dion\AppData\Local\sigil-ebook\sigil\plugins\ePUBOptimizer\dummy.epub
Get unique characters per font

Unhandled Exception: System.Xml.XPath.XPathException: '//*[contains(concat(' ',normalize-space(@class),' '),' SecBrk2 ')]:first-letter' has an invalid token.
at MS.Internal.Xml.XPath.XPathScanner.NextLex()
at MS.Internal.Xml.XPath.XPathParser.ParsePredicate(A stNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseStep(AstNod e qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseRelativeLoc ationPath(AstNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseLocationPat h(AstNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParsePathExpr(As tNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseUnionExpr(A stNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseUnaryExpr(A stNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseMultiplicat iveExpr(AstNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseAdditiveExp r(AstNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseRelationalE xpr(AstNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseEqualityExp r(AstNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseAndExpr(Ast Node qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseOrExpr(AstN ode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseExpresion(A stNode qyInput)
at MS.Internal.Xml.XPath.XPathParser.ParseXPathExpres ion(String xpathExpresion)
at System.Xml.XPath.XPathExpression.Compile(String xpath, IXmlNamespaceResolver nsResolver)
at System.Xml.XPath.XPathNavigator.Select(String xpath)
at HtmlAgilityPack.HtmlNode.SelectNodes(String xpath)
at Toxaris.ToxarisePUB.FunColl.ApplyStylesheetAsInlin e(String html, String style)
at ePUBOptimizer.Main.HandleePUB(String ePUB)
at ePUBOptimizer.Main.Main()
Does this not support pseudo-classes? or am I making a heretofore undiscovered mistake in my css?

CSS:
Quote:

.SecBrk2:first-letter {font-family:FunkyFont}

Toxaris 03-01-2015 02:46 AM

No, it does support pseudo-classes, although most readers don't... However, the following pseudo-classes are currently not supported:
- :first-line
- :first-letter
- :before
- :after

Now, :before and :after would not be an issue I guess, but the other ones might. Still, it should not cause an error. The issue with these pseudo-classes is that they address portions of text within a tag, which cannot be translated to an XPath statement which I use to inline the CSS (necessary to properly determine the styling of tags). I think I can work around the :first-letter, but the :first-line might be much more difficult. I need to read into the :first-line a bit more, but IIRC the first line will differ on things like font-size and screen-size. If that is the case, it will become quite difficult to incorporate that.
I will look into this more and will report back.

Toxaris 11-08-2015 04:21 PM

I have updated the plugin to reflect the changes in Sigil. It now supports version 3.4 of Python (with a very big thank you to Doitsu!).

Toxaris 11-09-2015 12:05 PM

There were some small errors in the conversion. Now it will work on both 2.7 and 3.4.

I also forgot to incorporate the error as mentioned by Turtle91. That one is fixed as well...

ovinio 11-17-2015 08:17 AM

I've got an error while downloading the plugin
Sorry, this file is infected with a virus


All times are GMT -4. The time now is 08:27 PM.

Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.