Back to index

scribus-ng  1.3.4.dfsg+svn20071115
Classes | Functions | Variables
FontSample Namespace Reference

Classes

class  AboutDialog
class  ConfigurationDialog
class  Application

Functions

def set_font_fixed
def set_font_proportional
def save_user_conf
def restore_user_conf
def set_page_geometry
def set_odd_even
def draw_sample_row
def draw_sample_block
def insert_toc_row
def build_toc_page_template
def build_toc
def add_page_num
def create_empty_samplepage
def draw_horiz_line
def draw_selection
def preview_font
def setup_tk
def initialisation
def main
def main_wrapper

Variables

int showPreviewPanel = 1
tuple TEMP_PATH = os.path.join(os.path.expanduser('~'), '.scribus')
tuple CONFIG_PATH = os.path.join(os.path.expanduser('~'), '.scribus/fontsampler')
 gSamplePic = None
 gPreviewId = None
string WINDOW_TITLE = 'Font Sampler v0.8.1tk - Steve Callcott'
string SUPPORT_PAGE = 'www.firstwish.co.uk/sjc/scribus/index.php'
tuple fontsListFixed
tuple fontsListProportional
dictionary defaultPrefs
dictionary userPrefs = {}
list geometriesList
dictionary dD
dictionary samplesHeader
dictionary sampleAlphabet
dictionary sample6Point
dictionary sample8Point
dictionary sample10Point
dictionary sample12Point
dictionary sample16Point
dictionary sample20Point
dictionary sample32Point
dictionary sampleParagraph
string sampleParagraphText

Function Documentation

def FontSample.add_page_num (   pageNum)

Definition at line 639 of file FontSample.py.

00639 
00640 def add_page_num(pageNum):
00641     yPos = dD['paperHeight'] - \
00642            dD['paperBottomMargin'] - \
00643            dD['paperPageNumVertOffset']
00644     footer = scribus.createText(dD['paperLeftSide'], yPos, dD['paperTextWidth'], 15)
00645     scribus.insertText('%s' % pageNum, 0, footer)
00646     scribus.setFont(dD['bookstylePropFont'], footer)
00647     scribus.setFontSize(9, footer)
00648     scribus.setTextAlignment(1, footer)
00649     scribus.setLineSpacing(10, footer)
00650 

Here is the caller graph for this function:

def FontSample.build_toc (   tocList)
Creates all the Table of Contents pages.

Calls tocPageFramesBuild() to write the header and empty frame for the
toc rows each time a new page is added.
Then calls tocRowAdd() to add each line to the toc frame. Creates new page
each time it completes last row on page.

Definition at line 598 of file FontSample.py.

00598 
00599 def build_toc(tocList):
00600     """Creates all the Table of Contents pages.
00601 
00602     Calls tocPageFramesBuild() to write the header and empty frame for the
00603     toc rows each time a new page is added.
00604     Then calls tocRowAdd() to add each line to the toc frame. Creates new page
00605     each time it completes last row on page.
00606     """
00607     rowCount = 0
00608     yPos = 0
00609     tocPageNum = 1
00610     tocPageCount = 1
00611 
00612     scribus.newPage(tocPageNum)
00613     isEvenPage = set_odd_even(tocPageNum)
00614     body = build_toc_page_template()             # create frames for new empty page
00615     if isEvenPage == 0:
00616         scribus.setTextAlignment(2, body)
00617     else:
00618         scribus.setTextAlignment(0, body)
00619     for i in tocList:
00620         if rowCount == dD['tocRowsPerPage']: # Need to build a new TOC page (count is from zero, not one)
00621             tocPageNum = tocPageNum + 1
00622             scribus.newPage(tocPageNum)
00623             isEvenPage = set_odd_even(tocPageNum)
00624             body = build_toc_page_template()
00625             if not isEvenPage:
00626                 scribus.setTextAlignment(2, body)
00627             else:
00628                 scribus.setTextAlignment(0, body)
00629             rowCount = 0
00630             yPos = 0
00631             tocPageCount = tocPageCount + 1
00632         yPos = insert_toc_row(i[0], i[1], yPos, body)
00633         rowCount = rowCount + 1
00634     if userPrefs['wantDoubleSided']:
00635         if tocPageCount % 2 != 0:           # Odd page
00636             tocPageNum = tocPageNum + 1
00637             scribus.newPage(tocPageNum)     # Add an extra page if odd number
00638 

Here is the call graph for this function:

Here is the caller graph for this function:

Inserts empty toc template into the currently selected page.

Definition at line 579 of file FontSample.py.

