Compare commits

...

No commits in common. "gh-pages" and "main" have entirely different histories.

52 changed files with 7836 additions and 2 deletions

41
.github/workflows/build.yml vendored Normal file
View file

@ -0,0 +1,41 @@
name: Build CI
on:
push:
pull_request:
release:
types: [published]
check_suite:
types: [rerequested]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: install dependencies
run: |
sudo apt-get update
sudo apt-get --no-install-recommends -y install build-essential git
- name: build
run: |
docker run --rm -v $(pwd):/src -u $(id -u):$(id -g) emscripten/emsdk ./build.sh
- if: github.event_name == 'push' && github.ref == 'refs/heads/main'
name: publish
run: |
git branch -D gh-pages || true
python3 import.py | git fast-import --date-format=now
git config user.email "jeff@adafruit.com"
git config user.name "Jeff Epler (Adafruit) via github actions"
git remote set-url --push origin https://jepler:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git push -f origin gh-pages
- uses: actions/upload-artifact@v4
with:
name: Web pages
path: output/

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/output

1
AUTHORS Normal file
View file

@ -0,0 +1 @@
Keith Packard, MIT X Consortium

135
CODE_OF_CONDUCT.md Normal file
View file

@ -0,0 +1,135 @@
<!--
SPDX-FileCopyrightText: 2014 Coraline Ada Ehmke
SPDX-FileCopyrightText: 2019 Kattni Rembor for Adafruit Industries
SPDX-License-Identifier: CC-BY-4.0
-->
# Adafruit Community Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and leaders pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level or type of
experience, education, socio-economic status, nationality, personal appearance,
race, religion, or sexual identity and orientation.
## Our Standards
We are committed to providing a friendly, safe and welcoming environment for
all.
Examples of behavior that contributes to creating a positive environment
include:
* Be kind and courteous to others
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Collaborating with other community members
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and sexual attention or advances
* The use of inappropriate images, including in a community member's avatar
* The use of inappropriate language, including in a community member's nickname
* Any spamming, flaming, baiting or other attention-stealing behavior
* Excessive or unwelcome helping; answering outside the scope of the question
asked
* Trolling, insulting/derogatory comments, and personal or political attacks
* Promoting or spreading disinformation, lies, or conspiracy theories against
a person, group, organisation, project, or community
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate
The goal of the standards and moderation guidelines outlined here is to build
and maintain a respectful community. We ask that you dont just aim to be
"technically unimpeachable", but rather try to be your best self.
We value many things beyond technical expertise, including collaboration and
supporting others within our community. Providing a positive experience for
other community members can have a much more significant impact than simply
providing the correct answer.
## Our Responsibilities
Project leaders are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project leaders have the right and responsibility to remove, edit, or
reject messages, comments, commits, code, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any community member for other behaviors that they deem
inappropriate, threatening, offensive, or harmful.
## Moderation
Instances of behaviors that violate the Adafruit Community Code of Conduct
may be reported by any member of the community. Community members are
encouraged to report these situations, including situations they witness
involving other community members.
You may report in the following ways:
In any situation, you may send an email to <support@adafruit.com>.
On the Adafruit Discord, you may send an open message from any channel
to all Community Moderators by tagging @community moderators. You may
also send an open message from any channel, or a direct message to
@kattni#1507, @tannewt#4653, @danh#1614, @cater#2442,
@sommersoft#0222, @Mr. Certainly#0472 or @Andon#8175.
Email and direct message reports will be kept confidential.
In situations on Discord where the issue is particularly egregious, possibly
illegal, requires immediate action, or violates the Discord terms of service,
you should also report the message directly to Discord.
These are the steps for upholding our communitys standards of conduct.
1. Any member of the community may report any situation that violates the
Adafruit Community Code of Conduct. All reports will be reviewed and
investigated.
2. If the behavior is an egregious violation, the community member who
committed the violation may be banned immediately, without warning.
3. Otherwise, moderators will first respond to such behavior with a warning.
4. Moderators follow a soft "three strikes" policy - the community member may
be given another chance, if they are receptive to the warning and change their
behavior.
5. If the community member is unreceptive or unreasonable when warned by a
moderator, or the warning goes unheeded, they may be banned for a first or
second offense. Repeated offenses will result in the community member being
banned.
## Scope
This Code of Conduct and the enforcement policies listed above apply to all
Adafruit Community venues. This includes but is not limited to any community
spaces (both public and private), the entire Adafruit Discord server, and
Adafruit GitHub repositories. Examples of Adafruit Community spaces include
but are not limited to meet-ups, audio chats on the Adafruit Discord, or
interaction at a conference.
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. As a community
member, you are representing our community, and are expected to behave
accordingly.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 1.4, available at
<https://www.contributor-covenant.org/version/1/4/code-of-conduct.html>,
and the [Rust Code of Conduct](https://www.rust-lang.org/en-US/conduct.html).
For other projects adopting the Adafruit Community Code of
Conduct, please contact the maintainers of those projects for enforcement.
If you wish to use this code of conduct for your own project, consider
explicitly mentioning your moderation policy or making a copy with your
own moderation policy so as to avoid confusion.

22
CONTRIBUTING.md Normal file
View file

@ -0,0 +1,22 @@
<!--
SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors)
SPDX-License-Identifier: MIT
-->
# Contributing
Please note that this project is released with a
[Contributor Code of Conduct](CODE_OF_CONDUCT.md).
By participating in this project you agree to abide by its terms. Participation
covers any forum used to converse about CircuitPython including unofficial and official spaces. Failure to do
so will result in corrective actions such as time out or ban from the project.
## Licensing
By contributing to this repository you are certifying that you have all necessary
permissions to license the code under the Open Group License. You still retain the
copyright but are granting many permissions under the Open Group License.
For the full license text, see the COPYING file.
If you have an employment contract with your employer please make sure that they
don't automatically own your work product. Make sure to get any necessary approvals
before contributing. Another term for this contribution off-hours is moonlighting.

23
COPYING Normal file
View file

@ -0,0 +1,23 @@
Copyright 1991, 1993, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from The Open Group.

566
ChangeLog.historical Normal file
View file

@ -0,0 +1,566 @@
commit c0b7d0b4a8436145f3fddc78d2452d7c720cce8b
Author: Adam Jackson <ajax@redhat.com>
Date: Tue Nov 7 14:10:52 2017 -0500
bdftopcf 1.1
Signed-off-by: Adam Jackson <ajax@redhat.com>
commit 140f7f6e071a239329d700aa24191a664be2bea2
Author: Adam Jackson <ajax@redhat.com>
Date: Fri Nov 3 14:05:18 2017 -0400
Import more libXfont 1.x headers
The previous commit would build if you had the old headers installed,
but building it in a fresh chroot would fail. Import some more junk and
fix up the includes appropriately.
Signed-off-by: Adam Jackson <ajax@redhat.com>
commit 102696da8737fcb324034f673cd5815f28923311
Author: Adam Jackson <ajax@redhat.com>
Date: Tue Oct 24 13:54:47 2017 -0400
Import libXfont's BDF-to-PCF code
bdftopcf is the only consumer of libXfont 1.x's read/write support, and
we'd like 1.x to go away entirely. Copy in the BDF read and PCF write
support so there's one fewer consumer of 1.x.
Signed-off-by: Adam Jackson <ajax@redhat.com>
Acked-by: Julien Cristau <jcristau@debian.org>
commit e12c03d50a634a98e4560c7117a3bec3349561e9
Author: Mihail Konev <k.mvc@ya.ru>
Date: Thu Jan 26 14:00:20 2017 +1000
autogen: add default patch prefix
Signed-off-by: Mihail Konev <k.mvc@ya.ru>
commit 96dd358a7f921b45c381c42f483e5564ee0b80a7
Author: Emil Velikov <emil.l.velikov@gmail.com>
Date: Mon Mar 9 12:00:52 2015 +0000
autogen.sh: use quoted string variables
Place quotes around the $srcdir, $ORIGDIR and $0 variables to prevent
fall-outs, when they contain space.
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit d43135887fce7709084f5d3df9bf1e4c992fbd65
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date: Tue Jan 24 10:32:07 2017 +1000
autogen.sh: use exec instead of waiting for configure to finish
Syncs the invocation of configure with the one from the server.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
commit 211c077af0cf634aec54b91de7dde916da2da84b
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Tue Dec 30 15:14:31 2014 -0800
bdftopcf 1.0.5
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 234ab38883e36d63e4677d44a759fba829f68393
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sun Jun 1 21:02:04 2014 -0700
autogen.sh: Honor NOCONFIGURE=1
See http://people.gnome.org/~walters/docs/build-api.txt
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 05a3d1360842f6c530e53dec6480ef21ffc9f5db
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sun Jun 1 21:02:04 2014 -0700
configure: Drop AM_MAINTAINER_MODE
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit cf81381eac18f1a1f894fd31f2e4def1fbf7d027
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Mon Nov 4 22:29:59 2013 -0800
Print which option was in error along with usage message
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Gaetan Nadon <memsize@videotron.ca>
commit 2f5ac9eabfc9609bce3aa420a64f29279e626e95
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Mon Nov 4 22:28:19 2013 -0800
Correct usage message for scanline unit option to be -u, not -s
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Matthieu Herrb <matthieu@herrb.eu>
commit c8f568f295a11a7be406f170ed77a4c17a19fa7d
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat Jan 19 09:19:11 2013 -0800
config: Add missing AC_CONFIG_SRCDIR
Regroup AC statements under the Autoconf initialization section.
Regroup AM statements under the Automake initialization section.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 4759123ce0333e37ca13f3a6c9feed503fb13895
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Mon Jan 14 21:14:56 2013 -0800
bdftopcf 1.0.4
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit eb5013a55e7229979e5f46e627553e6121c2fca1
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Thu Jan 3 00:21:36 2013 -0800
Use remove() instead of unlink() to remove files
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit b6371ad6463cdc0c35e7ca5a34f1bd6d945266ec
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Thu Jan 3 00:19:30 2013 -0800
Use symbolic names instead of raw integers for stdin & stdout fd's
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 15cfc3dcd9194fcca7715049eb1f49be2aa6d92f
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Thu Jan 3 00:17:05 2013 -0800
Add -v flag to print version info
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit b73e3de2d8a192d64f22fd2f450741cba2b7ee18
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Thu Jan 3 00:07:16 2013 -0800
Combine usage message strings
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit f82c76db93e191f5d6dfc2b07333a2b22dc52875
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Thu Jan 3 00:07:06 2013 -0800
Initialize font to 0 values directly instead of via bzero
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit a28c5c4f2b9f3e20fb176e08a1eda149a8b866f3
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Thu Jan 3 00:01:52 2013 -0800
Adopt X.Org standard coding style (via x-indent.sh)
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 6d842fb19b4c85fd1bc69db604034667c0bb7b43
Author: Gaetan Nadon <memsize@videotron.ca>
Date: Wed Jan 19 10:06:55 2011 -0500
config: move man pages into their own directory
Use services provided by XORG_MANPAGE_SECTIONS.
Use standard Makefile for man pages.
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
commit f474c8a243d89162b596376193f802916428b89f
Author: Gaetan Nadon <memsize@videotron.ca>
Date: Thu Jan 13 11:15:00 2011 -0500
man: remove trailing spaces and tabs
Using s/[ \t]*$//
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
commit 5a98c1aff0d4d66a12132c18060172b20d556278
Author: Gaetan Nadon <memsize@videotron.ca>
Date: Wed Jan 12 16:28:01 2011 -0500
config: replace deprecated AM_CONFIG_HEADER with AC_CONFIG_HEADERS
This silences an Autoconf warning
commit e14b41b2af0c4aba099222433ef983ef83d4c938
Author: Gaetan Nadon <memsize@videotron.ca>
Date: Wed Jan 12 11:54:40 2011 -0500
config: use AC_PROG_INSTALL now supplied by XORG_DEFAULT_OPTIONS
It depends on util-macros 1.8 or later
The existing statement can now be removed from the configuration file.
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
commit bd6356693855f22de4fa50696c19f5bd8103aa88
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Fri Oct 29 19:53:54 2010 -0700
bdftopcf 1.0.3
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 423c3438394aa762feb9038e54e061f1761be252
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Fri Oct 29 19:52:06 2010 -0700
Remove unnecessary calls from configure.ac
XORG_DEFAULT_OPTIONS calls AC_PROG_CC
PKG_CHECK_MODULES calls AC_SUBST for CFLAGS and LIBS
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 89573e80d65db01ff12426781394969857bad715
Author: Gaetan Nadon <memsize@videotron.ca>
Date: Tue Jul 20 18:45:18 2010 -0400
config: update AC_PREREQ statement to 2.60
Unrelated to the previous patches, the new value simply reflects
the reality that the minimum level for autoconf to configure
all x.org modules is 2.60 dated June 2006.
ftp://ftp.gnu.org/gnu/autoconf/autoconf-2.60.tar.gz
Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
commit 7de8e74341322be5e6f4830478d477ef17c13a4a
Author: Jesse Adkins <jesserayadkins@gmail.com>
Date: Tue Sep 28 13:29:48 2010 -0700
Purge cvs tags.
Signed-off-by: Jesse Adkins <jesserayadkins@gmail.com>
commit 9615bfc454af6cb489e9572895ef00af022303b1
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Thu Jul 22 19:10:24 2010 -0700
Use AM_CFLAGS instead of bdftopcf_CFLAGS since there's only one target
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit ff16701d9054e47f1205e6ba4372077bd136062c
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Thu Jul 22 19:07:08 2010 -0700
config: upgrade to util-macros 1.8 for additional man page support
Use MAN_SUBST now supplied in XORG_MANPAGE_SECTIONS
The value of MAN_SUBST is the same for all X.Org packages.
Use AC_PROG_SED now supplied by XORG_DEFAULT_OPTIONS
The existing statement can now be removed from the configuration file.
Use automake provided $(AM_V_GEN) and XORG_DEFAULT_OPTIONS provided $(SED)
Enables silent rule and use platform appropriate version of sed.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit b29030dd85de4dee5d756390b1d15b3187bbb6d0
Author: Gaetan Nadon <memsize@videotron.ca>
Date: Thu Nov 26 09:19:52 2009 -0500
Makefile.am: add ChangeLog and INSTALL on MAINTAINERCLEANFILES
Now that the INSTALL file is generated.
Allows running make maintainer-clean.
commit fbce46de46b4c13098dc0590cf077150af3a470c
Author: Gaetan Nadon <memsize@videotron.ca>
Date: Wed Oct 28 14:09:07 2009 -0400
INSTALL, NEWS, README or AUTHORS files are missing/incorrect #24206
Add missing INSTALL file. Use standard GNU file on building tarball
README may have been updated
Remove AUTHORS file as it is empty and no content available yet.
Remove NEWS file as it is empty and no content available yet.
commit 8a6a1f4b7bde74b6df62ac949e75b4ba0aedff97
Author: Gaetan Nadon <memsize@videotron.ca>
Date: Tue Oct 27 15:07:24 2009 -0400
Deploy the new XORG_DEFAULT_OPTIONS #24242
This macro aggregate a number of existing macros that sets commmon
X.Org components configuration options. It shields the configuration file from
future changes.
commit 8021c657bcc6f27b99ed7a61f4036d614c47367d
Author: Gaetan Nadon <memsize@videotron.ca>
Date: Mon Oct 26 22:08:37 2009 -0400
Makefile.am: ChangeLog not required: EXTRA_DIST or *CLEANFILES #24432
ChangeLog filename is known to Automake and requires no further
coding in the makefile.
commit 6c1e289e0dcdd02b47d09547a8c5f9c8f0f50221
Author: Gaetan Nadon <memsize@videotron.ca>
Date: Thu Oct 22 12:34:14 2009 -0400
.gitignore: use common defaults with custom section # 24239
Using common defaults will reduce errors and maintenance.
Only the very small or inexistent custom section need periodic maintenance
when the structure of the component changes. Do not edit defaults.
commit 74b5dca54052c778d49e96b92fc2ef888a80cf8f
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Mon Sep 21 19:57:36 2009 -0700
bdftopcf 1.0.2
Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
commit 4f63878eab32d41c8a010d5e187f0c4cdc7eff32
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Mon Sep 21 19:51:44 2009 -0700
Migrate to xorg macros 1.3 & XORG_DEFAULT_OPTIONS
Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
commit 96a182df6f4168ec0b5585f08b088bfd58a383f6
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Mon Sep 21 19:43:10 2009 -0700
Add pointers to mailing list, bugzilla, wiki & git repo to README
Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
commit 7f1a66ecbe983e83e91941706218cde705b6cc0b
Author: Paulo Cesar Pereira de Andrade <pcpa@mandriva.com.br>
Date: Thu Jan 15 18:18:52 2009 -0200
Ansification and compile warning fixes.
This also uses XORG_CHANGELOG and XORG_CWARNFLAGS, corrects
make distcheck. There weren't any gcc 4.3 or sparse warnings.
commit 74541609dccff6e8405286b3f27661e2f4a00b29
Author: James Cloos <cloos@jhcloos.com>
Date: Thu Dec 6 15:51:03 2007 -0500
Add missing PHONY line for automatic ChangeLog generation
commit d6286044123ff787acf494a376dc22b2265623e2
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Wed Apr 25 17:05:43 2007 -0700
Version bump: 1.0.1
commit 963c88d67500b581fd4d44d4f561089c66bf7c56
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Tue Apr 24 20:04:39 2007 -0700
Fix sparse warning: Using plain integer as NULL pointer
commit 7206fb39a668384dfba3c8436222722123f4c9ff
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Tue Apr 24 20:03:51 2007 -0700
Add target for checking code with sparse/lint/etc.
commit c42df278513724e3236eecda859f069c34f78508
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Tue Apr 24 20:01:40 2007 -0700
Replace static ChangeLog with disthook to generate from git log
commit 608915a471c5a7a1cc3ecca19fc1b516480f439f
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Tue Apr 24 19:31:40 2007 -0700
Sun bug 6509763: bdftopcf crashes when bad font passed on stdin
When printing corrupt font error message, make sure file name reported is
not NULL.
commit a498f77133c4a6df5a192133528a846bd9e88d7c
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date: Tue Apr 24 19:30:13 2007 -0700
renamed: .cvsignore -> .gitignore
commit ebb668bf17f019813cc9615269d28da8205f1d00
Author: Kevin E Martin <kem@kem.org>
Date: Thu Dec 15 00:24:01 2005 +0000
Update package version number for final X11R7 release candidate.
commit 8e3cd1b0e5c443c3c93565343c6721a3345c085e
Author: Kevin E Martin <kem@kem.org>
Date: Tue Dec 6 22:48:15 2005 +0000
Change *man_SOURCES ==> *man_PRE to fix autotools warnings.
commit a61fd8c9f26b1defde1bf45ba5b938c197951d3f
Author: Kevin E Martin <kem@kem.org>
Date: Sat Dec 3 05:49:14 2005 +0000
Update package version number for X11R7 RC3 release.
commit 148db4c885a1adebf21e21d8f505b0148763cc00
Author: Alan Coopersmith <Alan.Coopersmith@sun.com>
Date: Mon Nov 28 22:01:36 2005 +0000
Change *mandir targets to use new *_MAN_DIR variables set by xorg-macros.m4
update to fix bug #5167 (Linux prefers *.1x man pages in man1 subdir)
commit a8afffe03349e74fbec823dd074b0c65bcc579c4
Author: Eric Anholt <anholt@freebsd.org>
Date: Mon Nov 21 10:34:54 2005 +0000
Another pass at .cvsignores for apps.
commit 1f9a92c950da572b246a5ee354617c7628539e9b
Author: Eric Anholt <anholt@freebsd.org>
Date: Sun Nov 20 22:08:47 2005 +0000
Add/improve .cvsignore files for apps.
commit f4d3c5288e31356b794253afb48c3691779b1cc2
Author: Kevin E Martin <kem@kem.org>
Date: Sat Nov 19 07:15:35 2005 +0000
Update pkgconfig files to separate library build-time dependencies from
application build-time dependencies, and update package deps to work
with separate build roots.
commit ebac4be33d3b439772212d35934f2753f03f42fe
Author: Kevin E Martin <kem@kem.org>
Date: Wed Nov 9 21:09:19 2005 +0000
Update package version number for X11R7 RC2 release.
commit 95833b04ce5ee998bcf2aaea03718157566ec671
Author: Kevin E Martin <kem@kem.org>
Date: Tue Nov 1 15:05:18 2005 +0000
Update pkgcheck depedencies to work with separate build roots.
commit 4358112e4b8c7433001c682de59b896df446d0f1
Author: Kevin E Martin <kem@kem.org>
Date: Wed Oct 19 02:47:47 2005 +0000
Update package version number for RC1 release.
commit 3079b683034b5ca45182df15e420041377aff190
Author: Alan Coopersmith <Alan.Coopersmith@sun.com>
Date: Mon Oct 17 23:56:18 2005 +0000
Use @APP_MAN_SUFFIX@ instead of $(APP_MAN_SUFFIX) in macro substitutions to
work better with BSD make
commit 3cf12f8bb84f6c7f48d21372026ed90cfbb448a4
Author: Alan Coopersmith <Alan.Coopersmith@sun.com>
Date: Fri Oct 14 00:25:40 2005 +0000
Use sed to fill in variables in man page
commit 1367d1093078bb49e4f1b5f1453fea41ae6f2b25
Author: Kristian Høgsberg <krh@redhat.com>
Date: Fri Sep 23 20:39:52 2005 +0000
Fill these in.
commit fc73e4a7408f73006267c4f9dbbd8edfadda17d6
Author: Kevin E Martin <kem@kem.org>
Date: Fri Jul 29 21:22:28 2005 +0000
Various changes preparing packages for RC0:
- Verify and update package version numbers as needed
- Implement versioning scheme
- Change bug address to point to bugzilla bug entry form
- Disable loadable i18n in libX11 by default (use --enable-loadable-i18n to
reenable it)
- Fix makedepend to use pkgconfig and pass distcheck
- Update build script to build macros first
- Update modular Xorg version
commit 4641ea0102ddccbe57de71dba7d31993b4f0d5fe
Author: Adam Jackson <ajax@nwnk.net>
Date: Wed Jul 20 19:31:48 2005 +0000
Use a unique token for PKG_CHECK_MODULES. Otherwise, if you use a global
configure cache, you cache it, and the cached value is probably wrong.
commit a1714821678853a349cfeb735e5cc2c05d7d7e10
Author: Kevin E Martin <kem@kem.org>
Date: Sun Jul 3 21:38:43 2005 +0000
Install publicly used headers in X11/fonts.
Change source files that use these headers to get them via <X11/fonts/*.h>.
commit 054583b047ea55cf8788ca94849f28c1fd601ee0
Author: Kevin E Martin <kem@kem.org>
Date: Sat Jul 2 21:42:05 2005 +0000
Add build system for bdftopcf, mkfontdir and mkfontscale
commit b19c10fc3e619fba0dfc0a93a79c3368fcc5ef8c
Author: Egbert Eich <eich@suse.de>
Date: Fri Apr 23 19:54:31 2004 +0000
Merging XORG-CURRENT into trunk
commit 3dc306ac1d27de0c20faaef7d0094131783fd294
Author: Egbert Eich <eich@suse.de>
Date: Sun Mar 14 08:34:49 2004 +0000
Importing vendor version xf86-4_4_99_1 on Sun Mar 14 00:26:39 PST 2004
commit c3b089ed758a0c74682256430bcbbb805b30e5ba
Author: Egbert Eich <eich@suse.de>
Date: Wed Mar 3 12:12:50 2004 +0000
Importing vendor version xf86-4_4_0 on Wed Mar 3 04:09:24 PST 2004
commit a455d7e899f248a6333c1435aaefa79a998fc9b3
Author: Egbert Eich <eich@suse.de>
Date: Thu Feb 26 13:36:15 2004 +0000
readding XFree86's cvs IDs
commit 74b7fe4751a5a37fa6c42b236038ed8f6109a5bd
Author: Egbert Eich <eich@suse.de>
Date: Thu Feb 26 09:23:53 2004 +0000
Importing vendor version xf86-4_3_99_903 on Wed Feb 26 01:21:00 PST 2004
commit 0ec9383c6314fbe7eb4b153a5b931cdced8e78a5
Author: Kaleb Keithley <kaleb@freedesktop.org>
Date: Fri Nov 14 16:48:57 2003 +0000
XFree86 4.3.0.1
commit f51be8ca0daef86a6f0b10383ca84f42fc1b9a74
Author: Kaleb Keithley <kaleb@freedesktop.org>
Date: Fri Nov 14 15:54:52 2003 +0000
R6.6 is the Xorg base-line

8
README.md Normal file
View file

@ -0,0 +1,8 @@
# web-bdftopcf
Convert BDF files to PCF files in your web browser
The latest version is hosted at https://adafruit.github.io/web-bdftopcf
To learn how to use web-bdftopcf, visit the [Adafruit Learning System](https://learn.adafruit.com/custom-fonts-for-pyportal-circuitpython-display/convert-to-pcf)
This project is built with emscripten; for details, see the github actions files that implement the CI and deployment workflow.

94
X11/Xarch.h Normal file
View file

@ -0,0 +1,94 @@
#ifndef _XARCH_H_
# define _XARCH_H_
/*
* Copyright 1997 Metro Link Incorporated
*
* All Rights Reserved
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the names of the above listed copyright holder(s)
* not be used in advertising or publicity pertaining to distribution of
* the software without specific, written prior permission. The above listed
* copyright holder(s) make(s) no representations about the suitability of
* this software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
* LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/*
* Determine the machine's byte order.
*/
/* See if it is set in the imake config first */
# ifdef X_BYTE_ORDER
# define X_BIG_ENDIAN 4321
# define X_LITTLE_ENDIAN 1234
# else
# if defined(SVR4) || defined(__SVR4)
# include <sys/types.h>
# include <sys/byteorder.h>
# elif defined(CSRG_BASED)
# if defined(__NetBSD__) || defined(__OpenBSD__)
# include <sys/types.h>
# endif
# include <machine/endian.h>
# elif defined(linux)
# if defined __STRICT_ANSI__
# undef __STRICT_ANSI__
# include <endian.h>
# define __STRICT_ANSI__
# else
# include <endian.h>
# endif
/* 'endian.h' might have been included before 'Xarch.h' */
# if !defined(LITTLE_ENDIAN) && defined(__LITTLE_ENDIAN)
# define LITTLE_ENDIAN __LITTLE_ENDIAN
# endif
# if !defined(BIG_ENDIAN) && defined(__BIG_ENDIAN)
# define BIG_ENDIAN __BIG_ENDIAN
# endif
# if !defined(PDP_ENDIAN) && defined(__PDP_ENDIAN)
# define PDP_ENDIAN __PDP_ENDIAN
# endif
# if !defined(BYTE_ORDER) && defined(__BYTE_ORDER)
# define BYTE_ORDER __BYTE_ORDER
# endif
# endif
# ifndef BYTE_ORDER
# define LITTLE_ENDIAN 1234
# define BIG_ENDIAN 4321
# if defined(__sun) && defined(__SVR4)
# include <sys/isa_defs.h>
# ifdef _LITTLE_ENDIAN
# define BYTE_ORDER LITTLE_ENDIAN
# endif
# ifdef _BIG_ENDIAN
# define BYTE_ORDER BIG_ENDIAN
# endif
# endif /* sun */
# endif /* BYTE_ORDER */
# define X_BYTE_ORDER BYTE_ORDER
# define X_BIG_ENDIAN BIG_ENDIAN
# define X_LITTLE_ENDIAN LITTLE_ENDIAN
# endif /* not in imake config */
#endif /* _XARCH_H_ */

