Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Plugins

Notices

Reply
 
Thread Tools Search this Thread
Old 05-21-2016, 12:59 AM   #571
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
The way fallback fonts are chosen when the specified font does not exist has changed -- but the issue of not being able to use the first font int he list has always existed.

Yes, stroke is no longer possible (well technically, it is possible, just more effort than I feel like putting in for a plugin that I dont use/maintain).
kovidgoyal is online now   Reply With Quote
Old 05-25-2016, 06:37 PM   #572
chorpler
Zealot
chorpler has a complete set of Star Wars action figures.chorpler has a complete set of Star Wars action figures.chorpler has a complete set of Star Wars action figures.
 
Posts: 128
Karma: 278
Join Date: Jun 2008
Device: Kindle; PRS-500; MobiPocket on Windows Mobile
Quote:
Originally Posted by baggins41 View Post
Also, I notice the "stroke" option has gone away. Did something change in Calibre that makes its existence no longer viable for some reason? It was extremely valuable in improving readability on certain cover images.
Agreed -- a dark "stroke" color surrounding a lighter "fill" color (or vice versa) makes the letters much more readable on images where the background colors are shifting behind the letters. I guess it's time to take a look at the plugin source code and see what's up with it. I've been meaning to get around to doing that anyway, as there are a couple other options I would find valuable, and this is good motivation.
chorpler is offline   Reply With Quote
Advert
Old 05-25-2016, 07:58 PM   #573
baggins41
Enthusiast
baggins41 has learned how to buy an e-book online
 
Posts: 26
Karma: 96
Join Date: Dec 2013
Device: Kindle Paperwhite (2nd Gen.)
Quote:
Originally Posted by chorpler View Post
I guess it's time to take a look at the plugin source code and see what's up with it.
I took a look at the plug-in source myself, as well as the documentation for Qt. It doesn't look like it would be nightmare to implement, though it's definitely non-trivial. Of course, I've no actual experience with coding for Calibre, so I may be underestimating the effort required.
baggins41 is offline   Reply With Quote
Old 05-25-2016, 10:27 PM   #574
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
If you want to re-enable stroke, what has to be done is create a QPAinterPath add the text to it, then draw it using the QPainter, instead of directly drawing the text with the QPainter. You will need to be careful with the auto resizing code, making sure the metrics its uses are the same metrics that will be sued for the final text painting.
kovidgoyal is online now   Reply With Quote
Old 05-28-2016, 04:27 PM   #575
MCBastos
Enthusiast
MCBastos began at the beginning.
 
Posts: 37
Karma: 10
Join Date: Jan 2012
Location: Brazil
Device: Galaxy A71
Blank lines bug

A rather serious bug I noticed in the latest version of Generate Cover:

If you have any blank lines, anywhere, in one of the text fieldd, the entire content of the field is moved to the top of the cover layout -- yes, even overlapping other fields. I tried a number of tricks to work around it -- using <br> tags, using &nbsp;, using various blank characters -- and whenever the character didn't show, the result was the same: the field jumps to the top of the cover layout.

This is very annoying because sometimes you NEED a blank line to tweak the text where you want to go. For instance, I routinely used blank lines in the "Custom Text" field as a spacer, because being a separate field the space can be fine-tuned by the simple expedient of changing the font size.
MCBastos is offline   Reply With Quote
Advert
Old 05-28-2016, 04:38 PM   #576
MCBastos
Enthusiast
MCBastos began at the beginning.
 
Posts: 37
Karma: 10
Join Date: Jan 2012
Location: Brazil
Device: Galaxy A71
Can't remove the image if it's set to "stretch to use as background"

And another odd bug: if the "Stretch image to use as cover background" is active on the "Dimensions" tab, unticking the "Image" box in the "Content" tab does nothing. It's not serious, it's easy to work around, but it's a bit counter-intuitive -- if you turn off the image, you expect it to disappear.
MCBastos is offline   Reply With Quote
Old 06-10-2016, 02:46 PM   #577
oren64
I need a chapter break
oren64 ought to be getting tired of karma fortunes by now.oren64 ought to be getting tired of karma fortunes by now.oren64 ought to be getting tired of karma fortunes by now.oren64 ought to be getting tired of karma fortunes by now.oren64 ought to be getting tired of karma fortunes by now.oren64 ought to be getting tired of karma fortunes by now.oren64 ought to be getting tired of karma fortunes by now.oren64 ought to be getting tired of karma fortunes by now.oren64 ought to be getting tired of karma fortunes by now.oren64 ought to be getting tired of karma fortunes by now.oren64 ought to be getting tired of karma fortunes by now.
 
