Пример #1
0
def google_fonts(name):
    for item in STORAGE_PATH.iterdir():
        if item.is_dir() and item.name == name:
            fonts_path = item
            break
    else:
        fonts_path = STORAGE_PATH / name
        sys.stdout.write("\r")
        sys.stdout.flush()  # clear progress indicator
        print("Typeface '{}' is not installed; searching Google Fonts.".format(
            name))
        if not try_install_family(name, fonts_path):
            raise GoogleFontNotFound(name)
    return [
        OpenTypeFont(font_path)
        for font_path in find_static_font_files(fonts_path)
    ]
Пример #2
0
from os import path

from rinoh.font import Typeface
from rinoh.font.style import MEDIUM, ITALIC
from rinoh.font.opentype import OpenTypeFont

__all__ = ['typeface']


def otf(style):
    filename = 'texgyrechorus-{}.otf'.format(style)
    return path.join(path.dirname(__file__), filename)


typeface = Typeface(
    'TeX Gyre Chorus',
    OpenTypeFont(otf('mediumitalic'), weight=MEDIUM, slant=ITALIC))
Пример #3
0
from os import path

from rinoh.font import TypeFace
from rinoh.font.style import REGULAR, ITALIC, BOLD
from rinoh.font.opentype import OpenTypeFont


def filename(variant):
    return path.join(path.dirname(__file__),
                     'texgyreheros-{}.otf'.format(variant))


regular = OpenTypeFont(filename('regular'), weight=REGULAR)
italic = OpenTypeFont(filename('italic'), weight=REGULAR, slant=ITALIC)
bold = OpenTypeFont(filename('bold'), weight=BOLD)
bold_italic = OpenTypeFont(filename('bolditalic'), weight=BOLD, slant=ITALIC)

typeface = TypeFace('TeXGyreHeros', regular, italic, bold, bold_italic)
from os import path

from rinoh.font import Typeface
from rinoh.font.style import REGULAR, BOLD, ITALIC
from rinoh.font.opentype import OpenTypeFont


__all__ = ['typeface']


def otf(style):
    filename = 'texgyrecursor-{}.otf'.format(style)
    return path.join(path.dirname(__file__), filename)


typeface = Typeface('TeX Gyre Cursor',
                    OpenTypeFont(otf('regular'), weight=REGULAR),
                    OpenTypeFont(otf('italic'), weight=REGULAR, slant=ITALIC),
                    OpenTypeFont(otf('bold'), weight=BOLD),
                    OpenTypeFont(otf('bolditalic'), weight=BOLD, slant=ITALIC))
Пример #5
0
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)
Пример #6
0
def otf(style):
    filename = 'DejaVuSans{}.ttf'.format(style)
    return OpenTypeFont(path.join(path.dirname(__file__), filename))
Пример #7
0
import time

from rinoh.font.opentype import OpenTypeFont
from rinoh.font.style import SMALL_CAPITAL


if __name__ == "__main__":
    time.clock()
    ot = OpenTypeFont("texgyretermes-regular.otf")
    ot2 = OpenTypeFont("Cuprum.otf")
    ot3 = OpenTypeFont("Puritan2.otf")

    print(ot.get_kerning(ot.get_glyph("V"), ot.get_glyph("A")))
    print(ot2.get_kerning(ot2.get_glyph("U"), ot2.get_glyph("A")))
    print(ot.get_ligature(ot.get_glyph("f"), ot.get_glyph("f")))
    print(ot.get_ligature(ot.get_glyph("f"), ot.get_glyph("i")))
    print(ot.get_ligature(ot.get_glyph("f"), ot.get_glyph("i")))
    print(ot.get_glyph("s").code, ot.get_glyph("s", SMALL_CAPITAL).code)
    run_time = time.clock()
    print("Total execution time: {} seconds".format(run_time))
Пример #8
0
import time

from rinoh.font.opentype import OpenTypeFont
from rinoh.font.style import SMALL_CAPITAL

if __name__ == '__main__':
    time.clock()
    ot = OpenTypeFont('texgyretermes-regular.otf')
    ot2 = OpenTypeFont('Cuprum.otf')
    ot3 = OpenTypeFont('Puritan2.otf')

    print(
        ot.metrics.get_kerning(ot.metrics.get_glyph('V'),
                               ot.metrics.get_glyph('A')))
    print(
        ot2.metrics.get_kerning(ot2.metrics.get_glyph('U'),
                                ot2.metrics.get_glyph('A')))
    print(
        ot.metrics.get_ligature(ot.metrics.get_glyph('f'),
                                ot.metrics.get_glyph('f')))
    print(
        ot.metrics.get_ligature(ot.metrics.get_glyph('f'),
                                ot.metrics.get_glyph('i')))
    print(
        ot.metrics.get_ligature(ot.metrics.get_glyph('f'),
                                ot.metrics.get_glyph('i')))
    print(
        ot.metrics.get_glyph('s').code,
        ot.metrics.get_glyph('s', SMALL_CAPITAL).code)
    run_time = time.clock()
    print('Total execution time: {} seconds'.format(run_time))
Пример #9
0
from os import path

from rinoh.font import Typeface
from rinoh.font.style import REGULAR, BOLD, ITALIC, CONDENSED
from rinoh.font.opentype import OpenTypeFont


__all__ = ['typeface']


def otf(style, variant=''):
    filename = 'texgyreheros{}-{}.otf'.format(variant, style)
    return path.join(path.dirname(__file__), filename)