108
X11/Xdefs.h Normal file
View file

@ -0,0 +1,108 @@
/***********************************************************
Copyright (c) 1999 The XFree86 Project Inc.
All Rights Reserved.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The XFree86 Project
Inc. shall not be used in advertising or otherwise to promote the
sale, use or other dealings in this Software without prior written
authorization from The XFree86 Project Inc..
*/
/**
** Types definitions shared between server and clients
**/
#ifndef _XDEFS_H
#define _XDEFS_H
#ifdef _XSERVER64
#include <X11/Xmd.h>
#endif
#ifndef _XTYPEDEF_ATOM
# define _XTYPEDEF_ATOM
# ifndef _XSERVER64
typedef unsigned long Atom;
# else
typedef CARD32 Atom;
# endif
#endif
#ifndef Bool
# ifndef _XTYPEDEF_BOOL
# define _XTYPEDEF_BOOL
typedef int Bool;
# endif
#endif
#ifndef _XTYPEDEF_POINTER
# define _XTYPEDEF_POINTER
typedef void *pointer;
#endif
#ifndef _XTYPEDEF_CLIENTPTR
typedef struct _Client *ClientPtr;
# define _XTYPEDEF_CLIENTPTR
#endif
#ifndef _XTYPEDEF_XID
# define _XTYPEDEF_XID
# ifndef _XSERVER64
typedef unsigned long XID;
# else
typedef CARD32 XID;
# endif
#endif
#ifndef _XTYPEDEF_MASK
# define _XTYPEDEF_MASK
# ifndef _XSERVER64
typedef unsigned long Mask;
# else
typedef CARD32 Mask;
# endif
#endif
#ifndef _XTYPEDEF_FONTPTR
# define _XTYPEDEF_FONTPTR
typedef struct _Font *FontPtr; /* also in fonts/include/font.h */
#endif
#ifndef _XTYPEDEF_FONT
# define _XTYPEDEF_FONT
typedef XID Font;
#endif
#ifndef _XTYPEDEF_FSID
# ifndef _XSERVER64
typedef unsigned long FSID;
# else
typedef CARD32 FSID;
# endif
#endif
typedef FSID AccContext;
/* OS independent time value
XXX Should probably go in Xos.h */
typedef struct timeval **OSTimePtr;
typedef void (* BlockHandlerProcPtr)(void * /* blockData */,
OSTimePtr /* pTimeout */,
void * /* pReadmask */);
#endif

148
X11/Xos.h Normal file
View file

@ -0,0 +1,148 @@
/*
*
Copyright 1987, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*
* The X Window System is a Trademark of The Open Group.
*
*/
/* This is a collection of things to try and minimize system dependencies
* in a "significant" number of source files.
*/
#ifndef _XOS_H_
# define _XOS_H_
# include <X11/Xosdefs.h>
/*
* Get major data types (esp. caddr_t)
*/
# include <sys/types.h>
# if defined(__SCO__) || defined(__UNIXWARE__)
# include <stdint.h>
# endif
/*
* Just about everyone needs the strings routines. We provide both forms here,
* index/rindex and strchr/strrchr, so any systems that don't provide them all
* need to have #defines here.
*
* These macros are defined this way, rather than, e.g.:
* #defined index(s,c) strchr(s,c)
* because someone might be using them as function pointers, and such
* a change would break compatibility for anyone who's relying on them
* being the way they currently are. So we're stuck with them this way,
* which can be really inconvenient. :-(
*/
# include <string.h>
# if defined(__SCO__) || defined(__UNIXWARE__) || defined(__sun) || defined(__CYGWIN__) || defined(_AIX) || defined(__APPLE__)
# include <strings.h>
# else
# ifndef index
# define index(s,c) (strchr((s),(c)))
# endif
# ifndef rindex
# define rindex(s,c) (strrchr((s),(c)))
# endif
# endif
/*
* Get open(2) constants
*/
# if defined(X_NOT_POSIX)
# include <fcntl.h>
# if defined(USL) || defined(__i386__) && (defined(SYSV) || defined(SVR4))
# include <unistd.h>
# endif
# ifdef WIN32
# include <X11/Xw32defs.h>
# else
# include <sys/file.h>
# endif
# else /* X_NOT_POSIX */
# include <fcntl.h>
# include <unistd.h>
# endif /* X_NOT_POSIX else */
/*
* Get struct timeval and struct tm
*/
# if defined(_POSIX_SOURCE) && defined(SVR4)
/* need to omit _POSIX_SOURCE in order to get what we want in SVR4 */
# undef _POSIX_SOURCE
# include <sys/time.h>
# define _POSIX_SOURCE
# elif defined(WIN32)
# include <time.h>
# if !defined(_WINSOCKAPI_) && !defined(_WILLWINSOCK_) && !defined(_TIMEVAL_DEFINED) && !defined(_STRUCT_TIMEVAL)
struct timeval {
long tv_sec; /* seconds */
long tv_usec; /* and microseconds */
};
# define _TIMEVAL_DEFINED
# endif
# include <sys/timeb.h>
# define gettimeofday(t) \
{ \
struct _timeb _gtodtmp; \
_ftime (&_gtodtmp); \
(t)->tv_sec = _gtodtmp.time; \
(t)->tv_usec = _gtodtmp.millitm * 1000; \
}
# else
# include <sys/time.h>
# include <time.h>
# endif /* defined(_POSIX_SOURCE) && defined(SVR4) */
/* define X_GETTIMEOFDAY macro, a portable gettimeofday() */
# if defined(_XOPEN_XPG4) || defined(_XOPEN_UNIX) /* _XOPEN_UNIX is XPG4.2 */
# define X_GETTIMEOFDAY(t) gettimeofday(t, (struct timezone*)0)
# else
# if defined(SVR4) || defined(__SVR4) || defined(WIN32)
# define X_GETTIMEOFDAY(t) gettimeofday(t)
# else
# define X_GETTIMEOFDAY(t) gettimeofday(t, (struct timezone*)0)
# endif
# endif /* XPG4 else */
# ifdef __GNU__
# define PATH_MAX 4096
# define MAXPATHLEN 4096
# define OPEN_MAX 256 /* We define a reasonable limit. */
# endif
/* use POSIX name for signal */
# if defined(X_NOT_POSIX) && defined(SYSV) && !defined(SIGCHLD)
# define SIGCHLD SIGCLD
# endif
# include <X11/Xarch.h>
#endif /* _XOS_H_ */

129
X11/fonts/FS.h Normal file
View file

@ -0,0 +1,129 @@
/*
* Copyright 1990, 1991 Network Computing Devices;
* Portions Copyright 1987 by Digital Equipment Corporation
*
* Permission to use, copy, modify, distribute, and sell this software and
* its documentation for any purpose is hereby granted without fee, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the names of Network Computing Devices or Digital
* not be used in advertising or publicity pertaining to distribution
* of the software without specific, written prior permission.
* Network Computing Devices and Digital make no representations
* about the suitability of this software for any purpose. It is provided
* "as is" without express or implied warranty.
*
* NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES
* OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
/*
Portions Copyright 1987, 1994, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
#ifndef _FS_H_
#define _FS_H_
#include <X11/Xdefs.h>
#include <X11/fonts/fsmasks.h>
#define FS_PROTOCOL 2
#define FS_PROTOCOL_MINOR 0
#ifndef X_PROTOCOL
/* protocol familes */
#define FamilyInternet 0
#define FamilyDECnet 1
#define FamilyChaos 2
#define FamilyInternet6 6
typedef unsigned int FSDrawDirection;
#endif
#ifndef None
#define None 0L
#endif
#define LeftToRightDrawDirection 0
#define RightToLeftDrawDirection 1
/* font info flags */
#define FontInfoAllCharsExist (1L << 0)
#define FontInfoInkInside (1L << 1)
#define FontInfoHorizontalOverlap (1L << 2)
/* auth status flags */
#define AuthSuccess 0
#define AuthContinue 1
#define AuthBusy 2
#define AuthDenied 3
/* property types */
#define PropTypeString 0
#define PropTypeUnsigned 1
#define PropTypeSigned 2
#ifndef LSBFirst
/* byte order */
#define LSBFirst 0
#define MSBFirst 1
#endif
/* event masks */
#define CatalogueChangeNotifyMask (1L << 0)
#define FontChangeNotifyMask (1L << 1)
/* errors */
#define FSSuccess -1
#define FSBadRequest 0
#define FSBadFormat 1
#define FSBadFont 2
#define FSBadRange 3
#define FSBadEventMask 4
#define FSBadAccessContext 5
#define FSBadIDChoice 6
#define FSBadName 7
#define FSBadResolution 8
#define FSBadAlloc 9
#define FSBadLength 10
#define FSBadImplementation 11
#define FirstExtensionError 128
#define LastExtensionError 255
/* events */
#define KeepAlive 0
#define CatalogueChangeNotify 1
#define FontChangeNotify 2
#define FSLASTEvent 3
#endif /* _FS_H_ */

814
X11/fonts/FSproto.h Normal file
View file

