[ocrfeeder] Use Pango from GI instead of the static bindings
- From: Joaquim Manuel Pereira Rocha <jrocha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ocrfeeder] Use Pango from GI instead of the static bindings
- Date: Wed, 30 Jul 2014 22:17:52 +0000 (UTC)
commit 128b4db0188f8d9c98819f399a72bcf6dc5e03f6
Author: Joaquim Rocha <me joaquimrocha com>
Date: Fri Jul 11 23:38:45 2014 +0200
Use Pango from GI instead of the static bindings
src/ocrfeeder/feeder/documentGeneration.py | 15 +++++++--------
src/ocrfeeder/studio/dataHolder.py | 7 ++++---
src/ocrfeeder/studio/widgetModeler.py | 7 +++----
3 files changed, 14 insertions(+), 15 deletions(-)
---
diff --git a/src/ocrfeeder/feeder/documentGeneration.py b/src/ocrfeeder/feeder/documentGeneration.py
index 9ff12a5..809e99d 100644
--- a/src/ocrfeeder/feeder/documentGeneration.py
+++ b/src/ocrfeeder/feeder/documentGeneration.py
@@ -23,13 +23,12 @@ from ocrfeeder.odf.opendocument import OpenDocumentText
from ocrfeeder.odf.style import Style, MasterPage, GraphicProperties, ParagraphProperties, \
TextProperties, PageLayout, PageLayoutProperties
from ocrfeeder.odf.text import P, Page, PageSequence
-from pango import WEIGHT_BOLD, WEIGHT_NORMAL, STYLE_ITALIC, STYLE_NORMAL, \
- STYLE_OBLIQUE
from ocrfeeder.util import TEXT_TYPE, IMAGE_TYPE, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTER, \
ALIGN_FILL
from ocrfeeder.util.configuration import ConfigurationManager
from ocrfeeder.util.graphics import getImagePrintSize
from ocrfeeder.util.lib import debug
+from gi.repository import Pango
from reportlab.pdfgen import canvas
from reportlab.lib import units
from reportlab.lib.utils import ImageReader, simpleSplit
@@ -157,14 +156,14 @@ class HtmlGenerator(DocumentGenerator):
return style_name
def convertFontStyle(self, style):
- if style == STYLE_OBLIQUE:
+ if style == Pango.Style.OBLIQUE:
return 'oblique'
- elif style == STYLE_ITALIC:
+ elif style == Pango.Style.ITALIC:
return 'italic'
return 'normal'
def convertFontWeight(self, weight):
- if weight == WEIGHT_BOLD:
+ if weight == Pango.Weight.BOLD:
return 'bold'
return 'normal'
@@ -341,14 +340,14 @@ class OdtGenerator(DocumentGenerator):
return style_name
def convertFontStyle(self, style):
- if style == STYLE_OBLIQUE:
+ if style == Pango.Style.OBLIQUE:
return 'oblique'
- elif style == STYLE_ITALIC:
+ elif style == Pango.Style.ITALIC:
return 'italic'
return 'normal'
def convertFontWeight(self, weight):
- if weight == WEIGHT_BOLD:
+ if weight == Pango.Weight.BOLD:
return 'bold'
return 'normal'
diff --git a/src/ocrfeeder/studio/dataHolder.py b/src/ocrfeeder/studio/dataHolder.py
index 1c03929..e32be1d 100644
--- a/src/ocrfeeder/studio/dataHolder.py
+++ b/src/ocrfeeder/studio/dataHolder.py
@@ -21,14 +21,15 @@
import os.path
from ocrfeeder.util import graphics
from PIL import Image
-from gi.repository import GObject
+from gi.repository import GObject, Pango
from ocrfeeder.util.graphics import getImagePrintSize, getImageResolution
from ocrfeeder.util import TEXT_TYPE, IMAGE_TYPE, ALIGN_LEFT, lib
-from pango import WEIGHT_NORMAL, STYLE_NORMAL
class TextData:
- def __init__(self, face = 'Sans', size = 12, justification = ALIGN_LEFT, line_space = 0, letter_space =
0, style = STYLE_NORMAL, weight = WEIGHT_NORMAL, language = ''):
+ def __init__(self, face = 'Sans', size = 12, justification = ALIGN_LEFT,
+ line_space = 0, letter_space = 0, style = Pango.Style.NORMAL,
+ weight = Pango.Weight.NORMAL, language = ''):
self.face = face
self.size = size
self.line_space = line_space
diff --git a/src/ocrfeeder/studio/widgetModeler.py b/src/ocrfeeder/studio/widgetModeler.py
index cd09c2a..5200960 100644
--- a/src/ocrfeeder/studio/widgetModeler.py
+++ b/src/ocrfeeder/studio/widgetModeler.py
@@ -23,7 +23,6 @@ from dataHolder import DataBox, PageData, TEXT_TYPE, IMAGE_TYPE
from ocrfeeder.feeder.documentGeneration import OdtGenerator, HtmlGenerator, PlaintextGenerator, PdfGenerator
from ocrfeeder.feeder.imageManipulation import *
from ocrfeeder.feeder.layoutAnalysis import *
-from pango import FontDescription, SCALE
from project import ProjectSaver, ProjectLoader
from ocrfeeder.util import graphics, ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTER, \
ALIGN_FILL, PAPER_SIZES
@@ -35,7 +34,7 @@ from widgetPresenter import BoxEditor, PagesToExportDialog, FileDialog, \
PageSizeDialog, getPopupMenu, WarningDialog, UnpaperDialog, \
QueuedEventsProgressDialog, SpellCheckerDialog
import gettext
-from gi.repository import Gtk, GObject, Gdk, GdkPixbuf
+from gi.repository import Gtk, GObject, Gdk, GdkPixbuf, Pango
import math
import os.path
import threading
@@ -880,9 +879,9 @@ class Editor:
def __setDataBoxFont(self, font_button = None):
font_button = font_button or self.box_editor.font_button
- font_description = FontDescription(font_button.get_font_name())
+ font_description = Pango.FontDescription(font_button.get_font_name())
self.data_box.setFontFace(font_description.get_family())
- self.data_box.setFontSize(font_description.get_size() / SCALE)
+ self.data_box.setFontSize(font_description.get_size() / Pango.SCALE)
self.data_box.setFontStyle(font_description.get_style())
self.data_box.setFontWeight(font_description.get_weight())
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]