Skip to content

Commit

Permalink
Add and use NotoSans font for text instead of Courier.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelrsweet committed Nov 19, 2023
1 parent a2a6efd commit ade96d8
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 6 deletions.
10 changes: 10 additions & 0 deletions tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ install: all
$(RM) $(BUILDROOT)$(bindir)/$$file; \
$(LN) ipptransform $(BUILDROOT)$(bindir)/$$file; \
done
echo "Installing fonts to $(BUILDROOT)$(CUPS_DATADIR)/fonts..."
$(INSTALL_DIR) $(BUILDROOT)$(CUPS_DATADIR)/fonts
for file in NotoSansMono-License.txt NotoSansMono-Regular.ttf; do \
$(INSTALL_DATA) $$file $(BUILDROOT)$(CUPS_DATADIR)/fonts; \
done
if test "x$(SYMROOT)" != "x"; then \
echo "Copying debug symbols to $(SYMROOT)..."; \
$(INSTALL_DIR) $(SYMROOT); \
Expand All @@ -99,6 +104,11 @@ uninstall:
$(RM) $(BUILDROOT)$(bindir)/$$file; \
done
-$(RMDIR) $(BUILDROOT)$(bindir)
echo "Uninstalling fonts from $(BUILDROOT)$(CUPS_DATADIR)/fonts..."
for file in NotoSansMono-License.txt NotoSansMono-Regular.ttf; do \
$(RM) $(BUILDROOT)$(CUPS_DATADIR)/fonts/$$file; \
done
-$(RMDIR) $(BUILDROOT)$(CUPS_DATADIR)/fonts


#
Expand Down
93 changes: 93 additions & 0 deletions tools/NotoSansMono-License.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
Copyright 2022 The Noto Project Authors (https://github.com/notofonts/latin-greek-cyrillic)

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file added tools/NotoSansMono-Regular.ttf
Binary file not shown.
21 changes: 15 additions & 6 deletions tools/ipptransform.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ extern char **environ;

#define XFORM_TEXT_SIZE 10.0 // Point size of plain text output
#define XFORM_TEXT_HEIGHT 12.0 // Point height of plain text output
#define XFORM_TEXT_WIDTH 0.6 // Width of Courier characters
#define XFORM_TEXT_WIDTH 0.6 // Width of monospaced characters

#define XFORM_RED_MASK 0x000000ff
#define XFORM_GREEN_MASK 0x0000ff00
Expand Down Expand Up @@ -1078,7 +1078,9 @@ convert_text(
{
pdfio_file_t *pdf; // Temporary PDF file
pdfio_stream_t *st = NULL; // Page stream
pdfio_obj_t *courier; // Courier font
char fontfile[1024]; // Monospace font filename
pdfio_obj_t *font; // Monospace font
bool unicode; // Doing Unicode text?
pdfio_dict_t *dict; // Page dictionary
cups_file_t *fp; // File
char line[1024], // Line from file
Expand All @@ -1090,6 +1092,7 @@ convert_text(
columns, // Columns per line
linenum = 0, // Current line
lines; // Number of lines per page
_cups_globals_t *cg = _cupsGlobals(); // Global data


// Open the text file...
Expand Down Expand Up @@ -1118,10 +1121,16 @@ convert_text(
}

// Create font and page dictionaries...
courier = pdfioFileCreateFontObjFromBase(pdf, "Courier");
dict = pdfioDictCreate(pdf);
snprintf(fontfile, sizeof(fontfile), "%s/fonts/NotoSansMono-Regular.ttf", cg->datadir);
unicode = !access(fontfile, 0);
if (unicode)
font = pdfioFileCreateFontObjFromFile(pdf, fontfile, true);
else
font = pdfioFileCreateFontObjFromBase(pdf, "Courier");

pdfioPageDictAddFont(dict, "F1", courier);
dict = pdfioDictCreate(pdf);

pdfioPageDictAddFont(dict, "F1", font);

// Read lines from the text file...
while (cupsFileGets(fp, line, sizeof(line)))
Expand Down Expand Up @@ -1244,7 +1253,7 @@ convert_text(
}

// Add a single line of text to the page...
pdfioContentTextShowf(st, false, "%s\n", outline);
pdfioContentTextShowf(st, unicode, "%s\n", outline);

linenum ++;
column = 0;
Expand Down

0 comments on commit ade96d8

Please sign in to comment.