@ -0,0 +1,814 @@
/*
Copyright 1990, 1991, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
* Copyright 1990, 1991 Network Computing Devices;
* Portions Copyright 1987 by Digital Equipment Corporation
*
* Permission to use, copy, modify, distribute, and sell this software and
* its documentation for any purpose is hereby granted without fee, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the names of Network Computing Devices, or Digital
* not be used in advertising or publicity pertaining to distribution
* of the software without specific, written prior permission.
*
* NETWORK COMPUTING DEVICES, AND DIGITAL DISCLAIM ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES,
* OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
#ifndef _FS_PROTO_H_
#define _FS_PROTO_H_
#include <X11/fonts/FS.h>
#define sz_fsPropOffset 20
#define sz_fsPropInfo 8
#define sz_fsResolution 6
#define sz_fsChar2b 2
#define sz_fsChar2b_version1 2
#define sz_fsOffset32 8
#define sz_fsRange 4
#define sz_fsXCharInfo 12
#define sz_fsXFontInfoHeader 40
#define sz_fsConnClientPrefix 8
#define sz_fsConnSetup 12
#define sz_fsConnSetupExtra 8
#define sz_fsConnSetupAccept 12
/* request sizes */
#define sz_fsReq 4
#define sz_fsListExtensionsReq 4
#define sz_fsResourceReq 8
#define sz_fsNoopReq 4
#define sz_fsListExtensionReq 4
#define sz_fsQueryExtensionReq 4
#define sz_fsListCataloguesReq 12
#define sz_fsSetCataloguesReq 4
#define sz_fsGetCataloguesReq 4
#define sz_fsSetEventMaskReq 8
#define sz_fsGetEventMaskReq 4
#define sz_fsCreateACReq 8
#define sz_fsFreeACReq 8
#define sz_fsSetAuthorizationReq 8
#define sz_fsSetResolutionReq 4
#define sz_fsGetResolutionReq 4
#define sz_fsListFontsReq 12
#define sz_fsListFontsWithXInfoReq 12
#define sz_fsOpenBitmapFontReq 16
#define sz_fsQueryXInfoReq 8
#define sz_fsQueryXExtents8Req 12
#define sz_fsQueryXExtents16Req 12
#define sz_fsQueryXBitmaps8Req 16
#define sz_fsQueryXBitmaps16Req 16
#define sz_fsCloseReq 8
/* reply sizes */
#define sz_fsReply 8
#define sz_fsGenericReply 8
#define sz_fsListExtensionsReply 8
#define sz_fsQueryExtensionReply 20
#define sz_fsListCataloguesReply 16
#define sz_fsGetCataloguesReply 8
#define sz_fsGetEventMaskReply 12
#define sz_fsCreateACReply 12
#define sz_fsGetResolutionReply 8
#define sz_fsListFontsReply 16
#define sz_fsListFontsWithXInfoReply (12 + sz_fsXFontInfoHeader)
#define sz_fsOpenBitmapFontReply 16
#define sz_fsQueryXInfoReply (8 + sz_fsXFontInfoHeader)
#define sz_fsQueryXExtents8Reply 12
#define sz_fsQueryXExtents16Reply 12
#define sz_fsQueryXBitmaps8Reply 20
#define sz_fsQueryXBitmaps16Reply 20
#define sz_fsError 16
#define sz_fsEvent 12
#define sz_fsKeepAliveEvent 12
#define fsTrue 1
#define fsFalse 0
/* temp decls */
#define Mask CARD32
#define Font CARD32
#define AccContext CARD32
typedef CARD32 fsTimestamp;
#ifdef NOTDEF /* in fsmasks.h */
typedef CARD32 fsBitmapFormat;
typedef CARD32 fsBitmapFormatMask;
#endif
#define sz_fsBitmapFormat 4
typedef struct {
INT16 left B16,
right B16;
INT16 width B16;
INT16 ascent B16,
descent B16;
CARD16 attributes B16;
} fsXCharInfo;
typedef struct {
CARD8 high;
CARD8 low;
} fsChar2b;
typedef struct {
CARD8 low;
CARD8 high;
} fsChar2b_version1;
typedef struct {
CARD8 min_char_high;
CARD8 min_char_low;
CARD8 max_char_high;
CARD8 max_char_low;
} fsRange;
typedef struct {
CARD32 position B32;
CARD32 length B32;
} fsOffset32;
typedef struct {
fsOffset32 name;
fsOffset32 value;
CARD8 type;
BYTE pad0;
CARD16 pad1 B16;
} fsPropOffset;
typedef struct {
CARD32 num_offsets B32;
CARD32 data_len B32;
/* offsets */
/* data */
} fsPropInfo;
typedef struct {
CARD16 x_resolution B16;
CARD16 y_resolution B16;
CARD16 point_size B16;
} fsResolution;
typedef struct {
CARD32 flags B32;
CARD8 char_range_min_char_high;
CARD8 char_range_min_char_low;
CARD8 char_range_max_char_high;
CARD8 char_range_max_char_low;
CARD8 draw_direction;
CARD8 pad;
CARD8 default_char_high;
CARD8 default_char_low;
INT16 min_bounds_left B16;
INT16 min_bounds_right B16;
INT16 min_bounds_width B16;
INT16 min_bounds_ascent B16;
INT16 min_bounds_descent B16;
CARD16 min_bounds_attributes B16;
INT16 max_bounds_left B16;
INT16 max_bounds_right B16;
INT16 max_bounds_width B16;
INT16 max_bounds_ascent B16;
INT16 max_bounds_descent B16;
CARD16 max_bounds_attributes B16;
INT16 font_ascent B16;
INT16 font_descent B16;
/* propinfo */
} fsXFontInfoHeader;
/* requests */
typedef struct {
BYTE byteOrder;
CARD8 num_auths;
CARD16 major_version B16;
CARD16 minor_version B16;
CARD16 auth_len B16;
/* auth data */
} fsConnClientPrefix;
typedef struct {
CARD16 status B16;
CARD16 major_version B16;
CARD16 minor_version B16;
CARD8 num_alternates;
CARD8 auth_index;
CARD16 alternate_len B16;
CARD16 auth_len B16;
/* alternates */
/* auth data */
} fsConnSetup;
typedef struct {
CARD32 length B32;
CARD16 status B16;
CARD16 pad B16;
/* more auth data */
} fsConnSetupExtra;
typedef struct {
CARD32 length B32;
CARD16 max_request_len B16;
CARD16 vendor_len B16;
CARD32 release_number B32;
/* vendor string */
} fsConnSetupAccept;
typedef struct {
CARD8 reqType;
CARD8 data;
CARD16 length B16;
} fsReq;
/*
* The fsFakeReq structure is never used in the protocol; it is prepended
* to incoming packets when setting up a connection so we can index
* through InitialVector. To avoid alignment problems, it is padded
* to the size of a word on the largest machine this code runs on.
* Hence no sz_fsFakeReq constant is necessary.
*/
typedef struct {
CARD8 reqType;
CARD8 data;
CARD16 length B16;
CARD32 pad B32; /* to fill out to multiple of 64 bits */
} fsFakeReq;
typedef struct {
CARD8 reqType;
BYTE pad;
CARD16 length B16;
Font id B32;
} fsResourceReq;
typedef fsReq fsNoopReq;
typedef fsReq fsListExtensionsReq;
typedef struct {
CARD8 reqType;
BYTE nbytes;
CARD16 length B16;
/* name */
} fsQueryExtensionReq;
typedef struct {
CARD8 reqType;
CARD8 data;
CARD16 length B16;
CARD32 maxNames B32;
CARD16 nbytes B16;
CARD16 pad2 B16;
/* pattern */
} fsListCataloguesReq;
typedef struct {
CARD8 reqType;
BYTE num_catalogues;
CARD16 length B16;
/* catalogues */
} fsSetCataloguesReq;
typedef fsReq fsGetCataloguesReq;
typedef struct {
CARD8 reqType;
CARD8 ext_opcode;
CARD16 length B16;
Mask event_mask;
} fsSetEventMaskReq;
typedef struct {
CARD8 reqType;
CARD8 ext_opcode;
CARD16 length B16;
} fsGetEventMaskReq;
typedef struct {
CARD8 reqType;
BYTE num_auths;
CARD16 length B16;
AccContext acid B32;
/* auth protocols */
} fsCreateACReq;
typedef fsResourceReq fsFreeACReq;
typedef fsResourceReq fsSetAuthorizationReq;
typedef struct {
CARD8 reqType;
BYTE num_resolutions;
CARD16 length B16;
/* resolutions */
} fsSetResolutionReq;
typedef fsReq fsGetResolutionReq;
typedef struct {
CARD8 reqType;
BYTE pad;
CARD16 length B16;
CARD32 maxNames B32;
CARD16 nbytes B16;
CARD16 pad2 B16;
/* pattern */
} fsListFontsReq;
typedef fsListFontsReq fsListFontsWithXInfoReq;
typedef struct {
CARD8 reqType;
BYTE pad;
CARD16 length B16;
Font fid B32;
fsBitmapFormatMask format_mask B32;
fsBitmapFormat format_hint B32;
/* pattern */
} fsOpenBitmapFontReq;
typedef fsResourceReq fsQueryXInfoReq;
typedef struct {
CARD8 reqType;
BOOL range;
CARD16 length B16;
Font fid B32;
CARD32 num_ranges B32;
/* list of chars */
} fsQueryXExtents8Req;
typedef fsQueryXExtents8Req fsQueryXExtents16Req;
typedef struct {
CARD8 reqType;
BOOL range;
CARD16 length B16;
Font fid B32;
fsBitmapFormat format B32;
CARD32 num_ranges B32;
/* list of chars */
} fsQueryXBitmaps8Req;
typedef fsQueryXBitmaps8Req fsQueryXBitmaps16Req;
typedef fsResourceReq fsCloseReq;
/* replies */
typedef struct {
BYTE type;
BYTE data1;
CARD16 sequenceNumber B16;
CARD32 length B32;
} fsGenericReply;
typedef struct {
BYTE type;
CARD8 nExtensions;
CARD16 sequenceNumber B16;
CARD32 length B32;
/* extension names */
} fsListExtensionsReply;
typedef struct {
BYTE type;
CARD8 present;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD16 major_version B16;
CARD16 minor_version B16;
CARD8 major_opcode;
CARD8 first_event;
CARD8 num_events;
CARD8 first_error;
CARD8 num_errors;
CARD8 pad1;
CARD16 pad2 B16;
} fsQueryExtensionReply;
typedef struct {
BYTE type;
BYTE pad;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 num_replies B32;
CARD32 num_catalogues B32;
/* catalog names */
} fsListCataloguesReply;
typedef struct {
BYTE type;
CARD8 num_catalogues;
CARD16 sequenceNumber B16;
CARD32 length B32;
/* catalogue names */
} fsGetCataloguesReply;
typedef struct {
BYTE type;
BYTE pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 event_mask B32;
} fsGetEventMaskReply;
typedef struct {
BYTE type;
CARD8 auth_index;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD16 status B16;
CARD16 pad B16;
/* auth data */
} fsCreateACReply;
typedef struct {
CARD32 length B32;
CARD16 status B16;
CARD16 pad B16;
/* auth data */
} fsCreateACExtraReply;
typedef struct {
BYTE type;
CARD8 num_resolutions;
CARD16 sequenceNumber B16;
CARD32 length B32;
/* resolutions */
} fsGetResolutionReply;
typedef struct {
BYTE type;
BYTE pad1;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 following B32;
CARD32 nFonts B32;
/* font names */
} fsListFontsReply;
/*
* this one is messy. the reply itself is variable length (unknown
* number of replies) and the contents of each is variable (unknown
* number of properties)
*
*/
typedef struct {
BYTE type;
CARD8 nameLength; /* 0 is end-of-reply */
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 nReplies B32;
CARD32 font_header_flags B32;
CARD8 font_hdr_char_range_min_char_high;
CARD8 font_hdr_char_range_min_char_low;
CARD8 font_hdr_char_range_max_char_high;
CARD8 font_hdr_char_range_max_char_low;
CARD8 font_header_draw_direction;
CARD8 font_header_pad;
CARD8 font_header_default_char_high;
CARD8 font_header_default_char_low;
INT16 font_header_min_bounds_left B16;
INT16 font_header_min_bounds_right B16;
INT16 font_header_min_bounds_width B16;
INT16 font_header_min_bounds_ascent B16;
INT16 font_header_min_bounds_descent B16;
CARD16 font_header_min_bounds_attributes B16;
INT16 font_header_max_bounds_left B16;
INT16 font_header_max_bounds_right B16;
INT16 font_header_max_bounds_width B16;
INT16 font_header_max_bounds_ascent B16;
INT16 font_header_max_bounds_descent B16;
CARD16 font_header_max_bounds_attributes B16;
INT16 font_header_font_ascent B16;
INT16 font_header_font_descent B16;
/* propinfo */
/* name */
} fsListFontsWithXInfoReply;
typedef struct {
BYTE type;
CARD8 otherid_valid;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 otherid B32;
BYTE cachable;
BYTE pad1;
CARD16 pad2 B16;
} fsOpenBitmapFontReply;
typedef struct {
BYTE type;
CARD8 pad0;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 font_header_flags B32;
CARD8 font_hdr_char_range_min_char_high;
CARD8 font_hdr_char_range_min_char_low;
CARD8 font_hdr_char_range_max_char_high;
CARD8 font_hdr_char_range_max_char_low;
CARD8 font_header_draw_direction;
CARD8 font_header_pad;
CARD8 font_header_default_char_high;
CARD8 font_header_default_char_low;
INT16 font_header_min_bounds_left B16;
INT16 font_header_min_bounds_right B16;
INT16 font_header_min_bounds_width B16;
INT16 font_header_min_bounds_ascent B16;
INT16 font_header_min_bounds_descent B16;
CARD16 font_header_min_bounds_attributes B16;
INT16 font_header_max_bounds_left B16;
INT16 font_header_max_bounds_right B16;
INT16 font_header_max_bounds_width B16;
INT16 font_header_max_bounds_ascent B16;
INT16 font_header_max_bounds_descent B16;
CARD16 font_header_max_bounds_attributes B16;
INT16 font_header_font_ascent B16;
INT16 font_header_font_descent B16;
/* propinfo */
} fsQueryXInfoReply;
typedef struct {
BYTE type;
CARD8 pad0;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 num_extents B32;
/* extents */
} fsQueryXExtents8Reply;
typedef fsQueryXExtents8Reply fsQueryXExtents16Reply;
typedef struct {
BYTE type;
CARD8 pad0;
CARD16 sequenceNumber B16;
CARD32 length B32;
CARD32 replies_hint B32;
CARD32 num_chars B32;
CARD32 nbytes B32;
/* offsets */
/* glyphs */
} fsQueryXBitmaps8Reply;
typedef fsQueryXBitmaps8Reply fsQueryXBitmaps16Reply;
typedef union {
fsGenericReply generic;
fsListExtensionsReply extensions;
fsGetResolutionReply getres;
} fsReply;
/* errors */
typedef struct {
BYTE type;
BYTE request;
CARD16 sequenceNumber B16;
CARD32 length B32;
fsTimestamp timestamp;
CARD8 major_opcode;
CARD8 minor_opcode;
CARD16 pad B16;
} fsError;
typedef struct {
BYTE type;
BYTE request;
CARD16 sequenceNumber B16;
CARD32 length B32;
fsTimestamp timestamp;
CARD8 major_opcode;
CARD8 minor_opcode;
CARD16 pad B16;
} fsRequestError;
typedef struct {
BYTE type;
BYTE request;
CARD16 sequenceNumber B16;
CARD32 length B32;
fsTimestamp timestamp;
CARD8 major_opcode;
CARD8 minor_opcode;
CARD16 pad B16;
fsBitmapFormat format B32;
} fsFormatError;
typedef struct {
BYTE type;
BYTE request;
CARD16 sequenceNumber B16;
CARD32 length B32;
fsTimestamp timestamp;
CARD8 major_opcode;
CARD8 minor_opcode;
CARD16 pad B16;
Font fontid;
} fsFontError;
typedef struct {
BYTE type;
BYTE request;
CARD16 sequenceNumber B16;
CARD32 length B32;
fsTimestamp timestamp;
CARD8 major_opcode;
CARD8 minor_opcode;
CARD16 pad B16;
fsRange range;
} fsRangeError;
typedef struct {
BYTE type;
BYTE request;
CARD16 sequenceNumber B16;
CARD32 length B32;
fsTimestamp timestamp;
CARD8 major_opcode;
CARD8 minor_opcode;
CARD16 pad B16;
Mask event_mask;
} fsEventMaskError;
typedef struct {
BYTE type;
BYTE request;
CARD16 sequenceNumber B16;
CARD32 length B32;
fsTimestamp timestamp;
CARD8 major_opcode;
CARD8 minor_opcode;
CARD16 pad B16;
AccContext acid;
} fsAccessContextError;
typedef struct {
BYTE type;
BYTE request;
CARD16 sequenceNumber B16;
CARD32 length B32;
fsTimestamp timestamp;
CARD8 major_opcode;
CARD8 minor_opcode;
CARD16 pad B16;
Font fontid;
} fsIDChoiceError;
typedef struct {
BYTE type;
BYTE request;
CARD16 sequenceNumber B16;
CARD32 length B32;
fsTimestamp timestamp;
CARD8 major_opcode;
CARD8 minor_opcode;
CARD16 pad B16;
} fsNameError;
typedef struct {
BYTE type;
BYTE request;
CARD16 sequenceNumber B16;
CARD32 length B32;
fsTimestamp timestamp;
CARD8 major_opcode;
CARD8 minor_opcode;
fsResolution resolution;
} fsResolutionError;
typedef struct {
BYTE type;
BYTE request;
CARD16 sequenceNumber B16;
CARD32 length B32;
fsTimestamp timestamp;
CARD8 major_opcode;
CARD8 minor_opcode;
CARD16 pad B16;
} fsAllocError;
typedef struct {
BYTE type;
BYTE request;
CARD16 sequenceNumber B16;
CARD32 length B32;
fsTimestamp timestamp;
CARD8 major_opcode;
CARD8 minor_opcode;
CARD16 pad B16;
CARD32 bad_length B32;
} fsLengthError;
typedef struct {
BYTE type;
BYTE request;
CARD16 sequenceNumber B16;
CARD32 length B32;
fsTimestamp timestamp;
CARD8 major_opcode;
CARD8 minor_opcode;
CARD16 pad B16;
} fsImplementationError;
/* events */
typedef struct {
BYTE type;
BYTE event_code;
CARD16 sequenceNumber B16;
CARD32 length B32;
fsTimestamp timestamp;
} fsKeepAliveEvent;
typedef struct {
BYTE type;
BYTE event_code;
CARD16 sequenceNumber B16;
CARD32 length B32;
fsTimestamp timestamp;
BOOL added;
BOOL deleted;
CARD16 pad B16;
} fsCatalogueChangeNotifyEvent;
typedef fsCatalogueChangeNotifyEvent fsFontChangeNotifyEvent;
typedef fsCatalogueChangeNotifyEvent fsEvent;
/* reply codes */
#define FS_Reply 0 /* normal reply */
#define FS_Error 1 /* error */
#define FS_Event 2
/* request codes */
#define FS_Noop 0
#define FS_ListExtensions 1
#define FS_QueryExtension 2
#define FS_ListCatalogues 3
#define FS_SetCatalogues 4
#define FS_GetCatalogues 5
#define FS_SetEventMask 6
#define FS_GetEventMask 7
#define FS_CreateAC 8
#define FS_FreeAC 9
#define FS_SetAuthorization 10
#define FS_SetResolution 11
#define FS_GetResolution 12
#define FS_ListFonts 13
#define FS_ListFontsWithXInfo 14
#define FS_OpenBitmapFont 15
#define FS_QueryXInfo 16
#define FS_QueryXExtents8 17
#define FS_QueryXExtents16 18
#define FS_QueryXBitmaps8 19
#define FS_QueryXBitmaps16 20
#define FS_CloseFont 21
/* restore decls */
#undef Mask
#undef Font
#undef AccContext
#endif /* _FS_PROTO_H_ */

168
X11/fonts/font.h Normal file
View file

@ -0,0 +1,168 @@
/***********************************************************
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Digital not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
#ifndef FONT_H
#define FONT_H
#include <X11/Xfuncproto.h>
#ifndef BitmapFormatByteOrderMask
#include "fsmasks.h"
#endif
/* data structures */
#ifndef _XTYPEDEF_FONTPTR
typedef struct _Font *FontPtr;
#define _XTYPEDEF_FONTPTR
#endif
typedef struct _FontInfo *FontInfoPtr;
typedef struct _FontProp *FontPropPtr;
typedef struct _ExtentInfo *ExtentInfoPtr;
typedef struct _FontPathElement *FontPathElementPtr;
#ifndef _XTYPEDEF_CHARINFOPTR
typedef struct _CharInfo *CharInfoPtr;
#define _XTYPEDEF_CHARINFOPTR
#endif
typedef struct _FontNames *FontNamesPtr;
typedef struct _FontResolution *FontResolutionPtr;
#define NullCharInfo ((CharInfoPtr) 0)
#define NullFont ((FontPtr) 0)
#define NullFontInfo ((FontInfoPtr) 0)
/* draw direction */
#define LeftToRight 0
#define RightToLeft 1
#define BottomToTop 2
#define TopToBottom 3
typedef int DrawDirection;
#define NO_SUCH_CHAR -1
#define FontAliasType 0x1000
#define AllocError 80
#define StillWorking 81
#define FontNameAlias 82
#define BadFontName 83
#define Suspended 84
#define Successful 85
#define BadFontPath 86
#define BadCharRange 87
#define BadFontFormat 88
#define FPEResetFailed 89 /* for when an FPE reset won't work */
/* OpenFont flags */
#define FontLoadInfo 0x0001
#define FontLoadProps 0x0002
#define FontLoadMetrics 0x0004
#define FontLoadBitmaps 0x0008
#define FontLoadAll 0x000f
#define FontOpenSync 0x0010
#define FontReopen 0x0020
/* Query flags */
#define LoadAll 0x1
#define FinishRamge 0x2
#define EightBitFont 0x4
#define SixteenBitFont 0x8
/* Glyph Caching Modes */
#define CACHING_OFF 0
#define CACHE_16_BIT_GLYPHS 1
#define CACHE_ALL_GLYPHS 2
#define DEFAULT_GLYPH_CACHING_MODE CACHE_16_BIT_GLYPHS
extern int glyphCachingMode;
struct _Client;
extern int StartListFontsWithInfo(
struct _Client * /*client*/,
int /*length*/,
unsigned char * /*pattern*/,
int /*max_names*/
);
extern FontNamesPtr MakeFontNamesRecord(
unsigned /* size */
);
extern void FreeFontNames(
FontNamesPtr /* pFN*/
);
extern int AddFontNamesName(
FontNamesPtr /* names */,
char * /* name */,
int /* length */
);
#if 0 /* unused */
extern int FontToFSError();
extern FontResolutionPtr GetClientResolution();
#endif
typedef struct _FontPatternCache *FontPatternCachePtr;
extern FontPatternCachePtr MakeFontPatternCache (
void
);
extern void FreeFontPatternCache (
FontPatternCachePtr /* cache */
);
extern void EmptyFontPatternCache (
FontPatternCachePtr /* cache */
);
extern void CacheFontPattern (
FontPatternCachePtr /* cache */,
const char * /* pattern */,
int /* patlen */,
FontPtr /* pFont */
);
extern _X_EXPORT FontResolutionPtr GetClientResolutions(
int * /* num */
);
extern FontPtr FindCachedFontPattern (
FontPatternCachePtr /* cache */,
const char * /* pattern */,
int /* patlen */
);
extern void RemoveCachedFontPattern (
FontPatternCachePtr /* cache */,
FontPtr /* pFont */
);
typedef enum {
Linear8Bit, TwoD8Bit, Linear16Bit, TwoD16Bit
} FontEncoding;
#endif /* FONT_H */

94
X11/fonts/fontproto.h Normal file
View file

@ -0,0 +1,94 @@
/***********************************************************
Copyright (c) 1999 The XFree86 Project Inc.
All Rights Reserved.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The XFree86 Project
Inc. shall not be used in advertising or otherwise to promote the
sale, use or other dealings in this Software without prior written
authorization from The XFree86 Project Inc..
*/
#ifndef _FONTPROTO_H
#define _FONTPROTO_H
#include <X11/Xfuncproto.h>
/* Externally provided functions required by libXfont */
extern _X_EXPORT int RegisterFPEFunctions (
NameCheckFunc name_func,
InitFpeFunc init_func,
FreeFpeFunc free_func,
ResetFpeFunc reset_func,
OpenFontFunc open_func,
CloseFontFunc close_func,
ListFontsFunc list_func,
StartLfwiFunc start_lfwi_func,
NextLfwiFunc next_lfwi_func,
WakeupFpeFunc wakeup_func,
ClientDiedFunc client_died,
LoadGlyphsFunc load_glyphs,
StartLaFunc start_list_alias_func,
NextLaFunc next_list_alias_func,
SetPathFunc set_path_func);
extern _X_EXPORT int GetDefaultPointSize ( void );
extern _X_EXPORT int init_fs_handlers ( FontPathElementPtr fpe,
BlockHandlerProcPtr block_handler);
extern _X_EXPORT void remove_fs_handlers ( FontPathElementPtr fpe,
BlockHandlerProcPtr block_handler,
Bool all );
extern _X_EXPORT int client_auth_generation ( ClientPtr client );
#ifndef ___CLIENTSIGNAL_DEFINED___
#define ___CLIENTSIGNAL_DEFINED___
extern Bool ClientSignal ( ClientPtr client );
#endif /* ___CLIENTSIGNAL_DEFINED___ */
extern _X_EXPORT void DeleteFontClientID ( Font id );
extern _X_EXPORT Font GetNewFontClientID ( void );
extern _X_EXPORT int StoreFontClientFont ( FontPtr pfont, Font id );
extern _X_EXPORT void FontFileRegisterFpeFunctions ( void );
extern _X_EXPORT void FontFileCheckRegisterFpeFunctions ( void );
extern Bool XpClientIsBitmapClient ( ClientPtr client );
extern Bool XpClientIsPrintClient( ClientPtr client, FontPathElementPtr fpe );
extern void PrinterFontRegisterFpeFunctions ( void );
extern void fs_register_fpe_functions ( void );
extern void check_fs_register_fpe_functions ( void );
/* util/private.c */
extern FontPtr CreateFontRec (void);
extern void DestroyFontRec (FontPtr font);
extern Bool _FontSetNewPrivate (FontPtr /* pFont */,
int /* n */,
void * /* ptr */);
extern int AllocateFontPrivateIndex (void);
extern void ResetFontPrivateIndex (void);
/* Type1/t1funcs.c */
extern void Type1RegisterFontFileFunctions(void);
extern void CIDRegisterFontFileFunctions(void);
/* Speedo/spfuncs.c */
extern void SpeedoRegisterFontFileFunctions(void);
/* FreeType/ftfuncs.c */
extern void FreeTypeRegisterFontFileFunctions(void);
#endif

297
X11/fonts/fontstruct.h Normal file
View file

@ -0,0 +1,297 @@
/***********************************************************
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Digital not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
#ifndef FONTSTR_H
#define FONTSTR_H
#include <X11/Xproto.h>
#include "font.h"
#include <X11/Xfuncproto.h>
#include <X11/Xdefs.h>
/*
* This version of the server font data strucutre is only for describing
* the in memory data structure. The file structure is not necessarily a
* copy of this. That is up to the compiler and the OS layer font loading
* machinery.
*/
#define GLYPHPADOPTIONS 4 /* 1, 2, 4, or 8 */
typedef struct _FontProp {
long name;
long value; /* assumes ATOM is not larger than INT32 */
} FontPropRec;
typedef struct _FontResolution {
unsigned short x_resolution;
unsigned short y_resolution;
unsigned short point_size;
} FontResolutionRec;
typedef struct _ExtentInfo {
DrawDirection drawDirection;
int fontAscent;
int fontDescent;
int overallAscent;
int overallDescent;
int overallWidth;
int overallLeft;
int overallRight;
} ExtentInfoRec;
typedef struct _CharInfo {
xCharInfo metrics; /* info preformatted for Queries */
char *bits; /* pointer to glyph image */
} CharInfoRec;
/*
* Font is created at font load time. It is specific to a single encoding.
* e.g. not all of the glyphs in a font may be part of a single encoding.
*/
typedef struct _FontInfo {
unsigned short firstCol;
unsigned short lastCol;
unsigned short firstRow;
unsigned short lastRow;
unsigned short defaultCh;
unsigned int noOverlap:1;
unsigned int terminalFont:1;
unsigned int constantMetrics:1;
unsigned int constantWidth:1;
unsigned int inkInside:1;
unsigned int inkMetrics:1;
unsigned int allExist:1;
unsigned int drawDirection:2;
unsigned int cachable:1;
unsigned int anamorphic:1;
short maxOverlap;
short pad;
xCharInfo maxbounds;
xCharInfo minbounds;
xCharInfo ink_maxbounds;
xCharInfo ink_minbounds;
short fontAscent;
short fontDescent;
int nprops;
FontPropPtr props;
char *isStringProp;
} FontInfoRec;
typedef struct _Font {
int refcnt;
FontInfoRec info;
char bit;
char byte;
char glyph;
char scan;
fsBitmapFormat format;
int (*get_glyphs) (FontPtr /* font */,
unsigned long /* count */,
unsigned char * /* chars */,
FontEncoding /* encoding */,
unsigned long * /* count */,
CharInfoPtr * /* glyphs */);
int (*get_metrics) (FontPtr /* font */,
unsigned long /* count */,
unsigned char * /* chars */,
FontEncoding /* encoding */,
unsigned long * /* count */,
xCharInfo ** /* glyphs */);
void (*unload_font) (FontPtr /* font */);
void (*unload_glyphs) (FontPtr /* font */);
FontPathElementPtr fpe;
void *svrPrivate;
void *fontPrivate;
void *fpePrivate;
int maxPrivate;
void **devPrivates;
} FontRec;
#define FontGetPrivate(pFont,n) ((n) > (pFont)->maxPrivate ? (void *) 0 : \
(pFont)->devPrivates[n])
#define FontSetPrivate(pFont,n,ptr) ((n) > (pFont)->maxPrivate ? \
_FontSetNewPrivate (pFont, n, ptr) : \
((((pFont)->devPrivates[n] = (ptr)) != 0) || TRUE))
typedef struct _FontNames {
int nnames;
int size;
int *length;
char **names;
} FontNamesRec;
/* External view of font paths */
typedef struct _FontPathElement {
int name_length;
#if FONT_PATH_ELEMENT_NAME_CONST
const
#endif
char *name;
int type;
int refcount;
void *private;
} FontPathElementRec;
typedef Bool (*NameCheckFunc) (const char *name);
typedef int (*InitFpeFunc) (FontPathElementPtr fpe);
typedef int (*FreeFpeFunc) (FontPathElementPtr fpe);
typedef int (*ResetFpeFunc) (FontPathElementPtr fpe);
typedef int (*OpenFontFunc) ( void *client,
FontPathElementPtr fpe,
Mask flags,
const char* name,
int namelen,
fsBitmapFormat format,
fsBitmapFormatMask fmask,
XID id,
FontPtr* pFont,
char** aliasName,
FontPtr non_cachable_font);
typedef void (*CloseFontFunc) (FontPathElementPtr fpe, FontPtr pFont);
typedef int (*ListFontsFunc) (void *client,
FontPathElementPtr fpe,
const char* pat,
int len,
int max,
FontNamesPtr names);
typedef int (*StartLfwiFunc) (void *client,
FontPathElementPtr fpe,
const char* pat,
int len,
int max,
void ** privatep);
typedef int (*NextLfwiFunc) (void *client,
FontPathElementPtr fpe,
char** name,
int* namelen,
FontInfoPtr* info,
int* numFonts,
void *private);
typedef int (*WakeupFpeFunc) (FontPathElementPtr fpe,
unsigned long* LastSelectMask);
typedef void (*ClientDiedFunc) (void *client,
FontPathElementPtr fpe);
typedef int (*LoadGlyphsFunc) (void *client,
FontPtr pfont,
Bool range_flag,
unsigned int nchars,
int item_size,
unsigned char* data);
typedef int (*StartLaFunc) (void *client,
FontPathElementPtr fpe,
const char* pat,
int len,
int max,
void ** privatep);
typedef int (*NextLaFunc) (void *client,
FontPathElementPtr fpe,
char** namep,
int* namelenp,
char** resolvedp,
int* resolvedlenp,
void *private);
typedef void (*SetPathFunc)(void);
typedef struct _FPEFunctions {
NameCheckFunc name_check;
InitFpeFunc init_fpe;
ResetFpeFunc reset_fpe;
FreeFpeFunc free_fpe;
OpenFontFunc open_font;
CloseFontFunc close_font;
ListFontsFunc list_fonts;
StartLaFunc start_list_fonts_and_aliases;
NextLaFunc list_next_font_or_alias;
StartLfwiFunc start_list_fonts_with_info;
NextLfwiFunc list_next_font_with_info;
WakeupFpeFunc wakeup_fpe;
ClientDiedFunc client_died;
/* for load_glyphs, range_flag = 0 ->
nchars = # of characters in data
item_size = bytes/char
data = list of characters
range_flag = 1 ->
nchars = # of fsChar2b's in data
item_size is ignored
data = list of fsChar2b's */
LoadGlyphsFunc load_glyphs;
SetPathFunc set_path_hook;
} FPEFunctionsRec, FPEFunctions;
/*
* Various macros for computing values based on contents of
* the above structures
*/
#define GLYPHWIDTHPIXELS(pci) \
((pci)->metrics.rightSideBearing - (pci)->metrics.leftSideBearing)
#define GLYPHHEIGHTPIXELS(pci) \
((pci)->metrics.ascent + (pci)->metrics.descent)
#define GLYPHWIDTHBYTES(pci) (((GLYPHWIDTHPIXELS(pci))+7) >> 3)
#define GLYPHWIDTHPADDED(bc) (((bc)+7) & ~0x7)
#define BYTES_PER_ROW(bits, nbytes) \
((nbytes) == 1 ? (((bits)+7)>>3) /* pad to 1 byte */ \
:(nbytes) == 2 ? ((((bits)+15)>>3)&~1) /* pad to 2 bytes */ \
:(nbytes) == 4 ? ((((bits)+31)>>3)&~3) /* pad to 4 bytes */ \
:(nbytes) == 8 ? ((((bits)+63)>>3)&~7) /* pad to 8 bytes */ \
: 0)
#define BYTES_FOR_GLYPH(ci,pad) (GLYPHHEIGHTPIXELS(ci) * \
BYTES_PER_ROW(GLYPHWIDTHPIXELS(ci),pad))
/*
* Macros for computing different bounding boxes for fonts; from
* the font protocol
*/
#define FONT_MAX_ASCENT(pi) ((pi)->fontAscent > (pi)->ink_maxbounds.ascent ? \
(pi)->fontAscent : (pi)->ink_maxbounds.ascent)
#define FONT_MAX_DESCENT(pi) ((pi)->fontDescent > (pi)->ink_maxbounds.descent ? \
(pi)->fontDescent : (pi)->ink_maxbounds.descent)
#define FONT_MAX_HEIGHT(pi) (FONT_MAX_ASCENT(pi) + FONT_MAX_DESCENT(pi))
#define FONT_MIN_LEFT(pi) ((pi)->ink_minbounds.leftSideBearing < 0 ? \
(pi)->ink_minbounds.leftSideBearing : 0)
#define FONT_MAX_RIGHT(pi) ((pi)->ink_maxbounds.rightSideBearing > \
(pi)->ink_maxbounds.characterWidth ? \
(pi)->ink_maxbounds.rightSideBearing : \
(pi)->ink_maxbounds.characterWidth)
#define FONT_MAX_WIDTH(pi) (FONT_MAX_RIGHT(pi) - FONT_MIN_LEFT(pi))
#include "fontproto.h"
#endif /* FONTSTR_H */