00579 
00580 def build_toc_page_template():
00581     """Inserts empty toc template into the currently selected page."""
00582     # first put a header on the empty page...
00583     textstring = dD['tocHeaderTitle']
00584     yPos = dD['paperTopMargin'] + 1
00585     header = scribus.createText(dD['paperLeftSide'], yPos, dD['paperTextWidth'], 35)
00586     scribus.insertText(textstring, 0, header)
00587     scribus.setFont(dD['bookstylePropFont'], header)
00588     scribus.setFontSize(24, header)
00589     scribus.setTextAlignment(1, header)
00590     # now create a text frame for the table of contents...
00591     yPos = yPos + 36
00592     body = scribus.createText(dD['paperLeftSide'], yPos, dD['paperTextWidth'], dD['paperHeight'] - yPos - dD['paperBottomMargin'] - 1)
00593     scribus.setFont(dD['bookstyleFixedFont'], body)
00594     scribus.setFontSize(10, body)
00595     scribus.setLineSpacing(12, body)
00596     return body
00597 

Here is the caller graph for this function:

def FontSample.create_empty_samplepage (   pageNum,
  getSizeOnly 
)
Creates a new page and increments page number by one.

Note getSizeOnly is now evaluated. Will still generate page number increment
but will not actually create the new page or place the number on the page.

Definition at line 651 of file FontSample.py.

00651 
00652 def create_empty_samplepage(pageNum, getSizeOnly):
00653     """Creates a new page and increments page number by one.
00654 
00655     Note getSizeOnly is now evaluated. Will still generate page number increment
00656     but will not actually create the new page or place the number on the page."""
00657     if not getSizeOnly:
00658         scribus.newPage(-1)
00659     pageNum = pageNum + 1
00660     set_odd_even(pageNum)
00661     if not getSizeOnly:
00662         if userPrefs['wantPageNumbers']:
00663             add_page_num(pageNum)
00664     return pageNum
00665 

Here is the call graph for this function:

Here is the caller graph for this function:

def FontSample.draw_horiz_line (   yPos,
  xStart,
  xEnd,
  getSizeOnly 
)
Draws a line and returns the height.

If getSizeOnly is set then returns the height it would have
used but without actually creating a line.

Definition at line 666 of file FontSample.py.

00666 
00667 def draw_horiz_line(yPos, xStart, xEnd, getSizeOnly):
00668     """Draws a line and returns the height.
00669 
00670     If getSizeOnly is set then returns the height it would have
00671     used but without actually creating a line.
00672     """
00673     lineWidth = 1
00674     if not getSizeOnly:
00675         newLine = scribus.createLine(xStart, yPos, xEnd, yPos)
00676         scribus.setLineWidth(lineWidth, newLine)
00677     return lineWidth
00678 

Here is the caller graph for this function:

def FontSample.draw_sample_block (   fontName,
  x,
  y,
  w,
  getSizeOnly 
)
Drawing of a complete sample block starts from here.

Iterates through each sample declared in the "samples" tuple. Places one
complete block using the font specified in fontname.
Note top line on page is drawn outside of this function. This ensures ease
of returning same height of every sample block. Line could have been drawn
at top inside this function and page finalised with line at bottom instead.
If getSizeOnly is true then returns the overall height of the entire text
block but without actually placing it.

Definition at line 509 of file FontSample.py.

00509 
00510 def draw_sample_block(fontName, x, y, w, getSizeOnly):
00511     """Drawing of a complete sample block starts from here.
00512 
00513     Iterates through each sample declared in the "samples" tuple. Places one
00514     complete block using the font specified in fontname.
00515     Note top line on page is drawn outside of this function. This ensures ease
00516     of returning same height of every sample block. Line could have been drawn
00517     at top inside this function and page finalised with line at bottom instead.
00518     If getSizeOnly is true then returns the overall height of the entire text
00519     block but without actually placing it.
00520     """
00521     startPos = y
00522     # Note there are 2 points of space before horizontal line at bottom of block.
00523     # This 2 points will not appear at top of page so need to add it.
00524 
00525     # set space below horizontal line to the top of the text block
00526     y = y + 4
00527 
00528     # (note there is one extra point inserted by addSampleRow() for each row generated)...
00529 
00530     # first need a header...
00531     y = draw_sample_row(dD['bookstylePropFont'], samplesHeader['fontSize'], samplesHeader['lineSpace'], fontName, x, y, w, samplesHeader['textHeight'], getSizeOnly)
00532 
00533     if userPrefs['wantAlphabet']:
00534         y = draw_sample_row(fontName, sampleAlphabet['fontSize'], sampleAlphabet['lineSpace'], sampleAlphabet['textString'], x, y, w, sampleAlphabet['textHeight'], getSizeOnly)
00535 
00536     if userPrefs['want6Point']:
00537         y = draw_sample_row(fontName, sample6Point['fontSize'], sample6Point['lineSpace'], sample6Point['textString'], x, y, w, sample6Point['textHeight'], getSizeOnly)
00538 
00539     if userPrefs['want8Point']:
00540         y = draw_sample_row(fontName, sample8Point['fontSize'], sample8Point['lineSpace'], sample8Point['textString'], x, y, w, sample8Point['textHeight'], getSizeOnly)
00541 
00542     if userPrefs['want10Point']:
00543         y = draw_sample_row(fontName, sample10Point['fontSize'], sample10Point['lineSpace'], sample10Point['textString'], x, y, w, sample10Point['textHeight'], getSizeOnly)
00544 
00545     if userPrefs['want12Point']:
00546         y = draw_sample_row(fontName, sample12Point['fontSize'], sample12Point['lineSpace'], sample12Point['textString'], x, y, w, sample12Point['textHeight'], getSizeOnly)
00547 
00548     if userPrefs['want16Point']:
00549         y = draw_sample_row(fontName, sample16Point['fontSize'], sample16Point['lineSpace'], sample16Point['textString'], x, y, w, sample16Point['textHeight'], getSizeOnly)
00550 
00551     if userPrefs['want20Point']:
00552         y = draw_sample_row(fontName, sample20Point['fontSize'], sample20Point['lineSpace'], sample20Point['textString'], x, y, w, sample20Point['textHeight'], getSizeOnly)
00553 
00554     if userPrefs['want32Point']:
00555         y = draw_sample_row(fontName, sample32Point['fontSize'], sample32Point['lineSpace'], sample32Point['textString'], x, y, w, sample32Point['textHeight'], getSizeOnly)
00556 
00557     if userPrefs['wantParagraph']:
00558         y = draw_sample_row(fontName, sampleParagraph['fontSize'], sampleParagraph['lineSpace'], sampleParagraphText, x, y, w, sampleParagraph['textHeight'], getSizeOnly)
00559 
00560     y = y + 1   # one extra point of space above bottom Horiz. line
00561 
00562     lineHeight = draw_horiz_line(y, x, w + x, getSizeOnly)
00563     y = y + lineHeight
00564 
00565     return y - startPos
00566 