oren64's Avatar
 
Posts: 4,042
Karma: 56058267
Join Date: Mar 2015
Location: Israel
Device: Kobo Glo
In Hebrew (rtl) the text is inverted, is there a way to fix it?

Click image for larger version

Name:	1.PNG
Views:	365
Size:	505.8 KB
ID:	149327

EDIT: I find if i inverted the text manually or by this software, it show correcetly in the cover.

Last edited by oren64; 06-12-2016 at 03:46 AM.
oren64 is offline   Reply With Quote
Old 07-02-2016, 01:25 PM   #578
chorpler
Zealot
chorpler has a complete set of Star Wars action figures.chorpler has a complete set of Star Wars action figures.chorpler has a complete set of Star Wars action figures.
 
Posts: 128
Karma: 278
Join Date: Jun 2008
Device: Kindle; PRS-500; MobiPocket on Windows Mobile
Wow, Kovid, I wish I had seen your comment before I started working on the code. I started by doing exactly what you suggest, but it was annoying me so I started exploring alternate methods of doing it for a few days and finally went back to the path method. It still took a few days to get it right (I could only spare a few minutes at a time to work on it) -- since QPainterPath.addText() doesn't let you specify a bounding rectangle, I had to figure out how to get the proper starting point for each line's text. Finally got it working so that it matches up properly, though, and I added the option to make the stroke any desired thickness. If anybody else cares about this, I can submit my changes.
chorpler is offline   Reply With Quote
Old 07-02-2016, 01:53 PM   #579
Tanjamuse
Wizard
Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!Tanjamuse , Klaatu Barada Niktu!
 
Posts: 1,327
Karma: 5306
Join Date: Jan 2014
Device: none
I would definitely appreciate it. This plugin is what's keeping me from updating Calibre.

Thanks so much for the work you've put into it.
Tanjamuse is offline   Reply With Quote
Old 07-02-2016, 02:36 PM   #580
MerlinMama
Evangelist
MerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beauty
 
MerlinMama's Avatar
 
Posts: 482
Karma: 32554
Join Date: May 2014
Location: Canada
Device: Kobo Sage
So would I
MerlinMama is offline   Reply With Quote
Old 07-02-2016, 03:01 PM   #581
firefoxxy
Zealot
firefoxxy began at the beginning.
 
Posts: 105
Karma: 10
Join Date: Nov 2012
Location: Germany
Device: Kobo Libra 2
Hi chorpler!
I would be interested in the stroke option, too - but I would also really appreciate an instruction for adding the code, if that's possible.
firefoxxy is offline   Reply With Quote
Old 07-02-2016, 11:27 PM   #582
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
@chorpler: Doesn't QPainterPath have a boundingRect method?
kovidgoyal is online now   Reply With Quote
Old 07-09-2016, 12:08 AM   #583
chorpler
Zealot
chorpler has a complete set of Star Wars action figures.chorpler has a complete set of Star Wars action figures.chorpler has a complete set of Star Wars action figures.
 
Posts: 128
Karma: 278
Join Date: Jun 2008
Device: Kindle; PRS-500; MobiPocket on Windows Mobile
firefoxxy: it's not too complicated to add my modifications to the code, and the source code itself is already included in the "Generate Cover.zip" file you can download. Most of the modification goes in draw.py, which is responsible for (unsurprisingly) doing all the text layout and actually drawing it. I will make the code available on GitHub, plus as good a tutorial as I can come up with in the time I can spare.

kovidgoyal: yes, QPainterPath absolutely does have a boundingRect() method, which gives you the bounding rectangle it ends up with after you create it and do something like QPainterPath.addText(). But what it doesn't have, and what would be useful for what we want to do here, is a setBoundingRect() method, or a parameter for QPainterPath.addText() that would be equivalent.

A bit more detail for anybody curious: currently, the Generate Cover plugin uses a method called QPainter.drawText() to do the text layout and then actually drawing it. And QPainter.drawText() will let you specify a bounding rectangle as one of its parameters (it also has parameters for the text to draw, the font to use, the font size to use, the alignment of the text, whether wrapping is allowed, etc.). Then QPainter.drawText() handles the details of text layout automatically, fitting the text into the specified bounding rectangle and using the specified alignment and wrapping settings.