97
X11/fonts/fsmasks.h Normal file
View file

@ -0,0 +1,97 @@
/*
* Copyright 1990, 1991 Network Computing Devices;
* Portions Copyright 1987 by Digital Equipment Corporation
*
* Permission to use, copy, modify, distribute, and sell this software and
* its documentation for any purpose is hereby granted without fee, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the names of Network Computing Devices or Digital
* not be used in advertising or publicity pertaining to distribution
* of the software without specific, written prior permission.
* Network Computing Devices and Digital make no representations
* about the suitability of this software for any purpose. It is provided
* "as is" without express or implied warranty.
*
* NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES
* OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
* THIS SOFTWARE.
*/
/*
Portions Copyright 1987, 1994, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
/*
* masks & values used by the font lib and the font server
*/
#ifndef _FSMASKS_H_
#define _FSMASKS_H_
#include <X11/Xmd.h>
/* font format macros */
#define BitmapFormatByteOrderMask (1L << 0)
#define BitmapFormatBitOrderMask (1L << 1)
#define BitmapFormatImageRectMask (3L << 2)
#define BitmapFormatScanlinePadMask (3L << 8)
#define BitmapFormatScanlineUnitMask (3L << 12)
#define BitmapFormatByteOrderLSB (0)
#define BitmapFormatByteOrderMSB (1L << 0)
#define BitmapFormatBitOrderLSB (0)
#define BitmapFormatBitOrderMSB (1L << 1)
#define BitmapFormatImageRectMin (0L << 2)
#define BitmapFormatImageRectMaxWidth (1L << 2)
#define BitmapFormatImageRectMax (2L << 2)
#define BitmapFormatScanlinePad8 (0L << 8)
#define BitmapFormatScanlinePad16 (1L << 8)
#define BitmapFormatScanlinePad32 (2L << 8)
#define BitmapFormatScanlinePad64 (3L << 8)
#define BitmapFormatScanlineUnit8 (0L << 12)
#define BitmapFormatScanlineUnit16 (1L << 12)
#define BitmapFormatScanlineUnit32 (2L << 12)
#define BitmapFormatScanlineUnit64 (3L << 12)
#define BitmapFormatMaskByte (1L << 0)
#define BitmapFormatMaskBit (1L << 1)
#define BitmapFormatMaskImageRectangle (1L << 2)
#define BitmapFormatMaskScanLinePad (1L << 3)
#define BitmapFormatMaskScanLineUnit (1L << 4)
typedef CARD32 fsBitmapFormat;
typedef CARD32 fsBitmapFormatMask;
#endif /* _FSMASKS_H_ */

238
atom.c Normal file
View file

@ -0,0 +1,238 @@
/*
Copyright 1990, 1994, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
/*
* Author: Keith Packard, MIT X Consortium
*/
/* lame atom replacement routines for font applications */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "fontmisc.h"
#include "stubs.h"
typedef struct _AtomList {
char *name;
int len;
int hash;
Atom atom;
} AtomListRec, *AtomListPtr;
static AtomListPtr *hashTable;
static int hashSize, hashUsed;
static int hashMask;
static int rehash;
static AtomListPtr *reverseMap;
static int reverseMapSize;
static Atom lastAtom;
static int
Hash(const char *string, int len)
{
int h;
h = 0;
while (len--)
h = (h << 3) ^ *string++;
if (h < 0)
return -h;
return h;
}
static int
ResizeHashTable (void)
{
int newHashSize;
int newHashMask;
AtomListPtr *newHashTable;
int i;
int h;
int newRehash;
int r;
if (hashSize == 0)
newHashSize = 1024;
else
newHashSize = hashSize * 2;
newHashTable = calloc (newHashSize, sizeof (AtomListPtr));
if (!newHashTable) {
fprintf(stderr, "ResizeHashTable(): Error: Couldn't allocate"
" newHashTable (%ld)\n",
newHashSize * (unsigned long)sizeof (AtomListPtr));
return FALSE;
}
newHashMask = newHashSize - 1;
newRehash = (newHashMask - 2);
for (i = 0; i < hashSize; i++)
{
if (hashTable[i])
{
h = (hashTable[i]->hash) & newHashMask;
if (newHashTable[h])
{
r = hashTable[i]->hash % newRehash | 1;
do {
h += r;
if (h >= newHashSize)
h -= newHashSize;
} while (newHashTable[h]);
}
newHashTable[h] = hashTable[i];
}
}
free (hashTable);
hashTable = newHashTable;
hashSize = newHashSize;
hashMask = newHashMask;
rehash = newRehash;
return TRUE;
}
static int
ResizeReverseMap (void)
{
AtomListPtr *newMap;
int newMapSize;
if (reverseMapSize == 0)
newMapSize = 1000;
else
newMapSize = reverseMapSize * 2;
newMap = realloc (reverseMap, newMapSize * sizeof (AtomListPtr));
if (newMap == NULL) {
fprintf(stderr, "ResizeReverseMap(): Error: Couldn't reallocate"
" reverseMap (%ld)\n",
newMapSize * (unsigned long)sizeof(AtomListPtr));
return FALSE;
}
reverseMap = newMap;
reverseMapSize = newMapSize;
return TRUE;
}
static int
NameEqual (const char *a, const char *b, int l)
{
while (l--)
if (*a++ != *b++)
return FALSE;
return TRUE;
}
Atom
MakeAtom(const char *string, unsigned len, int makeit)
{
AtomListPtr a;
int hash;
int h = 0;
int r;
OVERRIDE_SYMBOL(MakeAtom, string, len, makeit);
hash = Hash (string, len);
if (hashTable)
{
h = hash & hashMask;
if (hashTable[h])
{
if (hashTable[h]->hash == hash && hashTable[h]->len == len &&
NameEqual (hashTable[h]->name, string, len))
{
return hashTable[h]->atom;
}
r = (hash % rehash) | 1;
for (;;)
{
h += r;
if (h >= hashSize)
h -= hashSize;
if (!hashTable[h])
break;
if (hashTable[h]->hash == hash && hashTable[h]->len == len &&
NameEqual (hashTable[h]->name, string, len))
{
return hashTable[h]->atom;
}
}
}
}
if (!makeit)
return None;
a = malloc (sizeof (AtomListRec) + len + 1);
if (a == NULL) {
fprintf(stderr, "MakeAtom(): Error: Couldn't allocate AtomListRec"
" (%ld)\n", (unsigned long)sizeof (AtomListRec) + len + 1);
return None;
}
a->name = (char *) (a + 1);
a->len = len;
strncpy (a->name, string, len);
a->name[len] = '\0';
a->atom = ++lastAtom;
a->hash = hash;
if (hashUsed >= hashSize / 2)
{
ResizeHashTable ();
h = hash & hashMask;
if (hashTable[h])
{
r = (hash % rehash) | 1;
do {
h += r;
if (h >= hashSize)
h -= hashSize;
} while (hashTable[h]);
}
}
hashTable[h] = a;
hashUsed++;
if (reverseMapSize <= a->atom) {
if (!ResizeReverseMap())
return None;
}
reverseMap[a->atom] = a;
return a->atom;
}
int
ValidAtom(Atom atom)
{
OVERRIDE_SYMBOL(ValidAtom, atom);
return (atom != None) && (atom <= lastAtom);
}
char *
NameForAtom(Atom atom)
{
OVERRIDE_SYMBOL(NameForAtom, atom);
if (atom != None && atom <= lastAtom)
return reverseMap[atom]->name;
return NULL;
}

89
bdfint.h Normal file
View file

@ -0,0 +1,89 @@
/*
Copyright 1990, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from The Open Group.
*/
#ifndef BDFINT_H
#define BDFINT_H
#define bdfIsPrefix(buf,str) (!strncmp((char *)buf,str,strlen(str)))
#define bdfStrEqual(s1,s2) (!strcmp(s1,s2))
#define BDF_GENPROPS 6
#define NullProperty ((FontPropPtr)0)
/*
* This structure holds some properties we need to generate if they aren't
* specified in the BDF file and some other values read from the file
* that we'll need to calculate them. We need to keep track of whether
* or not we've read them.
*/
typedef struct BDFSTAT {
int linenum;
char *fileName;
char fontName[MAXFONTNAMELEN];
float pointSize;
int resolution_x;
int resolution_y;
int digitCount;
int digitWidths;
int exHeight;
int sWidthDefault;
int dWidthDefault;
FontPropPtr fontProp;
FontPropPtr pointSizeProp;
FontPropPtr resolutionXProp;
FontPropPtr resolutionYProp;
FontPropPtr resolutionProp;
FontPropPtr xHeightProp;
FontPropPtr weightProp;
FontPropPtr quadWidthProp;
BOOL haveFontAscent;
BOOL haveFontDescent;
BOOL haveDefaultCh;
} bdfFileState;
extern void bdfError ( const char * message, ... ) _X_ATTRIBUTE_PRINTF(1, 2);
extern void bdfWarning ( const char *message, ... ) _X_ATTRIBUTE_PRINTF(1, 2);
extern unsigned char * bdfGetLine ( FontFilePtr file, unsigned char *buf,
int len );
extern Atom bdfForceMakeAtom ( const char *str, int *size );
extern Atom bdfGetPropertyValue ( char *s );
extern int bdfIsInteger ( char *str );
extern unsigned char bdfHexByte ( unsigned char *s );
extern Bool bdfSpecialProperty ( FontPtr pFont, FontPropPtr prop,
char isString, bdfFileState *bdfState );
extern int bdfReadFont( FontPtr pFont, FontFilePtr file,
int bit, int byte, int glyph, int scan );
extern int bdfReadFontInfo( FontInfoPtr pFontInfo, FontFilePtr file );
extern void FontCharInkMetrics ( FontPtr pFont, CharInfoPtr pCI,
xCharInfo *pInk );
extern void FontCharReshape ( FontPtr pFont, CharInfoPtr pSrc,
CharInfoPtr pDst );
#endif /* BDFINT_H */

1033
bdfread.c Normal file

File diff suppressed because it is too large Load diff

94
bdftopcf.c Normal file
View file

@ -0,0 +1,94 @@
/*
Copyright 1991, 1993, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from The Open Group.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <X11/X.h>
#include <X11/Xproto.h>
#include "fontmisc.h"
#include <X11/fonts/fontstruct.h>
#include "fntfilio.h"
#include "fntfil.h"
#include "bdfint.h"
#include "pcf.h"
#include <stdio.h>
#include <X11/Xos.h>
#include <emscripten.h>
int
main(int argc, char *argv[])
{
}
EMSCRIPTEN_KEEPALIVE
int font_convert() {
const char *input_name = "/input.bdf", *output_name="/output.pcf";
FontRec font = { 0 };
FontFilePtr input = NULL, output = NULL;
int bit, byte, glyph, scan;
FontDefaultFormat(&bit, &byte, &glyph, &scan);
input = FontFileOpen(input_name);
output = FontFileOpenWrite(output_name);
int result = Successful;
if (!input) {
fprintf(stderr, "can't open bdf source file %s\n",
input_name); fflush(stderr);
result = 0;
}
if (!output) {
fprintf(stderr, "can't open pcf sink file %s\n",
output_name); fflush(stderr);
result = 0;
}
if (result == Successful) {
fprintf(stderr, "reading input font\n");
result = bdfReadFont(&font, input, bit, byte, glyph, scan);
if (result != Successful) {
fprintf(stderr, "bdf input, corrupt\n");
}
}
if (result == Successful) {
fprintf(stderr, "preparing output font\n"); fflush(stderr);
result = pcfWriteFont(&font, output);
if (result != Successful) {
fprintf(stderr, "can't write pcf file %s\n", output_name); fflush(stderr);
remove(output_name);
}
}
if (input)
FontFileClose(input);
if (output)
FontFileClose(output);
return (result == Successful);
}

337
bdfutils.c Normal file
View file

@ -0,0 +1,337 @@
/************************************************************************
Copyright 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Digital not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
************************************************************************/
/*
Copyright 1994, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from The Open Group.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
#include "fntfilst.h"
#include <X11/fonts/fontstruct.h>
/* use bitmap structure */
#include "bitmap.h"
#include "bdfint.h"
int bdfFileLineNum;
/***====================================================================***/
void
bdfError(const char* message, ...)
{
va_list args;
va_start (args, message);
fprintf(stderr, "BDF Error on line %d: ", bdfFileLineNum);
vfprintf(stderr, message, args);
va_end (args);
}
/***====================================================================***/
void
bdfWarning(const char *message, ...)
{
va_list args;
va_start (args, message);
fprintf(stderr, "BDF Warning on line %d: ", bdfFileLineNum);
vfprintf(stderr, message, args);
va_end (args);
}
/*
* read the next (non-comment) line and keep a count for error messages.
* Returns buf, or NULL if EOF.
*/
unsigned char *
bdfGetLine(FontFilePtr file, unsigned char *buf, int len)
{
int c;
unsigned char *b;
for (;;) {
b = buf;
while ((c = FontFileGetc(file)) != FontFileEOF) {
if (c == '\r')
continue;
if (c == '\n') {
bdfFileLineNum++;
break;
}
if (b - buf >= (len - 1))
break;
*b++ = c;
}
*b = '\0';
if (c == FontFileEOF)
return NULL;
if (b != buf && !bdfIsPrefix(buf, "COMMENT"))
break;
}
return buf;
}
/***====================================================================***/
Atom
bdfForceMakeAtom(const char *str, int *size)
{
register int len = strlen(str);
Atom the_atom;
if (size != NULL)
*size += len + 1;
the_atom = MakeAtom(str, len, TRUE);
if (the_atom == None)
bdfError("Atom allocation failed\n");
return the_atom;
}
/***====================================================================***/
/*
* Handle quoted strings.
*/
Atom
bdfGetPropertyValue(char *s)
{
register char *p,
*pp;
char *orig_s = s;
Atom atom;
/* strip leading white space */
while (*s && (*s == ' ' || *s == '\t'))
s++;
if (*s == 0) {
return bdfForceMakeAtom(s, NULL);
}
if (*s != '"') {
pp = s;
/* no white space in value */
for (pp = s; *pp; pp++)
if (*pp == ' ' || *pp == '\t' || *pp == '\015' || *pp == '\n') {
*pp = 0;
break;
}
return bdfForceMakeAtom(s, NULL);
}
/* quoted string: strip outer quotes and undouble inner quotes */
s++;
pp = p = malloc((unsigned) strlen(s) + 1);
if (pp == NULL) {
bdfError("Couldn't allocate property value string (%d)\n",
(int) strlen(s) + 1);
return None;
}
while (*s) {
if (*s == '"') {
if (*(s + 1) != '"') {
*p++ = 0;
atom = bdfForceMakeAtom(pp, NULL);
free(pp);
return atom;
} else {
s++;
}
}
*p++ = *s++;
}
free (pp);
bdfError("unterminated quoted string property: %s\n", orig_s);
return None;
}
/***====================================================================***/
/*
* return TRUE if string is a valid integer
*/
int
bdfIsInteger(char *str)
{
char c;
c = *str++;
if (!(isdigit((unsigned char)c) || c == '-' || c == '+'))
return (FALSE);
while ((c = *str++))
if (!isdigit((unsigned char)c))
return (FALSE);
return (TRUE);
}
/***====================================================================***/
/*
* make a byte from the first two hex characters in glyph picture
*/
unsigned char
bdfHexByte(unsigned char *s)
{
unsigned char b = 0;
register char c;
int i;
for (i = 2; i; i--) {
c = *s++;
if ((c >= '0') && (c <= '9'))
b = (b << 4) + (c - '0');
else if ((c >= 'A') && (c <= 'F'))
b = (b << 4) + 10 + (c - 'A');
else if ((c >= 'a') && (c <= 'f'))
b = (b << 4) + 10 + (c - 'a');
else
bdfError("bad hex char '%c'", c);
}
return b;
}
/***====================================================================***/
/*
* check for known special property values
*/
static const char *SpecialAtoms[] = {
"FONT_ASCENT",
#define BDF_FONT_ASCENT 0
"FONT_DESCENT",
#define BDF_FONT_DESCENT 1
"DEFAULT_CHAR",
#define BDF_DEFAULT_CHAR 2
"POINT_SIZE",
#define BDF_POINT_SIZE 3
"RESOLUTION",
#define BDF_RESOLUTION 4
"X_HEIGHT",
#define BDF_X_HEIGHT 5
"WEIGHT",
#define BDF_WEIGHT 6
"QUAD_WIDTH",
#define BDF_QUAD_WIDTH 7
"FONT",
#define BDF_FONT 8
"RESOLUTION_X",
#define BDF_RESOLUTION_X 9
"RESOLUTION_Y",
#define BDF_RESOLUTION_Y 10
0,
};
Bool
bdfSpecialProperty(FontPtr pFont, FontPropPtr prop,
char isString, bdfFileState *bdfState)
{
const char **special;
const char *name;
name = NameForAtom(prop->name);
for (special = SpecialAtoms; *special; special++)
if (!strcmp(name, *special))
break;
switch (special - SpecialAtoms) {
case BDF_FONT_ASCENT:
if (!isString) {
pFont->info.fontAscent = prop->value;
bdfState->haveFontAscent = TRUE;
}
return TRUE;
case BDF_FONT_DESCENT:
if (!isString) {
pFont->info.fontDescent = prop->value;
bdfState->haveFontDescent = TRUE;
}
return TRUE;
case BDF_DEFAULT_CHAR:
if (!isString) {
pFont->info.defaultCh = prop->value;
bdfState->haveDefaultCh = TRUE;
}
return TRUE;
case BDF_POINT_SIZE:
bdfState->pointSizeProp = prop;
return FALSE;
case BDF_RESOLUTION:
bdfState->resolutionProp = prop;
return FALSE;
case BDF_X_HEIGHT:
bdfState->xHeightProp = prop;
return FALSE;
case BDF_WEIGHT:
bdfState->weightProp = prop;
return FALSE;
case BDF_QUAD_WIDTH:
bdfState->quadWidthProp = prop;
return FALSE;
case BDF_FONT:
bdfState->fontProp = prop;
return FALSE;
case BDF_RESOLUTION_X:
bdfState->resolutionXProp = prop;
return FALSE;
case BDF_RESOLUTION_Y:
bdfState->resolutionYProp = prop;
return FALSE;
default:
return FALSE;
}
}

161
bitmap.c Normal file
View file