Here is the call graph for this function:

Here is the caller graph for this function:

def FontSample.draw_sample_row (   font,
  fontSize,
  lineSpace,
  textString,
  x,
  y,
  w,
  h,
  getSizeOnly 
)
Creates one row of samples or a header for the top of the block.

Called once by draw_sample_block() to create a block label then as many times
as required to create each actual sample found in the list of dictionaries
containing each samples definition.

Definition at line 492 of file FontSample.py.

00492 
00493 def draw_sample_row(font, fontSize, lineSpace, textString, x, y, w, h, getSizeOnly):
00494     """Creates one row of samples or a header for the top of the block.
00495 
00496     Called once by draw_sample_block() to create a block label then as many times
00497     as required to create each actual sample found in the list of dictionaries
00498     containing each samples definition.
00499     """
00500     if not getSizeOnly:
00501         f = scribus.createText(x, y, w, h)
00502         scribus.insertText(textString, 0, f)
00503         scribus.setFont(font, f)
00504         scribus.setFontSize(fontSize, f)
00505         scribus.setLineSpacing(lineSpace, f)
00506         scribus.setTextAlignment(0, f)
00507     return y + h + 1
00508 

Here is the caller graph for this function:

def FontSample.draw_selection (   fontList,
  getSizeOnly 
)
Draws the sample blocks onto the Scribus canvas.

Measure one font sample block including any horizontal lines and extra
vertical spaces.
Get the amount of vertical space available for the text area between the
top line and top of page number area.
Use these two values to calculate how many complete sample blocks will fit
in the space available. This is the "pageBlocks"
Note we always draw the top horizontal line before placing the blocks. This
is taken into account when calculating the available text area.
Next, if "getSizeOnly" is false we create a page then create the sample
blocks while incrementing a counter until it matches the "pageBlocks".
Reset the counter and create new page. We keep going until we have processed
all the fonts in the selection list.
We update the Scribus progress bar as we create each font sample block.
The returned result is used to update some values in the status bar.

Definition at line 679 of file FontSample.py.