So, to make it work with Generate Cover's options, you just have to make a bounding rectangle from the cover size and the desired margins, and then let QPainter.drawText() handle all the layout for you.

Unfortunately, QPainter.drawText() doesn't have any way to stroke/outline the text it draws. So, to make the stroke option work again, we have to convert the text to a path, which is just a representation of the outline of the text. Then we can draw the resulting path, using whatever color and thickness we want, and we can also fill the path, so we can get a stroke and a fill of different colors. Just what we want!

So the way we make our text into a path we can draw is to use a method called QPainterPath.addText(). But it is not as sophisticated as QPainter.drawText(). The big difference for our purposes is that QPainterPath.addText() doesn't let you specify a bounding rectangle. You can only specify the starting point for the path (and it isn't even a bounding rectangle point -- it's the point where the baseline of the text will start. What that means is explained in the documentation for QPainterPath.addText()).

And QPainterPath.addText() is also not good at text alignment (left, center, right) or wrapping, so you have to figure out where the given text will be wrapped and then calculate the starting point for each line. It's a lot more intricate than just letting the QPainter.drawText() function handle it automatically.

Fortunately, you can do a version of what QPainter.drawText() does internally (I believe -- haven't examined the Qt / PyQt source code yet to verify this) and use the QTextLayout class to figure out where the text will wrap and what the starting points of each line will be. Then you can plug those into QPainterPath.addText(), then add those paths to the QPainter object with QPainter.addPath(), run a fill with QPainter.fillPath(), and the words are drawn just as if you were using QPainter.drawText() (but with the stroke showing up again! Hooray!).

There's a minor issue currently, where some characters in some fonts are not processed properly.

For instance, one of my books has a title that includes a literal HTML tag, </span>, and the slash is normally seen as part of the text path, as it should be. But if there's an "s" right after it, then suddenly the slash is not seen, and it doesn't get a stroke drawn for it, even when all the other characters do.

In another case, titles that have colons in them, where the font being used is the "Buffied" font (which I use for anything spooky ... and, of course, for anything Buffy the Vampire Slayer related), are working fine for the most part, but for some reason QPainter.fillPath() doesn't realize that the colon's two circles are fillable paths. So it draws the stroke normally, and the colon shows up as two circles stacked vertically ... but they are left as empty outlines, even though all the other characters are filled in properly.

Because of this issue, right now I still have the original QPainter.drawText() code running first, and then the stroke path just draws over the top of it, rather than drawing everything itself. That at least leaves characters visible, even when the new QPainterPath.addText() technique is having problems. I suspect I need to do a little string sanitizing to fix this weird bug. I am taking a look at it after I post this. (On the plus side, doing it this way allows me to quickly verify that I got the path position calculations right, since it's easy and obvious if the stroke is not in precisely the right place, outlining each character.)

Finally, just as a brief aside, kovidgoyal, thanks for all the time and effort you put into Calibre and helping us!
chorpler is offline   Reply With Quote
Old 07-09-2016, 12:23 AM   #584
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
@chorpler: Ah you are having trouble with wrapping text. Well there are a couple of other approaches you can try. One is to use QSvgRenderer with SVG that species the text with appropriate fill and stroke properties. IIRC SVG supports that -- though I may be misremembering.

Another possibility is to use HTML + CSS for the layout, with QWebView. WebKit supports text stroking, https://css-tricks.com/adding-stroke-to-web-text/
kovidgoyal is online now   Reply With Quote
Old 07-10-2016, 09:35 AM   #585
firefoxxy
Zealot
firefoxxy began at the beginning.
 
Posts: 105
Karma: 10
Join Date: Nov 2012
Location: Germany
Device: Kobo Libra 2
Dear chorpler
Thank you for your explanation (although I didn't understand much of the information you gave, I am usually quite adept at following a how-to-guide - I just don't get why I am doing things :P)
So, I'm grateful for any kind of guidance you'll give
firefoxxy is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[GUI Plugin] Goodreads Sync kiwidude Plugins 1721 04-18-2024 10:22 AM
[GUI Plugin] Clipboard Search kiwidude Plugins 29 04-02-2024 10:05 PM
[GUI Plugin] Open With kiwidude Plugins 403 04-01-2024 08:39 AM
[GUI Plugin] User Category kiwidude Plugins 123 03-16-2024 11:59 PM
[GUI Plugin] Quick Preferences kiwidude Plugins 62 03-16-2024 11:47 PM


All times are GMT -4. The time now is 07:57 AM.


MobileRead.com is a privately owned, operated and funded community.