@ -0,0 +1,161 @@
/*
Copyright 1991, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
/*
* Author: Keith Packard, MIT X Consortium
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "fntfilst.h"
#include "bitmap.h"
int
bitmapGetGlyphs(FontPtr pFont, unsigned long count, unsigned char *chars,
FontEncoding charEncoding,
unsigned long *glyphCount, /* RETURN */
CharInfoPtr *glyphs) /* RETURN */
{
BitmapFontPtr bitmapFont;
unsigned int firstCol;
register unsigned int numCols;
unsigned int firstRow;
unsigned int numRows;
CharInfoPtr *glyphsBase;
register unsigned int c;
register CharInfoPtr pci;
unsigned int r;
CharInfoPtr **encoding;
CharInfoPtr pDefault;
bitmapFont = (BitmapFontPtr) pFont->fontPrivate;
encoding = bitmapFont->encoding;
pDefault = bitmapFont->pDefault;
firstCol = pFont->info.firstCol;
numCols = pFont->info.lastCol - firstCol + 1;
glyphsBase = glyphs;
switch (charEncoding) {
case Linear8Bit:
case TwoD8Bit:
if (pFont->info.firstRow > 0) {
if (pDefault)
while (count--)
*glyphs++ = pDefault;
break;
}
if (pFont->info.allExist && pDefault) {
while (count--) {
c = (*chars++) - firstCol;
if (c < numCols)
*glyphs++ = ACCESSENCODING(encoding,c);
else
*glyphs++ = pDefault;
}
} else {
while (count--) {
c = (*chars++) - firstCol;
if (c < numCols && (pci = ACCESSENCODING(encoding,c)))
*glyphs++ = pci;
else if (pDefault)
*glyphs++ = pDefault;
}
}
break;
case Linear16Bit:
if (pFont->info.allExist && pDefault) {
while (count--) {
c = *chars++ << 8;
c = (c | *chars++) - firstCol;
if (c < numCols)
*glyphs++ = ACCESSENCODING(encoding,c);
else
*glyphs++ = pDefault;
}
} else {
while (count--) {
c = *chars++ << 8;
c = (c | *chars++) - firstCol;
if (c < numCols && (pci = ACCESSENCODING(encoding,c)))
*glyphs++ = pci;
else if (pDefault)
*glyphs++ = pDefault;
}
}
break;
case TwoD16Bit:
firstRow = pFont->info.firstRow;
numRows = pFont->info.lastRow - firstRow + 1;
while (count--) {
r = (*chars++) - firstRow;
c = (*chars++) - firstCol;
if (r < numRows && c < numCols &&
(pci = ACCESSENCODING(encoding, r * numCols + c)))
*glyphs++ = pci;
else if (pDefault)
*glyphs++ = pDefault;
}
break;
}
*glyphCount = glyphs - glyphsBase;
return Successful;
}
static CharInfoRec nonExistantChar;
int
bitmapGetMetrics(FontPtr pFont, unsigned long count, unsigned char *chars,
FontEncoding charEncoding,
unsigned long *glyphCount, /* RETURN */
xCharInfo **glyphs) /* RETURN */
{
int ret;
xCharInfo *ink_metrics;
CharInfoPtr metrics;
BitmapFontPtr bitmapFont;
CharInfoPtr oldDefault;
int i;
bitmapFont = (BitmapFontPtr) pFont->fontPrivate;
oldDefault = bitmapFont->pDefault;
bitmapFont->pDefault = &nonExistantChar;
ret = bitmapGetGlyphs(pFont, count, chars, charEncoding, glyphCount, (CharInfoPtr *) glyphs);
if (ret == Successful) {
if (bitmapFont->ink_metrics) {
metrics = bitmapFont->metrics;
ink_metrics = bitmapFont->ink_metrics;
for (i = 0; i < *glyphCount; i++) {
if (glyphs[i] != (xCharInfo *) & nonExistantChar)
glyphs[i] = ink_metrics + (((CharInfoPtr) glyphs[i]) - metrics);
}
}
}
bitmapFont->pDefault = oldDefault;
return ret;
}

101
bitmap.h Normal file
View file

@ -0,0 +1,101 @@
/*
Copyright 1990, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from The Open Group.
*/
/*
* Author: Keith Packard, MIT X Consortium
*/
#ifndef _BITMAP_H_
#define _BITMAP_H_
#include "fntfilio.h"
#include <stdio.h> /* just for NULL */
/*
* Internal format used to store bitmap fonts
*/
/* number of encoding entries in one segment */
#define BITMAP_FONT_SEGMENT_SIZE 128
typedef struct _BitmapExtra {
Atom *glyphNames;
int *sWidths;
CARD32 bitmapsSizes[GLYPHPADOPTIONS];
FontInfoRec info;
} BitmapExtraRec, *BitmapExtraPtr;
typedef struct _BitmapFont {
unsigned version_num;
int num_chars;
int num_tables;
CharInfoPtr metrics; /* font metrics, including glyph pointers */
xCharInfo *ink_metrics; /* ink metrics */
char *bitmaps; /* base of bitmaps, useful only to free */
CharInfoPtr **encoding; /* array of arrays of char info pointers */
CharInfoPtr pDefault; /* default character */
BitmapExtraPtr bitmapExtra; /* stuff not used by X server */
} BitmapFontRec, *BitmapFontPtr;
#define ACCESSENCODING(enc,i) \
(enc[(i)/BITMAP_FONT_SEGMENT_SIZE]?\
(enc[(i)/BITMAP_FONT_SEGMENT_SIZE][(i)%BITMAP_FONT_SEGMENT_SIZE]):\
0)
#define ACCESSENCODINGL(enc,i) \
(enc[(i)/BITMAP_FONT_SEGMENT_SIZE][(i)%BITMAP_FONT_SEGMENT_SIZE])
#define SEGMENT_MAJOR(n) ((n)/BITMAP_FONT_SEGMENT_SIZE)
#define SEGMENT_MINOR(n) ((n)%BITMAP_FONT_SEGMENT_SIZE)
#define NUM_SEGMENTS(n) \
(((n)+BITMAP_FONT_SEGMENT_SIZE-1)/BITMAP_FONT_SEGMENT_SIZE)
extern int bitmapGetGlyphs ( FontPtr pFont, unsigned long count,
unsigned char *chars, FontEncoding charEncoding,
unsigned long *glyphCount, CharInfoPtr *glyphs );
extern int bitmapGetMetrics ( FontPtr pFont, unsigned long count,
unsigned char *chars, FontEncoding charEncoding,
unsigned long *glyphCount, xCharInfo **glyphs );
extern void bitmapComputeFontBounds ( FontPtr pFont );
extern void bitmapComputeFontInkBounds ( FontPtr pFont );
extern Bool bitmapAddInkMetrics ( FontPtr pFont );
extern int bitmapComputeWeight ( FontPtr pFont );
extern void BitmapRegisterFontFileFunctions ( void );
extern int BitmapOpenScalable ( FontPathElementPtr fpe, FontPtr *pFont,
int flags, FontEntryPtr entry, char *fileName,
FontScalablePtr vals, fsBitmapFormat format,
fsBitmapFormatMask fmask,
FontPtr non_cachable_font );
extern int BitmapGetInfoScalable ( FontPathElementPtr fpe,
FontInfoPtr pFontInfo, FontEntryPtr entry,
FontNamePtr fontName, char *fileName,
FontScalablePtr vals );
#endif /* _BITMAP_H_ */

229
bitmaputil.c Normal file
View file

@ -0,0 +1,229 @@
/*
Copyright 1990, 1994, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from The Open Group.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "fntfilst.h"
#include "bitmap.h"
#include "bdfint.h"
#ifndef MAXSHORT
#define MAXSHORT 32767
#endif
#ifndef MINSHORT
#define MINSHORT -32768
#endif
static xCharInfo initMinMetrics = {
MAXSHORT, MAXSHORT, MAXSHORT, MAXSHORT, MAXSHORT, 0xFFFF};
static xCharInfo initMaxMetrics = {
MINSHORT, MINSHORT, MINSHORT, MINSHORT, MINSHORT, 0x0000};
#define MINMAX(field,ci) \
if (minbounds->field > (ci)->field) \
minbounds->field = (ci)->field; \
if (maxbounds->field < (ci)->field) \
maxbounds->field = (ci)->field;
#define COMPUTE_MINMAX(ci) \
if ((ci)->ascent || (ci)->descent || \
(ci)->leftSideBearing || (ci)->rightSideBearing || \
(ci)->characterWidth) \
{ \
MINMAX(ascent, (ci)); \
MINMAX(descent, (ci)); \
MINMAX(leftSideBearing, (ci)); \
MINMAX(rightSideBearing, (ci)); \
MINMAX(characterWidth, (ci)); \
}
void
bitmapComputeFontBounds(FontPtr pFont)
{
BitmapFontPtr bitmapFont = (BitmapFontPtr) pFont->fontPrivate;
int nchars;
int r,
c;
CharInfoPtr ci;
int maxOverlap;
int overlap;
xCharInfo *minbounds,
*maxbounds;
int i;
int numneg = 0, numpos = 0;
if (bitmapFont->bitmapExtra) {
minbounds = &bitmapFont->bitmapExtra->info.minbounds;
maxbounds = &bitmapFont->bitmapExtra->info.maxbounds;
} else {
minbounds = &pFont->info.minbounds;
maxbounds = &pFont->info.maxbounds;
}
*minbounds = initMinMetrics;
*maxbounds = initMaxMetrics;
maxOverlap = MINSHORT;
nchars = bitmapFont->num_chars;
for (i = 0, ci = bitmapFont->metrics; i < nchars; i++, ci++) {
COMPUTE_MINMAX(&ci->metrics);
if (ci->metrics.characterWidth < 0)
numneg++;
else
numpos++;
minbounds->attributes &= ci->metrics.attributes;
maxbounds->attributes |= ci->metrics.attributes;
overlap = ci->metrics.rightSideBearing - ci->metrics.characterWidth;
if (maxOverlap < overlap)
maxOverlap = overlap;
}
if (bitmapFont->bitmapExtra) {
if (numneg > numpos)
bitmapFont->bitmapExtra->info.drawDirection = RightToLeft;
else
bitmapFont->bitmapExtra->info.drawDirection = LeftToRight;
bitmapFont->bitmapExtra->info.maxOverlap = maxOverlap;
minbounds = &pFont->info.minbounds;
maxbounds = &pFont->info.maxbounds;
*minbounds = initMinMetrics;
*maxbounds = initMaxMetrics;
i = 0;
maxOverlap = MINSHORT;
for (r = pFont->info.firstRow; r <= pFont->info.lastRow; r++) {
for (c = pFont->info.firstCol; c <= pFont->info.lastCol; c++) {
ci = ACCESSENCODING(bitmapFont->encoding, i);
if (ci) {
COMPUTE_MINMAX(&ci->metrics);
if (ci->metrics.characterWidth < 0)
numneg++;
else
numpos++;
minbounds->attributes &= ci->metrics.attributes;
maxbounds->attributes |= ci->metrics.attributes;
overlap = ci->metrics.rightSideBearing -
ci->metrics.characterWidth;
if (maxOverlap < overlap)
maxOverlap = overlap;
}
i++;
}
}
}
if (numneg > numpos)
pFont->info.drawDirection = RightToLeft;
else
pFont->info.drawDirection = LeftToRight;
pFont->info.maxOverlap = maxOverlap;
}
void
bitmapComputeFontInkBounds(FontPtr pFont)
{
BitmapFontPtr bitmapFont = (BitmapFontPtr) pFont->fontPrivate;
int nchars;
int r,
c;
CharInfoPtr cit;
xCharInfo *ci;
int offset;
xCharInfo *minbounds,
*maxbounds;
int i;
if (!bitmapFont->ink_metrics) {
if (bitmapFont->bitmapExtra) {
bitmapFont->bitmapExtra->info.ink_minbounds = bitmapFont->bitmapExtra->info.minbounds;
bitmapFont->bitmapExtra->info.ink_maxbounds = bitmapFont->bitmapExtra->info.maxbounds;
}
pFont->info.ink_minbounds = pFont->info.minbounds;
pFont->info.ink_maxbounds = pFont->info.maxbounds;
} else {
if (bitmapFont->bitmapExtra) {
minbounds = &bitmapFont->bitmapExtra->info.ink_minbounds;
maxbounds = &bitmapFont->bitmapExtra->info.ink_maxbounds;
} else {
minbounds = &pFont->info.ink_minbounds;
maxbounds = &pFont->info.ink_maxbounds;
}
*minbounds = initMinMetrics;
*maxbounds = initMaxMetrics;
nchars = bitmapFont->num_chars;
for (i = 0, ci = bitmapFont->ink_metrics; i < nchars; i++, ci++) {
COMPUTE_MINMAX(ci);
minbounds->attributes &= ci->attributes;
maxbounds->attributes |= ci->attributes;
}
if (bitmapFont->bitmapExtra) {
minbounds = &pFont->info.ink_minbounds;
maxbounds = &pFont->info.ink_maxbounds;
*minbounds = initMinMetrics;
*maxbounds = initMaxMetrics;
i=0;
for (r = pFont->info.firstRow; r <= pFont->info.lastRow; r++) {
for (c = pFont->info.firstCol; c <= pFont->info.lastCol; c++) {
cit = ACCESSENCODING(bitmapFont->encoding, i);
if (cit) {
offset = cit - bitmapFont->metrics;
ci = &bitmapFont->ink_metrics[offset];
COMPUTE_MINMAX(ci);
minbounds->attributes &= ci->attributes;
maxbounds->attributes |= ci->attributes;
}
i++;
}
}
}
}
}
Bool
bitmapAddInkMetrics(FontPtr pFont)
{
BitmapFontPtr bitmapFont;
int i;
bitmapFont = (BitmapFontPtr) pFont->fontPrivate;
bitmapFont->ink_metrics = malloc(bitmapFont->num_chars * sizeof(xCharInfo));
if (!bitmapFont->ink_metrics) {
fprintf(stderr, "Error: Couldn't allocate ink_metrics (%d*%ld)\n",
bitmapFont->num_chars, (unsigned long)sizeof(xCharInfo));
return FALSE;
}
for (i = 0; i < bitmapFont->num_chars; i++)
FontCharInkMetrics(pFont, &bitmapFont->metrics[i], &bitmapFont->ink_metrics[i]);
pFont->info.inkMetrics = TRUE;
return TRUE;
}
/* ARGSUSED */
int
bitmapComputeWeight(FontPtr pFont)
{
return 10;
}

205
bufio.c Normal file
View file

@ -0,0 +1,205 @@
/*
Copyright 1991, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from The Open Group.
*/
/*
* Author: Keith Packard, MIT X Consortium
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <X11/Xos.h>
#include "fontmisc.h"
#include "bufio.h"
#include <errno.h>
BufFilePtr
BufFileCreate (char *private,
int (*input)(BufFilePtr),
int (*output)(int, BufFilePtr),
int (*skip)(BufFilePtr, int),
int (*close)(BufFilePtr, int))
{
BufFilePtr f;
f = malloc (sizeof *f);
if (!f)
return 0;
f->private = private;
f->bufp = f->buffer;
f->left = 0;
f->input = input;
f->output = output;
f->skip = skip;
f->eof = 0;
f->close = close;
return f;
}
#define FileDes(f) ((int)(long) (f)->private)
static int
BufFileRawFill (BufFilePtr f)
{
int left;
left = read (FileDes(f), (char *)f->buffer, BUFFILESIZE);
if (left <= 0) {
f->left = 0;
return BUFFILEEOF;
}
f->left = left - 1;
f->bufp = f->buffer + 1;
return f->buffer[0];
}
static int
BufFileRawSkip (BufFilePtr f, int count)
{
int curoff;
int fileoff;
int todo;
curoff = f->bufp - f->buffer;
fileoff = curoff + f->left;
if (curoff + count <= fileoff) {
f->bufp += count;
f->left -= count;
} else {
todo = count - (fileoff - curoff);
if (lseek (FileDes(f), todo, 1) == -1) {
if (errno != ESPIPE)
return BUFFILEEOF;
while (todo) {
curoff = BUFFILESIZE;
if (curoff > todo)
curoff = todo;
fileoff = read (FileDes(f), (char *)f->buffer, curoff);
if (fileoff <= 0)
return BUFFILEEOF;
todo -= fileoff;
}
}
f->left = 0;
}
return count;
}
static int
BufFileRawClose (BufFilePtr f, int doClose)
{
if (doClose)
close (FileDes (f));
return 1;
}
BufFilePtr
BufFileOpenRead (int fd)
{
#if defined (WIN32)
/* hv: I'd bet WIN32 has the same effect here */
setmode(fd,O_BINARY);
#endif
return BufFileCreate ((char *)(long) fd, BufFileRawFill, 0, BufFileRawSkip, BufFileRawClose);
}
static int
BufFileRawFlush (int c, BufFilePtr f)
{
int cnt;
if (c != BUFFILEEOF)
*f->bufp++ = c;
cnt = f->bufp - f->buffer;
f->bufp = f->buffer;
f->left = BUFFILESIZE;
if (write (FileDes(f), (char *)f->buffer, cnt) != cnt)
return BUFFILEEOF;
return c;
}
static int
BufFileFlush (BufFilePtr f, int doClose)
{
if (f->bufp != f->buffer)
return (*f->output) (BUFFILEEOF, f);
return 0;
}
BufFilePtr
BufFileOpenWrite (int fd)
{
BufFilePtr f;
#if defined(WIN32)
/* hv: I'd bet WIN32 has the same effect here */
setmode(fd,O_BINARY);
#endif
f = BufFileCreate ((char *)(long) fd, 0, BufFileRawFlush, 0, BufFileFlush);
if (f != NULL) {
f->bufp = f->buffer;
f->left = BUFFILESIZE;
}
return f;
}
int
BufFileRead (BufFilePtr f, char *b, int n)
{
int c, cnt;
cnt = n;
while (cnt--) {
c = BufFileGet (f);
if (c == BUFFILEEOF)
break;
*b++ = c;
}
return n - cnt - 1;
}
int
BufFileWrite (BufFilePtr f, char *b, int n)
{
int cnt;
cnt = n;
while (cnt--) {
if (BufFilePut (*b++, f) == BUFFILEEOF)
return BUFFILEEOF;
}
return n;
}
int
BufFileClose (BufFilePtr f, int doClose)
{
int ret;
ret = (*f->close) (f, doClose);
free (f);
return ret;
}

83
bufio.h Normal file
View file

@ -0,0 +1,83 @@
/*
Copyright 1993, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from The Open Group.
*/
#ifndef ___BUFIO_H___
#define ___BUFIO_H___ 1
#include <X11/Xfuncproto.h>
#define BUFFILESIZE 8192
#define BUFFILEEOF -1
typedef unsigned char BufChar;
typedef struct _buffile *BufFilePtr;
typedef struct _buffile {
BufChar *bufp;
int left;
int eof;
BufChar buffer[BUFFILESIZE];
int (*input)( BufFilePtr /* f */);
int (*output)( int /* c */, BufFilePtr /* f */);
int (*skip)( BufFilePtr /* f */, int /* count */);
int (*close)( BufFilePtr /* f */, int /* doClose */);
char *private;
} BufFileRec;
extern BufFilePtr BufFileCreate (
char*,
int (*)(BufFilePtr),
int (*)(int, BufFilePtr),
int (*)(BufFilePtr, int),
int (*)(BufFilePtr, int));
extern BufFilePtr BufFileOpenRead ( int );
extern BufFilePtr BufFileOpenWrite ( int );
extern BufFilePtr BufFilePushCompressed ( BufFilePtr );
#ifdef X_GZIP_FONT_COMPRESSION
extern BufFilePtr BufFilePushZIP ( BufFilePtr );
#endif
#ifdef X_BZIP2_FONT_COMPRESSION
extern BufFilePtr BufFilePushBZIP2 ( BufFilePtr );
#endif
extern int BufFileClose ( BufFilePtr, int );
extern int BufFileRead ( BufFilePtr, char*, int );
extern int BufFileWrite ( BufFilePtr, char*, int );
#define BufFileGet(f) ((f)->left-- ? *(f)->bufp++ : ((f)->eof = (*(f)->input) (f)))
#define BufFilePut(c,f) (--(f)->left ? *(f)->bufp++ = ((unsigned char)(c)) : (*(f)->output) ((unsigned char)(c),f))
#define BufFileSkip(f,c) ((f)->eof = (*(f)->skip) (f, c))
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#endif /* ___BUFIO_H___ */

4
build.sh Executable file
View file

@ -0,0 +1,4 @@
#!/bin/sh
[ -d output ] || mkdir output
emcc -O -Wall -Werror -s TOTAL_MEMORY=67108864 -s SAFE_HEAP=1 -s STACK_OVERFLOW_CHECK=1 -s ASSERTIONS=2 -s FORCE_FILESYSTEM=1 -s EXPORTED_RUNTIME_METHODS="['ccall']" -DPACKAGE_STRING=\"bdftopcf\" -I . *.c -o output/index.html --shell-file shell.html

65
config.h Normal file
View file

@ -0,0 +1,65 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Name of package */
#define PACKAGE "bdftopcf"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "https://bugs.freedesktop.org/enter_bug.cgi?product=xorg"
/* Define to the full name of this package. */
#define PACKAGE_NAME "bdftopcf"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "bdftopcf 1.1"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "bdftopcf"
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION "1.1"
/* Major version of this package */
#define PACKAGE_VERSION_MAJOR 1
/* Minor version of this package */
#define PACKAGE_VERSION_MINOR 1
/* Patch version of this package */
#define PACKAGE_VERSION_PATCHLEVEL 0
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Version number of package */
#define VERSION "1.1"

74
defaults.c Normal file
View file