00679 
00680 def draw_selection(fontList, getSizeOnly):
00681     """Draws the sample blocks onto the Scribus canvas.
00682 
00683     Measure one font sample block including any horizontal lines and extra
00684     vertical spaces.
00685     Get the amount of vertical space available for the text area between the
00686     top line and top of page number area.
00687     Use these two values to calculate how many complete sample blocks will fit
00688     in the space available. This is the "pageBlocks"
00689     Note we always draw the top horizontal line before placing the blocks. This
00690     is taken into account when calculating the available text area.
00691     Next, if "getSizeOnly" is false we create a page then create the sample
00692     blocks while incrementing a counter until it matches the "pageBlocks".
00693     Reset the counter and create new page. We keep going until we have processed
00694     all the fonts in the selection list.
00695     We update the Scribus progress bar as we create each font sample block.
00696     The returned result is used to update some values in the status bar.
00697     """
00698     progress = 1
00699     scribus.progressReset()
00700     scribus.progressTotal(len(fontList))
00701     tocList = []
00702     pageNum = 1
00703     blockCounter = 0
00704     counter = 0
00705     facingPages = scribus.NOFACINGPAGES
00706     
00707     # Just get blocks per page value...
00708     set_odd_even(pageNum)
00709     lineHeight = 1 # include the one point of space below top margin
00710     lineHeight = lineHeight + draw_horiz_line(0, dD['paperLeftSide'], dD['paperLeftSide'] + dD['paperTextWidth'], 1)
00711     usuableArea = dD['paperHeight'] - \
00712                   dD['paperTopMargin'] - \
00713                   lineHeight - \
00714                   dD['paperBottomMargin'] - \
00715                   dD['paperPageNumVertOffset']
00716 
00717     blockHeight = draw_sample_block(fontList[0], dD['paperLeftSide'], 0, dD['paperTextWidth'], 1)
00718     pageBlocks = int(usuableArea / blockHeight)
00719     #print blockHeight
00720     #print "Usuable area %s points high" % usuableArea
00721     #print "Used space on page is %s points high" % (blockHeight * pageBlocks)
00722 
00723     if not getSizeOnly:
00724         # not a dummy run so start by setting up page numbering...
00725         if userPrefs['wantPageOneOnFirst'] and userPrefs['wantTOC']:
00726             tocPageCount = divmod(len(fontList), dD['tocRowsPerPage'])
00727             pageNum = pageNum + tocPageCount[0]
00728             if tocPageCount[1] != 0:
00729                 # (adding more to page number as not whole number)
00730                 pageNum = pageNum + 1
00731             if userPrefs['wantDoubleSided']:
00732                 oddEvenTest = divmod(pageNum, 2)
00733                 if oddEvenTest[1] == 0:
00734                     # (adding extra one to start number as odd amount)
00735                     pageNum = pageNum + 1
00736         if userPrefs['wantDoubleSided']:
00737             facingPages = scribus.FACINGPAGES
00738         # now create a new document with empty page and start building...
00739         scribus.newDocument(dD['paperSize'], dD['paperMargins'], scribus.PORTRAIT, 1, scribus.UNIT_POINTS, facingPages, scribus.FIRSTPAGERIGHT, 1)
00740         scribus.zoomDocument(-100)
00741         # A new doc gives us a new page by default so set it up first...
00742         set_odd_even(pageNum)
00743         yPos = dD['paperTopMargin'] + 1
00744         lineHeight = draw_horiz_line(yPos, dD['paperLeftSide'], dD['paperLeftSide'] + dD['paperTextWidth'], getSizeOnly)
00745         yPos = yPos + lineHeight
00746         if userPrefs['wantPageNumbers']:
00747             add_page_num(pageNum)
00748         for i in fontList:
00749             # Now place the actual sample block but create a new page if needed...
00750             if counter == pageBlocks:
00751                 pageNum = create_empty_samplepage(pageNum, getSizeOnly)
00752                 yPos = dD['paperTopMargin'] + 1
00753                 lineHeight = draw_horiz_line(yPos, dD['paperLeftSide'], dD['paperLeftSide'] + dD['paperTextWidth'], getSizeOnly)
00754                 yPos = yPos + lineHeight
00755                 counter = 0
00756             blockHeight = draw_sample_block(i, dD['paperLeftSide'], yPos, dD['paperTextWidth'], getSizeOnly)
00757             yPos = yPos + blockHeight
00758             # and also increment the Scribus progress bar...
00759             scribus.progressSet(progress)
00760             progress = progress + 1
00761             # Add current font to TOC...
00762             tocList.append([i, pageNum])
00763             counter = counter + 1
00764         if userPrefs['wantTOC']:
00765             # Insert table of contents - (before page numbering)...
00766             build_toc(tocList)
00767         scribus.gotoPage(1)
00768     return pageBlocks
00769 

Here is the call graph for this function:

Here is the caller graph for this function:

Test for suitable fonts and on success creates tkinter app.

Definition at line 1529 of file FontSample.py.

01529 
01530 def initialisation():
01531     """Test for suitable fonts and on success creates tkinter app."""
01532     try:
01533         dD['bookstyleFixedFont'] = set_font_fixed(fontsListFixed)
01534         dD['bookstylePropFont'] = set_font_proportional(fontsListProportional)
01535     except:
01536         scribus.messageBox('Font problem',
01537                            '%s' % sys.exc_info()[1],
01538                            scribus.ICON_WARNING)
01539         sys.exit(1)
01540     # load users saved defaults...
01541     restore_user_conf(CONFIG_PATH)
01542     # get and set the initial paper size to match default radiobutton selection...
01543     dD.update(set_page_geometry(dD, geometriesList, userPrefs['paperSize'], userPrefs['wantBindingOffset']))
01544     # Made it this far so its time to create our Tkinter app...
01545     app = setup_tk()
01546     # now show the main window and wait for user to do something...
01547     app.mainloop()
01548 

Here is the call graph for this function:

Here is the caller graph for this function:

def FontSample.insert_toc_row (   fontName,
  pageNum,
  yPos,
  frame 
)
Called once for each content line to be drawn in the text frame.

Definition at line 567 of file FontSample.py.

