<commit_before>
from rinoh.dimension import PT, INCH, CM
from rinoh.font import TypeFace, TypeFamily
from rinoh.font.type1 import Type1Font
from rinoh.font.opentype import OpenTypeFont
from rinoh.font.style import REGULAR, MEDIUM, BOLD, ITALIC
from rinoh.paper import Paper, LETTER
from rinoh.document import Document, Page, PORTRAIT
from rinoh.layout import Container, DownExpandingContainer, Chain
from rinoh.layout import TopFloatContainer, FootnoteContainer
from rinoh.paragraph import ParagraphStyle, Paragraph, LEFT, RIGHT, CENTER, BOTH
from rinoh.paragraph import ProportionalSpacing, FixedSpacing, TabStop
from rinoh.number import CHARACTER_UC, ROMAN_UC, NUMBER
from rinoh.text import SingleStyledText, MixedStyledText
from rinoh.text import Bold, Emphasized, SmallCaps, Superscript, Subscript
from rinoh.text import TextStyle, BOLD_ITALIC_STYLE
from rinoh.text import Tab as RinohTab
from rinoh.math import MathFonts, MathStyle, Equation, EquationStyle
from rinoh.math import Math as RinohMath
from rinoh.structure import Heading, List
from rinoh.structure import HeadingStyle, ListStyle
from rinoh.structure import Header, Footer, HeaderStyle, FooterStyle
from rinoh.structure import TableOfContents, TableOfContentsStyle
from rinoh.reference import Field, Reference, REFERENCE
from rinoh.reference import Footnote as RinohFootnote
from rinoh.flowable import Flowable, FlowableStyle, Floating
from rinoh.float import Figure as RinohFigure, CaptionStyle
from rinoh.table import Tabular as RinohTabular, MIDDLE
from rinoh.table import HTMLTabularData, CSVTabularData, TabularStyle, CellStyle
from rinoh.draw import LineStyle, RED
from rinoh.style import PARENT_STYLE, StyleStore
from rinoh.frontend.xml import element_factory
from rinoh.backend import pdf

import rinoh.frontend.xml.elementtree as xml_frontend

from citeproc import CitationStylesStyle, CitationStylesBibliography
from citeproc import Citation, CitationItem, Locator



# use Gyre Termes instead of (PDF Core) Times
use_gyre = True

# fonts
# ----------------------------------------------------------------------------
if use_gyre:
    #termes_roman = Type1Font("../fonts/qtmr", weight=REGULAR)
    termes_roman = OpenTypeFont("../fonts/texgyretermes-regular.otf",
                                weight=REGULAR)
    termes_italic = Type1Font("../fonts/qtmri", weight=REGULAR, slant=ITALIC)
    termes_bold = Type1Font("../fonts/qtmb", weight=BOLD)
    termes_bold_italic = Type1Font("../fonts/qtmbi", weight=BOLD, slant=ITALIC)

    termes = TypeFace("TeXGyreTermes", termes_roman, termes_bold,
                      termes_italic, termes_bold_italic)
    cursor_regular = Type1Font("../fonts/qcrr", weight=REGULAR)
    cursor = TypeFace("TeXGyreCursor", cursor_regular)

    ieeeFamily = TypeFamily(serif=termes, mono=cursor)

    schola_roman = Type1Font("../fonts/qcsr", weight=REGULAR)
    schola_italic = Type1Font("../fonts/qcsri", weight=REGULAR, slant=ITALIC)
    schola_bold = Type1Font("../fonts/qcsb", weight=BOLD)
    heros_roman = Type1Font("../fonts/qhvr", weight=REGULAR)
    chorus = Type1Font("../fonts/qzcmi", weight=MEDIUM)
    standard_symbols = Type1Font("../fonts/usyr", weight=REGULAR)
    cmex9 = Type1Font("../fonts/cmex9", weight=REGULAR)

    mathfonts = MathFonts(schola_roman, schola_italic, schola_bold,
                          heros_roman, cursor_regular, chorus, standard_symbols,
                          cmex9)