@ -0,0 +1,74 @@
/*
Copyright 1990, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
/*
* Author: Keith Packard, MIT X Consortium
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <X11/X.h>
#include <X11/Xproto.h>
#ifndef DEFAULT_BIT_ORDER
#ifdef BITMAP_BIT_ORDER
#define DEFAULT_BIT_ORDER BITMAP_BIT_ORDER
#else
#define DEFAULT_BIT_ORDER MSBFirst
#endif
#endif
#ifndef DEFAULT_BYTE_ORDER
#ifdef IMAGE_BYTE_ORDER
#define DEFAULT_BYTE_ORDER IMAGE_BYTE_ORDER
#else
#define DEFAULT_BYTE_ORDER MSBFirst
#endif
#endif
#ifndef DEFAULT_GLYPH_PAD
#ifdef GLYPHPADBYTES
#define DEFAULT_GLYPH_PAD GLYPHPADBYTES
#else
#define DEFAULT_GLYPH_PAD 4
#endif
#endif
#ifndef DEFAULT_SCAN_UNIT
#define DEFAULT_SCAN_UNIT 1
#endif
#include "fntfilst.h"
void
FontDefaultFormat (int *bit, int *byte, int *glyph, int *scan)
{
*bit = DEFAULT_BIT_ORDER;
*byte = DEFAULT_BYTE_ORDER;
*glyph = DEFAULT_GLYPH_PAD;
*scan = DEFAULT_SCAN_UNIT;
}

66
fileio.c Normal file
View file

@ -0,0 +1,66 @@
/*
Copyright 1991, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
/*
* Author: Keith Packard, MIT X Consortium
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "fntfilio.h"
#include <X11/Xos.h>
#ifndef O_BINARY
#define O_BINARY O_RDONLY
#endif
#ifndef O_CLOEXEC
#define O_CLOEXEC 0
#endif
FontFilePtr
FontFileOpen (const char *name)
{
int fd;
BufFilePtr raw;
fd = open (name, O_BINARY|O_CLOEXEC);
if (fd < 0)
return 0;
raw = BufFileOpenRead (fd);
if (!raw)
{
close (fd);
return 0;
}
return (FontFilePtr) raw;
}
int
FontFileClose (FontFilePtr f)
{
return BufFileClose ((BufFilePtr) f, TRUE);
}

64
filewr.c Normal file
View file

@ -0,0 +1,64 @@
/*
Copyright 1991, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
/*
* Author: Keith Packard, MIT X Consortium
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "fntfilio.h"
#include <X11/Xos.h>
#ifndef O_BINARY
#define O_BINARY 0
#endif
#ifndef O_CLOEXEC
#define O_CLOEXEC 0
#endif
FontFilePtr
FontFileOpenWrite (const char *name)
{
int fd;
fd = open (name, O_CREAT|O_TRUNC|O_RDWR|O_BINARY|O_CLOEXEC, 0666);
if (fd < 0)
return 0;
return (FontFilePtr) BufFileOpenWrite (fd);
}
FontFilePtr
FontFileOpenWriteFd (int fd)
{
return (FontFilePtr) BufFileOpenWrite (fd);
}
FontFilePtr
FontFileOpenFd (int fd)
{
return (FontFilePtr) BufFileOpenRead (fd);
}

179
fntfil.h Normal file
View file

@ -0,0 +1,179 @@
/*
Copyright 1991, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
/*
* Author: Keith Packard, MIT X Consortium
*/
#ifndef _FONTFILE_H_
#define _FONTFILE_H_
#include "fontxlfd.h"
typedef struct _FontEntry *FontEntryPtr;
typedef struct _FontTable *FontTablePtr;
typedef struct _FontName *FontNamePtr;
typedef struct _FontScaled *FontScaledPtr;
typedef struct _FontScalableExtra *FontScalableExtraPtr;
typedef struct _FontScalableEntry *FontScalableEntryPtr;
typedef struct _FontScaleAliasEntry *FontScaleAliasEntryPtr;
typedef struct _FontBitmapEntry *FontBitmapEntryPtr;
typedef struct _FontAliasEntry *FontAliasEntryPtr;
typedef struct _FontBCEntry *FontBCEntryPtr;
typedef struct _FontDirectory *FontDirectoryPtr;
typedef struct _FontRenderer *FontRendererPtr;
#define NullFontEntry ((FontEntryPtr) 0)
#define NullFontTable ((FontTablePtr) 0)
#define NullFontName ((FontNamePtr) 0)
#define NullFontScaled ((FontScaled) 0)
#define NullFontScalableExtra ((FontScalableExtra) 0)
#define NullFontscalableEntry ((FontScalableEntry) 0)
#define NullFontScaleAliasEntry ((FontScaleAliasEntry) 0)
#define NullFontBitmapEntry ((FontBitmapEntry) 0)
#define NullFontAliasEntry ((FontAliasEntry) 0)
#define NullFontBCEntry ((FontBCEntry) 0)
#define NullFontDirectory ((FontDirectoryPtr) 0)
#define NullFontRenderer ((FontRendererPtr) 0)
#define FONT_ENTRY_SCALABLE 0
#define FONT_ENTRY_SCALE_ALIAS 1
#define FONT_ENTRY_BITMAP 2
#define FONT_ENTRY_ALIAS 3
#define FONT_ENTRY_BC 4
#define MAXFONTNAMELEN 1024
#define MAXFONTFILENAMELEN 1024
#define FontDirFile "fonts.dir"
#define FontAliasFile "fonts.alias"
#define FontScalableFile "fonts.scale"
extern int FontFileNameCheck ( const char *name );
extern int FontFileInitFPE ( FontPathElementPtr fpe );
extern int FontFileResetFPE ( FontPathElementPtr fpe );
extern int FontFileFreeFPE ( FontPathElementPtr fpe );
extern int FontFileOpenFont ( pointer client, FontPathElementPtr fpe,
Mask flags, const char *name, int namelen,
fsBitmapFormat format, fsBitmapFormatMask fmask,
XID id, FontPtr *pFont, char **aliasName,
FontPtr non_cachable_font );
extern void FontFileCloseFont ( FontPathElementPtr fpe, FontPtr pFont );
extern int FontFileOpenBitmap ( FontPathElementPtr fpe, FontPtr *pFont,
int flags, FontEntryPtr entry,
fsBitmapFormat format,
fsBitmapFormatMask fmask );
extern int FontFileListFonts ( pointer client, FontPathElementPtr fpe,
const char *pat, int len, int max,
FontNamesPtr names );
extern int FontFileStartListFonts ( pointer client, FontPathElementPtr fpe,
const char *pat, int len, int max,
pointer *privatep, int mark_aliases );
extern int FontFileStartListFontsWithInfo ( pointer client,
FontPathElementPtr fpe,
const char *pat, int len, int max,
pointer *privatep );
extern int FontFileListNextFontWithInfo ( pointer client,
FontPathElementPtr fpe,
char **namep, int *namelenp,
FontInfoPtr *pFontInfo,
int *numFonts, pointer private );
extern int FontFileStartListFontsAndAliases ( pointer client,
FontPathElementPtr fpe,
const char *pat, int len, int max,
pointer *privatep );
extern int FontFileListNextFontOrAlias ( pointer client,
FontPathElementPtr fpe,
char **namep, int *namelenp,
char **resolvedp, int *resolvedlenp,
pointer private );
extern void FontFileRegisterLocalFpeFunctions ( void );
extern void CatalogueRegisterLocalFpeFunctions ( void );
extern FontEntryPtr FontFileAddEntry ( FontTablePtr table,
FontEntryPtr prototype );
extern Bool FontFileAddFontAlias ( FontDirectoryPtr dir, char *aliasName,
char *fontName );
extern Bool FontFileAddFontFile ( FontDirectoryPtr dir, char *fontName,
char *fileName );
extern int FontFileCountDashes ( char *name, int namelen );
extern FontEntryPtr FontFileFindNameInDir ( FontTablePtr table,
FontNamePtr pat );
extern FontEntryPtr FontFileFindNameInScalableDir ( FontTablePtr table,
FontNamePtr pat,
FontScalablePtr vals );
extern int FontFileFindNamesInDir ( FontTablePtr table, FontNamePtr pat,
int max, FontNamesPtr names );
extern int FontFileFindNamesInScalableDir ( FontTablePtr table,
FontNamePtr pat, int max,
FontNamesPtr names,
FontScalablePtr vals,
int alias_behavior, int *newmax );
extern void FontFileFreeDir ( FontDirectoryPtr dir );
extern void FontFileFreeEntry ( FontEntryPtr entry );
extern void FontFileFreeTable ( FontTablePtr table );
extern Bool FontFileInitTable ( FontTablePtr table, int size );
extern FontDirectoryPtr FontFileMakeDir ( const char *dirName, int size );
extern Bool FontFileMatchName ( char *name, int length, FontNamePtr pat );
extern char * FontFileSaveString ( char *s );
extern void FontFileSortDir ( FontDirectoryPtr dir );
extern void FontFileSortTable ( FontTablePtr table );
extern void FontDefaultFormat ( int *bit, int *byte, int *glyph, int *scan );
extern Bool FontFileRegisterRenderer ( FontRendererPtr renderer );
extern Bool FontFilePriorityRegisterRenderer ( FontRendererPtr renderer,
int priority );
extern FontRendererPtr FontFileMatchRenderer ( char *fileName );
extern Bool FontFileAddScaledInstance ( FontEntryPtr entry,
FontScalablePtr vals, FontPtr pFont,
char *bitmapName );
extern void FontFileSwitchStringsToBitmapPointers ( FontDirectoryPtr dir );
extern void FontFileRemoveScaledInstance ( FontEntryPtr entry, FontPtr pFont );
extern Bool FontFileCompleteXLFD ( FontScalablePtr vals, FontScalablePtr def );
extern FontScaledPtr FontFileFindScaledInstance ( FontEntryPtr entry,
FontScalablePtr vals,
int noSpecificSize );
extern Bool FontFileRegisterBitmapSource ( FontPathElementPtr fpe );
extern void FontFileUnregisterBitmapSource ( FontPathElementPtr fpe );
extern void FontFileEmptyBitmapSource ( void );
extern int FontFileMatchBitmapSource ( FontPathElementPtr fpe,
FontPtr *pFont, int flags,
FontEntryPtr entry,
FontNamePtr zeroPat,
FontScalablePtr vals,
fsBitmapFormat format,
fsBitmapFormatMask fmask,
Bool noSpecificSize );
extern int FontFileReadDirectory ( const char *directory, FontDirectoryPtr *pdir );
extern Bool FontFileDirectoryChanged ( FontDirectoryPtr dir );
#endif /* _FONTFILE_H_ */

53
fntfilio.h Normal file
View file

@ -0,0 +1,53 @@
/*
Copyright 1991, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
/*
* Author: Keith Packard, MIT X Consortium
*/
#ifndef _FNTFILIO_H_
#define _FNTFILIO_H_
#include "bufio.h"
typedef BufFilePtr FontFilePtr;
#define FontFileGetc(f) BufFileGet(f)
#define FontFilePutc(c,f) BufFilePut(c,f)
#define FontFileRead(f,b,n) BufFileRead(f,b,n)
#define FontFileWrite(f,b,n) BufFileWrite(f,b,n)
#define FontFileSkip(f,n) (BufFileSkip (f, n) != BUFFILEEOF)
#define FontFileSeek(f,n) (BufFileSeek (f,n,0) != BUFFILEEOF)
#define FontFileEOF BUFFILEEOF
extern FontFilePtr FontFileOpen ( const char *name );
extern int FontFileClose ( FontFilePtr f );
extern FontFilePtr FontFileOpenWrite ( const char *name );
extern FontFilePtr FontFileOpenWriteFd ( int fd );
extern FontFilePtr FontFileOpenFd ( int fd );
#endif /* _FNTFILIO_H_ */

193
fntfilst.h Normal file
View file

@ -0,0 +1,193 @@
/*
Copyright 1991, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
/*
* Author: Keith Packard, MIT X Consortium
*/
#ifndef _FONTFILEST_H_
#define _FONTFILEST_H_
#include <X11/Xos.h>
#ifndef XP_PSTEXT
#include "fontmisc.h"
#endif
#include <X11/fonts/fontstruct.h>
#include "fontxlfd.h"
#include "fntfil.h"
typedef struct _FontName {
char *name;
short length;
short ndashes;
} FontNameRec;
typedef struct _FontScaled {
FontScalableRec vals;
FontEntryPtr bitmap;
FontPtr pFont;
} FontScaledRec;
typedef struct _FontScalableExtra {
FontScalableRec defaults;
int numScaled;
int sizeScaled;
FontScaledPtr scaled;
pointer private;
} FontScalableExtraRec;
typedef struct _FontScalableEntry {
FontRendererPtr renderer;
char *fileName;
FontScalableExtraPtr extra;
} FontScalableEntryRec;
/*
* This "can't" work yet - the returned alias string must be permanent,
* but this layer would need to generate the appropriate name from the
* resolved scalable + the XLFD values passed in. XXX
*/
typedef struct _FontScaleAliasEntry {
char *resolved;
} FontScaleAliasEntryRec;
typedef struct _FontBitmapEntry {
FontRendererPtr renderer;
char *fileName;
FontPtr pFont;
} FontBitmapEntryRec;
typedef struct _FontAliasEntry {
char *resolved;
} FontAliasEntryRec;
typedef struct _FontBCEntry {
FontScalableRec vals;
FontEntryPtr entry;
} FontBCEntryRec;
typedef struct _FontEntry {
FontNameRec name;
int type;
union _FontEntryParts {
FontScalableEntryRec scalable;
FontBitmapEntryRec bitmap;
FontAliasEntryRec alias;
FontBCEntryRec bc;
} u;
} FontEntryRec;
typedef struct _FontTable {
int used;
int size;
FontEntryPtr entries;
Bool sorted;
} FontTableRec;
typedef struct _FontDirectory {
char *directory;
unsigned long dir_mtime;
unsigned long alias_mtime;
FontTableRec scalable;
FontTableRec nonScalable;
char *attributes;
} FontDirectoryRec;
/* Capability bits: for definition of capabilities bitmap in the
FontRendererRec to indicate support of XLFD enhancements */
#define CAP_MATRIX 0x1
#define CAP_CHARSUBSETTING 0x2
typedef struct _FontRenderer {
const char *fileSuffix;
int fileSuffixLen;
int (*OpenBitmap)(FontPathElementPtr /* fpe */,
FontPtr * /* pFont */,
int /* flags */,
FontEntryPtr /* entry */,
char * /* fileName */,
fsBitmapFormat /* format */,
fsBitmapFormatMask /* mask */,
FontPtr /* non_cachable_font */);
int (*OpenScalable)(FontPathElementPtr /* fpe */,
FontPtr * /* pFont */,
int /* flags */,
FontEntryPtr /* entry */,
char * /* fileName */,
FontScalablePtr /* vals */,
fsBitmapFormat /* format */,
fsBitmapFormatMask /* fmask */,
FontPtr /* non_cachable_font */);
int (*GetInfoBitmap)(FontPathElementPtr /* fpe */,
FontInfoPtr /* pFontInfo */,
FontEntryPtr /* entry */,
char * /*fileName */);
int (*GetInfoScalable)(FontPathElementPtr /* fpe */,
FontInfoPtr /* pFontInfo */,
FontEntryPtr /* entry */,
FontNamePtr /* fontName */,
char * /* fileName */,
FontScalablePtr /* vals */);
int number;
int capabilities; /* Bitmap components defined above */
} FontRendererRec;
typedef struct _FontRenders {
int number;
struct _FontRenderersElement {
/* In order to preserve backward compatibility, the
priority field is made invisible to renderers */
FontRendererPtr renderer;
int priority;
} *renderers;
} FontRenderersRec, *FontRenderersPtr;
typedef struct _BitmapInstance {
FontScalableRec vals;
FontBitmapEntryPtr bitmap;
} BitmapInstanceRec, *BitmapInstancePtr;
typedef struct _BitmapScalablePrivate {
int numInstances;
BitmapInstancePtr instances;
} BitmapScalablePrivateRec, *BitmapScalablePrivatePtr;
typedef struct _BitmapSources {
FontPathElementPtr *fpe;
int size;
int count;
} BitmapSourcesRec, *BitmapSourcesPtr;
extern BitmapSourcesRec FontFileBitmapSources;
/* Defines for FontFileFindNamesInScalableDir() behavior */
#define NORMAL_ALIAS_BEHAVIOR 0
#define LIST_ALIASES_AND_TARGET_NAMES (1<<0)
#define IGNORE_SCALABLE_ALIASES (1<<1)
#endif /* _FONTFILEST_H_ */

166
font.h Normal file
View file

@ -0,0 +1,166 @@
/***********************************************************
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Digital not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
#ifndef FONT_H
#define FONT_H
#ifndef BitmapFormatByteOrderMask
#include "fsmasks.h"
#endif
/* data structures */
#ifndef _XTYPEDEF_FONTPTR
typedef struct _Font *FontPtr;
#define _XTYPEDEF_FONTPTR
#endif
typedef struct _FontInfo *FontInfoPtr;
typedef struct _FontProp *FontPropPtr;
typedef struct _ExtentInfo *ExtentInfoPtr;
typedef struct _FontPathElement *FontPathElementPtr;
#ifndef _XTYPEDEF_CHARINFOPTR
typedef struct _CharInfo *CharInfoPtr;
#define _XTYPEDEF_CHARINFOPTR
#endif
typedef struct _FontNames *FontNamesPtr;
typedef struct _FontResolution *FontResolutionPtr;
#define NullCharInfo ((CharInfoPtr) 0)
#define NullFont ((FontPtr) 0)
#define NullFontInfo ((FontInfoPtr) 0)
/* draw direction */
#define LeftToRight 0
#define RightToLeft 1
#define BottomToTop 2
#define TopToBottom 3
typedef int DrawDirection;
#define NO_SUCH_CHAR -1
#define FontAliasType 0x1000
#define AllocError 80
#define StillWorking 81
#define FontNameAlias 82
#define BadFontName 83
#define Suspended 84
#define Successful 85
#define BadFontPath 86
#define BadCharRange 87
#define BadFontFormat 88
#define FPEResetFailed 89 /* for when an FPE reset won't work */
/* OpenFont flags */
#define FontLoadInfo 0x0001
#define FontLoadProps 0x0002
#define FontLoadMetrics 0x0004
#define FontLoadBitmaps 0x0008
#define FontLoadAll 0x000f
#define FontOpenSync 0x0010
#define FontReopen 0x0020
/* Query flags */
#define LoadAll 0x1
#define FinishRamge 0x2
#define EightBitFont 0x4
#define SixteenBitFont 0x8
/* Glyph Caching Modes */
#define CACHING_OFF 0
#define CACHE_16_BIT_GLYPHS 1
#define CACHE_ALL_GLYPHS 2
#define DEFAULT_GLYPH_CACHING_MODE CACHE_16_BIT_GLYPHS
extern int glyphCachingMode;
struct _Client;
extern int StartListFontsWithInfo(
struct _Client * /*client*/,
int /*length*/,
unsigned char * /*pattern*/,
int /*max_names*/
);
extern FontNamesPtr MakeFontNamesRecord(
unsigned /* size */
);
extern void FreeFontNames(
FontNamesPtr /* pFN*/
);
extern int AddFontNamesName(
FontNamesPtr /* names */,
char * /* name */,
int /* length */
);
#if 0 /* unused */
extern int FontToFSError();
extern FontResolutionPtr GetClientResolution();
#endif
typedef struct _FontPatternCache *FontPatternCachePtr;
extern FontPatternCachePtr MakeFontPatternCache (
void
);
extern void FreeFontPatternCache (
FontPatternCachePtr /* cache */
);
extern void EmptyFontPatternCache (
FontPatternCachePtr /* cache */
);
extern void CacheFontPattern (
FontPatternCachePtr /* cache */,
const char * /* pattern */,
int /* patlen */,
FontPtr /* pFont */
);
extern FontResolutionPtr GetClientResolutions(
int * /* num */
);
extern FontPtr FindCachedFontPattern (
FontPatternCachePtr /* cache */,
const char * /* pattern */,
int /* patlen */
);
extern void RemoveCachedFontPattern (
FontPatternCachePtr /* cache */,
FontPtr /* pFont */
);
typedef enum {
Linear8Bit, TwoD8Bit, Linear16Bit, TwoD16Bit
} FontEncoding;
#endif /* FONT_H */

104
fontaccel.c Normal file
View file

@ -0,0 +1,104 @@
/*
Copyright 1990, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from The Open Group.
*/
/*
* Author: Keith Packard, MIT X Consortium
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "fontmisc.h"
#include <X11/fonts/fontstruct.h>
#include "fontutil.h"
void
FontComputeInfoAccelerators(FontInfoPtr pFontInfo)
{
pFontInfo->noOverlap = FALSE;
if (pFontInfo->maxOverlap <= pFontInfo->minbounds.leftSideBearing)
pFontInfo->noOverlap = TRUE;
if ((pFontInfo->minbounds.ascent == pFontInfo->maxbounds.ascent) &&
(pFontInfo->minbounds.descent == pFontInfo->maxbounds.descent) &&
(pFontInfo->minbounds.leftSideBearing ==
pFontInfo->maxbounds.leftSideBearing) &&
(pFontInfo->minbounds.rightSideBearing ==
pFontInfo->maxbounds.rightSideBearing) &&
(pFontInfo->minbounds.characterWidth ==
pFontInfo->maxbounds.characterWidth) &&
(pFontInfo->minbounds.attributes == pFontInfo->maxbounds.attributes)) {
pFontInfo->constantMetrics = TRUE;
if ((pFontInfo->maxbounds.leftSideBearing == 0) &&
(pFontInfo->maxbounds.rightSideBearing ==
pFontInfo->maxbounds.characterWidth) &&
(pFontInfo->maxbounds.ascent == pFontInfo->fontAscent) &&
(pFontInfo->maxbounds.descent == pFontInfo->fontDescent))
pFontInfo->terminalFont = TRUE;
else
pFontInfo->terminalFont = FALSE;
} else {
pFontInfo->constantMetrics = FALSE;
pFontInfo->terminalFont = FALSE;
}
if (pFontInfo->minbounds.characterWidth == pFontInfo->maxbounds.characterWidth)
pFontInfo->constantWidth = TRUE;
else
pFontInfo->constantWidth = FALSE;
if ((pFontInfo->minbounds.leftSideBearing >= 0) &&
(pFontInfo->maxOverlap <= 0) &&
(pFontInfo->minbounds.ascent >= -pFontInfo->fontDescent) &&
(pFontInfo->maxbounds.ascent <= pFontInfo->fontAscent) &&
(-pFontInfo->minbounds.descent <= pFontInfo->fontAscent) &&
(pFontInfo->maxbounds.descent <= pFontInfo->fontDescent))
pFontInfo->inkInside = TRUE;
else
pFontInfo->inkInside = FALSE;
}
int
FontCouldBeTerminal(FontInfoPtr pFontInfo)
{
if ((pFontInfo->minbounds.leftSideBearing >= 0) &&
(pFontInfo->maxbounds.rightSideBearing <= pFontInfo->maxbounds.characterWidth) &&
(pFontInfo->minbounds.characterWidth == pFontInfo->maxbounds.characterWidth) &&
(pFontInfo->maxbounds.ascent <= pFontInfo->fontAscent) &&
(pFontInfo->maxbounds.descent <= pFontInfo->fontDescent) &&
(pFontInfo->maxbounds.leftSideBearing != 0 ||
pFontInfo->minbounds.rightSideBearing != pFontInfo->minbounds.characterWidth ||
pFontInfo->minbounds.ascent != pFontInfo->fontAscent ||
pFontInfo->minbounds.descent != pFontInfo->fontDescent)) {
/* blow off font with nothing but a SPACE */
if (pFontInfo->maxbounds.ascent == 0 &&
pFontInfo->maxbounds.descent == 0)
return FALSE;
return TRUE;
}
return FALSE;
}

216
fontink.c Normal file
View file