00567 
00568 def insert_toc_row(fontName, pageNum, yPos, frame):
00569     """Called once for each content line to be drawn in the text frame."""
00570     dotLine = ""
00571     dotQuant = dD['tocCharsInRow'] - len(fontName) - len(str(pageNum)) + 1
00572     for i in range(dotQuant):
00573         dotLine = dotLine + '.'
00574     oneLine = fontName + dotLine + str(pageNum) + "\n"
00575     scribus.insertText(oneLine, yPos, frame)
00576     yPos = yPos + len(oneLine) + 0
00577     return yPos
00578 

Here is the caller graph for this function:

def FontSample.main (   argv)
Application initialization, font checks and initial setup.

Definition at line 1549 of file FontSample.py.

01549 
01550 def main(argv):
01551     """Application initialization, font checks and initial setup."""
01552     initialisation()
01553 

Here is the call graph for this function:

Here is the caller graph for this function:

def FontSample.main_wrapper (   argv)
The main_wrapper() function disables redrawing, sets a sensible generic
status bar message, and optionally sets up the progress bar. It then runs
the main() function. Once everything finishes it cleans up after the main()
function, making sure everything is sane before the script terminates.

Definition at line 1554 of file FontSample.py.

01554 
01555 def main_wrapper(argv):
01556     """The main_wrapper() function disables redrawing, sets a sensible generic
01557     status bar message, and optionally sets up the progress bar. It then runs
01558     the main() function. Once everything finishes it cleans up after the main()
01559     function, making sure everything is sane before the script terminates."""
01560     try:
01561         scribus.statusMessage('Running script...')
01562         scribus.progressReset()
01563         main(argv)
01564     finally:
01565         # Exit neatly even if the script terminated with an exception,
01566         # so we leave the progress bar and status bar blank and make sure
01567         # drawing is enabled.
01568         if scribus.haveDoc():
01569             scribus.setRedraw(True)
01570         scribus.statusMessage('')
01571         scribus.progressReset()
01572 
01573 
01574 # This code detects if the script is being run as a script, or imported as a module.
01575 # It only runs main() if being run as a script. This permits you to import your script
# and control it manually for debugging.

Here is the call graph for this function:

def FontSample.preview_font (   app,
  fontName 
)
Gets the named font and puts a sample in the preview panel.

Pick up the temp sample qpixmap file and display it in a canvas object
The temp file is put in the users ".scribus" folder and cleaned up on exit.
We create samplePic as a global as a workaround because the reference count
does not increase when we add the image to the canvas. Therefore python
garbage collection removes our image before we have even displayed it.
Note app.previewPanel is the actual canvas.

Definition at line 770 of file FontSample.py.

00770 
00771 def preview_font(app, fontName):
00772     """Gets the named font and puts a sample in the preview panel.
00773 
00774     Pick up the temp sample qpixmap file and display it in a canvas object
00775     The temp file is put in the users ".scribus" folder and cleaned up on exit.
00776     We create samplePic as a global as a workaround because the reference count
00777     does not increase when we add the image to the canvas. Therefore python
00778     garbage collection removes our image before we have even displayed it.
00779     Note app.previewPanel is the actual canvas.
00780     """
00781     global gSamplePic
00782     global gPreviewId
00783     scribus.renderFont(fontName, os.path.join(TEMP_PATH,'temp079r.bmp'),dD['previewpanelSampleText'],dD['previewpanelFontHeight'])
00784     try:
00785         tempPic = Image.open(os.path.join(TEMP_PATH,'temp079r.bmp'))
00786         tempPic.save(os.path.join(TEMP_PATH,'temp079r.jpeg'),format='JPEG')
00787         tempImage = Image.open(os.path.join(TEMP_PATH,'temp079r.jpeg'))
00788         imgDimen = tempPic.getbbox()
00789         gSamplePic = ImageTk.PhotoImage(tempImage)
00790         # To center the image use "Half display height minus half the image height"
00791         # preview panel is allegedly 56 (60 less a 2 pixel border top and bottom)
00792         # need to be lower than that to look correct visually...
00793         topEdge = (32 - (imgDimen[3] / 2))
00794         gPreviewId = app.previewPanel.create_image(5, topEdge, anchor=NW, image=gSamplePic)
00795         os.remove(os.path.join(TEMP_PATH,'temp079r.bmp'))
00796         os.remove(os.path.join(TEMP_PATH,'temp079r.jpeg'))
00797     except IOError:
00798         gSamplePic = None
00799         gPreviewId = app.previewPanel.create_image(0, 0, anchor=NW, image=gSamplePic)
00800     return
00801 

Here is the caller graph for this function:

Restore the data from the save file on the path specified by CONFIG_PATH.

Definition at line 415 of file FontSample.py.

00415 
00416 def restore_user_conf(path):
00417     """Restore the data from the save file on the path specified by CONFIG_PATH."""
00418     try:
00419         file = open(os.path.join(path,'fontsampler.conf'), 'r')
00420         data = cPickle.load(file)
00421         file.close()
00422         defaultPrefs.update(data['a'])
00423         userPrefs.update(data['b'])
00424     except:
00425         userPrefs.update(defaultPrefs)
00426         print 'failed to load saved data so using default values defined in the script'
00427 