typeface = Typeface('TeX Gyre Heros',
                    OpenTypeFont(otf('regular'), weight=REGULAR),
                    OpenTypeFont(otf('italic'), weight=REGULAR, slant=ITALIC),
                    OpenTypeFont(otf('bold'), weight=BOLD),
                    OpenTypeFont(otf('bolditalic'), weight=BOLD, slant=ITALIC),
                    OpenTypeFont(otf('regular', 'cn'),
                                 width=CONDENSED, weight=REGULAR),
                    OpenTypeFont(otf('italic', 'cn'),
                                 width=CONDENSED, weight=REGULAR, slant=ITALIC),
                    OpenTypeFont(otf('bold', 'cn'),
                                 width=CONDENSED, weight=BOLD),
                    OpenTypeFont(otf('bolditalic', 'cn'),
                                 width=CONDENSED, weight=BOLD, slant=ITALIC))
Пример #10
0
from os import path

from rinoh.font import Typeface
from rinoh.font.style import REGULAR, ITALIC, BOLD
from rinoh.font.opentype import OpenTypeFont

__all__ = ['typeface']

# font files were downloaded from https://fontlibrary.org/en/font/carlito


def otf(style):
    filename = 'Carlito-{}.ttf'.format(style)
    return path.join(path.dirname(__file__), filename)


typeface = Typeface('Carlito', OpenTypeFont(otf('Regular'), weight=REGULAR),
                    OpenTypeFont(otf('Italic'), weight=REGULAR, slant=ITALIC),
                    OpenTypeFont(otf('Bold'), weight=BOLD),
                    OpenTypeFont(otf('BoldItalic'), weight=BOLD, slant=ITALIC))
from os import path

from rinoh.font import Typeface
from rinoh.font.style import REGULAR, BOLD, ITALIC, CONDENSED
from rinoh.font.opentype import OpenTypeFont

__all__ = ['typeface']


def otf(style):
    filename = 'DejaVuSerif{}.ttf'.format(style)
    return path.join(path.dirname(__file__), filename)


typeface = Typeface(
    'DejaVu Serif', OpenTypeFont(otf(''), weight=REGULAR),
    OpenTypeFont(otf('-Italic'), weight=REGULAR, slant=ITALIC),
    OpenTypeFont(otf('-Bold'), weight=BOLD),
    OpenTypeFont(otf('-BoldItalic'), weight=BOLD, slant=ITALIC),
    OpenTypeFont(otf('Condensed'), weight=REGULAR, width=CONDENSED),
    OpenTypeFont(otf('Condensed-Italic'),
                 weight=REGULAR,
                 slant=ITALIC,
                 width=CONDENSED),
    OpenTypeFont(otf('Condensed-Bold'), weight=BOLD, width=CONDENSED),
    OpenTypeFont(otf('Condensed-BoldItalic'),
                 weight=BOLD,
                 slant=ITALIC,
                 width=CONDENSED))
Пример #12
0
import time

from rinoh.font.opentype import OpenTypeFont
from rinoh.font.style import SMALL_CAPITAL

if __name__ == '__main__':
    time.clock()
    ot = OpenTypeFont('texgyretermes-regular.otf')
    ot2 = OpenTypeFont('Cuprum.otf')
    ot3 = OpenTypeFont('Puritan2.otf')

    print(ot.get_kerning(ot.get_glyph('V'), ot.get_glyph('A')))
    print(ot2.get_kerning(ot2.get_glyph('U'), ot2.get_glyph('A')))
    print(ot.get_ligature(ot.get_glyph('f'), ot.get_glyph('f')))
    print(ot.get_ligature(ot.get_glyph('f'), ot.get_glyph('i')))
    print(ot.get_ligature(ot.get_glyph('f'), ot.get_glyph('i')))
    print(ot.get_glyph('s').code, ot.get_glyph('s', SMALL_CAPITAL).code)
    run_time = time.clock()
    print('Total execution time: {} seconds'.format(run_time))
Пример #13
0
from os import path

from rinoh.font import Typeface
from rinoh.font.style import REGULAR, BOLD
from rinoh.font.opentype import OpenTypeFont

__all__ = ['typeface']


def otf(style):
    filename = 'notosanscjkjp-{}.otf'.format(style)
    return path.join(path.dirname(__file__), filename)


typeface = Typeface('Noto Sans CJK JP',
                    OpenTypeFont(otf('regular'), weight=REGULAR),
                    OpenTypeFont(otf('bold'), weight=BOLD))
Пример #14
0
from docutils.core import publish_doctree, publish_from_doctree

import rinoh as rt

from rinoh.font import TypeFace, TypeFamily
from rinoh.font.style import REGULAR, BOLD, ITALIC
from rinoh.font.type1 import Type1Font
from rinoh.font.opentype import OpenTypeFont
from rinoh.dimension import PT, CM, INCH
from rinoh.backend import pdf
from rinoh.frontend.xml import element_factory
from rinoh.util import all_subclasses

import rinoh.frontend.xml.elementtree as xml_frontend

pagella_regular = OpenTypeFont("../fonts/texgyrepagella-regular.otf",
                               weight=REGULAR)
pagella_italic = OpenTypeFont("../fonts/texgyrepagella-italic.otf",
                              weight=REGULAR,
                              slant=ITALIC)
pagella_bold = OpenTypeFont("../fonts/texgyrepagella-bold.otf", weight=BOLD)
pagella_bold_italic = OpenTypeFont("../fonts/texgyrepagella-bolditalic.otf",
                                   weight=BOLD,
                                   slant=ITALIC)

pagella = TypeFace("TeXGyrePagella", pagella_regular, pagella_italic,
                   pagella_bold, pagella_bold_italic)
cursor_regular = Type1Font("../fonts/qcrr", weight=REGULAR)
cursor = TypeFace("TeXGyreCursor", cursor_regular)

fontFamily = TypeFamily(serif=pagella, mono=cursor)