@ -0,0 +1,216 @@
/*
Copyright 1990, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from The Open Group.
*/
/*
* Author: Keith Packard, MIT X Consortium
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "fntfilst.h"
#include "bitmap.h"
#include "bdfint.h"
static unsigned char ink_mask_msb[8] = {
0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01,
};
static unsigned char ink_mask_lsb[8] = {
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
};
void
FontCharInkMetrics(FontPtr pFont, CharInfoPtr pCI, xCharInfo *pInk)
{
int leftBearing,
ascent,
descent;
register int vpos,
hpos,
bpos = 0;
int bitmapByteWidth,
bitmapByteWidthPadded;
int bitmapBitWidth;
int span;
register unsigned char *p;
unsigned char *ink_mask = 0;
register int bmax;
register unsigned char charbits;
if (pFont->bit == MSBFirst)
ink_mask = ink_mask_msb;
else if (pFont->bit == LSBFirst)
ink_mask = ink_mask_lsb;
pInk->characterWidth = pCI->metrics.characterWidth;
pInk->attributes = pCI->metrics.attributes;
leftBearing = pCI->metrics.leftSideBearing;
ascent = pCI->metrics.ascent;
descent = pCI->metrics.descent;
bitmapBitWidth = GLYPHWIDTHPIXELS(pCI);
bitmapByteWidth = GLYPHWIDTHBYTES(pCI);
bitmapByteWidthPadded = BYTES_PER_ROW(bitmapBitWidth, pFont->glyph);
span = bitmapByteWidthPadded - bitmapByteWidth;
p = (unsigned char *) pCI->bits;
for (vpos = descent + ascent; --vpos >= 0;) {
for (hpos = bitmapByteWidth; --hpos >= 0;) {
if (*p++ != 0)
goto found_ascent;
}
p += span;
}
/*
* special case -- font with no bits gets all zeros
*/
pInk->leftSideBearing = leftBearing;
pInk->rightSideBearing = leftBearing;
pInk->ascent = 0;
pInk->descent = 0;
return;
found_ascent:
pInk->ascent = vpos - descent + 1;
p = ((unsigned char *) pCI->bits) + bitmapByteWidthPadded *
(descent + ascent - 1) + bitmapByteWidth;
for (vpos = descent + ascent; --vpos >= 0;) {
for (hpos = bitmapByteWidth; --hpos >= 0;) {
if (*--p != 0)
goto found_descent;
}
p -= span;
}
found_descent:
pInk->descent = vpos - ascent + 1;
bmax = 8;
for (hpos = 0; hpos < bitmapByteWidth; hpos++) {
charbits = 0;
p = (unsigned char *) pCI->bits + hpos;
for (vpos = descent + ascent; --vpos >= 0; p += bitmapByteWidthPadded)
charbits |= *p;
if (charbits) {
if (hpos == bitmapByteWidth - 1)
bmax = bitmapBitWidth - (hpos << 3);
p = ink_mask;
for (bpos = bmax; --bpos >= 0;) {
if (charbits & *p++)
goto found_left;
}
}
}
found_left:
pInk->leftSideBearing = leftBearing + (hpos << 3) + bmax - bpos - 1;
bmax = bitmapBitWidth - ((bitmapByteWidth - 1) << 3);
for (hpos = bitmapByteWidth; --hpos >= 0;) {
charbits = 0;
p = (unsigned char *) pCI->bits + hpos;
for (vpos = descent + ascent; --vpos >= 0; p += bitmapByteWidthPadded)
charbits |= *p;
if (charbits) {
p = ink_mask + bmax;
for (bpos = bmax; --bpos >= 0;) {
if (charbits & *--p)
goto found_right;
}
}
bmax = 8;
}
found_right:
pInk->rightSideBearing = leftBearing + (hpos << 3) + bpos + 1;
}
#define ISBITONMSB(x, line) ((line)[(x)/8] & (1 << (7-((x)%8))))
#define SETBITMSB(x, line) ((line)[(x)/8] |= (1 << (7-((x)%8))))
#define ISBITONLSB(x, line) ((line)[(x)/8] & (1 << ((x)%8)))
#define SETBITLSB(x, line) ((line)[(x)/8] |= (1 << ((x)%8)))
#define Min(a,b) ((a)<(b)?(a):(b))
#define Max(a,b) ((a)>(b)?(a):(b))
void
FontCharReshape(FontPtr pFont, CharInfoPtr pSrc, CharInfoPtr pDst)
{
int x,
y;
unsigned char *in_line,
*out_line;
unsigned char *oldglyph,
*newglyph;
int inwidth;
int outwidth,
outheight;
int out_bytes,
in_bytes;
int y_min,
y_max,
x_min,
x_max;
newglyph = (unsigned char *) pDst->bits;
outwidth = pDst->metrics.rightSideBearing - pDst->metrics.leftSideBearing;
outheight = pDst->metrics.descent + pDst->metrics.ascent;
out_bytes = BYTES_PER_ROW(outwidth, pFont->glyph);
oldglyph = (unsigned char *) pSrc->bits;
inwidth = pSrc->metrics.rightSideBearing - pSrc->metrics.leftSideBearing;
in_bytes = BYTES_PER_ROW(inwidth, pFont->glyph);
bzero(newglyph, out_bytes * outheight);
in_line = oldglyph;
out_line = newglyph;
y_min = Max(-pSrc->metrics.ascent, -pDst->metrics.ascent);
y_max = Min(pSrc->metrics.descent, pDst->metrics.descent);
x_min = Max(pSrc->metrics.leftSideBearing, pDst->metrics.leftSideBearing);
x_max = Min(pSrc->metrics.rightSideBearing, pDst->metrics.rightSideBearing);
in_line += (y_min + pSrc->metrics.ascent) * in_bytes;
out_line += (y_min + pDst->metrics.ascent) * out_bytes;
if (pFont->bit == MSBFirst) {
for (y = y_min; y < y_max; y++) {
for (x = x_min; x < x_max; x++) {
if (ISBITONMSB(x - pSrc->metrics.leftSideBearing, in_line))
SETBITMSB(x - pDst->metrics.leftSideBearing, out_line);
}
in_line += in_bytes;
out_line += out_bytes;
}
} else {
for (y = y_min; y < y_max; y++) {
for (x = x_min; x < x_max; x++) {
if (ISBITONLSB(x - pSrc->metrics.leftSideBearing, in_line))
SETBITLSB(x - pDst->metrics.leftSideBearing, out_line);
}
in_line += in_bytes;
out_line += out_bytes;
}
}
}

100
fontmisc.h Normal file
View file

@ -0,0 +1,100 @@
/*
Copyright 1991, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
/*
* Author: Keith Packard, MIT X Consortium
*/
#ifndef _FONTMISC_H_
#define _FONTMISC_H_
#include <X11/Xfuncs.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <X11/Xdefs.h>
#ifndef LSBFirst
#define LSBFirst 0
#define MSBFirst 1
#endif
#ifndef None
#define None 0l
#endif
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif
extern Atom MakeAtom ( const char *string, unsigned len, int makeit );
extern int ValidAtom ( Atom atom );
extern char *NameForAtom (Atom atom);
#define lowbit(x) ((x) & (~(x) + 1))
#undef assert
#define assert(x) ((void)0)
extern void
BitOrderInvert(
register unsigned char *,
register int
);
extern void
TwoByteSwap(
register unsigned char *,
register int
);
extern void
FourByteSwap(
register unsigned char *,
register int
);
extern int
RepadBitmap (
char*,
char*,
unsigned,
unsigned,
int,
int
);
extern void CopyISOLatin1Lowered(
char * /*dest*/,
const char * /*source*/,
int /*length*/
);
extern void register_fpe_functions(void);
#endif /* _FONTMISC_H_ */

24
fontutil.h Normal file
View file

@ -0,0 +1,24 @@
#ifndef _FONTUTIL_H_
#define _FONTUTIL_H_
#include <X11/fonts/FSproto.h>
extern int FontCouldBeTerminal(FontInfoPtr);
extern int CheckFSFormat(fsBitmapFormat, fsBitmapFormatMask, int *, int *,
int *, int *, int *);
extern void FontComputeInfoAccelerators(FontInfoPtr);
extern void GetGlyphs ( FontPtr font, unsigned long count,
unsigned char *chars, FontEncoding fontEncoding,
unsigned long *glyphcount, CharInfoPtr *glyphs );
extern void QueryGlyphExtents ( FontPtr pFont, CharInfoPtr *charinfo,
unsigned long count, ExtentInfoRec *info );
extern Bool QueryTextExtents ( FontPtr pFont, unsigned long count,
unsigned char *chars, ExtentInfoRec *info );
extern Bool ParseGlyphCachingMode ( char *str );
extern void InitGlyphCaching ( void );
extern void SetGlyphCachingMode ( int newmode );
extern int add_range ( fsRange *newrange, int *nranges, fsRange **range,
Bool charset_subset );
#endif /* _FONTUTIL_H_ */

97
fontxlfd.h Normal file
View file

@ -0,0 +1,97 @@
/*
Copyright 1990, 1994, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from The Open Group.
*/
/*
* Author: Keith Packard, MIT X Consortium
*/
#ifndef _FONTXLFD_H_
#define _FONTXLFD_H_
#include <X11/fonts/FSproto.h>
/* Constants for values_supplied bitmap */
#define SIZE_SPECIFY_MASK 0xf
#define PIXELSIZE_MASK 0x3
#define PIXELSIZE_UNDEFINED 0
#define PIXELSIZE_SCALAR 0x1
#define PIXELSIZE_ARRAY 0x2
#define PIXELSIZE_SCALAR_NORMALIZED 0x3 /* Adjusted for resolution */
#define POINTSIZE_MASK 0xc
#define POINTSIZE_UNDEFINED 0
#define POINTSIZE_SCALAR 0x4
#define POINTSIZE_ARRAY 0x8
#define PIXELSIZE_WILDCARD 0x10
#define POINTSIZE_WILDCARD 0x20
#define ENHANCEMENT_SPECIFY_MASK 0x40
#define CHARSUBSET_SPECIFIED 0x40
#define EPS 1.0e-20
#define XLFD_NDIGITS 3 /* Round numbers in pixel and
point arrays to this many
digits for repeatability */
typedef struct _FontScalable {
int values_supplied; /* Bitmap identifying what advanced
capabilities or enhancements
were specified in the font name */
double pixel_matrix[4];
double point_matrix[4];
/* Pixel and point fields are deprecated in favor of the
transformation matrices. They are provided and filled in for the
benefit of rasterizers that do not handle the matrices. */
int pixel,
point;
int x,
y,
width;
char *xlfdName;
int nranges;
fsRange *ranges;
} FontScalableRec, *FontScalablePtr;
extern double xlfd_round_double ( double x );
extern Bool FontParseXLFDName ( char *fname, FontScalablePtr vals, int subst );
extern fsRange *FontParseRanges ( char *name, int *nranges );
#define FONT_XLFD_REPLACE_NONE 0
#define FONT_XLFD_REPLACE_STAR 1
#define FONT_XLFD_REPLACE_ZERO 2
#define FONT_XLFD_REPLACE_VALUE 3
#endif /* _FONTXLFD_H_ */

30
import.py Executable file
View file

@ -0,0 +1,30 @@
#!/usr/bin/python3
import argparse
import glob
import os
import subprocess
import sys
parser = argparse.ArgumentParser()
parser.add_argument("branch", default="gh-pages", nargs="?")
args = parser.parse_args()
version = subprocess.getoutput("git describe --always")
fd = os.fdopen(sys.stdout.fileno(), 'wb')
fd.write(b"commit refs/heads/" + args.branch.encode('utf-8') + b"\n")
fd.write(b"committer Doc Man <noreply@example.com> now" + b"\n")
fd.write(b"data <<EOF" + b"\n")
fd.write(b"Docs built at " + version.encode('utf-8') + b"\n")
fd.write(b"EOF" + b"\n")
files = glob.glob("output/*")
for fn in files:
with open(fn, 'rb') as f: contents = f.read()
fd.write(b"M 644 inline " + os.path.basename(fn).encode('utf-8') + b"\n")
fd.write(b"data " + str(len(contents)).encode("utf-8") + b"\n")
fd.write(contents)
fd.write(b"done\n")

View file

@ -1 +0,0 @@
<!doctypehtml><html lang=en-us><head><meta charset=utf-8><meta content="text/html; charset=utf-8"http-equiv=Content-Type><title>bdftopcf font converter</title><style>form button,form label{background-color:#7f9ccb;padding:5px 10px;border-radius:5px;border:1px ridge #000;font-size:.8rem;height:auto}.emscripten{display:block}textarea.emscripten{font-family:monospace;width:80%}div.emscripten_border{border:1px solid #000}canvas.emscripten{border:0 none;background-color:#000}.spinner{height:50px;width:50px;margin:0 auto;-webkit-animation:rotation .8s linear infinite;-moz-animation:rotation .8s linear infinite;-o-animation:rotation .8s linear infinite;animation:rotation .8s linear infinite;border-left:10px solid #0096f0;border-right:10px solid #0096f0;border-bottom:10px solid #0096f0;border-top:10px solid #6400c8;border-radius:100%;background-color:#c864fa}@-webkit-keyframes rotation{from{-webkit-transform:rotate(0)}to{-webkit-transform:rotate(360deg)}}@-moz-keyframes rotation{from{-moz-transform:rotate(0)}to{-moz-transform:rotate(360deg)}}@-o-keyframes rotation{from{-o-transform:rotate(0)}to{-o-transform:rotate(360deg)}}@keyframes rotation{from{transform:rotate(0)}to{transform:rotate(360deg)}}</style></head><body>Convert a font in BDF format to PCF format for use with CircuitPython. CircuitPython can load PCF files more quickly, and they are also somewhat smaller.<figure id=spinner style=overflow:visible><div class=spinner></div><center style=margin-top:.5em><strong>emscripten</strong></center></figure><div class=emscripten id=status>Downloading...</div><div class=emscripten><progress hidden id=progress max=100 value=0></progress></div><form enctype=multipart/form-data method=POST><label for=bdffont>Browse</label><input accept=.bdf id=bdffont name=bdffont style=opacity:0 type=file><br></form><br><div id=outputDiv><textarea class=emscripten id=output rows=8 style=display:none></textarea><script>function downloadData(e,t){var n=Array.from(t).map((e=>String.fromCharCode(e))).join(""),o="data:application/binary;base64,"+btoa(n),l=document.createElement("a");l.download=e,l.href=o,l.target="blank",document.body.appendChild(l),l.click(),document.body.removeChild(l),delete l}document.querySelector("#bdffont").addEventListener("change",(e=>{var t=document.getElementById("bdffont");if(t.files.length){var n=new FileReader;n.onload=function(e){FS.writeFile("/input.bdf",e.target.result);var n=Module._font_convert(),o=t.value.replace(/.*[/\\]/,"").replace(/\.bdf$/i,"")+".pcf";0!=n&&downloadData(o,FS.readFile("/output.pcf"))},n.readAsBinaryString(t.files[0])}return!1}));var statusElement=document.getElementById("status"),progressElement=document.getElementById("progress"),spinnerElement=document.getElementById("spinner"),outputElement=document.getElementById("output"),Module={preRun:[],postRun:[],print:function(){var e=document.getElementById("output");return e&&(e.value=""),function(t){arguments.length>1&&(t=Array.prototype.slice.call(arguments).join(" ")),console.log(t),e&&(e.style="",e.value+=t+"\n",e.scrollTop=e.scrollHeight)}}(),printErr:function(e){arguments.length>1&&(e=Array.prototype.slice.call(arguments).join(" ")),outputElement.style="",outputElement.value+=e+"\n",outputElement.scrollTop=outputElement.scrollHeight,console.error(e)},setStatus:function(e){if(Module.setStatus.last||(Module.setStatus.last={time:Date.now(),text:""}),e!==Module.setStatus.last.text){var t=e.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/),n=Date.now();t&&n-Module.setStatus.last.time<30||(Module.setStatus.last.time=n,Module.setStatus.last.text=e,t?(e=t[1],progressElement.value=100*parseInt(t[2]),progressElement.max=100*parseInt(t[4]),progressElement.hidden=!1,spinnerElement.hidden=!1):(progressElement.value=null,progressElement.max=null,progressElement.hidden=!0,e||(spinnerElement.hidden=!0)),statusElement.innerHTML=e)}},totalDependencies:0,monitorRunDependencies:function(e){this.totalDependencies=Math.max(this.totalDependencies,e),Module.setStatus(e?"Preparing... ("+(this.totalDependencies-e)+"/"+this.totalDependencies+")":"All downloads complete.")}};Module.setStatus("Downloading..."),window.onerror=function(){Module.setStatus("Exception thrown, see JavaScript console"),spinnerElement.style.display="none",Module.setStatus=function(e){e&&Module.printErr("[post-exception status] "+e)}}</script><script async src=index.js></script></body></html>

File diff suppressed because one or more lines are too long

Binary file not shown.

97
pcf.h Normal file
View file

@ -0,0 +1,97 @@
/*
Copyright 1991, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from The Open Group.
*/
/*
* Author: Keith Packard, MIT X Consortium
*/
#ifndef _PCF_H_
#define _PCF_H_
#include "fntfilio.h"
/*
* Information used to read/write PCF fonts
*/
typedef struct _PCFTable {
CARD32 type;
CARD32 format;
CARD32 size;
CARD32 offset;
} PCFTableRec, *PCFTablePtr;
#define PCF_FILE_VERSION (('p'<<24)|('c'<<16)|('f'<<8)|1)
#define PCF_FORMAT_MASK 0xffffff00
#define PCF_DEFAULT_FORMAT 0x00000000
#define PCF_INKBOUNDS 0x00000200
#define PCF_ACCEL_W_INKBOUNDS 0x00000100
#define PCF_COMPRESSED_METRICS 0x00000100
#define PCF_FORMAT_MATCH(a,b) (((a)&PCF_FORMAT_MASK) == ((b)&PCF_FORMAT_MASK))
#define PCF_GLYPH_PAD_MASK (3<<0)
#define PCF_BYTE_MASK (1<<2)
#define PCF_BIT_MASK (1<<3)
#define PCF_SCAN_UNIT_MASK (3<<4)
#define PCF_BYTE_ORDER(f) (((f) & PCF_BYTE_MASK)?MSBFirst:LSBFirst)
#define PCF_BIT_ORDER(f) (((f) & PCF_BIT_MASK)?MSBFirst:LSBFirst)
#define PCF_GLYPH_PAD_INDEX(f) ((f) & PCF_GLYPH_PAD_MASK)
#define PCF_GLYPH_PAD(f) (1<<PCF_GLYPH_PAD_INDEX(f))
#define PCF_SCAN_UNIT_INDEX(f) (((f) & PCF_SCAN_UNIT_MASK) >> 4)
#define PCF_SCAN_UNIT(f) (1<<PCF_SCAN_UNIT_INDEX(f))
#define PCF_FORMAT_BITS(f) ((f) & (PCF_GLYPH_PAD_MASK|PCF_BYTE_MASK|PCF_BIT_MASK|PCF_SCAN_UNIT_MASK))
#define PCF_SIZE_TO_INDEX(s) ((s) == 4 ? 2 : (s) == 2 ? 1 : 0)
#define PCF_INDEX_TO_SIZE(b) (1<<b)
#define PCF_FORMAT(bit,byte,glyph,scan) (\
(PCF_SIZE_TO_INDEX(scan) << 4) | \
(((bit) == MSBFirst ? 1 : 0) << 3) | \
(((byte) == MSBFirst ? 1 : 0) << 2) | \
(PCF_SIZE_TO_INDEX(glyph) << 0))
#define PCF_PROPERTIES (1<<0)
#define PCF_ACCELERATORS (1<<1)
#define PCF_METRICS (1<<2)
#define PCF_BITMAPS (1<<3)
#define PCF_INK_METRICS (1<<4)
#define PCF_BDF_ENCODINGS (1<<5)
#define PCF_SWIDTHS (1<<6)
#define PCF_GLYPH_NAMES (1<<7)
#define PCF_BDF_ACCELERATORS (1<<8)
extern int pcfReadFont ( FontPtr pFont, FontFilePtr file,
int bit, int byte, int glyph, int scan );
extern int pcfReadFontInfo ( FontInfoPtr pFontInfo, FontFilePtr file );
extern int pcfWriteFont ( FontPtr pFont, FontFilePtr file );
extern void pcfError ( const char *, ... ) _X_ATTRIBUTE_PRINTF(1, 2);
#endif /* _PCF_H_ */

481
pcfwrite.c Normal file
View file