Here is the caller graph for this function:

def FontSample.save_user_conf (   path)
Save the data to the save file on the path specified by CONFIG_PATH.

Note initialisation unsets the CONFIG_PATH if it failed to verify or create

Definition at line 398 of file FontSample.py.

00398 
00399 def save_user_conf(path):
00400     """Save the data to the save file on the path specified by CONFIG_PATH.
00401 
00402     Note initialisation unsets the CONFIG_PATH if it failed to verify or create"""
00403     if not path == '':
00404         try:
00405             file = open(os.path.join(path,'fontsampler.conf'), 'w')
00406             data = {
00407                 'a' : defaultPrefs,
00408                 'b' : userPrefs
00409             }
00410             cPickle.dump(data, file)
00411             file.close()
00412         except:
00413             print 'failed to save data'
00414 

Here is the caller graph for this function:

def FontSample.set_font_fixed (   fontList)
Find a matching font for the Table of Contents.

Definition at line 354 of file FontSample.py.

00354 
00355 def set_font_fixed(fontList):
00356     """Find a matching font for the Table of Contents."""
00357     availableFonts = scribus.getFontNames()
00358     found = 0
00359     for f in fontList:
00360         if found:
00361             break
00362         for i in availableFonts:
00363             if not found:
00364                 if f == i:
00365                     return f
00366                     found = 1
00367                     break
00368     if not found:
00369         errorList = ''
00370         for j in fontList:
00371             errorList = errorList + j + '\n'
00372         errorMessage ='No suitable fixed width font found.\nPlease install at least one of these fixed width fonts:\n'+errorList
00373         print errorMessage
00374         raise Exception(errorMessage)
00375 

Here is the caller graph for this function:

Find a matching font for the page numbers and font names above samples.

Definition at line 376 of file FontSample.py.

00376 
00377 def set_font_proportional(fontList):
00378     """Find a matching font for the page numbers and font names above samples."""
00379     availableFonts = scribus.getFontNames()
00380     found = 0
00381     for p in fontList:
00382         if found:
00383             break
00384         for i in availableFonts:
00385             if not found:
00386                 if p == i:
00387                     return p
00388                     found = 1
00389                     break
00390     if not found:
00391         errorList = ''
00392         for j in fontList:
00393             errorList = errorList + j + '\n'
00394         errorMessage = 'No suitable proportional font found.\nPlease install at least one of these proportional fonts:\n'+errorList
00395         print errorMessage
00396         raise Exception(errorMessage)
00397 

Here is the caller graph for this function:

def FontSample.set_odd_even (   pageNum)
Sets the left margin position.

Checks the number passed to it and sets left margin accordingly.
Call once after each new page is created.
Returns 1 if even and 0 if odd page.

Definition at line 470 of file FontSample.py.

00470 
00471 def set_odd_even(pageNum):
00472     """ Sets the left margin position.
00473 
00474     Checks the number passed to it and sets left margin accordingly.
00475     Call once after each new page is created.
00476     Returns 1 if even and 0 if odd page.
00477     """
00478     if pageNum % 2 == 0:
00479         isEvenPage = 1                                          # Even side
00480     else:
00481         isEvenPage = 0                                          # Odd side
00482 
00483     if userPrefs['wantBindingOffset']:
00484         if isEvenPage and userPrefs['wantDoubleSided']:         # Even (when double sided)
00485             dD['paperLeftSide'] = dD['paperLeftMargin'] + 1
00486         else:                                                   # Odd side
00487             dD['paperLeftSide'] = dD['paperLeftMarginOdd'] + 1
00488     else:                                                       # No binding
00489         dD['paperLeftSide'] = dD['paperLeftMargin'] + 1
00490     return isEvenPage
00491 

Here is the caller graph for this function:

def FontSample.set_page_geometry (   dD,
  geometriesList,
  paperSize,
  wantBindingOffset 
)
This is the experimental replacement paper size setting function.

Each paper size and other associated data are stored in a dictionary.
The dictionaries are stored in a list. We copy appropriate dictionary
and custom calculations into a work dictionary for use.
The advantage of this is its easier to add new paper definitions.
Returns a new dictionary, use .update to merge in new values into dD.

Definition at line 428 of file FontSample.py.

