Register Guidelines E-Books Search Today's Posts Mark Forums Read

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

Notices

Reply
 
Thread Tools Search this Thread
Old 03-04-2011, 10:58 AM   #1
kiwidude
calibre/Sigil Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,230
Karma: 1345754
Join Date: Oct 2010
Location: London, UK
Device: Kindle Paperwhite 3G, iPad 3, iPad Air
Working with Fonts and Calibre

I'm working on a "Generate Cover" plugin which allows all sorts of customisation of a cover that gets generated. As part of that I wanted to offer the ability for the user to choose fonts for the rendering using magick of the title, author, series.

The issue is whether it is possible to make use of the QFontDialog as a UI for selecting a font to then pass to the drawing code in the magick namespace. As far as I can tell, the magick stuff takes a physical file path, whereas a QFontDialog gives you a QFont from which you get a font family.

Is there any suggested way of reconciling the two? In a cross platform way? I saw some code via Google which queried the registry for font matches but obviously that is a windows only option.

Or should I just use a file chooser dialog and get the user to navigate to a .ttf file instead?
kiwidude is offline   Reply With Quote
Old 03-04-2011, 11:39 AM   #2
GRiker
Comparer of the Ephemeris
GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.
 
Posts: 1,497
Karma: 424627
Join Date: Mar 2009
Device: iPad
Take a look at gui2.convert.mobi_output.py, I use a combo box there to list available fonts, that might be of some assistance.

G
GRiker is offline   Reply With Quote
Old 03-04-2011, 11:46 AM   #3
user_none
Sigil & calibre developer
user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.user_none ought to be getting tired of karma fortunes by now.
 
user_none's Avatar
 
Posts: 2,473
Karma: 1053245
Join Date: Jan 2009
Location: Florida, USA
Device: Nook STR
The font file has to be read at some point to populate the font dialog. I would first look to see if QFont stores the file path. Then I would look at the Qt source to see how it loads the font list. It would have to handle it per platform and might have some cross platform method.
user_none is offline   Reply With Quote
Old 03-04-2011, 12:53 PM   #4
kiwidude
calibre/Sigil Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,230
Karma: 1345754
Join Date: Oct 2010
Location: London, UK
Device: Kindle Paperwhite 3G, iPad 3, iPad Air
Thanks guys.

@user_none - I found a feature request on the web for QFont to have this info and it was rejected by the devs as not worth the effort. My reading of what is going on is that Qt deals with the font abstractions it is passed by other layered components underneath, so it doesn't actually know the file path. So I think I will abandon QFontDialog - I think if I used the Qt drawing ability it would be useful but I'm trying not to start from scratch on the image stuff.

@GRiker - thanks for pointing me at that font combo, I'll try to figure out some sort of UI using similar code.
kiwidude is offline   Reply With Quote
Old 03-04-2011, 12:55 PM   #5
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: 26,450
Karma: 5383257
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
There's already a tweak to specify the font paths. If you want a UI for the tweak, use the FontFamilyModel from gui2.widgets, see the lrf output or mobi output plugins for an example.

Qt doesn't make paths to fonts available, because of DRM (windows tries to prevent programs from accessing font data unless they have the embed bit set).
kovidgoyal is offline   Reply With Quote
Old 03-04-2011, 01:08 PM   #6
kiwidude
calibre/Sigil Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,230
Karma: 1345754
Join Date: Oct 2010
Location: London, UK
Device: Kindle Paperwhite 3G, iPad 3, iPad Air
Thx Kovid, yeah I have seen the tweaks for covers. Originally I wasn't going to bother with offering font choices at all since they existed. However I wanted both more granularity and also to not force users to have to go through separate dialogs/calibre restarts to switch a font. I still will fallback to respecting that value if the user does not bother in my plugin.
kiwidude is offline   Reply With Quote
Old 03-04-2011, 04:34 PM   #7
kiwidude
calibre/Sigil Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,230
Karma: 1345754
Join Date: Oct 2010
Location: London, UK
Device: Kindle Paperwhite 3G, iPad 3, iPad Air
All working now, thanks for the pointers guys.
Attached Thumbnails
Click image for larger version

Name:	Screenshot_2_Configuration.png
Views:	125
Size:	228.4 KB
ID:	67806  
kiwidude is offline   Reply With Quote
Old 03-04-2011, 05:01 PM   #8
GRiker
Comparer of the Ephemeris
GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.GRiker ought to be getting tired of karma fortunes by now.
 
Posts: 1,497
Karma: 424627
Join Date: Mar 2009
Device: iPad
That looks awesome, looking forward to trying it.

G
GRiker is offline   Reply With Quote
Old 03-04-2011, 08:49 PM   #9
theducks
Grand Sorcerer
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 15,287
Karma: 6022733
Join Date: Aug 2009
Location: (The original) Silicon Valley, USA
Device: Galaxy Tab 2, Astak Pocket Pro, K4NT
Quote:
Originally Posted by kiwidude View Post
All working now, thanks for the pointers guys.
Wow!
Now if I only had artistic TALENT

Got a plug-in for that?
theducks is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Fonts not working in a converted book snape Sony Reader 9 11-09-2010 12:46 AM
Embedded fonts, Calibre, and choice of fonts AlexBell ePub 8 05-30-2010 07:00 AM
Changing fonts not working? tselling Astak EZReader 11 09-21-2009 04:03 PM
Why are some fonts not working?? daviddem HanLin eBook 4 01-22-2009 10:14 AM
PRS-500 Embedded fonts in LRF WORKING igorsk Sony Reader Dev Corner 21 03-23-2007 06:59 AM


All times are GMT -4. The time now is 10:29 AM.


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