else:
    from rinoh.fonts.adobe14 import pdf_family as ieeeFamily
    #from rinoh.fonts.adobe35 import palatino, helvetica, courier
    #from rinoh.fonts.adobe35 import newcenturyschlbk, bookman
    #ieeeFamily = TypeFamily(serif=palatino, sans=helvetica, mono=courier)
    from rinoh.fonts.adobe35 import postscript_mathfonts as mathfonts


# styles
# ----------------------------------------------------------------------------
styles = StyleStore()

styles['body'] = ParagraphStyle(typeface=ieeeFamily.serif,
                                font_weight=REGULAR,
                                font_size=10*PT,
                                line_spacing=FixedSpacing(12*PT),
                                indent_first=0.125*INCH,
                                space_above=0*PT,
                                space_below=0*PT,
                                justify=BOTH)

# set style defaults

#TextStyle.attributes['kerning'] = False
#TextStyle.attributes['ligatures'] = False
ParagraphStyle.attributes['typeface'] = styles['body'].typeface
ParagraphStyle.attributes['hyphen_lang'] = 'en_US'
ParagraphStyle.attributes['hyphen_chars'] = 4


styles['math'] = MathStyle(fonts=mathfonts)

styles['equation'] = EquationStyle(base='body',
                                   math_style='math',
                                   indent_first=0*PT,
                                   space_above=6*PT,
                                   space_below=6*PT,
                                   justify=CENTER,
                                   tab_stops=[TabStop(0.5, CENTER),
                                              TabStop(1.0, RIGHT)])

styles['toc0'] = ParagraphStyle(base='body',
                                indent_first=0)<commit_msg>Pre-load the hyphenation dictionary to be able to properly benchmark<commit_after>
from rinoh.dimension import PT, INCH, CM
from rinoh.font import TypeFace, TypeFamily
from rinoh.font.type1 import Type1Font
from rinoh.font.opentype import OpenTypeFont
from rinoh.font.style import REGULAR, MEDIUM, BOLD, ITALIC
from rinoh.paper import Paper, LETTER
from rinoh.document import Document, Page, PORTRAIT
from rinoh.layout import Container, DownExpandingContainer, Chain
from rinoh.layout import TopFloatContainer, FootnoteContainer
from rinoh.paragraph import ParagraphStyle, Paragraph, LEFT, RIGHT, CENTER, BOTH
from rinoh.paragraph import ProportionalSpacing, FixedSpacing, TabStop
from rinoh.number import CHARACTER_UC, ROMAN_UC, NUMBER
from rinoh.text import SingleStyledText, MixedStyledText
from rinoh.text import Bold, Emphasized, SmallCaps, Superscript, Subscript
from rinoh.text import TextStyle, BOLD_ITALIC_STYLE
from rinoh.text import Tab as RinohTab
from rinoh.math import MathFonts, MathStyle, Equation, EquationStyle
from rinoh.math import Math as RinohMath
from rinoh.structure import Heading, List
from rinoh.structure import HeadingStyle, ListStyle
from rinoh.structure import Header, Footer, HeaderStyle, FooterStyle
from rinoh.structure import TableOfContents, TableOfContentsStyle
from rinoh.reference import Field, Reference, REFERENCE
from rinoh.reference import Footnote as RinohFootnote
from rinoh.flowable import Flowable, FlowableStyle, Floating
from rinoh.float import Figure as RinohFigure, CaptionStyle
from rinoh.table import Tabular as RinohTabular, MIDDLE
from rinoh.table import HTMLTabularData, CSVTabularData, TabularStyle, CellStyle
from rinoh.draw import LineStyle, RED
from rinoh.style import PARENT_STYLE, StyleStore
from rinoh.frontend.xml import element_factory
from rinoh.backend import pdf

import rinoh.frontend.xml.elementtree as xml_frontend

from citeproc import CitationStylesStyle, CitationStylesBibliography
from citeproc import Citation, CitationItem, Locator



# use Gyre Termes instead of (PDF Core) Times
use_gyre = True