00428 
00429 def set_page_geometry(dD, geometriesList, paperSize, wantBindingOffset):
00430     """This is the experimental replacement paper size setting function.
00431 
00432     Each paper size and other associated data are stored in a dictionary.
00433     The dictionaries are stored in a list. We copy appropriate dictionary
00434     and custom calculations into a work dictionary for use.
00435     The advantage of this is its easier to add new paper definitions.
00436     Returns a new dictionary, use .update to merge in new values into dD.
00437     """
00438     try:
00439         result={}
00440         for i in geometriesList:
00441             if i['paperName'] == paperSize:
00442                 dD.update(i)
00443 
00444         result['paperLeftMarginOdd'] = dD['paperLeftMargin'] + \
00445                                        dD['paperBinding']
00446         result['paperRightMarginEven'] = dD['paperRightMargin'] + \
00447                                          dD['paperBinding']
00448         result['paperTextHeight'] = dD['paperHeight'] - \
00449                                     dD['paperTopMargin'] - \
00450                                     dD['paperBottomMargin']
00451         result['paperMargins'] =  dD['paperLeftMargin'],dD['paperRightMargin'],dD['paperTopMargin'],dD['paperBottomMargin']
00452 
00453         # if we are adding a binding offset to the margins then we will have less width for our text...
00454         if wantBindingOffset:
00455             result['paperTextWidth'] = dD['paperWidth'] - \
00456                                        dD['paperLeftMargin'] - \
00457                                        dD['paperRightMargin'] - \
00458                                        dD['paperBinding'] - \
00459                                        2
00460         else:
00461             result['paperTextWidth'] = dD['paperWidth'] - \
00462                                        dD['paperLeftMargin'] - \
00463                                        dD['paperRightMargin'] - \
00464                                        2
00465         return result
00466     except:
00467         errorMessage = 'set_page_geometry() failure: %s' % sys.exc_info()[1]
00468         print errorMessage
00469 

Here is the caller graph for this function:

Create and setup the Tkinter app.

Definition at line 1510 of file FontSample.py.

01510 
01511 def setup_tk():
01512     """Create and setup the Tkinter app."""
01513     root = Tk()
01514     app = Application(root)
01515     app.master.title(WINDOW_TITLE)
01516 
01517     # now get a list of all the fonts Scribus knows about...
01518     fontList = scribus.getFontNames()
01519     fontList.sort()
01520     # and load the list into the GUI listbox...
01521     for i in fontList:
01522         app.listbox1.insert(END, i)
01523     app.sampleBlocksPerPage = draw_selection(scribus.getFontNames(), 1)
01524     # now set the status bar message...
01525     app.statusbarUpdate()
01526     # set up widgets using data from userPrefs...
01527     app.initialiseWidgets()
01528     return app

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

string FontSample.CONFIG_PATH = os.path.join(os.path.expanduser('~'), '.scribus/fontsampler')

Definition at line 120 of file FontSample.py.

dictionary FontSample.dD
Initial value:
00001 {
00002     'tocHeaderTitle' : 'Table of Contents',
00003     'tocCharsInRow' : 75,
00004     'previewpanelFontHeight' : 28,
00005     'previewpanelSampleText' : 'Woven silk pyjamas exchanged for blue quartz'
00006 }

Definition at line 259 of file FontSample.py.

Initial value:
00001 {
00002     'wantDoubleSided': 0,
00003     'paperSize':'A4',           # currently PAPER_LETTER or PAPER_A4
00004     'wantTOC': 1,
00005     'wantBindingOffset': 0,
00006     'wantPageNumbers': 1,
00007     'wantPageOneOnFirst': 0,
00008     'wantAlphabet' : 1,
00009     'want6Point' : 1,
00010     'want8Point' : 1,
00011     'want10Point' : 1,
00012     'want12Point' : 1,
00013     'want16Point' : 1,
00014     'want20Point' : 1,
00015     'want32Point' : 1,
00016     'wantParagraph' : 0         # Uses a lot of space so default is off
00017 }

Definition at line 209 of file FontSample.py.

Initial value:
00001 (
00002     'Luxi Mono Regular',
00003     'Nimbus Mono L Regular',
00004     'Courier 10 Pitch Regular',
00005     'Courier New Regular',
00006     'Courier Regular',
00007     'Andale Mono Regular',
00008     'Larabiefont Regular'
00009 )

Definition at line 191 of file FontSample.py.

Initial value:
00001 (
00002     'Nimbus Sans L Regular',
00003     'Luxi Sans Regular',
00004     'Bitstream Vera Sans',
00005     'Helvetica',
00006     'Arial Regular'
00007 )

Definition at line 201 of file FontSample.py.

Initial value:
00001 [
00002     {
00003         'paperName' : 'A4',
00004         'paperSize' : scribus.PAPER_A4,
00005         'paperWidth' : 595,
00006         'paperHeight' : 842,
00007         'paperTopMargin' : 60,
00008         'paperBottomMargin' : 50,
00009         'paperLeftMargin' : 50,
00010         'paperRightMargin' : 50,
00011         'paperBinding' : 16,
00012         'tocRowsPerPage' : 57,
00013         'paperPageNumVertOffset' : 16
00014     },
00015     {
00016         'paperName' : 'US Letter',
00017         'paperSize' : scribus.PAPER_LETTER,
00018         'paperWidth' : 612,
00019         'paperHeight' : 792,
00020         'paperTopMargin' : 27,
00021         'paperBottomMargin' : 45,
00022         'paperLeftMargin' : 50,
00023         'paperRightMargin' : 50,
00024         'paperBinding' : 18,
00025         'tocRowsPerPage' : 56,
00026         'paperPageNumVertOffset' : 16
00027     }
00028 ]