@ -0,0 +1,481 @@
/*
Copyright 1990, 1994, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from The Open Group.
*/
/*
* Author: Keith Packard, MIT X Consortium
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "fntfilst.h"
#include "bitmap.h"
#include "pcf.h"
#include <stdarg.h>
#include <stdio.h>
/* Write PCF font files */
static CARD32 current_position;
void
pcfError(const char* message, ...)
{
va_list args;
va_start(args, message);
fprintf(stderr, "PCF Error: ");
vfprintf(stderr, message, args);
va_end(args);
}
static int
pcfWrite(FontFilePtr file, char *b, int c)
{
current_position += c;
return FontFileWrite(file, b, c);
}
static int
pcfPutLSB32(FontFilePtr file, int c)
{
current_position += 4;
(void) FontFilePutc(c, file);
(void) FontFilePutc(c >> 8, file);
(void) FontFilePutc(c >> 16, file);
return FontFilePutc(c >> 24, file);
}
static int
pcfPutINT32(FontFilePtr file, CARD32 format, int c)
{
current_position += 4;
if (PCF_BYTE_ORDER(format) == MSBFirst) {
(void) FontFilePutc(c >> 24, file);
(void) FontFilePutc(c >> 16, file);
(void) FontFilePutc(c >> 8, file);
return FontFilePutc(c, file);
} else {
(void) FontFilePutc(c, file);
(void) FontFilePutc(c >> 8, file);
(void) FontFilePutc(c >> 16, file);
return FontFilePutc(c >> 24, file);
}
}
static int
pcfPutINT16(FontFilePtr file, CARD32 format, int c)
{
current_position += 2;
if (PCF_BYTE_ORDER(format) == MSBFirst) {
(void) FontFilePutc(c >> 8, file);
return FontFilePutc(c, file);
} else {
(void) FontFilePutc(c, file);
return FontFilePutc(c >> 8, file);
}
}
/*ARGSUSED*/
static int
pcfPutINT8(FontFilePtr file, CARD32 format, int c)
{
current_position += 1;
return FontFilePutc(c, file);
}
static void
pcfWriteTOC(FontFilePtr file, PCFTablePtr table, int count)
{
CARD32 version;
int i;
version = PCF_FILE_VERSION;
pcfPutLSB32(file, version);
pcfPutLSB32(file, count);
for (i = 0; i < count; i++) {
pcfPutLSB32(file, table->type);
pcfPutLSB32(file, table->format);
pcfPutLSB32(file, table->size);
pcfPutLSB32(file, table->offset);
table++;
}
}
static void
pcfPutCompressedMetric(FontFilePtr file, CARD32 format, xCharInfo *metric)
{
pcfPutINT8(file, format, metric->leftSideBearing + 0x80);
pcfPutINT8(file, format, metric->rightSideBearing + 0x80);
pcfPutINT8(file, format, metric->characterWidth + 0x80);
pcfPutINT8(file, format, metric->ascent + 0x80);
pcfPutINT8(file, format, metric->descent + 0x80);
}
static void
pcfPutMetric(FontFilePtr file, CARD32 format, xCharInfo *metric)
{
pcfPutINT16(file, format, metric->leftSideBearing);
pcfPutINT16(file, format, metric->rightSideBearing);
pcfPutINT16(file, format, metric->characterWidth);
pcfPutINT16(file, format, metric->ascent);
pcfPutINT16(file, format, metric->descent);
pcfPutINT16(file, format, metric->attributes);
}
static void
pcfPutBitmap(FontFilePtr file, CARD32 format, CharInfoPtr pCI)
{
int count;
unsigned char *bits;
count = BYTES_FOR_GLYPH(pCI, PCF_GLYPH_PAD(format));
bits = (unsigned char *) pCI->bits;
current_position += count;
while (count--)
FontFilePutc(*bits++, file);
}
static void
pcfPutAccel(FontFilePtr file, CARD32 format, FontInfoPtr pFontInfo)
{
pcfPutINT8(file, format, pFontInfo->noOverlap);
pcfPutINT8(file, format, pFontInfo->constantMetrics);
pcfPutINT8(file, format, pFontInfo->terminalFont);
pcfPutINT8(file, format, pFontInfo->constantWidth);
pcfPutINT8(file, format, pFontInfo->inkInside);
pcfPutINT8(file, format, pFontInfo->inkMetrics);
pcfPutINT8(file, format, pFontInfo->drawDirection);
pcfPutINT8(file, format, 0);
pcfPutINT32(file, format, pFontInfo->fontAscent);
pcfPutINT32(file, format, pFontInfo->fontDescent);
pcfPutINT32(file, format, pFontInfo->maxOverlap);
pcfPutMetric(file, format, &pFontInfo->minbounds);
pcfPutMetric(file, format, &pFontInfo->maxbounds);
if (PCF_FORMAT_MATCH(format, PCF_ACCEL_W_INKBOUNDS)) {
pcfPutMetric(file, format, &pFontInfo->ink_minbounds);
pcfPutMetric(file, format, &pFontInfo->ink_maxbounds);
}
}
#define S32 4
#define S16 2
#define S8 1
#define Pad(s) (RoundUp(s) - (s))
#define RoundUp(s) (((s) + 3) & ~3)
#define Compressable(i) (-128 <= (i) && (i) <= 127)
#define CanCompressMetric(m) (Compressable((m)->leftSideBearing) && \
Compressable((m)->rightSideBearing) && \
Compressable((m)->characterWidth) && \
Compressable((m)->ascent) && \
Compressable((m)->descent) && \
(m)->attributes == 0)
#define CanCompressMetrics(min,max) (CanCompressMetric(min) && CanCompressMetric(max))
static char *
pcfNameForAtom(Atom a)
{
return NameForAtom(a);
}
int
pcfWriteFont(FontPtr pFont, FontFilePtr file)
{
PCFTableRec tables[32],
*table;
CARD32 mask,
bit;
int ntables;
int size;
CARD32 format;
int i;
int cur_table;
int prop_string_size;
int glyph_string_size;
xCharInfo *minbounds,
*maxbounds;
xCharInfo *ink_minbounds,
*ink_maxbounds;
BitmapFontPtr bitmapFont;
int nencodings = 0;
int header_size;
FontPropPtr offsetProps;
int prop_pad = 0;
char *atom_name;
int glyph;
CARD32 offset;
bitmapFont = (BitmapFontPtr) pFont->fontPrivate;
if (bitmapFont->bitmapExtra) {
minbounds = &bitmapFont->bitmapExtra->info.minbounds;
maxbounds = &bitmapFont->bitmapExtra->info.maxbounds;
ink_minbounds = &bitmapFont->bitmapExtra->info.ink_minbounds;
ink_maxbounds = &bitmapFont->bitmapExtra->info.ink_maxbounds;
} else {
minbounds = &pFont->info.minbounds;
maxbounds = &pFont->info.maxbounds;
ink_minbounds = &pFont->info.ink_minbounds;
ink_maxbounds = &pFont->info.ink_maxbounds;
}
offsetProps = malloc(pFont->info.nprops * sizeof(FontPropRec));
if (!offsetProps) {
pcfError("pcfWriteFont(): Couldn't allocate offsetProps (%d*%d)",
pFont->info.nprops, (int) sizeof(FontPropRec));
return AllocError;
}
prop_string_size = 0;
for (i = 0; i < pFont->info.nprops; i++) {
offsetProps[i].name = prop_string_size;
prop_string_size += strlen(pcfNameForAtom(pFont->info.props[i].name)) + 1;
if (pFont->info.isStringProp[i]) {
offsetProps[i].value = prop_string_size;
prop_string_size += strlen(pcfNameForAtom(pFont->info.props[i].value)) + 1;
} else
offsetProps[i].value = pFont->info.props[i].value;
}
format = PCF_FORMAT(pFont->bit, pFont->byte, pFont->glyph, pFont->scan);
mask = 0xFFFFFFF;
ntables = 0;
table = tables;
while (mask) {
bit = lowbit(mask);
mask &= ~bit;
table->type = bit;
switch (bit) {
case PCF_PROPERTIES:
table->format = PCF_DEFAULT_FORMAT | format;
size = S32 + S32 + (S32 + S8 + S32) * pFont->info.nprops;
prop_pad = Pad(size);
table->size = RoundUp(size) + S32 +
RoundUp(prop_string_size);
table++;
break;
case PCF_ACCELERATORS:
if (bitmapFont->bitmapExtra->info.inkMetrics)
table->format = PCF_ACCEL_W_INKBOUNDS | format;
else
table->format = PCF_DEFAULT_FORMAT | format;
table->size = 100;
table++;
break;
case PCF_METRICS:
if (CanCompressMetrics(minbounds, maxbounds)) {
table->format = PCF_COMPRESSED_METRICS | format;
size = S32 + S16 + bitmapFont->num_chars * (5 * S8);
table->size = RoundUp(size);
} else {
table->format = PCF_DEFAULT_FORMAT | format;
table->size = S32 + S32 + bitmapFont->num_chars * (6 * S16);
}
table++;
break;
case PCF_BITMAPS:
table->format = PCF_DEFAULT_FORMAT | format;
size = S32 + S32 + bitmapFont->num_chars * S32 +
GLYPHPADOPTIONS * S32 +
bitmapFont->bitmapExtra->bitmapsSizes[PCF_GLYPH_PAD_INDEX(format)];
table->size = RoundUp(size);
table++;
break;
case PCF_INK_METRICS:
if (bitmapFont->ink_metrics) {
if (CanCompressMetrics(ink_minbounds, ink_maxbounds)) {
table->format = PCF_COMPRESSED_METRICS | format;
size = S32 + S16 + bitmapFont->num_chars * (5 * S8);
table->size = RoundUp(size);
} else {
table->format = PCF_DEFAULT_FORMAT | format;
table->size = S32 + S32 + bitmapFont->num_chars * (6 * S16);
}
table++;
}
break;
case PCF_BDF_ENCODINGS:
table->format = PCF_DEFAULT_FORMAT | format;
nencodings = (pFont->info.lastRow - pFont->info.firstRow + 1) *
(pFont->info.lastCol - pFont->info.firstCol + 1);
size = S32 + 5 * S16 + nencodings * S16;
table->size = RoundUp(size);
table++;
break;
case PCF_SWIDTHS:
table->format = PCF_DEFAULT_FORMAT | format;
table->size = S32 + S32 + bitmapFont->num_chars * S32;
table++;
break;
case PCF_GLYPH_NAMES:
table->format = PCF_DEFAULT_FORMAT | format;
glyph_string_size = 0;
for (i = 0; i < bitmapFont->num_chars; i++)
glyph_string_size += strlen(pcfNameForAtom(bitmapFont->bitmapExtra->glyphNames[i])) + 1;
table->size = S32 + S32 + bitmapFont->num_chars * S32 +
S32 + RoundUp(glyph_string_size);
table++;
break;
case PCF_BDF_ACCELERATORS:
if (pFont->info.inkMetrics)
table->format = PCF_ACCEL_W_INKBOUNDS | format;
else
table->format = PCF_DEFAULT_FORMAT | format;
table->size = 100;
table++;
break;
}
}
ntables = table - tables;
offset = 0;
header_size = S32 + S32 + ntables * (4 * S32);
offset = header_size;
for (cur_table = 0, table = tables;
cur_table < ntables;
cur_table++, table++) {
table->offset = offset;
offset += table->size;
}
current_position = 0;
pcfWriteTOC(file, tables, ntables);
for (cur_table = 0, table = tables;
cur_table < ntables;
cur_table++, table++) {
if (current_position > table->offset) {
printf("can't go backwards... %d > %d\n",
(int)current_position, (int)table->offset);
free(offsetProps);
return BadFontName;
}
while (current_position < table->offset)
pcfPutINT8(file, format, '\0');
pcfPutLSB32(file, table->format);
switch (table->type) {
case PCF_PROPERTIES:
pcfPutINT32(file, format, pFont->info.nprops);
for (i = 0; i < pFont->info.nprops; i++) {
pcfPutINT32(file, format, offsetProps[i].name);
pcfPutINT8(file, format, pFont->info.isStringProp[i]);
pcfPutINT32(file, format, offsetProps[i].value);
}
for (i = 0; i < prop_pad; i++)
pcfPutINT8(file, format, 0);
pcfPutINT32(file, format, prop_string_size);
for (i = 0; i < pFont->info.nprops; i++) {
atom_name = pcfNameForAtom(pFont->info.props[i].name);
pcfWrite(file, atom_name, strlen(atom_name) + 1);
if (pFont->info.isStringProp[i]) {
atom_name = pcfNameForAtom(pFont->info.props[i].value);
pcfWrite(file, atom_name, strlen(atom_name) + 1);
}
}
break;
case PCF_ACCELERATORS:
pcfPutAccel(file, table->format, &bitmapFont->bitmapExtra->info);
break;
case PCF_METRICS:
if (PCF_FORMAT_MATCH(table->format, PCF_COMPRESSED_METRICS)) {
pcfPutINT16(file, format, bitmapFont->num_chars);
for (i = 0; i < bitmapFont->num_chars; i++)
pcfPutCompressedMetric(file, format, &bitmapFont->metrics[i].metrics);
} else {
pcfPutINT32(file, format, bitmapFont->num_chars);
for (i = 0; i < bitmapFont->num_chars; i++)
pcfPutMetric(file, format, &bitmapFont->metrics[i].metrics);
}
break;
case PCF_BITMAPS:
pcfPutINT32(file, format, bitmapFont->num_chars);
glyph = PCF_GLYPH_PAD(format);
offset = 0;
for (i = 0; i < bitmapFont->num_chars; i++) {
pcfPutINT32(file, format, offset);
offset += BYTES_FOR_GLYPH(&bitmapFont->metrics[i], glyph);
}
for (i = 0; i < GLYPHPADOPTIONS; i++) {
pcfPutINT32(file, format,
bitmapFont->bitmapExtra->bitmapsSizes[i]);
}
for (i = 0; i < bitmapFont->num_chars; i++)
pcfPutBitmap(file, format, &bitmapFont->metrics[i]);
break;
case PCF_INK_METRICS:
if (PCF_FORMAT_MATCH(table->format, PCF_COMPRESSED_METRICS)) {
pcfPutINT16(file, format, bitmapFont->num_chars);
for (i = 0; i < bitmapFont->num_chars; i++)
pcfPutCompressedMetric(file, format, &bitmapFont->ink_metrics[i]);
} else {
pcfPutINT32(file, format, bitmapFont->num_chars);
for (i = 0; i < bitmapFont->num_chars; i++)
pcfPutMetric(file, format, &bitmapFont->ink_metrics[i]);
}
break;
case PCF_BDF_ENCODINGS:
pcfPutINT16(file, format, pFont->info.firstCol);
pcfPutINT16(file, format, pFont->info.lastCol);
pcfPutINT16(file, format, pFont->info.firstRow);
pcfPutINT16(file, format, pFont->info.lastRow);
pcfPutINT16(file, format, pFont->info.defaultCh);
for (i = 0; i < nencodings; i++) {
if (ACCESSENCODING(bitmapFont->encoding,i))
pcfPutINT16(file, format,
ACCESSENCODING(bitmapFont->encoding, i) -
bitmapFont->metrics);
else
pcfPutINT16(file, format, 0xFFFF);
}
break;
case PCF_SWIDTHS:
pcfPutINT32(file, format, bitmapFont->num_chars);
for (i = 0; i < bitmapFont->num_chars; i++)
pcfPutINT32(file, format, bitmapFont->bitmapExtra->sWidths[i]);
break;
case PCF_GLYPH_NAMES:
pcfPutINT32(file, format, bitmapFont->num_chars);
offset = 0;
for (i = 0; i < bitmapFont->num_chars; i++) {
pcfPutINT32(file, format, offset);
offset += strlen(pcfNameForAtom(bitmapFont->bitmapExtra->glyphNames[i])) + 1;
}
pcfPutINT32(file, format, offset);
for (i = 0; i < bitmapFont->num_chars; i++) {
atom_name = pcfNameForAtom(bitmapFont->bitmapExtra->glyphNames[i]);
pcfWrite(file, atom_name, strlen(atom_name) + 1);
}
break;
case PCF_BDF_ACCELERATORS:
pcfPutAccel(file, table->format, &pFont->info);
break;
}
}
free(offsetProps);
return Successful;
}

104
private.c Normal file
View file

@ -0,0 +1,104 @@
/*
Copyright 1991, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
/*
* Author: Keith Packard, MIT X Consortium
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "fontmisc.h"
#include <X11/fonts/fontstruct.h>
static int _FontPrivateAllocateIndex = 0;
int
AllocateFontPrivateIndex (void)
{
return _FontPrivateAllocateIndex++;
}
FontPtr
CreateFontRec (void)
{
FontPtr pFont;
int size;
size = sizeof(FontRec) + (sizeof(pointer) * _FontPrivateAllocateIndex);
pFont = malloc(size);
if(pFont) {
bzero((char*)pFont, size);
pFont->maxPrivate = _FontPrivateAllocateIndex - 1;
if(_FontPrivateAllocateIndex)
pFont->devPrivates = (pointer)(&pFont[1]);
}
return pFont;
}
void
DestroyFontRec (FontPtr pFont)
{
if (pFont->devPrivates && pFont->devPrivates != (pointer)(&pFont[1]))
free(pFont->devPrivates);
free(pFont);
}
void
ResetFontPrivateIndex (void)
{
_FontPrivateAllocateIndex = 0;
}
Bool
_FontSetNewPrivate (FontPtr pFont, int n, pointer ptr)
{
pointer *new;
if (n > pFont->maxPrivate) {
if (pFont->devPrivates && pFont->devPrivates != (pointer)(&pFont[1])) {
new = realloc (pFont->devPrivates, (n + 1) * sizeof (pointer));
if (!new)
return FALSE;
} else {
/* omg realloc */
new = malloc ((n + 1) * sizeof (pointer));
if (!new)
return FALSE;
if (pFont->devPrivates)
memcpy (new, pFont->devPrivates, (pFont->maxPrivate + 1) * sizeof (pointer));
}
pFont->devPrivates = new;
/* zero out new, uninitialized privates */
while(++pFont->maxPrivate < n)
pFont->devPrivates[pFont->maxPrivate] = (pointer)0;
}
pFont->devPrivates[n] = ptr;
return TRUE;
}

12
server.py Executable file
View file

@ -0,0 +1,12 @@
#!/usr/bin/env python3
import http.server
import socketserver
PORT = 4242
Handler = http.server.SimpleHTTPRequestHandler
Handler.extensions_map[".wasm"] = "application/wasm"
with socketserver.TCPServer(("", PORT), Handler) as httpd:
print("serving at port", PORT)
httpd.serve_forever()

183
shell.html Normal file
View file

@ -0,0 +1,183 @@
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>bdftopcf font converter</title>
<style>
form label, form button {
background-color: #7F9CCB;
padding: 5px 10px;
border-radius: 5px;
border: 1px ridge black;
font-size: 0.8rem;
height: auto;
}
.emscripten { display: block; }
textarea.emscripten { font-family: monospace; width: 80%; }
div.emscripten_border { border: 1px solid black; }
/* the canvas *must not* have any border or padding, or mouse coords will be wrong */
canvas.emscripten { border: 0px none; background-color: black; }
.spinner {
height: 50px;
width: 50px;
margin: 0px auto;
-webkit-animation: rotation .8s linear infinite;
-moz-animation: rotation .8s linear infinite;
-o-animation: rotation .8s linear infinite;
animation: rotation 0.8s linear infinite;
border-left: 10px solid rgb(0,150,240);
border-right: 10px solid rgb(0,150,240);
border-bottom: 10px solid rgb(0,150,240);
border-top: 10px solid rgb(100,0,200);
border-radius: 100%;
background-color: rgb(200,100,250);
}
@-webkit-keyframes rotation {
from {-webkit-transform: rotate(0deg);}
to {-webkit-transform: rotate(360deg);}
}
@-moz-keyframes rotation {
from {-moz-transform: rotate(0deg);}
to {-moz-transform: rotate(360deg);}
}
@-o-keyframes rotation {
from {-o-transform: rotate(0deg);}
to {-o-transform: rotate(360deg);}
}
@keyframes rotation {
from {transform: rotate(0deg);}
to {transform: rotate(360deg);}
}
</style>
</head>
<body>
Convert a font in BDF format to PCF format for use with CircuitPython. CircuitPython can load PCF files more quickly, and they are also somewhat smaller.
<figure style="overflow:visible;" id="spinner"><div class="spinner"></div><center style="margin-top:0.5em"><strong>emscripten</strong></center></figure>
<div class="emscripten" id="status">Downloading...</div>
<div class="emscripten">
<progress value="0" max="100" id="progress" hidden=1></progress>
</div>
<form method="POST" enctype="multipart/form-data">
<label for="bdffont">Browse</label><input type="file" id="bdffont" name="bdffont" accept=".bdf" style="opacity:0"/>
<br>
<!-- <input type="submit" value="Convert" onSubmit="return convert_me()"/> -->
</form>
<br/>
<div id="outputDiv"/>
<textarea class="emscripten" id="output" rows="8" style="display:none"></textarea>
<script type='text/javascript'>
function downloadData(name, data) {
var as_str = Array.from(data).map((c)=>String.fromCharCode(c)).join("")
var datauri = "data:application/binary;base64," + btoa(as_str)
var link = document.createElement("a");
link.download = name;
link.href = datauri;
link.target = "blank";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
delete link;
}
document.querySelector('#bdffont').addEventListener('change', (event) => {
var file = document.getElementById("bdffont");
if (file.files.length) {
var reader = new FileReader();
reader.onload = function(e) {
FS.writeFile("/input.bdf", e.target.result);
// Module._font_convert("/input.bdf", "/output.pcf");
var result = Module._font_convert();
var ofn = file.value.replace(/.*[/\\]/, "").replace(/\.bdf$/i, "") + ".pcf"
if(result != 0) {
downloadData(ofn, FS.readFile("/output.pcf"));
}
}
reader.readAsBinaryString(file.files[0]);
}
return false;
});
var statusElement = document.getElementById('status');
var progressElement = document.getElementById('progress');
var spinnerElement = document.getElementById('spinner');
var outputElement = document.getElementById('output');
var Module = {
preRun: [],
postRun: [],
print: (function() {
var element = document.getElementById('output');
if (element) element.value = ''; // clear browser cache
return function(text) {
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
// These replacements are necessary if you render to raw HTML
//text = text.replace(/&/g, "&amp;");
//text = text.replace(/</g, "&lt;");
//text = text.replace(/>/g, "&gt;");
//text = text.replace('\n', '<br>', 'g');
console.log(text);
if (element) {
element.style = ""
element.value += text + "\n";
element.scrollTop = element.scrollHeight; // focus on bottom
}
};
})(),
printErr: function(text) {
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
if (0) { // XXX disabled for safety typeof dump == 'function') {
dump(text + '\n'); // fast, straight to the real console
} else {
outputElement.style = ""
outputElement.value += text + "\n";
outputElement.scrollTop = outputElement.scrollHeight; // focus on bottom
console.error(text);
}
},
setStatus: function(text) {
if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
if (text === Module.setStatus.last.text) return;
var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
var now = Date.now();
if (m && now - Module.setStatus.last.time < 30) return; // if this is a progress update, skip it if too soon
Module.setStatus.last.time = now;
Module.setStatus.last.text = text;
if (m) {
text = m[1];
progressElement.value = parseInt(m[2])*100;
progressElement.max = parseInt(m[4])*100;
progressElement.hidden = false;
spinnerElement.hidden = false;
} else {
progressElement.value = null;
progressElement.max = null;
progressElement.hidden = true;
if (!text) spinnerElement.hidden = true;
}
statusElement.innerHTML = text;
},
totalDependencies: 0,
monitorRunDependencies: function(left) {
this.totalDependencies = Math.max(this.totalDependencies, left);
Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
}
};
Module.setStatus('Downloading...');
window.onerror = function() {
Module.setStatus('Exception thrown, see JavaScript console');
spinnerElement.style.display = 'none';
Module.setStatus = function(text) {
if (text) Module.printErr('[post-exception status] ' + text);
};
};
</script>
{{{ SCRIPT }}}
</body>
</html>

25
stubs.h Normal file
View file

@ -0,0 +1,25 @@
#include <stdio.h>
#include "fntfilst.h"
#include "font.h"
#ifndef True
#define True (-1)
#endif
#ifndef False
#define False (0)
#endif
#define OVERRIDE_DATA(sym)
#define OVERRIDE_SYMBOL(sym,...)
#define OVERRIDE_VA_SYMBOL(sym,f)
extern FontPtr find_old_font ( FSID id );
extern int set_font_authorizations ( char **authorizations,
int *authlen,
ClientPtr client );
extern unsigned long GetTimeInMillis (void);
extern void ErrorF(const char *format, ...);
/* end of file */

183
utilbitmap.c Normal file
View file

@ -0,0 +1,183 @@
/*
Copyright 1990, 1994, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
/*
* Author: Keith Packard, MIT X Consortium
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "fontmisc.h"
/* Utility functions for reformating font bitmaps */
static const unsigned char _reverse_byte[0x100] = {
0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
};
/*
* Invert bit order within each BYTE of an array.
*/
void
BitOrderInvert(unsigned char *buf, int nbytes)
{
const unsigned char *rev = _reverse_byte;
for (; --nbytes >= 0; buf++)
*buf = rev[*buf];
}
/*
* Invert byte order within each 16-bits of an array.
*/
void
TwoByteSwap(unsigned char *buf, int nbytes)
{
unsigned char c;
for (; nbytes > 0; nbytes -= 2, buf += 2)
{
c = buf[0];
buf[0] = buf[1];
buf[1] = c;
}
}
/*
* Invert byte order within each 32-bits of an array.
*/
void
FourByteSwap(unsigned char *buf, int nbytes)
{
unsigned char c;
for (; nbytes > 0; nbytes -= 4, buf += 4)
{
c = buf[0];
buf[0] = buf[3];
buf[3] = c;
c = buf[1];
buf[1] = buf[2];
buf[2] = c;
}
}
/*
* Repad a bitmap
*/
int
RepadBitmap (char *pSrc, char *pDst,
unsigned int srcPad, unsigned int dstPad,
int width, int height)
{
int srcWidthBytes,dstWidthBytes;
int row,col;
char *pTmpSrc,*pTmpDst;
switch (srcPad) {
case 1:
srcWidthBytes = (width+7)>>3;
break;
case 2:
srcWidthBytes = ((width+15)>>4)<<1;
break;
case 4:
srcWidthBytes = ((width+31)>>5)<<2;
break;
case 8:
srcWidthBytes = ((width+63)>>6)<<3;
break;
default:
return 0;
}
switch (dstPad) {
case 1:
dstWidthBytes = (width+7)>>3;
break;
case 2:
dstWidthBytes = ((width+15)>>4)<<1;
break;
case 4:
dstWidthBytes = ((width+31)>>5)<<2;
break;
case 8:
dstWidthBytes = ((width+63)>>6)<<3;
break;
default:
return 0;
}
width = srcWidthBytes;
if (width > dstWidthBytes)
width = dstWidthBytes;
pTmpSrc= pSrc;
pTmpDst= pDst;
for (row = 0; row < height; row++)
{
for (col = 0; col < width; col++)
*pTmpDst++ = *pTmpSrc++;
while (col < dstWidthBytes)
{
*pTmpDst++ = '\0';
col++;
}
pTmpSrc += srcWidthBytes - width;
}
return dstWidthBytes * height;
}