1
0
forked from 0ad/0ad

Load original Pagella .otf font with hinting explicitly disabled, instead of loading via .ttf

This was SVN commit r9243.
This commit is contained in:
Ykkrosh 2011-04-13 22:15:04 +00:00
parent dac7b2d82b
commit 73add20727
5 changed files with 36 additions and 36 deletions

Binary file not shown.

Binary file not shown.

View File

@ -5,9 +5,5 @@ The following files are covered by the license in DejaVu-LICENSE.txt:
The following files are covered by the license in GUST-FONT-LICENSE.txt:
texgyrepagella-regular.otf
texgyrepagella-bold.otf
ConvertedPagella-Regular.ttf
ConvertedPagella-Bold.ttf
The texgyrepagella... fonts come from http://www.gust.org.pl/projects/e-foundry/tex-gyre/pagella
The Converted... fonts were produced by opening the originals in FontForge 20090923, changing the names, and exporting as TrueType.

View File

@ -7,6 +7,11 @@ import sys
CAIRO_STATUS_SUCCESS = 0
FT_Err_Ok = 0
FT_LOAD_DEFAULT = 0x0
FT_LOAD_NO_HINTING = 0x2
FT_LOAD_FORCE_AUTOHINT = 0x20
FT_LOAD_NO_AUTOHINT = 0x8000
# find required libraries (platform specific)
if sys.platform == "win32":
ft_lib = "freetype6.dll"
@ -27,7 +32,7 @@ _cairo_so.cairo_status.argtypes = [ ctypes.c_void_p ]
# initialize freetype
_ft_lib = ctypes.c_void_p ()
if FT_Err_Ok != _freetype_so.FT_Init_FreeType (ctypes.byref (_ft_lib)):
raise "Error initialising FreeType library."
raise Exception("Error initialising FreeType library.")
_surface = cairo.ImageSurface (cairo.FORMAT_A8, 0, 0)
@ -43,16 +48,16 @@ def create_cairo_font_face_for_file (filename, faceindex=0, loadoptions=0):
cairo_t = PycairoContext.from_address(id(cairo_ctx)).ctx
if FT_Err_Ok != _freetype_so.FT_New_Face (_ft_lib, filename, faceindex, ctypes.byref(ft_face)):
raise "Error creating FreeType font face for " + filename
raise Exception("Error creating FreeType font face for " + filename)
# create cairo font face for freetype face
cr_face = _cairo_so.cairo_ft_font_face_create_for_ft_face (ft_face, loadoptions)
if CAIRO_STATUS_SUCCESS != _cairo_so.cairo_font_face_status (cr_face):
raise "Error creating cairo font face for " + filename
raise Exception("Error creating cairo font face for " + filename)
_cairo_so.cairo_set_font_face (cairo_t, cr_face)
if CAIRO_STATUS_SUCCESS != _cairo_so.cairo_status (cairo_t):
raise "Error creating cairo font face for " + filename
raise Exception("Error creating cairo font face for " + filename)
face = cairo_ctx.get_font_face ()

View File

@ -90,9 +90,9 @@ def setup_context(width, height, face, size, renderstyle):
ctx.set_line_join(cairo.LINE_JOIN_ROUND)
return ctx, surface
def generate_font(chars, outname, ttf, size, renderstyle):
def generate_font(chars, outname, ttf, loadopts, size, renderstyle):
(face, indexes) = FontLoader.create_cairo_font_face_for_file(ttf)
(face, indexes) = FontLoader.create_cairo_font_face_for_file(ttf, 0, loadopts)
(ctx, _) = setup_context(1, 1, face, size, renderstyle)
@ -158,27 +158,32 @@ stroked3 = { "colour": True, "stroke": [((0, 0, 0, 1), 2.5)], "fill": [(1, 1, 1,
chars = load_char_list("charset.txt")
DejaVuSansMono = ("DejaVuSansMono.ttf", FontLoader.FT_LOAD_DEFAULT)
DejaVuSans = ("DejaVuSans.ttf", FontLoader.FT_LOAD_DEFAULT)
PagellaRegular = ("texgyrepagella-regular.otf", FontLoader.FT_LOAD_NO_HINTING)
PagellaBold = ("texgyrepagella-bold.otf", FontLoader.FT_LOAD_NO_HINTING)
fonts = (
("mono-10", "DejaVuSansMono.ttf", 10, filled),
("mono-stroke-10", "DejaVuSansMono.ttf", 10, stroked2),
("sans-10", "DejaVuSans.ttf", 10, filled),
("serif-9", "ConvertedPagella-Regular.ttf", 9, filled),
("serif-12", "ConvertedPagella-Regular.ttf", 12, filled),
("serif-13", "ConvertedPagella-Regular.ttf", 13, filled),
("serif-14", "ConvertedPagella-Regular.ttf", 14, filled),
("serif-16", "ConvertedPagella-Regular.ttf", 16, filled),
("serif-bold-12", "ConvertedPagella-Bold.ttf", 12, filled),
("serif-bold-13", "ConvertedPagella-Bold.ttf", 13, filled),
("serif-bold-14", "ConvertedPagella-Bold.ttf", 14, filled),
("serif-bold-16", "ConvertedPagella-Bold.ttf", 16, filled),
("serif-bold-18", "ConvertedPagella-Bold.ttf", 18, filled),
("serif-bold-20", "ConvertedPagella-Bold.ttf", 20, filled),
("serif-bold-22", "ConvertedPagella-Bold.ttf", 22, filled),
("serif-bold-24", "ConvertedPagella-Bold.ttf", 24, filled),
("serif-stroke-14", "ConvertedPagella-Regular.ttf", 14, stroked2),
("serif-bold-stroke-14", "ConvertedPagella-Bold.ttf", 14, stroked3),
("mono-10", DejaVuSansMono, 10, filled),
("mono-stroke-10", DejaVuSansMono, 10, stroked2),
("sans-10", DejaVuSans, 10, filled),
("serif-9", PagellaRegular, 9, filled),
("serif-12", PagellaRegular, 12, filled),
("serif-13", PagellaRegular, 13, filled),
("serif-14", PagellaRegular, 14, filled),
("serif-16", PagellaRegular, 16, filled),
("serif-bold-12", PagellaBold, 12, filled),
("serif-bold-13", PagellaBold, 13, filled),
("serif-bold-14", PagellaBold, 14, filled),
("serif-bold-16", PagellaBold, 16, filled),
("serif-bold-18", PagellaBold, 18, filled),
("serif-bold-20", PagellaBold, 20, filled),
("serif-bold-22", PagellaBold, 22, filled),
("serif-bold-24", PagellaBold, 24, filled),
("serif-stroke-14", PagellaRegular, 14, stroked2),
("serif-bold-stroke-14", PagellaBold, 14, stroked3),
)
for (name, fontname, size, style) in fonts:
for (name, (fontname, loadopts), size, style) in fonts:
print "%s..." % name
generate_font(chars, "../../../binaries/data/mods/public/fonts/%s" % name, "../../../binaries/data/tools/fontbuilder/fonts/%s" % fontname, size, style)
generate_font(chars, "../../../binaries/data/mods/public/fonts/%s" % name, "../../../binaries/data/tools/fontbuilder/fonts/%s" % fontname, loadopts, size, style)