Definition at line 229 of file FontSample.py.

Definition at line 184 of file FontSample.py.

Definition at line 183 of file FontSample.py.

Initial value:
00001 {
00002     'fontSize' : 10,
00003     'lineSpace' : 11,
00004     'textString' : 'This line is in 10 point',
00005     'textHeight' : 19
00006 }

Definition at line 294 of file FontSample.py.

Initial value:
00001 {
00002     'fontSize' : 12,
00003     'lineSpace' : 11,
00004     'textString' : 'This line is in 12 point',
00005     'textHeight' : 21
00006 }

Definition at line 301 of file FontSample.py.

Initial value:
00001 {
00002     'fontSize' : 16,
00003     'lineSpace' : 13,
00004     'textString' : 'This line is in 16 point',
00005     'textHeight' : 26
00006 }

Definition at line 308 of file FontSample.py.

Initial value:
00001 {
00002     'fontSize' : 20,
00003     'lineSpace' : 16,
00004     'textString' : 'This line is in 20 point',
00005     'textHeight' : 31
00006 }

Definition at line 315 of file FontSample.py.

Initial value:
00001 {
00002     'fontSize' : 32,
00003     'lineSpace' : 29,
00004     'textString' : 'This line is in 32 point',
00005     'textHeight' : 49
00006 }

Definition at line 322 of file FontSample.py.

Initial value:
00001 {
00002     'fontSize' : 6,
00003     'lineSpace' : 6,
00004     'textString' : 'This line is in 6 point',
00005     'textHeight' : 13
00006 }

Definition at line 280 of file FontSample.py.

Initial value:
00001 {
00002     'fontSize' : 8,
00003     'lineSpace' : 8,
00004     'textString' : 'This line is in 8 point',
00005     'textHeight' : 16
00006 }

Definition at line 287 of file FontSample.py.

Initial value:
00001 {
00002     'fontSize' : 10.5,
00003     'lineSpace' : 12,
00004     'textString' : 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#?$*&',
00005     'textHeight' : 18
00006 }

Definition at line 273 of file FontSample.py.

Initial value:
00001 {
00002     'fontSize' : 9,
00003     'lineSpace' : 10.8,
00004     'textHeight' : 175
00005 }

Definition at line 329 of file FontSample.py.

Initial value:
00001 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut a sapien. \
00002 Aliquam aliquet purus molestie dolor. Integer quis eros ut erat posuere dictum. \
00003 Curabitur dignissim. Integer orci. Fusce vulputate lacus at ipsum. Quisque in libero \
00004 nec mi laoreet volutpat. Aliquam eros pede, scelerisque quis, tristique cursus, \
00005 placerat convallis, velit. Nam condimentum. Nulla ut mauris. Curabitur adipiscing, \
00006 mauris non dictum aliquam, arcu risus dapibus diam, nec sollicitudin quam erat quis \
00007 ligula. Aenean massa nulla, volutpat eu, accumsan et, fringilla eget, odio. \
00008 Nulla placerat porta justo. Nulla vitae turpis.\n\nPraesent lacus.Lorem ipsum dolor sit \
00009 amet, consectetuer adipiscing elit. Pellentesque habitant morbi tristique senectus \
00010 et netus et malesuada fames ac turpis egestas. Quisque vel erat eget diam \
00011 consectetuer iaculis. Cras ante velit, suscipit et, porta tempus, dignissim quis, \
00012 magna. Vivamus viverra, turpis nec rhoncus ultricies, diam turpis eleifend nisl, a \
00013 eleifend ante felis ac sapien. Integer bibendum. Suspendisse in mi non neque \
00014 bibendum convallis. Suspendisse potenti. Sed sit amet purus at felis adipiscing \
00015 aliquam. Vivamus et nisl sit amet mauris aliquet molestie. Integer tortor massa, \
00016 aliquam a, lacinia nonummy, sagittis nec, eros.'

Definition at line 335 of file FontSample.py.

Initial value:
00001 {
00002     'fontSize' : 16,
00003     'lineSpace' : 15,
00004     'textHeight' : 23
00005 }

Definition at line 266 of file FontSample.py.

Definition at line 118 of file FontSample.py.

string FontSample.SUPPORT_PAGE = 'www.firstwish.co.uk/sjc/scribus/index.php'

Definition at line 189 of file FontSample.py.

tuple FontSample.TEMP_PATH = os.path.join(os.path.expanduser('~'), '.scribus')

Definition at line 119 of file FontSample.py.

dictionary FontSample.userPrefs = {}

Definition at line 227 of file FontSample.py.

string FontSample.WINDOW_TITLE = 'Font Sampler v0.8.1tk - Steve Callcott'

Definition at line 188 of file FontSample.py.