# fonts
# ----------------------------------------------------------------------------
if use_gyre:
    #termes_roman = Type1Font("../fonts/qtmr", weight=REGULAR)
    termes_roman = OpenTypeFont("../fonts/texgyretermes-regular.otf",
                                weight=REGULAR)
    #termes_roman = OpenTypeFont(r"C:\Windows\Fonts\times.ttf", weight=REGULAR)
    termes_italic = Type1Font("../fonts/qtmri", weight=REGULAR, slant=ITALIC)
    termes_bold = Type1Font("../fonts/qtmb", weight=BOLD)
    termes_bold_italic = Type1Font("../fonts/qtmbi", weight=BOLD, slant=ITALIC)

    termes = TypeFace("TeXGyreTermes", termes_roman, termes_bold,
                      termes_italic, termes_bold_italic)
    cursor_regular = Type1Font("../fonts/qcrr", weight=REGULAR)
    cursor = TypeFace("TeXGyreCursor", cursor_regular)

    ieeeFamily = TypeFamily(serif=termes, mono=cursor)

    schola_roman = Type1Font("../fonts/qcsr", weight=REGULAR)
    schola_italic = Type1Font("../fonts/qcsri", weight=REGULAR, slant=ITALIC)
    schola_bold = Type1Font("../fonts/qcsb", weight=BOLD)
    heros_roman = Type1Font("../fonts/qhvr", weight=REGULAR)
    chorus = Type1Font("../fonts/qzcmi", weight=MEDIUM)
    standard_symbols = Type1Font("../fonts/usyr", weight=REGULAR)
    cmex9 = Type1Font("../fonts/cmex9", weight=REGULAR)

    mathfonts = MathFonts(schola_roman, schola_italic, schola_bold,
                          heros_roman, cursor_regular, chorus, standard_symbols,
                          cmex9)
else:
    from rinoh.fonts.adobe14 import pdf_family as ieeeFamily
    #from rinoh.fonts.adobe35 import palatino, helvetica, courier
    #from rinoh.fonts.adobe35 import newcenturyschlbk, bookman
    #ieeeFamily = TypeFamily(serif=palatino, sans=helvetica, mono=courier)
    from rinoh.fonts.adobe35 import postscript_mathfonts as mathfonts


# styles
# ----------------------------------------------------------------------------
styles = StyleStore()

styles['body'] = ParagraphStyle(typeface=ieeeFamily.serif,
                                font_weight=REGULAR,
                                font_size=10*PT,
                                line_spacing=FixedSpacing(12*PT),
                                indent_first=0.125*INCH,
                                space_above=0*PT,
                                space_below=0*PT,
                                justify=BOTH)

# set style defaults

#TextStyle.attributes['kerning'] = False
#TextStyle.attributes['ligatures'] = False
ParagraphStyle.attributes['typeface'] = styles['body'].typeface
ParagraphStyle.attributes['hyphen_lang'] = 'en_US'
ParagraphStyle.attributes['hyphen_chars'] = 4
#ParagraphStyle.attributes['hyphenate'] = False

# pre-load hyphenation dictionary (which otherwise occurs during page rendering,
# and thus invalidates per-page render time)
from rinoh.paragraph import HYPHENATORS
HYPHENATORS[(styles['body'].hyphen_lang, styles['body'].hyphen_chars)]

styles['math'] = MathStyle(fonts=mathfonts)

styles['equation'] = EquationStyle(base='body',
                                   math_style='math',
                                   indent_first=0*PT,
                                   space_above=6*PT,
                                   space_below=6*PT,
                                   justify=CENTER,
                                   tab_stops=[TabStop(0.5, CENTER),
                                              TabStop(1.0, RIGHT)])

styles['toc0'] = ParagraphStyle(base='body',
                                indent_first=0)
{'fraction_non_alphanumeric': 0.1137713437268003, 'fraction_numerical': 0.008351893095768375, 'mean_word_length': 2.855813953488372, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4021259', 'n_tokens_mistral': 3406, 'n_tokens_neox': 3194, 'n_words': 726}