Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3df9a5d01c | ||
|
|
2682829bd3 | ||
|
|
30cfa2607d | ||
|
|
4467c2e6ad | ||
|
|
2c0e8a0ddf | ||
|
|
4c17f32a2e | ||
|
|
674220087f | ||
|
|
fc8d5d5799 | ||
|
|
4e4f04c174 | ||
|
|
65c21f3392 | ||
|
|
97fb30cdf1 | ||
|
|
c975279589 | ||
|
|
b3ee7a635f | ||
|
|
c2b12868bb | ||
|
|
bdbb03e16f | ||
|
|
53138d7c16 | ||
|
|
18d1d35104 | ||
|
|
99d9de35de | ||
|
|
e6a48481a5 | ||
|
|
21f2b1224a | ||
|
|
187f47a353 | ||
|
|
cb75b3d6d2 | ||
|
|
27708b9ecb | ||
|
|
5443165fce | ||
|
|
dfb006d264 | ||
|
|
4f00f62674 | ||
|
|
cec527ffd5 | ||
|
|
4f2fe5c988 | ||
|
|
2bf552f801 | ||
|
|
477fa8fedf | ||
|
|
f1c7c5f02c | ||
|
|
4e936193c7 | ||
|
|
f9895c22b6 | ||
|
|
6e46537112 | ||
|
|
92b3918b26 | ||
|
|
34c615a5fd | ||
|
|
fa29260e09 | ||
|
|
a05816b495 | ||
|
|
9c5d847dae | ||
|
|
082e330f9d | ||
|
|
8878c4a136 | ||
|
|
00926bac81 | ||
|
|
67b0907e52 | ||
|
|
dba479774b | ||
|
|
5c8a1e632b | ||
|
|
d65e29111f | ||
|
|
ed170b8092 | ||
|
|
ac36fef968 | ||
|
|
10f6b73cad | ||
|
|
13d933fc07 | ||
|
|
3ba98e86f2 | ||
|
|
1dfca525cf | ||
|
|
e51ad1a68a | ||
|
|
9c76700f74 | ||
|
|
773b1af6f1 | ||
|
|
b8b633a6cc | ||
|
|
ada2270bd1 | ||
|
|
25e5175c54 | ||
|
|
9dcd770df2 | ||
|
|
00a1948b73 | ||
|
|
859a5a5e0c | ||
|
|
6783cf57da | ||
|
|
a8dc5ac14a | ||
|
|
6182553d79 | ||
|
|
905a0cdac1 | ||
|
|
f20ddcf26d | ||
|
|
fe26098c2b | ||
|
|
2354a0a640 | ||
|
|
7c3f09c70c | ||
|
|
caf5350fe6 | ||
|
|
84084835ce | ||
|
|
7f38a67ede | ||
|
|
54383b84ec | ||
|
|
948910bfa2 | ||
|
|
ce5dac07d3 | ||
|
|
d4b0057423 | ||
|
|
de8b12f594 | ||
|
|
69e31a0a37 | ||
|
|
c383cd39f4 | ||
|
|
e88d2f0ab2 | ||
|
|
32535578a0 | ||
|
|
2e9af8fef0 | ||
|
|
0aa87aacc6 | ||
|
|
bc38c302ed | ||
|
|
c724902508 | ||
|
|
73604020d7 | ||
|
|
060a00b9c7 | ||
|
|
2cd32bf25a | ||
|
|
81ad1a18fa | ||
|
|
1d94903eef | ||
|
|
2d7dcb495c | ||
|
|
bc580c9aaa | ||
|
|
f8e2740532 | ||
|
|
a079ecd20b | ||
|
|
89c8725766 | ||
|
|
da7d532564 | ||
|
|
4752d4966d | ||
|
|
50f47f1ed5 | ||
|
|
26bdc3e1d5 | ||
|
|
764360c0f3 | ||
|
|
08482577eb | ||
|
|
cabbba2448 | ||
|
|
c48ed7bb0d | ||
|
|
fa4c0e82bd | ||
|
|
c0bf8b9c25 | ||
|
|
d2cff86c97 | ||
|
|
03c0be0720 | ||
|
|
a3361363e4 | ||
|
|
40e142c5c7 | ||
|
|
2703efedef | ||
|
|
c313f1a20b | ||
|
|
b7116657d9 | ||
|
|
2bf3f1b94b | ||
|
|
b78a7971d9 | ||
|
|
5079bc4976 | ||
|
|
555032c15c | ||
|
|
bcff327565 | ||
|
|
e95ff989b1 | ||
|
|
018e8999e2 | ||
|
|
f624a1817e | ||
|
|
202a643e5a | ||
|
|
c75b9c9221 | ||
|
|
9a6f5ba1a8 | ||
|
|
052194714a | ||
|
|
5ccb4a8b7f | ||
|
|
7c3cec0451 | ||
|
|
b79d3b31b3 | ||
|
|
bf5d43d0cf | ||
|
|
f2ac570949 | ||
|
|
37636ef1eb | ||
|
|
c540bec824 | ||
|
|
9288cfa684 | ||
|
|
b1de8b703b | ||
|
|
ccd0777ce9 | ||
|
|
49b67b3e18 | ||
|
|
bc97168dc7 | ||
|
|
0ec04df334 | ||
|
|
26d7946b4a | ||
|
|
292cc579cf | ||
|
|
8492482e55 | ||
|
|
ac8183feee | ||
|
|
8037fb76fc | ||
|
|
754a14941b | ||
|
|
e32bc1a0a3 | ||
|
|
e5a8b49c93 | ||
|
|
b6872456cd | ||
|
|
2a12b018da | ||
|
|
f64486c88f | ||
|
|
80a40ac5f9 | ||
|
|
a1956350b1 | ||
|
|
2c09875556 | ||
|
|
561eed4cbd | ||
|
|
a8f72df7f8 | ||
|
|
ab4127f940 | ||
|
|
f03d12b677 | ||
|
|
81c6202582 | ||
|
|
6cab2bec61 | ||
|
|
94ffda653c | ||
|
|
c2268b45f6 | ||
|
|
38b8a59fe5 | ||
|
|
640e3213ee | ||
|
|
b1799009b3 | ||
|
|
f8e693a060 | ||
|
|
aba806bc32 | ||
|
|
b1fb3f2391 | ||
|
|
041e901c61 | ||
|
|
bb72134992 | ||
|
|
f83853c2fb | ||
|
|
d5f7b20be3 | ||
|
|
b878d64460 | ||
|
|
5397e8ae1a | ||
|
|
46bd8ad83d | ||
|
|
4dac57cf8c | ||
|
|
95cb026446 | ||
|
|
76ea714257 | ||
|
|
5788fa7204 | ||
|
|
d077c6450f | ||
|
|
4499ed3878 | ||
|
|
feb5e3bc78 | ||
|
|
23f1060756 | ||
|
|
6ed512e762 | ||
|
|
947970e07b | ||
|
|
df567b405a | ||
|
|
7b0596d9df | ||
|
|
4b7200ae69 | ||
|
|
710648f3f4 | ||
|
|
d2002b6a62 | ||
|
|
8de42b3199 | ||
|
|
48e78d2cd3 | ||
|
|
1fd099db70 | ||
|
|
2986a40c5a | ||
|
|
8bb6d4d0d9 | ||
|
|
00f08578ee | ||
|
|
6a514c7f51 | ||
|
|
21aad643f3 | ||
|
|
8687448966 | ||
|
|
6fcc8b721b | ||
|
|
b4bbd58c77 | ||
|
|
1a45b8f07a | ||
|
|
4471a858db | ||
|
|
22e712af5a | ||
|
|
9799b82d53 | ||
|
|
78915e0b99 | ||
|
|
c9cc65aae7 | ||
|
|
a4edd9d202 | ||
|
|
7747624c80 | ||
|
|
aab7191a44 | ||
|
|
1f972b1828 | ||
|
|
58b77cf589 | ||
|
|
c064f87889 | ||
|
|
d6b4c8e7da | ||
|
|
49f0b45fa8 | ||
|
|
b19c4bfc5d | ||
|
|
e944c819d9 | ||
|
|
75f631599c | ||
|
|
e0bebeae25 | ||
|
|
32e7ddf272 | ||
|
|
7091e0324e | ||
|
|
8f8532921c | ||
|
|
e9936992ec | ||
|
|
6375055b3e | ||
|
|
88b1ea296c | ||
|
|
2a13a869f3 | ||
|
|
89c342bb6f | ||
|
|
067f5e33aa | ||
|
|
33695f1c6b | ||
|
|
52ef84873e | ||
|
|
c21ba5c808 | ||
|
|
6cf408f12b | ||
|
|
8bdc2d285d | ||
|
|
a66fbcd6be | ||
|
|
93402a62fc | ||
|
|
2a56fb6c70 | ||
|
|
8276c031e9 | ||
|
|
102e5f6de9 | ||
|
|
1f7bdbfbcb | ||
|
|
f2fdd048c7 | ||
|
|
5a2cfc15a6 | ||
|
|
11c7131875 | ||
|
|
34aacc90d7 | ||
|
|
e75dce2543 | ||
|
|
e2774309fb | ||
|
|
dfefdc93c5 | ||
|
|
d46ea28bba | ||
|
|
d35c5bcaba | ||
|
|
2b14856d7f | ||
|
|
3316fdb80e | ||
|
|
c5d70c48c9 | ||
|
|
82230ef2f5 | ||
|
|
dcfd3d3e48 | ||
|
|
cb1e2ac32e | ||
|
|
ec2c15946a | ||
|
|
8be73142f8 | ||
|
|
d1640e3bb8 | ||
|
|
8612e6726d | ||
|
|
3b4694e9f8 | ||
|
|
14cb2e1999 | ||
|
|
cfabaf334e | ||
|
|
c054536fab | ||
|
|
35aac18b4e | ||
|
|
de3928cb4d | ||
|
|
9bf612b800 | ||
|
|
d9a8d67e3d | ||
|
|
99b0a56a6a | ||
|
|
61d7aa0400 | ||
|
|
1e98594972 | ||
|
|
c6383f042c | ||
|
|
b4d8e0e551 |
@@ -13,19 +13,28 @@ Any special steps that are required for the bug to appear.
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem. If the issue is related to video glitching or poor quality, please include screenshots.
|
||||
|
||||
**Affected games**
|
||||
List the games you've tried that exhibit the issue. To see if the issue is game-specific, try streaming Steam Big Picture with Moonlight and see if the issue persists there.
|
||||
|
||||
**Moonlight settings (please complete the following information)**
|
||||
- Have any settings been adjusted from defaults?
|
||||
- If so, which settings have been changed?
|
||||
- Does the problem still occur after reverting settings back to default?
|
||||
|
||||
**Client PC details (please complete the following information)**
|
||||
- OS: [e.g. Windows 10 1803]
|
||||
- Moonlight Version: [e.g. v0.2.0]
|
||||
- OS: [e.g. Windows 10 1809]
|
||||
- Moonlight Version: [e.g. v0.9.0]
|
||||
|
||||
**Logs (please attach)**
|
||||
**Server PC details (please complete the following information)**
|
||||
- OS: [e.g. Windows 10 1809]
|
||||
- GeForce Experience version: [e.g. 3.16.0.140]
|
||||
- Nvidia GPU driver: [e.g. 417.35]
|
||||
|
||||
**Moonlight Logs (please attach)**
|
||||
- On Windows, `Moonlight-###.log` files can be found in `%TEMP%`. Simply type that into the File Explorer path field to navigate there.
|
||||
- On macOS, `Moonlight-###.log` files can be found in `/tmp`. In Finder, press Cmd+Shift+G, then type `/tmp` to navigate there.
|
||||
- On Linux, logs print to the terminal when running via `flatpak run com.moonlight_stream.Moonlight`
|
||||
- On Linux with the Flatpak, logs print to the terminal when running with the command: `flatpak run com.moonlight_stream.Moonlight`
|
||||
- On Linux with the Snap, logs print to the terminal when running with the command: `moonlight`
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
Anything else you think may be relevant to the issue
|
||||
|
||||
@@ -2,4 +2,6 @@
|
||||
|
||||
|
||||
**/.vs/
|
||||
build/
|
||||
build/
|
||||
config.tests/*/.qmake.stash
|
||||
config.tests/*/Makefile
|
||||
|
||||
@@ -3,6 +3,9 @@ language: cpp
|
||||
git:
|
||||
depth: 1
|
||||
|
||||
env:
|
||||
- NJOBS=2
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- os: osx
|
||||
@@ -14,13 +17,12 @@ matrix:
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- sourceline: 'ppa:beineri/opt-qt596-xenial'
|
||||
- sourceline: 'ppa:beineri/opt-qt597-xenial'
|
||||
- sourceline: 'ppa:jonathonf/ffmpeg-4'
|
||||
packages:
|
||||
- qt59base
|
||||
- qt59quickcontrols2
|
||||
- qt59svg
|
||||
- qt59multimedia
|
||||
- libesd0-dev
|
||||
- libgl-dev
|
||||
- libegl1-mesa-dev
|
||||
@@ -35,7 +37,8 @@ matrix:
|
||||
install:
|
||||
- '[ "$TRAVIS_OS_NAME" != osx ] || brew install qt5'
|
||||
- '[ "$TRAVIS_OS_NAME" != osx ] || brew link --force qt5'
|
||||
- if [[ "$TRAVIS_OS_NAME" = "linux" ]]; then export SDL2_VER=2.0.8 && wget https://www.libsdl.org/release/SDL2-$SDL2_VER.tar.gz && tar -xvf SDL2-$SDL2_VER.tar.gz && cd SDL2-$SDL2_VER && ./configure && make && sudo make install && cd ..; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" = "linux" ]]; then export SDL2_VER=2.0.9 && wget https://www.libsdl.org/release/SDL2-$SDL2_VER.tar.gz && tar -xvf SDL2-$SDL2_VER.tar.gz && cd SDL2-$SDL2_VER && ./configure && make -j$NJOBS && sudo make install && cd ..; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" = "linux" ]]; then export SDL2_TTF_VER=2.0.15 && wget https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-$SDL2_TTF_VER.tar.gz && tar -xvf SDL2_ttf-$SDL2_TTF_VER.tar.gz && cd SDL2_ttf-$SDL2_TTF_VER && ./configure && make -j$NJOBS && sudo make install && cd ..; fi
|
||||
|
||||
before_script:
|
||||
- '[ "$TRAVIS_OS_NAME" != "linux" ] || source /opt/qt59/bin/qt59-env.sh'
|
||||
@@ -46,5 +49,5 @@ before_script:
|
||||
|
||||
script:
|
||||
- qmake moonlight-qt.pro -spec $QMAKESPEC
|
||||
- make debug
|
||||
- make release
|
||||
- make -j$NJOBS debug
|
||||
- make -j$NJOBS release
|
||||
|
||||
@@ -3,11 +3,7 @@ QT -= core gui
|
||||
TARGET = AntiHooking
|
||||
TEMPLATE = lib
|
||||
|
||||
# Support debug and release builds from command line for CI
|
||||
CONFIG += debug_and_release
|
||||
|
||||
# Ensure symbols are always generated
|
||||
CONFIG += force_debug_info
|
||||
include(../globaldefs.pri)
|
||||
|
||||
INCLUDEPATH += $$PWD/../libs/windows/include
|
||||
contains(QT_ARCH, i386) {
|
||||
|
||||
@@ -134,7 +134,11 @@ private:
|
||||
// This DLL shipped with ASUS Sonic Radar 3 improperly handles
|
||||
// D3D9 exclusive fullscreen in a way that causes CreateDeviceEx()
|
||||
// to deadlock. https://github.com/moonlight-stream/moonlight-qt/issues/102
|
||||
L"NahimicOSD.dll"
|
||||
L"NahimicOSD.dll",
|
||||
// This DLL has been seen in several crash reports. Some Googling
|
||||
// suggests it's highly unstable and causes issues in many games.
|
||||
L"EZFRD32.dll",
|
||||
L"EZFRD64.dll",
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -16,41 +16,51 @@ You can follow development on our [Discord server](https://discord.gg/6ERtzFY).
|
||||
- 5.1 surround sound audio
|
||||
- HEVC support for better image quality at reduced bandwidth
|
||||
- Keyboard and mouse support
|
||||
- Gamepad support with SDL gamepad mappings
|
||||
- Gamepad support with force feedback for up to 4 players
|
||||
|
||||
## Downloads
|
||||
- [Windows and macOS](https://github.com/moonlight-stream/moonlight-qt/releases)
|
||||
- [Linux](https://flathub.org/apps/details/com.moonlight_stream.Moonlight)
|
||||
- [Windows, macOS, and Steam Link](https://github.com/moonlight-stream/moonlight-qt/releases)
|
||||
- [Snap (for Ubuntu-based Linux distros)](https://snapcraft.io/moonlight)
|
||||
- [Flatpak (for other Linux distros)](https://flathub.org/apps/details/com.moonlight_stream.Moonlight)
|
||||
|
||||
## Building
|
||||
### General Build Requirements
|
||||
* Qt 5.9 SDK or later
|
||||
|
||||
### Windows-specific Requirements
|
||||
### Windows-specific Build Requirements
|
||||
* Windows 7 or later
|
||||
* Visual Studio 2015 or later
|
||||
* [Visual Studio](https://visualstudio.microsoft.com/downloads/) 2017 (Community edition is fine)
|
||||
* Select MSVC Desktop toolchain during Qt installation
|
||||
* 7-Zip (only if building installers for non-development PCs)
|
||||
* WiX Toolset v3.11 or later (only if building installers for non-development PCs)
|
||||
* [DirectX SDK](https://www.microsoft.com/en-us/download/details.aspx?id=6812)
|
||||
* [7-Zip](https://www.7-zip.org/) (only if building installers for non-development PCs)
|
||||
* [WiX Toolset](http://wixtoolset.org/releases/) v3.11 or later (only if building installers for non-development PCs)
|
||||
|
||||
### Mac-specific Requirements
|
||||
* macOS El Capitan (10.11) or later
|
||||
* Xcode with High Sierra (10.13) SDK (Mojave SDK not yet supported until Qt 5.12 later this year)
|
||||
### Mac-specific Build Requirements
|
||||
* macOS Sierra (10.12) or later
|
||||
* Xcode 10
|
||||
* [create-dmg](https://github.com/sindresorhus/create-dmg) (only if building DMGs for use on non-development Macs)
|
||||
|
||||
### Linux-specific Requirements
|
||||
### Linux-specific Build Requirements
|
||||
* GCC or Clang
|
||||
* Install your distro equivalents of: `openssl-devel qt5-devel SDL2-devel ffmpeg-devel qt5-qtquickcontrols2-devel libva-devel libvdpau-devel opus-devel`
|
||||
* Install your distro equivalents of: `openssl-devel qt5-devel SDL2-devel ffmpeg-devel qt5-qtquickcontrols2-devel libva-devel libvdpau-devel opus-devel pulseaudio-libs-devel alsa-lib-devel SDL2_ttf-devel`
|
||||
* FFmpeg 4.0 is required to build. If your distro doesn't package FFmpeg 4.0, you can build and install it from source on http://ffmpeg.org/
|
||||
|
||||
### Steam Link-specific Build Requirements
|
||||
* [Steam Link SDK](https://github.com/ValveSoftware/steamlink-sdk) cloned on your build system
|
||||
* STEAMLINK_SDK_PATH environment variable set to the Steam Link SDK path
|
||||
|
||||
### Build Setup Steps
|
||||
1. Install the latest Qt SDK (and optionally, the Qt Creator IDE) from https://www.qt.io/download
|
||||
* You may also use Homebrew on macOS or your Linux distro's package manager for the Qt SDK as long as the packages are Qt 5.9 or later.
|
||||
* You can install Qt via Homebrew on macOS, but you will need to use `brew install qt --with-debug` to be able to create debug builds of Moonlight.
|
||||
* You may also use your Linux distro's package manager for the Qt SDK as long as the packages are Qt 5.9 or later.
|
||||
* This step is not required for building on Steam Link, because the Steam Link SDK includes Qt 5.9.
|
||||
2. Run `git submodule update --init --recursive` from within `moonlight-qt/`
|
||||
3. Open the project in Qt Creator or build from qmake on the command line.
|
||||
* To build a binary for use on non-development machines, use the scripts in the `scripts` folder.
|
||||
* For Windows builds, use `scripts\generate-installers.bat`. Execute this script from the root of the repository within a Qt command prompt. Ensure WiX and 7-Zip binary directories are in your `%PATH%`.
|
||||
* For macOS builds, use `scripts/generate-dmg.sh`. Execute this script from the root of the repository and ensure Qt's `bin` folder is in your `$PATH`.
|
||||
* For Steam Link builds, run `scripts/build-steamlink-app.sh` from the root of the repository.
|
||||
* To build from the command line for development use, run `qmake moonlight-qt.pro` then `make debug` or `make release`
|
||||
|
||||
## Contribute
|
||||
1. Fork us
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
<key>NSSupportsAutomaticGraphicsSwitching</key>
|
||||
<true/>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>0.7.0</string>
|
||||
<string>VERSION</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>0.7.0</string>
|
||||
<string>VERSION</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>Moonlight</string>
|
||||
</dict>
|
||||
|
||||
@@ -8,11 +8,7 @@ unix:!macx {
|
||||
TARGET = Moonlight
|
||||
}
|
||||
|
||||
# Support debug and release builds from command line for CI
|
||||
CONFIG += debug_and_release
|
||||
|
||||
# Ensure symbols are always generated
|
||||
CONFIG += force_debug_info
|
||||
include(../globaldefs.pri)
|
||||
|
||||
# Precompile QML files to avoid writing qmlcache on portable versions.
|
||||
# Since this binds the app against the Qt runtime version, we will only
|
||||
@@ -37,32 +33,44 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
||||
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
win32 {
|
||||
INCLUDEPATH += $$PWD/../libs/windows/include
|
||||
INCLUDEPATH += \
|
||||
$$PWD/../libs/windows/include \
|
||||
$$(DXSDK_DIR)/Include
|
||||
|
||||
contains(QT_ARCH, i386) {
|
||||
LIBS += -L$$PWD/../libs/windows/lib/x86
|
||||
LIBS += -L$$(DXSDK_DIR)/Lib/x86
|
||||
}
|
||||
contains(QT_ARCH, x86_64) {
|
||||
LIBS += -L$$PWD/../libs/windows/lib/x64
|
||||
LIBS += -L$$(DXSDK_DIR)/Lib/x64
|
||||
}
|
||||
|
||||
LIBS += ws2_32.lib winmm.lib dxva2.lib ole32.lib gdi32.lib user32.lib d3d9.lib dwmapi.lib dbghelp.lib
|
||||
}
|
||||
macx {
|
||||
INCLUDEPATH += $$PWD/../libs/mac/include $$PWD/../libs/mac/Frameworks/SDL2.framework/Versions/A/Headers
|
||||
INCLUDEPATH += $$PWD/../libs/mac/include
|
||||
INCLUDEPATH += $$PWD/../libs/mac/Frameworks/SDL2.framework/Versions/A/Headers
|
||||
INCLUDEPATH += $$PWD/../libs/mac/Frameworks/SDL2_ttf.framework/Versions/A/Headers
|
||||
LIBS += -L$$PWD/../libs/mac/lib -F$$PWD/../libs/mac/Frameworks
|
||||
}
|
||||
|
||||
unix:!macx {
|
||||
CONFIG += link_pkgconfig soundio
|
||||
PKGCONFIG += openssl sdl2 opus
|
||||
CONFIG += link_pkgconfig
|
||||
PKGCONFIG += openssl sdl2 SDL2_ttf opus
|
||||
|
||||
# For libsoundio
|
||||
packagesExist(libpulse) {
|
||||
PKGCONFIG += libpulse
|
||||
# SLAudio is used on Steam Link
|
||||
!config_SL {
|
||||
CONFIG += soundio
|
||||
}
|
||||
packagesExist(alsa) {
|
||||
PKGCONFIG += alsa
|
||||
|
||||
soundio {
|
||||
packagesExist(libpulse) {
|
||||
PKGCONFIG += libpulse
|
||||
}
|
||||
packagesExist(alsa) {
|
||||
PKGCONFIG += alsa
|
||||
}
|
||||
}
|
||||
|
||||
packagesExist(libavcodec) {
|
||||
@@ -82,14 +90,27 @@ unix:!macx {
|
||||
packagesExist(vdpau) {
|
||||
CONFIG += libvdpau
|
||||
}
|
||||
|
||||
packagesExist(mmal) {
|
||||
PKGCONFIG += mmal
|
||||
CONFIG += mmal
|
||||
}
|
||||
|
||||
packagesExist(libdrm) {
|
||||
PKGCONFIG += libdrm
|
||||
CONFIG += libdrm
|
||||
}
|
||||
}
|
||||
}
|
||||
win32 {
|
||||
LIBS += -llibssl -llibcrypto -lSDL2 -lavcodec -lavutil -lopus
|
||||
CONFIG += ffmpeg soundio
|
||||
LIBS += -llibssl -llibcrypto -lSDL2 -lSDL2_ttf -lavcodec -lavutil -lopus -ld3dx9
|
||||
CONFIG += ffmpeg
|
||||
}
|
||||
win32:!winrt {
|
||||
CONFIG += soundio
|
||||
}
|
||||
macx {
|
||||
LIBS += -lssl -lcrypto -lavcodec.58 -lavutil.56 -lopus -framework SDL2
|
||||
LIBS += -lssl -lcrypto -lavcodec.58 -lavutil.56 -lopus -framework SDL2 -framework SDL2_ttf
|
||||
LIBS += -lobjc -framework VideoToolbox -framework AVFoundation -framework CoreVideo -framework CoreGraphics -framework CoreMedia -framework AppKit
|
||||
|
||||
# For libsoundio
|
||||
@@ -121,7 +142,9 @@ SOURCES += \
|
||||
backend/autoupdatechecker.cpp \
|
||||
path.cpp \
|
||||
settings/mappingmanager.cpp \
|
||||
gui/sdlgamepadkeynavigation.cpp
|
||||
gui/sdlgamepadkeynavigation.cpp \
|
||||
streaming/video/overlaymanager.cpp \
|
||||
backend/systemproperties.cpp
|
||||
|
||||
HEADERS += \
|
||||
utils.h \
|
||||
@@ -147,7 +170,9 @@ HEADERS += \
|
||||
backend/autoupdatechecker.h \
|
||||
path.h \
|
||||
settings/mappingmanager.h \
|
||||
gui/sdlgamepadkeynavigation.h
|
||||
gui/sdlgamepadkeynavigation.h \
|
||||
streaming/video/overlaymanager.h \
|
||||
backend/systemproperties.h
|
||||
|
||||
# Platform-specific renderers and decoders
|
||||
ffmpeg {
|
||||
@@ -160,10 +185,10 @@ ffmpeg {
|
||||
streaming/video/ffmpeg-renderers/pacer/pacer.cpp \
|
||||
streaming/video/ffmpeg-renderers/pacer/nullthreadedvsyncsource.cpp
|
||||
|
||||
|
||||
HEADERS += \
|
||||
streaming/video/ffmpeg.h \
|
||||
streaming/video/ffmpeg-renderers/renderer.h \
|
||||
streaming/video/ffmpeg-renderers/sdlvid.h \
|
||||
streaming/video/ffmpeg-renderers/pacer/pacer.h \
|
||||
streaming/video/ffmpeg-renderers/pacer/nullthreadedvsyncsource.h
|
||||
}
|
||||
@@ -194,16 +219,34 @@ libvdpau {
|
||||
SOURCES += streaming/video/ffmpeg-renderers/vdpau.cpp
|
||||
HEADERS += streaming/video/ffmpeg-renderers/vdpau.h
|
||||
}
|
||||
config_SLVideo {
|
||||
message(SLVideo decoder/renderer selected)
|
||||
mmal {
|
||||
message(MMAL renderer selected)
|
||||
|
||||
DEFINES += HAVE_SLVIDEO
|
||||
LIBS += -lSLVideo
|
||||
|
||||
SOURCES += streaming/video/sl.cpp
|
||||
HEADERS += streaming/video/sl.h
|
||||
DEFINES += HAVE_MMAL
|
||||
SOURCES += streaming/video/ffmpeg-renderers/mmal.cpp
|
||||
HEADERS += streaming/video/ffmpeg-renderers/mmal.h
|
||||
}
|
||||
win32 {
|
||||
libdrm {
|
||||
message(DRM renderer selected)
|
||||
|
||||
DEFINES += HAVE_DRM
|
||||
SOURCES += streaming/video/ffmpeg-renderers/drm.cpp
|
||||
HEADERS += streaming/video/ffmpeg-renderers/drm.h
|
||||
}
|
||||
config_SL {
|
||||
message(Steam Link build configuration selected)
|
||||
|
||||
DEFINES += STEAM_LINK HAVE_SLVIDEO HAVE_SLAUDIO
|
||||
LIBS += -lSLVideo -lSLAudio
|
||||
|
||||
SOURCES += \
|
||||
streaming/video/slvid.cpp \
|
||||
streaming/audio/renderers/slaud.cpp
|
||||
HEADERS += \
|
||||
streaming/video/slvid.h \
|
||||
streaming/audio/renderers/slaud.h
|
||||
}
|
||||
win32:!winrt {
|
||||
message(DXVA2 renderer selected)
|
||||
|
||||
SOURCES += \
|
||||
@@ -218,12 +261,10 @@ macx {
|
||||
message(VideoToolbox renderer selected)
|
||||
|
||||
SOURCES += \
|
||||
streaming/video/ffmpeg-renderers/vt.mm \
|
||||
streaming/video/ffmpeg-renderers/pacer/displaylinkvsyncsource.mm
|
||||
streaming/video/ffmpeg-renderers/vt.mm
|
||||
|
||||
HEADERS += \
|
||||
streaming/video/ffmpeg-renderers/vt.h \
|
||||
streaming/video/ffmpeg-renderers/pacer/displaylinkvsyncsource.h
|
||||
streaming/video/ffmpeg-renderers/vt.h
|
||||
}
|
||||
soundio {
|
||||
message(libsoundio audio renderer selected)
|
||||
@@ -257,12 +298,14 @@ else:unix: LIBS += -L$$OUT_PWD/../qmdnsengine/ -lqmdnsengine
|
||||
INCLUDEPATH += $$PWD/../qmdnsengine/qmdnsengine/src/include $$PWD/../qmdnsengine
|
||||
DEPENDPATH += $$PWD/../qmdnsengine/qmdnsengine/src/include $$PWD/../qmdnsengine
|
||||
|
||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../soundio/release/ -lsoundio
|
||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../soundio/debug/ -lsoundio
|
||||
else:unix: LIBS += -L$$OUT_PWD/../soundio/ -lsoundio
|
||||
soundio {
|
||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../soundio/release/ -lsoundio
|
||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../soundio/debug/ -lsoundio
|
||||
else:unix: LIBS += -L$$OUT_PWD/../soundio/ -lsoundio
|
||||
|
||||
INCLUDEPATH += $$PWD/../soundio/libsoundio
|
||||
DEPENDPATH += $$PWD/../soundio/libsoundio
|
||||
INCLUDEPATH += $$PWD/../soundio/libsoundio
|
||||
DEPENDPATH += $$PWD/../soundio/libsoundio
|
||||
}
|
||||
|
||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../h264bitstream/release/ -lh264bitstream
|
||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../h264bitstream/debug/ -lh264bitstream
|
||||
@@ -271,11 +314,13 @@ else:unix: LIBS += -L$$OUT_PWD/../h264bitstream/ -lh264bitstream
|
||||
INCLUDEPATH += $$PWD/../h264bitstream/h264bitstream
|
||||
DEPENDPATH += $$PWD/../h264bitstream/h264bitstream
|
||||
|
||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../AntiHooking/release/ -lAntiHooking
|
||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../AntiHooking/debug/ -lAntiHooking
|
||||
!winrt {
|
||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../AntiHooking/release/ -lAntiHooking
|
||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../AntiHooking/debug/ -lAntiHooking
|
||||
|
||||
INCLUDEPATH += $$PWD/../AntiHooking
|
||||
DEPENDPATH += $$PWD/../AntiHooking
|
||||
INCLUDEPATH += $$PWD/../AntiHooking
|
||||
DEPENDPATH += $$PWD/../AntiHooking
|
||||
}
|
||||
|
||||
unix:!macx: {
|
||||
isEmpty(PREFIX) {
|
||||
@@ -299,10 +344,7 @@ unix:!macx: {
|
||||
appstream.files = deploy/linux/com.moonlight_stream.Moonlight.appdata.xml
|
||||
appstream.path = $$PREFIX/$$DATADIR/metainfo/
|
||||
|
||||
appdata.files = SDL_GameControllerDB/gamecontrollerdb.txt
|
||||
appdata.path = "$$PREFIX/$$DATADIR/Moonlight Game Streaming Project/Moonlight/"
|
||||
|
||||
INSTALLS += target appdata desktop icons appstream
|
||||
INSTALLS += target desktop icons appstream
|
||||
}
|
||||
win32 {
|
||||
RC_ICONS = moonlight.ico
|
||||
@@ -314,9 +356,13 @@ win32 {
|
||||
QMAKE_LFLAGS += /MANIFEST:embed /MANIFESTINPUT:$${PWD}/Moonlight.exe.manifest
|
||||
}
|
||||
macx {
|
||||
QMAKE_INFO_PLIST = $$PWD/Info.plist
|
||||
# Create Info.plist in object dir with the correct version string
|
||||
system(cp $$PWD/Info.plist $$OUT_PWD/Info.plist)
|
||||
system(sed -i -e 's/VERSION/$$cat(version.txt)/g' $$OUT_PWD/Info.plist)
|
||||
|
||||
APP_BUNDLE_RESOURCES.files = moonlight.icns SDL_GameControllerDB/gamecontrollerdb.txt
|
||||
QMAKE_INFO_PLIST = $$OUT_PWD/Info.plist
|
||||
|
||||
APP_BUNDLE_RESOURCES.files = moonlight.icns
|
||||
APP_BUNDLE_RESOURCES.path = Contents/Resources
|
||||
|
||||
APP_BUNDLE_FRAMEWORKS.files = $$files(../libs/mac/Frameworks/*.framework, true)
|
||||
@@ -327,5 +373,5 @@ macx {
|
||||
QMAKE_RPATHDIR += @executable_path/../Frameworks
|
||||
}
|
||||
|
||||
VERSION = 0.7.0
|
||||
DEFINES += VERSION_STR=\\\"0.7.0\\\"
|
||||
VERSION = "$$cat(version.txt)"
|
||||
DEFINES += VERSION_STR=\\\"$$cat(version.txt)\\\"
|
||||
|
||||
@@ -116,7 +116,8 @@ void AutoUpdateChecker::handleUpdateCheckRequestFinished(QNetworkReply* reply)
|
||||
if (currentVer < latestVer) {
|
||||
qDebug() << "Update available";
|
||||
|
||||
emit onUpdateAvailable(updateObj["browser_url"].toString());
|
||||
emit onUpdateAvailable(updateObj["version"].toString(),
|
||||
updateObj["browser_url"].toString());
|
||||
return;
|
||||
}
|
||||
else if (currentVer > latestVer) {
|
||||
|
||||
@@ -12,7 +12,7 @@ public:
|
||||
Q_INVOKABLE void start();
|
||||
|
||||
signals:
|
||||
void onUpdateAvailable(QString url);
|
||||
void onUpdateAvailable(QString newVersion, QString url);
|
||||
|
||||
private slots:
|
||||
void handleUpdateCheckRequestFinished(QNetworkReply* reply);
|
||||
|
||||
@@ -89,15 +89,14 @@ QUrl BoxArtManager::loadBoxArt(NvComputer* computer, NvApp& app)
|
||||
|
||||
void BoxArtManager::handleBoxArtLoadComplete(NvComputer* computer, NvApp app, QUrl image)
|
||||
{
|
||||
if (image.isEmpty()) {
|
||||
image = QUrl("qrc:/res/no_app_image.png");
|
||||
if (!image.isEmpty()) {
|
||||
emit boxArtLoadComplete(computer, app, image);
|
||||
}
|
||||
emit boxArtLoadComplete(computer, app, image);
|
||||
}
|
||||
|
||||
QUrl BoxArtManager::loadBoxArtFromNetwork(NvComputer* computer, int appId)
|
||||
{
|
||||
NvHTTP http(computer->activeAddress);
|
||||
NvHTTP http(computer->activeAddress, computer->serverCert);
|
||||
|
||||
QString cachePath = getFilePathForBoxArt(computer, appId);
|
||||
QImage image;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <QThread>
|
||||
#include <QThreadPool>
|
||||
#include <QCoreApplication>
|
||||
|
||||
#define SER_HOSTS "hosts"
|
||||
|
||||
@@ -27,16 +28,16 @@ public:
|
||||
private:
|
||||
bool tryPollComputer(QString address, bool& changed)
|
||||
{
|
||||
NvHTTP http(address);
|
||||
NvHTTP http(address, m_Computer->serverCert);
|
||||
|
||||
QString serverInfo;
|
||||
try {
|
||||
serverInfo = http.getServerInfo(NvHTTP::NvLogLevel::NONE);
|
||||
serverInfo = http.getServerInfo(NvHTTP::NvLogLevel::NVLL_NONE);
|
||||
} catch (...) {
|
||||
return false;
|
||||
}
|
||||
|
||||
NvComputer newState(address, serverInfo);
|
||||
NvComputer newState(address, serverInfo, QSslCertificate());
|
||||
|
||||
// Ensure the machine that responded is the one we intended to contact
|
||||
if (m_Computer->uuid != newState.uuid) {
|
||||
@@ -52,7 +53,7 @@ private:
|
||||
{
|
||||
Q_ASSERT(m_Computer->activeAddress != nullptr);
|
||||
|
||||
NvHTTP http(m_Computer->activeAddress);
|
||||
NvHTTP http(m_Computer->activeAddress, m_Computer->serverCert);
|
||||
|
||||
QVector<NvApp> appList;
|
||||
|
||||
@@ -130,8 +131,12 @@ private:
|
||||
emit computerStateChanged(m_Computer);
|
||||
}
|
||||
|
||||
// Wait a bit to poll again
|
||||
QThread::sleep(3);
|
||||
// Wait a bit to poll again, but do it in 100 ms chunks
|
||||
// so we can be interrupted reasonably quickly.
|
||||
// FIXME: QWaitCondition would be better.
|
||||
for (int i = 0; i < 30 && !isInterruptionRequested(); i++) {
|
||||
QThread::msleep(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,6 +162,13 @@ ComputerManager::ComputerManager(QObject *parent)
|
||||
m_KnownHosts[computer->uuid] = computer;
|
||||
}
|
||||
settings.endArray();
|
||||
|
||||
// To quit in a timely manner, we must block additional requests
|
||||
// after we receive the aboutToQuit() signal. This is neccessary
|
||||
// because NvHTTP uses aboutToQuit() to abort requests in progres
|
||||
// while quitting, however this is a one time signal - additional
|
||||
// requests would not be aborted and block termination.
|
||||
connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(handleAboutToQuit()));
|
||||
}
|
||||
|
||||
ComputerManager::~ComputerManager()
|
||||
@@ -174,38 +186,19 @@ ComputerManager::~ComputerManager()
|
||||
delete m_MdnsBrowser;
|
||||
m_MdnsBrowser = nullptr;
|
||||
|
||||
{
|
||||
QMutableMapIterator<QString, QThread*> i(m_PollThreads);
|
||||
|
||||
// Interrupt all polling threads
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
i.value()->requestInterruption();
|
||||
}
|
||||
|
||||
// Wait for all threads to terminate before destroying
|
||||
// the NvComputer objects.
|
||||
i.toFront();
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
|
||||
QThread* thread = i.value();
|
||||
thread->wait();
|
||||
delete thread;
|
||||
|
||||
i.remove();
|
||||
}
|
||||
// Interrupt polling
|
||||
for (ComputerPollingEntry* entry : m_PollEntries) {
|
||||
entry->interrupt();
|
||||
}
|
||||
|
||||
{
|
||||
QMutableMapIterator<QString, NvComputer*> i(m_KnownHosts);
|
||||
// Delete all polling entries (and associated threads)
|
||||
for (ComputerPollingEntry* entry : m_PollEntries) {
|
||||
delete entry;
|
||||
}
|
||||
|
||||
// Destroy all NvComputer objects
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
delete i.value();
|
||||
i.remove();
|
||||
}
|
||||
// Destroy all NvComputer objects now that polling is halted
|
||||
for (NvComputer* computer : m_KnownHosts) {
|
||||
delete computer;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,7 +211,7 @@ void ComputerManager::saveHosts()
|
||||
settings.beginWriteArray(SER_HOSTS);
|
||||
for (int i = 0; i < m_KnownHosts.count(); i++) {
|
||||
settings.setArrayIndex(i);
|
||||
m_KnownHosts[m_KnownHosts.keys()[i]]->serialize(settings);
|
||||
m_KnownHosts.value(m_KnownHosts.keys()[i])->serialize(settings);
|
||||
}
|
||||
settings.endArray();
|
||||
}
|
||||
@@ -265,16 +258,22 @@ void ComputerManager::startPollingComputer(NvComputer* computer)
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_PollThreads.contains(computer->uuid)) {
|
||||
Q_ASSERT(m_PollThreads[computer->uuid]->isRunning());
|
||||
return;
|
||||
ComputerPollingEntry* pollingEntry;
|
||||
|
||||
if (!m_PollEntries.contains(computer->uuid)) {
|
||||
pollingEntry = m_PollEntries[computer->uuid] = new ComputerPollingEntry();
|
||||
}
|
||||
else {
|
||||
pollingEntry = m_PollEntries[computer->uuid];
|
||||
}
|
||||
|
||||
PcMonitorThread* thread = new PcMonitorThread(computer);
|
||||
connect(thread, SIGNAL(computerStateChanged(NvComputer*)),
|
||||
this, SLOT(handleComputerStateChanged(NvComputer*)));
|
||||
m_PollThreads[computer->uuid] = thread;
|
||||
thread->start();
|
||||
if (!pollingEntry->isActive()) {
|
||||
PcMonitorThread* thread = new PcMonitorThread(computer);
|
||||
connect(thread, SIGNAL(computerStateChanged(NvComputer*)),
|
||||
this, SLOT(handleComputerStateChanged(NvComputer*)));
|
||||
pollingEntry->setActiveThread(thread);
|
||||
thread->start();
|
||||
}
|
||||
}
|
||||
|
||||
void ComputerManager::handleMdnsServiceResolved(MdnsPendingComputer* computer,
|
||||
@@ -317,34 +316,23 @@ public:
|
||||
|
||||
void run()
|
||||
{
|
||||
QThread* pollingThread;
|
||||
ComputerPollingEntry* pollingEntry;
|
||||
|
||||
// Only do the minimum amount of work while holding the writer lock.
|
||||
// We must release it before calling saveHosts().
|
||||
{
|
||||
QWriteLocker lock(&m_ComputerManager->m_Lock);
|
||||
|
||||
pollingThread = m_ComputerManager->m_PollThreads[m_Computer->uuid];
|
||||
pollingEntry = m_ComputerManager->m_PollEntries.take(m_Computer->uuid);
|
||||
|
||||
m_ComputerManager->m_PollThreads.remove(m_Computer->uuid);
|
||||
m_ComputerManager->m_KnownHosts.remove(m_Computer->uuid);
|
||||
}
|
||||
|
||||
// Persist the new host list
|
||||
m_ComputerManager->saveHosts();
|
||||
|
||||
// Delete the polling thread
|
||||
if (pollingThread != nullptr) {
|
||||
pollingThread->requestInterruption();
|
||||
|
||||
// We must wait here because we're going to delete computer
|
||||
// and we can't do that out from underneath the poller.
|
||||
pollingThread->wait();
|
||||
|
||||
// The thread is safe to delete now
|
||||
Q_ASSERT(pollingThread->isFinished());
|
||||
delete pollingThread;
|
||||
}
|
||||
// Delete the polling entry first. This will stop all polling threads too.
|
||||
delete pollingEntry;
|
||||
|
||||
// Finally, delete the computer itself. This must be done
|
||||
// last because the polling thread might be using it.
|
||||
@@ -363,6 +351,17 @@ void ComputerManager::deleteHost(NvComputer* computer)
|
||||
QThreadPool::globalInstance()->start(new DeferredHostDeletionTask(this, computer));
|
||||
}
|
||||
|
||||
void ComputerManager::handleAboutToQuit()
|
||||
{
|
||||
QWriteLocker lock(&m_Lock);
|
||||
|
||||
// Interrupt polling threads immediately, so they
|
||||
// avoid making additional requests while quitting
|
||||
for (ComputerPollingEntry* entry : m_PollEntries) {
|
||||
entry->interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
class PendingPairingTask : public QObject, public QRunnable
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -385,7 +384,7 @@ private:
|
||||
NvPairingManager pairingManager(m_Computer->activeAddress);
|
||||
|
||||
try {
|
||||
NvPairingManager::PairState result = pairingManager.pair(m_Computer->appVersion, m_Pin);
|
||||
NvPairingManager::PairState result = pairingManager.pair(m_Computer->appVersion, m_Pin, m_Computer->serverCert);
|
||||
switch (result)
|
||||
{
|
||||
case NvPairingManager::PairState::PIN_WRONG:
|
||||
@@ -402,7 +401,7 @@ private:
|
||||
break;
|
||||
}
|
||||
} catch (const GfeHttpResponseException& e) {
|
||||
emit pairingCompleted(m_Computer, e.toQString());
|
||||
emit pairingCompleted(m_Computer, "GeForce Experience returned error: " + e.toQString());
|
||||
} catch (const QtNetworkReplyException& e) {
|
||||
emit pairingCompleted(m_Computer, e.toQString());
|
||||
}
|
||||
@@ -438,7 +437,7 @@ signals:
|
||||
private:
|
||||
void run()
|
||||
{
|
||||
NvHTTP http(m_Computer->activeAddress);
|
||||
NvHTTP http(m_Computer->activeAddress, m_Computer->serverCert);
|
||||
|
||||
try {
|
||||
if (m_Computer->currentGameId != 0) {
|
||||
@@ -499,20 +498,8 @@ void ComputerManager::stopPollingAsync()
|
||||
m_MdnsBrowser = nullptr;
|
||||
|
||||
// Interrupt all threads, but don't wait for them to terminate
|
||||
QMutableMapIterator<QString, QThread*> i(m_PollThreads);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
|
||||
QThread* thread = i.value();
|
||||
|
||||
// Let this thread delete itself when it's finished
|
||||
connect(thread, SIGNAL(finished()),
|
||||
thread, SLOT(deleteLater()));
|
||||
|
||||
// The threads will delete themselves when they terminate,
|
||||
// but we remove them from the polling threads map here.
|
||||
i.value()->requestInterruption();
|
||||
i.remove();
|
||||
for (ComputerPollingEntry* entry : m_PollEntries) {
|
||||
entry->interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -538,12 +525,8 @@ signals:
|
||||
void computerStateChanged(NvComputer* computer);
|
||||
|
||||
private:
|
||||
void run()
|
||||
QString fetchServerInfo(NvHTTP& http)
|
||||
{
|
||||
NvHTTP http(m_Address);
|
||||
|
||||
qInfo() << "Processing new PC at" << m_Address << "from" << (m_Mdns ? "mDNS" : "user");
|
||||
|
||||
QString serverInfo;
|
||||
try {
|
||||
// There's a race condition between GameStream servers reporting presence over
|
||||
@@ -551,12 +534,12 @@ private:
|
||||
// around this issue, we will issue the request again after a few seconds if
|
||||
// we see a ServiceUnavailableError error.
|
||||
try {
|
||||
serverInfo = http.getServerInfo(NvHTTP::NvLogLevel::VERBOSE);
|
||||
serverInfo = http.getServerInfo(NvHTTP::NVLL_VERBOSE);
|
||||
} catch (const QtNetworkReplyException& e) {
|
||||
if (e.getError() == QNetworkReply::ServiceUnavailableError) {
|
||||
qWarning() << "Retrying request in 5 seconds after ServiceUnavailableError";
|
||||
QThread::sleep(5);
|
||||
serverInfo = http.getServerInfo(NvHTTP::NvLogLevel::VERBOSE);
|
||||
serverInfo = http.getServerInfo(NvHTTP::NVLL_VERBOSE);
|
||||
qInfo() << "Retry successful";
|
||||
}
|
||||
else {
|
||||
@@ -564,14 +547,51 @@ private:
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
return serverInfo;
|
||||
} catch (...) {
|
||||
if (!m_Mdns) {
|
||||
emit computerAddCompleted(false);
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
void run()
|
||||
{
|
||||
NvHTTP http(m_Address, QSslCertificate());
|
||||
|
||||
qInfo() << "Processing new PC at" << m_Address << "from" << (m_Mdns ? "mDNS" : "user");
|
||||
|
||||
// Perform initial serverinfo fetch over HTTP since we don't know which cert to use
|
||||
QString serverInfo = fetchServerInfo(http);
|
||||
if (serverInfo.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
NvComputer* newComputer = new NvComputer(m_Address, serverInfo);
|
||||
// Create initial newComputer using HTTP serverinfo with no pinned cert
|
||||
NvComputer* newComputer = new NvComputer(m_Address, serverInfo, QSslCertificate());
|
||||
|
||||
// Check if we have a record of this host UUID to pull the pinned cert
|
||||
NvComputer* existingComputer;
|
||||
{
|
||||
QReadLocker lock(&m_ComputerManager->m_Lock);
|
||||
existingComputer = m_ComputerManager->m_KnownHosts.value(newComputer->uuid);
|
||||
if (existingComputer != nullptr) {
|
||||
http.setServerCert(existingComputer->serverCert);
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch serverinfo again over HTTPS with the pinned cert
|
||||
if (existingComputer != nullptr) {
|
||||
serverInfo = fetchServerInfo(http);
|
||||
if (serverInfo.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Update the polled computer with the HTTPS information
|
||||
NvComputer httpsComputer(m_Address, serverInfo, QSslCertificate());
|
||||
newComputer->update(httpsComputer);
|
||||
}
|
||||
|
||||
// Update addresses depending on the context
|
||||
if (m_Mdns) {
|
||||
@@ -579,7 +599,7 @@ private:
|
||||
|
||||
// Get the WAN IP address using STUN if we're on mDNS
|
||||
quint32 addr;
|
||||
int err = LiFindExternalAddressIP4("stun.stunprotocol.org", 3478, &addr);
|
||||
int err = LiFindExternalAddressIP4("stun.moonlight-stream.org", 3478, &addr);
|
||||
if (err == 0) {
|
||||
newComputer->remoteAddress = QHostAddress(qFromBigEndian(addr)).toString();
|
||||
}
|
||||
@@ -591,46 +611,48 @@ private:
|
||||
newComputer->manualAddress = m_Address;
|
||||
}
|
||||
|
||||
// Check if this PC already exists
|
||||
QWriteLocker lock(&m_ComputerManager->m_Lock);
|
||||
NvComputer* existingComputer = m_ComputerManager->m_KnownHosts[newComputer->uuid];
|
||||
if (existingComputer != nullptr) {
|
||||
// Fold it into the existing PC
|
||||
bool changed = existingComputer->update(*newComputer);
|
||||
delete newComputer;
|
||||
{
|
||||
// Check if this PC already exists
|
||||
QWriteLocker lock(&m_ComputerManager->m_Lock);
|
||||
NvComputer* existingComputer = m_ComputerManager->m_KnownHosts.value(newComputer->uuid);
|
||||
if (existingComputer != nullptr) {
|
||||
// Fold it into the existing PC
|
||||
bool changed = existingComputer->update(*newComputer);
|
||||
delete newComputer;
|
||||
|
||||
// Drop the lock before notifying
|
||||
lock.unlock();
|
||||
// Drop the lock before notifying
|
||||
lock.unlock();
|
||||
|
||||
// For non-mDNS clients, let them know it succeeded
|
||||
if (!m_Mdns) {
|
||||
emit computerAddCompleted(true);
|
||||
// For non-mDNS clients, let them know it succeeded
|
||||
if (!m_Mdns) {
|
||||
emit computerAddCompleted(true);
|
||||
}
|
||||
|
||||
// Tell our client if something changed
|
||||
if (changed) {
|
||||
qInfo() << existingComputer->name << "is now at" << existingComputer->activeAddress;
|
||||
emit computerStateChanged(existingComputer);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Store this in our active sets
|
||||
m_ComputerManager->m_KnownHosts[newComputer->uuid] = newComputer;
|
||||
|
||||
// Tell our client if something changed
|
||||
if (changed) {
|
||||
qInfo() << existingComputer->name << "is now at" << existingComputer->activeAddress;
|
||||
emit computerStateChanged(existingComputer);
|
||||
// Start polling if enabled (write lock required)
|
||||
m_ComputerManager->startPollingComputer(newComputer);
|
||||
|
||||
// Drop the lock before notifying
|
||||
lock.unlock();
|
||||
|
||||
// For non-mDNS clients, let them know it succeeded
|
||||
if (!m_Mdns) {
|
||||
emit computerAddCompleted(true);
|
||||
}
|
||||
|
||||
// Tell our client about this new PC
|
||||
emit computerStateChanged(newComputer);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Store this in our active sets
|
||||
m_ComputerManager->m_KnownHosts[newComputer->uuid] = newComputer;
|
||||
|
||||
// Start polling if enabled (write lock required)
|
||||
m_ComputerManager->startPollingComputer(newComputer);
|
||||
|
||||
// Drop the lock before notifying
|
||||
lock.unlock();
|
||||
|
||||
// For non-mDNS clients, let them know it succeeded
|
||||
if (!m_Mdns) {
|
||||
emit computerAddCompleted(true);
|
||||
}
|
||||
|
||||
// Tell our client about this new PC
|
||||
emit computerStateChanged(newComputer);
|
||||
}
|
||||
}
|
||||
|
||||
ComputerManager* m_ComputerManager;
|
||||
|
||||
@@ -51,6 +51,79 @@ private:
|
||||
QMdnsEngine::Resolver m_Resolver;
|
||||
};
|
||||
|
||||
class ComputerPollingEntry
|
||||
{
|
||||
public:
|
||||
ComputerPollingEntry()
|
||||
: m_ActiveThread(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
virtual ~ComputerPollingEntry()
|
||||
{
|
||||
interrupt();
|
||||
|
||||
// interrupt() should have taken care of this
|
||||
Q_ASSERT(m_ActiveThread == nullptr);
|
||||
|
||||
for (QThread* thread : m_InactiveList) {
|
||||
thread->wait();
|
||||
delete thread;
|
||||
}
|
||||
}
|
||||
|
||||
bool isActive()
|
||||
{
|
||||
cleanInactiveList();
|
||||
|
||||
return m_ActiveThread != nullptr;
|
||||
}
|
||||
|
||||
void setActiveThread(QThread* thread)
|
||||
{
|
||||
cleanInactiveList();
|
||||
|
||||
Q_ASSERT(!isActive());
|
||||
m_ActiveThread = thread;
|
||||
}
|
||||
|
||||
void interrupt()
|
||||
{
|
||||
cleanInactiveList();
|
||||
|
||||
if (m_ActiveThread != nullptr) {
|
||||
// Interrupt the active thread
|
||||
m_ActiveThread->requestInterruption();
|
||||
|
||||
// Place it on the inactive list awaiting death
|
||||
m_InactiveList.append(m_ActiveThread);
|
||||
|
||||
m_ActiveThread = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
void cleanInactiveList()
|
||||
{
|
||||
QMutableListIterator<QThread*> i(m_InactiveList);
|
||||
|
||||
// Reap any threads that have finished
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
|
||||
QThread* thread = i.value();
|
||||
if (thread->isFinished()) {
|
||||
delete thread;
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QThread* m_ActiveThread;
|
||||
QList<QThread*> m_InactiveList;
|
||||
};
|
||||
|
||||
class ComputerManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -88,6 +161,8 @@ signals:
|
||||
void quitAppCompleted(QVariant error);
|
||||
|
||||
private slots:
|
||||
void handleAboutToQuit();
|
||||
|
||||
void handleComputerStateChanged(NvComputer* computer);
|
||||
|
||||
void handleMdnsServiceResolved(MdnsPendingComputer* computer, const QHostAddress& address);
|
||||
@@ -100,7 +175,7 @@ private:
|
||||
int m_PollingRef;
|
||||
QReadWriteLock m_Lock;
|
||||
QMap<QString, NvComputer*> m_KnownHosts;
|
||||
QMap<QString, QThread*> m_PollThreads;
|
||||
QMap<QString, ComputerPollingEntry*> m_PollEntries;
|
||||
QMdnsEngine::Server m_MdnsServer;
|
||||
QMdnsEngine::Browser* m_MdnsBrowser;
|
||||
QMdnsEngine::Cache m_MdnsCache;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <QUdpSocket>
|
||||
#include <QHostInfo>
|
||||
#include <QNetworkInterface>
|
||||
|
||||
#define SER_NAME "hostname"
|
||||
#define SER_UUID "uuid"
|
||||
@@ -10,6 +11,7 @@
|
||||
#define SER_REMOTEADDR "remoteaddress"
|
||||
#define SER_MANUALADDR "manualaddress"
|
||||
#define SER_APPLIST "apps"
|
||||
#define SER_SRVCERT "srvcert"
|
||||
|
||||
#define SER_APPNAME "name"
|
||||
#define SER_APPID "id"
|
||||
@@ -23,6 +25,7 @@ NvComputer::NvComputer(QSettings& settings)
|
||||
this->localAddress = settings.value(SER_LOCALADDR).toString();
|
||||
this->remoteAddress = settings.value(SER_REMOTEADDR).toString();
|
||||
this->manualAddress = settings.value(SER_MANUALADDR).toString();
|
||||
this->serverCert = QSslCertificate(settings.value(SER_SRVCERT).toByteArray());
|
||||
|
||||
int appCount = settings.beginReadArray(SER_APPLIST);
|
||||
for (int i = 0; i < appCount; i++) {
|
||||
@@ -61,6 +64,7 @@ void NvComputer::serialize(QSettings& settings)
|
||||
settings.setValue(SER_LOCALADDR, localAddress);
|
||||
settings.setValue(SER_REMOTEADDR, remoteAddress);
|
||||
settings.setValue(SER_MANUALADDR, manualAddress);
|
||||
settings.setValue(SER_SRVCERT, serverCert.toPem());
|
||||
|
||||
// Avoid deleting an existing applist if we couldn't get one
|
||||
if (!appList.isEmpty()) {
|
||||
@@ -84,8 +88,10 @@ void NvComputer::sortAppList()
|
||||
});
|
||||
}
|
||||
|
||||
NvComputer::NvComputer(QString address, QString serverInfo)
|
||||
NvComputer::NvComputer(QString address, QString serverInfo, QSslCertificate serverCert)
|
||||
{
|
||||
this->serverCert = serverCert;
|
||||
|
||||
this->name = NvHTTP::getXmlString(serverInfo, "hostname");
|
||||
if (this->name.isEmpty()) {
|
||||
this->name = "UNKNOWN";
|
||||
@@ -150,7 +156,7 @@ bool NvComputer::wake()
|
||||
|
||||
const quint16 WOL_PORTS[] = {
|
||||
7, 9, // Standard WOL ports
|
||||
47998, 47999, 48000, // Ports opened by GFE
|
||||
47998, 47999, 48000, 48002, 48010, // Ports opened by GFE
|
||||
};
|
||||
|
||||
// Create the WoL payload
|
||||
@@ -167,6 +173,32 @@ bool NvComputer::wake()
|
||||
QVector<QString> addressList = uniqueAddresses();
|
||||
addressList.append("255.255.255.255");
|
||||
|
||||
// Try to broadcast on all available NICs
|
||||
for (const QNetworkInterface& nic : QNetworkInterface::allInterfaces()) {
|
||||
// Ensure the interface is up and skip the loopback adapter
|
||||
if ((nic.flags() & QNetworkInterface::IsUp) == 0 ||
|
||||
(nic.flags() & QNetworkInterface::IsLoopBack) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
QHostAddress allNodesMulticast("FF02::1");
|
||||
for (const QNetworkAddressEntry& addr : nic.addressEntries()) {
|
||||
// Store the scope ID for this NIC if IPv6 is enabled
|
||||
if (!addr.ip().scopeId().isEmpty()) {
|
||||
allNodesMulticast.setScopeId(addr.ip().scopeId());
|
||||
}
|
||||
|
||||
// Skip IPv6 which doesn't support broadcast
|
||||
if (!addr.broadcast().isNull()) {
|
||||
addressList.append(addr.broadcast().toString());
|
||||
}
|
||||
}
|
||||
|
||||
if (!allNodesMulticast.scopeId().isEmpty()) {
|
||||
addressList.append(allNodesMulticast.toString());
|
||||
}
|
||||
}
|
||||
|
||||
// Try all unique address strings or host names
|
||||
bool success = false;
|
||||
for (QString& addressString : addressList) {
|
||||
@@ -181,16 +213,14 @@ bool NvComputer::wake()
|
||||
for (QHostAddress& address : hostInfo.addresses()) {
|
||||
QUdpSocket sock;
|
||||
|
||||
// Bind to any address on the correct protocol
|
||||
if (sock.bind(address.protocol() == QUdpSocket::IPv4Protocol ?
|
||||
QHostAddress::AnyIPv4 : QHostAddress::AnyIPv6)) {
|
||||
|
||||
// Send to all ports
|
||||
for (quint16 port : WOL_PORTS) {
|
||||
if (sock.writeDatagram(wolPayload, address, port)) {
|
||||
qInfo().nospace().noquote() << "Send WoL packet to " << name << " via " << address.toString() << ":" << port;
|
||||
success = true;
|
||||
}
|
||||
// Send to all ports
|
||||
for (quint16 port : WOL_PORTS) {
|
||||
if (sock.writeDatagram(wolPayload, address, port)) {
|
||||
qInfo().nospace().noquote() << "Sent WoL packet to " << name << " via " << address.toString() << ":" << port;
|
||||
success = true;
|
||||
}
|
||||
else {
|
||||
qWarning() << "Send failed:" << sock.error();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -255,6 +285,13 @@ bool NvComputer::update(NvComputer& that)
|
||||
changed = true; \
|
||||
}
|
||||
|
||||
#define ASSIGN_IF_CHANGED_AND_NONNULL(field) \
|
||||
if (!that.field.isNull() && \
|
||||
this->field != that.field) { \
|
||||
this->field = that.field; \
|
||||
changed = true; \
|
||||
}
|
||||
|
||||
ASSIGN_IF_CHANGED(name);
|
||||
ASSIGN_IF_CHANGED_AND_NONEMPTY(macAddress);
|
||||
ASSIGN_IF_CHANGED_AND_NONEMPTY(localAddress);
|
||||
@@ -269,6 +306,7 @@ bool NvComputer::update(NvComputer& that)
|
||||
ASSIGN_IF_CHANGED(appVersion);
|
||||
ASSIGN_IF_CHANGED(maxLumaPixelsHEVC);
|
||||
ASSIGN_IF_CHANGED(gpuModel);
|
||||
ASSIGN_IF_CHANGED_AND_NONNULL(serverCert);
|
||||
ASSIGN_IF_CHANGED_AND_NONEMPTY(appList);
|
||||
ASSIGN_IF_CHANGED_AND_NONEMPTY(displayModes);
|
||||
return changed;
|
||||
|
||||
@@ -19,7 +19,7 @@ private:
|
||||
bool pendingQuit;
|
||||
|
||||
public:
|
||||
explicit NvComputer(QString address, QString serverInfo);
|
||||
explicit NvComputer(QString address, QString serverInfo, QSslCertificate serverCert);
|
||||
|
||||
explicit NvComputer(QSettings& settings);
|
||||
|
||||
@@ -68,6 +68,7 @@ public:
|
||||
QByteArray macAddress;
|
||||
QString name;
|
||||
QString uuid;
|
||||
QSslCertificate serverCert;
|
||||
QVector<NvApp> appList;
|
||||
|
||||
// Synchronization
|
||||
|
||||
@@ -13,9 +13,13 @@
|
||||
#include <QNetworkProxy>
|
||||
|
||||
#define REQUEST_TIMEOUT_MS 5000
|
||||
#define LAUNCH_TIMEOUT_MS 120000
|
||||
#define RESUME_TIMEOUT_MS 30000
|
||||
#define QUIT_TIMEOUT_MS 30000
|
||||
|
||||
NvHTTP::NvHTTP(QString address) :
|
||||
m_Address(address)
|
||||
NvHTTP::NvHTTP(QString address, QSslCertificate serverCert) :
|
||||
m_Address(address),
|
||||
m_ServerCert(serverCert)
|
||||
{
|
||||
Q_ASSERT(!address.isEmpty());
|
||||
|
||||
@@ -29,6 +33,13 @@ NvHTTP::NvHTTP(QString address) :
|
||||
// Never use a proxy server
|
||||
QNetworkProxy noProxy(QNetworkProxy::NoProxy);
|
||||
m_Nam.setProxy(noProxy);
|
||||
|
||||
connect(&m_Nam, &QNetworkAccessManager::sslErrors, this, &NvHTTP::handleSslErrors);
|
||||
}
|
||||
|
||||
void NvHTTP::setServerCert(QSslCertificate serverCert)
|
||||
{
|
||||
m_ServerCert = serverCert;
|
||||
}
|
||||
|
||||
QVector<int>
|
||||
@@ -73,36 +84,50 @@ NvHTTP::getServerInfo(NvLogLevel logLevel)
|
||||
{
|
||||
QString serverInfo;
|
||||
|
||||
try
|
||||
// Check if we have a pinned cert for this host yet
|
||||
if (!m_ServerCert.isNull())
|
||||
{
|
||||
// Always try HTTPS first, since it properly reports
|
||||
// pairing status (and a few other attributes).
|
||||
serverInfo = openConnectionToString(m_BaseUrlHttps,
|
||||
"serverinfo",
|
||||
nullptr,
|
||||
true,
|
||||
logLevel);
|
||||
// Throws if the request failed
|
||||
verifyResponseStatus(serverInfo);
|
||||
}
|
||||
catch (const GfeHttpResponseException& e)
|
||||
{
|
||||
if (e.getStatusCode() == 401)
|
||||
try
|
||||
{
|
||||
// Certificate validation error, fallback to HTTP
|
||||
serverInfo = openConnectionToString(m_BaseUrlHttp,
|
||||
// Always try HTTPS first, since it properly reports
|
||||
// pairing status (and a few other attributes).
|
||||
serverInfo = openConnectionToString(m_BaseUrlHttps,
|
||||
"serverinfo",
|
||||
nullptr,
|
||||
true,
|
||||
REQUEST_TIMEOUT_MS,
|
||||
logLevel);
|
||||
// Throws if the request failed
|
||||
verifyResponseStatus(serverInfo);
|
||||
}
|
||||
else
|
||||
catch (const GfeHttpResponseException& e)
|
||||
{
|
||||
// Rethrow real errors
|
||||
throw e;
|
||||
if (e.getStatusCode() == 401)
|
||||
{
|
||||
// Certificate validation error, fallback to HTTP
|
||||
serverInfo = openConnectionToString(m_BaseUrlHttp,
|
||||
"serverinfo",
|
||||
nullptr,
|
||||
REQUEST_TIMEOUT_MS,
|
||||
logLevel);
|
||||
verifyResponseStatus(serverInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Rethrow real errors
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Only use HTTP prior to pairing
|
||||
serverInfo = openConnectionToString(m_BaseUrlHttp,
|
||||
"serverinfo",
|
||||
nullptr,
|
||||
REQUEST_TIMEOUT_MS,
|
||||
logLevel);
|
||||
verifyResponseStatus(serverInfo);
|
||||
}
|
||||
|
||||
return serverInfo;
|
||||
}
|
||||
@@ -149,7 +174,10 @@ NvHTTP::launchApp(int appId,
|
||||
"appid="+QString::number(appId)+
|
||||
"&mode="+QString::number(streamConfig->width)+"x"+
|
||||
QString::number(streamConfig->height)+"x"+
|
||||
QString::number(streamConfig->fps)+
|
||||
// Using an FPS value over 60 causes SOPS to default to 720p60,
|
||||
// so force it to 60 when starting. This won't impact our ability
|
||||
// to get > 60 FPS while actually streaming though.
|
||||
QString::number(streamConfig->fps > 60 ? 60 : streamConfig->fps)+
|
||||
"&additionalStates=1&sops="+QString::number(sops ? 1 : 0)+
|
||||
"&rikey="+QByteArray(streamConfig->remoteInputAesKey, sizeof(streamConfig->remoteInputAesKey)).toHex()+
|
||||
"&rikeyid="+QString::number(riKeyId)+
|
||||
@@ -160,7 +188,7 @@ NvHTTP::launchApp(int appId,
|
||||
"&surroundAudioInfo="+getSurroundAudioInfoString(streamConfig->audioConfiguration)+
|
||||
"&remoteControllersBitmap="+QString::number(gamepadMask)+
|
||||
"&gcmap="+QString::number(gamepadMask),
|
||||
false);
|
||||
LAUNCH_TIMEOUT_MS);
|
||||
|
||||
// Throws if the request failed
|
||||
verifyResponseStatus(response);
|
||||
@@ -180,7 +208,7 @@ NvHTTP::resumeApp(PSTREAM_CONFIGURATION streamConfig)
|
||||
"rikey="+QString(QByteArray(streamConfig->remoteInputAesKey, sizeof(streamConfig->remoteInputAesKey)).toHex())+
|
||||
"&rikeyid="+QString::number(riKeyId)+
|
||||
"&surroundAudioInfo="+getSurroundAudioInfoString(streamConfig->audioConfiguration),
|
||||
false);
|
||||
RESUME_TIMEOUT_MS);
|
||||
|
||||
// Throws if the request failed
|
||||
verifyResponseStatus(response);
|
||||
@@ -193,14 +221,14 @@ NvHTTP::quitApp()
|
||||
openConnectionToString(m_BaseUrlHttps,
|
||||
"cancel",
|
||||
nullptr,
|
||||
false);
|
||||
QUIT_TIMEOUT_MS);
|
||||
|
||||
// Throws if the request failed
|
||||
verifyResponseStatus(response);
|
||||
|
||||
// Newer GFE versions will just return success even if quitting fails
|
||||
// if we're not the original requestor.
|
||||
if (getCurrentGame(getServerInfo(NvHTTP::ERROR)) != 0) {
|
||||
if (getCurrentGame(getServerInfo(NvHTTP::NVLL_ERROR)) != 0) {
|
||||
// Generate a synthetic GfeResponseException letting the caller know
|
||||
// that they can't kill someone else's stream.
|
||||
throw GfeHttpResponseException(599, "");
|
||||
@@ -240,8 +268,8 @@ NvHTTP::getAppList()
|
||||
QString appxml = openConnectionToString(m_BaseUrlHttps,
|
||||
"applist",
|
||||
nullptr,
|
||||
true,
|
||||
NvLogLevel::ERROR);
|
||||
REQUEST_TIMEOUT_MS,
|
||||
NvLogLevel::NVLL_ERROR);
|
||||
verifyResponseStatus(appxml);
|
||||
|
||||
QXmlStreamReader xmlReader(appxml);
|
||||
@@ -308,8 +336,8 @@ NvHTTP::getBoxArt(int appId)
|
||||
"appasset",
|
||||
"appid="+QString::number(appId)+
|
||||
"&AssetType=2&AssetIdx=0",
|
||||
true,
|
||||
NvLogLevel::VERBOSE);
|
||||
REQUEST_TIMEOUT_MS,
|
||||
NvLogLevel::NVLL_VERBOSE);
|
||||
QImage image = QImageReader(reply).read();
|
||||
delete reply;
|
||||
|
||||
@@ -351,14 +379,36 @@ NvHTTP::getXmlString(QString xml,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void NvHTTP::handleSslErrors(QNetworkReply* reply, const QList<QSslError>& errors)
|
||||
{
|
||||
bool ignoreErrors = true;
|
||||
|
||||
if (m_ServerCert.isNull()) {
|
||||
// We should never make an HTTPS request without a cert
|
||||
Q_ASSERT(!m_ServerCert.isNull());
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto error : errors) {
|
||||
if (m_ServerCert != error.certificate()) {
|
||||
ignoreErrors = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ignoreErrors) {
|
||||
reply->ignoreSslErrors(errors);
|
||||
}
|
||||
}
|
||||
|
||||
QString
|
||||
NvHTTP::openConnectionToString(QUrl baseUrl,
|
||||
QString command,
|
||||
QString arguments,
|
||||
bool enableTimeout,
|
||||
int timeoutMs,
|
||||
NvLogLevel logLevel)
|
||||
{
|
||||
QNetworkReply* reply = openConnection(baseUrl, command, arguments, enableTimeout, logLevel);
|
||||
QNetworkReply* reply = openConnection(baseUrl, command, arguments, timeoutMs, logLevel);
|
||||
QString ret;
|
||||
|
||||
QTextStream stream(reply);
|
||||
@@ -373,34 +423,35 @@ QNetworkReply*
|
||||
NvHTTP::openConnection(QUrl baseUrl,
|
||||
QString command,
|
||||
QString arguments,
|
||||
bool enableTimeout,
|
||||
int timeoutMs,
|
||||
NvLogLevel logLevel)
|
||||
{
|
||||
// Build a URL for the request
|
||||
QUrl url(baseUrl);
|
||||
url.setPath("/" + command);
|
||||
url.setQuery("uniqueid=" + IdentityManager::get()->getUniqueId() +
|
||||
"&uuid=" + QUuid::createUuid().toRfc4122().toHex() +
|
||||
|
||||
// Use a common UID for Moonlight clients to allow them to quit
|
||||
// games for each other (otherwise GFE gets screwed up and it requires
|
||||
// manual intervention to solve).
|
||||
url.setQuery("uniqueid=0123456789ABCDEF&uuid=" +
|
||||
QUuid::createUuid().toRfc4122().toHex() +
|
||||
((arguments != nullptr) ? ("&" + arguments) : ""));
|
||||
|
||||
QNetworkRequest request = QNetworkRequest(url);
|
||||
QNetworkRequest request(url);
|
||||
|
||||
// Add our client certificate
|
||||
request.setSslConfiguration(IdentityManager::get()->getSslConfig());
|
||||
|
||||
QNetworkReply* reply = m_Nam.get(request);
|
||||
|
||||
// Ignore self-signed certificate errors (since GFE uses them)
|
||||
reply->ignoreSslErrors();
|
||||
|
||||
// Run the request with a timeout if requested
|
||||
QEventLoop loop;
|
||||
QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
|
||||
if (enableTimeout)
|
||||
{
|
||||
QTimer::singleShot(REQUEST_TIMEOUT_MS, &loop, SLOT(quit()));
|
||||
connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
|
||||
connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), &loop, SLOT(quit()));
|
||||
if (timeoutMs) {
|
||||
QTimer::singleShot(timeoutMs, &loop, SLOT(quit()));
|
||||
}
|
||||
if (logLevel >= NvLogLevel::VERBOSE) {
|
||||
if (logLevel >= NvLogLevel::NVLL_VERBOSE) {
|
||||
qInfo() << "Executing request:" << url.toString();
|
||||
}
|
||||
loop.exec(QEventLoop::ExcludeUserInputEvents);
|
||||
@@ -408,7 +459,7 @@ NvHTTP::openConnection(QUrl baseUrl,
|
||||
// Abort the request if it timed out
|
||||
if (!reply->isFinished())
|
||||
{
|
||||
if (logLevel >= NvLogLevel::ERROR) {
|
||||
if (logLevel >= NvLogLevel::NVLL_ERROR) {
|
||||
qWarning() << "Aborting timed out request for" << url.toString();
|
||||
}
|
||||
reply->abort();
|
||||
@@ -421,12 +472,27 @@ NvHTTP::openConnection(QUrl baseUrl,
|
||||
// Handle error
|
||||
if (reply->error() != QNetworkReply::NoError)
|
||||
{
|
||||
if (logLevel >= NvLogLevel::ERROR) {
|
||||
if (logLevel >= NvLogLevel::NVLL_ERROR) {
|
||||
qWarning() << command << " request failed with error " << reply->error();
|
||||
}
|
||||
QtNetworkReplyException exception(reply->error(), reply->errorString());
|
||||
delete reply;
|
||||
throw exception;
|
||||
|
||||
if (reply->error() == QNetworkReply::SslHandshakeFailedError) {
|
||||
// This will trigger falling back to HTTP for the serverinfo query
|
||||
// then pairing again to get the updated certificate.
|
||||
GfeHttpResponseException exception(401, "Server certificate mismatch");
|
||||
delete reply;
|
||||
throw exception;
|
||||
}
|
||||
else if (reply->error() == QNetworkReply::OperationCanceledError) {
|
||||
QtNetworkReplyException exception(QNetworkReply::TimeoutError, "Request timed out");
|
||||
delete reply;
|
||||
throw exception;
|
||||
}
|
||||
else {
|
||||
QtNetworkReplyException exception(reply->error(), reply->errorString());
|
||||
delete reply;
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
|
||||
return reply;
|
||||
|
||||
@@ -113,16 +113,18 @@ private:
|
||||
QString m_ErrorText;
|
||||
};
|
||||
|
||||
class NvHTTP
|
||||
class NvHTTP : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum NvLogLevel {
|
||||
NONE,
|
||||
ERROR,
|
||||
VERBOSE
|
||||
NVLL_NONE,
|
||||
NVLL_ERROR,
|
||||
NVLL_VERBOSE
|
||||
};
|
||||
|
||||
explicit NvHTTP(QString address);
|
||||
explicit NvHTTP(QString address, QSslCertificate serverCert);
|
||||
|
||||
static
|
||||
int
|
||||
@@ -149,8 +151,10 @@ public:
|
||||
openConnectionToString(QUrl baseUrl,
|
||||
QString command,
|
||||
QString arguments,
|
||||
bool enableTimeout,
|
||||
NvLogLevel logLevel = NvLogLevel::VERBOSE);
|
||||
int timeoutMs,
|
||||
NvLogLevel logLevel = NvLogLevel::NVLL_VERBOSE);
|
||||
|
||||
void setServerCert(QSslCertificate serverCert);
|
||||
|
||||
static
|
||||
QVector<int>
|
||||
@@ -182,13 +186,17 @@ public:
|
||||
QUrl m_BaseUrlHttp;
|
||||
QUrl m_BaseUrlHttps;
|
||||
private:
|
||||
void
|
||||
handleSslErrors(QNetworkReply* reply, const QList<QSslError>& errors);
|
||||
|
||||
QNetworkReply*
|
||||
openConnection(QUrl baseUrl,
|
||||
QString command,
|
||||
QString arguments,
|
||||
bool enableTimeout,
|
||||
int timeoutMs,
|
||||
NvLogLevel logLevel);
|
||||
|
||||
QString m_Address;
|
||||
QNetworkAccessManager m_Nam;
|
||||
QSslCertificate m_ServerCert;
|
||||
};
|
||||
|
||||
@@ -8,8 +8,10 @@
|
||||
#include <openssl/x509.h>
|
||||
#include <openssl/evp.h>
|
||||
|
||||
#define REQUEST_TIMEOUT_MS 5000
|
||||
|
||||
NvPairingManager::NvPairingManager(QString address) :
|
||||
m_Http(address)
|
||||
m_Http(address, QSslCertificate())
|
||||
{
|
||||
QByteArray cert = IdentityManager::get()->getCertificate();
|
||||
BIO *bio = BIO_new_mem_buf(cert.data(), -1);
|
||||
@@ -161,7 +163,7 @@ NvPairingManager::saltPin(QByteArray salt, QString pin)
|
||||
}
|
||||
|
||||
NvPairingManager::PairState
|
||||
NvPairingManager::pair(QString appVersion, QString pin)
|
||||
NvPairingManager::pair(QString appVersion, QString pin, QSslCertificate& serverCert)
|
||||
{
|
||||
int serverMajorVersion = NvHTTP::parseQuad(appVersion).at(0);
|
||||
qInfo() << "Pairing with server generation:" << serverMajorVersion;
|
||||
@@ -192,7 +194,7 @@ NvPairingManager::pair(QString appVersion, QString pin)
|
||||
"pair",
|
||||
"devicename=roth&updateState=1&phrase=getservercert&salt=" +
|
||||
salt.toHex() + "&clientcert=" + IdentityManager::get()->getCertificate().toHex(),
|
||||
false);
|
||||
0);
|
||||
NvHTTP::verifyResponseStatus(getCert);
|
||||
if (NvHTTP::getXmlString(getCert, "paired") != "1")
|
||||
{
|
||||
@@ -200,26 +202,38 @@ NvPairingManager::pair(QString appVersion, QString pin)
|
||||
return PairState::FAILED;
|
||||
}
|
||||
|
||||
QByteArray serverCert = NvHTTP::getXmlStringFromHex(getCert, "plaincert");
|
||||
if (serverCert == nullptr)
|
||||
QByteArray serverCertStr = NvHTTP::getXmlStringFromHex(getCert, "plaincert");
|
||||
if (serverCertStr == nullptr)
|
||||
{
|
||||
qCritical() << "Server likely already pairing";
|
||||
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, true);
|
||||
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, REQUEST_TIMEOUT_MS);
|
||||
return PairState::ALREADY_IN_PROGRESS;
|
||||
}
|
||||
|
||||
serverCert = QSslCertificate(serverCertStr);
|
||||
if (serverCert.isNull()) {
|
||||
Q_ASSERT(!serverCert.isNull());
|
||||
|
||||
qCritical() << "Failed to parse plaincert";
|
||||
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, REQUEST_TIMEOUT_MS);
|
||||
return PairState::FAILED;
|
||||
}
|
||||
|
||||
// Pin this cert for TLS
|
||||
m_Http.setServerCert(serverCert);
|
||||
|
||||
QByteArray randomChallenge = generateRandomBytes(16);
|
||||
QByteArray encryptedChallenge = encrypt(randomChallenge, &encKey);
|
||||
QString challengeXml = m_Http.openConnectionToString(m_Http.m_BaseUrlHttp,
|
||||
"pair",
|
||||
"devicename=roth&updateState=1&clientchallenge=" +
|
||||
encryptedChallenge.toHex(),
|
||||
true);
|
||||
REQUEST_TIMEOUT_MS);
|
||||
NvHTTP::verifyResponseStatus(challengeXml);
|
||||
if (NvHTTP::getXmlString(challengeXml, "paired") != "1")
|
||||
{
|
||||
qCritical() << "Failed pairing at stage #2";
|
||||
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, true);
|
||||
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, REQUEST_TIMEOUT_MS);
|
||||
return PairState::FAILED;
|
||||
}
|
||||
|
||||
@@ -247,12 +261,12 @@ NvPairingManager::pair(QString appVersion, QString pin)
|
||||
"pair",
|
||||
"devicename=roth&updateState=1&serverchallengeresp=" +
|
||||
encryptedChallengeResponseHash.toHex(),
|
||||
true);
|
||||
REQUEST_TIMEOUT_MS);
|
||||
NvHTTP::verifyResponseStatus(respXml);
|
||||
if (NvHTTP::getXmlString(respXml, "paired") != "1")
|
||||
{
|
||||
qCritical() << "Failed pairing at stage #3";
|
||||
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, true);
|
||||
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, REQUEST_TIMEOUT_MS);
|
||||
return PairState::FAILED;
|
||||
}
|
||||
|
||||
@@ -262,21 +276,21 @@ NvPairingManager::pair(QString appVersion, QString pin)
|
||||
|
||||
if (!verifySignature(serverSecret,
|
||||
serverSignature,
|
||||
serverCert))
|
||||
serverCertStr))
|
||||
{
|
||||
qCritical() << "MITM detected";
|
||||
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, true);
|
||||
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, REQUEST_TIMEOUT_MS);
|
||||
return PairState::FAILED;
|
||||
}
|
||||
|
||||
QByteArray expectedResponseData;
|
||||
expectedResponseData.append(randomChallenge);
|
||||
expectedResponseData.append(getSignatureFromPemCert(serverCert));
|
||||
expectedResponseData.append(getSignatureFromPemCert(serverCertStr));
|
||||
expectedResponseData.append(serverSecret);
|
||||
if (QCryptographicHash::hash(expectedResponseData, hashAlgo) != serverResponse)
|
||||
{
|
||||
qCritical() << "Incorrect PIN";
|
||||
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, true);
|
||||
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, REQUEST_TIMEOUT_MS);
|
||||
return PairState::PIN_WRONG;
|
||||
}
|
||||
|
||||
@@ -288,24 +302,24 @@ NvPairingManager::pair(QString appVersion, QString pin)
|
||||
"pair",
|
||||
"devicename=roth&updateState=1&clientpairingsecret=" +
|
||||
clientPairingSecret.toHex(),
|
||||
true);
|
||||
REQUEST_TIMEOUT_MS);
|
||||
NvHTTP::verifyResponseStatus(secretRespXml);
|
||||
if (NvHTTP::getXmlString(secretRespXml, "paired") != "1")
|
||||
{
|
||||
qCritical() << "Failed pairing at stage #4";
|
||||
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, true);
|
||||
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, REQUEST_TIMEOUT_MS);
|
||||
return PairState::FAILED;
|
||||
}
|
||||
|
||||
QString pairChallengeXml = m_Http.openConnectionToString(m_Http.m_BaseUrlHttps,
|
||||
"pair",
|
||||
"devicename=roth&updateState=1&phrase=pairchallenge",
|
||||
true);
|
||||
REQUEST_TIMEOUT_MS);
|
||||
NvHTTP::verifyResponseStatus(pairChallengeXml);
|
||||
if (NvHTTP::getXmlString(pairChallengeXml, "paired") != "1")
|
||||
{
|
||||
qCritical() << "Failed pairing at stage #5";
|
||||
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, true);
|
||||
m_Http.openConnectionToString(m_Http.m_BaseUrlHttp, "unpair", nullptr, REQUEST_TIMEOUT_MS);
|
||||
return PairState::FAILED;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
~NvPairingManager();
|
||||
|
||||
PairState
|
||||
pair(QString appVersion, QString pin);
|
||||
pair(QString appVersion, QString pin, QSslCertificate& serverCert);
|
||||
|
||||
private:
|
||||
QByteArray
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
#include "systemproperties.h"
|
||||
|
||||
#include <QGuiApplication>
|
||||
|
||||
#include "streaming/session.h"
|
||||
#include "streaming/streamutils.h"
|
||||
|
||||
SystemProperties::SystemProperties()
|
||||
{
|
||||
isRunningWayland = qgetenv("XDG_SESSION_TYPE") == "wayland";
|
||||
isRunningXWayland = qgetenv("XDG_SESSION_TYPE") == "wayland" && QGuiApplication::platformName() == "xcb";
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
isWow64 = QSysInfo::currentCpuArchitecture() != QSysInfo::buildCpuArchitecture();
|
||||
#else
|
||||
isWow64 = false;
|
||||
#endif
|
||||
|
||||
#ifndef STEAM_LINK
|
||||
hasBrowser = true;
|
||||
#else
|
||||
hasBrowser = false;
|
||||
#endif
|
||||
|
||||
unmappedGamepads = SdlInputHandler::getUnmappedGamepads();
|
||||
|
||||
// Populate data that requires talking to SDL. We do it all in one shot
|
||||
// and cache the results to speed up future queries on this data.
|
||||
querySdlVideoInfo();
|
||||
|
||||
Q_ASSERT(maximumStreamingFrameRate >= 60);
|
||||
Q_ASSERT(!monitorDesktopResolutions.isEmpty());
|
||||
Q_ASSERT(!monitorNativeResolutions.isEmpty());
|
||||
}
|
||||
|
||||
QRect SystemProperties::getDesktopResolution(int displayIndex)
|
||||
{
|
||||
// Returns default constructed QRect if out of bounds
|
||||
return monitorDesktopResolutions.value(displayIndex);
|
||||
}
|
||||
|
||||
QRect SystemProperties::getNativeResolution(int displayIndex)
|
||||
{
|
||||
// Returns default constructed QRect if out of bounds
|
||||
return monitorNativeResolutions.value(displayIndex);
|
||||
}
|
||||
|
||||
void SystemProperties::querySdlVideoInfo()
|
||||
{
|
||||
monitorDesktopResolutions.clear();
|
||||
monitorNativeResolutions.clear();
|
||||
hasHardwareAcceleration = false;
|
||||
|
||||
// Never let the maximum drop below 60 FPS
|
||||
maximumStreamingFrameRate = 60;
|
||||
|
||||
if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL_InitSubSystem(SDL_INIT_VIDEO) failed: %s",
|
||||
SDL_GetError());
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_DisplayMode bestMode;
|
||||
for (int displayIndex = 0; displayIndex < SDL_GetNumVideoDisplays(); displayIndex++) {
|
||||
SDL_DisplayMode desktopMode;
|
||||
int err;
|
||||
|
||||
err = SDL_GetDesktopDisplayMode(displayIndex, &desktopMode);
|
||||
if (err == 0) {
|
||||
monitorDesktopResolutions.insert(displayIndex, QRect(0, 0, desktopMode.w, desktopMode.h));
|
||||
}
|
||||
else {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL_GetDesktopDisplayMode() failed: %s",
|
||||
SDL_GetError());
|
||||
}
|
||||
|
||||
if (StreamUtils::getRealDesktopMode(displayIndex, &desktopMode)) {
|
||||
monitorNativeResolutions.insert(displayIndex, QRect(0, 0, desktopMode.w, desktopMode.h));
|
||||
|
||||
// Start at desktop mode and work our way up
|
||||
bestMode = desktopMode;
|
||||
for (int i = 0; i < SDL_GetNumDisplayModes(displayIndex); i++) {
|
||||
SDL_DisplayMode mode;
|
||||
if (SDL_GetDisplayMode(displayIndex, i, &mode) == 0) {
|
||||
if (mode.w == desktopMode.w && mode.h == desktopMode.h) {
|
||||
if (mode.refresh_rate > bestMode.refresh_rate) {
|
||||
bestMode = mode;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
maximumStreamingFrameRate = qMax(maximumStreamingFrameRate, bestMode.refresh_rate);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_Window* testWindow = SDL_CreateWindow("", 0, 0, 1280, 720, SDL_WINDOW_HIDDEN);
|
||||
if (!testWindow) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Failed to create window for hardware decode test: %s",
|
||||
SDL_GetError());
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
return;
|
||||
}
|
||||
|
||||
hasHardwareAcceleration =
|
||||
Session::isHardwareDecodeAvailable(testWindow,
|
||||
StreamingPreferences::VDS_AUTO,
|
||||
VIDEO_FORMAT_H264,
|
||||
1920, 1080, 60);
|
||||
|
||||
SDL_DestroyWindow(testWindow);
|
||||
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QRect>
|
||||
|
||||
class SystemProperties : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SystemProperties();
|
||||
|
||||
Q_PROPERTY(bool hasHardwareAcceleration MEMBER hasHardwareAcceleration CONSTANT)
|
||||
Q_PROPERTY(bool isRunningWayland MEMBER isRunningWayland CONSTANT)
|
||||
Q_PROPERTY(bool isRunningXWayland MEMBER isRunningXWayland CONSTANT)
|
||||
Q_PROPERTY(bool isWow64 MEMBER isWow64 CONSTANT)
|
||||
Q_PROPERTY(bool hasBrowser MEMBER hasBrowser CONSTANT)
|
||||
Q_PROPERTY(QString unmappedGamepads MEMBER unmappedGamepads NOTIFY unmappedGamepadsChanged)
|
||||
Q_PROPERTY(int maximumStreamingFrameRate MEMBER maximumStreamingFrameRate CONSTANT)
|
||||
|
||||
Q_INVOKABLE QRect getDesktopResolution(int displayIndex);
|
||||
Q_INVOKABLE QRect getNativeResolution(int displayIndex);
|
||||
|
||||
signals:
|
||||
void unmappedGamepadsChanged();
|
||||
|
||||
private:
|
||||
void querySdlVideoInfo();
|
||||
|
||||
bool hasHardwareAcceleration;
|
||||
bool isRunningWayland;
|
||||
bool isRunningXWayland;
|
||||
bool isWow64;
|
||||
bool hasBrowser;
|
||||
QString unmappedGamepads;
|
||||
int maximumStreamingFrameRate;
|
||||
QList<QRect> monitorDesktopResolutions;
|
||||
QList<QRect> monitorNativeResolutions;
|
||||
};
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
|
||||
void showMessage(QString message, MessageType type) const
|
||||
{
|
||||
#if defined(Q_OS_WIN)
|
||||
#if defined(Q_OS_WIN32)
|
||||
UINT flags = MB_OK | MB_TOPMOST | MB_SETFOREGROUND;
|
||||
flags |= (type == Info ? MB_ICONINFORMATION : MB_ICONERROR);
|
||||
QString title = "Moonlight";
|
||||
@@ -287,6 +287,7 @@ void StreamCommandLineParser::parse(const QStringList &args, StreamingPreference
|
||||
parser.addToggleOption("mouse-acceleration", "mouse acceleration");
|
||||
parser.addToggleOption("game-optimization", "game optimizations");
|
||||
parser.addToggleOption("audio-on-host", "audio on host PC");
|
||||
parser.addToggleOption("frame-pacing", "frame pacing");
|
||||
parser.addChoiceOption("video-codec", "video codec", m_VideoCodecMap.keys());
|
||||
parser.addChoiceOption("video-decoder", "video decoder", m_VideoDecoderMap.keys());
|
||||
|
||||
@@ -372,6 +373,9 @@ void StreamCommandLineParser::parse(const QStringList &args, StreamingPreference
|
||||
// Resolve --audio-on-host and --no-audio-on-host options
|
||||
preferences->playAudioOnHost = parser.getToggleOptionValue("audio-on-host", preferences->playAudioOnHost);
|
||||
|
||||
// Resolve --frame-pacing and --no-frame-pacing options
|
||||
preferences->framePacing = parser.getToggleOptionValue("frame-pacing", preferences->framePacing);
|
||||
|
||||
// Resolve --video-codec option
|
||||
if (parser.isSet("video-codec")) {
|
||||
preferences->videoCodecConfig = mapValue(m_VideoCodecMap, parser.getChoiceOptionValue("video-codec"));
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<metadata_license>CC0-1.0</metadata_license>
|
||||
<project_license>GPL-3.0+</project_license>
|
||||
<name>Moonlight</name>
|
||||
<summary>Stream games from your NVIDIA GameStream-enabled PC</summary>
|
||||
<summary>Play games remotely from your NVIDIA GameStream-enabled PC</summary>
|
||||
|
||||
<description>
|
||||
<p>Moonlight can stream games and other applications from a PC with an NVIDIA GeForce GTX 600-series or higher GPU and GeForce Experience installed.</p>
|
||||
@@ -15,7 +15,7 @@
|
||||
<li>Hardware accelerated video decoding with VAAPI and VDPAU support</li>
|
||||
<li>5.1 surround sound audio support</li>
|
||||
<li>HEVC support for better video compression efficiency</li>
|
||||
<li>Gamepad support with SDL mapping compatibility</li>
|
||||
<li>Gamepad support with force feedback for up to 4 players</li>
|
||||
</ul>
|
||||
</description>
|
||||
|
||||
@@ -33,6 +33,122 @@
|
||||
</screenshots>
|
||||
|
||||
<releases>
|
||||
<release version="1.0.0" date="2019-05-21">
|
||||
<description>
|
||||
<p>New features:</p>
|
||||
<ul>
|
||||
<li>Mouse mode for gamepads (Press and hold Start to toggle)</li>
|
||||
<li>Improved gamepad UI navigation</li>
|
||||
</ul>
|
||||
<p>Bugfixes:</p>
|
||||
<ul>
|
||||
<li>Fixed duplicate non-working gamepads appearing on the host</li>
|
||||
<li>Fixed excessive frame queue delay on macOS</li>
|
||||
<li>Fixed excessive audio latency on Steam Link</li>
|
||||
<li>Fixed hiding mouse cursor after streaming on Steam Link</li>
|
||||
<li>Fixed incorrect receive time stats on 32-bit platforms</li>
|
||||
<li>Added UDP ports 48002 and 48010 for Wake-on-LAN</li>
|
||||
<li>Updated included gamepad mappings</li>
|
||||
</ul>
|
||||
</description>
|
||||
</release>
|
||||
<release version="0.10.1" date="2019-04-28">
|
||||
<description>
|
||||
<p>New features:</p>
|
||||
<ul>
|
||||
<li>Video performance optimizations</li>
|
||||
<li>VAAPI support on Wayland</li>
|
||||
</ul>
|
||||
<p>Bugfixes:</p>
|
||||
<ul>
|
||||
<li>Fixed a crash when attempting to dismiss the connection terminated dialog</li>
|
||||
<li>Fixed a crash when using the overlay on the software decoder</li>
|
||||
<li>Fixed software decoder not displaying output in some cases</li>
|
||||
<li>Fixed some minor UI issues on the PC grid</li>
|
||||
<li>Improved visibility of toolbar highlights</li>
|
||||
</ul>
|
||||
</description>
|
||||
</release>
|
||||
<release version="0.10.0" date="2019-04-07">
|
||||
<description>
|
||||
<p>New features:</p>
|
||||
<ul>
|
||||
<li>Redesigned App Grid with larger game artwork and less blank space</li>
|
||||
<li>Redesigned UI dialogs using Material Design</li>
|
||||
<li>Added a connection warning overlay (which can be disabled in settings)</li>
|
||||
<li>Streaming window no longer minimizes when it loses focus in full-screen mode</li>
|
||||
<li>The Steam Link device is now a supported platform</li>
|
||||
</ul>
|
||||
<p>Bugfixes:</p>
|
||||
<ul>
|
||||
<li>Fixed several bugs that could cause UI hangs or lag</li>
|
||||
<li>Fixed rumble support on gamepads with limited rumble motor control</li>
|
||||
<li>Fixed increased memory usage if the software renderer gets delayed</li>
|
||||
<li>Fixed crashes on certain desktop configurations when loading the UI</li>
|
||||
<li>Fixed handling of pairing certificates with a bogus date</li>
|
||||
</ul>
|
||||
</description>
|
||||
</release>
|
||||
<release version="0.9.1" date="2019-02-17">
|
||||
<description>
|
||||
<p>New features:</p>
|
||||
<ul>
|
||||
<li>Added gamepad rumble support</li>
|
||||
<li>Added a dedicated quit button to the running app tile</li>
|
||||
<li>Reduced video latency on Windows and Linux</li>
|
||||
<li>Added a performance overlay for software decoding</li>
|
||||
</ul>
|
||||
<p>Bugfixes:</p>
|
||||
<ul>
|
||||
<li>Fixed delayed first video frame with GFE 3.17</li>
|
||||
<li>Fixed erroneously setting host resolution to 720p in certain configurations</li>
|
||||
<li>The connection termination dialog is no longer displayed for intentional termination</li>
|
||||
<li>Fixed some gamepads only functioning for UI navigation and not in game</li>
|
||||
<li>Fixed audio latency increasing when switching audio devices</li>
|
||||
<li>Fixed VDPAU scaling behavior on AMD cards</li>
|
||||
<li>Fixed several bugs in gamepad navigation behavior</li>
|
||||
<li>Work around a bug in QGnomePlatform that breaks dialog rendering on Linux</li>
|
||||
<li>Updated included SDL gamepad mappings</li>
|
||||
<li>Fixed hotkey behavior on non-latin keyboards</li>
|
||||
<li>Fixed incorrect frame drop percentages in debug stats</li>
|
||||
</ul>
|
||||
</description>
|
||||
</release>
|
||||
<release version="0.8.1" date="2019-01-08">
|
||||
<description>
|
||||
<p>New features:</p>
|
||||
<ul>
|
||||
<li>Stricter adherence to the specified bitrate when streaming over the Internet</li>
|
||||
</ul>
|
||||
<p>Bugfixes:</p>
|
||||
<ul>
|
||||
<li>Fixed audio crackling that impacted certain systems</li>
|
||||
<li>Fixed Wake-on-LAN packets failing to send on some systems</li>
|
||||
<li>Reduced audio latency when resuming a session where audio is already playing</li>
|
||||
<li>Added option to enable the old SDL audio renderer by setting ML_AUDIO=SDL</li>
|
||||
<li>Updated to use the new Qt 5.12 Flatpak runtime</li>
|
||||
<li>Updated to FFmpeg 4.1</li>
|
||||
<li>Minor UI tweaks</li>
|
||||
</ul>
|
||||
</description>
|
||||
</release>
|
||||
<release version="0.8.0" date="2018-12-25">
|
||||
<description>
|
||||
<p>New features:</p>
|
||||
<ul>
|
||||
<li>Improved security of pairing - After this update, you must re-pair with your PC!</li>
|
||||
<li>Enabled quitting games started by other Moonlight clients also running this update</li>
|
||||
</ul>
|
||||
<p>Bugfixes:</p>
|
||||
<ul>
|
||||
<li>Fixed the video bitrate slider not working above certain values on GFE 3.16</li>
|
||||
<li>Fixed broken Bluetooth audio with PulseAudio</li>
|
||||
<li>Reduced audio latency</li>
|
||||
<li>Fixed some non-gamepad devices triggering the unmapped gamepad dialog box</li>
|
||||
<li>Minor UI tweaks</li>
|
||||
</ul>
|
||||
</description>
|
||||
</release>
|
||||
<release version="0.7.0" date="2018-12-05">
|
||||
<description>
|
||||
<p>New features:</p>
|
||||
|
||||
|
After Width: | Height: | Size: 2.9 KiB |
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
# The default HOME is not persistent, so override
|
||||
# it to a path on the onboard flash. Otherwise our
|
||||
# pairing data will be lost each reboot.
|
||||
HOME=/usr/local/moonlight
|
||||
|
||||
# Renice PE_Single_CPU which seems to host A/V stuff
|
||||
renice -10 -p $(pidof PE_Single_CPU)
|
||||
|
||||
# Renice Moonlight itself to avoid preemption by background tasks
|
||||
# Write output to a logfile in /tmp
|
||||
exec nice -n -10 ./bin/moonlight > /tmp/moonlight.log
|
||||
@@ -0,0 +1,3 @@
|
||||
name=Moonlight
|
||||
icon=moonlight.png
|
||||
run=moonlight.sh
|
||||
@@ -1,29 +1,21 @@
|
||||
import QtQuick 2.9
|
||||
import QtQuick.Dialogs 1.2
|
||||
import QtQuick.Controls 2.2
|
||||
|
||||
import AppModel 1.0
|
||||
import ComputerManager 1.0
|
||||
import SdlGamepadKeyNavigation 1.0
|
||||
|
||||
GridView {
|
||||
CenteredGridView {
|
||||
property int computerIndex
|
||||
property AppModel appModel : createModel()
|
||||
property bool activated
|
||||
|
||||
id: appGrid
|
||||
focus: true
|
||||
activeFocusOnTab: true
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: (parent.width % (cellWidth + anchors.rightMargin)) / 2
|
||||
anchors.topMargin: 20
|
||||
anchors.rightMargin: 5
|
||||
anchors.bottomMargin: 5
|
||||
cellWidth: 225; cellHeight: 385;
|
||||
|
||||
// The StackView will trigger a visibility change when
|
||||
// we're pushed onto it, causing our onVisibleChanged
|
||||
// routine to run, but only if we start as invisible
|
||||
visible: false
|
||||
topMargin: 20
|
||||
bottomMargin: 5
|
||||
cellWidth: 230; cellHeight: 297;
|
||||
|
||||
function computerLost()
|
||||
{
|
||||
@@ -32,23 +24,25 @@ GridView {
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
// Don't show any highlighted item until interacting with them
|
||||
// Don't show any highlighted item until interacting with them.
|
||||
// We do this here instead of onActivated to avoid losing the user's
|
||||
// selection when backing out of a different page of the app.
|
||||
currentIndex = -1
|
||||
}
|
||||
|
||||
SdlGamepadKeyNavigation {
|
||||
id: gamepadKeyNav
|
||||
StackView.onActivated: {
|
||||
appModel.computerLost.connect(computerLost)
|
||||
activated = true
|
||||
|
||||
// Highlight the first item if a gamepad is connected
|
||||
if (currentIndex == -1 && SdlGamepadKeyNavigation.getConnectedGamepads() > 0) {
|
||||
currentIndex = 0
|
||||
}
|
||||
}
|
||||
|
||||
onVisibleChanged: {
|
||||
if (visible) {
|
||||
appModel.computerLost.connect(computerLost)
|
||||
gamepadKeyNav.enable()
|
||||
}
|
||||
else {
|
||||
appModel.computerLost.disconnect(computerLost)
|
||||
gamepadKeyNav.disable()
|
||||
}
|
||||
StackView.onDeactivating: {
|
||||
appModel.computerLost.disconnect(computerLost)
|
||||
activated = false
|
||||
}
|
||||
|
||||
function createModel()
|
||||
@@ -61,50 +55,110 @@ GridView {
|
||||
model: appModel
|
||||
|
||||
delegate: NavigableItemDelegate {
|
||||
width: 200; height: 335;
|
||||
width: 220; height: 287;
|
||||
grid: appGrid
|
||||
|
||||
Image {
|
||||
property bool isPlaceholder: false
|
||||
|
||||
id: appIcon
|
||||
anchors.horizontalCenter: parent.horizontalCenter;
|
||||
y: 20
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
y: 10
|
||||
source: model.boxart
|
||||
sourceSize {
|
||||
width: 150
|
||||
height: 200
|
||||
}
|
||||
width: sourceSize.width
|
||||
height: sourceSize.height
|
||||
fillMode: Image.Pad
|
||||
}
|
||||
|
||||
Image {
|
||||
id: runningIcon
|
||||
anchors.centerIn: appIcon
|
||||
visible: model.running
|
||||
source: "qrc:/res/baseline-play_circle_filled_white-48px.svg"
|
||||
sourceSize {
|
||||
width: 75
|
||||
height: 75
|
||||
}
|
||||
}
|
||||
onSourceSizeChanged: {
|
||||
if ((sourceSize.width == 130 && sourceSize.height == 180) || // GFE 2.0 placeholder image
|
||||
(sourceSize.width == 628 && sourceSize.height == 888) || // GFE 3.0 placeholder image
|
||||
(sourceSize.width == 200 && sourceSize.height == 266)) // Our no_app_image.png
|
||||
{
|
||||
isPlaceholder = true
|
||||
}
|
||||
else
|
||||
{
|
||||
isPlaceholder = false
|
||||
}
|
||||
|
||||
Label {
|
||||
id: appNameText
|
||||
text: model.name
|
||||
width: parent.width
|
||||
height: 125
|
||||
anchors.top: appIcon.bottom
|
||||
font.pointSize: 22
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
wrapMode: Text.Wrap
|
||||
elide: Text.ElideRight
|
||||
width = 200
|
||||
height = 267
|
||||
}
|
||||
|
||||
// Display a tooltip with the full name if it's truncated
|
||||
ToolTip.text: model.name
|
||||
ToolTip.delay: 1000
|
||||
ToolTip.timeout: 5000
|
||||
ToolTip.visible: (parent.hovered || parent.highlighted) && truncated
|
||||
ToolTip.visible: (parent.hovered || parent.highlighted) && (!appNameText.visible || appNameText.truncated)
|
||||
}
|
||||
|
||||
ToolButton {
|
||||
id: resumeButton
|
||||
anchors.horizontalCenterOffset: appIcon.isPlaceholder ? -47 : 0
|
||||
anchors.verticalCenterOffset: appIcon.isPlaceholder ? -75 : -60
|
||||
anchors.centerIn: appIcon
|
||||
visible: model.running
|
||||
implicitWidth: 125
|
||||
implicitHeight: 125
|
||||
|
||||
Image {
|
||||
source: "qrc:/res/baseline-play_circle_filled_white-48px.svg"
|
||||
anchors.centerIn: parent
|
||||
sourceSize {
|
||||
width: 75
|
||||
height: 75
|
||||
}
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
launchOrResumeSelectedApp()
|
||||
}
|
||||
|
||||
ToolTip.text: "Resume Game"
|
||||
ToolTip.delay: 1000
|
||||
ToolTip.timeout: 3000
|
||||
ToolTip.visible: hovered
|
||||
}
|
||||
|
||||
ToolButton {
|
||||
id: quitButton
|
||||
anchors.horizontalCenterOffset: appIcon.isPlaceholder ? 47 : 0
|
||||
anchors.verticalCenterOffset: appIcon.isPlaceholder ? -75 : 60
|
||||
anchors.centerIn: appIcon
|
||||
visible: model.running
|
||||
implicitWidth: 125
|
||||
implicitHeight: 125
|
||||
|
||||
Image {
|
||||
source: "qrc:/res/baseline-cancel-24px.svg"
|
||||
anchors.centerIn: parent
|
||||
sourceSize {
|
||||
width: 75
|
||||
height: 75
|
||||
}
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
doQuitGame()
|
||||
}
|
||||
|
||||
ToolTip.text: "Quit Game"
|
||||
ToolTip.delay: 1000
|
||||
ToolTip.timeout: 3000
|
||||
ToolTip.visible: hovered
|
||||
}
|
||||
|
||||
Label {
|
||||
id: appNameText
|
||||
visible: appIcon.isPlaceholder
|
||||
text: model.name
|
||||
width: appIcon.width
|
||||
height: model.running ? 175 : appIcon.height
|
||||
anchors.left: appIcon.left
|
||||
anchors.right: appIcon.right
|
||||
anchors.bottom: appIcon.bottom
|
||||
font.pointSize: 22
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
wrapMode: Text.Wrap
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
function launchOrResumeSelectedApp()
|
||||
@@ -125,55 +179,64 @@ GridView {
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
// Nothing is running or this app is running
|
||||
launchOrResumeSelectedApp()
|
||||
// Only allow clicking on the box art for non-running games.
|
||||
// For running games, buttons will appear to resume or quit which
|
||||
// will handle starting the game and clicks on the box art will
|
||||
// be ignored.
|
||||
if (!model.running) {
|
||||
launchOrResumeSelectedApp()
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.RightButton
|
||||
onClicked: {
|
||||
// popup() ensures the menu appears under the mouse cursor
|
||||
appContextMenu.popup()
|
||||
Keys.onReturnPressed: {
|
||||
// Open the app context menu if activated via the gamepad or keyboard
|
||||
// for running games. If the game isn't running, the above onClicked
|
||||
// method will handle the launch.
|
||||
if (model.running) {
|
||||
// This will be keyboard/gamepad driven so use
|
||||
// open() instead of popup()
|
||||
appContextMenu.open()
|
||||
}
|
||||
}
|
||||
|
||||
Keys.onMenuPressed: {
|
||||
// We must use open() here so the menu is positioned on
|
||||
// the ItemDelegate and not where the mouse cursor is
|
||||
appContextMenu.open()
|
||||
if (model.running) {
|
||||
// This will be keyboard/gamepad driven so use
|
||||
// open() instead of popup()
|
||||
appContextMenu.open()
|
||||
}
|
||||
}
|
||||
|
||||
Menu {
|
||||
function doQuitGame() {
|
||||
quitAppDialog.appName = appModel.getRunningAppName()
|
||||
quitAppDialog.segueToStream = false
|
||||
quitAppDialog.open()
|
||||
}
|
||||
|
||||
NavigableMenu {
|
||||
id: appContextMenu
|
||||
NavigableMenuItem {
|
||||
parentMenu: appContextMenu
|
||||
text: model.running ? "Resume Game" : "Launch Game"
|
||||
onTriggered: {
|
||||
appContextMenu.close()
|
||||
launchOrResumeSelectedApp()
|
||||
}
|
||||
onTriggered: launchOrResumeSelectedApp()
|
||||
}
|
||||
NavigableMenuItem {
|
||||
parentMenu: appContextMenu
|
||||
text: "Quit Game"
|
||||
onTriggered: {
|
||||
quitAppDialog.appName = appModel.getRunningAppName()
|
||||
quitAppDialog.segueToStream = false
|
||||
quitAppDialog.open()
|
||||
}
|
||||
onTriggered: doQuitGame()
|
||||
visible: model.running
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MessageDialog {
|
||||
NavigableMessageDialog {
|
||||
id: quitAppDialog
|
||||
modality:Qt.WindowModal
|
||||
property string appName : ""
|
||||
property bool segueToStream : false
|
||||
property string nextAppName: ""
|
||||
property int nextAppIndex: 0
|
||||
text:"Are you sure you want to quit " + appName +"? Any unsaved progress will be lost."
|
||||
standardButtons: StandardButton.Yes | StandardButton.No
|
||||
standardButtons: Dialog.Yes | Dialog.No
|
||||
|
||||
function quitApp() {
|
||||
var component = Qt.createComponent("QuitSegue.qml")
|
||||
@@ -195,20 +258,21 @@ GridView {
|
||||
appModel.quitRunningApp()
|
||||
}
|
||||
|
||||
onYes: quitApp()
|
||||
|
||||
// For keyboard/gamepad navigation
|
||||
onAccepted: quitApp()
|
||||
}
|
||||
|
||||
ScrollBar.vertical: ScrollBar {
|
||||
// Manually hide the scrollbar to prevent it from being drawn on top
|
||||
// of the StreamSegue during the transition. It can sometimes get stuck
|
||||
// there since we're not consistently pumping the event loop while
|
||||
// starting the stream.
|
||||
visible: activated
|
||||
|
||||
parent: appGrid.parent
|
||||
anchors {
|
||||
top: appGrid.top
|
||||
left: appGrid.right
|
||||
bottom: appGrid.bottom
|
||||
|
||||
leftMargin: -10
|
||||
top: parent.top
|
||||
right: parent.right
|
||||
bottom: parent.bottom
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import QtQuick 2.9
|
||||
import QtQuick.Controls 2.2
|
||||
|
||||
import SdlGamepadKeyNavigation 1.0
|
||||
|
||||
// https://stackoverflow.com/questions/45029968/how-do-i-set-the-combobox-width-to-fit-the-largest-item
|
||||
ComboBox {
|
||||
property int textWidth
|
||||
@@ -28,4 +30,13 @@ ComboBox {
|
||||
textWidth = Math.max(popupMetrics.width, textWidth)
|
||||
}
|
||||
}
|
||||
|
||||
popup.onAboutToShow: {
|
||||
// Switch to normal navigation for combo boxes
|
||||
SdlGamepadKeyNavigation.setUiNavMode(false)
|
||||
}
|
||||
|
||||
popup.onAboutToHide: {
|
||||
SdlGamepadKeyNavigation.setUiNavMode(true)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import QtQuick 2.9
|
||||
import QtQuick.Controls 2.2
|
||||
|
||||
GridView {
|
||||
// Detect Qt 5.11 or earlier using presence of synchronousDrag.
|
||||
// Prior to 5.12, the leftMargin and rightMargin values did not work.
|
||||
property bool hasBrokenMargins: this.synchronousDrag === undefined
|
||||
|
||||
property int minMargin: 10
|
||||
property real availableWidth: (parent.width - 2 * minMargin)
|
||||
property int itemsPerRow: availableWidth / cellWidth
|
||||
property real horizontalMargin: itemsPerRow < count && availableWidth >= cellWidth ?
|
||||
(availableWidth % cellWidth) / 2 : minMargin
|
||||
|
||||
function updateMargins() {
|
||||
leftMargin = horizontalMargin
|
||||
rightMargin = horizontalMargin
|
||||
|
||||
if (hasBrokenMargins) {
|
||||
anchors.leftMargin = leftMargin
|
||||
anchors.rightMargin = rightMargin
|
||||
}
|
||||
}
|
||||
|
||||
onHorizontalMarginChanged: {
|
||||
updateMargins()
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
if (hasBrokenMargins) {
|
||||
// This will cause an anchor conflict with the parent StackView
|
||||
// which breaks animation, but otherwise the grid will not be
|
||||
// centered in the window.
|
||||
anchors.fill = parent
|
||||
anchors.topMargin = topMargin
|
||||
anchors.bottomMargin = bottomMargin
|
||||
}
|
||||
|
||||
updateMargins()
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,10 @@
|
||||
import QtQuick 2.0
|
||||
import QtQuick.Controls 2.2
|
||||
import QtQuick.Dialogs 1.2
|
||||
|
||||
import ComputerManager 1.0
|
||||
import Session 1.0
|
||||
|
||||
Item {
|
||||
anchors.fill: parent
|
||||
|
||||
function onSearchingComputer() {
|
||||
stageLabel.text = "Establishing connection to PC..."
|
||||
}
|
||||
@@ -21,13 +18,8 @@ Item {
|
||||
errorDialog.open()
|
||||
}
|
||||
|
||||
// The StackView will trigger a visibility change when
|
||||
// we're pushed onto it, causing our onVisibleChanged
|
||||
// routine to run, but only if we start as invisible
|
||||
visible: false
|
||||
|
||||
onVisibleChanged: {
|
||||
if (visible && !launcher.isExecuted()) {
|
||||
StackView.onActivated: {
|
||||
if (!launcher.isExecuted()) {
|
||||
toolBar.visible = false
|
||||
launcher.searchingComputer.connect(onSearchingComputer)
|
||||
launcher.quittingApp.connect(onQuittingApp)
|
||||
@@ -55,16 +47,11 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
MessageDialog {
|
||||
ErrorMessageDialog {
|
||||
id: errorDialog
|
||||
modality:Qt.WindowModal
|
||||
icon: StandardIcon.Critical
|
||||
standardButtons: StandardButton.Ok
|
||||
|
||||
onVisibleChanged: {
|
||||
if (!visible) {
|
||||
Qt.quit()
|
||||
}
|
||||
onClosed: {
|
||||
Qt.quit()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
import QtQml 2.2
|
||||
import QtQuick 2.0
|
||||
import QtQuick.Controls 2.2
|
||||
import QtQuick.Dialogs 1.2
|
||||
|
||||
import ComputerManager 1.0
|
||||
|
||||
Item {
|
||||
visible: false
|
||||
|
||||
function onSearchingComputer() {
|
||||
stageLabel.text = "Establishing connection to PC..."
|
||||
}
|
||||
@@ -36,8 +32,8 @@ Item {
|
||||
quitAppDialog.open()
|
||||
}
|
||||
|
||||
onVisibleChanged: {
|
||||
if (visible && !launcher.isExecuted()) {
|
||||
StackView.onActivated: {
|
||||
if (!launcher.isExecuted()) {
|
||||
toolBar.visible = false
|
||||
launcher.searchingComputer.connect(onSearchingComputer)
|
||||
launcher.searchingApp.connect(onSearchingApp)
|
||||
@@ -66,26 +62,18 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
MessageDialog {
|
||||
ErrorMessageDialog {
|
||||
id: errorDialog
|
||||
modality:Qt.WindowModal
|
||||
icon: StandardIcon.Critical
|
||||
standardButtons: StandardButton.Ok | StandardButton.Help
|
||||
onHelp: {
|
||||
Qt.openUrlExternally("https://github.com/moonlight-stream/moonlight-docs/wiki/Troubleshooting");
|
||||
}
|
||||
onVisibleChanged: {
|
||||
if (!visible) {
|
||||
Qt.quit();
|
||||
}
|
||||
|
||||
onClosed: {
|
||||
Qt.quit();
|
||||
}
|
||||
}
|
||||
|
||||
MessageDialog {
|
||||
NavigableMessageDialog {
|
||||
id: quitAppDialog
|
||||
modality:Qt.WindowModal
|
||||
text:"Are you sure you want to quit " + appName +"? Any unsaved progress will be lost."
|
||||
standardButtons: StandardButton.Yes | StandardButton.No
|
||||
standardButtons: Dialog.Yes | Dialog.No
|
||||
property string appName : ""
|
||||
|
||||
function quitApp() {
|
||||
@@ -96,29 +84,7 @@ Item {
|
||||
launcher.quitRunningApp()
|
||||
}
|
||||
|
||||
onYes: quitApp()
|
||||
|
||||
// For keyboard/gamepad navigation
|
||||
onAccepted: quitApp()
|
||||
|
||||
// Exit process if app quit is rejected (reacts also to closing of the
|
||||
// dialog from title bar's close button).
|
||||
// Note: this depends on undocumented behavior of visibleChanged()
|
||||
// signal being emitted before yes() or accepted() has been emitted.
|
||||
onVisibleChanged: {
|
||||
if (!visible) {
|
||||
quitTimer.start()
|
||||
}
|
||||
}
|
||||
Component.onCompleted: {
|
||||
yes.connect(quitTimer.stop)
|
||||
accepted.connect(quitTimer.stop)
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: quitTimer
|
||||
interval: 100
|
||||
onTriggered: Qt.quit()
|
||||
onRejected: Qt.quit()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import QtQuick 2.0
|
||||
import QtQuick.Controls 2.2
|
||||
|
||||
import SystemProperties 1.0
|
||||
|
||||
NavigableMessageDialog {
|
||||
standardButtons: Dialog.Ok | (SystemProperties.hasBrowser ? Dialog.Help : 0)
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import QtQuick 2.0
|
||||
import QtQuick.Controls 2.2
|
||||
|
||||
Dialog {
|
||||
parent: overlay
|
||||
|
||||
x: Math.round((parent.width - width) / 2)
|
||||
y: Math.round((parent.height - height) / 2)
|
||||
|
||||
onAboutToHide: {
|
||||
// We must force focus back to the last item for platforms without
|
||||
// support for more than one active window like Steam Link. If
|
||||
// we don't, gamepad and keyboard navigation will break after a
|
||||
// dialog appears.
|
||||
stackView.forceActiveFocus()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import QtQuick 2.0
|
||||
import QtQuick.Controls 2.2
|
||||
|
||||
Menu {
|
||||
onOpened: {
|
||||
itemAt(0).forceActiveFocus(Qt.TabFocusReason)
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,27 @@ import QtQuick 2.0
|
||||
import QtQuick.Controls 2.2
|
||||
|
||||
MenuItem {
|
||||
// Qt 5.10 has a menu property, but we need to support 5.9
|
||||
// so we must make our own.
|
||||
property Menu parentMenu
|
||||
|
||||
// Ensure focus can't be given to an invisible item
|
||||
enabled: visible
|
||||
height: visible ? implicitHeight : 0
|
||||
focusPolicy: visible ? Qt.TabFocus : Qt.NoFocus
|
||||
|
||||
onTriggered: {
|
||||
// We must close the context menu first or
|
||||
// it can steal focus from any dialogs that
|
||||
// onTriggered may spawn.
|
||||
parentMenu.close()
|
||||
}
|
||||
|
||||
Keys.onReturnPressed: {
|
||||
triggered()
|
||||
}
|
||||
|
||||
Keys.onEscapePressed: {
|
||||
parentMenu.close()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
import QtQuick 2.0
|
||||
import QtQuick.Controls 2.2
|
||||
import QtQuick.Layouts 1.2
|
||||
|
||||
NavigableDialog {
|
||||
id: dialog
|
||||
|
||||
property alias text: dialogLabel.dialogText
|
||||
|
||||
property string helpText
|
||||
property string helpUrl : "https://github.com/moonlight-stream/moonlight-docs/wiki/Troubleshooting"
|
||||
property string helpTextSeparator : " "
|
||||
|
||||
onOpened: {
|
||||
// Force keyboard focus on the label so keyboard navigation works
|
||||
dialogLabel.forceActiveFocus()
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
spacing: 10
|
||||
|
||||
Image {
|
||||
source: (standardButtons & Dialog.Yes) ?
|
||||
"qrc:/res/baseline-help_outline-24px.svg" :
|
||||
"qrc:/res/baseline-error_outline-24px.svg"
|
||||
sourceSize {
|
||||
// The icon should be square so use the height as the width too
|
||||
width: 50
|
||||
height: 50
|
||||
}
|
||||
}
|
||||
|
||||
Label {
|
||||
property string dialogText
|
||||
|
||||
id: dialogLabel
|
||||
text: dialogText + ((helpText && (standardButtons & Dialog.Help)) ? (helpTextSeparator + helpText) : "")
|
||||
wrapMode: Text.Wrap
|
||||
elide: Label.ElideRight
|
||||
|
||||
// Cap the width so the dialog doesn't grow horizontally forever. This
|
||||
// will cause word wrap to kick in.
|
||||
Layout.maximumWidth: 400
|
||||
Layout.maximumHeight: 400
|
||||
|
||||
Keys.onReturnPressed: {
|
||||
accept()
|
||||
}
|
||||
|
||||
Keys.onEscapePressed: {
|
||||
reject()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
footer: DialogButtonBox {
|
||||
id: dialogButtonBox
|
||||
standardButtons: dialog.standardButtons
|
||||
|
||||
onHelpRequested: {
|
||||
Qt.openUrlExternally(helpUrl)
|
||||
close()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,27 @@ import QtQuick 2.0
|
||||
import QtQuick.Controls 2.2
|
||||
|
||||
ToolButton {
|
||||
property string iconSource
|
||||
|
||||
activeFocusOnTab: true
|
||||
|
||||
// FIXME: We're using an Image here rather than icon.source because
|
||||
// icons don't work on Qt 5.9 LTS.
|
||||
Image {
|
||||
id: image
|
||||
source: iconSource
|
||||
anchors.centerIn: parent.background
|
||||
sourceSize {
|
||||
width: parent.background.width * 1.10
|
||||
height: parent.background.height * 1.10
|
||||
}
|
||||
}
|
||||
|
||||
// This determines the size of the Material highlight. We increase it
|
||||
// from the default because we use larger than normal icons for TV readability.
|
||||
background.width: (parent.height - parent.anchors.bottomMargin - parent.anchors.topMargin) * 0.60
|
||||
background.height: (parent.height - parent.anchors.bottomMargin - parent.anchors.topMargin) * 0.60
|
||||
|
||||
Keys.onReturnPressed: {
|
||||
clicked()
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import QtQuick 2.9
|
||||
import QtQuick.Controls 2.2
|
||||
import QtQuick.Dialogs 1.2
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick.Window 2.2
|
||||
|
||||
import ComputerModel 1.0
|
||||
|
||||
@@ -10,48 +7,41 @@ import ComputerManager 1.0
|
||||
import StreamingPreferences 1.0
|
||||
import SdlGamepadKeyNavigation 1.0
|
||||
|
||||
GridView {
|
||||
CenteredGridView {
|
||||
property ComputerModel computerModel : createModel()
|
||||
|
||||
id: pcGrid
|
||||
focus: true
|
||||
activeFocusOnTab: true
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: (parent.width % (cellWidth + anchors.rightMargin)) / 2
|
||||
anchors.topMargin: 20
|
||||
anchors.rightMargin: 5
|
||||
anchors.bottomMargin: 5
|
||||
cellWidth: 350; cellHeight: 350;
|
||||
topMargin: 20
|
||||
bottomMargin: 5
|
||||
cellWidth: 310; cellHeight: 330;
|
||||
objectName: "Computers"
|
||||
|
||||
// The StackView will trigger a visibility change when
|
||||
// we're pushed onto it, causing our onVisibleChanged
|
||||
// routine to run, but only if we start as invisible
|
||||
visible: false
|
||||
|
||||
StreamingPreferences {
|
||||
id: prefs
|
||||
}
|
||||
|
||||
SdlGamepadKeyNavigation {
|
||||
id: gamepadKeyNav
|
||||
}
|
||||
|
||||
onVisibleChanged: {
|
||||
if (visible) {
|
||||
gamepadKeyNav.enable()
|
||||
}
|
||||
else {
|
||||
gamepadKeyNav.disable()
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
// Don't show any highlighted item until interacting with them.
|
||||
// We do this here instead of onActivated to avoid losing the user's
|
||||
// selection when backing out of a different page of the app.
|
||||
currentIndex = -1
|
||||
}
|
||||
|
||||
StackView.onActivated: {
|
||||
// Setup signals on CM
|
||||
ComputerManager.computerAddCompleted.connect(addComplete)
|
||||
|
||||
// Don't show any highlighted item until interacting with them
|
||||
currentIndex = -1
|
||||
// This is a bit of a hack to do this here as opposed to main.qml, but
|
||||
// we need it enabled before calling getConnectedGamepads() and PcView
|
||||
// is never destroyed, so it should be okay.
|
||||
SdlGamepadKeyNavigation.enable()
|
||||
|
||||
// Highlight the first item if a gamepad is connected
|
||||
if (currentIndex == -1 && SdlGamepadKeyNavigation.getConnectedGamepads() > 0) {
|
||||
currentIndex = 0
|
||||
}
|
||||
}
|
||||
|
||||
StackView.onDeactivating: {
|
||||
ComputerManager.computerAddCompleted.disconnect(addComplete)
|
||||
}
|
||||
|
||||
function pairingComplete(error)
|
||||
@@ -62,6 +52,7 @@ GridView {
|
||||
// Display a failed dialog if we got an error
|
||||
if (error !== undefined) {
|
||||
errorDialog.text = error
|
||||
errorDialog.helpText = ""
|
||||
errorDialog.open()
|
||||
}
|
||||
}
|
||||
@@ -69,7 +60,8 @@ GridView {
|
||||
function addComplete(success)
|
||||
{
|
||||
if (!success) {
|
||||
errorDialog.text = "Unable to connect to the specified PC. Click the Help button for possible solutions."
|
||||
errorDialog.text = "Unable to connect to the specified PC."
|
||||
errorDialog.helpText = "Click the Help button for possible solutions."
|
||||
errorDialog.open()
|
||||
}
|
||||
}
|
||||
@@ -82,18 +74,37 @@ GridView {
|
||||
return model
|
||||
}
|
||||
|
||||
Row {
|
||||
anchors.centerIn: parent
|
||||
spacing: 5
|
||||
visible: pcGrid.count === 0
|
||||
|
||||
BusyIndicator {
|
||||
id: searchSpinner
|
||||
visible: StreamingPreferences.enableMdns
|
||||
}
|
||||
|
||||
Label {
|
||||
height: searchSpinner.height
|
||||
elide: Label.ElideRight
|
||||
text: StreamingPreferences.enableMdns ? "Searching for PCs with NVIDIA GameStream enabled..."
|
||||
: "Automatic PC discovery is disabled. Add your PC manually."
|
||||
font.pointSize: 20
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
wrapMode: Text.Wrap
|
||||
}
|
||||
}
|
||||
|
||||
model: computerModel
|
||||
|
||||
delegate: NavigableItemDelegate {
|
||||
width: 300; height: 300;
|
||||
width: 300; height: 320;
|
||||
grid: pcGrid
|
||||
|
||||
Image {
|
||||
id: pcIcon
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
source: {
|
||||
model.addPc ? "qrc:/res/ic_add_to_queue_white_48px.svg" : "qrc:/res/ic_tv_white_48px.svg"
|
||||
}
|
||||
source: "qrc:/res/ic_tv_white_48px.svg"
|
||||
sourceSize {
|
||||
width: 200
|
||||
height: 200
|
||||
@@ -106,7 +117,7 @@ GridView {
|
||||
anchors.horizontalCenter: pcIcon.horizontalCenter
|
||||
anchors.verticalCenter: pcIcon.verticalCenter
|
||||
anchors.verticalCenterOffset: -10
|
||||
visible: !model.addPc && !model.statusUnknown && (!model.online || !model.paired)
|
||||
visible: !model.statusUnknown && (!model.online || !model.paired)
|
||||
source: !model.online ? "qrc:/res/baseline-warning-24px.svg" : "qrc:/res/baseline-lock-24px.svg"
|
||||
sourceSize {
|
||||
width: 75
|
||||
@@ -121,7 +132,7 @@ GridView {
|
||||
anchors.verticalCenterOffset: -10
|
||||
width: 75
|
||||
height: 75
|
||||
visible: !model.addPc && model.statusUnknown
|
||||
visible: model.statusUnknown
|
||||
}
|
||||
|
||||
Label {
|
||||
@@ -130,19 +141,17 @@ GridView {
|
||||
|
||||
width: parent.width
|
||||
anchors.top: pcIcon.bottom
|
||||
anchors.bottom: parent.bottom
|
||||
font.pointSize: 36
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
wrapMode: Text.Wrap
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
Menu {
|
||||
NavigableMenu {
|
||||
id: pcContextMenu
|
||||
NavigableMenuItem {
|
||||
text: "Wake PC"
|
||||
onTriggered: computerModel.wakeComputer(index)
|
||||
visible: !model.addPc && !model.online && model.wakeable
|
||||
}
|
||||
NavigableMenuItem {
|
||||
parentMenu: pcContextMenu
|
||||
text: "Delete PC"
|
||||
onTriggered: {
|
||||
deletePcDialog.pcIndex = index
|
||||
@@ -150,13 +159,16 @@ GridView {
|
||||
deletePcDialog.open()
|
||||
}
|
||||
}
|
||||
NavigableMenuItem {
|
||||
parentMenu: pcContextMenu
|
||||
text: "Wake PC"
|
||||
onTriggered: computerModel.wakeComputer(index)
|
||||
visible: !model.online && model.wakeable
|
||||
}
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
if (model.addPc) {
|
||||
addPcDialog.open()
|
||||
}
|
||||
else if (model.online) {
|
||||
if (model.online) {
|
||||
if (model.paired) {
|
||||
// go to game view
|
||||
var component = Qt.createComponent("AppView.qml")
|
||||
@@ -176,7 +188,8 @@ GridView {
|
||||
}
|
||||
else {
|
||||
// cannot pair while something is streaming or attempting to pair
|
||||
errorDialog.text = "This PC is currently busy. Make sure to quit any running games and try again."
|
||||
errorDialog.text = "You cannot pair while a previous session is still running on the host PC. Quit any running games or reboot the host PC, then try pairing again."
|
||||
errorDialog.helpText = ""
|
||||
errorDialog.open()
|
||||
}
|
||||
}
|
||||
@@ -186,111 +199,72 @@ GridView {
|
||||
}
|
||||
}
|
||||
|
||||
onPressAndHold: {
|
||||
// popup() ensures the menu appears under the mouse cursor
|
||||
if (pcContextMenu.popup) {
|
||||
pcContextMenu.popup()
|
||||
}
|
||||
else {
|
||||
// Qt 5.9 doesn't have popup()
|
||||
pcContextMenu.open()
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.RightButton;
|
||||
onClicked: {
|
||||
if (!model.addPc) {
|
||||
// popup() ensures the menu appears under the mouse cursor
|
||||
pcContextMenu.popup()
|
||||
}
|
||||
parent.onPressAndHold()
|
||||
}
|
||||
}
|
||||
|
||||
Keys.onMenuPressed: {
|
||||
if (!model.addPc) {
|
||||
// We must use open() here so the menu is positioned on
|
||||
// the ItemDelegate and not where the mouse cursor is
|
||||
pcContextMenu.open()
|
||||
}
|
||||
// We must use open() here so the menu is positioned on
|
||||
// the ItemDelegate and not where the mouse cursor is
|
||||
pcContextMenu.open()
|
||||
}
|
||||
}
|
||||
|
||||
MessageDialog {
|
||||
ErrorMessageDialog {
|
||||
id: errorDialog
|
||||
// don't allow edits to the rest of the window while open
|
||||
modality:Qt.WindowModal
|
||||
icon: StandardIcon.Critical
|
||||
standardButtons: StandardButton.Ok | StandardButton.Help
|
||||
onHelp: {
|
||||
// Using Setup-Guide here instead of Troubleshooting because it's likely that users
|
||||
// will arrive here by forgetting to enable GameStream or not forwarding ports.
|
||||
Qt.openUrlExternally("https://github.com/moonlight-stream/moonlight-docs/wiki/Setup-Guide");
|
||||
}
|
||||
|
||||
// Using Setup-Guide here instead of Troubleshooting because it's likely that users
|
||||
// will arrive here by forgetting to enable GameStream or not forwarding ports.
|
||||
helpUrl: "https://github.com/moonlight-stream/moonlight-docs/wiki/Setup-Guide"
|
||||
}
|
||||
|
||||
MessageDialog {
|
||||
NavigableMessageDialog {
|
||||
id: pairDialog
|
||||
// don't allow edits to the rest of the window while open
|
||||
modality:Qt.WindowModal
|
||||
property string pin : "0000"
|
||||
text:"Please enter " + pin + " on your GameStream PC. This dialog will close when pairing is completed."
|
||||
standardButtons: StandardButton.Cancel
|
||||
standardButtons: Dialog.Cancel
|
||||
onRejected: {
|
||||
// FIXME: We should interrupt pairing here
|
||||
}
|
||||
}
|
||||
|
||||
MessageDialog {
|
||||
NavigableMessageDialog {
|
||||
id: deletePcDialog
|
||||
// don't allow edits to the rest of the window while open
|
||||
modality:Qt.WindowModal
|
||||
property int pcIndex : -1;
|
||||
text:"Are you sure you want to remove this PC?"
|
||||
standardButtons: StandardButton.Yes | StandardButton.No
|
||||
standardButtons: Dialog.Yes | Dialog.No
|
||||
|
||||
function deletePc() {
|
||||
console.log("deleting PC pairing for PC at index: " + pcIndex)
|
||||
computerModel.deleteComputer(pcIndex);
|
||||
}
|
||||
|
||||
onYes: deletePc()
|
||||
|
||||
// For keyboard/gamepad activation
|
||||
onAccepted: deletePc()
|
||||
}
|
||||
|
||||
Dialog {
|
||||
id: addPcDialog
|
||||
property string label: "Enter the IP address of your GameStream PC"
|
||||
property string hint: "192.168.1.100"
|
||||
property alias editText : editTextItem
|
||||
|
||||
standardButtons: StandardButton.Ok | StandardButton.Cancel
|
||||
onVisibleChanged: {
|
||||
editTextItem.focus = true
|
||||
editTextItem.selectAll()
|
||||
}
|
||||
onAccepted: {
|
||||
ComputerManager.addNewHost(editText.text, false)
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
Text {
|
||||
id: addPcDialogLabel
|
||||
text: addPcDialog.label
|
||||
}
|
||||
Rectangle {
|
||||
implicitWidth: parent.parent.width
|
||||
height: editTextItem.height
|
||||
|
||||
TextInput {
|
||||
id: editTextItem
|
||||
inputMethodHints: Qt.ImhPreferUppercase
|
||||
text: addPcDialog.hint
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ScrollBar.vertical: ScrollBar {
|
||||
parent: pcGrid.parent
|
||||
anchors {
|
||||
top: pcGrid.top
|
||||
left: pcGrid.right
|
||||
bottom: pcGrid.bottom
|
||||
|
||||
leftMargin: -10
|
||||
top: parent.top
|
||||
right: parent.right
|
||||
bottom: parent.bottom
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import QtQuick 2.0
|
||||
import QtQuick.Controls 2.2
|
||||
import QtQuick.Dialogs 1.2
|
||||
|
||||
import ComputerManager 1.0
|
||||
import Session 1.0
|
||||
@@ -12,13 +11,6 @@ Item {
|
||||
|
||||
property string stageText : "Quitting " + appName + "..."
|
||||
|
||||
anchors.fill: parent
|
||||
|
||||
// The StackView will trigger a visibility change when
|
||||
// we're pushed onto it, causing our onVisibleChanged
|
||||
// routine to run, but only if we start as invisible
|
||||
visible: false
|
||||
|
||||
function quitAppCompleted(error)
|
||||
{
|
||||
// Display a failed dialog if we got an error
|
||||
@@ -27,26 +19,32 @@ Item {
|
||||
errorDialog.open()
|
||||
}
|
||||
|
||||
// Exit this view
|
||||
stackView.pop()
|
||||
|
||||
// If we're supposed to launch another game after this, do so now
|
||||
if (error === undefined && nextSession !== null) {
|
||||
var component = Qt.createComponent("StreamSegue.qml")
|
||||
var segue = component.createObject(stackView, {"appName": nextAppName, "session": nextSession})
|
||||
stackView.push(segue)
|
||||
stackView.replace(segue)
|
||||
}
|
||||
else {
|
||||
// Exit this view
|
||||
stackView.pop()
|
||||
}
|
||||
}
|
||||
|
||||
onVisibleChanged: {
|
||||
if (visible) {
|
||||
// Connect the quit completion signal
|
||||
ComputerManager.quitAppCompleted.connect(quitAppCompleted)
|
||||
}
|
||||
else {
|
||||
// Disconnect the signal
|
||||
ComputerManager.quitAppCompleted.disconnect(quitAppCompleted)
|
||||
}
|
||||
StackView.onActivated: {
|
||||
// Hide the toolbar before we start loading
|
||||
toolBar.visible = false
|
||||
|
||||
// Connect the quit completion signal
|
||||
ComputerManager.quitAppCompleted.connect(quitAppCompleted)
|
||||
}
|
||||
|
||||
StackView.onDeactivating: {
|
||||
// Show the toolbar again
|
||||
toolBar.visible = true
|
||||
|
||||
// Disconnect the signal
|
||||
ComputerManager.quitAppCompleted.disconnect(quitAppCompleted)
|
||||
}
|
||||
|
||||
Row {
|
||||
@@ -68,10 +66,7 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
MessageDialog {
|
||||
ErrorMessageDialog {
|
||||
id: errorDialog
|
||||
modality:Qt.WindowModal
|
||||
icon: StandardIcon.Critical
|
||||
standardButtons: StandardButton.Ok
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@ import QtQuick.Controls 2.2
|
||||
import StreamingPreferences 1.0
|
||||
import ComputerManager 1.0
|
||||
import SdlGamepadKeyNavigation 1.0
|
||||
import SystemProperties 1.0
|
||||
|
||||
Flickable {
|
||||
id: settingsPage
|
||||
objectName: "Settings"
|
||||
anchors.fill: parent
|
||||
|
||||
contentWidth: settingsColumn1.width > settingsColumn2.width ? settingsColumn1.width : settingsColumn2.width
|
||||
contentHeight: settingsColumn1.height > settingsColumn2.height ? settingsColumn1.height : settingsColumn2.height
|
||||
@@ -24,31 +24,22 @@ Flickable {
|
||||
}
|
||||
}
|
||||
|
||||
StreamingPreferences {
|
||||
id: prefs
|
||||
}
|
||||
StackView.onActivated: {
|
||||
// This enables Tab and BackTab based navigation rather than arrow keys.
|
||||
// It is required to shift focus between controls on the settings page.
|
||||
SdlGamepadKeyNavigation.setUiNavMode(true)
|
||||
|
||||
// The StackView will trigger a visibility change when
|
||||
// we're pushed onto it, causing our onVisibleChanged
|
||||
// routine to run, but only if we start as invisible
|
||||
visible: false
|
||||
|
||||
SdlGamepadKeyNavigation {
|
||||
id: gamepadKeyNav
|
||||
}
|
||||
|
||||
onVisibleChanged: {
|
||||
if (visible) {
|
||||
gamepadKeyNav.setSettingsMode(true)
|
||||
gamepadKeyNav.enable()
|
||||
}
|
||||
else {
|
||||
gamepadKeyNav.disable()
|
||||
// Highlight the first item if a gamepad is connected
|
||||
if (SdlGamepadKeyNavigation.getConnectedGamepads() > 0) {
|
||||
resolutionComboBox.forceActiveFocus(Qt.TabFocus)
|
||||
}
|
||||
}
|
||||
|
||||
Component.onDestruction: {
|
||||
prefs.save()
|
||||
StackView.onDeactivating: {
|
||||
SdlGamepadKeyNavigation.setUiNavMode(false)
|
||||
|
||||
// Save the prefs so the Session can observe the changes
|
||||
StreamingPreferences.save()
|
||||
}
|
||||
|
||||
Column {
|
||||
@@ -98,10 +89,10 @@ Flickable {
|
||||
// Some platforms have different desktop resolutions
|
||||
// and native resolutions (like macOS with Retina displays)
|
||||
if (displayResIndex == 0) {
|
||||
screenRect = prefs.getDesktopResolution(displayIndex)
|
||||
screenRect = SystemProperties.getDesktopResolution(displayIndex)
|
||||
}
|
||||
else {
|
||||
screenRect = prefs.getNativeResolution(displayIndex)
|
||||
screenRect = SystemProperties.getNativeResolution(displayIndex)
|
||||
}
|
||||
|
||||
if (screenRect.width === 0) {
|
||||
@@ -140,8 +131,8 @@ Flickable {
|
||||
|
||||
// load the saved width/height, and iterate through the ComboBox until a match is found
|
||||
// and set it to that index.
|
||||
var saved_width = prefs.width
|
||||
var saved_height = prefs.height
|
||||
var saved_width = StreamingPreferences.width
|
||||
var saved_height = StreamingPreferences.height
|
||||
currentIndex = 0
|
||||
for (var i = 0; i < resolutionListModel.count; i++) {
|
||||
var el_width = parseInt(resolutionListModel.get(i).video_width);
|
||||
@@ -190,12 +181,14 @@ Flickable {
|
||||
var selectedHeight = parseInt(resolutionListModel.get(currentIndex).video_height)
|
||||
|
||||
// Only modify the bitrate if the values actually changed
|
||||
if (prefs.width !== selectedWidth || prefs.height !== selectedHeight) {
|
||||
prefs.width = selectedWidth
|
||||
prefs.height = selectedHeight
|
||||
if (StreamingPreferences.width !== selectedWidth || StreamingPreferences.height !== selectedHeight) {
|
||||
StreamingPreferences.width = selectedWidth
|
||||
StreamingPreferences.height = selectedHeight
|
||||
|
||||
prefs.bitrateKbps = prefs.getDefaultBitrate(prefs.width, prefs.height, prefs.fps);
|
||||
slider.value = prefs.bitrateKbps
|
||||
StreamingPreferences.bitrateKbps = StreamingPreferences.getDefaultBitrate(StreamingPreferences.width,
|
||||
StreamingPreferences.height,
|
||||
StreamingPreferences.fps);
|
||||
slider.value = StreamingPreferences.bitrateKbps
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -204,15 +197,14 @@ Flickable {
|
||||
function createModel() {
|
||||
var fpsListModel = Qt.createQmlObject('import QtQuick 2.0; ListModel {}', parent, '')
|
||||
|
||||
// Get the max supported FPS on this system
|
||||
var max_fps = prefs.getMaximumStreamingFrameRate();
|
||||
var max_fps = SystemProperties.maximumStreamingFrameRate
|
||||
|
||||
// Default entries
|
||||
fpsListModel.append({"text": "30 FPS", "video_fps": "30"})
|
||||
fpsListModel.append({"text": "60 FPS", "video_fps": "60"})
|
||||
|
||||
// Add unsupported FPS values that come before the display max FPS
|
||||
if (prefs.unsupportedFps) {
|
||||
if (StreamingPreferences.unsupportedFps) {
|
||||
if (max_fps > 90) {
|
||||
fpsListModel.append({"text": "90 FPS (Unsupported)", "video_fps": "90"})
|
||||
}
|
||||
@@ -225,7 +217,7 @@ Flickable {
|
||||
// handle wonky displays that report just over 60 Hz.
|
||||
if (max_fps > 64) {
|
||||
// Mark any FPS value greater than 120 as unsupported
|
||||
if (prefs.unsupportedFps && max_fps > 120) {
|
||||
if (StreamingPreferences.unsupportedFps && max_fps > 120) {
|
||||
fpsListModel.append({"text": max_fps+" FPS (Unsupported)", "video_fps": ""+max_fps})
|
||||
}
|
||||
else if (max_fps > 120) {
|
||||
@@ -237,7 +229,7 @@ Flickable {
|
||||
}
|
||||
|
||||
// Add unsupported FPS values that come after the display max FPS
|
||||
if (prefs.unsupportedFps) {
|
||||
if (StreamingPreferences.unsupportedFps) {
|
||||
if (max_fps < 90) {
|
||||
fpsListModel.append({"text": "90 FPS (Unsupported)", "video_fps": "90"})
|
||||
}
|
||||
@@ -252,7 +244,7 @@ Flickable {
|
||||
function reinitialize() {
|
||||
model = createModel()
|
||||
|
||||
var saved_fps = prefs.fps
|
||||
var saved_fps = StreamingPreferences.fps
|
||||
currentIndex = 0
|
||||
for (var i = 0; i < model.count; i++) {
|
||||
var el_fps = parseInt(model.get(i).video_fps);
|
||||
@@ -279,11 +271,13 @@ Flickable {
|
||||
var selectedFps = parseInt(model.get(currentIndex).video_fps)
|
||||
|
||||
// Only modify the bitrate if the values actually changed
|
||||
if (prefs.fps !== selectedFps) {
|
||||
prefs.fps = selectedFps
|
||||
if (StreamingPreferences.fps !== selectedFps) {
|
||||
StreamingPreferences.fps = selectedFps
|
||||
|
||||
prefs.bitrateKbps = prefs.getDefaultBitrate(prefs.width, prefs.height, prefs.fps);
|
||||
slider.value = prefs.bitrateKbps
|
||||
StreamingPreferences.bitrateKbps = StreamingPreferences.getDefaultBitrate(StreamingPreferences.width,
|
||||
StreamingPreferences.height,
|
||||
StreamingPreferences.fps);
|
||||
slider.value = StreamingPreferences.bitrateKbps
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -300,16 +294,15 @@ Flickable {
|
||||
Label {
|
||||
width: parent.width
|
||||
id: bitrateDesc
|
||||
text: qsTr("Lower bitrate to reduce lag and stuttering. Raise bitrate to increase image quality.")
|
||||
text: qsTr("Lower the bitrate on slower connections. Raise the bitrate to increase image quality.")
|
||||
font.pointSize: 9
|
||||
wrapMode: Text.Wrap
|
||||
}
|
||||
|
||||
Slider {
|
||||
id: slider
|
||||
wheelEnabled: true
|
||||
|
||||
value: prefs.bitrateKbps
|
||||
value: StreamingPreferences.bitrateKbps
|
||||
|
||||
stepSize: 500
|
||||
from : 500
|
||||
@@ -320,7 +313,7 @@ Flickable {
|
||||
|
||||
onValueChanged: {
|
||||
bitrateTitle.text = "Video bitrate: " + (value / 1000.0) + " Mbps"
|
||||
prefs.bitrateKbps = value
|
||||
StreamingPreferences.bitrateKbps = value
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,7 +328,7 @@ Flickable {
|
||||
AutoResizingComboBox {
|
||||
// ignore setting the index at first, and actually set it when the component is loaded
|
||||
Component.onCompleted: {
|
||||
var savedWm = prefs.windowMode
|
||||
var savedWm = StreamingPreferences.windowMode
|
||||
currentIndex = 0
|
||||
for (var i = 0; i < windowModeListModel.count; i++) {
|
||||
var thisWm = windowModeListModel.get(i).val;
|
||||
@@ -366,7 +359,7 @@ Flickable {
|
||||
}
|
||||
}
|
||||
onActivated: {
|
||||
prefs.windowMode = windowModeListModel.get(currentIndex).val
|
||||
StreamingPreferences.windowMode = windowModeListModel.get(currentIndex).val
|
||||
}
|
||||
|
||||
ToolTip.delay: 1000
|
||||
@@ -378,11 +371,11 @@ Flickable {
|
||||
CheckBox {
|
||||
id: vsyncCheck
|
||||
hoverEnabled: true
|
||||
text: "Enable V-Sync"
|
||||
text: "V-Sync"
|
||||
font.pointSize: 12
|
||||
checked: prefs.enableVsync
|
||||
checked: StreamingPreferences.enableVsync
|
||||
onCheckedChanged: {
|
||||
prefs.enableVsync = checked
|
||||
StreamingPreferences.enableVsync = checked
|
||||
}
|
||||
|
||||
ToolTip.delay: 1000
|
||||
@@ -390,6 +383,22 @@ Flickable {
|
||||
ToolTip.visible: hovered
|
||||
ToolTip.text: "Disabling V-Sync allows sub-frame rendering latency, but it can display visible tearing"
|
||||
}
|
||||
|
||||
CheckBox {
|
||||
id: framePacingCheck
|
||||
hoverEnabled: true
|
||||
text: "Frame pacing"
|
||||
font.pointSize: 12
|
||||
enabled: StreamingPreferences.enableVsync
|
||||
checked: StreamingPreferences.enableVsync && StreamingPreferences.framePacing
|
||||
onCheckedChanged: {
|
||||
StreamingPreferences.framePacing = checked
|
||||
}
|
||||
ToolTip.delay: 1000
|
||||
ToolTip.timeout: 5000
|
||||
ToolTip.visible: hovered
|
||||
ToolTip.text: "Frame pacing reduces micro-stutter by delaying frames that come in too early"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,7 +425,7 @@ Flickable {
|
||||
AutoResizingComboBox {
|
||||
// ignore setting the index at first, and actually set it when the component is loaded
|
||||
Component.onCompleted: {
|
||||
var saved_audio = prefs.audioConfig
|
||||
var saved_audio = StreamingPreferences.audioConfig
|
||||
currentIndex = 0
|
||||
for (var i = 0; i < audioListModel.count; i++) {
|
||||
var el_audio = audioListModel.get(i).val;
|
||||
@@ -443,7 +452,7 @@ Flickable {
|
||||
}
|
||||
// ::onActivated must be used, as it only listens for when the index is changed by a human
|
||||
onActivated : {
|
||||
prefs.audioConfig = audioListModel.get(currentIndex).val
|
||||
StreamingPreferences.audioConfig = audioListModel.get(currentIndex).val
|
||||
}
|
||||
}
|
||||
|
||||
@@ -465,9 +474,19 @@ Flickable {
|
||||
id: startMaximizedCheck
|
||||
text: "Maximize Moonlight window on startup"
|
||||
font.pointSize: 12
|
||||
checked: !prefs.startWindowed
|
||||
checked: !StreamingPreferences.startWindowed
|
||||
onCheckedChanged: {
|
||||
prefs.startWindowed = !checked
|
||||
StreamingPreferences.startWindowed = !checked
|
||||
}
|
||||
}
|
||||
|
||||
CheckBox {
|
||||
id: connectionWarningsCheck
|
||||
text: "Show connection quality warnings"
|
||||
font.pointSize: 12
|
||||
checked: StreamingPreferences.connectionWarnings
|
||||
onCheckedChanged: {
|
||||
StreamingPreferences.connectionWarnings = checked
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -495,9 +514,9 @@ Flickable {
|
||||
id: singleControllerCheck
|
||||
text: "Force gamepad #1 always present"
|
||||
font.pointSize: 12
|
||||
checked: !prefs.multiController
|
||||
checked: !StreamingPreferences.multiController
|
||||
onCheckedChanged: {
|
||||
prefs.multiController = !checked
|
||||
StreamingPreferences.multiController = !checked
|
||||
}
|
||||
|
||||
ToolTip.delay: 1000
|
||||
@@ -512,9 +531,9 @@ Flickable {
|
||||
hoverEnabled: true
|
||||
text: "Raw mouse input"
|
||||
font.pointSize: 12
|
||||
checked: !prefs.mouseAcceleration
|
||||
checked: !StreamingPreferences.mouseAcceleration
|
||||
onCheckedChanged: {
|
||||
prefs.mouseAcceleration = !checked
|
||||
StreamingPreferences.mouseAcceleration = !checked
|
||||
}
|
||||
|
||||
ToolTip.delay: 1000
|
||||
@@ -540,9 +559,9 @@ Flickable {
|
||||
id: optimizeGameSettingsCheck
|
||||
text: "Optimize game settings"
|
||||
font.pointSize: 12
|
||||
checked: prefs.gameOptimizations
|
||||
checked: StreamingPreferences.gameOptimizations
|
||||
onCheckedChanged: {
|
||||
prefs.gameOptimizations = checked
|
||||
StreamingPreferences.gameOptimizations = checked
|
||||
}
|
||||
}
|
||||
|
||||
@@ -550,9 +569,9 @@ Flickable {
|
||||
id: audioPcCheck
|
||||
text: "Play audio on host PC"
|
||||
font.pointSize: 12
|
||||
checked: prefs.playAudioOnHost
|
||||
checked: StreamingPreferences.playAudioOnHost
|
||||
onCheckedChanged: {
|
||||
prefs.playAudioOnHost = checked
|
||||
StreamingPreferences.playAudioOnHost = checked
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -580,7 +599,7 @@ Flickable {
|
||||
AutoResizingComboBox {
|
||||
// ignore setting the index at first, and actually set it when the component is loaded
|
||||
Component.onCompleted: {
|
||||
var saved_vds = prefs.videoDecoderSelection
|
||||
var saved_vds = StreamingPreferences.videoDecoderSelection
|
||||
currentIndex = 0
|
||||
for (var i = 0; i < decoderListModel.count; i++) {
|
||||
var el_vds = decoderListModel.get(i).val;
|
||||
@@ -611,7 +630,7 @@ Flickable {
|
||||
}
|
||||
// ::onActivated must be used, as it only listens for when the index is changed by a human
|
||||
onActivated : {
|
||||
prefs.videoDecoderSelection = decoderListModel.get(currentIndex).val
|
||||
StreamingPreferences.videoDecoderSelection = decoderListModel.get(currentIndex).val
|
||||
}
|
||||
}
|
||||
|
||||
@@ -626,7 +645,7 @@ Flickable {
|
||||
AutoResizingComboBox {
|
||||
// ignore setting the index at first, and actually set it when the component is loaded
|
||||
Component.onCompleted: {
|
||||
var saved_vcc = prefs.videoCodecConfig
|
||||
var saved_vcc = StreamingPreferences.videoCodecConfig
|
||||
currentIndex = 0
|
||||
for(var i = 0; i < codecListModel.count; i++) {
|
||||
var el_vcc = codecListModel.get(i).val;
|
||||
@@ -664,7 +683,7 @@ Flickable {
|
||||
}
|
||||
// ::onActivated must be used, as it only listens for when the index is changed by a human
|
||||
onActivated : {
|
||||
prefs.videoCodecConfig = codecListModel.get(currentIndex).val
|
||||
StreamingPreferences.videoCodecConfig = codecListModel.get(currentIndex).val
|
||||
}
|
||||
}
|
||||
|
||||
@@ -672,13 +691,17 @@ Flickable {
|
||||
id: unlockUnsupportedFps
|
||||
text: "Unlock unsupported FPS options"
|
||||
font.pointSize: 12
|
||||
checked: prefs.unsupportedFps
|
||||
checked: StreamingPreferences.unsupportedFps
|
||||
onCheckedChanged: {
|
||||
prefs.unsupportedFps = checked
|
||||
// This is called on init, so only do the work if we've
|
||||
// actually changed the value.
|
||||
if (StreamingPreferences.unsupportedFps != checked) {
|
||||
StreamingPreferences.unsupportedFps = checked
|
||||
|
||||
// The selectable FPS values depend on whether
|
||||
// this option is enabled or not
|
||||
fpsComboBox.reinitialize()
|
||||
// The selectable FPS values depend on whether
|
||||
// this option is enabled or not
|
||||
fpsComboBox.reinitialize()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -686,18 +709,22 @@ Flickable {
|
||||
id: enableMdns
|
||||
text: "Automatically find PCs on the local network (Recommended)"
|
||||
font.pointSize: 12
|
||||
checked: prefs.enableMdns
|
||||
checked: StreamingPreferences.enableMdns
|
||||
onCheckedChanged: {
|
||||
prefs.enableMdns = checked
|
||||
// This is called on init, so only do the work if we've
|
||||
// actually changed the value.
|
||||
if (StreamingPreferences.enableMdns != checked) {
|
||||
StreamingPreferences.enableMdns = checked
|
||||
|
||||
// We must save the updated preference to ensure
|
||||
// ComputerManager can observe the change internally.
|
||||
prefs.save()
|
||||
// We must save the updated preference to ensure
|
||||
// ComputerManager can observe the change internally.
|
||||
StreamingPreferences.save()
|
||||
|
||||
// Restart polling so the mDNS change takes effect
|
||||
if (window.pollingActive) {
|
||||
ComputerManager.stopPollingAsync()
|
||||
ComputerManager.startPolling()
|
||||
// Restart polling so the mDNS change takes effect
|
||||
if (window.pollingActive) {
|
||||
ComputerManager.stopPollingAsync()
|
||||
ComputerManager.startPolling()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -706,9 +733,9 @@ Flickable {
|
||||
id: quitAppAfter
|
||||
text: "Quit app after quitting session"
|
||||
font.pointSize: 12
|
||||
checked: prefs.quitAppAfter
|
||||
checked: StreamingPreferences.quitAppAfter
|
||||
onCheckedChanged: {
|
||||
prefs.quitAppAfter = checked
|
||||
StreamingPreferences.quitAppAfter = checked
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import QtQuick 2.0
|
||||
import QtQuick.Controls 2.2
|
||||
import QtQuick.Dialogs 1.2
|
||||
import QtQuick.Window 2.2
|
||||
|
||||
import ComputerManager 1.0
|
||||
import SdlGamepadKeyNavigation 1.0
|
||||
import Session 1.0
|
||||
|
||||
@@ -13,13 +11,6 @@ Item {
|
||||
property string stageText : "Starting " + appName + "..."
|
||||
property bool quitAfter : false
|
||||
|
||||
anchors.fill: parent
|
||||
|
||||
// The StackView will trigger a visibility change when
|
||||
// we're pushed onto it, causing our onVisibleChanged
|
||||
// routine to run, but only if we start as invisible
|
||||
visible: false
|
||||
|
||||
function stageStarting(stage)
|
||||
{
|
||||
// Update the spinner text
|
||||
@@ -28,8 +19,8 @@ Item {
|
||||
|
||||
function stageFailed(stage, errorCode)
|
||||
{
|
||||
errorDialog.text = "Starting " + stage + " failed: Error " + errorCode
|
||||
errorDialog.open()
|
||||
// Display the error dialog after Session::exec() returns
|
||||
streamSegueErrorDialog.text = "Starting " + stage + " failed: Error " + errorCode
|
||||
}
|
||||
|
||||
function connectionStarted()
|
||||
@@ -38,6 +29,7 @@ Item {
|
||||
// see them briefly when we pop off the StackView
|
||||
stageSpinner.visible = false
|
||||
stageLabel.visible = false
|
||||
hintText.visible = false
|
||||
|
||||
// Hide the window now that streaming has begun
|
||||
window.visible = false
|
||||
@@ -46,7 +38,7 @@ Item {
|
||||
function displayLaunchError(text)
|
||||
{
|
||||
// Display the error dialog after Session::exec() returns
|
||||
errorDialog.text = text
|
||||
streamSegueErrorDialog.text = text
|
||||
}
|
||||
|
||||
function displayLaunchWarning(text)
|
||||
@@ -54,7 +46,7 @@ Item {
|
||||
// This toast appears for 3 seconds, just shorter than how long
|
||||
// Session will wait for it to be displayed. This gives it time
|
||||
// to transition to invisible before continuing.
|
||||
var toast = Qt.createQmlObject('import QtQuick.Controls 2.3; ToolTip {}', parent, '')
|
||||
var toast = Qt.createQmlObject('import QtQuick.Controls 2.2; ToolTip {}', parent, '')
|
||||
toast.text = text
|
||||
toast.timeout = 3000
|
||||
toast.visible = true
|
||||
@@ -72,10 +64,14 @@ Item {
|
||||
|
||||
function sessionFinished()
|
||||
{
|
||||
// Enable GUI gamepad usage now
|
||||
SdlGamepadKeyNavigation.enable()
|
||||
|
||||
if (quitAfter) {
|
||||
if (errorDialog.text) {
|
||||
if (streamSegueErrorDialog.text) {
|
||||
// Quit when the error dialog is acknowledged
|
||||
errorDialog.open()
|
||||
streamSegueErrorDialog.quitAfter = quitAfter
|
||||
streamSegueErrorDialog.open()
|
||||
}
|
||||
else {
|
||||
// Quit immediately
|
||||
@@ -92,48 +88,60 @@ Item {
|
||||
// the Qt UI is visible again to prevent losing
|
||||
// focus on the dialog which would impact gamepad
|
||||
// users.
|
||||
if (errorDialog.text) {
|
||||
errorDialog.open()
|
||||
if (streamSegueErrorDialog.text) {
|
||||
streamSegueErrorDialog.quitAfter = quitAfter
|
||||
streamSegueErrorDialog.open()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// It's important that we don't call enable() here
|
||||
// or it may interfere with the Session instance
|
||||
// getting notified of initial connected gamepads.
|
||||
SdlGamepadKeyNavigation {
|
||||
id: gamepadKeyNav
|
||||
StackView.onDeactivating: {
|
||||
// Show the toolbar again when popped off the stack
|
||||
toolBar.visible = true
|
||||
|
||||
// Enable GUI gamepad usage now
|
||||
SdlGamepadKeyNavigation.enable()
|
||||
}
|
||||
|
||||
onVisibleChanged: {
|
||||
if (visible) {
|
||||
// Hide the toolbar before we start loading
|
||||
toolBar.visible = false
|
||||
StackView.onActivated: {
|
||||
// Hide the toolbar before we start loading
|
||||
toolBar.visible = false
|
||||
|
||||
// Hook up our signals
|
||||
session.stageStarting.connect(stageStarting)
|
||||
session.stageFailed.connect(stageFailed)
|
||||
session.connectionStarted.connect(connectionStarted)
|
||||
session.displayLaunchError.connect(displayLaunchError)
|
||||
session.displayLaunchWarning.connect(displayLaunchWarning)
|
||||
session.quitStarting.connect(quitStarting)
|
||||
session.sessionFinished.connect(sessionFinished)
|
||||
|
||||
// Kick off the stream
|
||||
streamLoader.active = true
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: streamLoader
|
||||
active: false
|
||||
asynchronous: true
|
||||
|
||||
onLoaded: {
|
||||
// Set the hint text. We do this here rather than
|
||||
// in the hintText control itself to synchronize
|
||||
// with Session.exec() which requires no concurrent
|
||||
// gamepad usage.
|
||||
hintText.text = gamepadKeyNav.getConnectedGamepads() > 0 ?
|
||||
hintText.text = SdlGamepadKeyNavigation.getConnectedGamepads() > 0 ?
|
||||
"Tip: Press Start+Select+L1+R1 to disconnect your session" :
|
||||
"Tip: Press Ctrl+Alt+Shift+Q to disconnect your session"
|
||||
|
||||
// Hook up our signals
|
||||
session.stageStarting.connect(stageStarting)
|
||||
session.stageFailed.connect(stageFailed)
|
||||
session.connectionStarted.connect(connectionStarted)
|
||||
session.displayLaunchError.connect(displayLaunchError)
|
||||
session.displayLaunchWarning.connect(displayLaunchWarning)
|
||||
session.quitStarting.connect(quitStarting)
|
||||
session.sessionFinished.connect(sessionFinished)
|
||||
// Stop GUI gamepad usage now
|
||||
SdlGamepadKeyNavigation.disable()
|
||||
|
||||
// Run the streaming session to completion
|
||||
session.exec(Screen.virtualX, Screen.virtualY)
|
||||
}
|
||||
else if (!quitAfter) {
|
||||
// Show the toolbar again when we become hidden
|
||||
toolBar.visible = true
|
||||
}
|
||||
|
||||
sourceComponent: Item {}
|
||||
}
|
||||
|
||||
Row {
|
||||
@@ -165,25 +173,4 @@ Item {
|
||||
|
||||
wrapMode: Text.Wrap
|
||||
}
|
||||
|
||||
MessageDialog {
|
||||
id: errorDialog
|
||||
modality:Qt.WindowModal
|
||||
icon: StandardIcon.Critical
|
||||
standardButtons: StandardButton.Ok | StandardButton.Help
|
||||
|
||||
onAccepted: {
|
||||
if (quitAfter) {
|
||||
Qt.quit()
|
||||
}
|
||||
}
|
||||
|
||||
onHelp: {
|
||||
Qt.openUrlExternally("https://github.com/moonlight-stream/moonlight-docs/wiki/Troubleshooting");
|
||||
|
||||
if (quitAfter) {
|
||||
Qt.quit()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,18 +22,6 @@ QVariant ComputerModel::data(const QModelIndex& index, int role) const
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
if (index.row() == m_Computers.count()) {
|
||||
// We insert a synthetic item at the end for the Add PC option
|
||||
switch (role) {
|
||||
case NameRole:
|
||||
return "Add PC";
|
||||
case AddPcRole:
|
||||
return true;
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
|
||||
Q_ASSERT(index.row() < m_Computers.count());
|
||||
|
||||
NvComputer* computer = m_Computers[index.row()];
|
||||
@@ -50,8 +38,6 @@ QVariant ComputerModel::data(const QModelIndex& index, int role) const
|
||||
return computer->currentGameId != 0;
|
||||
case WakeableRole:
|
||||
return !computer->macAddress.isEmpty();
|
||||
case AddPcRole:
|
||||
return false;
|
||||
case StatusUnknownRole:
|
||||
return computer->state == NvComputer::CS_UNKNOWN;
|
||||
default:
|
||||
@@ -67,8 +53,7 @@ int ComputerModel::rowCount(const QModelIndex& parent) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Add PC placeholder counts as 1
|
||||
return m_Computers.count() + 1;
|
||||
return m_Computers.count();
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> ComputerModel::roleNames() const
|
||||
@@ -79,7 +64,6 @@ QHash<int, QByteArray> ComputerModel::roleNames() const
|
||||
names[OnlineRole] = "online";
|
||||
names[PairedRole] = "paired";
|
||||
names[BusyRole] = "busy";
|
||||
names[AddPcRole] = "addPc";
|
||||
names[WakeableRole] = "wakeable";
|
||||
names[StatusUnknownRole] = "statusUnknown";
|
||||
|
||||
|
||||
@@ -14,8 +14,7 @@ class ComputerModel : public QAbstractListModel
|
||||
PairedRole,
|
||||
BusyRole,
|
||||
WakeableRole,
|
||||
StatusUnknownRole,
|
||||
AddPcRole
|
||||
StatusUnknownRole
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import QtQuick 2.9
|
||||
import QtQuick.Controls 2.2
|
||||
import QtQuick.Dialogs 1.2
|
||||
import QtQuick.Layouts 1.3
|
||||
import QtQuick.Window 2.2
|
||||
|
||||
import QtQuick.Controls.Material 2.1
|
||||
|
||||
import ComputerManager 1.0
|
||||
import AutoUpdateChecker 1.0
|
||||
import StreamingPreferences 1.0
|
||||
import SystemProperties 1.0
|
||||
import SdlGamepadKeyNavigation 1.0
|
||||
|
||||
ApplicationWindow {
|
||||
property bool pollingActive: false
|
||||
@@ -18,14 +17,7 @@ ApplicationWindow {
|
||||
width: 1280
|
||||
height: 600
|
||||
|
||||
visibility: prefs.startWindowed ? "Windowed" : "Maximized"
|
||||
|
||||
Material.theme: Material.Dark
|
||||
Material.accent: Material.Purple
|
||||
|
||||
StreamingPreferences {
|
||||
id: prefs
|
||||
}
|
||||
visibility: StreamingPreferences.startWindowed ? "Windowed" : "Maximized"
|
||||
|
||||
StackView {
|
||||
id: stackView
|
||||
@@ -142,19 +134,20 @@ ApplicationWindow {
|
||||
// onAfterRendering call and potentially reenter this code.
|
||||
initialized = true;
|
||||
|
||||
if (prefs.isRunningWayland()) {
|
||||
waylandDialog.open()
|
||||
}
|
||||
else if (prefs.isWow64()) {
|
||||
if (SystemProperties.isWow64) {
|
||||
wow64Dialog.open()
|
||||
}
|
||||
else if (!prefs.hasAnyHardwareAcceleration()) {
|
||||
noHwDecoderDialog.open()
|
||||
else if (!SystemProperties.hasHardwareAcceleration) {
|
||||
if (SystemProperties.isRunningXWayland) {
|
||||
xWaylandDialog.open()
|
||||
}
|
||||
else {
|
||||
noHwDecoderDialog.open()
|
||||
}
|
||||
}
|
||||
|
||||
var unmappedGamepads = prefs.getUnmappedGamepads()
|
||||
if (unmappedGamepads) {
|
||||
unmappedGamepadDialog.unmappedGamepads = unmappedGamepads
|
||||
if (SystemProperties.unmappedGamepads) {
|
||||
unmappedGamepadDialog.unmappedGamepads = SystemProperties.unmappedGamepads
|
||||
unmappedGamepadDialog.open()
|
||||
}
|
||||
}
|
||||
@@ -178,28 +171,21 @@ ApplicationWindow {
|
||||
|
||||
header: ToolBar {
|
||||
id: toolBar
|
||||
height: 60
|
||||
anchors.topMargin: 5
|
||||
anchors.bottomMargin: 5
|
||||
|
||||
RowLayout {
|
||||
spacing: 20
|
||||
anchors.leftMargin: 10
|
||||
anchors.rightMargin: 10
|
||||
anchors.fill: parent
|
||||
|
||||
NavigableToolButton {
|
||||
// Only make the button visible if the user has navigated somewhere.
|
||||
visible: stackView.depth > 1
|
||||
|
||||
// FIXME: We're using an Image here rather than icon.source because
|
||||
// icons don't work on Qt 5.9 LTS.
|
||||
Image {
|
||||
source: "qrc:/res/arrow_left.svg"
|
||||
anchors.centerIn: parent
|
||||
sourceSize {
|
||||
// The icon should be square so use the height as the width too
|
||||
width: toolBar.height - toolBar.anchors.bottomMargin - toolBar.anchors.topMargin
|
||||
height: toolBar.height - toolBar.anchors.bottomMargin - toolBar.anchors.topMargin
|
||||
}
|
||||
}
|
||||
iconSource: "qrc:/res/arrow_left.svg"
|
||||
|
||||
onClicked: stackView.pop()
|
||||
|
||||
@@ -219,23 +205,41 @@ ApplicationWindow {
|
||||
}
|
||||
|
||||
NavigableToolButton {
|
||||
property string browserUrl: ""
|
||||
id: addPcButton
|
||||
visible: stackView.currentItem.objectName === "Computers"
|
||||
|
||||
iconSource: "qrc:/res/ic_add_to_queue_white_48px.svg"
|
||||
|
||||
ToolTip.delay: 1000
|
||||
ToolTip.timeout: 3000
|
||||
ToolTip.visible: hovered
|
||||
ToolTip.text: "Add PC manually" + (newPcShortcut.nativeText ? (" ("+newPcShortcut.nativeText+")") : "")
|
||||
|
||||
Shortcut {
|
||||
id: newPcShortcut
|
||||
sequence: StandardKey.New
|
||||
onActivated: addPcButton.clicked()
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
addPcDialog.open()
|
||||
}
|
||||
|
||||
Keys.onDownPressed: {
|
||||
stackView.currentItem.forceActiveFocus(Qt.TabFocus)
|
||||
}
|
||||
}
|
||||
|
||||
NavigableToolButton {
|
||||
property string browserUrl: ""
|
||||
|
||||
id: updateButton
|
||||
|
||||
Image {
|
||||
source: "qrc:/res/update.svg"
|
||||
anchors.centerIn: parent
|
||||
sourceSize {
|
||||
width: toolBar.height - toolBar.anchors.bottomMargin - toolBar.anchors.topMargin
|
||||
height: toolBar.height - toolBar.anchors.bottomMargin - toolBar.anchors.topMargin
|
||||
}
|
||||
}
|
||||
iconSource: "qrc:/res/update.svg"
|
||||
|
||||
ToolTip.delay: 1000
|
||||
ToolTip.timeout: 3000
|
||||
ToolTip.visible: hovered
|
||||
ToolTip.text: "Update available for Moonlight"
|
||||
|
||||
// Invisible until we get a callback notifying us that
|
||||
// an update is available
|
||||
@@ -243,8 +247,9 @@ ApplicationWindow {
|
||||
|
||||
onClicked: Qt.openUrlExternally(browserUrl);
|
||||
|
||||
function updateAvailable(url)
|
||||
function updateAvailable(version, url)
|
||||
{
|
||||
ToolTip.text = "Update available for Moonlight: Version " + version
|
||||
updateButton.browserUrl = url
|
||||
updateButton.visible = true
|
||||
}
|
||||
@@ -261,15 +266,9 @@ ApplicationWindow {
|
||||
|
||||
NavigableToolButton {
|
||||
id: helpButton
|
||||
visible: SystemProperties.hasBrowser
|
||||
|
||||
Image {
|
||||
source: "qrc:/res/question_mark.svg"
|
||||
anchors.centerIn: parent
|
||||
sourceSize {
|
||||
width: toolBar.height - toolBar.anchors.bottomMargin - toolBar.anchors.topMargin
|
||||
height: toolBar.height - toolBar.anchors.bottomMargin - toolBar.anchors.topMargin
|
||||
}
|
||||
}
|
||||
iconSource: "qrc:/res/question_mark.svg"
|
||||
|
||||
ToolTip.delay: 1000
|
||||
ToolTip.timeout: 3000
|
||||
@@ -299,14 +298,7 @@ ApplicationWindow {
|
||||
ToolTip.visible: hovered
|
||||
ToolTip.text: "Gamepad Mapper"
|
||||
|
||||
Image {
|
||||
source: "qrc:/res/ic_videogame_asset_white_48px.svg"
|
||||
anchors.centerIn: parent
|
||||
sourceSize {
|
||||
width: toolBar.height - toolBar.anchors.bottomMargin - toolBar.anchors.topMargin
|
||||
height: toolBar.height - toolBar.anchors.bottomMargin - toolBar.anchors.topMargin
|
||||
}
|
||||
}
|
||||
iconSource: "qrc:/res/ic_videogame_asset_white_48px.svg"
|
||||
|
||||
onClicked: navigateTo("qrc:/gui/GamepadMapper.qml", "Gamepad Mapping")
|
||||
|
||||
@@ -318,14 +310,7 @@ ApplicationWindow {
|
||||
NavigableToolButton {
|
||||
id: settingsButton
|
||||
|
||||
Image {
|
||||
source: "qrc:/res/settings.svg"
|
||||
anchors.centerIn: parent
|
||||
sourceSize {
|
||||
width: toolBar.height - toolBar.anchors.bottomMargin - toolBar.anchors.topMargin
|
||||
height: toolBar.height - toolBar.anchors.bottomMargin - toolBar.anchors.topMargin
|
||||
}
|
||||
}
|
||||
iconSource: "qrc:/res/settings.svg"
|
||||
|
||||
onClicked: navigateTo("qrc:/gui/SettingsView.qml", "Settings")
|
||||
|
||||
@@ -347,67 +332,104 @@ ApplicationWindow {
|
||||
}
|
||||
}
|
||||
|
||||
MessageDialog {
|
||||
ErrorMessageDialog {
|
||||
id: noHwDecoderDialog
|
||||
modality:Qt.WindowModal
|
||||
icon: StandardIcon.Warning
|
||||
standardButtons: StandardButton.Ok | StandardButton.Help
|
||||
text: "No functioning hardware accelerated H.264 video decoder was detected by Moonlight. " +
|
||||
"Your streaming performance may be severely degraded in this configuration. " +
|
||||
"Click the Help button for more information on solving this problem."
|
||||
onHelp: {
|
||||
Qt.openUrlExternally("https://github.com/moonlight-stream/moonlight-docs/wiki/Fixing-Hardware-Decoding-Problems");
|
||||
}
|
||||
"Your streaming performance may be severely degraded in this configuration."
|
||||
helpText: "Click the Help button for more information on solving this problem."
|
||||
helpUrl: "https://github.com/moonlight-stream/moonlight-docs/wiki/Fixing-Hardware-Decoding-Problems"
|
||||
}
|
||||
|
||||
MessageDialog {
|
||||
id: waylandDialog
|
||||
modality:Qt.WindowModal
|
||||
icon: StandardIcon.Warning
|
||||
standardButtons: StandardButton.Ok | StandardButton.Help
|
||||
text: "Moonlight does not support hardware acceleration on Wayland. Continuing on Wayland may result in poor streaming performance. " +
|
||||
"Please switch to an X session for optimal performance."
|
||||
onHelp: {
|
||||
Qt.openUrlExternally("https://github.com/moonlight-stream/moonlight-docs/wiki/Fixing-Hardware-Decoding-Problems");
|
||||
}
|
||||
ErrorMessageDialog {
|
||||
id: xWaylandDialog
|
||||
text: "Hardware acceleration doesn't work on XWayland. Continuing on XWayland may result in poor streaming performance. " +
|
||||
"Try running with QT_QPA_PLATFORM=wayland or switch to X11."
|
||||
helpText: "Click the Help button for more information."
|
||||
helpUrl: "https://github.com/moonlight-stream/moonlight-docs/wiki/Fixing-Hardware-Decoding-Problems"
|
||||
}
|
||||
|
||||
MessageDialog {
|
||||
NavigableMessageDialog {
|
||||
id: wow64Dialog
|
||||
modality:Qt.WindowModal
|
||||
icon: StandardIcon.Warning
|
||||
standardButtons: StandardButton.Ok | StandardButton.Cancel
|
||||
standardButtons: Dialog.Ok | Dialog.Cancel
|
||||
text: "This PC is running a 64-bit version of Windows. Please download the x64 version of Moonlight for the best streaming performance."
|
||||
onAccepted: {
|
||||
Qt.openUrlExternally("https://github.com/moonlight-stream/moonlight-qt/releases");
|
||||
}
|
||||
}
|
||||
|
||||
MessageDialog {
|
||||
ErrorMessageDialog {
|
||||
id: unmappedGamepadDialog
|
||||
property string unmappedGamepads : ""
|
||||
modality:Qt.WindowModal
|
||||
icon: StandardIcon.Warning
|
||||
standardButtons: StandardButton.Ok | StandardButton.Help
|
||||
text: "Moonlight detected gamepads without a proper mapping. " +
|
||||
"The following gamepads will not function until this is resolved: " + unmappedGamepads + "\n\n" +
|
||||
"Click the Help button for information on how to map your gamepads."
|
||||
onHelp: {
|
||||
Qt.openUrlExternally("https://github.com/moonlight-stream/moonlight-docs/wiki/Gamepad-Mapping");
|
||||
}
|
||||
text: "Moonlight detected gamepads without a mapping:\n" + unmappedGamepads
|
||||
helpTextSeparator: "\n\n"
|
||||
helpText: "Click the Help button for information on how to map your gamepads."
|
||||
helpUrl: "https://github.com/moonlight-stream/moonlight-docs/wiki/Gamepad-Mapping"
|
||||
}
|
||||
|
||||
// This dialog appears when quitting via keyboard or gamepad button
|
||||
MessageDialog {
|
||||
NavigableMessageDialog {
|
||||
id: quitConfirmationDialog
|
||||
modality:Qt.WindowModal
|
||||
icon: StandardIcon.Warning
|
||||
standardButtons: StandardButton.Yes | StandardButton.No
|
||||
standardButtons: Dialog.Yes | Dialog.No
|
||||
text: "Are you sure you want to quit?"
|
||||
|
||||
onYes: Qt.quit()
|
||||
|
||||
// For keyboard/gamepad navigation
|
||||
onAccepted: Qt.quit()
|
||||
}
|
||||
|
||||
// HACK: This belongs in StreamSegue but keeping a dialog around after the parent
|
||||
// dies can trigger bugs in Qt 5.12 that cause the app to crash. For now, we will
|
||||
// host this dialog in a QML component that is never destroyed.
|
||||
//
|
||||
// To repro: Start a stream, cut the network connection to trigger the "Connection
|
||||
// terminated" dialog, wait until the app grid times out back to the PC grid, then
|
||||
// try to dismiss the dialog.
|
||||
ErrorMessageDialog {
|
||||
id: streamSegueErrorDialog
|
||||
|
||||
property bool quitAfter: false
|
||||
|
||||
onClosed: {
|
||||
if (quitAfter) {
|
||||
Qt.quit()
|
||||
}
|
||||
|
||||
// StreamSegue assumes its dialog will be re-created each time we
|
||||
// start streaming, so fake it by wiping out the text each time.
|
||||
text = ""
|
||||
}
|
||||
}
|
||||
|
||||
NavigableDialog {
|
||||
id: addPcDialog
|
||||
property string label: "Enter the IP address of your GameStream PC:"
|
||||
|
||||
standardButtons: Dialog.Ok | Dialog.Cancel
|
||||
|
||||
onOpened: {
|
||||
// Force keyboard focus on the textbox so keyboard navigation works
|
||||
editText.forceActiveFocus()
|
||||
}
|
||||
|
||||
onAccepted: {
|
||||
if (editText.text) {
|
||||
ComputerManager.addNewHost(editText.text, false)
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
Label {
|
||||
text: addPcDialog.label
|
||||
font.bold: true
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: editText
|
||||
Layout.fillWidth: true
|
||||
focus: true
|
||||
|
||||
Keys.onReturnPressed: {
|
||||
addPcDialog.accept()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
SdlGamepadKeyNavigation::SdlGamepadKeyNavigation()
|
||||
: m_Enabled(false),
|
||||
m_SettingsMode(false),
|
||||
m_UiNavMode(false),
|
||||
m_LastAxisNavigationEventTime(0)
|
||||
{
|
||||
m_PollingTimer = new QTimer(this);
|
||||
@@ -91,6 +91,12 @@ void SdlGamepadKeyNavigation::onPollingTimerFired()
|
||||
|
||||
while (SDL_PollEvent(&event)) {
|
||||
switch (event.type) {
|
||||
case SDL_QUIT:
|
||||
// SDL may send us a quit event since we initialize
|
||||
// the video subsystem on startup. If we get one,
|
||||
// forward it on for Qt to take care of.
|
||||
QCoreApplication::instance()->quit();
|
||||
break;
|
||||
case SDL_CONTROLLERBUTTONDOWN:
|
||||
case SDL_CONTROLLERBUTTONUP:
|
||||
{
|
||||
@@ -100,7 +106,7 @@ void SdlGamepadKeyNavigation::onPollingTimerFired()
|
||||
|
||||
switch (event.cbutton.button) {
|
||||
case SDL_CONTROLLER_BUTTON_DPAD_UP:
|
||||
if (m_SettingsMode) {
|
||||
if (m_UiNavMode) {
|
||||
// Back-tab
|
||||
sendKey(type, Qt::Key_Tab, Qt::ShiftModifier);
|
||||
}
|
||||
@@ -109,7 +115,7 @@ void SdlGamepadKeyNavigation::onPollingTimerFired()
|
||||
}
|
||||
break;
|
||||
case SDL_CONTROLLER_BUTTON_DPAD_DOWN:
|
||||
if (m_SettingsMode) {
|
||||
if (m_UiNavMode) {
|
||||
sendKey(type, Qt::Key_Tab);
|
||||
}
|
||||
else {
|
||||
@@ -118,24 +124,12 @@ void SdlGamepadKeyNavigation::onPollingTimerFired()
|
||||
break;
|
||||
case SDL_CONTROLLER_BUTTON_DPAD_LEFT:
|
||||
sendKey(type, Qt::Key_Left);
|
||||
if (m_SettingsMode) {
|
||||
// Some settings controls respond to left/right (like the slider)
|
||||
// and others respond to up/down (like combo boxes). They seem to
|
||||
// be mutually exclusive though so let's just send both.
|
||||
sendKey(type, Qt::Key_Up);
|
||||
}
|
||||
break;
|
||||
case SDL_CONTROLLER_BUTTON_DPAD_RIGHT:
|
||||
sendKey(type, Qt::Key_Right);
|
||||
if (m_SettingsMode) {
|
||||
// Some settings controls respond to left/right (like the slider)
|
||||
// and others respond to up/down (like combo boxes). They seem to
|
||||
// be mutually exclusive though so let's just send both.
|
||||
sendKey(type, Qt::Key_Down);
|
||||
}
|
||||
break;
|
||||
case SDL_CONTROLLER_BUTTON_A:
|
||||
if (m_SettingsMode) {
|
||||
if (m_UiNavMode) {
|
||||
sendKey(type, Qt::Key_Space);
|
||||
}
|
||||
else {
|
||||
@@ -177,7 +171,7 @@ void SdlGamepadKeyNavigation::onPollingTimerFired()
|
||||
// Do nothing
|
||||
}
|
||||
else if (leftY < -30000) {
|
||||
if (m_SettingsMode) {
|
||||
if (m_UiNavMode) {
|
||||
// Back-tab
|
||||
sendKey(QEvent::Type::KeyPress, Qt::Key_Tab, Qt::ShiftModifier);
|
||||
sendKey(QEvent::Type::KeyRelease, Qt::Key_Tab, Qt::ShiftModifier);
|
||||
@@ -190,7 +184,7 @@ void SdlGamepadKeyNavigation::onPollingTimerFired()
|
||||
m_LastAxisNavigationEventTime = SDL_GetTicks();
|
||||
}
|
||||
else if (leftY > 30000) {
|
||||
if (m_SettingsMode) {
|
||||
if (m_UiNavMode) {
|
||||
sendKey(QEvent::Type::KeyPress, Qt::Key_Tab);
|
||||
sendKey(QEvent::Type::KeyRelease, Qt::Key_Tab);
|
||||
}
|
||||
@@ -204,27 +198,11 @@ void SdlGamepadKeyNavigation::onPollingTimerFired()
|
||||
else if (leftX < -30000) {
|
||||
sendKey(QEvent::Type::KeyPress, Qt::Key_Left);
|
||||
sendKey(QEvent::Type::KeyRelease, Qt::Key_Left);
|
||||
if (m_SettingsMode) {
|
||||
// Some settings controls respond to left/right (like the slider)
|
||||
// and others respond to up/down (like combo boxes). They seem to
|
||||
// be mutually exclusive though so let's just send both.
|
||||
sendKey(QEvent::Type::KeyPress, Qt::Key_Up);
|
||||
sendKey(QEvent::Type::KeyRelease, Qt::Key_Up);
|
||||
}
|
||||
|
||||
m_LastAxisNavigationEventTime = SDL_GetTicks();
|
||||
}
|
||||
else if (leftX > 30000) {
|
||||
sendKey(QEvent::Type::KeyPress, Qt::Key_Right);
|
||||
sendKey(QEvent::Type::KeyRelease, Qt::Key_Right);
|
||||
if (m_SettingsMode) {
|
||||
// Some settings controls respond to left/right (like the slider)
|
||||
// and others respond to up/down (like combo boxes). They seem to
|
||||
// be mutually exclusive though so let's just send both.
|
||||
sendKey(QEvent::Type::KeyPress, Qt::Key_Down);
|
||||
sendKey(QEvent::Type::KeyRelease, Qt::Key_Down);
|
||||
}
|
||||
|
||||
m_LastAxisNavigationEventTime = SDL_GetTicks();
|
||||
}
|
||||
}
|
||||
@@ -240,19 +218,14 @@ void SdlGamepadKeyNavigation::sendKey(QEvent::Type type, Qt::Key key, Qt::Keyboa
|
||||
}
|
||||
}
|
||||
|
||||
void SdlGamepadKeyNavigation::setSettingsMode(bool settingsMode)
|
||||
void SdlGamepadKeyNavigation::setUiNavMode(bool uiNavMode)
|
||||
{
|
||||
m_SettingsMode = settingsMode;
|
||||
m_UiNavMode = uiNavMode;
|
||||
}
|
||||
|
||||
int SdlGamepadKeyNavigation::getConnectedGamepads()
|
||||
{
|
||||
if (SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) != 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) failed: %s",
|
||||
SDL_GetError());
|
||||
return 0;
|
||||
}
|
||||
Q_ASSERT(m_Enabled);
|
||||
|
||||
int count = 0;
|
||||
for (int i = 0; i < SDL_NumJoysticks(); i++) {
|
||||
@@ -261,6 +234,5 @@ int SdlGamepadKeyNavigation::getConnectedGamepads()
|
||||
}
|
||||
}
|
||||
|
||||
SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER);
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
|
||||
Q_INVOKABLE void disable();
|
||||
|
||||
Q_INVOKABLE void setSettingsMode(bool settingsMode);
|
||||
Q_INVOKABLE void setUiNavMode(bool settingsMode);
|
||||
|
||||
Q_INVOKABLE int getConnectedGamepads();
|
||||
|
||||
@@ -32,6 +32,6 @@ private:
|
||||
QTimer* m_PollingTimer;
|
||||
QList<SDL_GameController*> m_Gamepads;
|
||||
bool m_Enabled;
|
||||
bool m_SettingsMode;
|
||||
bool m_UiNavMode;
|
||||
Uint32 m_LastAxisNavigationEventTime;
|
||||
};
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
#include <QMutex>
|
||||
#include <QtDebug>
|
||||
#include <QNetworkProxyFactory>
|
||||
#include <QPalette>
|
||||
#include <QFont>
|
||||
#include <QCursor>
|
||||
|
||||
// Don't let SDL hook our main function, since Qt is already
|
||||
// doing the same thing. This needs to be before any headers
|
||||
@@ -28,6 +31,7 @@
|
||||
#include "gui/computermodel.h"
|
||||
#include "gui/appmodel.h"
|
||||
#include "backend/autoupdatechecker.h"
|
||||
#include "backend/systemproperties.h"
|
||||
#include "streaming/session.h"
|
||||
#include "settings/streamingpreferences.h"
|
||||
#include "gui/sdlgamepadkeynavigation.h"
|
||||
@@ -223,6 +227,8 @@ LONG WINAPI UnhandledExceptionHandler(struct _EXCEPTION_POINTERS *ExceptionInfo)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
SDL_SetMainReady();
|
||||
|
||||
// Set the app version for the QCommandLineParser's showVersion() command
|
||||
QCoreApplication::setApplicationVersion(VERSION_STR);
|
||||
|
||||
@@ -282,7 +288,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// This avoids using the default keychain for SSL, which may cause
|
||||
// password prompts on macOS.
|
||||
qputenv("QT_SSL_USE_TEMPORARY_KEYCHAIN", QByteArray("1"));
|
||||
qputenv("QT_SSL_USE_TEMPORARY_KEYCHAIN", "1");
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
if (!qEnvironmentVariableIsSet("QT_OPENGL")) {
|
||||
@@ -303,15 +309,82 @@ int main(int argc, char *argv[])
|
||||
// Register custom metatypes for use in signals
|
||||
qRegisterMetaType<NvApp>("NvApp");
|
||||
|
||||
// Allow the display to sleep by default. We will manually use SDL_DisableScreenSaver()
|
||||
// and SDL_EnableScreenSaver() when appropriate. This hint must be set before
|
||||
// initializing the SDL video subsystem to have any effect.
|
||||
SDL_SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, "1");
|
||||
|
||||
if (SDL_InitSubSystem(SDL_INIT_TIMER) != 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL_InitSubSystem(SDL_INIT_TIMER) failed: %s",
|
||||
SDL_GetError());
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef STEAM_LINK
|
||||
// Steam Link requires that we initialize video before creating our
|
||||
// QGuiApplication in order to configure the framebuffer correctly.
|
||||
if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL_InitSubSystem(SDL_INIT_VIDEO) failed: %s",
|
||||
SDL_GetError());
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Use atexit() to ensure SDL_Quit() is called. This avoids
|
||||
// racing with object destruction where SDL may be used.
|
||||
atexit(SDL_Quit);
|
||||
|
||||
// Avoid the default behavior of changing the timer resolution to 1 ms.
|
||||
// We don't want this all the time that Moonlight is open. We will set
|
||||
// it manually when we start streaming.
|
||||
SDL_SetHint(SDL_HINT_TIMER_RESOLUTION, "0");
|
||||
|
||||
// Disable minimize on focus loss by default. Users seem to want this off by default.
|
||||
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
// Allow thread naming using exceptions on debug builds. SDL doesn't use SEH
|
||||
// when throwing the exceptions, so we don't enable it for release builds out
|
||||
// of caution.
|
||||
SDL_SetHint(SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING, "0");
|
||||
#endif
|
||||
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
// After the QGuiApplication is created, the platform stuff will be initialized
|
||||
// and we can set the SDL video driver to match Qt.
|
||||
if (qgetenv("XDG_SESSION_TYPE") == "wayland" && QGuiApplication::platformName() == "xcb") {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Detected XWayland. This will probably break hardware decoding! Try running with QT_QPA_PLATFORM=wayland or switch to X11.");
|
||||
}
|
||||
else if (QGuiApplication::platformName().startsWith("wayland")) {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Detected Wayland. Performance may be worse than X11.");
|
||||
qputenv("SDL_VIDEODRIVER", "wayland");
|
||||
}
|
||||
|
||||
#ifdef STEAM_LINK
|
||||
// Qt 5.9 from the Steam Link SDK is not able to load any fonts
|
||||
// since the Steam Link doesn't include any of the ones it looks
|
||||
// for. We know it has NotoSans so we will explicitly ask for that.
|
||||
if (app.font().family().isEmpty()) {
|
||||
qWarning() << "SL HACK: No default font - using NotoSans";
|
||||
|
||||
QFont fon("NotoSans");
|
||||
app.setFont(fon);
|
||||
}
|
||||
|
||||
// Move the mouse to the bottom right so it's invisible when using
|
||||
// gamepad-only navigation.
|
||||
QCursor().setPos(0xFFFF, 0xFFFF);
|
||||
#endif
|
||||
|
||||
app.setWindowIcon(QIcon(":/res/moonlight.svg"));
|
||||
|
||||
// Register our C++ types for QML
|
||||
qmlRegisterType<ComputerModel>("ComputerModel", 1, 0, "ComputerModel");
|
||||
qmlRegisterType<AppModel>("AppModel", 1, 0, "AppModel");
|
||||
qmlRegisterType<StreamingPreferences>("StreamingPreferences", 1, 0, "StreamingPreferences");
|
||||
qmlRegisterType<SdlGamepadKeyNavigation>("SdlGamepadKeyNavigation", 1, 0, "SdlGamepadKeyNavigation");
|
||||
qmlRegisterUncreatableType<Session>("Session", 1, 0, "Session", "Session cannot be created from QML");
|
||||
qmlRegisterSingletonType<ComputerManager>("ComputerManager", 1, 0,
|
||||
"ComputerManager",
|
||||
@@ -323,8 +396,45 @@ int main(int argc, char *argv[])
|
||||
[](QQmlEngine*, QJSEngine*) -> QObject* {
|
||||
return new AutoUpdateChecker();
|
||||
});
|
||||
qmlRegisterSingletonType<SystemProperties>("SystemProperties", 1, 0,
|
||||
"SystemProperties",
|
||||
[](QQmlEngine*, QJSEngine*) -> QObject* {
|
||||
return new SystemProperties();
|
||||
});
|
||||
qmlRegisterSingletonType<SdlGamepadKeyNavigation>("SdlGamepadKeyNavigation", 1, 0,
|
||||
"SdlGamepadKeyNavigation",
|
||||
[](QQmlEngine*, QJSEngine*) -> QObject* {
|
||||
return new SdlGamepadKeyNavigation();
|
||||
});
|
||||
qmlRegisterSingletonType<StreamingPreferences>("StreamingPreferences", 1, 0,
|
||||
"StreamingPreferences",
|
||||
[](QQmlEngine*, QJSEngine*) -> QObject* {
|
||||
return new StreamingPreferences();
|
||||
});
|
||||
|
||||
QQuickStyle::setStyle("Material");
|
||||
#ifndef Q_OS_WINRT
|
||||
// Use the dense material dark theme by default
|
||||
if (!qEnvironmentVariableIsSet("QT_QUICK_CONTROLS_STYLE")) {
|
||||
qputenv("QT_QUICK_CONTROLS_STYLE", "Material");
|
||||
}
|
||||
#else
|
||||
// Use universal dark on WinRT
|
||||
if (!qEnvironmentVariableIsSet("QT_QUICK_CONTROLS_STYLE")) {
|
||||
qputenv("QT_QUICK_CONTROLS_STYLE", "Universal");
|
||||
}
|
||||
#endif
|
||||
if (!qEnvironmentVariableIsSet("QT_QUICK_CONTROLS_MATERIAL_THEME")) {
|
||||
qputenv("QT_QUICK_CONTROLS_MATERIAL_THEME", "Dark");
|
||||
}
|
||||
if (!qEnvironmentVariableIsSet("QT_QUICK_CONTROLS_MATERIAL_ACCENT")) {
|
||||
qputenv("QT_QUICK_CONTROLS_MATERIAL_ACCENT", "Purple");
|
||||
}
|
||||
if (!qEnvironmentVariableIsSet("QT_QUICK_CONTROLS_MATERIAL_VARIANT")) {
|
||||
qputenv("QT_QUICK_CONTROLS_MATERIAL_VARIANT", "Dense");
|
||||
}
|
||||
if (!qEnvironmentVariableIsSet("QT_QUICK_CONTROLS_UNIVERSAL_THEME")) {
|
||||
qputenv("QT_QUICK_CONTROLS_UNIVERSAL_THEME", "Dark");
|
||||
}
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
QString initialView;
|
||||
@@ -332,11 +442,11 @@ int main(int argc, char *argv[])
|
||||
GlobalCommandLineParser parser;
|
||||
switch (parser.parse(app.arguments())) {
|
||||
case GlobalCommandLineParser::NormalStartRequested:
|
||||
initialView = "PcView.qml";
|
||||
initialView = "qrc:/gui/PcView.qml";
|
||||
break;
|
||||
case GlobalCommandLineParser::StreamRequested:
|
||||
{
|
||||
initialView = "CliStartStreamSegue.qml";
|
||||
initialView = "qrc:/gui/CliStartStreamSegue.qml";
|
||||
StreamingPreferences* preferences = new StreamingPreferences(&app);
|
||||
StreamCommandLineParser streamParser;
|
||||
streamParser.parse(app.arguments(), preferences);
|
||||
@@ -348,7 +458,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
case GlobalCommandLineParser::QuitRequested:
|
||||
{
|
||||
initialView = "CliQuitStreamSegue.qml";
|
||||
initialView = "qrc:/gui/CliQuitStreamSegue.qml";
|
||||
QuitCommandLineParser quitParser;
|
||||
quitParser.parse(app.arguments());
|
||||
auto launcher = new CliQuitStream::Launcher(quitParser.getHost(), &app);
|
||||
@@ -364,22 +474,6 @@ int main(int argc, char *argv[])
|
||||
if (engine.rootObjects().isEmpty())
|
||||
return -1;
|
||||
|
||||
SDL_SetMainReady();
|
||||
if (SDL_Init(SDL_INIT_TIMER) != 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL_Init() failed: %s",
|
||||
SDL_GetError());
|
||||
}
|
||||
|
||||
// Use atexit() to ensure SDL_Quit() is called. This avoids
|
||||
// racing with object destruction where SDL may be used.
|
||||
atexit(SDL_Quit);
|
||||
|
||||
// Avoid the default behavior of changing the timer resolution to 1 ms.
|
||||
// We don't want this all the time that Moonlight is open. We will set
|
||||
// it manually when we start streaming.
|
||||
SDL_SetHint(SDL_HINT_TIMER_RESOLUTION, "0");
|
||||
|
||||
int err = app.exec();
|
||||
|
||||
// Give worker tasks time to properly exit. Fixes PendingQuitTask
|
||||
|
||||
|
Before Width: | Height: | Size: 345 KiB After Width: | Height: | Size: 328 KiB |
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 2.6 KiB |
@@ -8,7 +8,6 @@
|
||||
|
||||
QString Path::s_LogDir;
|
||||
QString Path::s_BoxArtCacheDir;
|
||||
const QString Path::k_GameControllerMappingFile("gamecontrollerdb.txt");
|
||||
|
||||
QString Path::getLogDir()
|
||||
{
|
||||
@@ -22,40 +21,42 @@ QString Path::getBoxArtCacheDir()
|
||||
return s_BoxArtCacheDir;
|
||||
}
|
||||
|
||||
QString Path::getGamepadMappingFile()
|
||||
QByteArray Path::readDataFile(QString fileName)
|
||||
{
|
||||
QFile dataFile(getDataFilePath(fileName));
|
||||
dataFile.open(QIODevice::ReadOnly);
|
||||
return dataFile.readAll();
|
||||
}
|
||||
|
||||
QString Path::getDataFilePath(QString fileName)
|
||||
{
|
||||
QString candidatePath;
|
||||
|
||||
// Check the current directory first
|
||||
candidatePath = QDir(QDir::currentPath()).absoluteFilePath(k_GameControllerMappingFile);
|
||||
candidatePath = QDir(QDir::currentPath()).absoluteFilePath(fileName);
|
||||
if (QFile::exists(candidatePath)) {
|
||||
qInfo() << "Found" << fileName << "at" << candidatePath;
|
||||
return candidatePath;
|
||||
}
|
||||
|
||||
// Now check the data directories (for Linux, in particular)
|
||||
candidatePath = QStandardPaths::locate(QStandardPaths::DataLocation, k_GameControllerMappingFile);
|
||||
candidatePath = QStandardPaths::locate(QStandardPaths::DataLocation, fileName);
|
||||
if (!candidatePath.isEmpty() && QFile::exists(candidatePath)) {
|
||||
qInfo() << "Found" << fileName << "at" << candidatePath;
|
||||
return candidatePath;
|
||||
}
|
||||
|
||||
// Now try the directory of our app installation (for Windows, if current dir doesn't find it)
|
||||
candidatePath = QDir(QCoreApplication::applicationDirPath()).absoluteFilePath(k_GameControllerMappingFile);
|
||||
candidatePath = QDir(QCoreApplication::applicationDirPath()).absoluteFilePath(fileName);
|
||||
if (QFile::exists(candidatePath)) {
|
||||
qInfo() << "Found" << fileName << "at" << candidatePath;
|
||||
return candidatePath;
|
||||
}
|
||||
|
||||
// Now try the Resources folder in our app bundle for macOS
|
||||
QDir dir = QDir(QCoreApplication::applicationDirPath());
|
||||
dir.cdUp();
|
||||
dir.cd("Resources");
|
||||
dir.filePath(k_GameControllerMappingFile);
|
||||
candidatePath = dir.absoluteFilePath(k_GameControllerMappingFile);
|
||||
if (QFile::exists(candidatePath)) {
|
||||
return candidatePath;
|
||||
}
|
||||
|
||||
// Couldn't find it
|
||||
return QString();
|
||||
// Return the QRC embedded copy
|
||||
candidatePath = ":/data/" + fileName;
|
||||
qInfo() << "Found" << fileName << "at" << candidatePath;
|
||||
return QString(candidatePath);
|
||||
}
|
||||
|
||||
void Path::initialize(bool portable)
|
||||
|
||||
@@ -9,12 +9,14 @@ public:
|
||||
|
||||
static QString getBoxArtCacheDir();
|
||||
|
||||
static QString getGamepadMappingFile();
|
||||
static QByteArray readDataFile(QString fileName);
|
||||
|
||||
// Only safe to use directly for Qt classes
|
||||
static QString getDataFilePath(QString fileName);
|
||||
|
||||
static void initialize(bool portable);
|
||||
|
||||
private:
|
||||
static QString s_LogDir;
|
||||
static QString s_BoxArtCacheDir;
|
||||
static const QString k_GameControllerMappingFile;
|
||||
};
|
||||
|
||||
@@ -13,5 +13,10 @@
|
||||
<file>gui/CliQuitStreamSegue.qml</file>
|
||||
<file>gui/CliStartStreamSegue.qml</file>
|
||||
<file>gui/AutoResizingComboBox.qml</file>
|
||||
<file>gui/NavigableMenu.qml</file>
|
||||
<file>gui/ErrorMessageDialog.qml</file>
|
||||
<file>gui/NavigableMessageDialog.qml</file>
|
||||
<file>gui/NavigableDialog.qml</file>
|
||||
<file>gui/CenteredGridView.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="#fff"><path d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z"/><path d="M0 0h24v24H0z" fill="none"/></svg>
|
||||
|
After Width: | Height: | Size: 325 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="#FFFFFF"><path fill="none" d="M0 0h24v24H0V0z"/><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/></svg>
|
||||
|
After Width: | Height: | Size: 323 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="#FFFFFF"><path fill="none" d="M0 0h24v24H0z"/><path d="M11 18h2v-2h-2v2zm1-16C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm0-14c-2.21 0-4 1.79-4 4h2c0-1.1.9-2 2-2s2 .9 2 2c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5 0-2.21-1.79-4-4-4z"/></svg>
|
||||
|
After Width: | Height: | Size: 397 B |
@@ -1,69 +1 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
id="svg3761"
|
||||
viewBox="0 0 680 680"
|
||||
height="680"
|
||||
width="680"
|
||||
version="1.0">
|
||||
<metadata
|
||||
id="metadata3767">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs3765" />
|
||||
<g
|
||||
id="g3759"
|
||||
transform="translate(-135,491) scale(0.100000,-0.100000)">
|
||||
<circle
|
||||
id="circle3741"
|
||||
fill="#565C64"
|
||||
r="3400"
|
||||
cy="1505"
|
||||
cx="4755" />
|
||||
<path
|
||||
id="path3743"
|
||||
style="fill:#ffffff"
|
||||
d="M4550 4230 c-582 -48 -1123 -271 -1568 -646 l-84 -70 869 -869 c477 -477 871 -868 876 -868 4 0 6 552 5 1228 l-3 1227 -25 1 c-14 0 -45 -1 -70 -3z" />
|
||||
<path
|
||||
id="path3745"
|
||||
style="fill:#ffffff"
|
||||
d="M4867 4230 c-10 -9 -9 -2453 1 -2453 4 0 398 391 875 868 l869 869 -84 70 c-344 290 -749 492 -1178 587 -166 36 -469 74 -483 59z" />
|
||||
<path
|
||||
id="path3747"
|
||||
style="fill:#ffffff"
|
||||
d="M2673 3275 c-241 -285 -412 -595 -526 -953 -63 -196 -111 -458 -119 -640 l-3 -70 1228 -3 c675 -1 1227 1 1227 5 0 5 -391 399 -868 876 l-869 869 -70 -84z" />
|
||||
<path
|
||||
id="path3749"
|
||||
style="fill:#ffffff"
|
||||
d="M5898 2490 c-478 -477 -868 -871 -868 -876 0 -4 552 -6 1228 -5 l1227 3 -3 70 c-14 326 -124 729 -287 1055 -91 182 -259 430 -387 573 l-43 48 -867 -868z" />
|
||||
<path
|
||||
id="path3751"
|
||||
style="fill:#ffffff"
|
||||
d="M2026 1388 c-7 -11 10 -198 30 -321 76 -486 291 -952 617 -1338 l70 -84 869 869 c477 477 868 871 868 875 0 11 -2448 10 -2454 -1z" />
|
||||
<path
|
||||
id="path3753"
|
||||
style="fill:#ffffff"
|
||||
d="M5030 1390 c0 -5 391 -399 868 -876 l869 -869 70 84 c241 285 412 595 526 953 63 196 111 458 119 640 l3 70 -1227 3 c-676 1 -1228 -1 -1228 -5z" />
|
||||
<path
|
||||
id="path3755"
|
||||
style="fill:#ffffff"
|
||||
d="M3767 359 l-869 -869 84 -70 c285 -241 595 -412 953 -526 196 -63 458 -111 640 -119 l70 -3 3 1228 c1 675 -1 1227 -5 1227 -5 0 -399 -391 -876 -868z" />
|
||||
<path
|
||||
id="path3757"
|
||||
style="fill:#ffffff"
|
||||
d="M4862 0 l3 -1228 70 3 c182 8 444 56 640 119 358 114 668 285 953 526 l84 70 -869 869 c-477 477 -871 868 -876 868 -4 0 -6 -552 -5 -1227z" />
|
||||
</g>
|
||||
</svg>
|
||||
<?xml version="1.0" standalone="no"?><!-- Generator: Gravit.io --><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="isolation:isolate" viewBox="0 0 256 256" width="256" height="256"><g><circle vector-effect="non-scaling-stroke" cx="128" cy="128" r="128" fill="rgb(86,92,100)"/><circle vector-effect="non-scaling-stroke" cx="128.00000000000003" cy="128.00000000000003" r="96" fill="rgb(255,255,255)"/><path d=" M 137.66 132 L 224 132 L 224 124 L 137.66 124 L 198.71 62.95 L 193.05 57.29 L 132 118.34 L 132 32 L 124 32 L 124 118.34 L 62.95 57.29 L 57.29 62.95 L 118.34 124 L 32 124 L 32 132 L 118.34 132 L 57.29 193.05 L 62.95 198.71 L 124 137.66 L 124 224 L 132 224 L 132 137.66 L 193.05 198.71 L 198.71 193.05 L 137.66 132 Z " fill-rule="evenodd" fill="rgb(86,92,100)"/></g></svg>
|
||||
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 820 B |
@@ -8,11 +8,18 @@
|
||||
<file>res/baseline-lock-24px.svg</file>
|
||||
<file>res/baseline-play_circle_filled_white-48px.svg</file>
|
||||
<file>res/baseline-warning-24px.svg</file>
|
||||
<file>res/baseline-cancel-24px.svg</file>
|
||||
<file>res/no_app_image.png</file>
|
||||
<file>res/settings.svg</file>
|
||||
<file>res/arrow_left.svg</file>
|
||||
<file>res/question_mark.svg</file>
|
||||
<file>res/moonlight.svg</file>
|
||||
<file>res/update.svg</file>
|
||||
<file>res/baseline-help_outline-24px.svg</file>
|
||||
<file>res/baseline-error_outline-24px.svg</file>
|
||||
</qresource>
|
||||
<qresource prefix="/data">
|
||||
<file alias="gamecontrollerdb.txt">SDL_GameControllerDB/gamecontrollerdb.txt</file>
|
||||
<file alias="ModeSeven.ttf">ModeSeven.ttf</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
@@ -54,15 +54,10 @@ void MappingManager::save()
|
||||
|
||||
void MappingManager::applyMappings()
|
||||
{
|
||||
QString mappingFile = Path::getGamepadMappingFile();
|
||||
if (!mappingFile.isEmpty()) {
|
||||
std::string mappingFileNative = QDir::toNativeSeparators(mappingFile).toStdString();
|
||||
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Loading gamepad mappings from: %s",
|
||||
mappingFileNative.c_str());
|
||||
|
||||
int newMappings = SDL_GameControllerAddMappingsFromFile(mappingFileNative.c_str());
|
||||
QByteArray mappingData = Path::readDataFile("gamecontrollerdb.txt");
|
||||
if (!mappingData.isEmpty()) {
|
||||
int newMappings = SDL_GameControllerAddMappingsFromRW(
|
||||
SDL_RWFromConstMem(mappingData.constData(), mappingData.size()), 1);
|
||||
if (newMappings < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Error loading gamepad mappings: %s",
|
||||
@@ -75,8 +70,8 @@ void MappingManager::applyMappings()
|
||||
}
|
||||
}
|
||||
else {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"No gamepad mapping file found");
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Unable to load gamepad mapping file");
|
||||
}
|
||||
|
||||
QList<SdlGamepadMapping> mappings = m_Mappings.values();
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
#include "streamingpreferences.h"
|
||||
#include "streaming/session.h"
|
||||
#include "streaming/streamutils.h"
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
@@ -23,6 +21,8 @@
|
||||
#define SER_QUITAPPAFTER "quitAppAfter"
|
||||
#define SER_MOUSEACCELERATION "mouseacceleration"
|
||||
#define SER_STARTWINDOWED "startwindowed"
|
||||
#define SER_FRAMEPACING "framepacing"
|
||||
#define SER_CONNWARNINGS "connwarnings"
|
||||
|
||||
StreamingPreferences::StreamingPreferences(QObject *parent)
|
||||
: QObject(parent)
|
||||
@@ -47,6 +47,8 @@ void StreamingPreferences::reload()
|
||||
quitAppAfter = settings.value(SER_QUITAPPAFTER, false).toBool();
|
||||
mouseAcceleration = settings.value(SER_MOUSEACCELERATION, false).toBool();
|
||||
startWindowed = settings.value(SER_STARTWINDOWED, false).toBool();
|
||||
framePacing = settings.value(SER_FRAMEPACING, false).toBool();
|
||||
connectionWarnings = settings.value(SER_CONNWARNINGS, true).toBool();
|
||||
audioConfig = static_cast<AudioConfig>(settings.value(SER_AUDIOCFG,
|
||||
static_cast<int>(AudioConfig::AC_STEREO)).toInt());
|
||||
videoCodecConfig = static_cast<VideoCodecConfig>(settings.value(SER_VIDEOCFG,
|
||||
@@ -76,133 +78,14 @@ void StreamingPreferences::save()
|
||||
settings.setValue(SER_QUITAPPAFTER, quitAppAfter);
|
||||
settings.setValue(SER_MOUSEACCELERATION, mouseAcceleration);
|
||||
settings.setValue(SER_STARTWINDOWED, startWindowed);
|
||||
settings.setValue(SER_FRAMEPACING, framePacing);
|
||||
settings.setValue(SER_CONNWARNINGS, connectionWarnings);
|
||||
settings.setValue(SER_AUDIOCFG, static_cast<int>(audioConfig));
|
||||
settings.setValue(SER_VIDEOCFG, static_cast<int>(videoCodecConfig));
|
||||
settings.setValue(SER_VIDEODEC, static_cast<int>(videoDecoderSelection));
|
||||
settings.setValue(SER_WINDOWMODE, static_cast<int>(windowMode));
|
||||
}
|
||||
|
||||
bool StreamingPreferences::hasAnyHardwareAcceleration()
|
||||
{
|
||||
// Always use VDS_AUTO to avoid spamming the user with warnings
|
||||
// if they've forced software decoding.
|
||||
return Session::isHardwareDecodeAvailable(VDS_AUTO,
|
||||
VIDEO_FORMAT_H264,
|
||||
1920, 1080, 60);
|
||||
}
|
||||
|
||||
bool StreamingPreferences::isRunningWayland()
|
||||
{
|
||||
return qgetenv("XDG_SESSION_TYPE") == QByteArray("wayland");
|
||||
}
|
||||
|
||||
bool StreamingPreferences::isWow64()
|
||||
{
|
||||
#ifdef Q_OS_WIN32
|
||||
return QSysInfo::currentCpuArchitecture() != QSysInfo::buildCpuArchitecture();
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
QString StreamingPreferences::getUnmappedGamepads()
|
||||
{
|
||||
return SdlInputHandler::getUnmappedGamepads();
|
||||
}
|
||||
|
||||
int StreamingPreferences::getMaximumStreamingFrameRate()
|
||||
{
|
||||
// Never let the maximum drop below 60 FPS
|
||||
int maxFrameRate = 60;
|
||||
|
||||
if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL_InitSubSystem(SDL_INIT_VIDEO) failed: %s",
|
||||
SDL_GetError());
|
||||
return maxFrameRate;
|
||||
}
|
||||
|
||||
SDL_DisplayMode mode, bestMode, desktopMode;
|
||||
for (int displayIndex = 0; displayIndex < SDL_GetNumVideoDisplays(); displayIndex++) {
|
||||
// Get the native desktop resolution
|
||||
if (StreamUtils::getRealDesktopMode(displayIndex, &desktopMode)) {
|
||||
|
||||
// Start at desktop mode and work our way up
|
||||
bestMode = desktopMode;
|
||||
for (int i = 0; i < SDL_GetNumDisplayModes(displayIndex); i++) {
|
||||
if (SDL_GetDisplayMode(displayIndex, i, &mode) == 0) {
|
||||
if (mode.w == desktopMode.w && mode.h == desktopMode.h) {
|
||||
if (mode.refresh_rate > bestMode.refresh_rate) {
|
||||
bestMode = mode;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
maxFrameRate = qMax(maxFrameRate, bestMode.refresh_rate);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
|
||||
return maxFrameRate;
|
||||
}
|
||||
|
||||
QRect StreamingPreferences::getDesktopResolution(int displayIndex)
|
||||
{
|
||||
if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL_InitSubSystem(SDL_INIT_VIDEO) failed: %s",
|
||||
SDL_GetError());
|
||||
return QRect();
|
||||
}
|
||||
|
||||
if (displayIndex >= SDL_GetNumVideoDisplays()) {
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
return QRect();
|
||||
}
|
||||
|
||||
SDL_DisplayMode mode;
|
||||
int err = SDL_GetDesktopDisplayMode(displayIndex, &mode);
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
|
||||
if (err == 0) {
|
||||
return QRect(0, 0, mode.w, mode.h);
|
||||
}
|
||||
else {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL_GetDesktopDisplayMode() failed: %s",
|
||||
SDL_GetError());
|
||||
return QRect();
|
||||
}
|
||||
}
|
||||
|
||||
QRect StreamingPreferences::getNativeResolution(int displayIndex)
|
||||
{
|
||||
if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL_InitSubSystem(SDL_INIT_VIDEO) failed: %s",
|
||||
SDL_GetError());
|
||||
return QRect();
|
||||
}
|
||||
|
||||
if (displayIndex >= SDL_GetNumVideoDisplays()) {
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
return QRect();
|
||||
}
|
||||
|
||||
SDL_DisplayMode mode;
|
||||
bool success = StreamUtils::getRealDesktopMode(displayIndex, &mode);
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
|
||||
if (success) {
|
||||
return QRect(0, 0, mode.w, mode.h);
|
||||
}
|
||||
else {
|
||||
return QRect();
|
||||
}
|
||||
}
|
||||
|
||||
int StreamingPreferences::getDefaultBitrate(int width, int height, int fps)
|
||||
{
|
||||
// This table prefers 16:10 resolutions because they are
|
||||
|
||||
@@ -15,20 +15,6 @@ public:
|
||||
|
||||
Q_INVOKABLE void save();
|
||||
|
||||
Q_INVOKABLE static bool hasAnyHardwareAcceleration();
|
||||
|
||||
Q_INVOKABLE static bool isRunningWayland();
|
||||
|
||||
Q_INVOKABLE static bool isWow64();
|
||||
|
||||
Q_INVOKABLE static int getMaximumStreamingFrameRate();
|
||||
|
||||
Q_INVOKABLE QRect getDesktopResolution(int displayIndex);
|
||||
|
||||
Q_INVOKABLE QRect getNativeResolution(int displayIndex);
|
||||
|
||||
Q_INVOKABLE QString getUnmappedGamepads();
|
||||
|
||||
void reload();
|
||||
|
||||
enum AudioConfig
|
||||
@@ -76,6 +62,8 @@ public:
|
||||
Q_PROPERTY(bool quitAppAfter MEMBER quitAppAfter NOTIFY quitAppAfterChanged)
|
||||
Q_PROPERTY(bool mouseAcceleration MEMBER mouseAcceleration NOTIFY mouseAccelerationChanged)
|
||||
Q_PROPERTY(bool startWindowed MEMBER startWindowed NOTIFY startWindowedChanged)
|
||||
Q_PROPERTY(bool framePacing MEMBER framePacing NOTIFY framePacingChanged)
|
||||
Q_PROPERTY(bool connectionWarnings MEMBER connectionWarnings NOTIFY connectionWarningsChanged)
|
||||
Q_PROPERTY(AudioConfig audioConfig MEMBER audioConfig NOTIFY audioConfigChanged)
|
||||
Q_PROPERTY(VideoCodecConfig videoCodecConfig MEMBER videoCodecConfig NOTIFY videoCodecConfigChanged)
|
||||
Q_PROPERTY(VideoDecoderSelection videoDecoderSelection MEMBER videoDecoderSelection NOTIFY videoDecoderSelectionChanged)
|
||||
@@ -95,6 +83,8 @@ public:
|
||||
bool quitAppAfter;
|
||||
bool mouseAcceleration;
|
||||
bool startWindowed;
|
||||
bool framePacing;
|
||||
bool connectionWarnings;
|
||||
AudioConfig audioConfig;
|
||||
VideoCodecConfig videoCodecConfig;
|
||||
VideoDecoderSelection videoDecoderSelection;
|
||||
@@ -116,5 +106,7 @@ signals:
|
||||
void videoDecoderSelectionChanged();
|
||||
void windowModeChanged();
|
||||
void startWindowedChanged();
|
||||
void framePacingChanged();
|
||||
void connectionWarningsChanged();
|
||||
};
|
||||
|
||||
|
||||
@@ -3,16 +3,26 @@
|
||||
|
||||
#ifdef HAVE_SOUNDIO
|
||||
#include "renderers/soundioaudiorenderer.h"
|
||||
#else
|
||||
#include "renderers/sdl.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SLAUDIO
|
||||
#include "renderers/slaud.h"
|
||||
#endif
|
||||
|
||||
#include "renderers/sdl.h"
|
||||
|
||||
#include <Limelight.h>
|
||||
|
||||
IAudioRenderer* Session::createAudioRenderer()
|
||||
{
|
||||
#ifdef HAVE_SOUNDIO
|
||||
#if defined(HAVE_SOUNDIO)
|
||||
if (qgetenv("ML_AUDIO") == "SDL") {
|
||||
return new SdlAudioRenderer();
|
||||
}
|
||||
|
||||
return new SoundIoAudioRenderer();
|
||||
#elif defined(HAVE_SLAUDIO)
|
||||
return new SLAudioRenderer();
|
||||
#else
|
||||
return new SdlAudioRenderer();
|
||||
#endif
|
||||
@@ -31,6 +41,7 @@ bool Session::testAudio(int audioConfiguration)
|
||||
// the renderer the channel count and sample rate.
|
||||
OPUS_MULTISTREAM_CONFIGURATION opusConfig = {};
|
||||
opusConfig.sampleRate = 48000;
|
||||
opusConfig.samplesPerFrame = 240;
|
||||
|
||||
switch (audioConfiguration)
|
||||
{
|
||||
@@ -101,8 +112,11 @@ void Session::arDecodeAndPlaySample(char* sampleData, int sampleLength)
|
||||
{
|
||||
int samplesDecoded;
|
||||
|
||||
// Set this thread to high priority to reduce
|
||||
// the chance of missing our sample delivery time
|
||||
#ifndef STEAM_LINK
|
||||
// Set this thread to high priority to reduce the chance of missing
|
||||
// our sample delivery time. On Steam Link, this causes starvation
|
||||
// of other threads due to severely restricted CPU time available,
|
||||
// so we will skip it on that platform.
|
||||
if (s_ActiveSession->m_AudioSampleCount == 0) {
|
||||
if (SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH) < 0) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
@@ -110,29 +124,54 @@ void Session::arDecodeAndPlaySample(char* sampleData, int sampleLength)
|
||||
SDL_GetError());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// See if we need to drop this sample
|
||||
if (s_ActiveSession->m_DropAudioEndTime != 0) {
|
||||
if (SDL_TICKS_PASSED(SDL_GetTicks(), s_ActiveSession->m_DropAudioEndTime)) {
|
||||
// Avoid calling SDL_GetTicks() now
|
||||
s_ActiveSession->m_DropAudioEndTime = 0;
|
||||
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Audio drop window has ended");
|
||||
}
|
||||
else {
|
||||
// We're still in the drop window
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
s_ActiveSession->m_AudioSampleCount++;
|
||||
|
||||
if (s_ActiveSession->m_AudioRenderer != nullptr) {
|
||||
int desiredSize = sizeof(short) * s_ActiveSession->m_AudioConfig.samplesPerFrame * s_ActiveSession->m_AudioConfig.channelCount;
|
||||
void* buffer = s_ActiveSession->m_AudioRenderer->getAudioBuffer(&desiredSize);
|
||||
if (buffer == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
samplesDecoded = opus_multistream_decode(s_ActiveSession->m_OpusDecoder,
|
||||
(unsigned char*)sampleData,
|
||||
sampleLength,
|
||||
s_ActiveSession->m_OpusDecodeBuffer,
|
||||
SAMPLES_PER_FRAME,
|
||||
(short*)buffer,
|
||||
desiredSize / sizeof(short) / s_ActiveSession->m_AudioConfig.channelCount,
|
||||
0);
|
||||
|
||||
// Update desiredSize with the number of bytes actually populated by the decoding operation
|
||||
if (samplesDecoded > 0) {
|
||||
if (!s_ActiveSession->m_AudioRenderer->submitAudio(s_ActiveSession->m_OpusDecodeBuffer,
|
||||
static_cast<int>(
|
||||
sizeof(short) *
|
||||
samplesDecoded *
|
||||
s_ActiveSession->m_AudioConfig.channelCount))) {
|
||||
SDL_assert(desiredSize >= sizeof(short) * samplesDecoded * s_ActiveSession->m_AudioConfig.channelCount);
|
||||
desiredSize = sizeof(short) * samplesDecoded * s_ActiveSession->m_AudioConfig.channelCount;
|
||||
}
|
||||
else {
|
||||
desiredSize = 0;
|
||||
}
|
||||
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Reinitializing audio renderer after failure");
|
||||
if (!s_ActiveSession->m_AudioRenderer->submitAudio(desiredSize)) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Reinitializing audio renderer after failure");
|
||||
|
||||
delete s_ActiveSession->m_AudioRenderer;
|
||||
s_ActiveSession->m_AudioRenderer = nullptr;
|
||||
}
|
||||
delete s_ActiveSession->m_AudioRenderer;
|
||||
s_ActiveSession->m_AudioRenderer = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,10 +180,22 @@ void Session::arDecodeAndPlaySample(char* sampleData, int sampleLength)
|
||||
// safe to reinitialize here because we can't be torn down while
|
||||
// the audio decoder/playback thread is still alive.
|
||||
if (s_ActiveSession->m_AudioRenderer == nullptr && (s_ActiveSession->m_AudioSampleCount % 200) == 0) {
|
||||
// Since we're doing this inline and audio initialization takes time, we need
|
||||
// to drop samples to account for the time we've spent blocking audio rendering
|
||||
// so we return to real-time playback and don't accumulate latency.
|
||||
Uint32 audioReinitStartTime = SDL_GetTicks();
|
||||
|
||||
s_ActiveSession->m_AudioRenderer = s_ActiveSession->createAudioRenderer();
|
||||
if (!s_ActiveSession->m_AudioRenderer->prepareForPlayback(&s_ActiveSession->m_AudioConfig)) {
|
||||
delete s_ActiveSession->m_AudioRenderer;
|
||||
s_ActiveSession->m_AudioRenderer = nullptr;
|
||||
}
|
||||
|
||||
Uint32 audioReinitStopTime = SDL_GetTicks();
|
||||
|
||||
s_ActiveSession->m_DropAudioEndTime = audioReinitStopTime + (audioReinitStopTime - audioReinitStartTime);
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Audio reinitialization took %d ms - starting drop window",
|
||||
audioReinitStopTime - audioReinitStartTime);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,6 @@
|
||||
|
||||
#include <Limelight.h>
|
||||
|
||||
#define MAX_CHANNELS 6
|
||||
#define SAMPLES_PER_FRAME 240
|
||||
|
||||
class IAudioRenderer
|
||||
{
|
||||
public:
|
||||
@@ -12,6 +9,8 @@ public:
|
||||
|
||||
virtual bool prepareForPlayback(const OPUS_MULTISTREAM_CONFIGURATION* opusConfig) = 0;
|
||||
|
||||
virtual void* getAudioBuffer(int* size) = 0;
|
||||
|
||||
// Return false if an unrecoverable error has occurred and the renderer must be reinitialized
|
||||
virtual bool submitAudio(short* audioBuffer, int audioSize) = 0;
|
||||
virtual bool submitAudio(int bytesWritten) = 0;
|
||||
};
|
||||
|
||||
@@ -12,13 +12,11 @@ public:
|
||||
|
||||
virtual bool prepareForPlayback(const OPUS_MULTISTREAM_CONFIGURATION* opusConfig);
|
||||
|
||||
virtual bool submitAudio(short* audioBuffer, int audioSize);
|
||||
virtual void* getAudioBuffer(int* size);
|
||||
|
||||
virtual bool submitAudio(int bytesWritten);
|
||||
|
||||
private:
|
||||
SDL_AudioDeviceID m_AudioDevice;
|
||||
Uint32 m_ChannelCount;
|
||||
Uint32 m_PendingDrops;
|
||||
Uint32 m_PendingHardDrops;
|
||||
Uint32 m_SampleIndex;
|
||||
Uint32 m_BaselinePendingData;
|
||||
void* m_AudioBuffer;
|
||||
};
|
||||
|
||||
@@ -5,18 +5,9 @@
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
#define MIN_QUEUED_FRAMES 2
|
||||
#define MAX_QUEUED_FRAMES 4
|
||||
#define STOP_THE_WORLD_LIMIT 20
|
||||
#define DROP_RATIO_DENOM 32
|
||||
|
||||
SdlAudioRenderer::SdlAudioRenderer()
|
||||
: m_AudioDevice(0),
|
||||
m_ChannelCount(0),
|
||||
m_PendingDrops(0),
|
||||
m_PendingHardDrops(0),
|
||||
m_SampleIndex(0),
|
||||
m_BaselinePendingData(0)
|
||||
m_AudioBuffer(nullptr)
|
||||
{
|
||||
SDL_assert(!SDL_WasInit(SDL_INIT_AUDIO));
|
||||
if (SDL_InitSubSystem(SDL_INIT_AUDIO) != 0) {
|
||||
@@ -40,14 +31,20 @@ bool SdlAudioRenderer::prepareForPlayback(const OPUS_MULTISTREAM_CONFIGURATION*
|
||||
// frames contain a non-power of 2 number of samples,
|
||||
// so the slop would require buffering another full frame.
|
||||
// Specifying non-Po2 seems to work for our supported platforms.
|
||||
want.samples = SAMPLES_PER_FRAME;
|
||||
want.samples = opusConfig->samplesPerFrame;
|
||||
|
||||
m_AudioDevice = SDL_OpenAudioDevice(NULL, 0, &want, &have, 0);
|
||||
if (m_AudioDevice == 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Failed to open audio device: %s",
|
||||
SDL_GetError());
|
||||
SDL_QuitSubSystem(SDL_INIT_AUDIO);
|
||||
return false;
|
||||
}
|
||||
|
||||
m_AudioBuffer = malloc(opusConfig->samplesPerFrame * sizeof(short) * opusConfig->channelCount);
|
||||
if (m_AudioBuffer == nullptr) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Failed to allocate audio buffer");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -61,27 +58,6 @@ bool SdlAudioRenderer::prepareForPlayback(const OPUS_MULTISTREAM_CONFIGURATION*
|
||||
have.samples,
|
||||
have.size);
|
||||
|
||||
// SDL counts pending samples in the queued
|
||||
// audio size using the WASAPI backend. This
|
||||
// includes silence, which can throw off our
|
||||
// pending data count. Get a baseline so we
|
||||
// can exclude that data.
|
||||
m_BaselinePendingData = 0;
|
||||
#ifdef Q_OS_WIN32
|
||||
for (int i = 0; i < 100; i++) {
|
||||
m_BaselinePendingData = qMax(m_BaselinePendingData, SDL_GetQueuedAudioSize(m_AudioDevice));
|
||||
SDL_Delay(10);
|
||||
}
|
||||
#endif
|
||||
m_BaselinePendingData *= 2;
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Baseline pending audio data: %d bytes",
|
||||
m_BaselinePendingData);
|
||||
|
||||
m_ChannelCount = opusConfig->channelCount;
|
||||
m_SampleIndex = 0;
|
||||
m_PendingDrops = m_PendingHardDrops = 0;
|
||||
|
||||
// Start playback
|
||||
SDL_PauseAudioDevice(m_AudioDevice, 0);
|
||||
|
||||
@@ -96,60 +72,27 @@ SdlAudioRenderer::~SdlAudioRenderer()
|
||||
SDL_CloseAudioDevice(m_AudioDevice);
|
||||
}
|
||||
|
||||
if (m_AudioBuffer != nullptr) {
|
||||
free(m_AudioBuffer);
|
||||
}
|
||||
|
||||
SDL_QuitSubSystem(SDL_INIT_AUDIO);
|
||||
SDL_assert(!SDL_WasInit(SDL_INIT_AUDIO));
|
||||
}
|
||||
|
||||
bool SdlAudioRenderer::submitAudio(short* audioBuffer, int audioSize)
|
||||
void* SdlAudioRenderer::getAudioBuffer(int*)
|
||||
{
|
||||
m_SampleIndex++;
|
||||
return m_AudioBuffer;
|
||||
}
|
||||
|
||||
Uint32 queuedAudio = SDL_GetQueuedAudioSize(m_AudioDevice);
|
||||
if (queuedAudio > m_BaselinePendingData) {
|
||||
queuedAudio -= m_BaselinePendingData;
|
||||
}
|
||||
else {
|
||||
queuedAudio = 0;
|
||||
}
|
||||
|
||||
Uint32 framesQueued = queuedAudio / (SAMPLES_PER_FRAME * m_ChannelCount * sizeof(short));
|
||||
|
||||
// We must check this prior to the below checks to ensure we don't
|
||||
// underflow if framesQueued - m_PendingHardDrops < 0.
|
||||
if (framesQueued <= MIN_QUEUED_FRAMES) {
|
||||
m_PendingDrops = m_PendingHardDrops = 0;
|
||||
}
|
||||
// Pend enough drops to get us back to MIN_QUEUED_FRAMES, checking first
|
||||
// to ensure we don't underflow.
|
||||
else if (framesQueued > m_PendingHardDrops &&
|
||||
framesQueued - m_PendingHardDrops > STOP_THE_WORLD_LIMIT) {
|
||||
m_PendingHardDrops = framesQueued - MIN_QUEUED_FRAMES;
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Pending hard drop of %u audio frames",
|
||||
m_PendingHardDrops);
|
||||
}
|
||||
// If we're under the stop the world limit, we can drop samples
|
||||
// gracefully over the next little while.
|
||||
else if (framesQueued > m_PendingHardDrops + m_PendingDrops &&
|
||||
framesQueued - m_PendingHardDrops - m_PendingDrops > MAX_QUEUED_FRAMES) {
|
||||
m_PendingDrops = framesQueued - MIN_QUEUED_FRAMES;
|
||||
}
|
||||
|
||||
// Determine if this frame should be dropped
|
||||
if (m_PendingHardDrops != 0) {
|
||||
// Hard drops happen all at once to forcefully
|
||||
// resync with the source.
|
||||
m_PendingHardDrops--;
|
||||
return true;
|
||||
}
|
||||
else if (m_PendingDrops != 0 && m_SampleIndex % DROP_RATIO_DENOM == 0) {
|
||||
// Normal drops are interspersed with the audio data
|
||||
// to hide the glitches.
|
||||
m_PendingDrops--;
|
||||
bool SdlAudioRenderer::submitAudio(int bytesWritten)
|
||||
{
|
||||
if (bytesWritten == 0) {
|
||||
// Nothing to do
|
||||
return true;
|
||||
}
|
||||
|
||||
if (SDL_QueueAudio(m_AudioDevice, audioBuffer, audioSize) < 0) {
|
||||
if (SDL_QueueAudio(m_AudioDevice, m_AudioBuffer, bytesWritten) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Failed to queue audio sample: %s",
|
||||
SDL_GetError());
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
#include "slaud.h"
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
SLAudioRenderer::SLAudioRenderer()
|
||||
: m_AudioContext(nullptr),
|
||||
m_AudioStream(nullptr),
|
||||
m_AudioBuffer(nullptr)
|
||||
{
|
||||
SLAudio_SetLogFunction(SLAudioRenderer::slLogCallback, nullptr);
|
||||
}
|
||||
|
||||
bool SLAudioRenderer::prepareForPlayback(const OPUS_MULTISTREAM_CONFIGURATION* opusConfig)
|
||||
{
|
||||
m_AudioContext = SLAudio_CreateContext();
|
||||
if (m_AudioContext == nullptr) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SLAudio_CreateContext() failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
// This number is pretty conservative (especially for surround), but
|
||||
// it's hard to avoid since we get crushed by CPU limitations.
|
||||
m_MaxQueuedAudioMs = 40 * opusConfig->channelCount / 2;
|
||||
|
||||
m_FrameDuration = opusConfig->samplesPerFrame / 48;
|
||||
m_AudioBufferSize = opusConfig->samplesPerFrame * sizeof(short) * opusConfig->channelCount;
|
||||
m_AudioStream = SLAudio_CreateStream(m_AudioContext,
|
||||
opusConfig->sampleRate,
|
||||
opusConfig->channelCount,
|
||||
m_AudioBufferSize,
|
||||
1);
|
||||
if (m_AudioStream == nullptr) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SLAudio_CreateStream() failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Using SLAudio renderer with %d ms frames",
|
||||
m_FrameDuration);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void* SLAudioRenderer::getAudioBuffer(int* size)
|
||||
{
|
||||
SDL_assert(*size == m_AudioBufferSize);
|
||||
|
||||
if (m_AudioBuffer == nullptr) {
|
||||
m_AudioBuffer = SLAudio_BeginFrame(m_AudioStream);
|
||||
}
|
||||
|
||||
return m_AudioBuffer;
|
||||
}
|
||||
|
||||
SLAudioRenderer::~SLAudioRenderer()
|
||||
{
|
||||
if (m_AudioBuffer != nullptr) {
|
||||
memset(m_AudioBuffer, 0, m_AudioBufferSize);
|
||||
SLAudio_SubmitFrame(m_AudioStream);
|
||||
}
|
||||
|
||||
if (m_AudioStream != nullptr) {
|
||||
SLAudio_FreeStream(m_AudioStream);
|
||||
}
|
||||
|
||||
if (m_AudioContext != nullptr) {
|
||||
SLAudio_FreeContext(m_AudioContext);
|
||||
}
|
||||
}
|
||||
|
||||
bool SLAudioRenderer::submitAudio(int bytesWritten)
|
||||
{
|
||||
if (bytesWritten == 0) {
|
||||
// This buffer will be reused next time
|
||||
return true;
|
||||
}
|
||||
|
||||
if (LiGetPendingAudioFrames() * m_FrameDuration < m_MaxQueuedAudioMs) {
|
||||
SLAudio_SubmitFrame(m_AudioStream);
|
||||
m_AudioBuffer = nullptr;
|
||||
}
|
||||
else {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Too many queued audio frames: %d",
|
||||
LiGetPendingAudioFrames());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SLAudioRenderer::slLogCallback(void*, ESLAudioLog logLevel, const char *message)
|
||||
{
|
||||
SDL_LogPriority priority;
|
||||
|
||||
switch (logLevel)
|
||||
{
|
||||
case k_ESLAudioLogError:
|
||||
priority = SDL_LOG_PRIORITY_ERROR;
|
||||
break;
|
||||
case k_ESLAudioLogWarning:
|
||||
priority = SDL_LOG_PRIORITY_WARN;
|
||||
break;
|
||||
case k_ESLAudioLogInfo:
|
||||
priority = SDL_LOG_PRIORITY_INFO;
|
||||
break;
|
||||
default:
|
||||
case k_ESLAudioLogDebug:
|
||||
priority = SDL_LOG_PRIORITY_DEBUG;
|
||||
break;
|
||||
}
|
||||
|
||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION,
|
||||
priority,
|
||||
"SLAudio: %s",
|
||||
message);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include "renderer.h"
|
||||
#include <SLAudio.h>
|
||||
|
||||
class SLAudioRenderer : public IAudioRenderer
|
||||
{
|
||||
public:
|
||||
SLAudioRenderer();
|
||||
|
||||
virtual ~SLAudioRenderer();
|
||||
|
||||
virtual bool prepareForPlayback(const OPUS_MULTISTREAM_CONFIGURATION* opusConfig);
|
||||
|
||||
virtual void* getAudioBuffer(int* size);
|
||||
|
||||
virtual bool submitAudio(int bytesWritten);
|
||||
|
||||
private:
|
||||
static void slLogCallback(void* context, ESLAudioLog logLevel, const char* message);
|
||||
|
||||
CSLAudioContext* m_AudioContext;
|
||||
CSLAudioStream* m_AudioStream;
|
||||
|
||||
void* m_AudioBuffer;
|
||||
int m_AudioBufferSize;
|
||||
int m_FrameDuration;
|
||||
int m_MaxQueuedAudioMs;
|
||||
};
|
||||
@@ -4,19 +4,30 @@
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
// This determines the size of the buffers we'll
|
||||
// get from CoreAudio. Since GFE sends us packets
|
||||
// in 5 ms chunks, we'll give them to the OS in
|
||||
// buffers of the same size. It is also the minimum
|
||||
// size that we will write when called to fill a buffer.
|
||||
// GFE sends us packets in 5 ms chunks
|
||||
const double SoundIoAudioRenderer::k_RawSampleLengthSec = 0.005;
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
// PulseAudio and ALSA require more than just 5 ms samples
|
||||
// for some reason, so write a minimum of 25 ms each time to
|
||||
// prevent underruns on Bluetooth.
|
||||
// https://github.com/moonlight-stream/moonlight-qt/issues/147
|
||||
// https://github.com/moonlight-stream/moonlight-qt/issues/157
|
||||
const double SoundIoAudioRenderer::k_MinSampleLengthSec = 0.025;
|
||||
#else
|
||||
// This determines the size of the buffers we'll
|
||||
// get from CoreAudio. It is also the minimum
|
||||
// size that we will write when called to fill a buffer.
|
||||
const double SoundIoAudioRenderer::k_MinSampleLengthSec = k_RawSampleLengthSec;
|
||||
#endif
|
||||
|
||||
SoundIoAudioRenderer::SoundIoAudioRenderer()
|
||||
: m_OpusChannelCount(0),
|
||||
m_SoundIo(nullptr),
|
||||
m_Device(nullptr),
|
||||
m_OutputStream(nullptr),
|
||||
m_RingBuffer(nullptr),
|
||||
m_Latency(0),
|
||||
m_Errored(false)
|
||||
{
|
||||
|
||||
@@ -24,6 +35,10 @@ SoundIoAudioRenderer::SoundIoAudioRenderer()
|
||||
|
||||
SoundIoAudioRenderer::~SoundIoAudioRenderer()
|
||||
{
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Audio latency: %f",
|
||||
m_Latency);
|
||||
|
||||
if (m_OutputStream != nullptr) {
|
||||
soundio_outstream_destroy(m_OutputStream);
|
||||
}
|
||||
@@ -159,7 +174,7 @@ bool SoundIoAudioRenderer::prepareForPlayback(const OPUS_MULTISTREAM_CONFIGURATI
|
||||
|
||||
m_OutputStream->format = SoundIoFormatS16NE;
|
||||
m_OutputStream->sample_rate = opusConfig->sampleRate;
|
||||
m_OutputStream->software_latency = k_RawSampleLengthSec;
|
||||
m_OutputStream->software_latency = k_MinSampleLengthSec;
|
||||
m_OutputStream->name = "Moonlight";
|
||||
m_OutputStream->userdata = this;
|
||||
m_OutputStream->error_callback = sioErrorCallback;
|
||||
@@ -220,12 +235,33 @@ bool SoundIoAudioRenderer::prepareForPlayback(const OPUS_MULTISTREAM_CONFIGURATI
|
||||
}
|
||||
}
|
||||
|
||||
// Buffer up to 6 packets of audio (30 ms) to smooth
|
||||
// out network packet delivery jitter
|
||||
int packetsToBuffer;
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
// PulseAudio and ALSA need the large buffer (see comment on k_MinSampleLengthSec),
|
||||
// so we need a buffer at least double that size to allow packets to arrive
|
||||
// while we're writing to the sink.
|
||||
packetsToBuffer = (int)(k_MinSampleLengthSec / k_RawSampleLengthSec) * 2;
|
||||
#else
|
||||
if (m_SoundIo->current_backend == SoundIoBackendWasapi) {
|
||||
// 15 ms buffer seems to be fine for WASAPI
|
||||
packetsToBuffer = 3;
|
||||
}
|
||||
else {
|
||||
// 30 ms buffer on CoreAudio to avoid glitching on macOS
|
||||
packetsToBuffer = 6;
|
||||
}
|
||||
#endif
|
||||
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Audio buffer size: %d packets",
|
||||
packetsToBuffer);
|
||||
|
||||
m_RingBuffer = soundio_ring_buffer_create(m_SoundIo,
|
||||
m_OutputStream->bytes_per_sample *
|
||||
m_OpusChannelCount *
|
||||
SAMPLES_PER_FRAME * 6);
|
||||
opusConfig->samplesPerFrame *
|
||||
packetsToBuffer);
|
||||
if (m_RingBuffer == nullptr) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"soundio_ring_buffer_create() failed");
|
||||
@@ -240,18 +276,16 @@ bool SoundIoAudioRenderer::prepareForPlayback(const OPUS_MULTISTREAM_CONFIGURATI
|
||||
return false;
|
||||
}
|
||||
|
||||
// HACK: For some reason, a constant latency hangs around in the audio pipeline
|
||||
// unless we wait for the audio stream to drain before actually submitting any samples.
|
||||
// This is a gross hack, but it works remarkably well.
|
||||
SDL_Delay(500);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SoundIoAudioRenderer::submitAudio(short* audioBuffer, int audioSize)
|
||||
void* SoundIoAudioRenderer::getAudioBuffer(int* size)
|
||||
{
|
||||
if (m_Errored) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Flush events to update with new device arrivals
|
||||
soundio_flush_events(m_SoundIo);
|
||||
|
||||
// We must always write a full frame of audio. If we don't,
|
||||
// the reader will get out of sync with the writer and our
|
||||
// channels will get all mixed up. To ensure this is always
|
||||
@@ -259,9 +293,26 @@ bool SoundIoAudioRenderer::submitAudio(short* audioBuffer, int audioSize)
|
||||
// of our frame size.
|
||||
int bytesFree = soundio_ring_buffer_free_count(m_RingBuffer);
|
||||
int bytesPerFrame = m_OpusChannelCount * m_OutputStream->bytes_per_sample;
|
||||
int bytesToWrite = qMin(audioSize, (bytesFree / bytesPerFrame) * bytesPerFrame);
|
||||
memcpy(soundio_ring_buffer_write_ptr(m_RingBuffer), audioBuffer, bytesToWrite);
|
||||
soundio_ring_buffer_advance_write_ptr(m_RingBuffer, bytesToWrite);
|
||||
*size = qMin(*size, (bytesFree / bytesPerFrame) * bytesPerFrame);
|
||||
return soundio_ring_buffer_write_ptr(m_RingBuffer);
|
||||
}
|
||||
|
||||
bool SoundIoAudioRenderer::submitAudio(int bytesWritten)
|
||||
{
|
||||
if (m_Errored) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bytesWritten == 0) {
|
||||
// Nothing to do
|
||||
return true;
|
||||
}
|
||||
|
||||
// Flush events to update with new device arrivals
|
||||
soundio_flush_events(m_SoundIo);
|
||||
|
||||
// Advance the write pointer
|
||||
soundio_ring_buffer_advance_write_ptr(m_RingBuffer, bytesWritten);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -336,35 +387,12 @@ void SoundIoAudioRenderer::sioWriteCallback(SoundIoOutStream* stream, int frameC
|
||||
// Ensure we always write at least a buffer, even if it's silence, to avoid
|
||||
// busy looping when no audio data is available while libsoundio tries to keep
|
||||
// us from starving the output device.
|
||||
frameCountMin = qMax(frameCountMin, (int)(stream->sample_rate * k_RawSampleLengthSec));
|
||||
frameCountMin = qMax(frameCountMin, (int)(stream->sample_rate * k_MinSampleLengthSec));
|
||||
frameCountMin = qMin(frameCountMin, frameCountMax);
|
||||
|
||||
// Place an upper-bound on audio stream latency to
|
||||
// avoid accumulating packets in queue-based backends
|
||||
// like WASAPI, ALSA, and PulseAudio.
|
||||
//
|
||||
// This bound was set by testing on several Windows machines.
|
||||
// The highest latency was found on a XPS 9343 running Windows 7
|
||||
// in Steam Big Picture and the 5.1 audio test clip from Fraunhofer.
|
||||
// Track latency on queueing-based backends
|
||||
if (me->m_SoundIo->current_backend != SoundIoBackendCoreAudio && me->m_SoundIo->current_backend != SoundIoBackendJack) {
|
||||
double latency;
|
||||
if (soundio_outstream_get_latency(stream, &latency) == SoundIoErrorNone) {
|
||||
if (latency > 0.050) {
|
||||
// If our latency is higher than desired, drop these samples to gracefully lower
|
||||
// the latency without glitching too much. Dropping the whole buffer causes
|
||||
// a much more noticeable glitch. This approach also ensures that we don't
|
||||
// accidentally underflow if the driver/kernel side is delayed and isn't
|
||||
// consuming data fast enough. Dropping a frame at a time and re-evaluating
|
||||
// each time ensures that we'll stop dropping if latency returns to normal.
|
||||
readPtr += framesLeft * stream->bytes_per_sample * me->m_OpusChannelCount;
|
||||
bytesRead += framesLeft * stream->bytes_per_sample * me->m_OpusChannelCount;
|
||||
framesLeft = 0;
|
||||
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Latency exceeded drop cap: %f",
|
||||
latency);
|
||||
}
|
||||
}
|
||||
soundio_outstream_get_latency(stream, &me->m_Latency);
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
|
||||
@@ -13,7 +13,9 @@ public:
|
||||
|
||||
virtual bool prepareForPlayback(const OPUS_MULTISTREAM_CONFIGURATION* opusConfig);
|
||||
|
||||
virtual bool submitAudio(short* audioBuffer, int audioSize);
|
||||
virtual void* getAudioBuffer(int* size);
|
||||
|
||||
virtual bool submitAudio(int bytesWritten);
|
||||
|
||||
private:
|
||||
int scoreChannelLayout(const struct SoundIoChannelLayout* layout, const OPUS_MULTISTREAM_CONFIGURATION* opusConfig);
|
||||
@@ -32,7 +34,9 @@ private:
|
||||
struct SoundIoOutStream* m_OutputStream;
|
||||
struct SoundIoRingBuffer* m_RingBuffer;
|
||||
struct SoundIoChannelLayout m_EffectiveLayout;
|
||||
double m_Latency;
|
||||
bool m_Errored;
|
||||
|
||||
static const double k_RawSampleLengthSec;
|
||||
static const double k_MinSampleLengthSec;
|
||||
};
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "path.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QtMath>
|
||||
#include <QDir>
|
||||
|
||||
#define VK_0 0x30
|
||||
@@ -28,6 +29,18 @@
|
||||
// How far the finger can move before it cancels a drag or tap
|
||||
#define DEAD_ZONE_DELTA 0.1f
|
||||
|
||||
// How long the Start button must be pressed to toggle mouse emulation
|
||||
#define MOUSE_EMULATION_LONG_PRESS_TIME 750
|
||||
|
||||
// How long between polling the gamepad to send virtual mouse input
|
||||
#define MOUSE_EMULATION_POLLING_INTERVAL 50
|
||||
|
||||
// Determines how fast the mouse will move each interval
|
||||
#define MOUSE_EMULATION_MOTION_MULTIPLIER 4
|
||||
|
||||
// Determines the maximum motion amount before allowing movement
|
||||
#define MOUSE_EMULATION_DEADZONE 2
|
||||
|
||||
const int SdlInputHandler::k_ButtonMap[] = {
|
||||
A_FLAG, B_FLAG, X_FLAG, Y_FLAG,
|
||||
BACK_FLAG, SPECIAL_FLAG, PLAY_FLAG,
|
||||
@@ -54,8 +67,38 @@ SdlInputHandler::SdlInputHandler(StreamingPreferences& prefs, NvComputer*, int s
|
||||
// is via normal motion events that are influenced by mouse acceleration).
|
||||
// Otherwise, we'll use raw input capture which is straight from the device
|
||||
// without modification by the OS.
|
||||
SDL_SetHint(SDL_HINT_MOUSE_RELATIVE_MODE_WARP,
|
||||
prefs.mouseAcceleration ? "1" : "0");
|
||||
SDL_SetHintWithPriority(SDL_HINT_MOUSE_RELATIVE_MODE_WARP,
|
||||
prefs.mouseAcceleration ? "1" : "0",
|
||||
SDL_HINT_OVERRIDE);
|
||||
|
||||
#ifdef Q_OS_DARWIN
|
||||
// SDL 2.0.9 on macOS has a broken HIDAPI mapping for the older Xbox One S
|
||||
// firmware, so we have to disable HIDAPI for Xbox gamepads on macOS.
|
||||
// https://github.com/moonlight-stream/moonlight-qt/issues/133
|
||||
// https://bugzilla.libsdl.org/show_bug.cgi?id=4395
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_XBOX, "0");
|
||||
#endif
|
||||
|
||||
// We must initialize joystick explicitly before gamecontroller in order
|
||||
// to ensure we receive gamecontroller attach events for gamepads where
|
||||
// SDL doesn't have a built-in mapping. By starting joystick first, we
|
||||
// can allow mapping manager to update the mappings before GC attach
|
||||
// events are generated.
|
||||
SDL_assert(!SDL_WasInit(SDL_INIT_JOYSTICK));
|
||||
if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) != 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL_InitSubSystem(SDL_INIT_JOYSTICK) failed: %s",
|
||||
SDL_GetError());
|
||||
}
|
||||
|
||||
MappingManager mappingManager;
|
||||
mappingManager.applyMappings();
|
||||
|
||||
// Flush gamepad arrival and departure events which may be queued before
|
||||
// starting the gamecontroller subsystem again. This prevents us from
|
||||
// receiving duplicate arrival and departure events for the same gamepad.
|
||||
SDL_FlushEvent(SDL_CONTROLLERDEVICEADDED);
|
||||
SDL_FlushEvent(SDL_CONTROLLERDEVICEREMOVED);
|
||||
|
||||
// We need to reinit this each time, since you only get
|
||||
// an initial set of gamepad arrival events once per init.
|
||||
@@ -66,8 +109,12 @@ SdlInputHandler::SdlInputHandler(StreamingPreferences& prefs, NvComputer*, int s
|
||||
SDL_GetError());
|
||||
}
|
||||
|
||||
MappingManager mappingManager;
|
||||
mappingManager.applyMappings();
|
||||
SDL_assert(!SDL_WasInit(SDL_INIT_HAPTIC));
|
||||
if (SDL_InitSubSystem(SDL_INIT_HAPTIC) != 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL_InitSubSystem(SDL_INIT_HAPTIC) failed: %s",
|
||||
SDL_GetError());
|
||||
}
|
||||
|
||||
// Initialize the gamepad mask with currently attached gamepads to avoid
|
||||
// causing gamepads to unexpectedly disappear and reappear on the host
|
||||
@@ -87,6 +134,13 @@ SdlInputHandler::SdlInputHandler(StreamingPreferences& prefs, NvComputer*, int s
|
||||
SdlInputHandler::~SdlInputHandler()
|
||||
{
|
||||
for (int i = 0; i < MAX_GAMEPADS; i++) {
|
||||
if (m_GamepadState[i].mouseEmulationTimer != 0) {
|
||||
Session::get()->notifyMouseEmulationMode(false);
|
||||
SDL_RemoveTimer(m_GamepadState[i].mouseEmulationTimer);
|
||||
}
|
||||
if (m_GamepadState[i].haptic != nullptr) {
|
||||
SDL_HapticClose(m_GamepadState[i].haptic);
|
||||
}
|
||||
if (m_GamepadState[i].controller != nullptr) {
|
||||
SDL_GameControllerClose(m_GamepadState[i].controller);
|
||||
}
|
||||
@@ -97,8 +151,25 @@ SdlInputHandler::~SdlInputHandler()
|
||||
SDL_RemoveTimer(m_RightButtonReleaseTimer);
|
||||
SDL_RemoveTimer(m_DragTimer);
|
||||
|
||||
SDL_QuitSubSystem(SDL_INIT_HAPTIC);
|
||||
SDL_assert(!SDL_WasInit(SDL_INIT_HAPTIC));
|
||||
|
||||
SDL_QuitSubSystem(SDL_INIT_GAMECONTROLLER);
|
||||
SDL_assert(!SDL_WasInit(SDL_INIT_GAMECONTROLLER));
|
||||
|
||||
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
|
||||
SDL_assert(!SDL_WasInit(SDL_INIT_JOYSTICK));
|
||||
|
||||
// Return background event handling to off
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "0");
|
||||
|
||||
#ifdef STEAM_LINK
|
||||
// Hide SDL's cursor on Steam Link after quitting the stream.
|
||||
// FIXME: We should also do this for other situations where SDL
|
||||
// and Qt will draw their own mouse cursors like KMSDRM or RPi
|
||||
// video backends.
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SdlInputHandler::handleKeyEvent(SDL_KeyboardEvent* event)
|
||||
@@ -111,10 +182,21 @@ void SdlInputHandler::handleKeyEvent(SDL_KeyboardEvent* event)
|
||||
(event->keysym.mod & KMOD_CTRL) &&
|
||||
(event->keysym.mod & KMOD_ALT) &&
|
||||
(event->keysym.mod & KMOD_SHIFT)) {
|
||||
// First we test the SDLK combos for matches,
|
||||
// that way we ensure that latin keyboard users
|
||||
// can match to the key they see on their keyboards.
|
||||
// If nothing matches that, we'll then go on to
|
||||
// checking scancodes so non-latin keyboard users
|
||||
// can have working hotkeys (though possibly in
|
||||
// odd positions). We must do all SDLK tests before
|
||||
// any scancode tests to avoid issues in cases
|
||||
// where the SDLK for one shortcut collides with
|
||||
// the scancode of another.
|
||||
|
||||
// Check for quit combo (Ctrl+Alt+Shift+Q)
|
||||
if (event->keysym.sym == SDLK_q) {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Detected quit key combo");
|
||||
"Detected quit key combo (SDLK)");
|
||||
|
||||
// Push a quit event to the main loop
|
||||
SDL_Event event;
|
||||
@@ -126,7 +208,55 @@ void SdlInputHandler::handleKeyEvent(SDL_KeyboardEvent* event)
|
||||
// Check for the unbind combo (Ctrl+Alt+Shift+Z)
|
||||
else if (event->keysym.sym == SDLK_z) {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Detected mouse capture toggle combo");
|
||||
"Detected mouse capture toggle combo (SDLK)");
|
||||
|
||||
// Stop handling future input
|
||||
SDL_SetRelativeMouseMode((SDL_bool)!SDL_GetRelativeMouseMode());
|
||||
|
||||
// Force raise all keys to ensure they aren't stuck,
|
||||
// since we won't get their key up events.
|
||||
raiseAllKeys();
|
||||
return;
|
||||
}
|
||||
else if (event->keysym.sym == SDLK_x) {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Detected full-screen toggle combo (SDLK)");
|
||||
Session::s_ActiveSession->toggleFullscreen();
|
||||
|
||||
// Force raise all keys just be safe across this full-screen/windowed
|
||||
// transition just in case key events get lost.
|
||||
raiseAllKeys();
|
||||
return;
|
||||
}
|
||||
else if (event->keysym.sym == SDLK_s) {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Detected stats toggle combo (SDLK)");
|
||||
|
||||
// Toggle the stats overlay
|
||||
Session::get()->getOverlayManager().setOverlayState(Overlay::OverlayDebug,
|
||||
!Session::get()->getOverlayManager().isOverlayEnabled(Overlay::OverlayDebug));
|
||||
|
||||
// Force raise all keys just be safe across this full-screen/windowed
|
||||
// transition just in case key events get lost.
|
||||
raiseAllKeys();
|
||||
return;
|
||||
}
|
||||
// Check for quit combo (Ctrl+Alt+Shift+Q)
|
||||
else if (event->keysym.scancode == SDL_SCANCODE_Q) {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Detected quit key combo (scancode)");
|
||||
|
||||
// Push a quit event to the main loop
|
||||
SDL_Event event;
|
||||
event.type = SDL_QUIT;
|
||||
event.quit.timestamp = SDL_GetTicks();
|
||||
SDL_PushEvent(&event);
|
||||
return;
|
||||
}
|
||||
// Check for the unbind combo (Ctrl+Alt+Shift+Z)
|
||||
else if (event->keysym.scancode == SDL_SCANCODE_Z) {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Detected mouse capture toggle combo (scancode)");
|
||||
|
||||
// Stop handling future input
|
||||
SDL_SetRelativeMouseMode((SDL_bool)!SDL_GetRelativeMouseMode());
|
||||
@@ -137,11 +267,24 @@ void SdlInputHandler::handleKeyEvent(SDL_KeyboardEvent* event)
|
||||
return;
|
||||
}
|
||||
// Check for the full-screen combo (Ctrl+Alt+Shift+X)
|
||||
else if (event->keysym.sym == SDLK_x) {
|
||||
else if (event->keysym.scancode == SDL_SCANCODE_X) {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Detected full-screen toggle combo");
|
||||
"Detected full-screen toggle combo (scancode)");
|
||||
Session::s_ActiveSession->toggleFullscreen();
|
||||
|
||||
// Force raise all keys just be safe across this full-screen/windowed
|
||||
// transition just in case key events get lost.
|
||||
raiseAllKeys();
|
||||
return;
|
||||
}
|
||||
else if (event->keysym.scancode == SDL_SCANCODE_S) {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Detected stats toggle combo (scancode)");
|
||||
|
||||
// Toggle the stats overlay
|
||||
Session::get()->getOverlayManager().setOverlayState(Overlay::OverlayDebug,
|
||||
!Session::get()->getOverlayManager().isOverlayEnabled(Overlay::OverlayDebug));
|
||||
|
||||
// Force raise all keys just be safe across this full-screen/windowed
|
||||
// transition just in case key events get lost.
|
||||
raiseAllKeys();
|
||||
@@ -546,46 +689,103 @@ Uint32 SdlInputHandler::mouseMoveTimerCallback(Uint32 interval, void *param)
|
||||
return interval;
|
||||
}
|
||||
|
||||
Uint32 SdlInputHandler::mouseEmulationTimerCallback(Uint32 interval, void *param)
|
||||
{
|
||||
auto gamepad = reinterpret_cast<GamepadState*>(param);
|
||||
|
||||
short rawX;
|
||||
short rawY;
|
||||
|
||||
// Determine which analog stick is currently receiving the strongest input
|
||||
if ((uint32_t)qAbs(gamepad->lsX) + qAbs(gamepad->lsY) > (uint32_t)qAbs(gamepad->rsX) + qAbs(gamepad->rsY)) {
|
||||
rawX = gamepad->lsX;
|
||||
rawY = -gamepad->lsY;
|
||||
}
|
||||
else {
|
||||
rawX = gamepad->rsX;
|
||||
rawY = -gamepad->rsY;
|
||||
}
|
||||
|
||||
float deltaX;
|
||||
float deltaY;
|
||||
|
||||
// Produce a base vector for mouse movement with increased speed as we deviate further from center
|
||||
deltaX = qPow(rawX / 32766.0f * MOUSE_EMULATION_MOTION_MULTIPLIER, 3);
|
||||
deltaY = qPow(rawY / 32766.0f * MOUSE_EMULATION_MOTION_MULTIPLIER, 3);
|
||||
|
||||
// Enforce deadzones
|
||||
deltaX = qAbs(deltaX) > MOUSE_EMULATION_DEADZONE ? deltaX - MOUSE_EMULATION_DEADZONE : 0;
|
||||
deltaY = qAbs(deltaY) > MOUSE_EMULATION_DEADZONE ? deltaY - MOUSE_EMULATION_DEADZONE : 0;
|
||||
|
||||
if (deltaX != 0 || deltaY != 0) {
|
||||
LiSendMouseMoveEvent((short)deltaX, (short)deltaY);
|
||||
}
|
||||
|
||||
return interval;
|
||||
}
|
||||
|
||||
void SdlInputHandler::handleControllerAxisEvent(SDL_ControllerAxisEvent* event)
|
||||
{
|
||||
GamepadState* state = findStateForGamepad(event->which);
|
||||
SDL_JoystickID gameControllerId = event->which;
|
||||
GamepadState* state = findStateForGamepad(gameControllerId);
|
||||
if (state == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event->axis)
|
||||
{
|
||||
case SDL_CONTROLLER_AXIS_LEFTX:
|
||||
state->lsX = event->value;
|
||||
// Batch all pending axis motion events for this gamepad to save CPU time
|
||||
SDL_Event nextEvent;
|
||||
for (;;) {
|
||||
switch (event->axis)
|
||||
{
|
||||
case SDL_CONTROLLER_AXIS_LEFTX:
|
||||
state->lsX = event->value;
|
||||
break;
|
||||
case SDL_CONTROLLER_AXIS_LEFTY:
|
||||
// Signed values have one more negative value than
|
||||
// positive value, so inverting the sign on -32768
|
||||
// could actually cause the value to overflow and
|
||||
// wrap around to be negative again. Avoid that by
|
||||
// capping the value at 32767.
|
||||
state->lsY = -qMax(event->value, (short)-32767);
|
||||
break;
|
||||
case SDL_CONTROLLER_AXIS_RIGHTX:
|
||||
state->rsX = event->value;
|
||||
break;
|
||||
case SDL_CONTROLLER_AXIS_RIGHTY:
|
||||
state->rsY = -qMax(event->value, (short)-32767);
|
||||
break;
|
||||
case SDL_CONTROLLER_AXIS_TRIGGERLEFT:
|
||||
state->lt = (unsigned char)(event->value * 255UL / 32767);
|
||||
break;
|
||||
case SDL_CONTROLLER_AXIS_TRIGGERRIGHT:
|
||||
state->rt = (unsigned char)(event->value * 255UL / 32767);
|
||||
break;
|
||||
default:
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Unhandled controller axis: %d",
|
||||
event->axis);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for another event to batch with
|
||||
if (SDL_PeepEvents(&nextEvent, 1, SDL_PEEKEVENT, SDL_CONTROLLERAXISMOTION, SDL_CONTROLLERAXISMOTION) <= 0) {
|
||||
break;
|
||||
case SDL_CONTROLLER_AXIS_LEFTY:
|
||||
// Signed values have one more negative value than
|
||||
// positive value, so inverting the sign on -32768
|
||||
// could actually cause the value to overflow and
|
||||
// wrap around to be negative again. Avoid that by
|
||||
// capping the value at 32767.
|
||||
state->lsY = -qMax(event->value, (short)-32767);
|
||||
}
|
||||
|
||||
event = &nextEvent.caxis;
|
||||
if (event->which != gameControllerId) {
|
||||
// Stop batching if a different gamepad interrupts us
|
||||
break;
|
||||
case SDL_CONTROLLER_AXIS_RIGHTX:
|
||||
state->rsX = event->value;
|
||||
break;
|
||||
case SDL_CONTROLLER_AXIS_RIGHTY:
|
||||
state->rsY = -qMax(event->value, (short)-32767);
|
||||
break;
|
||||
case SDL_CONTROLLER_AXIS_TRIGGERLEFT:
|
||||
state->lt = (unsigned char)(event->value * 255UL / 32767);
|
||||
break;
|
||||
case SDL_CONTROLLER_AXIS_TRIGGERRIGHT:
|
||||
state->rt = (unsigned char)(event->value * 255UL / 32767);
|
||||
break;
|
||||
default:
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Unhandled controller axis: %d",
|
||||
event->axis);
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove the next event to batch
|
||||
SDL_PeepEvents(&nextEvent, 1, SDL_GETEVENT, SDL_CONTROLLERAXISMOTION, SDL_CONTROLLERAXISMOTION);
|
||||
}
|
||||
|
||||
sendGamepadState(state);
|
||||
// Only send the gamepad state to the host if it's not in mouse emulation mode
|
||||
if (state->mouseEmulationTimer == 0) {
|
||||
sendGamepadState(state);
|
||||
}
|
||||
}
|
||||
|
||||
void SdlInputHandler::handleControllerButtonEvent(SDL_ControllerButtonEvent* event)
|
||||
@@ -597,9 +797,76 @@ void SdlInputHandler::handleControllerButtonEvent(SDL_ControllerButtonEvent* eve
|
||||
|
||||
if (event->state == SDL_PRESSED) {
|
||||
state->buttons |= k_ButtonMap[event->button];
|
||||
|
||||
if (event->button == SDL_CONTROLLER_BUTTON_START) {
|
||||
state->lastStartDownTime = SDL_GetTicks();
|
||||
}
|
||||
else if (state->mouseEmulationTimer != 0) {
|
||||
if (event->button == SDL_CONTROLLER_BUTTON_A) {
|
||||
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT);
|
||||
}
|
||||
else if (event->button == SDL_CONTROLLER_BUTTON_B) {
|
||||
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_RIGHT);
|
||||
}
|
||||
else if (event->button == SDL_CONTROLLER_BUTTON_X) {
|
||||
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_MIDDLE);
|
||||
}
|
||||
else if (event->button == SDL_CONTROLLER_BUTTON_LEFTSHOULDER) {
|
||||
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_X1);
|
||||
}
|
||||
else if (event->button == SDL_CONTROLLER_BUTTON_RIGHTSHOULDER) {
|
||||
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_X2);
|
||||
}
|
||||
else if (event->button == SDL_CONTROLLER_BUTTON_DPAD_UP) {
|
||||
LiSendScrollEvent(1);
|
||||
}
|
||||
else if (event->button == SDL_CONTROLLER_BUTTON_DPAD_DOWN) {
|
||||
LiSendScrollEvent(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
state->buttons &= ~k_ButtonMap[event->button];
|
||||
|
||||
if (event->button == SDL_CONTROLLER_BUTTON_START) {
|
||||
if (SDL_GetTicks() - state->lastStartDownTime > MOUSE_EMULATION_LONG_PRESS_TIME) {
|
||||
if (state->mouseEmulationTimer != 0) {
|
||||
SDL_RemoveTimer(state->mouseEmulationTimer);
|
||||
state->mouseEmulationTimer = 0;
|
||||
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Mouse emulation deactivated");
|
||||
Session::get()->notifyMouseEmulationMode(false);
|
||||
}
|
||||
else {
|
||||
// Send the start button up event to the host, since we won't do it below
|
||||
sendGamepadState(state);
|
||||
|
||||
state->mouseEmulationTimer = SDL_AddTimer(MOUSE_EMULATION_POLLING_INTERVAL, SdlInputHandler::mouseEmulationTimerCallback, state);
|
||||
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Mouse emulation active");
|
||||
Session::get()->notifyMouseEmulationMode(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (state->mouseEmulationTimer != 0) {
|
||||
if (event->button == SDL_CONTROLLER_BUTTON_A) {
|
||||
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT);
|
||||
}
|
||||
else if (event->button == SDL_CONTROLLER_BUTTON_B) {
|
||||
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_RIGHT);
|
||||
}
|
||||
else if (event->button == SDL_CONTROLLER_BUTTON_X) {
|
||||
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_MIDDLE);
|
||||
}
|
||||
else if (event->button == SDL_CONTROLLER_BUTTON_LEFTSHOULDER) {
|
||||
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_X1);
|
||||
}
|
||||
else if (event->button == SDL_CONTROLLER_BUTTON_RIGHTSHOULDER) {
|
||||
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_X2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handle Start+Select+L1+R1 as a gamepad quit combo
|
||||
@@ -619,7 +886,10 @@ void SdlInputHandler::handleControllerButtonEvent(SDL_ControllerButtonEvent* eve
|
||||
return;
|
||||
}
|
||||
|
||||
sendGamepadState(state);
|
||||
// Only send the gamepad state to the host if it's not in mouse emulation mode
|
||||
if (state->mouseEmulationTimer == 0) {
|
||||
sendGamepadState(state);
|
||||
}
|
||||
}
|
||||
|
||||
void SdlInputHandler::handleControllerDeviceEvent(SDL_ControllerDeviceEvent* event)
|
||||
@@ -641,19 +911,15 @@ void SdlInputHandler::handleControllerDeviceEvent(SDL_ControllerDeviceEvent* eve
|
||||
return;
|
||||
}
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 9)
|
||||
// Determine this player's preferred index
|
||||
i = SDL_GameControllerGetPlayerIndex(controller);
|
||||
if (i < 0 || i >= MAX_GAMEPADS || m_GamepadState[i].controller != NULL) {
|
||||
// If the player index is unavailable or invalid, start searching from 0
|
||||
i = 0;
|
||||
}
|
||||
#else
|
||||
// SDL 2.0.8 and earlier has no player number hints
|
||||
// We used to use SDL_GameControllerGetPlayerIndex() here but that
|
||||
// can lead to strange issues due to bugs in Windows where an Xbox
|
||||
// controller will join as player 2, even though no player 1 controller
|
||||
// is connected at all. This pretty much screws any attempt to use
|
||||
// the gamepad in single player games, so just assign them in order from 0.
|
||||
i = 0;
|
||||
#endif
|
||||
|
||||
for (; i < MAX_GAMEPADS; i++) {
|
||||
SDL_assert(m_GamepadState[i].controller != controller);
|
||||
if (m_GamepadState[i].controller == NULL) {
|
||||
// Found an empty slot
|
||||
break;
|
||||
@@ -678,6 +944,24 @@ void SdlInputHandler::handleControllerDeviceEvent(SDL_ControllerDeviceEvent* eve
|
||||
|
||||
state->controller = controller;
|
||||
state->jsId = SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(state->controller));
|
||||
state->haptic = SDL_HapticOpenFromJoystick(SDL_GameControllerGetJoystick(state->controller));
|
||||
state->hapticEffectId = -1;
|
||||
state->hapticMethod = GAMEPAD_HAPTIC_METHOD_NONE;
|
||||
if (state->haptic != nullptr) {
|
||||
if ((SDL_HapticQuery(state->haptic) & SDL_HAPTIC_LEFTRIGHT) == 0) {
|
||||
if (SDL_HapticRumbleSupported(state->haptic)) {
|
||||
if (SDL_HapticRumbleInit(state->haptic) == 0) {
|
||||
state->hapticMethod = GAMEPAD_HAPTIC_METHOD_SIMPLERUMBLE;
|
||||
}
|
||||
}
|
||||
if (state->hapticMethod == GAMEPAD_HAPTIC_METHOD_NONE) {
|
||||
SDL_HapticClose(state->haptic);
|
||||
state->haptic = nullptr;
|
||||
}
|
||||
} else {
|
||||
state->hapticMethod = GAMEPAD_HAPTIC_METHOD_LEFTRIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(SDL_GameControllerGetJoystick(state->controller)),
|
||||
guidStr, sizeof(guidStr));
|
||||
@@ -711,7 +995,15 @@ void SdlInputHandler::handleControllerDeviceEvent(SDL_ControllerDeviceEvent* eve
|
||||
else if (event->type == SDL_CONTROLLERDEVICEREMOVED) {
|
||||
state = findStateForGamepad(event->which);
|
||||
if (state != NULL) {
|
||||
if (state->mouseEmulationTimer != 0) {
|
||||
Session::get()->notifyMouseEmulationMode(false);
|
||||
SDL_RemoveTimer(state->mouseEmulationTimer);
|
||||
}
|
||||
|
||||
SDL_GameControllerClose(state->controller);
|
||||
if (state->haptic != nullptr) {
|
||||
SDL_HapticClose(state->haptic);
|
||||
}
|
||||
|
||||
// Remove this from the gamepad mask in MC-mode
|
||||
if (m_MultiController) {
|
||||
@@ -765,6 +1057,59 @@ void SdlInputHandler::handleJoystickArrivalEvent(SDL_JoyDeviceEvent* event)
|
||||
}
|
||||
}
|
||||
|
||||
void SdlInputHandler::rumble(unsigned short controllerNumber, unsigned short lowFreqMotor, unsigned short highFreqMotor)
|
||||
{
|
||||
// Make sure the controller number is within our supported count
|
||||
if (controllerNumber >= MAX_GAMEPADS) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the controller supports haptics (and if the controller exists at all)
|
||||
SDL_Haptic* haptic = m_GamepadState[controllerNumber].haptic;
|
||||
if (haptic == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Stop the last effect we played
|
||||
if (m_GamepadState[controllerNumber].hapticMethod == GAMEPAD_HAPTIC_METHOD_LEFTRIGHT) {
|
||||
if (m_GamepadState[controllerNumber].hapticEffectId >= 0) {
|
||||
SDL_HapticDestroyEffect(haptic, m_GamepadState[controllerNumber].hapticEffectId);
|
||||
}
|
||||
} else if (m_GamepadState[controllerNumber].hapticMethod == GAMEPAD_HAPTIC_METHOD_SIMPLERUMBLE) {
|
||||
SDL_HapticRumbleStop(haptic);
|
||||
}
|
||||
|
||||
// If this callback is telling us to stop both motors, don't bother queuing a new effect
|
||||
if (lowFreqMotor == 0 && highFreqMotor == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_GamepadState[controllerNumber].hapticMethod == GAMEPAD_HAPTIC_METHOD_LEFTRIGHT) {
|
||||
SDL_HapticEffect effect;
|
||||
SDL_memset(&effect, 0, sizeof(effect));
|
||||
effect.type = SDL_HAPTIC_LEFTRIGHT;
|
||||
|
||||
// The effect should last until we are instructed to stop or change it
|
||||
effect.leftright.length = SDL_HAPTIC_INFINITY;
|
||||
|
||||
// SDL haptics range from 0-32767 but XInput uses 0-65535, so divide by 2 to correct for SDL's scaling
|
||||
effect.leftright.large_magnitude = lowFreqMotor / 2;
|
||||
effect.leftright.small_magnitude = highFreqMotor / 2;
|
||||
|
||||
// Play the new effect
|
||||
m_GamepadState[controllerNumber].hapticEffectId = SDL_HapticNewEffect(haptic, &effect);
|
||||
if (m_GamepadState[controllerNumber].hapticEffectId >= 0) {
|
||||
SDL_HapticRunEffect(haptic, m_GamepadState[controllerNumber].hapticEffectId, 1);
|
||||
}
|
||||
} else if (m_GamepadState[controllerNumber].hapticMethod == GAMEPAD_HAPTIC_METHOD_SIMPLERUMBLE) {
|
||||
SDL_HapticRumblePlay(haptic,
|
||||
std::min(1.0, (GAMEPAD_HAPTIC_SIMPLE_HIFREQ_MOTOR_WEIGHT*highFreqMotor +
|
||||
GAMEPAD_HAPTIC_SIMPLE_LOWFREQ_MOTOR_WEIGHT*lowFreqMotor) / 65535.0),
|
||||
SDL_HAPTIC_INFINITY);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SdlInputHandler::handleTouchFingerEvent(SDL_TouchFingerEvent* event)
|
||||
{
|
||||
int fingerIndex = -1;
|
||||
@@ -910,7 +1255,6 @@ int SdlInputHandler::getAttachedGamepadMask()
|
||||
return 0x1;
|
||||
}
|
||||
|
||||
// TODO: Use SDL_GameControllerGetPlayerIndex() for accurate indexes?
|
||||
count = mask = 0;
|
||||
for (int i = 0; i < SDL_NumJoysticks(); i++) {
|
||||
if (SDL_IsGameController(i)) {
|
||||
@@ -971,7 +1315,7 @@ QString SdlInputHandler::getUnmappedGamepads()
|
||||
"Number of axes: %d | Number of buttons: %d | Number of hats: %d",
|
||||
numAxes, numButtons, numHats);
|
||||
|
||||
if (numAxes >= 4 && numButtons >= 8 && numHats <= 1) {
|
||||
if ((numAxes >= 4 && numAxes <= 8) && numButtons >= 8 && numHats <= 1) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Joystick likely to be an unmapped game controller");
|
||||
if (!ret.isEmpty()) {
|
||||
|
||||
@@ -8,8 +8,14 @@
|
||||
struct GamepadState {
|
||||
SDL_GameController* controller;
|
||||
SDL_JoystickID jsId;
|
||||
SDL_Haptic* haptic;
|
||||
int hapticMethod;
|
||||
int hapticEffectId;
|
||||
short index;
|
||||
|
||||
SDL_TimerID mouseEmulationTimer;
|
||||
uint32_t lastStartDownTime;
|
||||
|
||||
short buttons;
|
||||
short lsX, lsY;
|
||||
short rsX, rsY;
|
||||
@@ -19,6 +25,13 @@ struct GamepadState {
|
||||
#define MAX_GAMEPADS 4
|
||||
#define MAX_FINGERS 2
|
||||
|
||||
#define GAMEPAD_HAPTIC_METHOD_NONE 0
|
||||
#define GAMEPAD_HAPTIC_METHOD_LEFTRIGHT 1
|
||||
#define GAMEPAD_HAPTIC_METHOD_SIMPLERUMBLE 2
|
||||
|
||||
#define GAMEPAD_HAPTIC_SIMPLE_HIFREQ_MOTOR_WEIGHT 0.33
|
||||
#define GAMEPAD_HAPTIC_SIMPLE_LOWFREQ_MOTOR_WEIGHT 0.8
|
||||
|
||||
class SdlInputHandler
|
||||
{
|
||||
public:
|
||||
@@ -43,6 +56,8 @@ public:
|
||||
|
||||
void handleJoystickArrivalEvent(SDL_JoyDeviceEvent* event);
|
||||
|
||||
void rumble(unsigned short controllerNumber, unsigned short lowFreqMotor, unsigned short highFreqMotor);
|
||||
|
||||
void handleTouchFingerEvent(SDL_TouchFingerEvent* event);
|
||||
|
||||
int getAttachedGamepadMask();
|
||||
@@ -70,6 +85,9 @@ private:
|
||||
static
|
||||
Uint32 mouseMoveTimerCallback(Uint32 interval, void* param);
|
||||
|
||||
static
|
||||
Uint32 mouseEmulationTimerCallback(Uint32 interval, void* param);
|
||||
|
||||
bool m_MultiController;
|
||||
SDL_TimerID m_MouseMoveTimer;
|
||||
SDL_atomic_t m_MouseDeltaX;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SLVIDEO
|
||||
#include "video/sl.h"
|
||||
#include "video/slvid.h"
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
@@ -38,7 +38,9 @@ CONNECTION_LISTENER_CALLBACKS Session::k_ConnCallbacks = {
|
||||
Session::clConnectionTerminated,
|
||||
nullptr,
|
||||
nullptr,
|
||||
Session::clLogMessage
|
||||
Session::clLogMessage,
|
||||
Session::clRumble,
|
||||
Session::clConnectionStatusUpdate
|
||||
};
|
||||
|
||||
AUDIO_RENDERER_CALLBACKS Session::k_AudioCallbacks = {
|
||||
@@ -47,7 +49,14 @@ AUDIO_RENDERER_CALLBACKS Session::k_AudioCallbacks = {
|
||||
nullptr,
|
||||
Session::arCleanup,
|
||||
Session::arDecodeAndPlaySample,
|
||||
#ifndef STEAM_LINK
|
||||
CAPABILITY_DIRECT_SUBMIT
|
||||
#else
|
||||
// We cannot use direct submit for Steam Link because the
|
||||
// SLAudio renderer needs to look at the audio backlog to
|
||||
// cap latency since playback is a blocking operation.
|
||||
CAPABILITY_SLOW_OPUS_DECODER
|
||||
#endif
|
||||
};
|
||||
|
||||
Session* Session::s_ActiveSession;
|
||||
@@ -73,8 +82,11 @@ void Session::clStageFailed(int stage, long errorCode)
|
||||
|
||||
void Session::clConnectionTerminated(long errorCode)
|
||||
{
|
||||
s_ActiveSession->m_UnexpectedTermination = true;
|
||||
emit s_ActiveSession->displayLaunchError("Connection terminated");
|
||||
// Display the termination dialog if this was not intended
|
||||
if (errorCode != 0) {
|
||||
s_ActiveSession->m_UnexpectedTermination = true;
|
||||
emit s_ActiveSession->displayLaunchError("Connection terminated");
|
||||
}
|
||||
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Connection terminated: %ld",
|
||||
@@ -99,15 +111,72 @@ void Session::clLogMessage(const char* format, ...)
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
#define CALL_INITIALIZE(dec) (dec)->initialize(vds, window, videoFormat, width, height, frameRate, enableVsync)
|
||||
void Session::clRumble(unsigned short controllerNumber, unsigned short lowFreqMotor, unsigned short highFreqMotor)
|
||||
{
|
||||
// The input handler can be closed during the stream if LiStopConnection() hasn't completed yet
|
||||
// but the stream has been stopped by the user. In this case, just discard the rumble.
|
||||
SDL_AtomicLock(&s_ActiveSession->m_InputHandlerLock);
|
||||
if (s_ActiveSession->m_InputHandler != nullptr) {
|
||||
s_ActiveSession->m_InputHandler->rumble(controllerNumber, lowFreqMotor, highFreqMotor);
|
||||
}
|
||||
SDL_AtomicUnlock(&s_ActiveSession->m_InputHandlerLock);
|
||||
}
|
||||
|
||||
void Session::clConnectionStatusUpdate(int connectionStatus)
|
||||
{
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Connection status update: %d",
|
||||
connectionStatus);
|
||||
|
||||
if (!s_ActiveSession->m_Preferences->connectionWarnings) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (s_ActiveSession->m_MouseEmulationRefCount > 0) {
|
||||
// Don't display the overlay if mouse emulation is already using it
|
||||
return;
|
||||
}
|
||||
|
||||
switch (connectionStatus)
|
||||
{
|
||||
case CONN_STATUS_POOR:
|
||||
if (s_ActiveSession->m_StreamConfig.bitrate > 5000) {
|
||||
strcpy(s_ActiveSession->m_OverlayManager.getOverlayText(Overlay::OverlayStatusUpdate), "Slow connection to PC\nReduce your bitrate");
|
||||
}
|
||||
else {
|
||||
strcpy(s_ActiveSession->m_OverlayManager.getOverlayText(Overlay::OverlayStatusUpdate), "Poor connection to PC");
|
||||
}
|
||||
s_ActiveSession->m_OverlayManager.setOverlayTextUpdated(Overlay::OverlayStatusUpdate);
|
||||
s_ActiveSession->m_OverlayManager.setOverlayState(Overlay::OverlayStatusUpdate, true);
|
||||
break;
|
||||
case CONN_STATUS_OKAY:
|
||||
s_ActiveSession->m_OverlayManager.setOverlayState(Overlay::OverlayStatusUpdate, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool Session::chooseDecoder(StreamingPreferences::VideoDecoderSelection vds,
|
||||
SDL_Window* window, int videoFormat, int width, int height,
|
||||
int frameRate, bool enableVsync, IVideoDecoder*& chosenDecoder)
|
||||
int frameRate, bool enableVsync, bool enableFramePacing, bool testOnly, IVideoDecoder*& chosenDecoder)
|
||||
{
|
||||
DECODER_PARAMETERS params;
|
||||
|
||||
params.width = width;
|
||||
params.height = height;
|
||||
params.frameRate = frameRate;
|
||||
params.videoFormat = videoFormat;
|
||||
params.window = window;
|
||||
params.enableVsync = enableVsync;
|
||||
params.enableFramePacing = enableFramePacing;
|
||||
params.vds = vds;
|
||||
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"V-sync %s",
|
||||
enableVsync ? "enabled" : "disabled");
|
||||
|
||||
#ifdef HAVE_SLVIDEO
|
||||
chosenDecoder = new SLVideoDecoder();
|
||||
if (CALL_INITIALIZE(chosenDecoder)) {
|
||||
chosenDecoder = new SLVideoDecoder(testOnly);
|
||||
if (chosenDecoder->initialize(¶ms)) {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SLVideo video decoder chosen");
|
||||
return true;
|
||||
@@ -121,8 +190,8 @@ bool Session::chooseDecoder(StreamingPreferences::VideoDecoderSelection vds,
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FFMPEG
|
||||
chosenDecoder = new FFmpegVideoDecoder();
|
||||
if (CALL_INITIALIZE(chosenDecoder)) {
|
||||
chosenDecoder = new FFmpegVideoDecoder(testOnly);
|
||||
if (chosenDecoder->initialize(¶ms)) {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"FFmpeg-based video decoder chosen");
|
||||
return true;
|
||||
@@ -196,30 +265,13 @@ int Session::drSubmitDecodeUnit(PDECODE_UNIT du)
|
||||
}
|
||||
}
|
||||
|
||||
bool Session::isHardwareDecodeAvailable(StreamingPreferences::VideoDecoderSelection vds,
|
||||
bool Session::isHardwareDecodeAvailable(SDL_Window* window,
|
||||
StreamingPreferences::VideoDecoderSelection vds,
|
||||
int videoFormat, int width, int height, int frameRate)
|
||||
{
|
||||
IVideoDecoder* decoder;
|
||||
|
||||
if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL_InitSubSystem(SDL_INIT_VIDEO) failed: %s",
|
||||
SDL_GetError());
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_Window* window = SDL_CreateWindow("", 0, 0, width, height, SDL_WINDOW_HIDDEN);
|
||||
if (!window) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Failed to create window for hardware decode test: %s",
|
||||
SDL_GetError());
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!chooseDecoder(vds, window, videoFormat, width, height, frameRate, true, decoder)) {
|
||||
SDL_DestroyWindow(window);
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
if (!chooseDecoder(vds, window, videoFormat, width, height, frameRate, true, false, true, decoder)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -227,39 +279,16 @@ bool Session::isHardwareDecodeAvailable(StreamingPreferences::VideoDecoderSelect
|
||||
|
||||
delete decoder;
|
||||
|
||||
// This must be called after the decoder is deleted, because
|
||||
// the renderer may want to interact with the window
|
||||
SDL_DestroyWindow(window);
|
||||
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int Session::getDecoderCapabilities(StreamingPreferences::VideoDecoderSelection vds,
|
||||
int Session::getDecoderCapabilities(SDL_Window* window,
|
||||
StreamingPreferences::VideoDecoderSelection vds,
|
||||
int videoFormat, int width, int height, int frameRate)
|
||||
{
|
||||
IVideoDecoder* decoder;
|
||||
|
||||
if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL_InitSubSystem(SDL_INIT_VIDEO) failed: %s",
|
||||
SDL_GetError());
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_Window* window = SDL_CreateWindow("", 0, 0, width, height, SDL_WINDOW_HIDDEN);
|
||||
if (!window) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Failed to create window for hardware decode test: %s",
|
||||
SDL_GetError());
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!chooseDecoder(vds, window, videoFormat, width, height, frameRate, true, decoder)) {
|
||||
SDL_DestroyWindow(window);
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
if (!chooseDecoder(vds, window, videoFormat, width, height, frameRate, true, false, true, decoder)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -267,12 +296,6 @@ int Session::getDecoderCapabilities(StreamingPreferences::VideoDecoderSelection
|
||||
|
||||
delete decoder;
|
||||
|
||||
// This must be called after the decoder is deleted, because
|
||||
// the renderer may want to interact with the window
|
||||
SDL_DestroyWindow(window);
|
||||
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
|
||||
return caps;
|
||||
}
|
||||
|
||||
@@ -289,12 +312,18 @@ Session::Session(NvComputer* computer, NvApp& app, StreamingPreferences *prefere
|
||||
m_DisplayOriginY(0),
|
||||
m_PendingWindowedTransition(false),
|
||||
m_UnexpectedTermination(true), // Failure prior to streaming is unexpected
|
||||
m_InputHandler(nullptr),
|
||||
m_InputHandlerLock(0),
|
||||
m_MouseEmulationRefCount(0),
|
||||
m_OpusDecoder(nullptr),
|
||||
m_AudioRenderer(nullptr),
|
||||
m_AudioSampleCount(0)
|
||||
m_AudioSampleCount(0),
|
||||
m_DropAudioEndTime(0)
|
||||
{
|
||||
}
|
||||
|
||||
// NB: This may not get destroyed for a long time! Don't put any vital cleanup here.
|
||||
// Use Session::exec() or DeferredSessionCleanupTask instead.
|
||||
Session::~Session()
|
||||
{
|
||||
// Acquire session semaphore to ensure all cleanup is done before the destructor returns
|
||||
@@ -303,8 +332,25 @@ Session::~Session()
|
||||
s_ActiveSessionSemaphore.release();
|
||||
}
|
||||
|
||||
void Session::initialize()
|
||||
bool Session::initialize()
|
||||
{
|
||||
if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL_InitSubSystem(SDL_INIT_VIDEO) failed: %s",
|
||||
SDL_GetError());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create a hidden window to use for decoder initialization tests
|
||||
SDL_Window* testWindow = SDL_CreateWindow("", 0, 0, 1280, 720, SDL_WINDOW_HIDDEN);
|
||||
if (!testWindow) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Failed to create window for hardware decode test: %s",
|
||||
SDL_GetError());
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
return false;
|
||||
}
|
||||
|
||||
qInfo() << "Server GPU:" << m_Computer->gpuModel;
|
||||
qInfo() << "Server GFE version:" << m_Computer->gfeVersion;
|
||||
|
||||
@@ -357,7 +403,8 @@ void Session::initialize()
|
||||
case StreamingPreferences::VCC_AUTO:
|
||||
// TODO: Determine if HEVC is better depending on the decoder
|
||||
m_StreamConfig.supportsHevc =
|
||||
isHardwareDecodeAvailable(m_Preferences->videoDecoderSelection,
|
||||
isHardwareDecodeAvailable(testWindow,
|
||||
m_Preferences->videoDecoderSelection,
|
||||
VIDEO_FORMAT_H265,
|
||||
m_StreamConfig.width,
|
||||
m_StreamConfig.height,
|
||||
@@ -394,6 +441,15 @@ void Session::initialize()
|
||||
break;
|
||||
}
|
||||
|
||||
// Add the capability flags from the chosen decoder/renderer
|
||||
// Requires m_StreamConfig.supportsHevc to be initialized
|
||||
m_VideoCallbacks.capabilities |= getDecoderCapabilities(testWindow,
|
||||
m_Preferences->videoDecoderSelection,
|
||||
m_StreamConfig.supportsHevc ? VIDEO_FORMAT_H265 : VIDEO_FORMAT_H264,
|
||||
m_StreamConfig.width,
|
||||
m_StreamConfig.height,
|
||||
m_StreamConfig.fps);
|
||||
|
||||
switch (m_Preferences->windowMode)
|
||||
{
|
||||
case StreamingPreferences::WM_FULLSCREEN_DESKTOP:
|
||||
@@ -404,6 +460,19 @@ void Session::initialize()
|
||||
m_FullScreenFlag = SDL_WINDOW_FULLSCREEN;
|
||||
break;
|
||||
}
|
||||
|
||||
// Check for validation errors/warnings and emit
|
||||
// signals for them, if appropriate
|
||||
bool ret = validateLaunch(testWindow);
|
||||
|
||||
SDL_DestroyWindow(testWindow);
|
||||
|
||||
if (!ret) {
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Session::emitLaunchWarning(QString text)
|
||||
@@ -422,7 +491,7 @@ void Session::emitLaunchWarning(QString text)
|
||||
}
|
||||
}
|
||||
|
||||
bool Session::validateLaunch()
|
||||
bool Session::validateLaunch(SDL_Window* testWindow)
|
||||
{
|
||||
QStringList warningList;
|
||||
|
||||
@@ -442,7 +511,8 @@ bool Session::validateLaunch()
|
||||
bool hevcForced = m_Preferences->videoCodecConfig == StreamingPreferences::VCC_FORCE_HEVC ||
|
||||
m_Preferences->videoCodecConfig == StreamingPreferences::VCC_FORCE_HEVC_HDR;
|
||||
|
||||
if (!isHardwareDecodeAvailable(m_Preferences->videoDecoderSelection,
|
||||
if (!isHardwareDecodeAvailable(testWindow,
|
||||
m_Preferences->videoDecoderSelection,
|
||||
VIDEO_FORMAT_H265,
|
||||
m_StreamConfig.width,
|
||||
m_StreamConfig.height,
|
||||
@@ -483,7 +553,8 @@ bool Session::validateLaunch()
|
||||
emitLaunchWarning("Your host PC GPU doesn't support HDR streaming. "
|
||||
"A GeForce GTX 1000-series (Pascal) or later GPU is required for HDR streaming.");
|
||||
}
|
||||
else if (!isHardwareDecodeAvailable(m_Preferences->videoDecoderSelection,
|
||||
else if (!isHardwareDecodeAvailable(testWindow,
|
||||
m_Preferences->videoDecoderSelection,
|
||||
VIDEO_FORMAT_H265_MAIN10,
|
||||
m_StreamConfig.width,
|
||||
m_StreamConfig.height,
|
||||
@@ -532,7 +603,8 @@ bool Session::validateLaunch()
|
||||
}
|
||||
|
||||
if (m_Preferences->videoDecoderSelection == StreamingPreferences::VDS_FORCE_HARDWARE &&
|
||||
!isHardwareDecodeAvailable(m_Preferences->videoDecoderSelection,
|
||||
!isHardwareDecodeAvailable(testWindow,
|
||||
m_Preferences->videoDecoderSelection,
|
||||
m_StreamConfig.supportsHevc ? VIDEO_FORMAT_H265 : VIDEO_FORMAT_H264,
|
||||
m_StreamConfig.width,
|
||||
m_StreamConfig.height,
|
||||
@@ -548,13 +620,6 @@ bool Session::validateLaunch()
|
||||
return false;
|
||||
}
|
||||
|
||||
// Add the capability flags from the chosen decoder/renderer
|
||||
m_VideoCallbacks.capabilities |= getDecoderCapabilities(m_Preferences->videoDecoderSelection,
|
||||
m_StreamConfig.supportsHevc ? VIDEO_FORMAT_H265 : VIDEO_FORMAT_H264,
|
||||
m_StreamConfig.width,
|
||||
m_StreamConfig.height,
|
||||
m_StreamConfig.fps);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -593,7 +658,7 @@ private:
|
||||
|
||||
// Perform a best-effort app quit
|
||||
if (shouldQuit) {
|
||||
NvHTTP http(m_Session->m_Computer->activeAddress);
|
||||
NvHTTP http(m_Session->m_Computer->activeAddress, m_Session->m_Computer->serverCert);
|
||||
|
||||
// Logging is already done inside NvHTTP
|
||||
try {
|
||||
@@ -768,6 +833,22 @@ void Session::toggleFullscreen()
|
||||
}
|
||||
}
|
||||
|
||||
void Session::notifyMouseEmulationMode(bool enabled)
|
||||
{
|
||||
m_MouseEmulationRefCount += enabled ? 1 : -1;
|
||||
SDL_assert(m_MouseEmulationRefCount >= 0);
|
||||
|
||||
// We re-use the status update overlay for mouse mode notification
|
||||
if (m_MouseEmulationRefCount > 0) {
|
||||
strcpy(m_OverlayManager.getOverlayText(Overlay::OverlayStatusUpdate), "Gamepad mouse mode active\nLong press Start to deactivate");
|
||||
m_OverlayManager.setOverlayTextUpdated(Overlay::OverlayStatusUpdate);
|
||||
m_OverlayManager.setOverlayState(Overlay::OverlayStatusUpdate, true);
|
||||
}
|
||||
else {
|
||||
m_OverlayManager.setOverlayState(Overlay::OverlayStatusUpdate, false);
|
||||
}
|
||||
}
|
||||
|
||||
void Session::exec(int displayOriginX, int displayOriginY)
|
||||
{
|
||||
m_DisplayOriginX = displayOriginX;
|
||||
@@ -776,11 +857,7 @@ void Session::exec(int displayOriginX, int displayOriginY)
|
||||
// Complete initialization in this deferred context to avoid
|
||||
// calling expensive functions in the constructor (during the
|
||||
// process of loading the StreamSegue).
|
||||
initialize();
|
||||
|
||||
// Check for validation errors/warnings and emit
|
||||
// signals for them, if appropriate
|
||||
if (!validateLaunch()) {
|
||||
if (!initialize()) {
|
||||
emit sessionFinished();
|
||||
return;
|
||||
}
|
||||
@@ -802,46 +879,57 @@ void Session::exec(int displayOriginX, int displayOriginY)
|
||||
|
||||
// Initialize the gamepad code with our preferences
|
||||
StreamingPreferences prefs;
|
||||
SdlInputHandler inputHandler(prefs, m_Computer,
|
||||
m_StreamConfig.width,
|
||||
m_StreamConfig.height);
|
||||
m_InputHandler = new SdlInputHandler(prefs, m_Computer,
|
||||
m_StreamConfig.width,
|
||||
m_StreamConfig.height);
|
||||
|
||||
// The UI should have ensured the old game was already quit
|
||||
// if we decide to stream a different game.
|
||||
Q_ASSERT(m_Computer->currentGameId == 0 ||
|
||||
m_Computer->currentGameId == m_App.id);
|
||||
|
||||
// SOPS will set all settings to 720p60 if it doesn't recognize
|
||||
// the chosen resolution. Avoid that by disabling SOPS when it
|
||||
// is not streaming a supported resolution.
|
||||
bool enableGameOptimizations = false;
|
||||
for (const NvDisplayMode &mode : m_Computer->displayModes) {
|
||||
if (mode.width == m_StreamConfig.width &&
|
||||
mode.height == m_StreamConfig.height) {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Found host supported resolution: %dx%d",
|
||||
mode.width, mode.height);
|
||||
enableGameOptimizations = prefs.gameOptimizations;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
NvHTTP http(m_Computer->activeAddress);
|
||||
NvHTTP http(m_Computer->activeAddress, m_Computer->serverCert);
|
||||
if (m_Computer->currentGameId != 0) {
|
||||
http.resumeApp(&m_StreamConfig);
|
||||
}
|
||||
else {
|
||||
http.launchApp(m_App.id, &m_StreamConfig,
|
||||
prefs.gameOptimizations,
|
||||
enableGameOptimizations,
|
||||
prefs.playAudioOnHost,
|
||||
inputHandler.getAttachedGamepadMask());
|
||||
m_InputHandler->getAttachedGamepadMask());
|
||||
}
|
||||
} catch (const GfeHttpResponseException& e) {
|
||||
emit displayLaunchError(e.toQString());
|
||||
delete m_InputHandler;
|
||||
m_InputHandler = nullptr;
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
emit displayLaunchError("GeForce Experience returned error: " + e.toQString());
|
||||
QThreadPool::globalInstance()->start(new DeferredSessionCleanupTask(this));
|
||||
return;
|
||||
} catch (const QtNetworkReplyException& e) {
|
||||
delete m_InputHandler;
|
||||
m_InputHandler = nullptr;
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
emit displayLaunchError(e.toQString());
|
||||
QThreadPool::globalInstance()->start(new DeferredSessionCleanupTask(this));
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_assert(!SDL_WasInit(SDL_INIT_VIDEO));
|
||||
if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL_InitSubSystem(SDL_INIT_VIDEO) failed: %s",
|
||||
SDL_GetError());
|
||||
emit displayLaunchError(QString::fromLocal8Bit(SDL_GetError()));
|
||||
QThreadPool::globalInstance()->start(new DeferredSessionCleanupTask(this));
|
||||
return;
|
||||
}
|
||||
|
||||
QByteArray hostnameStr = m_Computer->activeAddress.toLatin1();
|
||||
QByteArray siAppVersion = m_Computer->appVersion.toLatin1();
|
||||
|
||||
@@ -865,6 +953,8 @@ void Session::exec(int displayOriginX, int displayOriginY)
|
||||
if (err != 0) {
|
||||
// We already displayed an error dialog in the stage failure
|
||||
// listener.
|
||||
delete m_InputHandler;
|
||||
m_InputHandler = nullptr;
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
QThreadPool::globalInstance()->start(new DeferredSessionCleanupTask(this));
|
||||
return;
|
||||
@@ -887,6 +977,8 @@ void Session::exec(int displayOriginX, int displayOriginY)
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL_CreateWindow() failed: %s",
|
||||
SDL_GetError());
|
||||
delete m_InputHandler;
|
||||
m_InputHandler = nullptr;
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
QThreadPool::globalInstance()->start(new DeferredSessionCleanupTask(this));
|
||||
return;
|
||||
@@ -958,14 +1050,6 @@ void Session::exec(int displayOriginX, int displayOriginY)
|
||||
// sleep precision and more accurate callback timing.
|
||||
SDL_SetHint(SDL_HINT_TIMER_RESOLUTION, "1");
|
||||
|
||||
// Raise the priority of the main thread, since it handles
|
||||
// time-sensitive video rendering
|
||||
if (SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH) < 0) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Unable to set main thread to high priority: %s",
|
||||
SDL_GetError());
|
||||
}
|
||||
|
||||
int currentDisplayIndex = SDL_GetWindowDisplayIndex(m_Window);
|
||||
|
||||
// Now that we're about to stream, any SDL_QUIT event is expected
|
||||
@@ -982,7 +1066,13 @@ void Session::exec(int displayOriginX, int displayOriginY)
|
||||
// blocks this thread too long for high polling rate mice and high
|
||||
// refresh rate displays.
|
||||
if (!SDL_PollEvent(&event)) {
|
||||
#ifndef STEAM_LINK
|
||||
SDL_Delay(1);
|
||||
#else
|
||||
// Waking every 1 ms to process input is too much for the low performance
|
||||
// ARM core in the Steam Link, so we will wait 10 ms instead.
|
||||
SDL_Delay(10);
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
switch (event.type) {
|
||||
@@ -990,25 +1080,11 @@ void Session::exec(int displayOriginX, int displayOriginY)
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Quit event received");
|
||||
goto DispatchDeferredCleanup;
|
||||
case SDL_USEREVENT: {
|
||||
SDL_Event nextEvent;
|
||||
|
||||
case SDL_USEREVENT:
|
||||
SDL_assert(event.user.code == SDL_CODE_FRAME_READY);
|
||||
|
||||
// Drop any earlier frames
|
||||
while (SDL_PeepEvents(&nextEvent,
|
||||
1,
|
||||
SDL_GETEVENT,
|
||||
SDL_USEREVENT,
|
||||
SDL_USEREVENT) == 1) {
|
||||
m_VideoDecoder->dropFrame(&event.user);
|
||||
event = nextEvent;
|
||||
}
|
||||
|
||||
// Render the last frame
|
||||
m_VideoDecoder->renderFrame(&event.user);
|
||||
m_VideoDecoder->renderFrameOnMainThread();
|
||||
break;
|
||||
}
|
||||
|
||||
case SDL_WINDOWEVENT:
|
||||
// Capture mouse cursor when user actives the window by clicking on
|
||||
@@ -1048,7 +1124,7 @@ void Session::exec(int displayOriginX, int displayOriginY)
|
||||
|
||||
// Raise all keys that are currently pressed. If we don't do this, certain keys
|
||||
// used in shortcuts that cause focus loss (such as Alt+Tab) may get stuck down.
|
||||
inputHandler.raiseAllKeys();
|
||||
m_InputHandler->raiseAllKeys();
|
||||
}
|
||||
|
||||
// We want to recreate the decoder for resizes (full-screen toggles) and the initial shown event.
|
||||
@@ -1120,6 +1196,8 @@ void Session::exec(int displayOriginX, int displayOriginY)
|
||||
m_Window, m_ActiveVideoFormat, m_ActiveVideoWidth,
|
||||
m_ActiveVideoHeight, m_ActiveVideoFrameRate,
|
||||
enableVsync,
|
||||
enableVsync && m_Preferences->framePacing,
|
||||
false,
|
||||
s_ActiveSession->m_VideoDecoder)) {
|
||||
SDL_AtomicUnlock(&m_DecoderLock);
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
@@ -1137,31 +1215,31 @@ void Session::exec(int displayOriginX, int displayOriginY)
|
||||
|
||||
case SDL_KEYUP:
|
||||
case SDL_KEYDOWN:
|
||||
inputHandler.handleKeyEvent(&event.key);
|
||||
m_InputHandler->handleKeyEvent(&event.key);
|
||||
break;
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
inputHandler.handleMouseButtonEvent(&event.button);
|
||||
m_InputHandler->handleMouseButtonEvent(&event.button);
|
||||
break;
|
||||
case SDL_MOUSEMOTION:
|
||||
inputHandler.handleMouseMotionEvent(&event.motion);
|
||||
m_InputHandler->handleMouseMotionEvent(&event.motion);
|
||||
break;
|
||||
case SDL_MOUSEWHEEL:
|
||||
inputHandler.handleMouseWheelEvent(&event.wheel);
|
||||
m_InputHandler->handleMouseWheelEvent(&event.wheel);
|
||||
break;
|
||||
case SDL_CONTROLLERAXISMOTION:
|
||||
inputHandler.handleControllerAxisEvent(&event.caxis);
|
||||
m_InputHandler->handleControllerAxisEvent(&event.caxis);
|
||||
break;
|
||||
case SDL_CONTROLLERBUTTONDOWN:
|
||||
case SDL_CONTROLLERBUTTONUP:
|
||||
inputHandler.handleControllerButtonEvent(&event.cbutton);
|
||||
m_InputHandler->handleControllerButtonEvent(&event.cbutton);
|
||||
break;
|
||||
case SDL_CONTROLLERDEVICEADDED:
|
||||
case SDL_CONTROLLERDEVICEREMOVED:
|
||||
inputHandler.handleControllerDeviceEvent(&event.cdevice);
|
||||
m_InputHandler->handleControllerDeviceEvent(&event.cdevice);
|
||||
break;
|
||||
case SDL_JOYDEVICEADDED:
|
||||
inputHandler.handleJoystickArrivalEvent(&event.jdevice);
|
||||
m_InputHandler->handleJoystickArrivalEvent(&event.jdevice);
|
||||
break;
|
||||
|
||||
// SDL2 sends touch events from trackpads by default on
|
||||
@@ -1171,7 +1249,7 @@ void Session::exec(int displayOriginX, int displayOriginY)
|
||||
case SDL_FINGERDOWN:
|
||||
case SDL_FINGERMOTION:
|
||||
case SDL_FINGERUP:
|
||||
inputHandler.handleTouchFingerEvent(&event.tfinger);
|
||||
m_InputHandler->handleTouchFingerEvent(&event.tfinger);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
@@ -1185,7 +1263,16 @@ DispatchDeferredCleanup:
|
||||
SDL_SetHint(SDL_HINT_TIMER_RESOLUTION, "0");
|
||||
|
||||
// Raise any keys that are still down
|
||||
inputHandler.raiseAllKeys();
|
||||
m_InputHandler->raiseAllKeys();
|
||||
|
||||
// Destroy the input handler now. Any rumble callbacks that
|
||||
// occur after this point will be discarded. This must be destroyed
|
||||
// before allow the UI to continue execution or it could interfere
|
||||
// with SDLGamepadKeyNavigation.
|
||||
SDL_AtomicLock(&m_InputHandlerLock);
|
||||
delete m_InputHandler;
|
||||
m_InputHandler = nullptr;
|
||||
SDL_AtomicUnlock(&m_InputHandlerLock);
|
||||
|
||||
// Destroy the decoder, since this must be done on the main thread
|
||||
SDL_AtomicLock(&m_DecoderLock);
|
||||
@@ -1200,8 +1287,8 @@ DispatchDeferredCleanup:
|
||||
if (iconSurface != nullptr) {
|
||||
SDL_FreeSurface(iconSurface);
|
||||
}
|
||||
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
SDL_assert(!SDL_WasInit(SDL_INIT_VIDEO));
|
||||
|
||||
// Cleanup can take a while, so dispatch it to a worker thread.
|
||||
// When it is complete, it will release our s_ActiveSessionSemaphore
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
|
||||
#include <Limelight.h>
|
||||
#include <opus_multistream.h>
|
||||
#include "backend/computermanager.h"
|
||||
#include "settings/streamingpreferences.h"
|
||||
#include "input.h"
|
||||
#include "video/decoder.h"
|
||||
#include "audio/renderers/renderer.h"
|
||||
#include "video/overlaymanager.h"
|
||||
|
||||
class Session : public QObject
|
||||
{
|
||||
@@ -25,12 +25,19 @@ public:
|
||||
Q_INVOKABLE void exec(int displayOriginX, int displayOriginY);
|
||||
|
||||
static
|
||||
bool isHardwareDecodeAvailable(StreamingPreferences::VideoDecoderSelection vds,
|
||||
bool isHardwareDecodeAvailable(SDL_Window* window,
|
||||
StreamingPreferences::VideoDecoderSelection vds,
|
||||
int videoFormat, int width, int height, int frameRate);
|
||||
|
||||
static
|
||||
int getDecoderCapabilities(StreamingPreferences::VideoDecoderSelection vds,
|
||||
int videoFormat, int width, int height, int frameRate);
|
||||
static Session* get()
|
||||
{
|
||||
return s_ActiveSession;
|
||||
}
|
||||
|
||||
Overlay::OverlayManager& getOverlayManager()
|
||||
{
|
||||
return m_OverlayManager;
|
||||
}
|
||||
|
||||
signals:
|
||||
void stageStarting(QString stage);
|
||||
@@ -48,13 +55,16 @@ signals:
|
||||
void sessionFinished();
|
||||
|
||||
private:
|
||||
void initialize();
|
||||
bool initialize();
|
||||
|
||||
bool validateLaunch();
|
||||
bool validateLaunch(SDL_Window* testWindow);
|
||||
|
||||
void emitLaunchWarning(QString text);
|
||||
|
||||
int getDecoderCapabilities();
|
||||
static
|
||||
int getDecoderCapabilities(SDL_Window* window,
|
||||
StreamingPreferences::VideoDecoderSelection vds,
|
||||
int videoFormat, int width, int height, int frameRate);
|
||||
|
||||
IAudioRenderer* createAudioRenderer();
|
||||
|
||||
@@ -67,12 +77,16 @@ private:
|
||||
|
||||
void toggleFullscreen();
|
||||
|
||||
void notifyMouseEmulationMode(bool enabled);
|
||||
|
||||
void updateOptimalWindowDisplayMode();
|
||||
|
||||
static
|
||||
bool chooseDecoder(StreamingPreferences::VideoDecoderSelection vds,
|
||||
SDL_Window* window, int videoFormat, int width, int height,
|
||||
int frameRate, bool enableVsync, IVideoDecoder*& chosenDecoder);
|
||||
int frameRate, bool enableVsync, bool enableFramePacing,
|
||||
bool testOnly,
|
||||
IVideoDecoder*& chosenDecoder);
|
||||
|
||||
static
|
||||
void clStageStarting(int stage);
|
||||
@@ -86,6 +100,12 @@ private:
|
||||
static
|
||||
void clLogMessage(const char* format, ...);
|
||||
|
||||
static
|
||||
void clRumble(unsigned short controllerNumber, unsigned short lowFreqMotor, unsigned short highFreqMotor);
|
||||
|
||||
static
|
||||
void clConnectionStatusUpdate(int connectionStatus);
|
||||
|
||||
static
|
||||
int arInit(int audioConfiguration,
|
||||
const POPUS_MULTISTREAM_CONFIGURATION opusConfig,
|
||||
@@ -121,6 +141,9 @@ private:
|
||||
int m_DisplayOriginY;
|
||||
bool m_PendingWindowedTransition;
|
||||
bool m_UnexpectedTermination;
|
||||
SdlInputHandler* m_InputHandler;
|
||||
SDL_SpinLock m_InputHandlerLock;
|
||||
int m_MouseEmulationRefCount;
|
||||
|
||||
int m_ActiveVideoFormat;
|
||||
int m_ActiveVideoWidth;
|
||||
@@ -128,10 +151,12 @@ private:
|
||||
int m_ActiveVideoFrameRate;
|
||||
|
||||
OpusMSDecoder* m_OpusDecoder;
|
||||
short m_OpusDecodeBuffer[MAX_CHANNELS * SAMPLES_PER_FRAME];
|
||||
IAudioRenderer* m_AudioRenderer;
|
||||
OPUS_MULTISTREAM_CONFIGURATION m_AudioConfig;
|
||||
int m_AudioSampleCount;
|
||||
Uint32 m_DropAudioEndTime;
|
||||
|
||||
Overlay::OverlayManager m_OverlayManager;
|
||||
|
||||
static AUDIO_RENDERER_CALLBACKS k_AudioCallbacks;
|
||||
static CONNECTION_LISTENER_CALLBACKS k_ConnCallbacks;
|
||||
|
||||
@@ -12,43 +12,38 @@ typedef struct _VIDEO_STATS {
|
||||
uint32_t receivedFrames;
|
||||
uint32_t decodedFrames;
|
||||
uint32_t renderedFrames;
|
||||
uint32_t totalFrames;
|
||||
uint32_t networkDroppedFrames;
|
||||
uint32_t pacerDroppedFrames;
|
||||
uint32_t totalReassemblyTime;
|
||||
uint32_t totalDecodeTime;
|
||||
uint32_t totalPacerTime;
|
||||
uint32_t totalRenderTime;
|
||||
float totalFps;
|
||||
float receivedFps;
|
||||
float decodedFps;
|
||||
float renderedFps;
|
||||
uint32_t measurementStartTimestamp;
|
||||
} VIDEO_STATS, *PVIDEO_STATS;
|
||||
|
||||
typedef struct _DECODER_PARAMETERS {
|
||||
SDL_Window* window;
|
||||
StreamingPreferences::VideoDecoderSelection vds;
|
||||
|
||||
int videoFormat;
|
||||
int width;
|
||||
int height;
|
||||
int frameRate;
|
||||
bool enableVsync;
|
||||
bool enableFramePacing;
|
||||
} DECODER_PARAMETERS, *PDECODER_PARAMETERS;
|
||||
|
||||
class IVideoDecoder {
|
||||
public:
|
||||
virtual ~IVideoDecoder() {}
|
||||
virtual bool initialize(StreamingPreferences::VideoDecoderSelection vds,
|
||||
SDL_Window* window,
|
||||
int videoFormat,
|
||||
int width,
|
||||
int height,
|
||||
int frameRate,
|
||||
bool enableVsync) = 0;
|
||||
virtual bool initialize(PDECODER_PARAMETERS params) = 0;
|
||||
virtual bool isHardwareAccelerated() = 0;
|
||||
virtual int getDecoderCapabilities() = 0;
|
||||
virtual int submitDecodeUnit(PDECODE_UNIT du) = 0;
|
||||
virtual void renderFrame(SDL_UserEvent* event) = 0;
|
||||
virtual void dropFrame(SDL_UserEvent* event) = 0;
|
||||
|
||||
virtual void queueFrame(void* data1 = nullptr,
|
||||
void* data2 = nullptr)
|
||||
{
|
||||
SDL_Event event;
|
||||
|
||||
event.type = SDL_USEREVENT;
|
||||
event.user.code = SDL_CODE_FRAME_READY;
|
||||
event.user.data1 = data1;
|
||||
event.user.data2 = data2;
|
||||
|
||||
SDL_PushEvent(&event);
|
||||
}
|
||||
virtual void renderFrameOnMainThread() = 0;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,268 @@
|
||||
#include "drm.h"
|
||||
|
||||
extern "C" {
|
||||
#include <libavutil/hwcontext_drm.h>
|
||||
}
|
||||
|
||||
#include <libdrm/drm_fourcc.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "streaming/streamutils.h"
|
||||
#include "streaming/session.h"
|
||||
|
||||
#include <Limelight.h>
|
||||
|
||||
DrmRenderer::DrmRenderer()
|
||||
: m_DrmFd(-1),
|
||||
m_CrtcId(0),
|
||||
m_PlaneId(0),
|
||||
m_CurrentFbId(0)
|
||||
{
|
||||
}
|
||||
|
||||
DrmRenderer::~DrmRenderer()
|
||||
{
|
||||
if (m_CurrentFbId != 0) {
|
||||
drmModeRmFB(m_DrmFd, m_CurrentFbId);
|
||||
}
|
||||
|
||||
if (m_DrmFd != -1) {
|
||||
close(m_DrmFd);
|
||||
}
|
||||
}
|
||||
|
||||
bool DrmRenderer::prepareDecoderContext(AVCodecContext*)
|
||||
{
|
||||
/* Nothing to do */
|
||||
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Using DRM renderer");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DrmRenderer::initialize(PDECODER_PARAMETERS)
|
||||
{
|
||||
const char* device = SDL_getenv("DRM_DEV");
|
||||
int i;
|
||||
|
||||
if (device == nullptr) {
|
||||
device = "/dev/dri/card0";
|
||||
}
|
||||
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Opening DRM device: %s",
|
||||
device);
|
||||
|
||||
m_DrmFd = open(device, O_RDWR | O_CLOEXEC);
|
||||
if (m_DrmFd < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Failed to open DRM device: %d",
|
||||
errno);
|
||||
return false;
|
||||
}
|
||||
|
||||
drmModeRes* resources = drmModeGetResources(m_DrmFd);
|
||||
if (resources == nullptr) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"drmModeGetResources() failed: %d",
|
||||
errno);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Look for a connected connector and get the associated encoder
|
||||
uint32_t encoderId = 0;
|
||||
for (i = 0; i < resources->count_connectors && encoderId == 0; i++) {
|
||||
drmModeConnector* connector = drmModeGetConnector(m_DrmFd, resources->connectors[i]);
|
||||
if (connector != nullptr) {
|
||||
if (connector->connection == DRM_MODE_CONNECTED && connector->count_modes > 0) {
|
||||
encoderId = connector->encoder_id;
|
||||
}
|
||||
|
||||
drmModeFreeConnector(connector);
|
||||
}
|
||||
}
|
||||
|
||||
if (encoderId == 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"No connected displays found!");
|
||||
drmModeFreeResources(resources);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Now find the CRTC from the encoder
|
||||
m_CrtcId = 0;
|
||||
for (i = 0; i < resources->count_encoders && m_CrtcId == 0; i++) {
|
||||
drmModeEncoder* encoder = drmModeGetEncoder(m_DrmFd, resources->encoders[i]);
|
||||
if (encoder != nullptr) {
|
||||
if (encoder->encoder_id == encoderId) {
|
||||
m_CrtcId = encoder->crtc_id;
|
||||
}
|
||||
|
||||
drmModeFreeEncoder(encoder);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_CrtcId == 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"DRM encoder not found!");
|
||||
drmModeFreeResources(resources);
|
||||
return false;
|
||||
}
|
||||
|
||||
int crtcIndex = -1;
|
||||
for (int i = 0; i < resources->count_crtcs; i++) {
|
||||
if (resources->crtcs[i] == m_CrtcId) {
|
||||
drmModeCrtc* crtc = drmModeGetCrtc(m_DrmFd, resources->crtcs[i]);
|
||||
crtcIndex = i;
|
||||
m_OutputRect.x = m_OutputRect.y = 0;
|
||||
m_OutputRect.w = crtc->width;
|
||||
m_OutputRect.h = crtc->height;
|
||||
drmModeFreeCrtc(crtc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
drmModeFreeResources(resources);
|
||||
|
||||
if (crtcIndex == -1) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Failed to get CRTC!");
|
||||
return false;
|
||||
}
|
||||
|
||||
drmSetClientCap(m_DrmFd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
|
||||
|
||||
drmModePlaneRes* planeRes = drmModeGetPlaneResources(m_DrmFd);
|
||||
if (planeRes == nullptr) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"drmGetPlaneResources() failed: %d",
|
||||
errno);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Find an NV12 overlay plane to render on
|
||||
m_PlaneId = 0;
|
||||
for (uint32_t i = 0; i < planeRes->count_planes && m_PlaneId == 0; i++) {
|
||||
drmModePlane* plane = drmModeGetPlane(m_DrmFd, planeRes->planes[i]);
|
||||
if (plane != nullptr) {
|
||||
bool matchingFormat = false;
|
||||
for (uint32_t j = 0; j < plane->count_formats; j++) {
|
||||
if (plane->formats[j] == DRM_FORMAT_NV12) {
|
||||
matchingFormat = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (matchingFormat == false) {
|
||||
drmModeFreePlane(plane);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((plane->possible_crtcs & (1 << crtcIndex)) && plane->crtc_id == 0) {
|
||||
drmModeObjectPropertiesPtr props = drmModeObjectGetProperties(m_DrmFd, planeRes->planes[i], DRM_MODE_OBJECT_PLANE);
|
||||
if (props != nullptr) {
|
||||
for (uint32_t j = 0; j < props->count_props && m_PlaneId == 0; j++) {
|
||||
drmModePropertyPtr prop = drmModeGetProperty(m_DrmFd, props->props[j]);
|
||||
if (prop != nullptr) {
|
||||
if (!strcmp(prop->name, "type") && props->prop_values[j] == DRM_PLANE_TYPE_OVERLAY) {
|
||||
m_PlaneId = plane->plane_id;
|
||||
}
|
||||
|
||||
drmModeFreeProperty(prop);
|
||||
}
|
||||
}
|
||||
|
||||
drmModeFreeObjectProperties(props);
|
||||
}
|
||||
}
|
||||
|
||||
drmModeFreePlane(plane);
|
||||
}
|
||||
}
|
||||
|
||||
drmModeFreePlaneResources(planeRes);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
enum AVPixelFormat DrmRenderer::getPreferredPixelFormat(int)
|
||||
{
|
||||
// DRM PRIME buffers
|
||||
return AV_PIX_FMT_DRM_PRIME;
|
||||
}
|
||||
|
||||
void DrmRenderer::renderFrame(AVFrame* frame)
|
||||
{
|
||||
AVDRMFrameDescriptor* drmFrame = (AVDRMFrameDescriptor*)frame->data[0];
|
||||
int err;
|
||||
uint32_t primeHandle;
|
||||
uint32_t handles[4] = {};
|
||||
uint32_t pitches[4] = {};
|
||||
uint32_t offsets[4] = {};
|
||||
|
||||
SDL_Rect src, dst;
|
||||
|
||||
src.x = src.y = 0;
|
||||
src.w = frame->width;
|
||||
src.h = frame->height;
|
||||
dst = m_OutputRect;
|
||||
|
||||
StreamUtils::scaleSourceToDestinationSurface(&src, &dst);
|
||||
|
||||
// Convert the FD in the AVDRMFrameDescriptor to a PRIME handle
|
||||
// that can be used in drmModeAddFB2()
|
||||
SDL_assert(drmFrame->nb_objects == 1);
|
||||
err = drmPrimeFDToHandle(m_DrmFd, drmFrame->objects[0].fd, &primeHandle);
|
||||
if (err < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"drmPrimeFDToHandle() failed: %d",
|
||||
errno);
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_assert(drmFrame->nb_layers == 1);
|
||||
SDL_assert(drmFrame->layers[0].nb_planes == 2);
|
||||
for (int i = 0; i < drmFrame->layers[0].nb_planes; i++) {
|
||||
handles[i] = primeHandle;
|
||||
pitches[i] = drmFrame->layers[0].planes[i].pitch;
|
||||
offsets[i] = drmFrame->layers[0].planes[i].offset;
|
||||
}
|
||||
|
||||
// Remember the last FB object we created so we can free it
|
||||
// when we are finished rendering this one (if successful).
|
||||
uint32_t lastFbId = m_CurrentFbId;
|
||||
|
||||
// Create a frame buffer object from the PRIME buffer
|
||||
err = drmModeAddFB2(m_DrmFd, frame->width, frame->height,
|
||||
drmFrame->layers[0].format,
|
||||
handles, pitches, offsets, &m_CurrentFbId, 0);
|
||||
if (err < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"drmModeAddFB2() failed: %d",
|
||||
errno);
|
||||
m_CurrentFbId = lastFbId;
|
||||
return;
|
||||
}
|
||||
|
||||
// Update the overlay
|
||||
err = drmModeSetPlane(m_DrmFd, m_PlaneId, m_CrtcId, m_CurrentFbId, 0,
|
||||
dst.x, dst.y,
|
||||
dst.w, dst.h,
|
||||
0, 0,
|
||||
frame->width << 16,
|
||||
frame->height << 16);
|
||||
if (err < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"drmModeSetPlane() failed: %d",
|
||||
errno);
|
||||
drmModeRmFB(m_DrmFd, m_CurrentFbId);
|
||||
m_CurrentFbId = lastFbId;
|
||||
return;
|
||||
}
|
||||
|
||||
// Free the previous FB object which has now been superseded
|
||||
drmModeRmFB(m_DrmFd, lastFbId);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "renderer.h"
|
||||
|
||||
#include <xf86drm.h>
|
||||
#include <xf86drmMode.h>
|
||||
|
||||
class DrmRenderer : public IFFmpegRenderer {
|
||||
public:
|
||||
DrmRenderer();
|
||||
virtual ~DrmRenderer() override;
|
||||
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
||||
virtual bool prepareDecoderContext(AVCodecContext* context) override;
|
||||
virtual void renderFrame(AVFrame* frame) override;
|
||||
virtual enum AVPixelFormat getPreferredPixelFormat(int videoFormat) override;
|
||||
|
||||
private:
|
||||
int m_DrmFd;
|
||||
uint32_t m_CrtcId;
|
||||
uint32_t m_PlaneId;
|
||||
uint32_t m_CurrentFbId;
|
||||
SDL_Rect m_OutputRect;
|
||||
};
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "dxva2.h"
|
||||
#include "../ffmpeg.h"
|
||||
#include <streaming/streamutils.h>
|
||||
#include <streaming/session.h>
|
||||
|
||||
#include <SDL_syswm.h>
|
||||
|
||||
@@ -25,7 +26,10 @@ DXVA2Renderer::DXVA2Renderer() :
|
||||
m_RenderTarget(nullptr),
|
||||
m_ProcService(nullptr),
|
||||
m_Processor(nullptr),
|
||||
m_FrameIndex(0)
|
||||
m_FrameIndex(0),
|
||||
m_DebugOverlayFont(nullptr),
|
||||
m_StatusOverlayFont(nullptr),
|
||||
m_BlockingPresent(false)
|
||||
{
|
||||
RtlZeroMemory(m_DecSurfaces, sizeof(m_DecSurfaces));
|
||||
RtlZeroMemory(&m_DXVAContext, sizeof(m_DXVAContext));
|
||||
@@ -44,6 +48,8 @@ DXVA2Renderer::~DXVA2Renderer()
|
||||
SAFE_COM_RELEASE(m_RenderTarget);
|
||||
SAFE_COM_RELEASE(m_ProcService);
|
||||
SAFE_COM_RELEASE(m_Processor);
|
||||
SAFE_COM_RELEASE(m_DebugOverlayFont);
|
||||
SAFE_COM_RELEASE(m_StatusOverlayFont);
|
||||
|
||||
for (int i = 0; i < ARRAYSIZE(m_DecSurfaces); i++) {
|
||||
SAFE_COM_RELEASE(m_DecSurfaces[i]);
|
||||
@@ -101,7 +107,7 @@ bool DXVA2Renderer::prepareDecoderContext(AVCodecContext* context)
|
||||
|
||||
int DXVA2Renderer::ffGetBuffer2(AVCodecContext* context, AVFrame* frame, int)
|
||||
{
|
||||
DXVA2Renderer* me = (DXVA2Renderer*)((FFmpegVideoDecoder*)context->opaque)->getRenderer();
|
||||
DXVA2Renderer* me = (DXVA2Renderer*)((FFmpegVideoDecoder*)context->opaque)->getBackendRenderer();
|
||||
|
||||
frame->buf[0] = av_buffer_pool_get(me->m_Pool);
|
||||
if (!frame->buf[0]) {
|
||||
@@ -256,68 +262,120 @@ bool DXVA2Renderer::initializeRenderer()
|
||||
m_DisplayWidth = renderTargetDesc.Width;
|
||||
m_DisplayHeight = renderTargetDesc.Height;
|
||||
|
||||
hr = DXVA2CreateVideoService(m_Device, IID_IDirectXVideoProcessorService,
|
||||
reinterpret_cast<void**>(&m_ProcService));
|
||||
if (!isDXVideoProcessorAPIBlacklisted()) {
|
||||
hr = DXVA2CreateVideoService(m_Device, IID_IDirectXVideoProcessorService,
|
||||
reinterpret_cast<void**>(&m_ProcService));
|
||||
|
||||
if (FAILED(hr)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"DXVA2CreateVideoService(IID_IDirectXVideoProcessorService) failed: %x",
|
||||
hr);
|
||||
return false;
|
||||
}
|
||||
if (FAILED(hr)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"DXVA2CreateVideoService(IID_IDirectXVideoProcessorService) failed: %x",
|
||||
hr);
|
||||
return false;
|
||||
}
|
||||
|
||||
DXVA2_VideoProcessorCaps caps;
|
||||
hr = m_ProcService->GetVideoProcessorCaps(DXVA2_VideoProcProgressiveDevice, &m_Desc, renderTargetDesc.Format, &caps);
|
||||
if (FAILED(hr)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"GetVideoProcessorCaps() failed for DXVA2_VideoProcProgressiveDevice: %x",
|
||||
hr);
|
||||
return false;
|
||||
}
|
||||
DXVA2_VideoProcessorCaps caps;
|
||||
hr = m_ProcService->GetVideoProcessorCaps(DXVA2_VideoProcProgressiveDevice, &m_Desc, renderTargetDesc.Format, &caps);
|
||||
if (FAILED(hr)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"GetVideoProcessorCaps() failed for DXVA2_VideoProcProgressiveDevice: %x",
|
||||
hr);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(caps.DeviceCaps & DXVA2_VPDev_HardwareDevice)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"DXVA2_VideoProcProgressiveDevice is not hardware: %x",
|
||||
caps.DeviceCaps);
|
||||
return false;
|
||||
}
|
||||
else if (!(caps.VideoProcessorOperations & DXVA2_VideoProcess_YUV2RGB) &&
|
||||
!(caps.VideoProcessorOperations & DXVA2_VideoProcess_YUV2RGBExtended)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"DXVA2_VideoProcProgressiveDevice can't convert YUV2RGB: %x",
|
||||
caps.VideoProcessorOperations);
|
||||
return false;
|
||||
}
|
||||
else if (!(caps.VideoProcessorOperations & DXVA2_VideoProcess_StretchX) ||
|
||||
!(caps.VideoProcessorOperations & DXVA2_VideoProcess_StretchY)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"DXVA2_VideoProcProgressiveDevice can't stretch video: %x",
|
||||
caps.VideoProcessorOperations);
|
||||
return false;
|
||||
}
|
||||
if (!(caps.DeviceCaps & DXVA2_VPDev_HardwareDevice)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"DXVA2_VideoProcProgressiveDevice is not hardware: %x",
|
||||
caps.DeviceCaps);
|
||||
return false;
|
||||
}
|
||||
else if (!(caps.VideoProcessorOperations & DXVA2_VideoProcess_YUV2RGB) &&
|
||||
!(caps.VideoProcessorOperations & DXVA2_VideoProcess_YUV2RGBExtended)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"DXVA2_VideoProcProgressiveDevice can't convert YUV2RGB: %x",
|
||||
caps.VideoProcessorOperations);
|
||||
return false;
|
||||
}
|
||||
else if (!(caps.VideoProcessorOperations & DXVA2_VideoProcess_StretchX) ||
|
||||
!(caps.VideoProcessorOperations & DXVA2_VideoProcess_StretchY)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"DXVA2_VideoProcProgressiveDevice can't stretch video: %x",
|
||||
caps.VideoProcessorOperations);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (caps.DeviceCaps & DXVA2_VPDev_EmulatedDXVA1) {
|
||||
// DXVA2 over DXVA1 may have bad performance
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"DXVA2_VideoProcProgressiveDevice is DXVA1");
|
||||
}
|
||||
if (caps.DeviceCaps & DXVA2_VPDev_EmulatedDXVA1) {
|
||||
// DXVA2 over DXVA1 may have bad performance
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"DXVA2_VideoProcProgressiveDevice is DXVA1");
|
||||
}
|
||||
|
||||
m_ProcService->GetProcAmpRange(DXVA2_VideoProcProgressiveDevice, &m_Desc, renderTargetDesc.Format, DXVA2_ProcAmp_Brightness, &m_BrightnessRange);
|
||||
m_ProcService->GetProcAmpRange(DXVA2_VideoProcProgressiveDevice, &m_Desc, renderTargetDesc.Format, DXVA2_ProcAmp_Contrast, &m_ContrastRange);
|
||||
m_ProcService->GetProcAmpRange(DXVA2_VideoProcProgressiveDevice, &m_Desc, renderTargetDesc.Format, DXVA2_ProcAmp_Hue, &m_HueRange);
|
||||
m_ProcService->GetProcAmpRange(DXVA2_VideoProcProgressiveDevice, &m_Desc, renderTargetDesc.Format, DXVA2_ProcAmp_Saturation, &m_SaturationRange);
|
||||
m_ProcService->GetProcAmpRange(DXVA2_VideoProcProgressiveDevice, &m_Desc, renderTargetDesc.Format, DXVA2_ProcAmp_Brightness, &m_BrightnessRange);
|
||||
m_ProcService->GetProcAmpRange(DXVA2_VideoProcProgressiveDevice, &m_Desc, renderTargetDesc.Format, DXVA2_ProcAmp_Contrast, &m_ContrastRange);
|
||||
m_ProcService->GetProcAmpRange(DXVA2_VideoProcProgressiveDevice, &m_Desc, renderTargetDesc.Format, DXVA2_ProcAmp_Hue, &m_HueRange);
|
||||
m_ProcService->GetProcAmpRange(DXVA2_VideoProcProgressiveDevice, &m_Desc, renderTargetDesc.Format, DXVA2_ProcAmp_Saturation, &m_SaturationRange);
|
||||
|
||||
hr = m_ProcService->CreateVideoProcessor(DXVA2_VideoProcProgressiveDevice, &m_Desc, renderTargetDesc.Format, 0, &m_Processor);
|
||||
if (FAILED(hr)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"CreateVideoProcessor() failed for DXVA2_VideoProcProgressiveDevice: %x",
|
||||
hr);
|
||||
return false;
|
||||
hr = m_ProcService->CreateVideoProcessor(DXVA2_VideoProcProgressiveDevice, &m_Desc, renderTargetDesc.Format, 0, &m_Processor);
|
||||
if (FAILED(hr)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"CreateVideoProcessor() failed for DXVA2_VideoProcProgressiveDevice: %x",
|
||||
hr);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DXVA2Renderer::isDXVideoProcessorAPIBlacklisted()
|
||||
{
|
||||
IDirect3D9* d3d9;
|
||||
HRESULT hr;
|
||||
bool result = false;
|
||||
|
||||
if (qgetenv("DXVA2_DISABLE_VIDPROC_BLACKLIST") == "1") {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"IDirectXVideoProcessor blacklist is disabled");
|
||||
return false;
|
||||
}
|
||||
|
||||
hr = m_Device->GetDirect3D(&d3d9);
|
||||
if (SUCCEEDED(hr)) {
|
||||
D3DCAPS9 caps;
|
||||
|
||||
hr = m_Device->GetDeviceCaps(&caps);
|
||||
if (SUCCEEDED(hr)) {
|
||||
D3DADAPTER_IDENTIFIER9 id;
|
||||
|
||||
hr = d3d9->GetAdapterIdentifier(caps.AdapterOrdinal, 0, &id);
|
||||
if (SUCCEEDED(hr) && id.VendorId == 0x8086) {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Avoiding IDirectXVideoProcessor API on Intel GPU");
|
||||
|
||||
// On Intel GPUs, we can get unwanted video "enhancements" due to post-processing
|
||||
// effects that the GPU driver forces on us. In many cases, this makes the video
|
||||
// actually look worse. We can avoid these by using StretchRect() instead on these
|
||||
// platforms.
|
||||
result = true;
|
||||
}
|
||||
else {
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"GetDeviceCaps() failed: %x", hr);
|
||||
}
|
||||
|
||||
d3d9->Release();
|
||||
}
|
||||
else {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"GetDirect3D() failed: %x", hr);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool DXVA2Renderer::isDecoderBlacklisted()
|
||||
{
|
||||
IDirect3D9* d3d9;
|
||||
@@ -327,6 +385,12 @@ bool DXVA2Renderer::isDecoderBlacklisted()
|
||||
// TODO: Update for HEVC Main10
|
||||
SDL_assert(m_VideoFormat != VIDEO_FORMAT_H265_MAIN10);
|
||||
|
||||
if (qgetenv("DXVA2_DISABLE_DECODER_BLACKLIST") == "1") {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"DXVA2 decoder blacklist is disabled");
|
||||
return false;
|
||||
}
|
||||
|
||||
hr = m_Device->GetDirect3D(&d3d9);
|
||||
if (SUCCEEDED(hr)) {
|
||||
D3DCAPS9 caps;
|
||||
@@ -512,6 +576,8 @@ bool DXVA2Renderer::initializeDevice(SDL_Window* window, bool enableVsync)
|
||||
d3dpp.BackBufferCount = 1;
|
||||
}
|
||||
|
||||
m_BlockingPresent = false;
|
||||
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Windowed mode with DWM running");
|
||||
}
|
||||
@@ -521,6 +587,7 @@ bool DXVA2Renderer::initializeDevice(SDL_Window* window, bool enableVsync)
|
||||
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
|
||||
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||
d3dpp.BackBufferCount = 1;
|
||||
m_BlockingPresent = true;
|
||||
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"V-Sync enabled");
|
||||
@@ -531,6 +598,7 @@ bool DXVA2Renderer::initializeDevice(SDL_Window* window, bool enableVsync)
|
||||
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
|
||||
d3dpp.BackBufferCount = 1;
|
||||
m_BlockingPresent = false;
|
||||
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"V-Sync disabled in tearing mode");
|
||||
@@ -581,19 +649,23 @@ bool DXVA2Renderer::initializeDevice(SDL_Window* window, bool enableVsync)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DXVA2Renderer::initialize(SDL_Window* window, int videoFormat, int width, int height, int, bool enableVsync)
|
||||
bool DXVA2Renderer::initialize(PDECODER_PARAMETERS params)
|
||||
{
|
||||
m_VideoFormat = videoFormat;
|
||||
m_VideoWidth = width;
|
||||
m_VideoHeight = height;
|
||||
m_VideoFormat = params->videoFormat;
|
||||
m_VideoWidth = params->width;
|
||||
m_VideoHeight = params->height;
|
||||
|
||||
RtlZeroMemory(&m_Desc, sizeof(m_Desc));
|
||||
|
||||
int alignment;
|
||||
|
||||
// HEVC using DXVA requires 128B alignment
|
||||
// HEVC using DXVA requires 128 pixel alignment, however Intel GPUs decoding HEVC
|
||||
// using StretchRect() to render draw a translucent green line at the top of
|
||||
// the screen in full-screen mode at 720p/1080p unless we use 32 pixel alignment.
|
||||
// This appears to work without issues on AMD and Nvidia GPUs too, so we will
|
||||
// do it unconditionally for now.
|
||||
if (m_VideoFormat & VIDEO_FORMAT_MASK_H265) {
|
||||
alignment = 128;
|
||||
alignment = 32;
|
||||
}
|
||||
else {
|
||||
alignment = 16;
|
||||
@@ -610,7 +682,7 @@ bool DXVA2Renderer::initialize(SDL_Window* window, int videoFormat, int width, i
|
||||
m_Desc.SampleFormat.SampleFormat = DXVA2_SampleProgressiveFrame;
|
||||
m_Desc.Format = (D3DFORMAT)MAKEFOURCC('N','V','1','2');
|
||||
|
||||
if (!initializeDevice(window, enableVsync)) {
|
||||
if (!initializeDevice(params->window, params->enableVsync)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -627,29 +699,70 @@ bool DXVA2Renderer::initialize(SDL_Window* window, int videoFormat, int width, i
|
||||
// input focus. This glitches out the renderer and a bunch of other stuff.
|
||||
// Direct3D9Ex itself seems to have this minimize on focus loss behavior on its
|
||||
// own, so just disable SDL's handling of the focus loss event.
|
||||
SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0");
|
||||
SDL_SetHintWithPriority(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0", SDL_HINT_OVERRIDE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DXVA2Renderer::needsTestFrame()
|
||||
void DXVA2Renderer::notifyOverlayUpdated(Overlay::OverlayType type)
|
||||
{
|
||||
// We validate the DXVA2 profiles are supported
|
||||
// in initialize() so no test frame is required
|
||||
return false;
|
||||
HRESULT hr;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case Overlay::OverlayDebug:
|
||||
if (m_DebugOverlayFont == nullptr) {
|
||||
hr = D3DXCreateFontA(m_Device,
|
||||
Session::get()->getOverlayManager().getOverlayFontSize(Overlay::OverlayDebug),
|
||||
0,
|
||||
FW_HEAVY,
|
||||
1,
|
||||
false,
|
||||
ANSI_CHARSET,
|
||||
OUT_DEFAULT_PRECIS,
|
||||
DEFAULT_QUALITY,
|
||||
DEFAULT_PITCH | FF_DONTCARE,
|
||||
"",
|
||||
&m_DebugOverlayFont);
|
||||
if (FAILED(hr)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"D3DXCreateFontA() failed: %x",
|
||||
hr);
|
||||
m_DebugOverlayFont = nullptr;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Overlay::OverlayStatusUpdate:
|
||||
if (m_StatusOverlayFont == nullptr) {
|
||||
hr = D3DXCreateFontA(m_Device,
|
||||
Session::get()->getOverlayManager().getOverlayFontSize(Overlay::OverlayStatusUpdate),
|
||||
0,
|
||||
FW_HEAVY,
|
||||
1,
|
||||
false,
|
||||
ANSI_CHARSET,
|
||||
OUT_DEFAULT_PRECIS,
|
||||
DEFAULT_QUALITY,
|
||||
DEFAULT_PITCH | FF_DONTCARE,
|
||||
"",
|
||||
&m_StatusOverlayFont);
|
||||
if (FAILED(hr)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"D3DXCreateFontA() failed: %x",
|
||||
hr);
|
||||
m_StatusOverlayFont = nullptr;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
SDL_assert(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int DXVA2Renderer::getDecoderCapabilities()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
IFFmpegRenderer::VSyncConstraint DXVA2Renderer::getVsyncConstraint()
|
||||
{
|
||||
return VSYNC_ANY;
|
||||
}
|
||||
|
||||
void DXVA2Renderer::renderFrameAtVsync(AVFrame *frame)
|
||||
void DXVA2Renderer::renderFrame(AVFrame *frame)
|
||||
{
|
||||
IDirect3DSurface9* surface = reinterpret_cast<IDirect3DSurface9*>(frame->data[3]);
|
||||
HRESULT hr;
|
||||
@@ -785,12 +898,10 @@ void DXVA2Renderer::renderFrameAtVsync(AVFrame *frame)
|
||||
|
||||
bltParams.Alpha = DXVA2_Fixed32OpaqueAlpha();
|
||||
|
||||
m_Device->Clear(0, nullptr, D3DCLEAR_TARGET, D3DCOLOR_ARGB(255, 0, 0, 0), 0.0f, 0);
|
||||
|
||||
hr = m_Processor->VideoProcessBlt(m_RenderTarget, &bltParams, &sample, 1, nullptr);
|
||||
hr = m_Device->Clear(0, nullptr, D3DCLEAR_TARGET, D3DCOLOR_ARGB(255, 0, 0, 0), 0.0f, 0);
|
||||
if (FAILED(hr)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"VideoProcessBlt() failed: %x",
|
||||
"Clear() failed: %x",
|
||||
hr);
|
||||
SDL_Event event;
|
||||
event.type = SDL_RENDER_TARGETS_RESET;
|
||||
@@ -798,7 +909,85 @@ void DXVA2Renderer::renderFrameAtVsync(AVFrame *frame)
|
||||
return;
|
||||
}
|
||||
|
||||
hr = m_Device->PresentEx(nullptr, nullptr, nullptr, nullptr, 0);
|
||||
hr = m_Device->BeginScene();
|
||||
if (FAILED(hr)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"BeginScene() failed: %x",
|
||||
hr);
|
||||
SDL_Event event;
|
||||
event.type = SDL_RENDER_TARGETS_RESET;
|
||||
SDL_PushEvent(&event);
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_Processor) {
|
||||
hr = m_Processor->VideoProcessBlt(m_RenderTarget, &bltParams, &sample, 1, nullptr);
|
||||
if (FAILED(hr)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"VideoProcessBlt() failed, falling back to StretchRect(): %x",
|
||||
hr);
|
||||
m_Processor->Release();
|
||||
m_Processor = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_Processor) {
|
||||
// This function doesn't trigger any of Intel's garbage video "enhancements"
|
||||
hr = m_Device->StretchRect(surface, &sample.SrcRect, m_RenderTarget, &sample.DstRect, D3DTEXF_NONE);
|
||||
if (FAILED(hr)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"StretchRect() failed: %x",
|
||||
hr);
|
||||
SDL_Event event;
|
||||
event.type = SDL_RENDER_TARGETS_RESET;
|
||||
SDL_PushEvent(&event);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_DebugOverlayFont != nullptr) {
|
||||
if (Session::get()->getOverlayManager().isOverlayEnabled(Overlay::OverlayDebug)) {
|
||||
SDL_Color color = Session::get()->getOverlayManager().getOverlayColor(Overlay::OverlayDebug);
|
||||
m_DebugOverlayFont->DrawTextA(nullptr,
|
||||
Session::get()->getOverlayManager().getOverlayText(Overlay::OverlayDebug),
|
||||
-1,
|
||||
&sample.DstRect,
|
||||
DT_LEFT | DT_NOCLIP,
|
||||
D3DCOLOR_ARGB(color.a, color.r, color.g, color.b));
|
||||
}
|
||||
}
|
||||
|
||||
if (m_StatusOverlayFont != nullptr) {
|
||||
if (Session::get()->getOverlayManager().isOverlayEnabled(Overlay::OverlayStatusUpdate)) {
|
||||
SDL_Color color = Session::get()->getOverlayManager().getOverlayColor(Overlay::OverlayStatusUpdate);
|
||||
m_StatusOverlayFont->DrawTextA(nullptr,
|
||||
Session::get()->getOverlayManager().getOverlayText(Overlay::OverlayStatusUpdate),
|
||||
-1,
|
||||
&sample.DstRect,
|
||||
DT_RIGHT | DT_NOCLIP,
|
||||
D3DCOLOR_ARGB(color.a, color.r, color.g, color.b));
|
||||
}
|
||||
}
|
||||
|
||||
hr = m_Device->EndScene();
|
||||
if (FAILED(hr)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"EndScene() failed: %x",
|
||||
hr);
|
||||
SDL_Event event;
|
||||
event.type = SDL_RENDER_TARGETS_RESET;
|
||||
SDL_PushEvent(&event);
|
||||
return;
|
||||
}
|
||||
|
||||
do {
|
||||
// Use D3DPRESENT_DONOTWAIT if present may block in order to avoid holding the giant
|
||||
// lock around this D3D device for excessive lengths of time (blocking concurrent decoding tasks).
|
||||
hr = m_Device->PresentEx(nullptr, nullptr, nullptr, nullptr, m_BlockingPresent ? D3DPRESENT_DONOTWAIT : 0);
|
||||
if (hr == D3DERR_WASSTILLDRAWING) {
|
||||
SDL_Delay(1);
|
||||
}
|
||||
} while (hr == D3DERR_WASSTILLDRAWING);
|
||||
if (FAILED(hr)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"PresentEx() failed: %x",
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "pacer/pacer.h"
|
||||
|
||||
#include <d3d9.h>
|
||||
#include <d3dx9.h>
|
||||
#include <dxva2api.h>
|
||||
|
||||
extern "C" {
|
||||
@@ -14,24 +15,18 @@ class DXVA2Renderer : public IFFmpegRenderer
|
||||
{
|
||||
public:
|
||||
DXVA2Renderer();
|
||||
virtual ~DXVA2Renderer();
|
||||
virtual bool initialize(SDL_Window* window,
|
||||
int videoFormat,
|
||||
int width,
|
||||
int height,
|
||||
int maxFps,
|
||||
bool enableVsync);
|
||||
virtual bool prepareDecoderContext(AVCodecContext* context);
|
||||
virtual void renderFrameAtVsync(AVFrame* frame);
|
||||
virtual bool needsTestFrame();
|
||||
virtual int getDecoderCapabilities();
|
||||
virtual VSyncConstraint getVsyncConstraint();
|
||||
virtual ~DXVA2Renderer() override;
|
||||
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
||||
virtual bool prepareDecoderContext(AVCodecContext* context) override;
|
||||
virtual void renderFrame(AVFrame* frame) override;
|
||||
virtual void notifyOverlayUpdated(Overlay::OverlayType) override;
|
||||
|
||||
private:
|
||||
bool initializeDecoder();
|
||||
bool initializeRenderer();
|
||||
bool initializeDevice(SDL_Window* window, bool enableVsync);
|
||||
bool isDecoderBlacklisted();
|
||||
bool isDXVideoProcessorAPIBlacklisted();
|
||||
|
||||
static
|
||||
AVBufferRef* ffPoolAlloc(void* opaque, int size);
|
||||
@@ -67,4 +62,7 @@ private:
|
||||
DXVA2_ValueRange m_SaturationRange;
|
||||
DXVA2_VideoDesc m_Desc;
|
||||
REFERENCE_TIME m_FrameIndex;
|
||||
LPD3DXFONT m_DebugOverlayFont;
|
||||
LPD3DXFONT m_StatusOverlayFont;
|
||||
bool m_BlockingPresent;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
#include "mmal.h"
|
||||
|
||||
#include "streaming/streamutils.h"
|
||||
#include "streaming/session.h"
|
||||
|
||||
#include <Limelight.h>
|
||||
|
||||
MmalRenderer::MmalRenderer()
|
||||
: m_Renderer(nullptr),
|
||||
m_InputPort(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
MmalRenderer::~MmalRenderer()
|
||||
{
|
||||
if (m_InputPort != nullptr) {
|
||||
mmal_port_disable(m_InputPort);
|
||||
}
|
||||
|
||||
if (m_Renderer != nullptr) {
|
||||
mmal_component_destroy(m_Renderer);
|
||||
}
|
||||
}
|
||||
|
||||
bool MmalRenderer::prepareDecoderContext(AVCodecContext*)
|
||||
{
|
||||
/* Nothing to do */
|
||||
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Using MMAL renderer");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MmalRenderer::initialize(PDECODER_PARAMETERS params)
|
||||
{
|
||||
MMAL_STATUS_T status;
|
||||
|
||||
status = mmal_component_create(MMAL_COMPONENT_DEFAULT_VIDEO_RENDERER, &m_Renderer);
|
||||
if (status != MMAL_SUCCESS) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"mmal_component_create() failed: %x (%s)",
|
||||
status, mmal_status_to_string(status));
|
||||
return false;
|
||||
}
|
||||
|
||||
m_InputPort = m_Renderer->input[0];
|
||||
|
||||
m_InputPort->format->encoding = MMAL_ENCODING_OPAQUE;
|
||||
m_InputPort->format->es->video.width = params->width;
|
||||
m_InputPort->format->es->video.height = params->height;
|
||||
m_InputPort->format->es->video.crop.x = 0;
|
||||
m_InputPort->format->es->video.crop.y = 0;
|
||||
m_InputPort->format->es->video.crop.width = params->width;
|
||||
m_InputPort->format->es->video.crop.height = params->height;
|
||||
status = mmal_port_format_commit(m_InputPort);
|
||||
if (status != MMAL_SUCCESS) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"mmal_port_format_commit() failed: %x (%s)",
|
||||
status, mmal_status_to_string(status));
|
||||
return false;
|
||||
}
|
||||
|
||||
status = mmal_component_enable(m_Renderer);
|
||||
if (status != MMAL_SUCCESS) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"mmal_component_enable() failed: %x (%s)",
|
||||
status, mmal_status_to_string(status));
|
||||
return false;
|
||||
}
|
||||
|
||||
{
|
||||
MMAL_DISPLAYREGION_T dr;
|
||||
|
||||
dr.hdr.id = MMAL_PARAMETER_DISPLAYREGION;
|
||||
dr.hdr.size = sizeof(MMAL_DISPLAYREGION_T);
|
||||
|
||||
dr.set = MMAL_DISPLAY_SET_LAYER;
|
||||
dr.layer = 128;
|
||||
|
||||
dr.set |= MMAL_DISPLAY_SET_ALPHA;
|
||||
dr.alpha = 255;
|
||||
|
||||
dr.set |= MMAL_DISPLAY_SET_FULLSCREEN;
|
||||
dr.fullscreen = (SDL_GetWindowFlags(params->window) & SDL_WINDOW_FULLSCREEN) != 0;
|
||||
|
||||
{
|
||||
SDL_Rect src, dst;
|
||||
src.x = src.y = 0;
|
||||
src.w = params->width;
|
||||
src.h = params->height;
|
||||
dst.x = dst.y = 0;
|
||||
SDL_GetWindowSize(params->window, &dst.w, &dst.h);
|
||||
|
||||
StreamUtils::scaleSourceToDestinationSurface(&src, &dst);
|
||||
|
||||
dr.set |= MMAL_DISPLAY_SET_DEST_RECT;
|
||||
dr.dest_rect.x = dst.x;
|
||||
dr.dest_rect.y = dst.y;
|
||||
dr.dest_rect.width = dst.w;
|
||||
dr.dest_rect.height = dst.h;
|
||||
}
|
||||
}
|
||||
|
||||
status = mmal_port_enable(m_InputPort, InputPortCallback);
|
||||
if (status != MMAL_SUCCESS) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"mmal_port_enable() failed: %x (%s)",
|
||||
status, mmal_status_to_string(status));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MmalRenderer::InputPortCallback(MMAL_PORT_T*, MMAL_BUFFER_HEADER_T* buffer)
|
||||
{
|
||||
mmal_buffer_header_release(buffer);
|
||||
}
|
||||
|
||||
enum AVPixelFormat MmalRenderer::getPreferredPixelFormat(int videoFormat)
|
||||
{
|
||||
// Opaque MMAL buffers
|
||||
SDL_assert(videoFormat == VIDEO_FORMAT_H264);
|
||||
return AV_PIX_FMT_MMAL;
|
||||
}
|
||||
|
||||
bool MmalRenderer::needsTestFrame()
|
||||
{
|
||||
// We won't be able to decode if the GPU memory is 64 MB or lower,
|
||||
// so we must test before allowing the decoder to be used.
|
||||
return true;
|
||||
}
|
||||
|
||||
void MmalRenderer::renderFrame(AVFrame* frame)
|
||||
{
|
||||
MMAL_BUFFER_HEADER_T* buffer = (MMAL_BUFFER_HEADER_T*)frame->data[3];
|
||||
MMAL_STATUS_T status;
|
||||
|
||||
status = mmal_port_send_buffer(m_InputPort, buffer);
|
||||
if (status != MMAL_SUCCESS) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"mmal_port_send_buffer() failed: %x (%s)",
|
||||
status, mmal_status_to_string(status));
|
||||
}
|
||||
else {
|
||||
// Prevent the buffer from being freed during av_frame_free()
|
||||
// until rendering is complete. The reference is dropped in
|
||||
// InputPortCallback().
|
||||
mmal_buffer_header_acquire(buffer);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include "renderer.h"
|
||||
|
||||
#include <interface/mmal/mmal.h>
|
||||
#include <interface/mmal/util/mmal_util.h>
|
||||
#include <interface/mmal/util/mmal_util_params.h>
|
||||
#include <interface/mmal/util/mmal_default_components.h>
|
||||
|
||||
class MmalRenderer : public IFFmpegRenderer {
|
||||
public:
|
||||
MmalRenderer();
|
||||
virtual ~MmalRenderer() override;
|
||||
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
||||
virtual bool prepareDecoderContext(AVCodecContext* context) override;
|
||||
virtual void renderFrame(AVFrame* frame) override;
|
||||
virtual enum AVPixelFormat getPreferredPixelFormat(int videoFormat) override;
|
||||
virtual bool needsTestFrame() override;
|
||||
|
||||
private:
|
||||
static void InputPortCallback(MMAL_PORT_T* port, MMAL_BUFFER_HEADER_T* buffer);
|
||||
|
||||
MMAL_COMPONENT_T* m_Renderer;
|
||||
MMAL_PORT_T* m_InputPort;
|
||||
};
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "pacer.h"
|
||||
|
||||
class DisplayLinkVsyncSourceFactory
|
||||
{
|
||||
public:
|
||||
static
|
||||
IVsyncSource* createVsyncSource(Pacer* pacer);
|
||||
};
|
||||
|
||||
@@ -1,132 +0,0 @@
|
||||
#include "displaylinkvsyncsource.h"
|
||||
|
||||
#include <SDL_syswm.h>
|
||||
|
||||
#include <CoreVideo/CoreVideo.h>
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
class DisplayLinkVsyncSource : public IVsyncSource
|
||||
{
|
||||
public:
|
||||
DisplayLinkVsyncSource(Pacer* pacer)
|
||||
: m_Pacer(pacer),
|
||||
m_DisplayLink(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
virtual ~DisplayLinkVsyncSource() override
|
||||
{
|
||||
if (m_DisplayLink != nullptr) {
|
||||
CVDisplayLinkStop(m_DisplayLink);
|
||||
CVDisplayLinkRelease(m_DisplayLink);
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
CGDirectDisplayID
|
||||
getDisplayID(NSScreen* screen)
|
||||
{
|
||||
NSNumber* screenNumber = [screen deviceDescription][@"NSScreenNumber"];
|
||||
return [screenNumber unsignedIntValue];
|
||||
}
|
||||
|
||||
static
|
||||
CVReturn
|
||||
displayLinkOutputCallback(
|
||||
CVDisplayLinkRef displayLink,
|
||||
const CVTimeStamp* /* now */,
|
||||
const CVTimeStamp* /* vsyncTime */,
|
||||
CVOptionFlags,
|
||||
CVOptionFlags*,
|
||||
void *displayLinkContext)
|
||||
{
|
||||
auto me = reinterpret_cast<DisplayLinkVsyncSource*>(displayLinkContext);
|
||||
|
||||
SDL_assert(displayLink == me->m_DisplayLink);
|
||||
|
||||
// In my testing on macOS 10.13, this callback is invoked about 24 ms
|
||||
// prior to the specified v-sync time (now - vsyncTime). Since this is
|
||||
// greater than the standard v-sync interval (16 ms = 60 FPS), we will
|
||||
// draw using the current host time, rather than the actual v-sync target
|
||||
// time. Because the CVDisplayLink is in sync with the actual v-sync
|
||||
// interval, even if many ms prior, we can safely use the current host time
|
||||
// and get a consistent callback for each v-sync. This reduces video latency
|
||||
// by at least 1 frame vs. rendering with the actual vsyncTime.
|
||||
me->m_Pacer->vsyncCallback(500 / me->m_DisplayFps);
|
||||
|
||||
return kCVReturnSuccess;
|
||||
}
|
||||
|
||||
virtual bool initialize(SDL_Window* window, int displayFps) override
|
||||
{
|
||||
SDL_SysWMinfo info;
|
||||
|
||||
SDL_VERSION(&info.version);
|
||||
|
||||
if (!SDL_GetWindowWMInfo(window, &info)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL_GetWindowWMInfo() failed: %s",
|
||||
SDL_GetError());
|
||||
return false;
|
||||
}
|
||||
|
||||
SDL_assert(info.subsystem == SDL_SYSWM_COCOA);
|
||||
|
||||
m_DisplayFps = displayFps;
|
||||
|
||||
NSScreen* screen = [info.info.cocoa.window screen];
|
||||
CVReturn status;
|
||||
if (screen == nullptr) {
|
||||
// Window not visible on any display, so use a
|
||||
// CVDisplayLink that can work with all active displays.
|
||||
// When we become visible, we'll recreate ourselves
|
||||
// and associate with the new screen.
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"NSWindow is not visible on any display");
|
||||
status = CVDisplayLinkCreateWithActiveCGDisplays(&m_DisplayLink);
|
||||
}
|
||||
else {
|
||||
CGDirectDisplayID displayId;
|
||||
displayId = getDisplayID(screen);
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"NSWindow on display: %x",
|
||||
displayId);
|
||||
status = CVDisplayLinkCreateWithCGDisplay(displayId, &m_DisplayLink);
|
||||
}
|
||||
if (status != kCVReturnSuccess) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Failed to create CVDisplayLink: %d",
|
||||
status);
|
||||
return false;
|
||||
}
|
||||
|
||||
status = CVDisplayLinkSetOutputCallback(m_DisplayLink, displayLinkOutputCallback, this);
|
||||
if (status != kCVReturnSuccess) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"CVDisplayLinkSetOutputCallback() failed: %d",
|
||||
status);
|
||||
return false;
|
||||
}
|
||||
|
||||
status = CVDisplayLinkStart(m_DisplayLink);
|
||||
if (status != kCVReturnSuccess) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"CVDisplayLinkStart() failed: %d",
|
||||
status);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
Pacer* m_Pacer;
|
||||
CVDisplayLinkRef m_DisplayLink;
|
||||
int m_DisplayFps;
|
||||
};
|
||||
|
||||
IVsyncSource* DisplayLinkVsyncSourceFactory::createVsyncSource(Pacer* pacer) {
|
||||
return new DisplayLinkVsyncSource(pacer);
|
||||
}
|
||||
@@ -61,7 +61,7 @@ bool DxVsyncSource::initialize(SDL_Window* window, int displayFps)
|
||||
|
||||
m_Window = info.info.win.window;
|
||||
|
||||
m_Thread = SDL_CreateThread(vsyncThread, "DX Vsync Thread", this);
|
||||
m_Thread = SDL_CreateThread(vsyncThread, "DXVsync", this);
|
||||
if (m_Thread == nullptr) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Unable to create DX V-sync thread: %s",
|
||||
@@ -76,7 +76,11 @@ int DxVsyncSource::vsyncThread(void* context)
|
||||
{
|
||||
DxVsyncSource* me = reinterpret_cast<DxVsyncSource*>(context);
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 9)
|
||||
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_TIME_CRITICAL);
|
||||
#else
|
||||
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
|
||||
#endif
|
||||
|
||||
D3DKMT_OPENADAPTERFROMHDC openAdapterParams = {};
|
||||
HMONITOR lastMonitor = nullptr;
|
||||
|
||||
@@ -18,7 +18,7 @@ NullThreadedVsyncSource::~NullThreadedVsyncSource()
|
||||
bool NullThreadedVsyncSource::initialize(SDL_Window*, int displayFps)
|
||||
{
|
||||
m_DisplayFps = displayFps;
|
||||
m_Thread = SDL_CreateThread(vsyncThread, "Null Vsync Thread", this);
|
||||
m_Thread = SDL_CreateThread(vsyncThread, "NullVsync", this);
|
||||
if (m_Thread == nullptr) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Unable to create DX V-sync thread: %s",
|
||||
@@ -33,7 +33,11 @@ int NullThreadedVsyncSource::vsyncThread(void* context)
|
||||
{
|
||||
NullThreadedVsyncSource* me = reinterpret_cast<NullThreadedVsyncSource*>(context);
|
||||
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 9)
|
||||
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_TIME_CRITICAL);
|
||||
#else
|
||||
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
|
||||
#endif
|
||||
|
||||
while (SDL_AtomicGet(&me->m_Stopping) == 0) {
|
||||
me->m_Pacer->vsyncCallback(1000 / me->m_DisplayFps);
|
||||
|
||||
@@ -3,15 +3,16 @@
|
||||
|
||||
#include "nullthreadedvsyncsource.h"
|
||||
|
||||
#ifdef Q_OS_DARWIN
|
||||
#include "displaylinkvsyncsource.h"
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
#include <VersionHelpers.h>
|
||||
#include "dxvsyncsource.h"
|
||||
#endif
|
||||
|
||||
#define FRAME_HISTORY_ENTRIES 8
|
||||
// Limit the number of queued frames to prevent excessive memory consumption
|
||||
// if the V-Sync source or renderer is blocked for a while.
|
||||
#define MAX_QUEUED_FRAMES 8
|
||||
|
||||
// We may be woken up slightly late so don't go all the way
|
||||
// up to the next V-sync since we may accidentally step into
|
||||
@@ -21,7 +22,8 @@
|
||||
#define TIMER_SLACK_MS 3
|
||||
|
||||
Pacer::Pacer(IFFmpegRenderer* renderer, PVIDEO_STATS videoStats) :
|
||||
m_FrameQueueLock(0),
|
||||
m_RenderThread(nullptr),
|
||||
m_Stopping(false),
|
||||
m_VsyncSource(nullptr),
|
||||
m_VsyncRenderer(renderer),
|
||||
m_MaxVideoFps(0),
|
||||
@@ -37,10 +39,121 @@ Pacer::~Pacer()
|
||||
delete m_VsyncSource;
|
||||
m_VsyncSource = nullptr;
|
||||
|
||||
while (!m_FrameQueue.isEmpty()) {
|
||||
AVFrame* frame = m_FrameQueue.dequeue();
|
||||
// Stop the render thread
|
||||
m_Stopping = true;
|
||||
if (m_RenderThread != nullptr) {
|
||||
m_RenderQueueNotEmpty.wakeAll();
|
||||
SDL_WaitThread(m_RenderThread, nullptr);
|
||||
}
|
||||
|
||||
// Delete any remaining unconsumed frames
|
||||
while (!m_RenderQueue.isEmpty()) {
|
||||
AVFrame* frame = m_RenderQueue.dequeue();
|
||||
av_frame_free(&frame);
|
||||
}
|
||||
while (!m_PacingQueue.isEmpty()) {
|
||||
AVFrame* frame = m_PacingQueue.dequeue();
|
||||
av_frame_free(&frame);
|
||||
}
|
||||
}
|
||||
|
||||
void Pacer::renderOnMainThread()
|
||||
{
|
||||
// Ignore this call for renderers that work on a dedicated render thread
|
||||
if (m_RenderThread != nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_FrameQueueLock.lock();
|
||||
|
||||
if (!m_RenderQueue.isEmpty()) {
|
||||
// Releases m_FrameQueueLock
|
||||
renderLastFrameAndUnlock();
|
||||
}
|
||||
else {
|
||||
m_FrameQueueLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
int Pacer::renderThread(void* context)
|
||||
{
|
||||
Pacer* me = reinterpret_cast<Pacer*>(context);
|
||||
|
||||
if (SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH) < 0) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Unable to set render thread to high priority: %s",
|
||||
SDL_GetError());
|
||||
}
|
||||
|
||||
while (!me->m_Stopping) {
|
||||
// Acquire the frame queue lock to protect the queue and
|
||||
// the not empty condition
|
||||
me->m_FrameQueueLock.lock();
|
||||
|
||||
// Wait for a frame to be ready to render
|
||||
while (!me->m_Stopping && me->m_RenderQueue.isEmpty()) {
|
||||
me->m_RenderQueueNotEmpty.wait(&me->m_FrameQueueLock);
|
||||
}
|
||||
|
||||
if (me->m_Stopping) {
|
||||
// Exit this thread
|
||||
me->m_FrameQueueLock.unlock();
|
||||
break;
|
||||
}
|
||||
|
||||
// Render the latest frame and discard the others
|
||||
// NB: m_FrameQueueLock still held here!
|
||||
me->renderLastFrameAndUnlock();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Pacer::enqueueFrameForRenderingAndUnlock(AVFrame *frame)
|
||||
{
|
||||
dropFrameForEnqueue(m_RenderQueue);
|
||||
m_RenderQueue.enqueue(frame);
|
||||
|
||||
m_FrameQueueLock.unlock();
|
||||
|
||||
if (m_RenderThread != nullptr) {
|
||||
m_RenderQueueNotEmpty.wakeOne();
|
||||
}
|
||||
else {
|
||||
SDL_Event event;
|
||||
|
||||
// For main thread rendering, we'll push an event to trigger a callback
|
||||
event.type = SDL_USEREVENT;
|
||||
event.user.code = SDL_CODE_FRAME_READY;
|
||||
SDL_PushEvent(&event);
|
||||
}
|
||||
}
|
||||
|
||||
// Caller must hold m_FrameQueueLock
|
||||
void Pacer::renderLastFrameAndUnlock()
|
||||
{
|
||||
// Dequeue the most recent frame for rendering and free the others.
|
||||
AVFrame* lastFrame = nullptr;
|
||||
while (!m_RenderQueue.isEmpty()) {
|
||||
if (lastFrame != nullptr) {
|
||||
// Don't hold the frame queue lock across av_frame_free(),
|
||||
// since it could need to talk to the GPU driver. This is safe
|
||||
// because we're guaranteed that the queue will not shrink during
|
||||
// this time (and so dequeue() below will always get something).
|
||||
m_FrameQueueLock.unlock();
|
||||
av_frame_free(&lastFrame);
|
||||
m_VideoStats->pacerDroppedFrames++;
|
||||
m_FrameQueueLock.lock();
|
||||
}
|
||||
|
||||
lastFrame = m_RenderQueue.dequeue();
|
||||
}
|
||||
|
||||
// Release the frame queue lock before rendering
|
||||
m_FrameQueueLock.unlock();
|
||||
|
||||
// Render and free the mot current frame
|
||||
renderFrame(lastFrame);
|
||||
}
|
||||
|
||||
// Called in an arbitrary thread by the IVsyncSource on V-sync
|
||||
@@ -52,9 +165,7 @@ void Pacer::vsyncCallback(int timeUntilNextVsyncMillis)
|
||||
|
||||
SDL_assert(timeUntilNextVsyncMillis >= TIMER_SLACK_MS);
|
||||
|
||||
Uint32 vsyncCallbackStartTime = SDL_GetTicks();
|
||||
|
||||
SDL_AtomicLock(&m_FrameQueueLock);
|
||||
m_FrameQueueLock.lock();
|
||||
|
||||
// If the queue length history entries are large, be strict
|
||||
// about dropping excess frames.
|
||||
@@ -64,8 +175,8 @@ void Pacer::vsyncCallback(int timeUntilNextVsyncMillis)
|
||||
// frame history to drop frames only if consistently above the
|
||||
// one queued frame mark.
|
||||
if (m_MaxVideoFps >= m_DisplayFps) {
|
||||
for (int i = 0; i < m_FrameQueueHistory.count(); i++) {
|
||||
if (m_FrameQueueHistory[i] <= 1) {
|
||||
for (int queueHistoryEntry : m_PacingQueueHistory) {
|
||||
if (queueHistoryEntry <= 1) {
|
||||
// Be lenient as long as the queue length
|
||||
// resolves before the end of frame history
|
||||
frameDropTarget = 3;
|
||||
@@ -73,70 +184,54 @@ void Pacer::vsyncCallback(int timeUntilNextVsyncMillis)
|
||||
}
|
||||
}
|
||||
|
||||
if (m_FrameQueueHistory.count() == FRAME_HISTORY_ENTRIES) {
|
||||
m_FrameQueueHistory.dequeue();
|
||||
// Keep a rolling 500 ms window of pacing queue history
|
||||
if (m_PacingQueueHistory.count() == m_DisplayFps / 2) {
|
||||
m_PacingQueueHistory.dequeue();
|
||||
}
|
||||
|
||||
m_FrameQueueHistory.enqueue(m_FrameQueue.count());
|
||||
m_PacingQueueHistory.enqueue(m_PacingQueue.count());
|
||||
}
|
||||
|
||||
// Catch up if we're several frames ahead
|
||||
while (m_FrameQueue.count() > frameDropTarget) {
|
||||
AVFrame* frame = m_FrameQueue.dequeue();
|
||||
while (m_PacingQueue.count() > frameDropTarget) {
|
||||
AVFrame* frame = m_PacingQueue.dequeue();
|
||||
|
||||
// Drop the lock while we call av_frame_free()
|
||||
m_FrameQueueLock.unlock();
|
||||
m_VideoStats->pacerDroppedFrames++;
|
||||
av_frame_free(&frame);
|
||||
m_FrameQueueLock.lock();
|
||||
}
|
||||
|
||||
|
||||
if (m_FrameQueue.isEmpty()) {
|
||||
SDL_AtomicUnlock(&m_FrameQueueLock);
|
||||
|
||||
while (!SDL_TICKS_PASSED(SDL_GetTicks(),
|
||||
vsyncCallbackStartTime + timeUntilNextVsyncMillis - TIMER_SLACK_MS)) {
|
||||
SDL_Delay(1);
|
||||
|
||||
SDL_AtomicLock(&m_FrameQueueLock);
|
||||
if (!m_FrameQueue.isEmpty()) {
|
||||
// Don't release the lock
|
||||
goto RenderNextFrame;
|
||||
}
|
||||
SDL_AtomicUnlock(&m_FrameQueueLock);
|
||||
if (m_PacingQueue.isEmpty()) {
|
||||
// Wait for a frame to arrive or our V-sync timeout to expire
|
||||
if (!m_PacingQueueNotEmpty.wait(&m_FrameQueueLock, timeUntilNextVsyncMillis - TIMER_SLACK_MS)) {
|
||||
// Wait timed out - unlock and bail
|
||||
m_FrameQueueLock.unlock();
|
||||
return;
|
||||
}
|
||||
|
||||
// Nothing to render at this time
|
||||
return;
|
||||
}
|
||||
|
||||
RenderNextFrame:
|
||||
// Grab the first frame
|
||||
AVFrame* frame = m_FrameQueue.dequeue();
|
||||
SDL_AtomicUnlock(&m_FrameQueueLock);
|
||||
|
||||
// Render it
|
||||
Uint32 beforeRender = SDL_GetTicks();
|
||||
m_VsyncRenderer->renderFrameAtVsync(frame);
|
||||
m_VideoStats->totalRenderTime += SDL_GetTicks() - beforeRender;
|
||||
m_VideoStats->renderedFrames++;
|
||||
|
||||
// Free the frame
|
||||
av_frame_free(&frame);
|
||||
// Place the first frame on the render queue
|
||||
enqueueFrameForRenderingAndUnlock(m_PacingQueue.dequeue());
|
||||
}
|
||||
|
||||
bool Pacer::initialize(SDL_Window* window, int maxVideoFps, bool enableVsync)
|
||||
bool Pacer::initialize(SDL_Window* window, int maxVideoFps, bool enablePacing)
|
||||
{
|
||||
m_MaxVideoFps = maxVideoFps;
|
||||
m_EnableVsync = enableVsync;
|
||||
m_DisplayFps = StreamUtils::getDisplayRefreshRate(window);
|
||||
|
||||
if (m_EnableVsync) {
|
||||
if (enablePacing) {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Frame pacing in tear-free mode: target %d Hz with %d FPS stream",
|
||||
"Frame pacing active: target %d Hz with %d FPS stream",
|
||||
m_DisplayFps, m_MaxVideoFps);
|
||||
|
||||
#if defined(Q_OS_DARWIN)
|
||||
m_VsyncSource = DisplayLinkVsyncSourceFactory::createVsyncSource(this);
|
||||
#elif defined(Q_OS_WIN32)
|
||||
m_VsyncSource = new DxVsyncSource(this);
|
||||
#if defined(Q_OS_WIN32)
|
||||
// Don't use D3DKMTWaitForVerticalBlankEvent() on Windows 7, because
|
||||
// it blocks during other concurrent DX operations (like actually rendering).
|
||||
if (IsWindows8OrGreater()) {
|
||||
m_VsyncSource = new DxVsyncSource(this);
|
||||
}
|
||||
#else
|
||||
// Platforms without a VsyncSource will just render frames
|
||||
// immediately like they used to.
|
||||
@@ -148,36 +243,88 @@ bool Pacer::initialize(SDL_Window* window, int maxVideoFps, bool enableVsync)
|
||||
}
|
||||
else {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Minimal latency tearing mode: target %d Hz with %d FPS stream",
|
||||
"Frame pacing disabled: target %d Hz with %d FPS stream",
|
||||
m_DisplayFps, m_MaxVideoFps);
|
||||
}
|
||||
|
||||
if (m_VsyncRenderer->isRenderThreadSupported()) {
|
||||
m_RenderThread = SDL_CreateThread(Pacer::renderThread, "PacerRender", this);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Pacer::renderFrame(AVFrame* frame)
|
||||
{
|
||||
// Count time spent in Pacer's queues
|
||||
Uint32 beforeRender = SDL_GetTicks();
|
||||
m_VideoStats->totalPacerTime += beforeRender - frame->pts;
|
||||
|
||||
// Render it
|
||||
m_VsyncRenderer->renderFrame(frame);
|
||||
Uint32 afterRender = SDL_GetTicks();
|
||||
|
||||
m_VideoStats->totalRenderTime += afterRender - beforeRender;
|
||||
m_VideoStats->renderedFrames++;
|
||||
av_frame_free(&frame);
|
||||
|
||||
// Drop frames if we have too many queued up for a while
|
||||
m_FrameQueueLock.lock();
|
||||
|
||||
int frameDropTarget = 0;
|
||||
for (int queueHistoryEntry : m_RenderQueueHistory) {
|
||||
if (queueHistoryEntry == 0) {
|
||||
// Be lenient as long as the queue length
|
||||
// resolves before the end of frame history
|
||||
frameDropTarget = 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Keep a rolling 500 ms window of render queue history
|
||||
if (m_RenderQueueHistory.count() == m_MaxVideoFps / 2) {
|
||||
m_RenderQueueHistory.dequeue();
|
||||
}
|
||||
|
||||
m_RenderQueueHistory.enqueue(m_RenderQueue.count());
|
||||
|
||||
// Catch up if we're several frames ahead
|
||||
while (m_RenderQueue.count() > frameDropTarget) {
|
||||
AVFrame* frame = m_RenderQueue.dequeue();
|
||||
|
||||
// Drop the lock while we call av_frame_free()
|
||||
m_FrameQueueLock.unlock();
|
||||
m_VideoStats->pacerDroppedFrames++;
|
||||
av_frame_free(&frame);
|
||||
m_FrameQueueLock.lock();
|
||||
}
|
||||
|
||||
m_FrameQueueLock.unlock();
|
||||
}
|
||||
|
||||
void Pacer::dropFrameForEnqueue(QQueue<AVFrame*>& queue)
|
||||
{
|
||||
SDL_assert(queue.size() <= MAX_QUEUED_FRAMES);
|
||||
if (queue.size() == MAX_QUEUED_FRAMES) {
|
||||
AVFrame* frame = queue.dequeue();
|
||||
av_frame_free(&frame);
|
||||
}
|
||||
}
|
||||
|
||||
void Pacer::submitFrame(AVFrame* frame)
|
||||
{
|
||||
// Make sure initialize() has been called
|
||||
SDL_assert(m_MaxVideoFps != 0);
|
||||
|
||||
// Queue the frame until the V-sync callback if
|
||||
// we have a V-sync source, otherwise deliver it
|
||||
// immediately and hope for the best.
|
||||
if (isUsingFrameQueue()) {
|
||||
SDL_AtomicLock(&m_FrameQueueLock);
|
||||
m_FrameQueue.enqueue(frame);
|
||||
SDL_AtomicUnlock(&m_FrameQueueLock);
|
||||
// Queue the frame and possibly wake up the render thread
|
||||
m_FrameQueueLock.lock();
|
||||
if (m_VsyncSource != nullptr) {
|
||||
dropFrameForEnqueue(m_PacingQueue);
|
||||
m_PacingQueue.enqueue(frame);
|
||||
m_FrameQueueLock.unlock();
|
||||
m_PacingQueueNotEmpty.wakeOne();
|
||||
}
|
||||
else {
|
||||
Uint32 beforeRender = SDL_GetTicks();
|
||||
m_VsyncRenderer->renderFrameAtVsync(frame);
|
||||
m_VideoStats->totalRenderTime += SDL_GetTicks() - beforeRender;
|
||||
m_VideoStats->renderedFrames++;
|
||||
av_frame_free(&frame);
|
||||
enqueueFrameForRenderingAndUnlock(frame);
|
||||
}
|
||||
}
|
||||
|
||||
bool Pacer::isUsingFrameQueue()
|
||||
{
|
||||
return m_VsyncSource != nullptr;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include "../renderer.h"
|
||||
|
||||
#include <QQueue>
|
||||
#include <QMutex>
|
||||
#include <QWaitCondition>
|
||||
|
||||
class IVsyncSource {
|
||||
public:
|
||||
@@ -20,21 +22,36 @@ public:
|
||||
|
||||
void submitFrame(AVFrame* frame);
|
||||
|
||||
bool initialize(SDL_Window* window, int maxVideoFps, bool enableVsync);
|
||||
bool initialize(SDL_Window* window, int maxVideoFps, bool enablePacing);
|
||||
|
||||
void vsyncCallback(int timeUntilNextVsyncMillis);
|
||||
|
||||
bool isUsingFrameQueue();
|
||||
void renderOnMainThread();
|
||||
|
||||
private:
|
||||
QQueue<AVFrame*> m_FrameQueue;
|
||||
QQueue<int> m_FrameQueueHistory;
|
||||
SDL_SpinLock m_FrameQueueLock;
|
||||
static int renderThread(void* context);
|
||||
|
||||
void enqueueFrameForRenderingAndUnlock(AVFrame* frame);
|
||||
|
||||
void renderLastFrameAndUnlock();
|
||||
|
||||
void renderFrame(AVFrame* frame);
|
||||
|
||||
void dropFrameForEnqueue(QQueue<AVFrame*>& queue);
|
||||
|
||||
QQueue<AVFrame*> m_RenderQueue;
|
||||
QQueue<AVFrame*> m_PacingQueue;
|
||||
QQueue<int> m_PacingQueueHistory;
|
||||
QQueue<int> m_RenderQueueHistory;
|
||||
QMutex m_FrameQueueLock;
|
||||
QWaitCondition m_RenderQueueNotEmpty;
|
||||
QWaitCondition m_PacingQueueNotEmpty;
|
||||
SDL_Thread* m_RenderThread;
|
||||
bool m_Stopping;
|
||||
|
||||
IVsyncSource* m_VsyncSource;
|
||||
IFFmpegRenderer* m_VsyncRenderer;
|
||||
int m_MaxVideoFps;
|
||||
int m_DisplayFps;
|
||||
bool m_EnableVsync;
|
||||
PVIDEO_STATS m_VideoStats;
|
||||
};
|
||||
|
||||
@@ -2,49 +2,58 @@
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
#include "streaming/video/decoder.h"
|
||||
#include "streaming/video/overlaymanager.h"
|
||||
|
||||
extern "C" {
|
||||
#include <libavcodec/avcodec.h>
|
||||
}
|
||||
|
||||
class IFFmpegRenderer {
|
||||
class IFFmpegRenderer : public Overlay::IOverlayRenderer {
|
||||
public:
|
||||
enum VSyncConstraint {
|
||||
VSYNC_FORCE_OFF,
|
||||
VSYNC_FORCE_ON,
|
||||
VSYNC_ANY
|
||||
enum FramePacingConstraint {
|
||||
PACING_FORCE_OFF,
|
||||
PACING_FORCE_ON,
|
||||
PACING_ANY
|
||||
};
|
||||
|
||||
virtual ~IFFmpegRenderer() {}
|
||||
virtual bool initialize(SDL_Window* window,
|
||||
int videoFormat,
|
||||
int width,
|
||||
int height,
|
||||
int maxFps,
|
||||
bool enableVsync) = 0;
|
||||
virtual bool initialize(PDECODER_PARAMETERS params) = 0;
|
||||
virtual bool prepareDecoderContext(AVCodecContext* context) = 0;
|
||||
virtual void renderFrameAtVsync(AVFrame* frame) = 0;
|
||||
virtual bool needsTestFrame() = 0;
|
||||
virtual int getDecoderCapabilities() = 0;
|
||||
virtual VSyncConstraint getVsyncConstraint() = 0;
|
||||
};
|
||||
virtual void renderFrame(AVFrame* frame) = 0;
|
||||
|
||||
class SdlRenderer : public IFFmpegRenderer {
|
||||
public:
|
||||
SdlRenderer();
|
||||
virtual ~SdlRenderer();
|
||||
virtual bool initialize(SDL_Window* window,
|
||||
int videoFormat,
|
||||
int width,
|
||||
int height,
|
||||
int maxFps,
|
||||
bool enableVsync);
|
||||
virtual bool prepareDecoderContext(AVCodecContext* context);
|
||||
virtual void renderFrameAtVsync(AVFrame* frame);
|
||||
virtual bool needsTestFrame();
|
||||
virtual int getDecoderCapabilities();
|
||||
virtual VSyncConstraint getVsyncConstraint();
|
||||
virtual bool needsTestFrame() {
|
||||
// No test frame required by default
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
SDL_Renderer* m_Renderer;
|
||||
SDL_Texture* m_Texture;
|
||||
virtual int getDecoderCapabilities() {
|
||||
// No special capabilities by default
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual FramePacingConstraint getFramePacingConstraint() {
|
||||
// No pacing preference
|
||||
return PACING_ANY;
|
||||
}
|
||||
|
||||
virtual bool isRenderThreadSupported() {
|
||||
// Render thread is supported by default
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool isDirectRenderingSupported() {
|
||||
// The renderer can render directly to the display
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual enum AVPixelFormat getPreferredPixelFormat(int videoFormat) {
|
||||
// Planar YUV 4:2:0
|
||||
SDL_assert(videoFormat != VIDEO_FORMAT_H265_MAIN10);
|
||||
return AV_PIX_FMT_YUV420P;
|
||||
}
|
||||
|
||||
// IOverlayRenderer
|
||||
virtual void notifyOverlayUpdated(Overlay::OverlayType) override {
|
||||
// Nothing
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,16 +1,60 @@
|
||||
#include "renderer.h"
|
||||
#include "sdlvid.h"
|
||||
|
||||
#include "streaming/session.h"
|
||||
#include "path.h"
|
||||
|
||||
#include <QDir>
|
||||
|
||||
#include <Limelight.h>
|
||||
|
||||
const std::vector<int> SdlRenderer::k_SwFormats({
|
||||
AV_PIX_FMT_YUV420P,
|
||||
AV_PIX_FMT_NV12,
|
||||
AV_PIX_FMT_NV21
|
||||
});
|
||||
|
||||
SdlRenderer::SdlRenderer()
|
||||
: m_Renderer(nullptr),
|
||||
m_Texture(nullptr)
|
||||
m_Texture(nullptr),
|
||||
m_SwPixelFormat(AV_PIX_FMT_YUV420P),
|
||||
m_FontData(Path::readDataFile("ModeSeven.ttf"))
|
||||
{
|
||||
SDL_assert(TTF_WasInit() == 0);
|
||||
if (TTF_Init() != 0) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"TTF_Init() failed: %s",
|
||||
TTF_GetError());
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_zero(m_OverlayFonts);
|
||||
SDL_zero(m_OverlaySurfaces);
|
||||
SDL_zero(m_OverlayTextures);
|
||||
}
|
||||
|
||||
SdlRenderer::~SdlRenderer()
|
||||
{
|
||||
for (int i = 0; i < Overlay::OverlayMax; i++) {
|
||||
if (m_OverlayFonts[i] != nullptr) {
|
||||
TTF_CloseFont(m_OverlayFonts[i]);
|
||||
}
|
||||
}
|
||||
|
||||
TTF_Quit();
|
||||
SDL_assert(TTF_WasInit() == 0);
|
||||
|
||||
for (int i = 0; i < Overlay::OverlayMax; i++) {
|
||||
if (m_OverlayTextures[i] != nullptr) {
|
||||
SDL_DestroyTexture(m_OverlayTextures[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < Overlay::OverlayMax; i++) {
|
||||
if (m_OverlaySurfaces[i] != nullptr) {
|
||||
SDL_FreeSurface(m_OverlaySurfaces[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_Texture != nullptr) {
|
||||
SDL_DestroyTexture(m_Texture);
|
||||
}
|
||||
@@ -25,17 +69,11 @@ bool SdlRenderer::prepareDecoderContext(AVCodecContext*)
|
||||
/* Nothing to do */
|
||||
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Using SDL software renderer");
|
||||
"Using SDL renderer");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SdlRenderer::needsTestFrame()
|
||||
{
|
||||
// This renderer should always work
|
||||
return false;
|
||||
}
|
||||
|
||||
int SdlRenderer::getDecoderCapabilities()
|
||||
{
|
||||
// The FFmpeg CPU decoder can handle reference frame invalidation,
|
||||
@@ -43,30 +81,87 @@ int SdlRenderer::getDecoderCapabilities()
|
||||
return CAPABILITY_REFERENCE_FRAME_INVALIDATION_AVC;
|
||||
}
|
||||
|
||||
IFFmpegRenderer::VSyncConstraint SdlRenderer::getVsyncConstraint()
|
||||
void SdlRenderer::notifyOverlayUpdated(Overlay::OverlayType type)
|
||||
{
|
||||
return VSYNC_ANY;
|
||||
// Construct the required font to render the overlay
|
||||
if (m_OverlayFonts[type] == nullptr) {
|
||||
if (m_FontData.isEmpty()) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL overlay font failed to load");
|
||||
return;
|
||||
}
|
||||
|
||||
// m_FontData must stay around until the font is closed
|
||||
m_OverlayFonts[type] = TTF_OpenFontRW(SDL_RWFromConstMem(m_FontData.constData(), m_FontData.size()),
|
||||
1,
|
||||
Session::get()->getOverlayManager().getOverlayFontSize(type));
|
||||
if (m_OverlayFonts[type] == nullptr) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"TTF_OpenFont() failed: %s",
|
||||
TTF_GetError());
|
||||
|
||||
// Can't proceed without a font
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SDL_Surface* oldSurface = (SDL_Surface*)SDL_AtomicGetPtr((void**)&m_OverlaySurfaces[type]);
|
||||
|
||||
// Free the old surface
|
||||
if (oldSurface != nullptr && SDL_AtomicCASPtr((void**)&m_OverlaySurfaces[type], oldSurface, nullptr)) {
|
||||
SDL_FreeSurface(oldSurface);
|
||||
}
|
||||
|
||||
if (Session::get()->getOverlayManager().isOverlayEnabled(type)) {
|
||||
// The _Wrapped variant is required for line breaks to work
|
||||
SDL_Surface* surface = TTF_RenderText_Blended_Wrapped(m_OverlayFonts[type],
|
||||
Session::get()->getOverlayManager().getOverlayText(type),
|
||||
Session::get()->getOverlayManager().getOverlayColor(type),
|
||||
1000);
|
||||
SDL_AtomicSetPtr((void**)&m_OverlaySurfaces[type], surface);
|
||||
}
|
||||
}
|
||||
|
||||
bool SdlRenderer::initialize(SDL_Window* window,
|
||||
int,
|
||||
int width,
|
||||
int height,
|
||||
int,
|
||||
bool enableVsync)
|
||||
bool SdlRenderer::isRenderThreadSupported()
|
||||
{
|
||||
SDL_RendererInfo info;
|
||||
SDL_GetRendererInfo(m_Renderer, &info);
|
||||
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL renderer backend: %s",
|
||||
info.name);
|
||||
|
||||
if (info.name != QString("direct3d")) {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL renderer backend requires main thread rendering");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SdlRenderer::initialize(PDECODER_PARAMETERS params)
|
||||
{
|
||||
Uint32 rendererFlags = SDL_RENDERER_ACCELERATED;
|
||||
|
||||
if ((SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN) {
|
||||
if ((SDL_GetWindowFlags(params->window) & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN) {
|
||||
// In full-screen exclusive mode, we enable V-sync if requested. For other modes, Windows and Mac
|
||||
// have compositors that make rendering tear-free. Linux compositor varies by distro and user
|
||||
// configuration but doesn't seem feasible to detect here.
|
||||
if (enableVsync) {
|
||||
if (params->enableVsync) {
|
||||
rendererFlags |= SDL_RENDERER_PRESENTVSYNC;
|
||||
}
|
||||
}
|
||||
|
||||
m_Renderer = SDL_CreateRenderer(window, -1, rendererFlags);
|
||||
#ifdef Q_OS_WIN32
|
||||
// We render on a different thread than the main thread which is handling window
|
||||
// messages. Without D3DCREATE_MULTITHREADED, this can cause a deadlock by blocking
|
||||
// on a window message being processed while the main thread is blocked waiting for
|
||||
// the render thread to finish.
|
||||
SDL_SetHintWithPriority(SDL_HINT_RENDER_DIRECT3D_THREADSAFE, "1", SDL_HINT_OVERRIDE);
|
||||
#endif
|
||||
|
||||
m_Renderer = SDL_CreateRenderer(params->window, -1, rendererFlags);
|
||||
if (!m_Renderer) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL_CreateRenderer() failed: %s",
|
||||
@@ -76,39 +171,187 @@ bool SdlRenderer::initialize(SDL_Window* window,
|
||||
|
||||
// The window may be smaller than the stream size, so ensure our
|
||||
// logical rendering surface size is equal to the stream size
|
||||
SDL_RenderSetLogicalSize(m_Renderer, width, height);
|
||||
SDL_RenderSetLogicalSize(m_Renderer, params->width, params->height);
|
||||
|
||||
// Draw a black frame until the video stream starts rendering
|
||||
SDL_SetRenderDrawColor(m_Renderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
|
||||
SDL_RenderClear(m_Renderer);
|
||||
SDL_RenderPresent(m_Renderer);
|
||||
|
||||
m_Texture = SDL_CreateTexture(m_Renderer,
|
||||
SDL_PIXELFORMAT_YV12,
|
||||
SDL_TEXTUREACCESS_STREAMING,
|
||||
width,
|
||||
height);
|
||||
if (!m_Texture) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL_CreateRenderer() failed: %s",
|
||||
SDL_GetError());
|
||||
return false;
|
||||
}
|
||||
#ifdef Q_OS_WIN32
|
||||
// For some reason, using Direct3D9Ex breaks this with multi-monitor setups.
|
||||
// When focus is lost, the window is minimized then immediately restored without
|
||||
// input focus. This glitches out the renderer and a bunch of other stuff.
|
||||
// Direct3D9Ex itself seems to have this minimize on focus loss behavior on its
|
||||
// own, so just disable SDL's handling of the focus loss event.
|
||||
SDL_SetHintWithPriority(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0", SDL_HINT_OVERRIDE);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SdlRenderer::renderFrameAtVsync(AVFrame* frame)
|
||||
void SdlRenderer::renderOverlay(Overlay::OverlayType type)
|
||||
{
|
||||
SDL_UpdateYUVTexture(m_Texture, nullptr,
|
||||
frame->data[0],
|
||||
frame->linesize[0],
|
||||
frame->data[1],
|
||||
frame->linesize[1],
|
||||
frame->data[2],
|
||||
frame->linesize[2]);
|
||||
if (Session::get()->getOverlayManager().isOverlayEnabled(type)) {
|
||||
// If a new surface has been created for updated overlay data, convert it into a texture.
|
||||
// NB: We have to do this conversion at render-time because we can only interact
|
||||
// with the renderer on a single thread.
|
||||
SDL_Surface* surface = (SDL_Surface*)SDL_AtomicGetPtr((void**)&m_OverlaySurfaces[type]);
|
||||
if (surface != nullptr && SDL_AtomicCASPtr((void**)&m_OverlaySurfaces[type], surface, nullptr)) {
|
||||
if (m_OverlayTextures[type] != nullptr) {
|
||||
SDL_DestroyTexture(m_OverlayTextures[type]);
|
||||
}
|
||||
|
||||
if (type == Overlay::OverlayStatusUpdate) {
|
||||
// Bottom Left
|
||||
int unused;
|
||||
SDL_RenderGetLogicalSize(m_Renderer, &unused, &m_OverlayRects[type].y);
|
||||
m_OverlayRects[type].x = 0;
|
||||
m_OverlayRects[type].y -= surface->h;
|
||||
}
|
||||
else if (type == Overlay::OverlayDebug) {
|
||||
// Top left
|
||||
m_OverlayRects[type].x = 0;
|
||||
m_OverlayRects[type].y = 0;
|
||||
}
|
||||
|
||||
m_OverlayRects[type].w = surface->w;
|
||||
m_OverlayRects[type].h = surface->h;
|
||||
|
||||
m_OverlayTextures[type] = SDL_CreateTextureFromSurface(m_Renderer, surface);
|
||||
SDL_FreeSurface(surface);
|
||||
}
|
||||
|
||||
// If we have an overlay texture, render it too
|
||||
if (m_OverlayTextures[type] != nullptr) {
|
||||
SDL_RenderCopy(m_Renderer, m_OverlayTextures[type], nullptr, &m_OverlayRects[type]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SdlRenderer::renderFrame(AVFrame* frame)
|
||||
{
|
||||
int err;
|
||||
AVFrame* swFrame = nullptr;
|
||||
|
||||
if (frame->hw_frames_ctx != nullptr) {
|
||||
// If we are acting as the frontend for a hardware
|
||||
// accelerated decoder, we'll need to read the frame
|
||||
// back to render it.
|
||||
|
||||
swFrame = av_frame_alloc();
|
||||
if (swFrame == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
swFrame->width = frame->width;
|
||||
swFrame->height = frame->height;
|
||||
swFrame->format = m_SwPixelFormat;
|
||||
|
||||
err = av_hwframe_transfer_data(swFrame, frame, 0);
|
||||
if (err != 0) {
|
||||
// Try to find a supported format
|
||||
for (uint32_t i = 0; i < k_SwFormats.size(); i++) {
|
||||
swFrame->format = k_SwFormats.at(i);
|
||||
err = av_hwframe_transfer_data(swFrame, frame, 0);
|
||||
if (err == 0) {
|
||||
// The format was supported. Use that automatically in the future.
|
||||
m_SwPixelFormat = swFrame->format;
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Selected read-back format: %d",
|
||||
m_SwPixelFormat);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (err != 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"av_hwframe_transfer_data() failed: %d",
|
||||
err);
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
frame = swFrame;
|
||||
}
|
||||
|
||||
if (m_Texture == nullptr) {
|
||||
Uint32 sdlFormat;
|
||||
|
||||
switch (frame->format)
|
||||
{
|
||||
case AV_PIX_FMT_YUV420P:
|
||||
sdlFormat = SDL_PIXELFORMAT_YV12;
|
||||
break;
|
||||
case AV_PIX_FMT_NV12:
|
||||
sdlFormat = SDL_PIXELFORMAT_NV12;
|
||||
break;
|
||||
case AV_PIX_FMT_NV21:
|
||||
sdlFormat = SDL_PIXELFORMAT_NV21;
|
||||
break;
|
||||
default:
|
||||
SDL_assert(false);
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
m_Texture = SDL_CreateTexture(m_Renderer,
|
||||
sdlFormat,
|
||||
SDL_TEXTUREACCESS_STREAMING,
|
||||
frame->width,
|
||||
frame->height);
|
||||
if (!m_Texture) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL_CreateTexture() failed: %s",
|
||||
SDL_GetError());
|
||||
goto Exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (frame->format == AV_PIX_FMT_YUV420P) {
|
||||
SDL_UpdateYUVTexture(m_Texture, nullptr,
|
||||
frame->data[0],
|
||||
frame->linesize[0],
|
||||
frame->data[1],
|
||||
frame->linesize[1],
|
||||
frame->data[2],
|
||||
frame->linesize[2]);
|
||||
}
|
||||
else {
|
||||
char* pixels;
|
||||
int pitch;
|
||||
|
||||
err = SDL_LockTexture(m_Texture, nullptr, (void**)&pixels, &pitch);
|
||||
if (err < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL_LockTexture() failed: %s",
|
||||
SDL_GetError());
|
||||
goto Exit;
|
||||
}
|
||||
|
||||
memcpy(pixels,
|
||||
frame->data[0],
|
||||
frame->linesize[0] * frame->height);
|
||||
memcpy(pixels + (frame->linesize[0] * frame->height),
|
||||
frame->data[1],
|
||||
frame->linesize[1] * frame->height / 2);
|
||||
|
||||
SDL_UnlockTexture(m_Texture);
|
||||
}
|
||||
|
||||
SDL_RenderClear(m_Renderer);
|
||||
|
||||
// Draw the video content itself
|
||||
SDL_RenderCopy(m_Renderer, m_Texture, nullptr, nullptr);
|
||||
|
||||
// Draw the overlays
|
||||
for (int i = 0; i < Overlay::OverlayMax; i++) {
|
||||
renderOverlay((Overlay::OverlayType)i);
|
||||
}
|
||||
|
||||
SDL_RenderPresent(m_Renderer);
|
||||
|
||||
Exit:
|
||||
if (swFrame != nullptr) {
|
||||
av_frame_free(&swFrame);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include "renderer.h"
|
||||
|
||||
#include <SDL_ttf.h>
|
||||
|
||||
class SdlRenderer : public IFFmpegRenderer {
|
||||
public:
|
||||
SdlRenderer();
|
||||
virtual ~SdlRenderer() override;
|
||||
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
||||
virtual bool prepareDecoderContext(AVCodecContext* context) override;
|
||||
virtual void renderFrame(AVFrame* frame) override;
|
||||
virtual int getDecoderCapabilities() override;
|
||||
virtual void notifyOverlayUpdated(Overlay::OverlayType) override;
|
||||
virtual bool isRenderThreadSupported() override;
|
||||
|
||||
private:
|
||||
void renderOverlay(Overlay::OverlayType type);
|
||||
|
||||
SDL_Renderer* m_Renderer;
|
||||
SDL_Texture* m_Texture;
|
||||
int m_SwPixelFormat;
|
||||
QByteArray m_FontData;
|
||||
TTF_Font* m_OverlayFonts[Overlay::OverlayMax];
|
||||
SDL_Surface* m_OverlaySurfaces[Overlay::OverlayMax];
|
||||
SDL_Texture* m_OverlayTextures[Overlay::OverlayMax];
|
||||
SDL_Rect m_OverlayRects[Overlay::OverlayMax];
|
||||
|
||||
static const std::vector<int> k_SwFormats;
|
||||
};
|
||||
|
||||
@@ -29,19 +29,19 @@ VAAPIRenderer::~VAAPIRenderer()
|
||||
}
|
||||
|
||||
bool
|
||||
VAAPIRenderer::initialize(SDL_Window* window, int, int width, int height, int, bool)
|
||||
VAAPIRenderer::initialize(PDECODER_PARAMETERS params)
|
||||
{
|
||||
int err;
|
||||
SDL_SysWMinfo info;
|
||||
|
||||
m_VideoWidth = width;
|
||||
m_VideoHeight = height;
|
||||
m_VideoWidth = params->width;
|
||||
m_VideoHeight = params->height;
|
||||
|
||||
SDL_GetWindowSize(window, &m_DisplayWidth, &m_DisplayHeight);
|
||||
SDL_GetWindowSize(params->window, &m_DisplayWidth, &m_DisplayHeight);
|
||||
|
||||
SDL_VERSION(&info.version);
|
||||
|
||||
if (!SDL_GetWindowWMInfo(window, &info)) {
|
||||
if (!SDL_GetWindowWMInfo(params->window, &info)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL_GetWindowWMInfo() failed: %s",
|
||||
SDL_GetError());
|
||||
@@ -76,8 +76,6 @@ VAAPIRenderer::initialize(SDL_Window* window, int, int width, int height, int, b
|
||||
}
|
||||
else if (info.subsystem == SDL_SYSWM_WAYLAND) {
|
||||
#ifdef HAVE_LIBVA_WAYLAND
|
||||
m_WaylandSurface = info.info.wl.surface;
|
||||
m_WaylandDisplay = info.info.wl.display;
|
||||
vaDeviceContext->display = vaGetDisplayWl(info.info.wl.display);
|
||||
if (!vaDeviceContext->display) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
@@ -116,11 +114,12 @@ VAAPIRenderer::initialize(SDL_Window* window, int, int width, int height, int, b
|
||||
"Driver: %s",
|
||||
vendorString ? vendorString : "<unknown>");
|
||||
|
||||
// AMD's Gallium VAAPI driver has a nasty memory leak
|
||||
// that causes memory to be leaked for each submitted frame.
|
||||
// The Flatpak runtime has a VDPAU driver in place that works
|
||||
// well, so use that instead on AMD systems.
|
||||
if (vendorString && qgetenv("FORCE_VAAPI") != "1") {
|
||||
// AMD's Gallium VAAPI driver has a nasty memory leak that causes memory
|
||||
// to be leaked for each submitted frame. The Flatpak runtime has a VDPAU
|
||||
// driver in place that works well, so use that instead on AMD systems. If
|
||||
// we're using Wayland, we have no choice but to use VAAPI because VDPAU
|
||||
// is only supported under X11.
|
||||
if (vendorString && qgetenv("FORCE_VAAPI") != "1" && m_WindowSystem == SDL_SYSWM_X11) {
|
||||
QString vendorStr(vendorString);
|
||||
if (vendorStr.contains("AMD", Qt::CaseInsensitive) ||
|
||||
vendorStr.contains("Radeon", Qt::CaseInsensitive)) {
|
||||
@@ -171,19 +170,16 @@ VAAPIRenderer::needsTestFrame()
|
||||
return true;
|
||||
}
|
||||
|
||||
int
|
||||
VAAPIRenderer::getDecoderCapabilities()
|
||||
bool
|
||||
VAAPIRenderer::isDirectRenderingSupported()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
IFFmpegRenderer::VSyncConstraint VAAPIRenderer::getVsyncConstraint()
|
||||
{
|
||||
return VSYNC_ANY;
|
||||
// Many Wayland renderers don't support YUV surfaces, so use
|
||||
// another frontend renderer to draw our frames.
|
||||
return m_WindowSystem == SDL_SYSWM_X11;
|
||||
}
|
||||
|
||||
void
|
||||
VAAPIRenderer::renderFrameAtVsync(AVFrame* frame)
|
||||
VAAPIRenderer::renderFrame(AVFrame* frame)
|
||||
{
|
||||
VASurfaceID surface = (VASurfaceID)(uintptr_t)frame->data[3];
|
||||
AVHWDeviceContext* deviceContext = (AVHWDeviceContext*)m_HwContext->data;
|
||||
@@ -212,27 +208,10 @@ VAAPIRenderer::renderFrameAtVsync(AVFrame* frame)
|
||||
#endif
|
||||
}
|
||||
else if (m_WindowSystem == SDL_SYSWM_WAYLAND) {
|
||||
#ifdef HAVE_LIBVA_WAYLAND
|
||||
struct wl_buffer* buffer;
|
||||
VAStatus status;
|
||||
|
||||
status = vaGetSurfaceBufferWl(vaDeviceContext->display,
|
||||
surface,
|
||||
VA_FRAME_PICTURE,
|
||||
&buffer);
|
||||
if (status == VA_STATUS_SUCCESS) {
|
||||
wl_surface_attach(m_WaylandSurface, buffer, 0, 0);
|
||||
wl_surface_damage(m_WaylandSurface, dst.x, dst.y, dst.w, dst.h);
|
||||
|
||||
wl_display_flush(m_WaylandDisplay);
|
||||
wl_surface_commit(m_WaylandSurface);
|
||||
}
|
||||
else {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"vaGetSurfaceBufferWl failed(): %d",
|
||||
status);
|
||||
}
|
||||
#endif
|
||||
// We don't support direct rendering on Wayland, so we should
|
||||
// never get called there. Many common Wayland compositors don't
|
||||
// support YUV surfaces, so direct rendering would fail.
|
||||
SDL_assert(false);
|
||||
}
|
||||
else {
|
||||
// We don't accept anything else in initialize().
|
||||
|
||||
@@ -29,18 +29,12 @@ class VAAPIRenderer : public IFFmpegRenderer
|
||||
{
|
||||
public:
|
||||
VAAPIRenderer();
|
||||
virtual ~VAAPIRenderer();
|
||||
virtual bool initialize(SDL_Window* window,
|
||||
int videoFormat,
|
||||
int width,
|
||||
int height,
|
||||
int maxFps,
|
||||
bool enableVsync);
|
||||
virtual bool prepareDecoderContext(AVCodecContext* context);
|
||||
virtual void renderFrameAtVsync(AVFrame* frame);
|
||||
virtual bool needsTestFrame();
|
||||
virtual int getDecoderCapabilities();
|
||||
virtual VSyncConstraint getVsyncConstraint();
|
||||
virtual ~VAAPIRenderer() override;
|
||||
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
||||
virtual bool prepareDecoderContext(AVCodecContext* context) override;
|
||||
virtual void renderFrame(AVFrame* frame) override;
|
||||
virtual bool needsTestFrame() override;
|
||||
virtual bool isDirectRenderingSupported() override;
|
||||
|
||||
private:
|
||||
int m_WindowSystem;
|
||||
@@ -50,11 +44,6 @@ private:
|
||||
Window m_XWindow;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBVA_WAYLAND
|
||||
struct wl_surface* m_WaylandSurface;
|
||||
struct wl_display* m_WaylandDisplay;
|
||||
#endif
|
||||
|
||||
int m_VideoWidth;
|
||||
int m_VideoHeight;
|
||||
int m_DisplayWidth;
|
||||
|
||||
@@ -54,14 +54,14 @@ VDPAURenderer::~VDPAURenderer()
|
||||
}
|
||||
}
|
||||
|
||||
bool VDPAURenderer::initialize(SDL_Window* window, int, int width, int height, int, bool)
|
||||
bool VDPAURenderer::initialize(PDECODER_PARAMETERS params)
|
||||
{
|
||||
int err;
|
||||
VdpStatus status;
|
||||
SDL_SysWMinfo info;
|
||||
|
||||
m_VideoWidth = width;
|
||||
m_VideoHeight = height;
|
||||
m_VideoWidth = params->width;
|
||||
m_VideoHeight = params->height;
|
||||
|
||||
err = av_hwdevice_ctx_create(&m_HwContext,
|
||||
AV_HWDEVICE_TYPE_VDPAU,
|
||||
@@ -93,11 +93,11 @@ bool VDPAURenderer::initialize(SDL_Window* window, int, int width, int height, i
|
||||
GET_PROC_ADDRESS(VDP_FUNC_ID_VIDEO_SURFACE_GET_PARAMETERS, &m_VdpVideoSurfaceGetParameters);
|
||||
GET_PROC_ADDRESS(VDP_FUNC_ID_GET_INFORMATION_STRING, &m_VdpGetInformationString);
|
||||
|
||||
SDL_GetWindowSize(window, (int*)&m_DisplayWidth, (int*)&m_DisplayHeight);
|
||||
SDL_GetWindowSize(params->window, (int*)&m_DisplayWidth, (int*)&m_DisplayHeight);
|
||||
|
||||
SDL_VERSION(&info.version);
|
||||
|
||||
if (!SDL_GetWindowWMInfo(window, &info)) {
|
||||
if (!SDL_GetWindowWMInfo(params->window, &info)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL_GetWindowWMInfo() failed: %s",
|
||||
SDL_GetError());
|
||||
@@ -241,17 +241,7 @@ bool VDPAURenderer::needsTestFrame()
|
||||
return true;
|
||||
}
|
||||
|
||||
int VDPAURenderer::getDecoderCapabilities()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
IFFmpegRenderer::VSyncConstraint VDPAURenderer::getVsyncConstraint()
|
||||
{
|
||||
return VSYNC_ANY;
|
||||
}
|
||||
|
||||
void VDPAURenderer::renderFrameAtVsync(AVFrame* frame)
|
||||
void VDPAURenderer::renderFrame(AVFrame* frame)
|
||||
{
|
||||
VdpStatus status;
|
||||
VdpVideoSurface videoSurface = (VdpVideoSurface)(uintptr_t)frame->data[3];
|
||||
@@ -335,8 +325,8 @@ void VDPAURenderer::renderFrameAtVsync(AVFrame* frame)
|
||||
0, nullptr,
|
||||
&sourceRect,
|
||||
chosenSurface,
|
||||
&outputRect,
|
||||
nullptr,
|
||||
&outputRect,
|
||||
0,
|
||||
nullptr);
|
||||
if (status != VDP_STATUS_OK) {
|
||||
|
||||
@@ -12,18 +12,11 @@ class VDPAURenderer : public IFFmpegRenderer
|
||||
{
|
||||
public:
|
||||
VDPAURenderer();
|
||||
virtual ~VDPAURenderer();
|
||||
virtual bool initialize(SDL_Window* window,
|
||||
int videoFormat,
|
||||
int width,
|
||||
int height,
|
||||
int maxFps,
|
||||
bool enableVsync);
|
||||
virtual bool prepareDecoderContext(AVCodecContext* context);
|
||||
virtual void renderFrameAtVsync(AVFrame* frame);
|
||||
virtual bool needsTestFrame();
|
||||
virtual int getDecoderCapabilities();
|
||||
virtual VSyncConstraint getVsyncConstraint();
|
||||
virtual ~VDPAURenderer() override;
|
||||
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
||||
virtual bool prepareDecoderContext(AVCodecContext* context) override;
|
||||
virtual void renderFrame(AVFrame* frame) override;
|
||||
virtual bool needsTestFrame() override;
|
||||
|
||||
private:
|
||||
uint32_t m_VideoWidth, m_VideoHeight;
|
||||
|
||||
@@ -7,11 +7,13 @@
|
||||
|
||||
#include <SDL_syswm.h>
|
||||
#include <Limelight.h>
|
||||
#include <streaming/session.h>
|
||||
|
||||
#include <mach/mach_time.h>
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <VideoToolbox/VideoToolbox.h>
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
#import <dispatch/dispatch.h>
|
||||
|
||||
class VTRenderer : public IFFmpegRenderer
|
||||
{
|
||||
@@ -20,12 +22,27 @@ public:
|
||||
: m_HwContext(nullptr),
|
||||
m_DisplayLayer(nullptr),
|
||||
m_FormatDesc(nullptr),
|
||||
m_View(nullptr)
|
||||
m_StreamView(nullptr),
|
||||
m_DisplayLink(nullptr)
|
||||
{
|
||||
SDL_zero(m_OverlayTextFields);
|
||||
}
|
||||
|
||||
virtual ~VTRenderer()
|
||||
virtual ~VTRenderer() override
|
||||
{
|
||||
if (m_DisplayLink != nullptr) {
|
||||
CVDisplayLinkStop(m_DisplayLink);
|
||||
CVDisplayLinkRelease(m_DisplayLink);
|
||||
}
|
||||
|
||||
if (m_VsyncPassed != nullptr) {
|
||||
SDL_DestroyCond(m_VsyncPassed);
|
||||
}
|
||||
|
||||
if (m_VsyncMutex != nullptr) {
|
||||
SDL_DestroyMutex(m_VsyncMutex);
|
||||
}
|
||||
|
||||
if (m_HwContext != nullptr) {
|
||||
av_buffer_unref(&m_HwContext);
|
||||
}
|
||||
@@ -34,13 +51,89 @@ public:
|
||||
CFRelease(m_FormatDesc);
|
||||
}
|
||||
|
||||
if (m_View != nullptr) {
|
||||
[m_View removeFromSuperview];
|
||||
for (int i = 0; i < Overlay::OverlayMax; i++) {
|
||||
if (m_OverlayTextFields[i] != nullptr) {
|
||||
[m_OverlayTextFields[i] removeFromSuperview];
|
||||
}
|
||||
}
|
||||
|
||||
if (m_StreamView != nullptr) {
|
||||
[m_StreamView removeFromSuperview];
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
CVReturn
|
||||
displayLinkOutputCallback(
|
||||
CVDisplayLinkRef displayLink,
|
||||
const CVTimeStamp* /* now */,
|
||||
const CVTimeStamp* /* vsyncTime */,
|
||||
CVOptionFlags,
|
||||
CVOptionFlags*,
|
||||
void *displayLinkContext)
|
||||
{
|
||||
auto me = reinterpret_cast<VTRenderer*>(displayLinkContext);
|
||||
|
||||
SDL_assert(displayLink == me->m_DisplayLink);
|
||||
|
||||
SDL_LockMutex(me->m_VsyncMutex);
|
||||
SDL_CondSignal(me->m_VsyncPassed);
|
||||
SDL_UnlockMutex(me->m_VsyncMutex);
|
||||
|
||||
return kCVReturnSuccess;
|
||||
}
|
||||
|
||||
bool initializeVsyncCallback(SDL_SysWMinfo* info)
|
||||
{
|
||||
NSScreen* screen = [info->info.cocoa.window screen];
|
||||
CVReturn status;
|
||||
if (screen == nullptr) {
|
||||
// Window not visible on any display, so use a
|
||||
// CVDisplayLink that can work with all active displays.
|
||||
// When we become visible, we'll recreate ourselves
|
||||
// and associate with the new screen.
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"NSWindow is not visible on any display");
|
||||
status = CVDisplayLinkCreateWithActiveCGDisplays(&m_DisplayLink);
|
||||
}
|
||||
else {
|
||||
CGDirectDisplayID displayId = [[screen deviceDescription][@"NSScreenNumber"] unsignedIntValue];
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"NSWindow on display: %x",
|
||||
displayId);
|
||||
status = CVDisplayLinkCreateWithCGDisplay(displayId, &m_DisplayLink);
|
||||
}
|
||||
if (status != kCVReturnSuccess) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Failed to create CVDisplayLink: %d",
|
||||
status);
|
||||
return false;
|
||||
}
|
||||
|
||||
status = CVDisplayLinkSetOutputCallback(m_DisplayLink, displayLinkOutputCallback, this);
|
||||
if (status != kCVReturnSuccess) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"CVDisplayLinkSetOutputCallback() failed: %d",
|
||||
status);
|
||||
return false;
|
||||
}
|
||||
|
||||
status = CVDisplayLinkStart(m_DisplayLink);
|
||||
if (status != kCVReturnSuccess) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"CVDisplayLinkStart() failed: %d",
|
||||
status);
|
||||
return false;
|
||||
}
|
||||
|
||||
m_VsyncMutex = SDL_CreateMutex();
|
||||
m_VsyncPassed = SDL_CreateCond();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Caller frees frame after we return
|
||||
virtual void renderFrameAtVsync(AVFrame* frame) override
|
||||
virtual void renderFrame(AVFrame* frame) override
|
||||
{
|
||||
OSStatus status;
|
||||
CVPixelBufferRef pixBuf = reinterpret_cast<CVPixelBufferRef>(frame->data[3]);
|
||||
@@ -95,18 +188,23 @@ public:
|
||||
[m_DisplayLayer enqueueSampleBuffer:sampleBuffer];
|
||||
|
||||
CFRelease(sampleBuffer);
|
||||
|
||||
if (m_DisplayLink != nullptr) {
|
||||
// Vsync is enabled, so wait for a swap before returning
|
||||
SDL_LockMutex(m_VsyncMutex);
|
||||
if (SDL_CondWaitTimeout(m_VsyncPassed, m_VsyncMutex, 100) == SDL_MUTEX_TIMEDOUT) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"V-sync wait timed out after 100 ms");
|
||||
}
|
||||
SDL_UnlockMutex(m_VsyncMutex);
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool initialize(SDL_Window* window,
|
||||
int videoFormat,
|
||||
int,
|
||||
int,
|
||||
int,
|
||||
bool) override
|
||||
virtual bool initialize(PDECODER_PARAMETERS params) override
|
||||
{
|
||||
int err;
|
||||
|
||||
if (videoFormat & VIDEO_FORMAT_MASK_H264) {
|
||||
if (params->videoFormat & VIDEO_FORMAT_MASK_H264) {
|
||||
// Prior to 10.13, we'll just assume everything has
|
||||
// H.264 support and fail open to allow VT decode.
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300
|
||||
@@ -124,7 +222,7 @@ public:
|
||||
"Assuming H.264 HW decode on < macOS 10.13");
|
||||
}
|
||||
}
|
||||
else if (videoFormat & VIDEO_FORMAT_MASK_H265) {
|
||||
else if (params->videoFormat & VIDEO_FORMAT_MASK_H265) {
|
||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300
|
||||
if (__builtin_available(macOS 10.13, *)) {
|
||||
if (!VTIsHardwareDecodeSupported(kCMVideoCodecType_HEVC)) {
|
||||
@@ -147,7 +245,7 @@ public:
|
||||
|
||||
SDL_VERSION(&info.version);
|
||||
|
||||
if (!SDL_GetWindowWMInfo(window, &info)) {
|
||||
if (!SDL_GetWindowWMInfo(params->window, &info)) {
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"SDL_GetWindowWMInfo() failed: %s",
|
||||
SDL_GetError());
|
||||
@@ -159,21 +257,21 @@ public:
|
||||
// SDL adds its own content view to listen for events.
|
||||
// We need to add a subview for our display layer.
|
||||
NSView* contentView = info.info.cocoa.window.contentView;
|
||||
m_View = [[NSView alloc] initWithFrame:contentView.bounds];
|
||||
m_StreamView = [[NSView alloc] initWithFrame:contentView.bounds];
|
||||
|
||||
m_DisplayLayer = [[AVSampleBufferDisplayLayer alloc] init];
|
||||
m_DisplayLayer.bounds = m_View.bounds;
|
||||
m_DisplayLayer.position = CGPointMake(CGRectGetMidX(m_View.bounds), CGRectGetMidY(m_View.bounds));
|
||||
m_DisplayLayer.bounds = m_StreamView.bounds;
|
||||
m_DisplayLayer.position = CGPointMake(CGRectGetMidX(m_StreamView.bounds), CGRectGetMidY(m_StreamView.bounds));
|
||||
m_DisplayLayer.videoGravity = AVLayerVideoGravityResizeAspect;
|
||||
|
||||
// Create a layer-hosted view by setting the layer before wantsLayer
|
||||
// This avoids us having to add our AVSampleBufferDisplayLayer as a
|
||||
// sublayer of a layer-backed view which leaves a useless layer in
|
||||
// the middle.
|
||||
m_View.layer = m_DisplayLayer;
|
||||
m_View.wantsLayer = YES;
|
||||
m_StreamView.layer = m_DisplayLayer;
|
||||
m_StreamView.wantsLayer = YES;
|
||||
|
||||
[contentView addSubview: m_View];
|
||||
[contentView addSubview: m_StreamView];
|
||||
|
||||
err = av_hwdevice_ctx_create(&m_HwContext,
|
||||
AV_HWDEVICE_TYPE_VIDEOTOOLBOX,
|
||||
@@ -187,9 +285,80 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (params->enableVsync) {
|
||||
if (!initializeVsyncCallback(&info)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void updateOverlayOnMainThread(Overlay::OverlayType type)
|
||||
{
|
||||
// Lazy initialization for the overlay
|
||||
if (m_OverlayTextFields[type] == nullptr) {
|
||||
m_OverlayTextFields[type] = [[NSTextField alloc] initWithFrame:m_StreamView.bounds];
|
||||
[m_OverlayTextFields[type] setBezeled:NO];
|
||||
[m_OverlayTextFields[type] setDrawsBackground:NO];
|
||||
[m_OverlayTextFields[type] setEditable:NO];
|
||||
[m_OverlayTextFields[type] setSelectable:NO];
|
||||
|
||||
switch (type) {
|
||||
case Overlay::OverlayDebug:
|
||||
[m_OverlayTextFields[type] setAlignment:NSLeftTextAlignment];
|
||||
break;
|
||||
case Overlay::OverlayStatusUpdate:
|
||||
[m_OverlayTextFields[type] setAlignment:NSRightTextAlignment];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
SDL_Color color = Session::get()->getOverlayManager().getOverlayColor(type);
|
||||
[m_OverlayTextFields[type] setTextColor:[NSColor colorWithSRGBRed:color.r / 255.0 green:color.g / 255.0 blue:color.b / 255.0 alpha:color.a / 255.0]];
|
||||
[m_OverlayTextFields[type] setFont:[NSFont messageFontOfSize:Session::get()->getOverlayManager().getOverlayFontSize(type)]];
|
||||
|
||||
[m_StreamView addSubview: m_OverlayTextFields[type]];
|
||||
}
|
||||
|
||||
// Update text contents
|
||||
[m_OverlayTextFields[type] setStringValue: [NSString stringWithUTF8String:Session::get()->getOverlayManager().getOverlayText(type)]];
|
||||
|
||||
// Unhide if it's enabled
|
||||
[m_OverlayTextFields[type] setHidden: !Session::get()->getOverlayManager().isOverlayEnabled(type)];
|
||||
}
|
||||
|
||||
static void updateDebugOverlayOnMainThread(void* context)
|
||||
{
|
||||
VTRenderer* me = (VTRenderer*)context;
|
||||
|
||||
me->updateOverlayOnMainThread(Overlay::OverlayDebug);
|
||||
}
|
||||
|
||||
static void updateStatusOverlayOnMainThread(void* context)
|
||||
{
|
||||
VTRenderer* me = (VTRenderer*)context;
|
||||
|
||||
me->updateOverlayOnMainThread(Overlay::OverlayStatusUpdate);
|
||||
}
|
||||
|
||||
virtual void notifyOverlayUpdated(Overlay::OverlayType type) override
|
||||
{
|
||||
// We must do the actual UI updates on the main thread, so queue an
|
||||
// async callback on the main thread via GCD to do the UI update.
|
||||
switch (type) {
|
||||
case Overlay::OverlayDebug:
|
||||
dispatch_async_f(dispatch_get_main_queue(), this, updateDebugOverlayOnMainThread);
|
||||
break;
|
||||
case Overlay::OverlayStatusUpdate:
|
||||
dispatch_async_f(dispatch_get_main_queue(), this, updateStatusOverlayOnMainThread);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool prepareDecoderContext(AVCodecContext* context) override
|
||||
{
|
||||
context->hw_device_ctx = av_buffer_ref(m_HwContext);
|
||||
@@ -202,28 +371,22 @@ public:
|
||||
|
||||
virtual bool needsTestFrame() override
|
||||
{
|
||||
// We query VT to determine whether the codec is supported
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual int getDecoderCapabilities() override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual IFFmpegRenderer::VSyncConstraint getVsyncConstraint() override
|
||||
{
|
||||
// This renderer is inherently tied to V-sync due how we're
|
||||
// rendering with AVSampleBufferDisplay layer. Running without
|
||||
// the V-Sync source leads to massive stuttering.
|
||||
return VSYNC_FORCE_ON;
|
||||
// We used to trust VT to tell us whether decode will work, but
|
||||
// there are cases where it can lie because the hardware technically
|
||||
// can decode the format but VT is unserviceable for some other reason.
|
||||
// Decoding the test frame will tell us for sure whether it will work.
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
AVBufferRef* m_HwContext;
|
||||
AVSampleBufferDisplayLayer* m_DisplayLayer;
|
||||
CMVideoFormatDescriptionRef m_FormatDesc;
|
||||
NSView* m_View;
|
||||
NSView* m_StreamView;
|
||||
NSTextField* m_OverlayTextFields[Overlay::OverlayMax];
|
||||
CVDisplayLinkRef m_DisplayLink;
|
||||
SDL_mutex* m_VsyncMutex;
|
||||
SDL_cond* m_VsyncPassed;
|
||||
};
|
||||
|
||||
IFFmpegRenderer* VTRendererFactory::createRenderer() {
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
#include <Limelight.h>
|
||||
#include "ffmpeg.h"
|
||||
#include "streaming/streamutils.h"
|
||||
#include "streaming/session.h"
|
||||
|
||||
#include <h264_stream.h>
|
||||
|
||||
#include "ffmpeg-renderers/sdlvid.h"
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
#include "ffmpeg-renderers/dxva2.h"
|
||||
#endif
|
||||
@@ -19,6 +23,14 @@
|
||||
#include "ffmpeg-renderers/vdpau.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MMAL
|
||||
#include "ffmpeg-renderers/mmal.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DRM
|
||||
#include "ffmpeg-renderers/drm.h"
|
||||
#endif
|
||||
|
||||
// This is gross but it allows us to use sizeof()
|
||||
#include "ffmpeg_videosamples.cpp"
|
||||
|
||||
@@ -28,12 +40,13 @@
|
||||
|
||||
bool FFmpegVideoDecoder::isHardwareAccelerated()
|
||||
{
|
||||
return m_HwDecodeCfg != nullptr;
|
||||
return m_HwDecodeCfg != nullptr ||
|
||||
(m_VideoDecoderCtx->codec->capabilities & AV_CODEC_CAP_HARDWARE) != 0;
|
||||
}
|
||||
|
||||
int FFmpegVideoDecoder::getDecoderCapabilities()
|
||||
{
|
||||
return m_Renderer->getDecoderCapabilities();
|
||||
return m_BackendRenderer->getDecoderCapabilities();
|
||||
}
|
||||
|
||||
enum AVPixelFormat FFmpegVideoDecoder::ffGetFormat(AVCodecContext* context,
|
||||
@@ -57,19 +70,20 @@ enum AVPixelFormat FFmpegVideoDecoder::ffGetFormat(AVCodecContext* context,
|
||||
return AV_PIX_FMT_NONE;
|
||||
}
|
||||
|
||||
FFmpegVideoDecoder::FFmpegVideoDecoder()
|
||||
FFmpegVideoDecoder::FFmpegVideoDecoder(bool testOnly)
|
||||
: m_VideoDecoderCtx(nullptr),
|
||||
m_DecodeBuffer(1024 * 1024, 0),
|
||||
m_HwDecodeCfg(nullptr),
|
||||
m_Renderer(nullptr),
|
||||
m_BackendRenderer(nullptr),
|
||||
m_FrontendRenderer(nullptr),
|
||||
m_ConsecutiveFailedDecodes(0),
|
||||
m_Pacer(nullptr),
|
||||
m_LastFrameNumber(0),
|
||||
m_StreamFps(0),
|
||||
m_NeedsSpsFixup(false)
|
||||
m_NeedsSpsFixup(false),
|
||||
m_TestOnly(testOnly)
|
||||
{
|
||||
av_init_packet(&m_Pkt);
|
||||
SDL_AtomicSet(&m_QueuedFrames, 0);
|
||||
|
||||
SDL_zero(m_ActiveWndVideoStats);
|
||||
SDL_zero(m_LastWndVideoStats);
|
||||
@@ -82,37 +96,21 @@ FFmpegVideoDecoder::FFmpegVideoDecoder()
|
||||
FFmpegVideoDecoder::~FFmpegVideoDecoder()
|
||||
{
|
||||
reset();
|
||||
|
||||
// Set log level back to default.
|
||||
// NB: We don't do this in reset() because we want
|
||||
// to preserve the log level across reset() during
|
||||
// test initialization.
|
||||
av_log_set_level(AV_LOG_INFO);
|
||||
}
|
||||
|
||||
IFFmpegRenderer* FFmpegVideoDecoder::getRenderer()
|
||||
IFFmpegRenderer* FFmpegVideoDecoder::getBackendRenderer()
|
||||
{
|
||||
return m_Renderer;
|
||||
return m_BackendRenderer;
|
||||
}
|
||||
|
||||
void FFmpegVideoDecoder::reset()
|
||||
{
|
||||
// Drop any frames still queued to ensure
|
||||
// they are properly freed.
|
||||
SDL_Event event;
|
||||
|
||||
while (SDL_AtomicGet(&m_QueuedFrames) > 0) {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Waiting for %d frames to return",
|
||||
SDL_AtomicGet(&m_QueuedFrames));
|
||||
|
||||
if (SDL_PeepEvents(&event,
|
||||
1,
|
||||
SDL_GETEVENT,
|
||||
SDL_USEREVENT,
|
||||
SDL_USEREVENT) == 1) {
|
||||
dropFrame(&event.user);
|
||||
}
|
||||
else {
|
||||
SDL_Delay(10);
|
||||
SDL_PumpEvents();
|
||||
}
|
||||
}
|
||||
|
||||
delete m_Pacer;
|
||||
m_Pacer = nullptr;
|
||||
|
||||
@@ -123,38 +121,83 @@ void FFmpegVideoDecoder::reset()
|
||||
// need to delete in the renderer destructor.
|
||||
avcodec_free_context(&m_VideoDecoderCtx);
|
||||
|
||||
delete m_Renderer;
|
||||
m_Renderer = nullptr;
|
||||
if (!m_TestOnly) {
|
||||
Session::get()->getOverlayManager().setOverlayRenderer(nullptr);
|
||||
}
|
||||
|
||||
logVideoStats(m_GlobalVideoStats, "Global video stats");
|
||||
// If we have a separate frontend renderer, free that first
|
||||
if (m_FrontendRenderer != m_BackendRenderer) {
|
||||
delete m_FrontendRenderer;
|
||||
}
|
||||
|
||||
delete m_BackendRenderer;
|
||||
|
||||
m_FrontendRenderer = m_BackendRenderer = nullptr;
|
||||
|
||||
if (!m_TestOnly) {
|
||||
logVideoStats(m_GlobalVideoStats, "Global video stats");
|
||||
}
|
||||
else {
|
||||
// Test-only decoders can't have any frames submitted
|
||||
SDL_assert(m_GlobalVideoStats.totalFrames == 0);
|
||||
}
|
||||
}
|
||||
|
||||
bool FFmpegVideoDecoder::completeInitialization(AVCodec* decoder, SDL_Window* window,
|
||||
int videoFormat, int width, int height,
|
||||
int maxFps, bool enableVsync, bool testOnly)
|
||||
bool FFmpegVideoDecoder::createFrontendRenderer(PDECODER_PARAMETERS params)
|
||||
{
|
||||
auto vsyncConstraint = m_Renderer->getVsyncConstraint();
|
||||
if (vsyncConstraint == IFFmpegRenderer::VSYNC_FORCE_OFF && enableVsync) {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"V-sync is forcefully disabled by the active renderer");
|
||||
enableVsync = false;
|
||||
if (m_BackendRenderer->isDirectRenderingSupported()) {
|
||||
// The backend renderer can render to the display
|
||||
m_FrontendRenderer = m_BackendRenderer;
|
||||
}
|
||||
else if (vsyncConstraint == IFFmpegRenderer::VSYNC_FORCE_ON && !enableVsync) {
|
||||
// FIXME: This duplicates logic in Session.cpp
|
||||
int displayHz = StreamUtils::getDisplayRefreshRate(window);
|
||||
if (displayHz + 5 >= maxFps) {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"V-sync is forcefully enabled by the active renderer");
|
||||
enableVsync = true;
|
||||
else {
|
||||
// The backend renderer cannot directly render to the display, so
|
||||
// we will create an SDL renderer to draw the frames.
|
||||
m_FrontendRenderer = new SdlRenderer();
|
||||
if (!m_FrontendRenderer->initialize(params)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
m_StreamFps = maxFps;
|
||||
m_Pacer = new Pacer(m_Renderer, &m_ActiveWndVideoStats);
|
||||
if (!m_Pacer->initialize(window, maxFps, enableVsync)) {
|
||||
// Determine whether the frontend renderer prefers frame pacing
|
||||
auto vsyncConstraint = m_FrontendRenderer->getFramePacingConstraint();
|
||||
if (vsyncConstraint == IFFmpegRenderer::PACING_FORCE_OFF && params->enableFramePacing) {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Frame pacing is forcefully disabled by the frontend renderer");
|
||||
params->enableFramePacing = false;
|
||||
}
|
||||
else if (vsyncConstraint == IFFmpegRenderer::PACING_FORCE_ON && !params->enableFramePacing) {
|
||||
// FIXME: This duplicates logic in Session.cpp
|
||||
int displayHz = StreamUtils::getDisplayRefreshRate(params->window);
|
||||
if (displayHz + 5 >= params->frameRate) {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Frame pacing is forcefully enabled by the frontend renderer");
|
||||
params->enableFramePacing = true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FFmpegVideoDecoder::completeInitialization(AVCodec* decoder, PDECODER_PARAMETERS params, bool testFrame)
|
||||
{
|
||||
// In test-only mode, we should only see test frames
|
||||
SDL_assert(!m_TestOnly || testFrame);
|
||||
|
||||
// Create the frontend renderer based on the capabilities of the backend renderer
|
||||
if (!createFrontendRenderer(params)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_StreamFps = params->frameRate;
|
||||
|
||||
// Don't bother initializing Pacer if we're not actually going to render
|
||||
if (!testFrame) {
|
||||
m_Pacer = new Pacer(m_FrontendRenderer, &m_ActiveWndVideoStats);
|
||||
if (!m_Pacer->initialize(params->window, params->frameRate, params->enableFramePacing)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
m_VideoDecoderCtx = avcodec_alloc_context3(decoder);
|
||||
if (!m_VideoDecoderCtx) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
@@ -170,7 +213,7 @@ bool FFmpegVideoDecoder::completeInitialization(AVCodec* decoder, SDL_Window* wi
|
||||
m_VideoDecoderCtx->flags2 |= AV_CODEC_FLAG2_SHOW_ALL;
|
||||
|
||||
// Enable slice multi-threading for software decoding
|
||||
if (!m_HwDecodeCfg) {
|
||||
if (!isHardwareAccelerated()) {
|
||||
m_VideoDecoderCtx->thread_type = FF_THREAD_SLICE;
|
||||
m_VideoDecoderCtx->thread_count = qMin(MAX_SLICES, SDL_GetCPUCount());
|
||||
}
|
||||
@@ -180,13 +223,13 @@ bool FFmpegVideoDecoder::completeInitialization(AVCodec* decoder, SDL_Window* wi
|
||||
}
|
||||
|
||||
// Setup decoding parameters
|
||||
m_VideoDecoderCtx->width = width;
|
||||
m_VideoDecoderCtx->height = height;
|
||||
m_VideoDecoderCtx->pix_fmt = AV_PIX_FMT_YUV420P; // FIXME: HDR
|
||||
m_VideoDecoderCtx->width = params->width;
|
||||
m_VideoDecoderCtx->height = params->height;
|
||||
m_VideoDecoderCtx->pix_fmt = m_FrontendRenderer->getPreferredPixelFormat(params->videoFormat);
|
||||
m_VideoDecoderCtx->get_format = ffGetFormat;
|
||||
|
||||
// Allow the renderer to attach data to this decoder
|
||||
if (!m_Renderer->prepareDecoderContext(m_VideoDecoderCtx)) {
|
||||
// Allow the backend renderer to attach data to this decoder
|
||||
if (!m_BackendRenderer->prepareDecoderContext(m_VideoDecoderCtx)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -201,7 +244,7 @@ bool FFmpegVideoDecoder::completeInitialization(AVCodec* decoder, SDL_Window* wi
|
||||
if (err < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Unable to open decoder for format: %x",
|
||||
videoFormat);
|
||||
params->videoFormat);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -210,8 +253,8 @@ bool FFmpegVideoDecoder::completeInitialization(AVCodec* decoder, SDL_Window* wi
|
||||
// our minds on the selected video codec, so we'll do a trial run
|
||||
// now to see if things will actually work when the video stream
|
||||
// comes in.
|
||||
if (testOnly) {
|
||||
if (videoFormat & VIDEO_FORMAT_MASK_H264) {
|
||||
if (testFrame) {
|
||||
if (params->videoFormat & VIDEO_FORMAT_MASK_H264) {
|
||||
m_Pkt.data = (uint8_t*)k_H264TestFrame;
|
||||
m_Pkt.size = sizeof(k_H264TestFrame);
|
||||
}
|
||||
@@ -230,8 +273,8 @@ bool FFmpegVideoDecoder::completeInitialization(AVCodec* decoder, SDL_Window* wi
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ((videoFormat & VIDEO_FORMAT_MASK_H264) &&
|
||||
!(m_Renderer->getDecoderCapabilities() & CAPABILITY_REFERENCE_FRAME_INVALIDATION_AVC)) {
|
||||
if ((params->videoFormat & VIDEO_FORMAT_MASK_H264) &&
|
||||
!(m_BackendRenderer->getDecoderCapabilities() & CAPABILITY_REFERENCE_FRAME_INVALIDATION_AVC)) {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Using H.264 SPS fixup");
|
||||
m_NeedsSpsFixup = true;
|
||||
@@ -239,12 +282,10 @@ bool FFmpegVideoDecoder::completeInitialization(AVCodec* decoder, SDL_Window* wi
|
||||
else {
|
||||
m_NeedsSpsFixup = false;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
// Restore default log level before streaming
|
||||
av_log_set_level(AV_LOG_INFO);
|
||||
#endif
|
||||
// Tell overlay manager to use this frontend renderer
|
||||
Session::get()->getOverlayManager().setOverlayRenderer(m_FrontendRenderer);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -254,10 +295,12 @@ void FFmpegVideoDecoder::addVideoStats(VIDEO_STATS& src, VIDEO_STATS& dst)
|
||||
dst.receivedFrames += src.receivedFrames;
|
||||
dst.decodedFrames += src.decodedFrames;
|
||||
dst.renderedFrames += src.renderedFrames;
|
||||
dst.totalFrames += src.totalFrames;
|
||||
dst.networkDroppedFrames += src.networkDroppedFrames;
|
||||
dst.pacerDroppedFrames += src.pacerDroppedFrames;
|
||||
dst.totalReassemblyTime += src.totalReassemblyTime;
|
||||
dst.totalDecodeTime += src.totalDecodeTime;
|
||||
dst.totalPacerTime += src.totalPacerTime;
|
||||
dst.totalRenderTime += src.totalRenderTime;
|
||||
|
||||
Uint32 now = SDL_GetTicks();
|
||||
@@ -270,60 +313,63 @@ void FFmpegVideoDecoder::addVideoStats(VIDEO_STATS& src, VIDEO_STATS& dst)
|
||||
// The following code assumes the global measure was already started first
|
||||
SDL_assert(dst.measurementStartTimestamp <= src.measurementStartTimestamp);
|
||||
|
||||
dst.totalFps = (float)dst.totalFrames / ((float)(now - dst.measurementStartTimestamp) / 1000);
|
||||
dst.receivedFps = (float)dst.receivedFrames / ((float)(now - dst.measurementStartTimestamp) / 1000);
|
||||
dst.decodedFps = (float)dst.decodedFrames / ((float)(now - dst.measurementStartTimestamp) / 1000);
|
||||
dst.renderedFps = (float)dst.renderedFrames / ((float)(now - dst.measurementStartTimestamp) / 1000);
|
||||
}
|
||||
|
||||
void FFmpegVideoDecoder::logVideoStats(VIDEO_STATS& stats, const char* title)
|
||||
void FFmpegVideoDecoder::stringifyVideoStats(VIDEO_STATS& stats, char* output)
|
||||
{
|
||||
if (stats.renderedFps > 0 || stats.renderedFrames != 0) {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"%s", title);
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"----------------------------------------------------------");
|
||||
int offset = 0;
|
||||
|
||||
// Start with an empty string
|
||||
output[offset] = 0;
|
||||
|
||||
if (stats.receivedFps > 0) {
|
||||
offset += sprintf(&output[offset],
|
||||
"Estimated host PC frame rate: %.2f FPS\n"
|
||||
"Incoming frame rate from network: %.2f FPS\n"
|
||||
"Decoding frame rate: %.2f FPS\n"
|
||||
"Rendering frame rate: %.2f FPS\n",
|
||||
stats.totalFps,
|
||||
stats.receivedFps,
|
||||
stats.decodedFps,
|
||||
stats.renderedFps);
|
||||
}
|
||||
|
||||
if (stats.renderedFps > 0) {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Incoming frame rate from network: %.2f FPS",
|
||||
stats.receivedFps);
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Decoding frame rate: %.2f FPS",
|
||||
stats.decodedFps);
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Rendering frame rate: %.2f FPS",
|
||||
stats.renderedFps);
|
||||
}
|
||||
if (stats.renderedFrames != 0) {
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Total frames received: %u",
|
||||
stats.receivedFrames);
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Total frames decoded: %u",
|
||||
stats.decodedFrames);
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Total frames rendered: %u",
|
||||
stats.renderedFrames);
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Average reassembly time: %.2f ms",
|
||||
(float)stats.totalReassemblyTime / stats.decodedFrames);
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Average decode time: %.2f ms",
|
||||
(float)stats.totalDecodeTime / stats.decodedFrames);
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Average render time: %.2f ms",
|
||||
(float)stats.totalRenderTime / stats.renderedFrames);
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Frames lost during network transmission: %.2f%%",
|
||||
(float)stats.networkDroppedFrames / stats.decodedFrames);
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Frames dropped by frame pacing: %.2f%%",
|
||||
(float)stats.pacerDroppedFrames / stats.decodedFrames);
|
||||
offset += sprintf(&output[offset],
|
||||
"Frames dropped by your network connection: %.2f%%\n"
|
||||
"Frames dropped due to network jitter: %.2f%%\n"
|
||||
"Average receive time: %.2f ms\n"
|
||||
"Average decoding time: %.2f ms\n"
|
||||
"Average frame queue delay: %.2f ms\n"
|
||||
"Average rendering time (including monitor V-sync latency): %.2f ms\n",
|
||||
(float)stats.networkDroppedFrames / stats.totalFrames * 100,
|
||||
(float)stats.pacerDroppedFrames / stats.decodedFrames * 100,
|
||||
(float)stats.totalReassemblyTime / stats.receivedFrames,
|
||||
(float)stats.totalDecodeTime / stats.decodedFrames,
|
||||
(float)stats.totalPacerTime / stats.renderedFrames,
|
||||
(float)stats.totalRenderTime / stats.renderedFrames);
|
||||
}
|
||||
}
|
||||
|
||||
IFFmpegRenderer* FFmpegVideoDecoder::createAcceleratedRenderer(const AVCodecHWConfig* hwDecodeCfg)
|
||||
void FFmpegVideoDecoder::logVideoStats(VIDEO_STATS& stats, const char* title)
|
||||
{
|
||||
if (stats.renderedFps > 0 || stats.renderedFrames != 0) {
|
||||
char videoStatsStr[512];
|
||||
stringifyVideoStats(stats, videoStatsStr);
|
||||
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"%s", title);
|
||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"----------------------------------------------------------\n%s",
|
||||
videoStatsStr);
|
||||
}
|
||||
}
|
||||
|
||||
IFFmpegRenderer* FFmpegVideoDecoder::createHwAccelRenderer(const AVCodecHWConfig* hwDecodeCfg)
|
||||
{
|
||||
if (!(hwDecodeCfg->methods & AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX)) {
|
||||
return nullptr;
|
||||
@@ -352,26 +398,61 @@ IFFmpegRenderer* FFmpegVideoDecoder::createAcceleratedRenderer(const AVCodecHWCo
|
||||
}
|
||||
}
|
||||
|
||||
bool FFmpegVideoDecoder::initialize(
|
||||
StreamingPreferences::VideoDecoderSelection vds,
|
||||
SDL_Window* window,
|
||||
int videoFormat,
|
||||
int width,
|
||||
int height,
|
||||
int maxFps,
|
||||
bool enableVsync)
|
||||
bool FFmpegVideoDecoder::tryInitializeRenderer(AVCodec* decoder,
|
||||
PDECODER_PARAMETERS params,
|
||||
const AVCodecHWConfig* hwConfig,
|
||||
std::function<IFFmpegRenderer*()> createRendererFunc)
|
||||
{
|
||||
m_BackendRenderer = createRendererFunc();
|
||||
m_HwDecodeCfg = hwConfig;
|
||||
|
||||
if (m_BackendRenderer != nullptr &&
|
||||
m_BackendRenderer->initialize(params) &&
|
||||
completeInitialization(decoder, params, m_TestOnly || m_BackendRenderer->needsTestFrame())) {
|
||||
if (m_TestOnly) {
|
||||
// This decoder is only for testing capabilities, so don't bother
|
||||
// creating a usable renderer
|
||||
return true;
|
||||
}
|
||||
|
||||
if (m_BackendRenderer->needsTestFrame()) {
|
||||
// The test worked, so now let's initialize it for real
|
||||
reset();
|
||||
if ((m_BackendRenderer = createRendererFunc()) != nullptr &&
|
||||
m_BackendRenderer->initialize(params) &&
|
||||
completeInitialization(decoder, params, false)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Decoder failed to initialize after successful test");
|
||||
reset();
|
||||
}
|
||||
}
|
||||
else {
|
||||
// No test required. Good to go now.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Failed to initialize or test frame failed, so keep looking
|
||||
reset();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FFmpegVideoDecoder::initialize(PDECODER_PARAMETERS params)
|
||||
{
|
||||
AVCodec* decoder;
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
// Increase log level during initialization
|
||||
// Increase log level until the first frame is decoded
|
||||
av_log_set_level(AV_LOG_DEBUG);
|
||||
#endif
|
||||
|
||||
if (videoFormat & VIDEO_FORMAT_MASK_H264) {
|
||||
if (params->videoFormat & VIDEO_FORMAT_MASK_H264) {
|
||||
decoder = avcodec_find_decoder(AV_CODEC_ID_H264);
|
||||
}
|
||||
else if (videoFormat & VIDEO_FORMAT_MASK_H265) {
|
||||
else if (params->videoFormat & VIDEO_FORMAT_MASK_H265) {
|
||||
decoder = avcodec_find_decoder(AV_CODEC_ID_HEVC);
|
||||
}
|
||||
else {
|
||||
@@ -382,61 +463,71 @@ bool FFmpegVideoDecoder::initialize(
|
||||
if (!decoder) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Unable to find decoder for format: %x",
|
||||
videoFormat);
|
||||
params->videoFormat);
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0;; i++) {
|
||||
const AVCodecHWConfig *config = avcodec_get_hw_config(decoder, i);
|
||||
if (!config || vds == StreamingPreferences::VDS_FORCE_SOFTWARE) {
|
||||
// No matching hardware acceleration support.
|
||||
// This is not an error.
|
||||
m_HwDecodeCfg = nullptr;
|
||||
m_Renderer = new SdlRenderer();
|
||||
if (vds != StreamingPreferences::VDS_FORCE_HARDWARE &&
|
||||
m_Renderer->initialize(window, videoFormat, width, height, maxFps, enableVsync) &&
|
||||
completeInitialization(decoder, window, videoFormat, width, height, maxFps, enableVsync, false)) {
|
||||
return true;
|
||||
// Look for a hardware decoder first unless software-only
|
||||
if (params->vds != StreamingPreferences::VDS_FORCE_SOFTWARE) {
|
||||
// Look for the first matching hwaccel hardware decoder
|
||||
for (int i = 0;; i++) {
|
||||
const AVCodecHWConfig *config = avcodec_get_hw_config(decoder, i);
|
||||
if (!config) {
|
||||
// No remaing hwaccel options
|
||||
break;
|
||||
}
|
||||
else {
|
||||
reset();
|
||||
return false;
|
||||
|
||||
// Initialize the hardware codec and submit a test frame if the renderer needs it
|
||||
if (tryInitializeRenderer(decoder, params, config,
|
||||
[config]() -> IFFmpegRenderer* { return createHwAccelRenderer(config); })) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
m_Renderer = createAcceleratedRenderer(config);
|
||||
if (!m_Renderer) {
|
||||
continue;
|
||||
}
|
||||
// Continue with special non-hwaccel hardware decoders
|
||||
|
||||
m_HwDecodeCfg = config;
|
||||
// Initialize the hardware codec and submit a test frame if the renderer needs it
|
||||
if (m_Renderer->initialize(window, videoFormat, width, height, maxFps, enableVsync) &&
|
||||
completeInitialization(decoder, window, videoFormat, width, height, maxFps, enableVsync, m_Renderer->needsTestFrame())) {
|
||||
if (m_Renderer->needsTestFrame()) {
|
||||
// The test worked, so now let's initialize it for real
|
||||
reset();
|
||||
if ((m_Renderer = createAcceleratedRenderer(config)) != nullptr &&
|
||||
m_Renderer->initialize(window, videoFormat, width, height, maxFps, enableVsync) &&
|
||||
completeInitialization(decoder, window, videoFormat, width, height, maxFps, enableVsync, false)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION,
|
||||
"Decoder failed to initialize after successful test");
|
||||
reset();
|
||||
}
|
||||
}
|
||||
else {
|
||||
// No test required. Good to go now.
|
||||
#ifdef HAVE_MMAL
|
||||
// MMAL is the decoder for the Raspberry Pi
|
||||
if (params->videoFormat & VIDEO_FORMAT_MASK_H264) {
|
||||
AVCodec* mmalDecoder = avcodec_find_decoder_by_name("h264_mmal");
|
||||
if (mmalDecoder != nullptr &&
|
||||
tryInitializeRenderer(mmalDecoder, params, nullptr,
|
||||
[]() -> IFFmpegRenderer* { return new MmalRenderer(); })) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DRM
|
||||
// RKMPP is a hardware accelerated decoder that outputs DRI PRIME buffers
|
||||
AVCodec* rkmppDecoder;
|
||||
|
||||
if (params->videoFormat & VIDEO_FORMAT_MASK_H264) {
|
||||
rkmppDecoder = avcodec_find_decoder_by_name("h264_rkmpp");
|
||||
}
|
||||
else {
|
||||
// Failed to initialize or test frame failed, so keep looking
|
||||
reset();
|
||||
rkmppDecoder = avcodec_find_decoder_by_name("hevc_rkmpp");
|
||||
}
|
||||
|
||||
if (rkmppDecoder != nullptr &&
|
||||
tryInitializeRenderer(rkmppDecoder, params, nullptr,
|
||||
[]() -> IFFmpegRenderer* { return new DrmRenderer(); })) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Fallback to software if no matching hardware decoder was found
|
||||
// and if software fallback is allowed
|
||||
if (params->vds != StreamingPreferences::VDS_FORCE_HARDWARE) {
|
||||
if (tryInitializeRenderer(decoder, params, nullptr,
|
||||
[]() -> IFFmpegRenderer* { return new SdlRenderer(); })) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// No decoder worked
|
||||
return false;
|
||||
}
|
||||
|
||||
void FFmpegVideoDecoder::writeBuffer(PLENTRY entry, int& offset)
|
||||
@@ -487,16 +578,30 @@ int FFmpegVideoDecoder::submitDecodeUnit(PDECODE_UNIT du)
|
||||
PLENTRY entry = du->bufferList;
|
||||
int err;
|
||||
|
||||
// Flip stats windows roughly every second
|
||||
if (m_ActiveWndVideoStats.receivedFrames == m_StreamFps) {
|
||||
#if 0
|
||||
VIDEO_STATS lastTwoWndStats = {};
|
||||
addVideoStats(m_LastWndVideoStats, lastTwoWndStats);
|
||||
addVideoStats(m_ActiveWndVideoStats, lastTwoWndStats);
|
||||
SDL_assert(!m_TestOnly);
|
||||
|
||||
// Print stats from the last 2 windows
|
||||
logVideoStats(lastTwoWndStats, "Periodic video stats");
|
||||
#endif
|
||||
if (!m_LastFrameNumber) {
|
||||
m_ActiveWndVideoStats.measurementStartTimestamp = SDL_GetTicks();
|
||||
m_LastFrameNumber = du->frameNumber;
|
||||
}
|
||||
else {
|
||||
// Any frame number greater than m_LastFrameNumber + 1 represents a dropped frame
|
||||
m_ActiveWndVideoStats.networkDroppedFrames += du->frameNumber - (m_LastFrameNumber + 1);
|
||||
m_ActiveWndVideoStats.totalFrames += du->frameNumber - (m_LastFrameNumber + 1);
|
||||
m_LastFrameNumber = du->frameNumber;
|
||||
}
|
||||
|
||||
// Flip stats windows roughly every second
|
||||
if (SDL_TICKS_PASSED(SDL_GetTicks(), m_ActiveWndVideoStats.measurementStartTimestamp + 1000)) {
|
||||
// Update overlay stats if it's enabled
|
||||
if (Session::get()->getOverlayManager().isOverlayEnabled(Overlay::OverlayDebug)) {
|
||||
VIDEO_STATS lastTwoWndStats = {};
|
||||
addVideoStats(m_LastWndVideoStats, lastTwoWndStats);
|
||||
addVideoStats(m_ActiveWndVideoStats, lastTwoWndStats);
|
||||
|
||||
stringifyVideoStats(lastTwoWndStats, Session::get()->getOverlayManager().getOverlayText(Overlay::OverlayDebug));
|
||||
Session::get()->getOverlayManager().setOverlayTextUpdated(Overlay::OverlayDebug);
|
||||
}
|
||||
|
||||
// Accumulate these values into the global stats
|
||||
addVideoStats(m_ActiveWndVideoStats, m_GlobalVideoStats);
|
||||
@@ -508,25 +613,16 @@ int FFmpegVideoDecoder::submitDecodeUnit(PDECODE_UNIT du)
|
||||
}
|
||||
|
||||
m_ActiveWndVideoStats.receivedFrames++;
|
||||
|
||||
if (!m_LastFrameNumber) {
|
||||
m_ActiveWndVideoStats.measurementStartTimestamp = SDL_GetTicks();
|
||||
m_LastFrameNumber = du->frameNumber;
|
||||
}
|
||||
else {
|
||||
// Any frame number greater than m_LastFrameNumber + 1 represents a dropped frame
|
||||
m_ActiveWndVideoStats.networkDroppedFrames += du->frameNumber - (m_LastFrameNumber + 1);
|
||||
m_LastFrameNumber = du->frameNumber;
|
||||
}
|
||||
m_ActiveWndVideoStats.totalFrames++;
|
||||
|
||||
int requiredBufferSize = du->fullLength;
|
||||
if (du->frameType == FRAME_TYPE_IDR) {
|
||||
// Add some extra space in case we need to do an SPS fixup
|
||||
requiredBufferSize += MAX_SPS_EXTRA_SIZE;
|
||||
}
|
||||
if (requiredBufferSize + AV_INPUT_BUFFER_PADDING_SIZE > m_DecodeBuffer.length()) {
|
||||
m_DecodeBuffer = QByteArray(requiredBufferSize + AV_INPUT_BUFFER_PADDING_SIZE, 0);
|
||||
}
|
||||
|
||||
// Ensure the decoder buffer is large enough
|
||||
m_DecodeBuffer.reserve(requiredBufferSize + AV_INPUT_BUFFER_PADDING_SIZE);
|
||||
|
||||
int offset = 0;
|
||||
while (entry != nullptr) {
|
||||
@@ -577,14 +673,19 @@ int FFmpegVideoDecoder::submitDecodeUnit(PDECODE_UNIT du)
|
||||
// Reset failed decodes count if we reached this far
|
||||
m_ConsecutiveFailedDecodes = 0;
|
||||
|
||||
// Queue the frame for rendering from the main thread
|
||||
SDL_AtomicIncRef(&m_QueuedFrames);
|
||||
queueFrame(frame);
|
||||
// Restore default log level after a successful decode
|
||||
av_log_set_level(AV_LOG_INFO);
|
||||
|
||||
// Capture a frame timestamp to measuring pacing delay
|
||||
frame->pts = SDL_GetTicks();
|
||||
|
||||
// Count time in avcodec_send_packet() and avcodec_receive_frame()
|
||||
// as time spent decoding
|
||||
m_ActiveWndVideoStats.totalDecodeTime += SDL_GetTicks() - beforeDecode;
|
||||
m_ActiveWndVideoStats.decodedFrames++;
|
||||
|
||||
// Queue the frame for rendering (or render now if pacer is disabled)
|
||||
m_Pacer->submitFrame(frame);
|
||||
}
|
||||
else {
|
||||
av_frame_free(&frame);
|
||||
@@ -607,31 +708,8 @@ int FFmpegVideoDecoder::submitDecodeUnit(PDECODE_UNIT du)
|
||||
return DR_OK;
|
||||
}
|
||||
|
||||
// Called on main thread
|
||||
void FFmpegVideoDecoder::renderFrame(SDL_UserEvent* event)
|
||||
void FFmpegVideoDecoder::renderFrameOnMainThread()
|
||||
{
|
||||
AVFrame* frame = reinterpret_cast<AVFrame*>(event->data1);
|
||||
m_Pacer->submitFrame(frame);
|
||||
SDL_AtomicDecRef(&m_QueuedFrames);
|
||||
m_Pacer->renderOnMainThread();
|
||||
}
|
||||
|
||||
// Called on main thread
|
||||
void FFmpegVideoDecoder::dropFrame(SDL_UserEvent* event)
|
||||
{
|
||||
AVFrame* frame = reinterpret_cast<AVFrame*>(event->data1);
|
||||
// If Pacer is using a frame queue, we can just queue the
|
||||
// frame and let it decide whether to drop or not. If Pacer
|
||||
// is submitting directly for rendering, we drop the frame
|
||||
// ourselves.
|
||||
if (m_Pacer->isUsingFrameQueue()) {
|
||||
m_Pacer->submitFrame(frame);
|
||||
}
|
||||
else {
|
||||
av_frame_free(&frame);
|
||||
|
||||
// Since Pacer won't see this frame, we'll mark it as a drop
|
||||
// on its behalf
|
||||
m_ActiveWndVideoStats.pacerDroppedFrames++;
|
||||
}
|
||||
SDL_AtomicDecRef(&m_QueuedFrames);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "decoder.h"
|
||||
#include "ffmpeg-renderers/renderer.h"
|
||||
#include "ffmpeg-renderers/pacer/pacer.h"
|
||||
@@ -10,33 +12,33 @@ extern "C" {
|
||||
|
||||
class FFmpegVideoDecoder : public IVideoDecoder {
|
||||
public:
|
||||
FFmpegVideoDecoder();
|
||||
virtual ~FFmpegVideoDecoder();
|
||||
virtual bool initialize(StreamingPreferences::VideoDecoderSelection vds,
|
||||
SDL_Window* window,
|
||||
int videoFormat,
|
||||
int width,
|
||||
int height,
|
||||
int maxFps,
|
||||
bool enableVsync) override;
|
||||
FFmpegVideoDecoder(bool testOnly);
|
||||
virtual ~FFmpegVideoDecoder() override;
|
||||
virtual bool initialize(PDECODER_PARAMETERS params) override;
|
||||
virtual bool isHardwareAccelerated() override;
|
||||
virtual int getDecoderCapabilities() override;
|
||||
virtual int submitDecodeUnit(PDECODE_UNIT du) override;
|
||||
virtual void renderFrame(SDL_UserEvent* event) override;
|
||||
virtual void dropFrame(SDL_UserEvent* event) override;
|
||||
virtual void renderFrameOnMainThread() override;
|
||||
|
||||
virtual IFFmpegRenderer* getRenderer();
|
||||
virtual IFFmpegRenderer* getBackendRenderer();
|
||||
|
||||
private:
|
||||
bool completeInitialization(AVCodec* decoder, SDL_Window* window,
|
||||
int videoFormat, int width, int height,
|
||||
int maxFps, bool enableVsync, bool testOnly);
|
||||
bool completeInitialization(AVCodec* decoder, PDECODER_PARAMETERS params, bool testFrame);
|
||||
|
||||
void stringifyVideoStats(VIDEO_STATS& stats, char* output);
|
||||
|
||||
void logVideoStats(VIDEO_STATS& stats, const char* title);
|
||||
|
||||
void addVideoStats(VIDEO_STATS& src, VIDEO_STATS& dst);
|
||||
|
||||
IFFmpegRenderer* createAcceleratedRenderer(const AVCodecHWConfig* hwDecodeCfg);
|
||||
bool createFrontendRenderer(PDECODER_PARAMETERS params);
|
||||
|
||||
bool tryInitializeRenderer(AVCodec* decoder,
|
||||
PDECODER_PARAMETERS params,
|
||||
const AVCodecHWConfig* hwConfig,
|
||||
std::function<IFFmpegRenderer*()> createRendererFunc);
|
||||
|
||||
static IFFmpegRenderer* createHwAccelRenderer(const AVCodecHWConfig* hwDecodeCfg);
|
||||
|
||||
void reset();
|
||||
|
||||
@@ -50,16 +52,18 @@ private:
|
||||
AVCodecContext* m_VideoDecoderCtx;
|
||||
QByteArray m_DecodeBuffer;
|
||||
const AVCodecHWConfig* m_HwDecodeCfg;
|
||||
IFFmpegRenderer* m_Renderer;
|
||||
SDL_atomic_t m_QueuedFrames;
|
||||
IFFmpegRenderer* m_BackendRenderer;
|
||||
IFFmpegRenderer* m_FrontendRenderer;
|
||||
int m_ConsecutiveFailedDecodes;
|
||||
Pacer* m_Pacer;
|
||||
VIDEO_STATS m_ActiveWndVideoStats;
|
||||
VIDEO_STATS m_LastWndVideoStats;
|
||||
VIDEO_STATS m_GlobalVideoStats;
|
||||
|
||||
int m_LastFrameNumber;
|
||||
int m_StreamFps;
|
||||
bool m_NeedsSpsFixup;
|
||||
bool m_TestOnly;
|
||||
|
||||
static const uint8_t k_H264TestFrame[];
|
||||
static const uint8_t k_HEVCTestFrame[];
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
#include "overlaymanager.h"
|
||||
|
||||
using namespace Overlay;
|
||||
|
||||
OverlayManager::OverlayManager() :
|
||||
m_Renderer(nullptr)
|
||||
{
|
||||
memset(m_Overlays, 0, sizeof(m_Overlays));
|
||||
|
||||
m_Overlays[OverlayType::OverlayDebug].color = {0xD0, 0xD0, 0x00, 0xFF};
|
||||
m_Overlays[OverlayType::OverlayDebug].fontSize = 20;
|
||||
|
||||
m_Overlays[OverlayType::OverlayStatusUpdate].color = {0xCC, 0x00, 0x00, 0xFF};
|
||||
m_Overlays[OverlayType::OverlayStatusUpdate].fontSize = 36;
|
||||
}
|
||||
|
||||
bool OverlayManager::isOverlayEnabled(OverlayType type)
|
||||
{
|
||||
return m_Overlays[type].enabled;
|
||||
}
|
||||
|
||||
char* OverlayManager::getOverlayText(OverlayType type)
|
||||
{
|
||||
return m_Overlays[type].text;
|
||||
}
|
||||
|
||||
int OverlayManager::getOverlayFontSize(OverlayType type)
|
||||
{
|
||||
return m_Overlays[type].fontSize;
|
||||
}
|
||||
|
||||
void OverlayManager::setOverlayTextUpdated(OverlayType type)
|
||||
{
|
||||
// Only update the overlay state if it's enabled. If it's not enabled,
|
||||
// the renderer has already been notified by setOverlayState().
|
||||
if (m_Overlays[type].enabled && m_Renderer != nullptr) {
|
||||
m_Renderer->notifyOverlayUpdated(type);
|
||||
}
|
||||
}
|
||||
|
||||
void OverlayManager::setOverlayState(OverlayType type, bool enabled)
|
||||
{
|
||||
bool stateChanged = m_Overlays[type].enabled != enabled;
|
||||
|
||||
m_Overlays[type].enabled = enabled;
|
||||
|
||||
if (stateChanged) {
|
||||
if (!enabled) {
|
||||
// Set the text to empty string on disable
|
||||
m_Overlays[type].text[0] = 0;
|
||||
}
|
||||
|
||||
if (m_Renderer != nullptr) {
|
||||
m_Renderer->notifyOverlayUpdated(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SDL_Color OverlayManager::getOverlayColor(OverlayType type)
|
||||
{
|
||||
return m_Overlays[type].color;
|
||||
}
|
||||
|
||||
void OverlayManager::setOverlayRenderer(IOverlayRenderer* renderer)
|
||||
{
|
||||
m_Renderer = renderer;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
namespace Overlay {
|
||||
|
||||
enum OverlayType {
|
||||
OverlayDebug,
|
||||
OverlayStatusUpdate,
|
||||
OverlayMax
|
||||
};
|
||||
|
||||
class IOverlayRenderer
|
||||
{
|
||||
public:
|
||||
virtual ~IOverlayRenderer() = default;
|
||||
|
||||
virtual void notifyOverlayUpdated(OverlayType type) = 0;
|
||||
};
|
||||
|
||||
class OverlayManager
|
||||
{
|
||||
public:
|
||||
OverlayManager();
|
||||
|
||||
bool isOverlayEnabled(OverlayType type);
|
||||
char* getOverlayText(OverlayType type);
|
||||
void setOverlayTextUpdated(OverlayType type);
|
||||
void setOverlayState(OverlayType type, bool enabled);
|
||||
SDL_Color getOverlayColor(OverlayType type);
|
||||
int getOverlayFontSize(OverlayType type);
|
||||
|
||||
void setOverlayRenderer(IOverlayRenderer* renderer);
|
||||
|
||||
struct {
|
||||
bool enabled;
|
||||
int fontSize;
|
||||
SDL_Color color;
|
||||
char text[512];
|
||||
} m_Overlays[OverlayMax];
|
||||
IOverlayRenderer* m_Renderer;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "decoder.h"
|
||||
|
||||
#include <SLVideo.h>
|
||||
|
||||
class SLVideoDecoder : public IVideoDecoder
|
||||
{
|
||||
public:
|
||||
SLVideoDecoder();
|
||||
virtual ~SLVideoDecoder();
|
||||
virtual bool initialize(StreamingPreferences::VideoDecoderSelection vds,
|
||||
SDL_Window* window,
|
||||
int videoFormat,
|
||||
int width,
|
||||
int height,
|
||||
int frameRate,
|
||||
bool enableVsync);
|
||||
virtual bool isHardwareAccelerated();
|
||||
virtual int getDecoderCapabilities();
|
||||
virtual int submitDecodeUnit(PDECODE_UNIT du);
|
||||
|
||||
// Unused since rendering is done directly from the decode thread
|
||||
virtual void renderFrame(SDL_UserEvent*) {}
|
||||
virtual void dropFrame(SDL_UserEvent*) {}
|
||||
|
||||
private:
|
||||
CSLVideoContext* m_VideoContext;
|
||||
CSLVideoStream* m_VideoStream;
|
||||
};
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "sl.h"
|
||||
#include "slvid.h"
|
||||
|
||||
SLVideoDecoder::SLVideoDecoder()
|
||||
SLVideoDecoder::SLVideoDecoder(bool)
|
||||
: m_VideoContext(nullptr),
|
||||
m_VideoStream(nullptr)
|
||||
{
|
||||
|
||||
SLVideo_SetLogFunction(SLVideoDecoder::slLogCallback, nullptr);
|
||||
}
|
||||
|
||||
SLVideoDecoder::~SLVideoDecoder()
|
||||
@@ -32,17 +32,15 @@ SLVideoDecoder::getDecoderCapabilities()
|
||||
}
|
||||
|
||||
bool
|
||||
SLVideoDecoder::initialize(StreamingPreferences::VideoDecoderSelection vds,
|
||||
SDL_Window*,
|
||||
int videoFormat, int, int, int frameRate, bool)
|
||||
SLVideoDecoder::initialize(PDECODER_PARAMETERS params)
|
||||
{
|
||||
// SLVideo only supports hardware decoding
|
||||
if (vds == StreamingPreferences::VDS_FORCE_SOFTWARE) {
|
||||
if (params->vds == StreamingPreferences::VDS_FORCE_SOFTWARE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// SLVideo only supports H.264
|
||||
if (videoFormat != VIDEO_FORMAT_H264) {
|
||||
if (params->videoFormat != VIDEO_FORMAT_H264) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -61,7 +59,7 @@ SLVideoDecoder::initialize(StreamingPreferences::VideoDecoderSelection vds,
|
||||
return false;
|
||||
}
|
||||
|
||||
SLVideo_SetStreamTargetFramerate(m_VideoStream, frameRate, 1);
|
||||
SLVideo_SetStreamTargetFramerate(m_VideoStream, params->frameRate, 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -110,3 +108,30 @@ SLVideoDecoder::submitDecodeUnit(PDECODE_UNIT du)
|
||||
|
||||
return DR_OK;
|
||||
}
|
||||
|
||||
void SLVideoDecoder::slLogCallback(void*, ESLVideoLog logLevel, const char *message)
|
||||
{
|
||||
SDL_LogPriority priority;
|
||||
|
||||
switch (logLevel)
|
||||
{
|
||||
case k_ESLVideoLogError:
|
||||
priority = SDL_LOG_PRIORITY_ERROR;
|
||||
break;
|
||||
case k_ESLVideoLogWarning:
|
||||
priority = SDL_LOG_PRIORITY_WARN;
|
||||
break;
|
||||
case k_ESLVideoLogInfo:
|
||||
priority = SDL_LOG_PRIORITY_INFO;
|
||||
break;
|
||||
default:
|
||||
case k_ESLVideoLogDebug:
|
||||
priority = SDL_LOG_PRIORITY_DEBUG;
|
||||
break;
|
||||
}
|
||||
|
||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION,
|
||||
priority,
|
||||
"SLVideo: %s",
|
||||
message);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include "decoder.h"
|
||||
|
||||
#include <SLVideo.h>
|
||||
|
||||
class SLVideoDecoder : public IVideoDecoder
|
||||
{
|
||||
public:
|
||||
SLVideoDecoder(bool testOnly);
|
||||
virtual ~SLVideoDecoder();
|
||||
virtual bool initialize(PDECODER_PARAMETERS params);
|
||||
virtual bool isHardwareAccelerated();
|
||||
virtual int getDecoderCapabilities();
|
||||
virtual int submitDecodeUnit(PDECODE_UNIT du);
|
||||
|
||||
// Unused since rendering is done directly from the decode thread
|
||||
virtual void renderFrameOnMainThread() {}
|
||||
|
||||
private:
|
||||
static void slLogCallback(void* context, ESLVideoLog logLevel, const char* message);
|
||||
|
||||
CSLVideoContext* m_VideoContext;
|
||||
CSLVideoStream* m_VideoStream;
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
1.0.0
|
||||
@@ -0,0 +1,3 @@
|
||||
SOURCES = main.cpp
|
||||
LIBS += -lSLVideo -lSLAudio
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#include <SLVideo.h>
|
||||
#include <SLAudio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
SLVideo_CreateContext();
|
||||
SLAudio_CreateContext();
|
||||
return 0;
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
SOURCES = main.cpp
|
||||
LIBS += -lSLVideo
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
# Support debug and release builds from command line for CI
|
||||
CONFIG += debug_and_release
|
||||
|
||||
# Ensure symbols are always generated
|
||||
CONFIG += force_debug_info
|
||||
|
||||
# Disable asserts on release builds
|
||||
CONFIG(release, debug|release) {
|
||||
DEFINES += NDEBUG
|
||||
}
|
||||
|
||||
# Enable ASan if desired
|
||||
#CONFIG += sanitizer sanitize_address
|
||||
@@ -10,18 +10,15 @@ QT -= core gui
|
||||
TARGET = h264bitstream
|
||||
TEMPLATE = lib
|
||||
|
||||
# Support debug and release builds from command line for CI
|
||||
CONFIG += debug_and_release
|
||||
|
||||
# Ensure symbols are always generated
|
||||
CONFIG += force_debug_info
|
||||
|
||||
# Build a static library
|
||||
CONFIG += staticlib
|
||||
|
||||
# Disable warnings
|
||||
CONFIG += warn_off
|
||||
|
||||
# Include global qmake defs
|
||||
include(../globaldefs.pri)
|
||||
|
||||
# Older GCC versions defaulted to GNU89
|
||||
*-g++ {
|
||||
QMAKE_CFLAGS += -std=gnu99
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
#include "SDL_power.h"
|
||||
#include "SDL_render.h"
|
||||
#include "SDL_rwops.h"
|
||||
#include "SDL_sensor.h"
|
||||
#include "SDL_shape.h"
|
||||
#include "SDL_system.h"
|
||||
#include "SDL_thread.h"
|
||||
@@ -80,10 +81,11 @@ extern "C" {
|
||||
#define SDL_INIT_HAPTIC 0x00001000u
|
||||
#define SDL_INIT_GAMECONTROLLER 0x00002000u /**< SDL_INIT_GAMECONTROLLER implies SDL_INIT_JOYSTICK */
|
||||
#define SDL_INIT_EVENTS 0x00004000u
|
||||
#define SDL_INIT_SENSOR 0x00008000u
|
||||
#define SDL_INIT_NOPARACHUTE 0x00100000u /**< compatibility; this flag is ignored. */
|
||||
#define SDL_INIT_EVERYTHING ( \
|
||||
SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_EVENTS | \
|
||||
SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER \
|
||||
SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER | SDL_INIT_SENSOR \
|
||||
)
|
||||
/* @} */
|
||||
|
||||
|
||||
@@ -140,7 +140,8 @@ typedef Uint16 SDL_AudioFormat;
|
||||
#define SDL_AUDIO_ALLOW_FREQUENCY_CHANGE 0x00000001
|
||||
#define SDL_AUDIO_ALLOW_FORMAT_CHANGE 0x00000002
|
||||
#define SDL_AUDIO_ALLOW_CHANNELS_CHANGE 0x00000004
|
||||
#define SDL_AUDIO_ALLOW_ANY_CHANGE (SDL_AUDIO_ALLOW_FREQUENCY_CHANGE|SDL_AUDIO_ALLOW_FORMAT_CHANGE|SDL_AUDIO_ALLOW_CHANNELS_CHANGE)
|
||||
#define SDL_AUDIO_ALLOW_SAMPLES_CHANGE 0x00000008
|
||||
#define SDL_AUDIO_ALLOW_ANY_CHANGE (SDL_AUDIO_ALLOW_FREQUENCY_CHANGE|SDL_AUDIO_ALLOW_FORMAT_CHANGE|SDL_AUDIO_ALLOW_CHANNELS_CHANGE|SDL_AUDIO_ALLOW_SAMPLES_CHANGE)
|
||||
/* @} */
|
||||
|
||||
/* @} *//* Audio flags */
|
||||
|
||||
@@ -41,8 +41,10 @@
|
||||
#include "SDL_config_android.h"
|
||||
#elif defined(__PSP__)
|
||||
#include "SDL_config_psp.h"
|
||||
#elif defined(__OS2__)
|
||||
#include "SDL_config_os2.h"
|
||||
#else
|
||||
/* This is a minimal configuration just to get SDL running on new platforms */
|
||||
/* This is a minimal configuration just to get SDL running on new platforms. */
|
||||
#include "SDL_config_minimal.h"
|
||||
#endif /* platform config */
|
||||
|
||||
|
||||
@@ -102,6 +102,8 @@
|
||||
#define HAVE_COPYSIGNF 1
|
||||
#define HAVE_COS 1
|
||||
#define HAVE_COSF 1
|
||||
#define HAVE_EXP 1
|
||||
#define HAVE_EXPF 1
|
||||
#define HAVE_FABS 1
|
||||
#define HAVE_FABSF 1
|
||||
#define HAVE_FLOOR 1
|
||||
@@ -135,8 +137,12 @@
|
||||
|
||||
/* Enable various input drivers */
|
||||
#define SDL_JOYSTICK_IOKIT 1
|
||||
#define SDL_JOYSTICK_HIDAPI 1
|
||||
#define SDL_HAPTIC_IOKIT 1
|
||||
|
||||
/* Enable the dummy sensor driver */
|
||||
#define SDL_SENSOR_DUMMY 1
|
||||
|
||||
/* Enable various shared object loading systems */
|
||||
#define SDL_LOADSO_DLOPEN 1
|
||||
|
||||
|
||||
@@ -51,16 +51,19 @@
|
||||
#include <intrin.h>
|
||||
#else
|
||||
#ifdef __ALTIVEC__
|
||||
#if HAVE_ALTIVEC_H && !defined(__APPLE_ALTIVEC__) && !defined(SDL_DISABLE_ALTIVEC_H)
|
||||
#if defined(HAVE_ALTIVEC_H) && !defined(__APPLE_ALTIVEC__) && !defined(SDL_DISABLE_ALTIVEC_H)
|
||||
#include <altivec.h>
|
||||
#undef pixel
|
||||
#undef bool
|
||||
#endif
|
||||
#endif
|
||||
#if defined(__ARM_NEON__) && !defined(SDL_DISABLE_ARM_NEON_H)
|
||||
#include <arm_neon.h>
|
||||
#endif
|
||||
#if defined(__3dNOW__) && !defined(SDL_DISABLE_MM3DNOW_H)
|
||||
#include <mm3dnow.h>
|
||||
#endif
|
||||
#if HAVE_IMMINTRIN_H && !defined(SDL_DISABLE_IMMINTRIN_H)
|
||||
#if defined(HAVE_IMMINTRIN_H) && !defined(SDL_DISABLE_IMMINTRIN_H)
|
||||
#include <immintrin.h>
|
||||
#else
|
||||
#if defined(__MMX__) && !defined(SDL_DISABLE_MMINTRIN_H)
|
||||
@@ -159,6 +162,11 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX(void);
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX2(void);
|
||||
|
||||
/**
|
||||
* This function returns true if the CPU has AVX-512F (foundation) features.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX512F(void);
|
||||
|
||||
/**
|
||||
* This function returns true if the CPU has NEON (ARM SIMD) features.
|
||||
*/
|
||||
@@ -169,7 +177,6 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasNEON(void);
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetSystemRAM(void);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -85,6 +85,9 @@ typedef enum
|
||||
Called on Android in onResume()
|
||||
*/
|
||||
|
||||
/* Display events */
|
||||
SDL_DISPLAYEVENT = 0x150, /**< Display state change */
|
||||
|
||||
/* Window events */
|
||||
SDL_WINDOWEVENT = 0x200, /**< Window state change */
|
||||
SDL_SYSWMEVENT, /**< System specific event */
|
||||
@@ -144,6 +147,9 @@ typedef enum
|
||||
SDL_AUDIODEVICEADDED = 0x1100, /**< A new audio device is available */
|
||||
SDL_AUDIODEVICEREMOVED, /**< An audio device has been removed. */
|
||||
|
||||
/* Sensor events */
|
||||
SDL_SENSORUPDATE = 0x1200, /**< A sensor was updated */
|
||||
|
||||
/* Render events */
|
||||
SDL_RENDER_TARGETS_RESET = 0x2000, /**< The render targets have been reset and their contents need to be updated */
|
||||
SDL_RENDER_DEVICE_RESET, /**< The device has been reset and all textures need to be recreated */
|
||||
@@ -168,6 +174,21 @@ typedef struct SDL_CommonEvent
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
} SDL_CommonEvent;
|
||||
|
||||
/**
|
||||
* \brief Display state change event data (event.display.*)
|
||||
*/
|
||||
typedef struct SDL_DisplayEvent
|
||||
{
|
||||
Uint32 type; /**< ::SDL_DISPLAYEVENT */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
Uint32 display; /**< The associated display index */
|
||||
Uint8 event; /**< ::SDL_DisplayEventID */
|
||||
Uint8 padding1;
|
||||
Uint8 padding2;
|
||||
Uint8 padding3;
|
||||
Sint32 data1; /**< event dependent data */
|
||||
} SDL_DisplayEvent;
|
||||
|
||||
/**
|
||||
* \brief Window state change event data (event.window.*)
|
||||
*/
|
||||
@@ -471,6 +492,17 @@ typedef struct SDL_DropEvent
|
||||
} SDL_DropEvent;
|
||||
|
||||
|
||||
/**
|
||||
* \brief Sensor event structure (event.sensor.*)
|
||||
*/
|
||||
typedef struct SDL_SensorEvent
|
||||
{
|
||||
Uint32 type; /**< ::SDL_SENSORUPDATE */
|
||||
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
|
||||
Sint32 which; /**< The instance ID of the sensor */
|
||||
float data[6]; /**< Up to 6 values from the sensor - additional values can be queried using SDL_SensorGetData() */
|
||||
} SDL_SensorEvent;
|
||||
|
||||
/**
|
||||
* \brief The "quit requested" event
|
||||
*/
|
||||
@@ -526,6 +558,7 @@ typedef union SDL_Event
|
||||
{
|
||||
Uint32 type; /**< Event type, shared with all events */
|
||||
SDL_CommonEvent common; /**< Common event data */
|
||||
SDL_DisplayEvent display; /**< Window event data */
|
||||
SDL_WindowEvent window; /**< Window event data */
|
||||
SDL_KeyboardEvent key; /**< Keyboard event data */
|
||||
SDL_TextEditingEvent edit; /**< Text editing event data */
|
||||
@@ -542,6 +575,7 @@ typedef union SDL_Event
|
||||
SDL_ControllerButtonEvent cbutton; /**< Game Controller button event data */
|
||||
SDL_ControllerDeviceEvent cdevice; /**< Game Controller device event data */
|
||||
SDL_AudioDeviceEvent adevice; /**< Audio device event data */
|
||||
SDL_SensorEvent sensor; /**< Sensor event data */
|
||||
SDL_QuitEvent quit; /**< Quit request event data */
|
||||
SDL_UserEvent user; /**< Custom event data */
|
||||
SDL_SysWMEvent syswm; /**< System dependent window event data */
|
||||
|
||||
@@ -175,6 +175,14 @@ extern DECLSPEC SDL_bool SDLCALL SDL_IsGameController(int joystick_index);
|
||||
*/
|
||||
extern DECLSPEC const char *SDLCALL SDL_GameControllerNameForIndex(int joystick_index);
|
||||
|
||||
/**
|
||||
* Get the mapping of a game controller.
|
||||
* This can be called before any controllers are opened.
|
||||
*
|
||||
* \return the mapping string. Must be freed with SDL_free(). Returns NULL if no mapping is available
|
||||
*/
|
||||
extern DECLSPEC char *SDLCALL SDL_GameControllerMappingForDeviceIndex(int joystick_index);
|
||||
|
||||
/**
|
||||
* Open a game controller for use.
|
||||
* The index passed as an argument refers to the N'th game controller on the system.
|
||||
@@ -196,6 +204,13 @@ extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerFromInstanceID(SDL
|
||||
*/
|
||||
extern DECLSPEC const char *SDLCALL SDL_GameControllerName(SDL_GameController *gamecontroller);
|
||||
|
||||
/**
|
||||
* Get the player index of an opened game controller, or -1 if it's not available
|
||||
*
|
||||
* For XInput controllers this returns the XInput user index.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GameControllerGetPlayerIndex(SDL_GameController *gamecontroller);
|
||||
|
||||
/**
|
||||
* Get the USB vendor ID of an opened controller, if available.
|
||||
* If the vendor ID isn't available this function returns 0.
|
||||
@@ -345,6 +360,19 @@ SDL_GameControllerGetBindForButton(SDL_GameController *gamecontroller,
|
||||
extern DECLSPEC Uint8 SDLCALL SDL_GameControllerGetButton(SDL_GameController *gamecontroller,
|
||||
SDL_GameControllerButton button);
|
||||
|
||||
/**
|
||||
* Trigger a rumble effect
|
||||
* Each call to this function cancels any previous rumble effect, and calling it with 0 intensity stops any rumbling.
|
||||
*
|
||||
* \param gamecontroller The controller to vibrate
|
||||
* \param low_frequency_rumble The intensity of the low frequency (left) rumble motor, from 0 to 0xFFFF
|
||||
* \param high_frequency_rumble The intensity of the high frequency (right) rumble motor, from 0 to 0xFFFF
|
||||
* \param duration_ms The duration of the rumble effect, in milliseconds
|
||||
*
|
||||
* \return 0, or -1 if rumble isn't supported on this joystick
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GameControllerRumble(SDL_GameController *gamecontroller, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
|
||||
|
||||
/**
|
||||
* Close a controller previously opened with SDL_GameControllerOpen().
|
||||
*/
|
||||
|
||||
@@ -117,6 +117,17 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* FIXME: For SDL 2.1, adjust all the magnitude variables to be Uint16 (0xFFFF).
|
||||
*
|
||||
* At the moment the magnitude variables are mixed between signed/unsigned, and
|
||||
* it is also not made clear that ALL of those variables expect a max of 0x7FFF.
|
||||
*
|
||||
* Some platforms may have higher precision than that (Linux FF, Windows XInput)
|
||||
* so we should fix the inconsistency in favor of higher possible precision,
|
||||
* adjusting for platforms that use different scales.
|
||||
* -flibit
|
||||
*/
|
||||
|
||||
/**
|
||||
* \typedef SDL_Haptic
|
||||
*
|
||||
@@ -656,8 +667,8 @@ typedef struct SDL_HapticRamp
|
||||
* This struct is exclusively for the ::SDL_HAPTIC_LEFTRIGHT effect.
|
||||
*
|
||||
* The Left/Right effect is used to explicitly control the large and small
|
||||
* motors, commonly found in modern game controllers. One motor is high
|
||||
* frequency, the other is low frequency.
|
||||
* motors, commonly found in modern game controllers. The small (right) motor
|
||||
* is high frequency, and the large (left) motor is low frequency.
|
||||
*
|
||||
* \sa SDL_HAPTIC_LEFTRIGHT
|
||||
* \sa SDL_HapticEffect
|
||||
@@ -668,7 +679,7 @@ typedef struct SDL_HapticLeftRight
|
||||
Uint16 type; /**< ::SDL_HAPTIC_LEFTRIGHT */
|
||||
|
||||
/* Replay */
|
||||
Uint32 length; /**< Duration of the effect. */
|
||||
Uint32 length; /**< Duration of the effect in milliseconds. */
|
||||
|
||||
/* Rumble */
|
||||
Uint16 large_magnitude; /**< Control of the large controller motor. */
|
||||
|
||||
@@ -262,6 +262,16 @@ extern "C" {
|
||||
*/
|
||||
#define SDL_HINT_GRAB_KEYBOARD "SDL_GRAB_KEYBOARD"
|
||||
|
||||
/**
|
||||
* \brief A variable setting the double click time, in milliseconds.
|
||||
*/
|
||||
#define SDL_HINT_MOUSE_DOUBLE_CLICK_TIME "SDL_MOUSE_DOUBLE_CLICK_TIME"
|
||||
|
||||
/**
|
||||
* \brief A variable setting the double click radius, in pixels.
|
||||
*/
|
||||
#define SDL_HINT_MOUSE_DOUBLE_CLICK_RADIUS "SDL_MOUSE_DOUBLE_CLICK_RADIUS"
|
||||
|
||||
/**
|
||||
* \brief A variable setting the speed scale for mouse motion, in floating point, when the mouse is not in relative mode
|
||||
*/
|
||||
@@ -329,7 +339,7 @@ extern "C" {
|
||||
#define SDL_HINT_IDLE_TIMER_DISABLED "SDL_IOS_IDLE_TIMER_DISABLED"
|
||||
|
||||
/**
|
||||
* \brief A variable controlling which orientations are allowed on iOS.
|
||||
* \brief A variable controlling which orientations are allowed on iOS/Android.
|
||||
*
|
||||
* In some circumstances it is necessary to be able to explicitly control
|
||||
* which UI orientations are allowed.
|
||||
@@ -465,6 +475,88 @@ extern "C" {
|
||||
*/
|
||||
#define SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS "SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS"
|
||||
|
||||
/**
|
||||
* \brief A variable controlling whether the HIDAPI joystick drivers should be used.
|
||||
*
|
||||
* This variable can be set to the following values:
|
||||
* "0" - HIDAPI drivers are not used
|
||||
* "1" - HIDAPI drivers are used (the default)
|
||||
*
|
||||
* This variable is the default for all drivers, but can be overridden by the hints for specific drivers below.
|
||||
*/
|
||||
#define SDL_HINT_JOYSTICK_HIDAPI "SDL_JOYSTICK_HIDAPI"
|
||||
|
||||
/**
|
||||
* \brief A variable controlling whether the HIDAPI driver for PS4 controllers should be used.
|
||||
*
|
||||
* This variable can be set to the following values:
|
||||
* "0" - HIDAPI driver is not used
|
||||
* "1" - HIDAPI driver is used
|
||||
*
|
||||
* The default is the value of SDL_HINT_JOYSTICK_HIDAPI
|
||||
*/
|
||||
#define SDL_HINT_JOYSTICK_HIDAPI_PS4 "SDL_JOYSTICK_HIDAPI_PS4"
|
||||
|
||||
/**
|
||||
* \brief A variable controlling whether extended input reports should be used for PS4 controllers when using the HIDAPI driver.
|
||||
*
|
||||
* This variable can be set to the following values:
|
||||
* "0" - extended reports are not enabled (the default)
|
||||
* "1" - extended reports
|
||||
*
|
||||
* Extended input reports allow rumble on Bluetooth PS4 controllers, but
|
||||
* break DirectInput handling for applications that don't use SDL.
|
||||
*
|
||||
* Once extended reports are enabled, they can not be disabled without
|
||||
* power cycling the controller.
|
||||
*/
|
||||
#define SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE "SDL_JOYSTICK_HIDAPI_PS4_RUMBLE"
|
||||
|
||||
/**
|
||||
* \brief A variable controlling whether the HIDAPI driver for Steam Controllers should be used.
|
||||
*
|
||||
* This variable can be set to the following values:
|
||||
* "0" - HIDAPI driver is not used
|
||||
* "1" - HIDAPI driver is used
|
||||
*
|
||||
* The default is the value of SDL_HINT_JOYSTICK_HIDAPI
|
||||
*/
|
||||
#define SDL_HINT_JOYSTICK_HIDAPI_STEAM "SDL_JOYSTICK_HIDAPI_STEAM"
|
||||
|
||||
/**
|
||||
* \brief A variable controlling whether the HIDAPI driver for Nintendo Switch controllers should be used.
|
||||
*
|
||||
* This variable can be set to the following values:
|
||||
* "0" - HIDAPI driver is not used
|
||||
* "1" - HIDAPI driver is used
|
||||
*
|
||||
* The default is the value of SDL_HINT_JOYSTICK_HIDAPI
|
||||
*/
|
||||
#define SDL_HINT_JOYSTICK_HIDAPI_SWITCH "SDL_JOYSTICK_HIDAPI_SWITCH"
|
||||
|
||||
/**
|
||||
* \brief A variable controlling whether the HIDAPI driver for XBox controllers should be used.
|
||||
*
|
||||
* This variable can be set to the following values:
|
||||
* "0" - HIDAPI driver is not used
|
||||
* "1" - HIDAPI driver is used
|
||||
*
|
||||
* The default is the value of SDL_HINT_JOYSTICK_HIDAPI
|
||||
*/
|
||||
#define SDL_HINT_JOYSTICK_HIDAPI_XBOX "SDL_JOYSTICK_HIDAPI_XBOX"
|
||||
|
||||
/**
|
||||
* \brief A variable that controls whether Steam Controllers should be exposed using the SDL joystick and game controller APIs
|
||||
*
|
||||
* The variable can be set to the following values:
|
||||
* "0" - Do not scan for Steam Controllers
|
||||
* "1" - Scan for Steam Controllers (the default)
|
||||
*
|
||||
* The default value is "1". This hint must be set before initializing the joystick subsystem.
|
||||
*/
|
||||
#define SDL_HINT_ENABLE_STEAM_CONTROLLERS "SDL_ENABLE_STEAM_CONTROLLERS"
|
||||
|
||||
|
||||
/**
|
||||
* \brief If set to "0" then never set the top most bit on a SDL Window, even if the video mode expects it.
|
||||
* This is a debugging aid for developers and not expected to be used by end users. The default is "1"
|
||||
@@ -527,6 +619,10 @@ extern "C" {
|
||||
* This is specially useful if you build SDL against a non glibc libc library (such as musl) which
|
||||
* provides a relatively small default thread stack size (a few kilobytes versus the default 8MB glibc uses).
|
||||
* Support for this hint is currently available only in the pthread, Windows, and PSP backend.
|
||||
*
|
||||
* Instead of this hint, in 2.0.9 and later, you can use
|
||||
* SDL_CreateThreadWithStackSize(). This hint only works with the classic
|
||||
* SDL_CreateThread().
|
||||
*/
|
||||
#define SDL_HINT_THREAD_STACK_SIZE "SDL_THREAD_STACK_SIZE"
|
||||
|
||||
@@ -752,6 +848,23 @@ extern "C" {
|
||||
*/
|
||||
#define SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH "SDL_ANDROID_SEPARATE_MOUSE_AND_TOUCH"
|
||||
|
||||
/**
|
||||
* \brief A variable to control whether we trap the Android back button to handle it manually.
|
||||
* This is necessary for the right mouse button to work on some Android devices, or
|
||||
* to be able to trap the back button for use in your code reliably. If set to true,
|
||||
* the back button will show up as an SDL_KEYDOWN / SDL_KEYUP pair with a keycode of
|
||||
* SDL_SCANCODE_AC_BACK.
|
||||
*
|
||||
* The variable can be set to the following values:
|
||||
* "0" - Back button will be handled as usual for system. (default)
|
||||
* "1" - Back button will be trapped, allowing you to handle the key press
|
||||
* manually. (This will also let right mouse click work on systems
|
||||
* where the right mouse button functions as back.)
|
||||
*
|
||||
* The value of this hint is used at runtime, so it can be changed at any time.
|
||||
*/
|
||||
#define SDL_HINT_ANDROID_TRAP_BACK_BUTTON "SDL_ANDROID_TRAP_BACK_BUTTON"
|
||||
|
||||
/**
|
||||
* \brief A variable to control whether the return key on the soft keyboard
|
||||
* should hide the soft keyboard on Android and iOS.
|
||||
|
||||
@@ -97,10 +97,10 @@ typedef enum
|
||||
typedef enum
|
||||
{
|
||||
SDL_JOYSTICK_POWER_UNKNOWN = -1,
|
||||
SDL_JOYSTICK_POWER_EMPTY,
|
||||
SDL_JOYSTICK_POWER_LOW,
|
||||
SDL_JOYSTICK_POWER_MEDIUM,
|
||||
SDL_JOYSTICK_POWER_FULL,
|
||||
SDL_JOYSTICK_POWER_EMPTY, /* <= 5% */
|
||||
SDL_JOYSTICK_POWER_LOW, /* <= 20% */
|
||||
SDL_JOYSTICK_POWER_MEDIUM, /* <= 70% */
|
||||
SDL_JOYSTICK_POWER_FULL, /* <= 100% */
|
||||
SDL_JOYSTICK_POWER_WIRED,
|
||||
SDL_JOYSTICK_POWER_MAX
|
||||
} SDL_JoystickPowerLevel;
|
||||
@@ -132,6 +132,12 @@ extern DECLSPEC int SDLCALL SDL_NumJoysticks(void);
|
||||
*/
|
||||
extern DECLSPEC const char *SDLCALL SDL_JoystickNameForIndex(int device_index);
|
||||
|
||||
/**
|
||||
* Get the player index of a joystick, or -1 if it's not available
|
||||
* This can be called before any joysticks are opened.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickGetDevicePlayerIndex(int device_index);
|
||||
|
||||
/**
|
||||
* Return the GUID for the joystick at this index
|
||||
* This can be called before any joysticks are opened.
|
||||
@@ -194,6 +200,13 @@ extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickFromInstanceID(SDL_JoystickID
|
||||
*/
|
||||
extern DECLSPEC const char *SDLCALL SDL_JoystickName(SDL_Joystick * joystick);
|
||||
|
||||
/**
|
||||
* Get the player index of an opened joystick, or -1 if it's not available
|
||||
*
|
||||
* For XInput controllers this returns the XInput user index.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickGetPlayerIndex(SDL_Joystick * joystick);
|
||||
|
||||
/**
|
||||
* Return the GUID for this opened joystick
|
||||
*/
|
||||
@@ -361,6 +374,19 @@ extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick * joystick,
|
||||
extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick * joystick,
|
||||
int button);
|
||||
|
||||
/**
|
||||
* Trigger a rumble effect
|
||||
* Each call to this function cancels any previous rumble effect, and calling it with 0 intensity stops any rumbling.
|
||||
*
|
||||
* \param joystick The joystick to vibrate
|
||||
* \param low_frequency_rumble The intensity of the low frequency (left) rumble motor, from 0 to 0xFFFF
|
||||
* \param high_frequency_rumble The intensity of the high frequency (right) rumble motor, from 0 to 0xFFFF
|
||||
* \param duration_ms The duration of the rumble effect, in milliseconds
|
||||
*
|
||||
* \return 0, or -1 if rumble isn't supported on this joystick
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
|
||||
|
||||
/**
|
||||
* Close a joystick previously opened with SDL_JoystickOpen().
|
||||
*/
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
#define SDL_REVISION "hg-11914:f1084c419f33"
|
||||
#define SDL_REVISION_NUMBER 11914
|
||||
#define SDL_REVISION "hg-0:aaaaaaaaaaah"
|
||||
#define SDL_REVISION_NUMBER 0
|
||||
|
||||
@@ -0,0 +1,251 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file SDL_sensor.h
|
||||
*
|
||||
* Include file for SDL sensor event handling
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _SDL_sensor_h
|
||||
#define _SDL_sensor_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
extern "C" {
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief SDL_sensor.h
|
||||
*
|
||||
* In order to use these functions, SDL_Init() must have been called
|
||||
* with the ::SDL_INIT_SENSOR flag. This causes SDL to scan the system
|
||||
* for sensors, and load appropriate drivers.
|
||||
*/
|
||||
|
||||
struct _SDL_Sensor;
|
||||
typedef struct _SDL_Sensor SDL_Sensor;
|
||||
|
||||
/**
|
||||
* This is a unique ID for a sensor for the time it is connected to the system,
|
||||
* and is never reused for the lifetime of the application.
|
||||
*
|
||||
* The ID value starts at 0 and increments from there. The value -1 is an invalid ID.
|
||||
*/
|
||||
typedef Sint32 SDL_SensorID;
|
||||
|
||||
/* The different sensors defined by SDL
|
||||
*
|
||||
* Additional sensors may be available, using platform dependent semantics.
|
||||
*
|
||||
* Hare are the additional Android sensors:
|
||||
* https://developer.android.com/reference/android/hardware/SensorEvent.html#values
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SDL_SENSOR_INVALID = -1, /**< Returned for an invalid sensor */
|
||||
SDL_SENSOR_UNKNOWN, /**< Unknown sensor type */
|
||||
SDL_SENSOR_ACCEL, /**< Accelerometer */
|
||||
SDL_SENSOR_GYRO /**< Gyroscope */
|
||||
} SDL_SensorType;
|
||||
|
||||
/**
|
||||
* Accelerometer sensor
|
||||
*
|
||||
* The accelerometer returns the current acceleration in SI meters per
|
||||
* second squared. This includes gravity, so a device at rest will have
|
||||
* an acceleration of SDL_STANDARD_GRAVITY straight down.
|
||||
*
|
||||
* values[0]: Acceleration on the x axis
|
||||
* values[1]: Acceleration on the y axis
|
||||
* values[2]: Acceleration on the z axis
|
||||
*
|
||||
* For phones held in portrait mode, the axes are defined as follows:
|
||||
* -X ... +X : left ... right
|
||||
* -Y ... +Y : bottom ... top
|
||||
* -Z ... +Z : farther ... closer
|
||||
*
|
||||
* The axis data is not changed when the phone is rotated.
|
||||
*
|
||||
* \sa SDL_GetDisplayOrientation()
|
||||
*/
|
||||
#define SDL_STANDARD_GRAVITY 9.80665f
|
||||
|
||||
/**
|
||||
* Gyroscope sensor
|
||||
*
|
||||
* The gyroscope returns the current rate of rotation in radians per second.
|
||||
* The rotation is positive in the counter-clockwise direction. That is,
|
||||
* an observer looking from a positive location on one of the axes would
|
||||
* see positive rotation on that axis when it appeared to be rotating
|
||||
* counter-clockwise.
|
||||
*
|
||||
* values[0]: Angular speed around the x axis
|
||||
* values[1]: Angular speed around the y axis
|
||||
* values[2]: Angular speed around the z axis
|
||||
*
|
||||
* For phones held in portrait mode, the axes are defined as follows:
|
||||
* -X ... +X : left ... right
|
||||
* -Y ... +Y : bottom ... top
|
||||
* -Z ... +Z : farther ... closer
|
||||
*
|
||||
* The axis data is not changed when the phone is rotated.
|
||||
*
|
||||
* \sa SDL_GetDisplayOrientation()
|
||||
*/
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
/**
|
||||
* \brief Count the number of sensors attached to the system right now
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_NumSensors(void);
|
||||
|
||||
/**
|
||||
* \brief Get the implementation dependent name of a sensor.
|
||||
*
|
||||
* This can be called before any sensors are opened.
|
||||
*
|
||||
* \return The sensor name, or NULL if device_index is out of range.
|
||||
*/
|
||||
extern DECLSPEC const char *SDLCALL SDL_SensorGetDeviceName(int device_index);
|
||||
|
||||
/**
|
||||
* \brief Get the type of a sensor.
|
||||
*
|
||||
* This can be called before any sensors are opened.
|
||||
*
|
||||
* \return The sensor type, or SDL_SENSOR_INVALID if device_index is out of range.
|
||||
*/
|
||||
extern DECLSPEC SDL_SensorType SDLCALL SDL_SensorGetDeviceType(int device_index);
|
||||
|
||||
/**
|
||||
* \brief Get the platform dependent type of a sensor.
|
||||
*
|
||||
* This can be called before any sensors are opened.
|
||||
*
|
||||
* \return The sensor platform dependent type, or -1 if device_index is out of range.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SensorGetDeviceNonPortableType(int device_index);
|
||||
|
||||
/**
|
||||
* \brief Get the instance ID of a sensor.
|
||||
*
|
||||
* This can be called before any sensors are opened.
|
||||
*
|
||||
* \return The sensor instance ID, or -1 if device_index is out of range.
|
||||
*/
|
||||
extern DECLSPEC SDL_SensorID SDLCALL SDL_SensorGetDeviceInstanceID(int device_index);
|
||||
|
||||
/**
|
||||
* \brief Open a sensor for use.
|
||||
*
|
||||
* The index passed as an argument refers to the N'th sensor on the system.
|
||||
*
|
||||
* \return A sensor identifier, or NULL if an error occurred.
|
||||
*/
|
||||
extern DECLSPEC SDL_Sensor *SDLCALL SDL_SensorOpen(int device_index);
|
||||
|
||||
/**
|
||||
* Return the SDL_Sensor associated with an instance id.
|
||||
*/
|
||||
extern DECLSPEC SDL_Sensor *SDLCALL SDL_SensorFromInstanceID(SDL_SensorID instance_id);
|
||||
|
||||
/**
|
||||
* \brief Get the implementation dependent name of a sensor.
|
||||
*
|
||||
* \return The sensor name, or NULL if the sensor is NULL.
|
||||
*/
|
||||
extern DECLSPEC const char *SDLCALL SDL_SensorGetName(SDL_Sensor *sensor);
|
||||
|
||||
/**
|
||||
* \brief Get the type of a sensor.
|
||||
*
|
||||
* This can be called before any sensors are opened.
|
||||
*
|
||||
* \return The sensor type, or SDL_SENSOR_INVALID if the sensor is NULL.
|
||||
*/
|
||||
extern DECLSPEC SDL_SensorType SDLCALL SDL_SensorGetType(SDL_Sensor *sensor);
|
||||
|
||||
/**
|
||||
* \brief Get the platform dependent type of a sensor.
|
||||
*
|
||||
* This can be called before any sensors are opened.
|
||||
*
|
||||
* \return The sensor platform dependent type, or -1 if the sensor is NULL.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SensorGetNonPortableType(SDL_Sensor *sensor);
|
||||
|
||||
/**
|
||||
* \brief Get the instance ID of a sensor.
|
||||
*
|
||||
* This can be called before any sensors are opened.
|
||||
*
|
||||
* \return The sensor instance ID, or -1 if the sensor is NULL.
|
||||
*/
|
||||
extern DECLSPEC SDL_SensorID SDLCALL SDL_SensorGetInstanceID(SDL_Sensor *sensor);
|
||||
|
||||
/**
|
||||
* Get the current state of an opened sensor.
|
||||
*
|
||||
* The number of values and interpretation of the data is sensor dependent.
|
||||
*
|
||||
* \param sensor The sensor to query
|
||||
* \param data A pointer filled with the current sensor state
|
||||
* \param num_values The number of values to write to data
|
||||
*
|
||||
* \return 0 or -1 if an error occurred.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SensorGetData(SDL_Sensor * sensor, float *data, int num_values);
|
||||
|
||||
/**
|
||||
* Close a sensor previously opened with SDL_SensorOpen()
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_SensorClose(SDL_Sensor * sensor);
|
||||
|
||||
/**
|
||||
* Update the current state of the open sensors.
|
||||
*
|
||||
* This is called automatically by the event loop if sensor events are enabled.
|
||||
*
|
||||
* This needs to be called from the thread that initialized the sensor subsystem.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_SensorUpdate(void);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
/* *INDENT-OFF* */
|
||||
}
|
||||
/* *INDENT-ON* */
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* _SDL_sensor_h */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -86,6 +86,28 @@
|
||||
#ifdef HAVE_FLOAT_H
|
||||
# include <float.h>
|
||||
#endif
|
||||
#if defined(HAVE_ALLOCA) && !defined(alloca)
|
||||
# if defined(HAVE_ALLOCA_H)
|
||||
# include <alloca.h>
|
||||
# elif defined(__GNUC__)
|
||||
# define alloca __builtin_alloca
|
||||
# elif defined(_MSC_VER)
|
||||
# include <malloc.h>
|
||||
# define alloca _alloca
|
||||
# elif defined(__WATCOMC__)
|
||||
# include <malloc.h>
|
||||
# elif defined(__BORLANDC__)
|
||||
# include <malloc.h>
|
||||
# elif defined(__DMC__)
|
||||
# include <stdlib.h>
|
||||
# elif defined(__AIX__)
|
||||
#pragma alloca
|
||||
# elif defined(__MRC__)
|
||||
void *alloca(unsigned);
|
||||
# else
|
||||
char *alloca();
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The number of elements in an array.
|
||||
@@ -328,28 +350,6 @@ SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int));
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_ALLOCA) && !defined(alloca)
|
||||
# if defined(HAVE_ALLOCA_H)
|
||||
# include <alloca.h>
|
||||
# elif defined(__GNUC__)
|
||||
# define alloca __builtin_alloca
|
||||
# elif defined(_MSC_VER)
|
||||
# include <malloc.h>
|
||||
# define alloca _alloca
|
||||
# elif defined(__WATCOMC__)
|
||||
# include <malloc.h>
|
||||
# elif defined(__BORLANDC__)
|
||||
# include <malloc.h>
|
||||
# elif defined(__DMC__)
|
||||
# include <stdlib.h>
|
||||
# elif defined(__AIX__)
|
||||
#pragma alloca
|
||||
# elif defined(__MRC__)
|
||||
void *alloca(unsigned);
|
||||
# else
|
||||
char *alloca();
|
||||
# endif
|
||||
#endif
|
||||
#ifdef HAVE_ALLOCA
|
||||
#define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*(count))
|
||||
#define SDL_stack_free(data)
|
||||
@@ -445,12 +445,12 @@ SDL_FORCE_INLINE void SDL_memset4(void *dst, Uint32 val, size_t dwords)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
extern DECLSPEC void *SDLCALL SDL_memcpy(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len);
|
||||
|
||||
extern DECLSPEC void *SDLCALL SDL_memmove(SDL_OUT_BYTECAP(len) void *dst, SDL_IN_BYTECAP(len) const void *src, size_t len);
|
||||
extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len);
|
||||
|
||||
extern DECLSPEC wchar_t *SDLCALL SDL_wcsdup(const wchar_t *wstr);
|
||||
extern DECLSPEC size_t SDLCALL SDL_wcslen(const wchar_t *wstr);
|
||||
extern DECLSPEC size_t SDLCALL SDL_wcslcpy(SDL_OUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen);
|
||||
extern DECLSPEC size_t SDLCALL SDL_wcslcat(SDL_INOUT_Z_CAP(maxlen) wchar_t *dst, const wchar_t *src, size_t maxlen);
|
||||
@@ -514,6 +514,8 @@ extern DECLSPEC double SDLCALL SDL_copysign(double x, double y);
|
||||
extern DECLSPEC float SDLCALL SDL_copysignf(float x, float y);
|
||||
extern DECLSPEC double SDLCALL SDL_cos(double x);
|
||||
extern DECLSPEC float SDLCALL SDL_cosf(float x);
|
||||
extern DECLSPEC double SDLCALL SDL_exp(double x);
|
||||
extern DECLSPEC float SDLCALL SDL_expf(float x);
|
||||
extern DECLSPEC double SDLCALL SDL_fabs(double x);
|
||||
extern DECLSPEC float SDLCALL SDL_fabsf(float x);
|
||||
extern DECLSPEC double SDLCALL SDL_floor(double x);
|
||||
|
||||
@@ -248,6 +248,13 @@ extern DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface * surface,
|
||||
extern DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface * surface,
|
||||
int flag, Uint32 key);
|
||||
|
||||
/**
|
||||
* \brief Returns whether the surface has a color key
|
||||
*
|
||||
* \return SDL_TRUE if the surface has a color key, or SDL_FALSE if the surface is NULL or has no color key
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasColorKey(SDL_Surface * surface);
|
||||
|
||||
/**
|
||||
* \brief Gets the color key (transparent pixel) in a blittable surface.
|
||||
*
|
||||
|
||||
@@ -76,6 +76,18 @@ extern DECLSPEC SDL_bool SDLCALL SDL_DXGIGetOutputInfo( int displayIndex, int *a
|
||||
#endif /* __WIN32__ */
|
||||
|
||||
|
||||
/* Platform specific functions for Linux */
|
||||
#ifdef __LINUX__
|
||||
|
||||
/**
|
||||
\brief Sets the UNIX nice value for a thread, using setpriority() if possible, and RealtimeKit if available.
|
||||
|
||||
\return 0 on success, or -1 on error.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_LinuxSetThreadPriority(Sint64 threadID, int priority);
|
||||
|
||||
#endif /* __LINUX__ */
|
||||
|
||||
/* Platform specific functions for iOS */
|
||||
#if defined(__IPHONEOS__) && __IPHONEOS__
|
||||
|
||||
@@ -113,6 +125,21 @@ extern DECLSPEC void * SDLCALL SDL_AndroidGetActivity(void);
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_IsAndroidTV(void);
|
||||
|
||||
/**
|
||||
\brief Return true if the application is running on a Chromebook
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_IsChromebook(void);
|
||||
|
||||
/**
|
||||
\brief Return true is the application is running on a Samsung DeX docking station
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_IsDeXMode(void);
|
||||
|
||||
/**
|
||||
\brief Trigger the Android system back button behavior.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL SDL_AndroidBackButton(void);
|
||||
|
||||
/**
|
||||
See the official Android developer guide for more information:
|
||||
http://developer.android.com/guide/topics/data/data-storage.html
|
||||
@@ -236,6 +263,11 @@ extern DECLSPEC SDL_WinRT_DeviceFamily SDLCALL SDL_WinRTGetDeviceFamily();
|
||||
|
||||
#endif /* __WINRT__ */
|
||||
|
||||
/**
|
||||
\brief Return true if the current device is a tablet.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_IsTablet(void);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -33,12 +33,6 @@
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_version.h"
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \file SDL_syswm.h
|
||||
*
|
||||
@@ -110,6 +104,12 @@ typedef void *EGLSurface;
|
||||
#include "SDL_egl.h"
|
||||
#endif
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* These are the various supported windowing subsystems
|
||||
*/
|
||||
|
||||
@@ -54,12 +54,13 @@ typedef unsigned int SDL_TLSID;
|
||||
/**
|
||||
* The SDL thread priority.
|
||||
*
|
||||
* \note On many systems you require special privileges to set high priority.
|
||||
* \note On many systems you require special privileges to set high or time critical priority.
|
||||
*/
|
||||
typedef enum {
|
||||
SDL_THREAD_PRIORITY_LOW,
|
||||
SDL_THREAD_PRIORITY_NORMAL,
|
||||
SDL_THREAD_PRIORITY_HIGH
|
||||
SDL_THREAD_PRIORITY_HIGH,
|
||||
SDL_THREAD_PRIORITY_TIME_CRITICAL
|
||||
} SDL_ThreadPriority;
|
||||
|
||||
/**
|
||||
@@ -105,14 +106,24 @@ SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data,
|
||||
pfnSDL_CurrentBeginThread pfnBeginThread,
|
||||
pfnSDL_CurrentEndThread pfnEndThread);
|
||||
|
||||
extern DECLSPEC SDL_Thread *SDLCALL
|
||||
SDL_CreateThreadWithStackSize(int (SDLCALL * fn) (void *),
|
||||
const char *name, const size_t stacksize, void *data,
|
||||
pfnSDL_CurrentBeginThread pfnBeginThread,
|
||||
pfnSDL_CurrentEndThread pfnEndThread);
|
||||
|
||||
|
||||
/**
|
||||
* Create a thread.
|
||||
*/
|
||||
#if defined(SDL_CreateThread) && SDL_DYNAMIC_API
|
||||
#undef SDL_CreateThread
|
||||
#define SDL_CreateThread(fn, name, data) SDL_CreateThread_REAL(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthreadex, (pfnSDL_CurrentEndThread)_endthreadex)
|
||||
#undef SDL_CreateThreadWithStackSize
|
||||
#define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize_REAL(fn, name, stacksize, data, (pfnSDL_CurrentBeginThread)_beginthreadex, (pfnSDL_CurrentEndThread)_endthreadex)
|
||||
#else
|
||||
#define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthreadex, (pfnSDL_CurrentEndThread)_endthreadex)
|
||||
#define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthreadex, (pfnSDL_CurrentEndThread)_endthreadex)
|
||||
#endif
|
||||
|
||||
#elif defined(__OS2__)
|
||||
@@ -132,15 +143,31 @@ extern DECLSPEC SDL_Thread *SDLCALL
|
||||
SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data,
|
||||
pfnSDL_CurrentBeginThread pfnBeginThread,
|
||||
pfnSDL_CurrentEndThread pfnEndThread);
|
||||
extern DECLSPEC SDL_Thread *SDLCALL
|
||||
SDL_CreateThreadWithStackSize(SDL_ThreadFunction fn, const char *name, const size_t stacksize, void *data,
|
||||
pfnSDL_CurrentBeginThread pfnBeginThread,
|
||||
pfnSDL_CurrentEndThread pfnEndThread);
|
||||
#if defined(SDL_CreateThread) && SDL_DYNAMIC_API
|
||||
#undef SDL_CreateThread
|
||||
#define SDL_CreateThread(fn, name, data) SDL_CreateThread_REAL(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthread, (pfnSDL_CurrentEndThread)_endthread)
|
||||
#undef SDL_CreateThreadWithStackSize
|
||||
#define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize_REAL(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthread, (pfnSDL_CurrentEndThread)_endthread)
|
||||
#else
|
||||
#define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthread, (pfnSDL_CurrentEndThread)_endthread)
|
||||
#define SDL_CreateThreadWithStackSize(fn, name, stacksize, data) SDL_CreateThreadWithStackSize(fn, name, stacksize, data, (pfnSDL_CurrentBeginThread)_beginthread, (pfnSDL_CurrentEndThread)_endthread)
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
/**
|
||||
* Create a thread with a default stack size.
|
||||
*
|
||||
* This is equivalent to calling:
|
||||
* SDL_CreateThreadWithStackSize(fn, name, 0, data);
|
||||
*/
|
||||
extern DECLSPEC SDL_Thread *SDLCALL
|
||||
SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data);
|
||||
|
||||
/**
|
||||
* Create a thread.
|
||||
*
|
||||
@@ -158,9 +185,17 @@ SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data,
|
||||
* If a system imposes requirements, SDL will try to munge the string for
|
||||
* it (truncate, etc), but the original string contents will be available
|
||||
* from SDL_GetThreadName().
|
||||
*
|
||||
* The size (in bytes) of the new stack can be specified. Zero means "use
|
||||
* the system default" which might be wildly different between platforms
|
||||
* (x86 Linux generally defaults to eight megabytes, an embedded device
|
||||
* might be a few kilobytes instead).
|
||||
*
|
||||
* In SDL 2.1, stacksize will be folded into the original SDL_CreateThread
|
||||
* function.
|
||||
*/
|
||||
extern DECLSPEC SDL_Thread *SDLCALL
|
||||
SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data);
|
||||
SDL_CreateThreadWithStackSize(SDL_ThreadFunction fn, const char *name, const size_t stacksize, void *data);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ typedef struct SDL_version
|
||||
*/
|
||||
#define SDL_MAJOR_VERSION 2
|
||||
#define SDL_MINOR_VERSION 0
|
||||
#define SDL_PATCHLEVEL 8
|
||||
#define SDL_PATCHLEVEL 9
|
||||
|
||||
/**
|
||||
* \brief Macro to determine SDL version program was compiled against.
|
||||
|
||||
@@ -169,6 +169,24 @@ typedef enum
|
||||
SDL_WINDOWEVENT_HIT_TEST /**< Window had a hit test that wasn't SDL_HITTEST_NORMAL. */
|
||||
} SDL_WindowEventID;
|
||||
|
||||
/**
|
||||
* \brief Event subtype for display events
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SDL_DISPLAYEVENT_NONE, /**< Never used */
|
||||
SDL_DISPLAYEVENT_ORIENTATION /**< Display orientation has changed to data1 */
|
||||
} SDL_DisplayEventID;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SDL_ORIENTATION_UNKNOWN, /**< The display orientation can't be determined */
|
||||
SDL_ORIENTATION_LANDSCAPE, /**< The display is in landscape mode, with the right side up, relative to portrait mode */
|
||||
SDL_ORIENTATION_LANDSCAPE_FLIPPED, /**< The display is in landscape mode, with the left side up, relative to portrait mode */
|
||||
SDL_ORIENTATION_PORTRAIT, /**< The display is in portrait mode */
|
||||
SDL_ORIENTATION_PORTRAIT_FLIPPED /**< The display is in portrait mode, upside down */
|
||||
} SDL_DisplayOrientation;
|
||||
|
||||
/**
|
||||
* \brief An opaque handle to an OpenGL context.
|
||||
*/
|
||||
@@ -316,18 +334,6 @@ extern DECLSPEC const char * SDLCALL SDL_GetDisplayName(int displayIndex);
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetDisplayBounds(int displayIndex, SDL_Rect * rect);
|
||||
|
||||
/**
|
||||
* \brief Get the dots/pixels-per-inch for a display
|
||||
*
|
||||
* \note Diagonal, horizontal and vertical DPI can all be optionally
|
||||
* returned if the parameter is non-NULL.
|
||||
*
|
||||
* \return 0 on success, or -1 if no DPI information is available or the index is out of range.
|
||||
*
|
||||
* \sa SDL_GetNumVideoDisplays()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetDisplayDPI(int displayIndex, float * ddpi, float * hdpi, float * vdpi);
|
||||
|
||||
/**
|
||||
* \brief Get the usable desktop area represented by a display, with the
|
||||
* primary display located at 0,0
|
||||
@@ -347,6 +353,27 @@ extern DECLSPEC int SDLCALL SDL_GetDisplayDPI(int displayIndex, float * ddpi, fl
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetDisplayUsableBounds(int displayIndex, SDL_Rect * rect);
|
||||
|
||||
/**
|
||||
* \brief Get the dots/pixels-per-inch for a display
|
||||
*
|
||||
* \note Diagonal, horizontal and vertical DPI can all be optionally
|
||||
* returned if the parameter is non-NULL.
|
||||
*
|
||||
* \return 0 on success, or -1 if no DPI information is available or the index is out of range.
|
||||
*
|
||||
* \sa SDL_GetNumVideoDisplays()
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetDisplayDPI(int displayIndex, float * ddpi, float * hdpi, float * vdpi);
|
||||
|
||||
/**
|
||||
* \brief Get the orientation of a display
|
||||
*
|
||||
* \return The orientation of the display, or SDL_ORIENTATION_UNKNOWN if it isn't available.
|
||||
*
|
||||
* \sa SDL_GetNumVideoDisplays()
|
||||
*/
|
||||
extern DECLSPEC SDL_DisplayOrientation SDLCALL SDL_GetDisplayOrientation(int displayIndex);
|
||||
|
||||
/**
|
||||
* \brief Returns the number of available display modes.
|
||||
*
|
||||
|
||||
@@ -135,11 +135,11 @@ extern DECLSPEC void SDLCALL SDL_Vulkan_UnloadLibrary(void);
|
||||
* \brief Get the names of the Vulkan instance extensions needed to create
|
||||
* a surface with \c SDL_Vulkan_CreateSurface().
|
||||
*
|
||||
* \param [in] window Window for which the required Vulkan instance
|
||||
* \param [in] \c NULL or window Window for which the required Vulkan instance
|
||||
* extensions should be retrieved
|
||||
* \param [in,out] count pointer to an \c unsigned related to the number of
|
||||
* \param [in,out] pCount pointer to an \c unsigned related to the number of
|
||||
* required Vulkan instance extensions
|
||||
* \param [out] names \c NULL or a pointer to an array to be filled with the
|
||||
* \param [out] pNames \c NULL or a pointer to an array to be filled with the
|
||||
* required Vulkan instance extensions
|
||||
*
|
||||
* \return \c SDL_TRUE on success, \c SDL_FALSE on error.
|
||||
@@ -153,6 +153,10 @@ extern DECLSPEC void SDLCALL SDL_Vulkan_UnloadLibrary(void);
|
||||
* is smaller than the number of required extensions, \c SDL_FALSE will be
|
||||
* returned instead of \c SDL_TRUE, to indicate that not all the required
|
||||
* extensions were returned.
|
||||
*
|
||||
* \note If \c window is not NULL, it will be checked against its creation
|
||||
* flags to ensure that the Vulkan flag is present. This parameter
|
||||
* will be removed in a future major release.
|
||||
*
|
||||
* \note The returned list of extensions will contain \c VK_KHR_surface
|
||||
* and zero or more platform specific extensions
|
||||
@@ -160,12 +164,13 @@ extern DECLSPEC void SDLCALL SDL_Vulkan_UnloadLibrary(void);
|
||||
* \note The extension names queried here must be enabled when calling
|
||||
* VkCreateInstance, otherwise surface creation will fail.
|
||||
*
|
||||
* \note \c window should have been created with the \c SDL_WINDOW_VULKAN flag.
|
||||
* \note \c window should have been created with the \c SDL_WINDOW_VULKAN flag
|
||||
* or be \c NULL
|
||||
*
|
||||
* \code
|
||||
* unsigned int count;
|
||||
* // get count of required extensions
|
||||
* if(!SDL_Vulkan_GetInstanceExtensions(window, &count, NULL))
|
||||
* if(!SDL_Vulkan_GetInstanceExtensions(NULL, &count, NULL))
|
||||
* handle_error();
|
||||
*
|
||||
* static const char *const additionalExtensions[] =
|
||||
@@ -179,7 +184,7 @@ extern DECLSPEC void SDLCALL SDL_Vulkan_UnloadLibrary(void);
|
||||
* handle_error();
|
||||
*
|
||||
* // get names of required extensions
|
||||
* if(!SDL_Vulkan_GetInstanceExtensions(window, &count, names))
|
||||
* if(!SDL_Vulkan_GetInstanceExtensions(NULL, &count, names))
|
||||
* handle_error();
|
||||
*
|
||||
* // copy additional extensions after required extensions
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>BuildMachineOSBuild</key>
|
||||
<string>17C88</string>
|
||||
<string>18E226</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
@@ -19,7 +19,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>2.0.8</string>
|
||||
<string>2.0.9</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>SDLX</string>
|
||||
<key>CFBundleSupportedPlatforms</key>
|
||||
@@ -27,20 +27,20 @@
|
||||
<string>MacOSX</string>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>2.0.8</string>
|
||||
<string>2.0.9</string>
|
||||
<key>DTCompiler</key>
|
||||
<string>com.apple.compilers.llvm.clang.1_0</string>
|
||||
<key>DTPlatformBuild</key>
|
||||
<string>9C40b</string>
|
||||
<string>10E1001</string>
|
||||
<key>DTPlatformVersion</key>
|
||||
<string>GM</string>
|
||||
<key>DTSDKBuild</key>
|
||||
<string>17C76</string>
|
||||
<string>18E219</string>
|
||||
<key>DTSDKName</key>
|
||||
<string>macosx10.13</string>
|
||||
<string>macosx10.14</string>
|
||||
<key>DTXcode</key>
|
||||
<string>0920</string>
|
||||
<string>1020</string>
|
||||
<key>DTXcodeBuild</key>
|
||||
<string>9C40b</string>
|
||||
<string>10E1001</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<dict>
|
||||
<key>Resources/Info.plist</key>
|
||||
<data>
|
||||
dts8ape5zBg3+8u8BQ5kWqp9cC8=
|
||||
R+u/+U4v4MZreoaFKEgSTferTn0=
|
||||
</data>
|
||||
</dict>
|
||||
<key>files2</key>
|
||||
@@ -15,11 +15,11 @@
|
||||
<dict>
|
||||
<key>hash</key>
|
||||
<data>
|
||||
wiqwnVgtbgjGPAOFejxz8yw7geU=
|
||||
49nvc7QToCAQLOuQYg5d779VW3g=
|
||||
</data>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
LLwzMAHn2OsCr2SVR7M71KeQf+TiJpHk/KKojzQdRlI=
|
||||
NLgB0IPWGKfeYCtUqAAuK70AxrNGD5IUCdRh2wM0+VU=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/SDL_assert.h</key>
|
||||
@@ -48,11 +48,11 @@
|
||||
<dict>
|
||||
<key>hash</key>
|
||||
<data>
|
||||
9uJv81fH9Op/f3sF7/GVuNYQNOc=
|
||||
bCT1aBK06cMR6XwF8XLvtevSVAY=
|
||||
</data>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
KDokTSV3kZuHCQFFrRum3VoTP1QSW2xAghjceoIArXY=
|
||||
38oQKCI+MpwiSgdqg/YUBSB6cfzpXXnqv4oPEScXDDM=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/SDL_bits.h</key>
|
||||
@@ -92,22 +92,22 @@
|
||||
<dict>
|
||||
<key>hash</key>
|
||||
<data>
|
||||
nJnfliCMDJUfOG8t4QYt5U9tFBY=
|
||||
d/fShSScdM47JT6zVSrfULAMtpk=
|
||||
</data>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
qkVvxnI+XRMTIdbzQ9tV+ERRc75r/EzWu0qRTgt5K5c=
|
||||
hqFomi7gM/LXRjuRae5d3D/SKLBKmrPAp6TgW+OdkVg=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/SDL_config_macosx.h</key>
|
||||
<dict>
|
||||
<key>hash</key>
|
||||
<data>
|
||||
D0LXp0FibaaLSE6877hbyqf2Jb8=
|
||||
H0+NaeWz7cJLtW/LjkuWlCT2/oE=
|
||||
</data>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
pCQLXwJ6HaGZiG5vr9njJtgNcIV9p0mxcSJtYoj147A=
|
||||
skiBjJo1Yq2nen+FcO3Pxy4PjWbcUdDKF8p72tPBrpw=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/SDL_copying.h</key>
|
||||
@@ -125,11 +125,11 @@
|
||||
<dict>
|
||||
<key>hash</key>
|
||||
<data>
|
||||
2wleDfJFmCBrEssrE9rcuaiqOLQ=
|
||||
Nw8KCHXkAAuqJAvJOv+SWhZGEhU=
|
||||
</data>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
MEpF0mFQFLhuTV+5uSB++q8tT2z5heESxyP1HuzuKxc=
|
||||
0eRfEAH+V/dL+6GHKmkbzcmeR9nISfmjBGcoOn8J9J8=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/SDL_endian.h</key>
|
||||
@@ -158,11 +158,11 @@
|
||||
<dict>
|
||||
<key>hash</key>
|
||||
<data>
|
||||
ptgRA0IBsCg5za/lwhTOPGNmekY=
|
||||
szOypQL+tBWkumW9xkwm5kpiGCE=
|
||||
</data>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
lwISPqzee6nV4HCHaMzZCVJJAtFZmoi8cYlJkY41wKA=
|
||||
Iz2fuclzBbpDLa+Dq/Eq8MupiacS6vcB2AWrbvzWinM=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/SDL_filesystem.h</key>
|
||||
@@ -180,11 +180,11 @@
|
||||
<dict>
|
||||
<key>hash</key>
|
||||
<data>
|
||||
sUaSBwOprX7A696W6u2oOtIne+Y=
|
||||
Y46TpYRoYCHK4qV9HMp76Vj6jB8=
|
||||
</data>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
VZDstHk/V+tZik3q3xnDCAG3AfA+BoHk9lB406mKtxU=
|
||||
5cmyPcoPpG+9ZJCq4n1GsKirMlwU1NNi0dLGL7qH6qI=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/SDL_gesture.h</key>
|
||||
@@ -202,33 +202,33 @@
|
||||
<dict>
|
||||
<key>hash</key>
|
||||
<data>
|
||||
95rNclZzbsuV6pyeG8cbIETgS84=
|
||||
aNb86XMA8j7OVT9j3ReBkzfOvzI=
|
||||
</data>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
O4RUmC9HMqsjAf22Ru6z5j9HaYTsc7SxOnzOXPR3kz0=
|
||||
8QEdekDVr5cLtobUqsj19TtgOspGlP/2vlVCx1L+xcs=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/SDL_hints.h</key>
|
||||
<dict>
|
||||
<key>hash</key>
|
||||
<data>
|
||||
UjEgXfZiLUmQTh9G+Bkx8Y1Ov6k=
|
||||
wO6x0FskYQ3YXeNo8nC4fUuwVF0=
|
||||
</data>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
DqFPmBXNg9BovdIAlipnBKZo5mcQJCrLmhyIM/O+tvU=
|
||||
6V1lCUmwIWOAqq2OQ23J1/VhfbzwDnlQZPWTlhojfa4=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/SDL_joystick.h</key>
|
||||
<dict>
|
||||
<key>hash</key>
|
||||
<data>
|
||||
97SJSCx+xjRHUQ6ilndhP8TZ110=
|
||||
iMGs3U89FHkp1B8fAL14WyLC4Is=
|
||||
</data>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
xYWL+BS5f9NGr7eeP+vL0kD5K6O99PXgOWLT2Bx2dRQ=
|
||||
bUyUDarySk37tfBr5tn+rYVIboNQ8aSXAujz55F6HZo=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/SDL_keyboard.h</key>
|
||||
@@ -488,11 +488,11 @@
|
||||
<dict>
|
||||
<key>hash</key>
|
||||
<data>
|
||||
XBn2NI8Qm53MeZGaXVB3fQrs0uc=
|
||||
ixjPDg2DQUEDn7ID2l4wMHDUvDk=
|
||||
</data>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
FHG6Lqi1wMmjow+JjxKYy/LAoqP+iDH8QYuJS1zr6T4=
|
||||
LUUZKxelLmuZXjHwFWFSYH8HA96Px1JVmtuv79n+gYY=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/SDL_rwops.h</key>
|
||||
@@ -517,6 +517,17 @@
|
||||
5VaZC9IfMuNgz3h6OJn9Q/IGB/+cpymxIrjkluCWzOo=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/SDL_sensor.h</key>
|
||||
<dict>
|
||||
<key>hash</key>
|
||||
<data>
|
||||
Be7Gy5/r1i7xekMvnpx2rligsYU=
|
||||
</data>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
E/d0hIQ2nn69Cryv+nT2Hr+JmWa2ETnsBgE/JpJ36uc=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/SDL_shape.h</key>
|
||||
<dict>
|
||||
<key>hash</key>
|
||||
@@ -532,55 +543,55 @@
|
||||
<dict>
|
||||
<key>hash</key>
|
||||
<data>
|
||||
qBTB0Yqh+34vD3n3dN9ry9GwqJM=
|
||||
Z0uzAbGiXidgebOz6idDVTr7qtc=
|
||||
</data>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
TDMriI0PPYF73lvh6suExzpMldCmX1SkLgg+wkBqt7A=
|
||||
JMXREkpaKMdzh4IgZzSHyp5vbIaa3IjvgFjfUzDN6Y4=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/SDL_surface.h</key>
|
||||
<dict>
|
||||
<key>hash</key>
|
||||
<data>
|
||||
bssTKTIF4Yw/3a6fyF7GhaVrdU0=
|
||||
xCVDDdRmW3XjJfDaMiKm/c9oQlM=
|
||||
</data>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
zRF/b8bCqjClZnbPorqjhlWw9aujM9RwnVemHyiC2yM=
|
||||
IzrFWzZUTMjqUmCN5fCPOQuJuhE5P0NMUWtqfHJGWz4=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/SDL_system.h</key>
|
||||
<dict>
|
||||
<key>hash</key>
|
||||
<data>
|
||||
n2WodCV+WpbfpFSKUUKpB/i5ZPw=
|
||||
gfiAZLnsMKtcBY30ygv+FLGYBeE=
|
||||
</data>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
3W0Z/Fdwbc7dTyR+v4g6eVE58XcEYLTzDGO+RMwcmJc=
|
||||
8mRRFbV80FDAFMhJcJBBLuMOEzRZlaK9BaFNLvaZdFQ=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/SDL_syswm.h</key>
|
||||
<dict>
|
||||
<key>hash</key>
|
||||
<data>
|
||||
QoebSqgb1XslKPBwMiUOM6daVKo=
|
||||
lBCQTJ7UvTA5qYKTiEpsqFTGXHo=
|
||||
</data>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
rCqmdvdibhT5MBOnvKCT0gK7Howb5uLewC321yLYr5U=
|
||||
NVDqg+40pJZm/xBJTcr2sQFRQrov9a14KBJ07lfbwgs=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/SDL_thread.h</key>
|
||||
<dict>
|
||||
<key>hash</key>
|
||||
<data>
|
||||
fXCWQD4MIniqvdB6pWVwlxNS9jk=
|
||||
6gQ6df2RG9ffNYRQj6PwIE732BE=
|
||||
</data>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
18iJ1yFzOTeiM30JwK3GMlbgUqzNDIQiw3ZLLr3M+XQ=
|
||||
b7aDhH9W57nyn9u+xXrlA2kJVj91wFAAafUP07nphY0=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/SDL_timer.h</key>
|
||||
@@ -620,33 +631,33 @@
|
||||
<dict>
|
||||
<key>hash</key>
|
||||
<data>
|
||||
nKLee2vSNZZK9p94Up9o87OoiDE=
|
||||
n/L/bdSBJArMDPWwOU5CABfDXtE=
|
||||
</data>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
F3dpo9XlvebIS2NLJ1ovH+W7fG3bzb01F8OKUeqd+U0=
|
||||
of5yxPHtdFdC8JwFB7ULi195Ws4KbiM1l/WjB8Y2Os8=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/SDL_video.h</key>
|
||||
<dict>
|
||||
<key>hash</key>
|
||||
<data>
|
||||
UFZPU1U3CDog3RBKdd5wu9LFQZk=
|
||||
DwvB/tKrFg/8GMK9DWe7RYPVCDo=
|
||||
</data>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
6/OCq92BIQnGHBLmlGX4nUNnfLM7LzPoMp+lPlYY4ew=
|
||||
yBnTX5Y53PXTHttQX3YGhklBGQc/uUzL2ntHnjxM4DE=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/SDL_vulkan.h</key>
|
||||
<dict>
|
||||
<key>hash</key>
|
||||
<data>
|
||||
eLdIezOR2pV1ai5rLBrtiR3NAok=
|
||||
i1vRVTlmtbM2IJt9r8QO8MOL8eI=
|
||||
</data>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
iCB8avj2P0+ZkjVGfTchu5BAd7BJ+LeC1fJ9BU+80IE=
|
||||
EKCF9MU8qtxJHzJRCp0Zk2krWF631/jBU58TFGyfxcw=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/begin_code.h</key>
|
||||
@@ -675,11 +686,11 @@
|
||||
<dict>
|
||||
<key>hash</key>
|
||||
<data>
|
||||
dts8ape5zBg3+8u8BQ5kWqp9cC8=
|
||||
R+u/+U4v4MZreoaFKEgSTferTn0=
|
||||
</data>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
ZCgx1szeVwObsPiq6VoZh8Q9ym7l+7WXzv0HTSoFT0U=
|
||||
IRZvZMEiRywMETq3zPZTAHg/qtglFprMndUohrhHyFI=
|
||||
</data>
|
||||
</dict>
|
||||
</dict>
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
Versions/Current/Frameworks
|
||||
@@ -0,0 +1 @@
|
||||
Versions/Current/Headers
|
||||
@@ -0,0 +1 @@
|
||||
Versions/Current/Resources
|
||||
@@ -0,0 +1 @@
|
||||
Versions/Current/SDL2_ttf
|
||||
@@ -0,0 +1 @@
|
||||
Versions/Current/FreeType
|
||||
@@ -0,0 +1 @@
|
||||
Versions/Current/Headers
|
||||
@@ -0,0 +1 @@
|
||||
Versions/Current/Resources
|
||||
@@ -0,0 +1,603 @@
|
||||
/* ftconfig.h. Generated from ftconfig.in by configure. */
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftconfig.in */
|
||||
/* */
|
||||
/* UNIX-specific configuration file (specification only). */
|
||||
/* */
|
||||
/* Copyright 1996-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* This header file contains a number of macro definitions that are used */
|
||||
/* by the rest of the engine. Most of the macros here are automatically */
|
||||
/* determined at compile time, and you should not need to change it to */
|
||||
/* port FreeType, except to compile the library with a non-ANSI */
|
||||
/* compiler. */
|
||||
/* */
|
||||
/* Note however that if some specific modifications are needed, we */
|
||||
/* advise you to place a modified copy in your build directory. */
|
||||
/* */
|
||||
/* The build directory is usually `builds/<system>', and contains */
|
||||
/* system-specific files that are always included first when building */
|
||||
/* the library. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTCONFIG_H_
|
||||
#define FTCONFIG_H_
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_CONFIG_OPTIONS_H
|
||||
#include FT_CONFIG_STANDARD_LIBRARY_H
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* PLATFORM-SPECIFIC CONFIGURATION MACROS */
|
||||
/* */
|
||||
/* These macros can be toggled to suit a specific system. The current */
|
||||
/* ones are defaults used to compile FreeType in an ANSI C environment */
|
||||
/* (16bit compilers are also supported). Copy this file to your own */
|
||||
/* `builds/<system>' directory, and edit it to port the engine. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#define HAVE_UNISTD_H 1
|
||||
#define HAVE_FCNTL_H 1
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
|
||||
/* There are systems (like the Texas Instruments 'C54x) where a `char' */
|
||||
/* has 16 bits. ANSI C says that sizeof(char) is always 1. Since an */
|
||||
/* `int' has 16 bits also for this system, sizeof(int) gives 1 which */
|
||||
/* is probably unexpected. */
|
||||
/* */
|
||||
/* `CHAR_BIT' (defined in limits.h) gives the number of bits in a */
|
||||
/* `char' type. */
|
||||
|
||||
#ifndef FT_CHAR_BIT
|
||||
#define FT_CHAR_BIT CHAR_BIT
|
||||
#endif
|
||||
|
||||
|
||||
/* #undef FT_USE_AUTOCONF_SIZEOF_TYPES */
|
||||
#ifdef FT_USE_AUTOCONF_SIZEOF_TYPES
|
||||
|
||||
#define SIZEOF_INT 4
|
||||
#define SIZEOF_LONG 8
|
||||
#define FT_SIZEOF_INT SIZEOF_INT
|
||||
#define FT_SIZEOF_LONG SIZEOF_LONG
|
||||
|
||||
#else /* !FT_USE_AUTOCONF_SIZEOF_TYPES */
|
||||
|
||||
/* Following cpp computation of the bit length of int and long */
|
||||
/* is copied from default include/freetype/config/ftconfig.h. */
|
||||
/* If any improvement is required for this file, it should be */
|
||||
/* applied to the original header file for the builders that */
|
||||
/* do not use configure script. */
|
||||
|
||||
/* The size of an `int' type. */
|
||||
#if FT_UINT_MAX == 0xFFFFUL
|
||||
#define FT_SIZEOF_INT (16 / FT_CHAR_BIT)
|
||||
#elif FT_UINT_MAX == 0xFFFFFFFFUL
|
||||
#define FT_SIZEOF_INT (32 / FT_CHAR_BIT)
|
||||
#elif FT_UINT_MAX > 0xFFFFFFFFUL && FT_UINT_MAX == 0xFFFFFFFFFFFFFFFFUL
|
||||
#define FT_SIZEOF_INT (64 / FT_CHAR_BIT)
|
||||
#else
|
||||
#error "Unsupported size of `int' type!"
|
||||
#endif
|
||||
|
||||
/* The size of a `long' type. A five-byte `long' (as used e.g. on the */
|
||||
/* DM642) is recognized but avoided. */
|
||||
#if FT_ULONG_MAX == 0xFFFFFFFFUL
|
||||
#define FT_SIZEOF_LONG (32 / FT_CHAR_BIT)
|
||||
#elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFUL
|
||||
#define FT_SIZEOF_LONG (32 / FT_CHAR_BIT)
|
||||
#elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFFFFFFFUL
|
||||
#define FT_SIZEOF_LONG (64 / FT_CHAR_BIT)
|
||||
#else
|
||||
#error "Unsupported size of `long' type!"
|
||||
#endif
|
||||
|
||||
#endif /* !FT_USE_AUTOCONF_SIZEOF_TYPES */
|
||||
|
||||
|
||||
/* FT_UNUSED is a macro used to indicate that a given parameter is not */
|
||||
/* used -- this is only used to get rid of unpleasant compiler warnings */
|
||||
#ifndef FT_UNUSED
|
||||
#define FT_UNUSED( arg ) ( (arg) = (arg) )
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* AUTOMATIC CONFIGURATION MACROS */
|
||||
/* */
|
||||
/* These macros are computed from the ones defined above. Don't touch */
|
||||
/* their definition, unless you know precisely what you are doing. No */
|
||||
/* porter should need to mess with them. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Mac support */
|
||||
/* */
|
||||
/* This is the only necessary change, so it is defined here instead */
|
||||
/* providing a new configuration file. */
|
||||
/* */
|
||||
#if defined( __APPLE__ ) || ( defined( __MWERKS__ ) && defined( macintosh ) )
|
||||
/* no Carbon frameworks for 64bit 10.4.x */
|
||||
/* AvailabilityMacros.h is available since Mac OS X 10.2, */
|
||||
/* so guess the system version by maximum errno before inclusion */
|
||||
#include <errno.h>
|
||||
#ifdef ECANCELED /* defined since 10.2 */
|
||||
#include "AvailabilityMacros.h"
|
||||
#endif
|
||||
#if defined( __LP64__ ) && \
|
||||
( MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 )
|
||||
#undef FT_MACINTOSH
|
||||
#endif
|
||||
|
||||
#elif defined( __SC__ ) || defined( __MRC__ )
|
||||
/* Classic MacOS compilers */
|
||||
#include "ConditionalMacros.h"
|
||||
#if TARGET_OS_MAC
|
||||
#define FT_MACINTOSH 1
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* Fix compiler warning with sgi compiler */
|
||||
#if defined( __sgi ) && !defined( __GNUC__ )
|
||||
#if defined( _COMPILER_VERSION ) && ( _COMPILER_VERSION >= 730 )
|
||||
#pragma set woff 3505
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* basic_types */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Int16 */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A typedef for a 16bit signed integer type. */
|
||||
/* */
|
||||
typedef signed short FT_Int16;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_UInt16 */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A typedef for a 16bit unsigned integer type. */
|
||||
/* */
|
||||
typedef unsigned short FT_UInt16;
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
/* this #if 0 ... #endif clause is for documentation purposes */
|
||||
#if 0
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Int32 */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A typedef for a 32bit signed integer type. The size depends on */
|
||||
/* the configuration. */
|
||||
/* */
|
||||
typedef signed XXX FT_Int32;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_UInt32 */
|
||||
/* */
|
||||
/* A typedef for a 32bit unsigned integer type. The size depends on */
|
||||
/* the configuration. */
|
||||
/* */
|
||||
typedef unsigned XXX FT_UInt32;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Int64 */
|
||||
/* */
|
||||
/* A typedef for a 64bit signed integer type. The size depends on */
|
||||
/* the configuration. Only defined if there is real 64bit support; */
|
||||
/* otherwise, it gets emulated with a structure (if necessary). */
|
||||
/* */
|
||||
typedef signed XXX FT_Int64;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_UInt64 */
|
||||
/* */
|
||||
/* A typedef for a 64bit unsigned integer type. The size depends on */
|
||||
/* the configuration. Only defined if there is real 64bit support; */
|
||||
/* otherwise, it gets emulated with a structure (if necessary). */
|
||||
/* */
|
||||
typedef unsigned XXX FT_UInt64;
|
||||
|
||||
/* */
|
||||
|
||||
#endif
|
||||
|
||||
#if FT_SIZEOF_INT == 4
|
||||
|
||||
typedef signed int FT_Int32;
|
||||
typedef unsigned int FT_UInt32;
|
||||
|
||||
#elif FT_SIZEOF_LONG == 4
|
||||
|
||||
typedef signed long FT_Int32;
|
||||
typedef unsigned long FT_UInt32;
|
||||
|
||||
#else
|
||||
#error "no 32bit type found -- please check your configuration files"
|
||||
#endif
|
||||
|
||||
|
||||
/* look up an integer type that is at least 32 bits */
|
||||
#if FT_SIZEOF_INT >= 4
|
||||
|
||||
typedef int FT_Fast;
|
||||
typedef unsigned int FT_UFast;
|
||||
|
||||
#elif FT_SIZEOF_LONG >= 4
|
||||
|
||||
typedef long FT_Fast;
|
||||
typedef unsigned long FT_UFast;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* determine whether we have a 64-bit int type */
|
||||
/* (mostly for environments without `autoconf') */
|
||||
#if FT_SIZEOF_LONG == 8
|
||||
|
||||
/* FT_LONG64 must be defined if a 64-bit type is available */
|
||||
#define FT_LONG64
|
||||
#define FT_INT64 long
|
||||
#define FT_UINT64 unsigned long
|
||||
|
||||
/* we handle the LLP64 scheme separately for GCC and clang, */
|
||||
/* suppressing the `long long' warning */
|
||||
#elif ( FT_SIZEOF_LONG == 4 ) && \
|
||||
defined( HAVE_LONG_LONG_INT ) && \
|
||||
defined( __GNUC__ )
|
||||
#pragma GCC diagnostic ignored "-Wlong-long"
|
||||
#define FT_LONG64
|
||||
#define FT_INT64 long long int
|
||||
#define FT_UINT64 unsigned long long int
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* A 64-bit data type may create compilation problems if you compile */
|
||||
/* in strict ANSI mode. To avoid them, we disable other 64-bit data */
|
||||
/* types if __STDC__ is defined. You can however ignore this rule */
|
||||
/* by defining the FT_CONFIG_OPTION_FORCE_INT64 configuration macro. */
|
||||
/* */
|
||||
#elif !defined( __STDC__ ) || defined( FT_CONFIG_OPTION_FORCE_INT64 )
|
||||
|
||||
#if defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 199901L
|
||||
|
||||
#define FT_LONG64
|
||||
#define FT_INT64 long long int
|
||||
#define FT_UINT64 unsigned long long int
|
||||
|
||||
#elif defined( _MSC_VER ) && _MSC_VER >= 900 /* Visual C++ (and Intel C++) */
|
||||
|
||||
/* this compiler provides the __int64 type */
|
||||
#define FT_LONG64
|
||||
#define FT_INT64 __int64
|
||||
#define FT_UINT64 unsigned __int64
|
||||
|
||||
#elif defined( __BORLANDC__ ) /* Borland C++ */
|
||||
|
||||
/* XXXX: We should probably check the value of __BORLANDC__ in order */
|
||||
/* to test the compiler version. */
|
||||
|
||||
/* this compiler provides the __int64 type */
|
||||
#define FT_LONG64
|
||||
#define FT_INT64 __int64
|
||||
#define FT_UINT64 unsigned __int64
|
||||
|
||||
#elif defined( __WATCOMC__ ) /* Watcom C++ */
|
||||
|
||||
/* Watcom doesn't provide 64-bit data types */
|
||||
|
||||
#elif defined( __MWERKS__ ) /* Metrowerks CodeWarrior */
|
||||
|
||||
#define FT_LONG64
|
||||
#define FT_INT64 long long int
|
||||
#define FT_UINT64 unsigned long long int
|
||||
|
||||
#elif defined( __GNUC__ )
|
||||
|
||||
/* GCC provides the `long long' type */
|
||||
#define FT_LONG64
|
||||
#define FT_INT64 long long int
|
||||
#define FT_UINT64 unsigned long long int
|
||||
|
||||
#endif /* __STDC_VERSION__ >= 199901L */
|
||||
|
||||
#endif /* FT_SIZEOF_LONG == 8 */
|
||||
|
||||
#ifdef FT_LONG64
|
||||
typedef FT_INT64 FT_Int64;
|
||||
typedef FT_UINT64 FT_UInt64;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _WIN64
|
||||
/* only 64bit Windows uses the LLP64 data model, i.e., */
|
||||
/* 32bit integers, 64bit pointers */
|
||||
#define FT_UINT_TO_POINTER( x ) (void*)(unsigned __int64)(x)
|
||||
#else
|
||||
#define FT_UINT_TO_POINTER( x ) (void*)(unsigned long)(x)
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* miscellaneous */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#define FT_BEGIN_STMNT do {
|
||||
#define FT_END_STMNT } while ( 0 )
|
||||
#define FT_DUMMY_STMNT FT_BEGIN_STMNT FT_END_STMNT
|
||||
|
||||
|
||||
/* typeof condition taken from gnulib's `intprops.h' header file */
|
||||
#if ( ( defined( __GNUC__ ) && __GNUC__ >= 2 ) || \
|
||||
( defined( __IBMC__ ) && __IBMC__ >= 1210 && \
|
||||
defined( __IBM__TYPEOF__ ) ) || \
|
||||
( defined( __SUNPRO_C ) && __SUNPRO_C >= 0x5110 && !__STDC__ ) )
|
||||
#define FT_TYPEOF( type ) ( __typeof__ ( type ) )
|
||||
#else
|
||||
#define FT_TYPEOF( type ) /* empty */
|
||||
#endif
|
||||
|
||||
|
||||
/* Use FT_LOCAL and FT_LOCAL_DEF to declare and define, respectively, */
|
||||
/* a function that gets used only within the scope of a module. */
|
||||
/* Normally, both the header and source code files for such a */
|
||||
/* function are within a single module directory. */
|
||||
/* */
|
||||
/* Intra-module arrays should be tagged with FT_LOCAL_ARRAY and */
|
||||
/* FT_LOCAL_ARRAY_DEF. */
|
||||
/* */
|
||||
#ifdef FT_MAKE_OPTION_SINGLE_OBJECT
|
||||
|
||||
#define FT_LOCAL( x ) static x
|
||||
#define FT_LOCAL_DEF( x ) static x
|
||||
|
||||
#else
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define FT_LOCAL( x ) extern "C" x
|
||||
#define FT_LOCAL_DEF( x ) extern "C" x
|
||||
#else
|
||||
#define FT_LOCAL( x ) extern x
|
||||
#define FT_LOCAL_DEF( x ) x
|
||||
#endif
|
||||
|
||||
#endif /* FT_MAKE_OPTION_SINGLE_OBJECT */
|
||||
|
||||
#define FT_LOCAL_ARRAY( x ) extern const x
|
||||
#define FT_LOCAL_ARRAY_DEF( x ) const x
|
||||
|
||||
|
||||
/* Use FT_BASE and FT_BASE_DEF to declare and define, respectively, */
|
||||
/* functions that are used in more than a single module. In the */
|
||||
/* current setup this implies that the declaration is in a header */
|
||||
/* file in the `include/freetype/internal' directory, and the */
|
||||
/* function body is in a file in `src/base'. */
|
||||
/* */
|
||||
#ifndef FT_BASE
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define FT_BASE( x ) extern "C" x
|
||||
#else
|
||||
#define FT_BASE( x ) extern x
|
||||
#endif
|
||||
|
||||
#endif /* !FT_BASE */
|
||||
|
||||
|
||||
#ifndef FT_BASE_DEF
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define FT_BASE_DEF( x ) x
|
||||
#else
|
||||
#define FT_BASE_DEF( x ) x
|
||||
#endif
|
||||
|
||||
#endif /* !FT_BASE_DEF */
|
||||
|
||||
|
||||
/* When compiling FreeType as a DLL or DSO with hidden visibility */
|
||||
/* some systems/compilers need a special attribute in front OR after */
|
||||
/* the return type of function declarations. */
|
||||
/* */
|
||||
/* Two macros are used within the FreeType source code to define */
|
||||
/* exported library functions: FT_EXPORT and FT_EXPORT_DEF. */
|
||||
/* */
|
||||
/* FT_EXPORT( return_type ) */
|
||||
/* */
|
||||
/* is used in a function declaration, as in */
|
||||
/* */
|
||||
/* FT_EXPORT( FT_Error ) */
|
||||
/* FT_Init_FreeType( FT_Library* alibrary ); */
|
||||
/* */
|
||||
/* */
|
||||
/* FT_EXPORT_DEF( return_type ) */
|
||||
/* */
|
||||
/* is used in a function definition, as in */
|
||||
/* */
|
||||
/* FT_EXPORT_DEF( FT_Error ) */
|
||||
/* FT_Init_FreeType( FT_Library* alibrary ) */
|
||||
/* { */
|
||||
/* ... some code ... */
|
||||
/* return FT_Err_Ok; */
|
||||
/* } */
|
||||
/* */
|
||||
/* You can provide your own implementation of FT_EXPORT and */
|
||||
/* FT_EXPORT_DEF here if you want. */
|
||||
/* */
|
||||
/* To export a variable, use FT_EXPORT_VAR. */
|
||||
/* */
|
||||
#ifndef FT_EXPORT
|
||||
|
||||
#ifdef FT2_BUILD_LIBRARY
|
||||
|
||||
#if defined( _WIN32 ) && ( defined( _DLL ) || defined( DLL_EXPORT ) )
|
||||
#define FT_EXPORT( x ) __declspec( dllexport ) x
|
||||
#elif defined( __GNUC__ ) && __GNUC__ >= 4
|
||||
#define FT_EXPORT( x ) __attribute__(( visibility( "default" ) )) x
|
||||
#elif defined( __cplusplus )
|
||||
#define FT_EXPORT( x ) extern "C" x
|
||||
#else
|
||||
#define FT_EXPORT( x ) extern x
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#if defined( FT2_DLLIMPORT )
|
||||
#define FT_EXPORT( x ) __declspec( dllimport ) x
|
||||
#elif defined( __cplusplus )
|
||||
#define FT_EXPORT( x ) extern "C" x
|
||||
#else
|
||||
#define FT_EXPORT( x ) extern x
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* !FT_EXPORT */
|
||||
|
||||
|
||||
#ifndef FT_EXPORT_DEF
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define FT_EXPORT_DEF( x ) extern "C" x
|
||||
#else
|
||||
#define FT_EXPORT_DEF( x ) extern x
|
||||
#endif
|
||||
|
||||
#endif /* !FT_EXPORT_DEF */
|
||||
|
||||
|
||||
#ifndef FT_EXPORT_VAR
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define FT_EXPORT_VAR( x ) extern "C" x
|
||||
#else
|
||||
#define FT_EXPORT_VAR( x ) extern x
|
||||
#endif
|
||||
|
||||
#endif /* !FT_EXPORT_VAR */
|
||||
|
||||
/* The following macros are needed to compile the library with a */
|
||||
/* C++ compiler and with 16bit compilers. */
|
||||
/* */
|
||||
|
||||
/* This is special. Within C++, you must specify `extern "C"' for */
|
||||
/* functions which are used via function pointers, and you also */
|
||||
/* must do that for structures which contain function pointers to */
|
||||
/* assure C linkage -- it's not possible to have (local) anonymous */
|
||||
/* functions which are accessed by (global) function pointers. */
|
||||
/* */
|
||||
/* */
|
||||
/* FT_CALLBACK_DEF is used to _define_ a callback function, */
|
||||
/* located in the same source code file as the structure that uses */
|
||||
/* it. */
|
||||
/* */
|
||||
/* FT_BASE_CALLBACK and FT_BASE_CALLBACK_DEF are used to declare */
|
||||
/* and define a callback function, respectively, in a similar way */
|
||||
/* as FT_BASE and FT_BASE_DEF work. */
|
||||
/* */
|
||||
/* FT_CALLBACK_TABLE is used to _declare_ a constant variable that */
|
||||
/* contains pointers to callback functions. */
|
||||
/* */
|
||||
/* FT_CALLBACK_TABLE_DEF is used to _define_ a constant variable */
|
||||
/* that contains pointers to callback functions. */
|
||||
/* */
|
||||
/* */
|
||||
/* Some 16bit compilers have to redefine these macros to insert */
|
||||
/* the infamous `_cdecl' or `__fastcall' declarations. */
|
||||
/* */
|
||||
#ifndef FT_CALLBACK_DEF
|
||||
#ifdef __cplusplus
|
||||
#define FT_CALLBACK_DEF( x ) extern "C" x
|
||||
#else
|
||||
#define FT_CALLBACK_DEF( x ) static x
|
||||
#endif
|
||||
#endif /* FT_CALLBACK_DEF */
|
||||
|
||||
#ifndef FT_BASE_CALLBACK
|
||||
#ifdef __cplusplus
|
||||
#define FT_BASE_CALLBACK( x ) extern "C" x
|
||||
#define FT_BASE_CALLBACK_DEF( x ) extern "C" x
|
||||
#else
|
||||
#define FT_BASE_CALLBACK( x ) extern x
|
||||
#define FT_BASE_CALLBACK_DEF( x ) x
|
||||
#endif
|
||||
#endif /* FT_BASE_CALLBACK */
|
||||
|
||||
#ifndef FT_CALLBACK_TABLE
|
||||
#ifdef __cplusplus
|
||||
#define FT_CALLBACK_TABLE extern "C"
|
||||
#define FT_CALLBACK_TABLE_DEF extern "C"
|
||||
#else
|
||||
#define FT_CALLBACK_TABLE extern
|
||||
#define FT_CALLBACK_TABLE_DEF /* nothing */
|
||||
#endif
|
||||
#endif /* FT_CALLBACK_TABLE */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
|
||||
#endif /* FTCONFIG_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,804 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftheader.h */
|
||||
/* */
|
||||
/* Build macros of the FreeType 2 library. */
|
||||
/* */
|
||||
/* Copyright 1996-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
#ifndef FTHEADER_H_
|
||||
#define FTHEADER_H_
|
||||
|
||||
|
||||
/*@***********************************************************************/
|
||||
/* */
|
||||
/* <Macro> */
|
||||
/* FT_BEGIN_HEADER */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This macro is used in association with @FT_END_HEADER in header */
|
||||
/* files to ensure that the declarations within are properly */
|
||||
/* encapsulated in an `extern "C" { .. }' block when included from a */
|
||||
/* C++ compiler. */
|
||||
/* */
|
||||
#ifdef __cplusplus
|
||||
#define FT_BEGIN_HEADER extern "C" {
|
||||
#else
|
||||
#define FT_BEGIN_HEADER /* nothing */
|
||||
#endif
|
||||
|
||||
|
||||
/*@***********************************************************************/
|
||||
/* */
|
||||
/* <Macro> */
|
||||
/* FT_END_HEADER */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This macro is used in association with @FT_BEGIN_HEADER in header */
|
||||
/* files to ensure that the declarations within are properly */
|
||||
/* encapsulated in an `extern "C" { .. }' block when included from a */
|
||||
/* C++ compiler. */
|
||||
/* */
|
||||
#ifdef __cplusplus
|
||||
#define FT_END_HEADER }
|
||||
#else
|
||||
#define FT_END_HEADER /* nothing */
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Aliases for the FreeType 2 public and configuration files. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* header_file_macros */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* Header File Macros */
|
||||
/* */
|
||||
/* <Abstract> */
|
||||
/* Macro definitions used to #include specific header files. */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The following macros are defined to the name of specific */
|
||||
/* FreeType~2 header files. They can be used directly in #include */
|
||||
/* statements as in: */
|
||||
/* */
|
||||
/* { */
|
||||
/* #include FT_FREETYPE_H */
|
||||
/* #include FT_MULTIPLE_MASTERS_H */
|
||||
/* #include FT_GLYPH_H */
|
||||
/* } */
|
||||
/* */
|
||||
/* There are several reasons why we are now using macros to name */
|
||||
/* public header files. The first one is that such macros are not */
|
||||
/* limited to the infamous 8.3~naming rule required by DOS (and */
|
||||
/* `FT_MULTIPLE_MASTERS_H' is a lot more meaningful than `ftmm.h'). */
|
||||
/* */
|
||||
/* The second reason is that it allows for more flexibility in the */
|
||||
/* way FreeType~2 is installed on a given system. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/* configuration files */
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_CONFIG_CONFIG_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing
|
||||
* FreeType~2 configuration data.
|
||||
*
|
||||
*/
|
||||
#ifndef FT_CONFIG_CONFIG_H
|
||||
#define FT_CONFIG_CONFIG_H <freetype/config/ftconfig.h>
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_CONFIG_STANDARD_LIBRARY_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing
|
||||
* FreeType~2 interface to the standard C library functions.
|
||||
*
|
||||
*/
|
||||
#ifndef FT_CONFIG_STANDARD_LIBRARY_H
|
||||
#define FT_CONFIG_STANDARD_LIBRARY_H <freetype/config/ftstdlib.h>
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_CONFIG_OPTIONS_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing
|
||||
* FreeType~2 project-specific configuration options.
|
||||
*
|
||||
*/
|
||||
#ifndef FT_CONFIG_OPTIONS_H
|
||||
#define FT_CONFIG_OPTIONS_H <freetype/config/ftoption.h>
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_CONFIG_MODULES_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* list of FreeType~2 modules that are statically linked to new library
|
||||
* instances in @FT_Init_FreeType.
|
||||
*
|
||||
*/
|
||||
#ifndef FT_CONFIG_MODULES_H
|
||||
#define FT_CONFIG_MODULES_H <freetype/config/ftmodule.h>
|
||||
#endif
|
||||
|
||||
/* */
|
||||
|
||||
/* public headers */
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_FREETYPE_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* base FreeType~2 API.
|
||||
*
|
||||
*/
|
||||
#define FT_FREETYPE_H <freetype/freetype.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_ERRORS_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* list of FreeType~2 error codes (and messages).
|
||||
*
|
||||
* It is included by @FT_FREETYPE_H.
|
||||
*
|
||||
*/
|
||||
#define FT_ERRORS_H <freetype/fterrors.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_MODULE_ERRORS_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* list of FreeType~2 module error offsets (and messages).
|
||||
*
|
||||
*/
|
||||
#define FT_MODULE_ERRORS_H <freetype/ftmoderr.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_SYSTEM_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* FreeType~2 interface to low-level operations (i.e., memory management
|
||||
* and stream i/o).
|
||||
*
|
||||
* It is included by @FT_FREETYPE_H.
|
||||
*
|
||||
*/
|
||||
#define FT_SYSTEM_H <freetype/ftsystem.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_IMAGE_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing type
|
||||
* definitions related to glyph images (i.e., bitmaps, outlines,
|
||||
* scan-converter parameters).
|
||||
*
|
||||
* It is included by @FT_FREETYPE_H.
|
||||
*
|
||||
*/
|
||||
#define FT_IMAGE_H <freetype/ftimage.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_TYPES_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* basic data types defined by FreeType~2.
|
||||
*
|
||||
* It is included by @FT_FREETYPE_H.
|
||||
*
|
||||
*/
|
||||
#define FT_TYPES_H <freetype/fttypes.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_LIST_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* list management API of FreeType~2.
|
||||
*
|
||||
* (Most applications will never need to include this file.)
|
||||
*
|
||||
*/
|
||||
#define FT_LIST_H <freetype/ftlist.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_OUTLINE_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* scalable outline management API of FreeType~2.
|
||||
*
|
||||
*/
|
||||
#define FT_OUTLINE_H <freetype/ftoutln.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_SIZES_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* API which manages multiple @FT_Size objects per face.
|
||||
*
|
||||
*/
|
||||
#define FT_SIZES_H <freetype/ftsizes.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_MODULE_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* module management API of FreeType~2.
|
||||
*
|
||||
*/
|
||||
#define FT_MODULE_H <freetype/ftmodapi.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_RENDER_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* renderer module management API of FreeType~2.
|
||||
*
|
||||
*/
|
||||
#define FT_RENDER_H <freetype/ftrender.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_DRIVER_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing
|
||||
* structures and macros related to the driver modules.
|
||||
*
|
||||
*/
|
||||
#define FT_DRIVER_H <freetype/ftdriver.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_AUTOHINTER_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing
|
||||
* structures and macros related to the auto-hinting module.
|
||||
*
|
||||
* Deprecated since version 2.9; use @FT_DRIVER_H instead.
|
||||
*
|
||||
*/
|
||||
#define FT_AUTOHINTER_H FT_DRIVER_H
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_CFF_DRIVER_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing
|
||||
* structures and macros related to the CFF driver module.
|
||||
*
|
||||
* Deprecated since version 2.9; use @FT_DRIVER_H instead.
|
||||
*
|
||||
*/
|
||||
#define FT_CFF_DRIVER_H FT_DRIVER_H
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_TRUETYPE_DRIVER_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing
|
||||
* structures and macros related to the TrueType driver module.
|
||||
*
|
||||
* Deprecated since version 2.9; use @FT_DRIVER_H instead.
|
||||
*
|
||||
*/
|
||||
#define FT_TRUETYPE_DRIVER_H FT_DRIVER_H
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_PCF_DRIVER_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing
|
||||
* structures and macros related to the PCF driver module.
|
||||
*
|
||||
* Deprecated since version 2.9; use @FT_DRIVER_H instead.
|
||||
*
|
||||
*/
|
||||
#define FT_PCF_DRIVER_H FT_DRIVER_H
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_TYPE1_TABLES_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* types and API specific to the Type~1 format.
|
||||
*
|
||||
*/
|
||||
#define FT_TYPE1_TABLES_H <freetype/t1tables.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_TRUETYPE_IDS_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* enumeration values which identify name strings, languages, encodings,
|
||||
* etc. This file really contains a _large_ set of constant macro
|
||||
* definitions, taken from the TrueType and OpenType specifications.
|
||||
*
|
||||
*/
|
||||
#define FT_TRUETYPE_IDS_H <freetype/ttnameid.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_TRUETYPE_TABLES_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* types and API specific to the TrueType (as well as OpenType) format.
|
||||
*
|
||||
*/
|
||||
#define FT_TRUETYPE_TABLES_H <freetype/tttables.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_TRUETYPE_TAGS_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* definitions of TrueType four-byte `tags' which identify blocks in
|
||||
* SFNT-based font formats (i.e., TrueType and OpenType).
|
||||
*
|
||||
*/
|
||||
#define FT_TRUETYPE_TAGS_H <freetype/tttags.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_BDF_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* definitions of an API which accesses BDF-specific strings from a
|
||||
* face.
|
||||
*
|
||||
*/
|
||||
#define FT_BDF_H <freetype/ftbdf.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_CID_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* definitions of an API which access CID font information from a
|
||||
* face.
|
||||
*
|
||||
*/
|
||||
#define FT_CID_H <freetype/ftcid.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_GZIP_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* definitions of an API which supports gzip-compressed files.
|
||||
*
|
||||
*/
|
||||
#define FT_GZIP_H <freetype/ftgzip.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_LZW_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* definitions of an API which supports LZW-compressed files.
|
||||
*
|
||||
*/
|
||||
#define FT_LZW_H <freetype/ftlzw.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_BZIP2_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* definitions of an API which supports bzip2-compressed files.
|
||||
*
|
||||
*/
|
||||
#define FT_BZIP2_H <freetype/ftbzip2.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_WINFONTS_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* definitions of an API which supports Windows FNT files.
|
||||
*
|
||||
*/
|
||||
#define FT_WINFONTS_H <freetype/ftwinfnt.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_GLYPH_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* API of the optional glyph management component.
|
||||
*
|
||||
*/
|
||||
#define FT_GLYPH_H <freetype/ftglyph.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_BITMAP_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* API of the optional bitmap conversion component.
|
||||
*
|
||||
*/
|
||||
#define FT_BITMAP_H <freetype/ftbitmap.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_BBOX_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* API of the optional exact bounding box computation routines.
|
||||
*
|
||||
*/
|
||||
#define FT_BBOX_H <freetype/ftbbox.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_CACHE_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* API of the optional FreeType~2 cache sub-system.
|
||||
*
|
||||
*/
|
||||
#define FT_CACHE_H <freetype/ftcache.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_MAC_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* Macintosh-specific FreeType~2 API. The latter is used to access
|
||||
* fonts embedded in resource forks.
|
||||
*
|
||||
* This header file must be explicitly included by client applications
|
||||
* compiled on the Mac (note that the base API still works though).
|
||||
*
|
||||
*/
|
||||
#define FT_MAC_H <freetype/ftmac.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_MULTIPLE_MASTERS_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* optional multiple-masters management API of FreeType~2.
|
||||
*
|
||||
*/
|
||||
#define FT_MULTIPLE_MASTERS_H <freetype/ftmm.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_SFNT_NAMES_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* optional FreeType~2 API which accesses embedded `name' strings in
|
||||
* SFNT-based font formats (i.e., TrueType and OpenType).
|
||||
*
|
||||
*/
|
||||
#define FT_SFNT_NAMES_H <freetype/ftsnames.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_OPENTYPE_VALIDATE_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* optional FreeType~2 API which validates OpenType tables (BASE, GDEF,
|
||||
* GPOS, GSUB, JSTF).
|
||||
*
|
||||
*/
|
||||
#define FT_OPENTYPE_VALIDATE_H <freetype/ftotval.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_GX_VALIDATE_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* optional FreeType~2 API which validates TrueTypeGX/AAT tables (feat,
|
||||
* mort, morx, bsln, just, kern, opbd, trak, prop).
|
||||
*
|
||||
*/
|
||||
#define FT_GX_VALIDATE_H <freetype/ftgxval.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_PFR_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* FreeType~2 API which accesses PFR-specific data.
|
||||
*
|
||||
*/
|
||||
#define FT_PFR_H <freetype/ftpfr.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_STROKER_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* FreeType~2 API which provides functions to stroke outline paths.
|
||||
*/
|
||||
#define FT_STROKER_H <freetype/ftstroke.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_SYNTHESIS_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* FreeType~2 API which performs artificial obliquing and emboldening.
|
||||
*/
|
||||
#define FT_SYNTHESIS_H <freetype/ftsynth.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_FONT_FORMATS_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* FreeType~2 API which provides functions specific to font formats.
|
||||
*/
|
||||
#define FT_FONT_FORMATS_H <freetype/ftfntfmt.h>
|
||||
|
||||
/* deprecated */
|
||||
#define FT_XFREE86_H FT_FONT_FORMATS_H
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_TRIGONOMETRY_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* FreeType~2 API which performs trigonometric computations (e.g.,
|
||||
* cosines and arc tangents).
|
||||
*/
|
||||
#define FT_TRIGONOMETRY_H <freetype/fttrigon.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_LCD_FILTER_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* FreeType~2 API which performs color filtering for subpixel rendering.
|
||||
*/
|
||||
#define FT_LCD_FILTER_H <freetype/ftlcdfil.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_INCREMENTAL_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* FreeType~2 API which performs incremental glyph loading.
|
||||
*/
|
||||
#define FT_INCREMENTAL_H <freetype/ftincrem.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_GASP_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* FreeType~2 API which returns entries from the TrueType GASP table.
|
||||
*/
|
||||
#define FT_GASP_H <freetype/ftgasp.h>
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_ADVANCES_H
|
||||
*
|
||||
* @description:
|
||||
* A macro used in #include statements to name the file containing the
|
||||
* FreeType~2 API which returns individual and ranged glyph advances.
|
||||
*/
|
||||
#define FT_ADVANCES_H <freetype/ftadvanc.h>
|
||||
|
||||
|
||||
/* */
|
||||
|
||||
/* These header files don't need to be included by the user. */
|
||||
#define FT_ERROR_DEFINITIONS_H <freetype/fterrdef.h>
|
||||
#define FT_PARAMETER_TAGS_H <freetype/ftparams.h>
|
||||
|
||||
/* Deprecated macros. */
|
||||
#define FT_UNPATENTED_HINTING_H <freetype/ftparams.h>
|
||||
#define FT_TRUETYPE_UNPATENTED_H <freetype/ftparams.h>
|
||||
|
||||
/* FT_CACHE_H is the only header file needed for the cache subsystem. */
|
||||
#define FT_CACHE_IMAGE_H FT_CACHE_H
|
||||
#define FT_CACHE_SMALL_BITMAPS_H FT_CACHE_H
|
||||
#define FT_CACHE_CHARMAP_H FT_CACHE_H
|
||||
|
||||
/* The internals of the cache sub-system are no longer exposed. We */
|
||||
/* default to FT_CACHE_H at the moment just in case, but we know of */
|
||||
/* no rogue client that uses them. */
|
||||
/* */
|
||||
#define FT_CACHE_MANAGER_H FT_CACHE_H
|
||||
#define FT_CACHE_INTERNAL_MRU_H FT_CACHE_H
|
||||
#define FT_CACHE_INTERNAL_MANAGER_H FT_CACHE_H
|
||||
#define FT_CACHE_INTERNAL_CACHE_H FT_CACHE_H
|
||||
#define FT_CACHE_INTERNAL_GLYPH_H FT_CACHE_H
|
||||
#define FT_CACHE_INTERNAL_IMAGE_H FT_CACHE_H
|
||||
#define FT_CACHE_INTERNAL_SBITS_H FT_CACHE_H
|
||||
|
||||
|
||||
/*
|
||||
* Include internal headers definitions from <internal/...>
|
||||
* only when building the library.
|
||||
*/
|
||||
#ifdef FT2_BUILD_LIBRARY
|
||||
#define FT_INTERNAL_INTERNAL_H <freetype/internal/internal.h>
|
||||
#include FT_INTERNAL_INTERNAL_H
|
||||
#endif /* FT2_BUILD_LIBRARY */
|
||||
|
||||
|
||||
#endif /* FTHEADER_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,20 @@
|
||||
/* This is a generated file. */
|
||||
FT_USE_MODULE( FT_Driver_ClassRec, tt_driver_class )
|
||||
FT_USE_MODULE( FT_Driver_ClassRec, t1_driver_class )
|
||||
FT_USE_MODULE( FT_Driver_ClassRec, cff_driver_class )
|
||||
FT_USE_MODULE( FT_Driver_ClassRec, t1cid_driver_class )
|
||||
FT_USE_MODULE( FT_Driver_ClassRec, pfr_driver_class )
|
||||
FT_USE_MODULE( FT_Driver_ClassRec, t42_driver_class )
|
||||
FT_USE_MODULE( FT_Driver_ClassRec, winfnt_driver_class )
|
||||
FT_USE_MODULE( FT_Driver_ClassRec, pcf_driver_class )
|
||||
FT_USE_MODULE( FT_Driver_ClassRec, bdf_driver_class )
|
||||
FT_USE_MODULE( FT_Module_Class, sfnt_module_class )
|
||||
FT_USE_MODULE( FT_Module_Class, autofit_module_class )
|
||||
FT_USE_MODULE( FT_Module_Class, pshinter_module_class )
|
||||
FT_USE_MODULE( FT_Renderer_Class, ft_raster1_renderer_class )
|
||||
FT_USE_MODULE( FT_Renderer_Class, ft_smooth_renderer_class )
|
||||
FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcd_renderer_class )
|
||||
FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcdv_renderer_class )
|
||||
FT_USE_MODULE( FT_Module_Class, psaux_module_class )
|
||||
FT_USE_MODULE( FT_Module_Class, psnames_module_class )
|
||||
/* EOF */
|
||||
@@ -0,0 +1,977 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftoption.h */
|
||||
/* */
|
||||
/* User-selectable configuration macros (specification only). */
|
||||
/* */
|
||||
/* Copyright 1996-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTOPTION_H_
|
||||
#define FTOPTION_H_
|
||||
|
||||
|
||||
#include <ft2build.h>
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* USER-SELECTABLE CONFIGURATION MACROS */
|
||||
/* */
|
||||
/* This file contains the default configuration macro definitions for */
|
||||
/* a standard build of the FreeType library. There are three ways to */
|
||||
/* use this file to build project-specific versions of the library: */
|
||||
/* */
|
||||
/* - You can modify this file by hand, but this is not recommended in */
|
||||
/* cases where you would like to build several versions of the */
|
||||
/* library from a single source directory. */
|
||||
/* */
|
||||
/* - You can put a copy of this file in your build directory, more */
|
||||
/* precisely in `$BUILD/freetype/config/ftoption.h', where `$BUILD' */
|
||||
/* is the name of a directory that is included _before_ the FreeType */
|
||||
/* include path during compilation. */
|
||||
/* */
|
||||
/* The default FreeType Makefiles and Jamfiles use the build */
|
||||
/* directory `builds/<system>' by default, but you can easily change */
|
||||
/* that for your own projects. */
|
||||
/* */
|
||||
/* - Copy the file <ft2build.h> to `$BUILD/ft2build.h' and modify it */
|
||||
/* slightly to pre-define the macro FT_CONFIG_OPTIONS_H used to */
|
||||
/* locate this file during the build. For example, */
|
||||
/* */
|
||||
/* #define FT_CONFIG_OPTIONS_H <myftoptions.h> */
|
||||
/* #include <freetype/config/ftheader.h> */
|
||||
/* */
|
||||
/* will use `$BUILD/myftoptions.h' instead of this file for macro */
|
||||
/* definitions. */
|
||||
/* */
|
||||
/* Note also that you can similarly pre-define the macro */
|
||||
/* FT_CONFIG_MODULES_H used to locate the file listing of the modules */
|
||||
/* that are statically linked to the library at compile time. By */
|
||||
/* default, this file is <freetype/config/ftmodule.h>. */
|
||||
/* */
|
||||
/* We highly recommend using the third method whenever possible. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** G E N E R A L F R E E T Y P E 2 C O N F I G U R A T I O N ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*#***********************************************************************/
|
||||
/* */
|
||||
/* If you enable this configuration option, FreeType recognizes an */
|
||||
/* environment variable called `FREETYPE_PROPERTIES', which can be used */
|
||||
/* to control the various font drivers and modules. The controllable */
|
||||
/* properties are listed in the section @properties. */
|
||||
/* */
|
||||
/* You have to undefine this configuration option on platforms that lack */
|
||||
/* the concept of environment variables (and thus don't have the */
|
||||
/* `getenv' function), for example Windows CE. */
|
||||
/* */
|
||||
/* `FREETYPE_PROPERTIES' has the following syntax form (broken here into */
|
||||
/* multiple lines for better readability). */
|
||||
/* */
|
||||
/* { */
|
||||
/* <optional whitespace> */
|
||||
/* <module-name1> ':' */
|
||||
/* <property-name1> '=' <property-value1> */
|
||||
/* <whitespace> */
|
||||
/* <module-name2> ':' */
|
||||
/* <property-name2> '=' <property-value2> */
|
||||
/* ... */
|
||||
/* } */
|
||||
/* */
|
||||
/* Example: */
|
||||
/* */
|
||||
/* FREETYPE_PROPERTIES=truetype:interpreter-version=35 \ */
|
||||
/* cff:no-stem-darkening=1 \ */
|
||||
/* autofitter:warping=1 */
|
||||
/* */
|
||||
#define FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Uncomment the line below if you want to activate LCD rendering */
|
||||
/* technology similar to ClearType in this build of the library. This */
|
||||
/* technology triples the resolution in the direction color subpixels. */
|
||||
/* To mitigate color fringes inherent to this technology, you also need */
|
||||
/* to explicitly set up LCD filtering. */
|
||||
/* */
|
||||
/* Note that this feature is covered by several Microsoft patents */
|
||||
/* and should not be activated in any default build of the library. */
|
||||
/* When this macro is not defined, FreeType offers alternative LCD */
|
||||
/* rendering technology that produces excellent output without LCD */
|
||||
/* filtering. */
|
||||
/* */
|
||||
/* #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Many compilers provide a non-ANSI 64-bit data type that can be used */
|
||||
/* by FreeType to speed up some computations. However, this will create */
|
||||
/* some problems when compiling the library in strict ANSI mode. */
|
||||
/* */
|
||||
/* For this reason, the use of 64-bit integers is normally disabled when */
|
||||
/* the __STDC__ macro is defined. You can however disable this by */
|
||||
/* defining the macro FT_CONFIG_OPTION_FORCE_INT64 here. */
|
||||
/* */
|
||||
/* For most compilers, this will only create compilation warnings when */
|
||||
/* building the library. */
|
||||
/* */
|
||||
/* ObNote: The compiler-specific 64-bit integers are detected in the */
|
||||
/* file `ftconfig.h' either statically or through the */
|
||||
/* `configure' script on supported platforms. */
|
||||
/* */
|
||||
#undef FT_CONFIG_OPTION_FORCE_INT64
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* If this macro is defined, do not try to use an assembler version of */
|
||||
/* performance-critical functions (e.g. FT_MulFix). You should only do */
|
||||
/* that to verify that the assembler function works properly, or to */
|
||||
/* execute benchmark tests of the various implementations. */
|
||||
/* #define FT_CONFIG_OPTION_NO_ASSEMBLER */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* If this macro is defined, try to use an inlined assembler version of */
|
||||
/* the `FT_MulFix' function, which is a `hotspot' when loading and */
|
||||
/* hinting glyphs, and which should be executed as fast as possible. */
|
||||
/* */
|
||||
/* Note that if your compiler or CPU is not supported, this will default */
|
||||
/* to the standard and portable implementation found in `ftcalc.c'. */
|
||||
/* */
|
||||
#define FT_CONFIG_OPTION_INLINE_MULFIX
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* LZW-compressed file support. */
|
||||
/* */
|
||||
/* FreeType now handles font files that have been compressed with the */
|
||||
/* `compress' program. This is mostly used to parse many of the PCF */
|
||||
/* files that come with various X11 distributions. The implementation */
|
||||
/* uses NetBSD's `zopen' to partially uncompress the file on the fly */
|
||||
/* (see src/lzw/ftgzip.c). */
|
||||
/* */
|
||||
/* Define this macro if you want to enable this `feature'. */
|
||||
/* */
|
||||
#define FT_CONFIG_OPTION_USE_LZW
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Gzip-compressed file support. */
|
||||
/* */
|
||||
/* FreeType now handles font files that have been compressed with the */
|
||||
/* `gzip' program. This is mostly used to parse many of the PCF files */
|
||||
/* that come with XFree86. The implementation uses `zlib' to */
|
||||
/* partially uncompress the file on the fly (see src/gzip/ftgzip.c). */
|
||||
/* */
|
||||
/* Define this macro if you want to enable this `feature'. See also */
|
||||
/* the macro FT_CONFIG_OPTION_SYSTEM_ZLIB below. */
|
||||
/* */
|
||||
#define FT_CONFIG_OPTION_USE_ZLIB
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* ZLib library selection */
|
||||
/* */
|
||||
/* This macro is only used when FT_CONFIG_OPTION_USE_ZLIB is defined. */
|
||||
/* It allows FreeType's `ftgzip' component to link to the system's */
|
||||
/* installation of the ZLib library. This is useful on systems like */
|
||||
/* Unix or VMS where it generally is already available. */
|
||||
/* */
|
||||
/* If you let it undefined, the component will use its own copy */
|
||||
/* of the zlib sources instead. These have been modified to be */
|
||||
/* included directly within the component and *not* export external */
|
||||
/* function names. This allows you to link any program with FreeType */
|
||||
/* _and_ ZLib without linking conflicts. */
|
||||
/* */
|
||||
/* Do not #undef this macro here since the build system might define */
|
||||
/* it for certain configurations only. */
|
||||
/* */
|
||||
/* If you use a build system like cmake or the `configure' script, */
|
||||
/* options set by those programs have precendence, overwriting the */
|
||||
/* value here with the configured one. */
|
||||
/* */
|
||||
#define FT_CONFIG_OPTION_SYSTEM_ZLIB
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Bzip2-compressed file support. */
|
||||
/* */
|
||||
/* FreeType now handles font files that have been compressed with the */
|
||||
/* `bzip2' program. This is mostly used to parse many of the PCF */
|
||||
/* files that come with XFree86. The implementation uses `libbz2' to */
|
||||
/* partially uncompress the file on the fly (see src/bzip2/ftbzip2.c). */
|
||||
/* Contrary to gzip, bzip2 currently is not included and need to use */
|
||||
/* the system available bzip2 implementation. */
|
||||
/* */
|
||||
/* Define this macro if you want to enable this `feature'. */
|
||||
/* */
|
||||
/* If you use a build system like cmake or the `configure' script, */
|
||||
/* options set by those programs have precendence, overwriting the */
|
||||
/* value here with the configured one. */
|
||||
/* */
|
||||
#define FT_CONFIG_OPTION_USE_BZIP2
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Define to disable the use of file stream functions and types, FILE, */
|
||||
/* fopen() etc. Enables the use of smaller system libraries on embedded */
|
||||
/* systems that have multiple system libraries, some with or without */
|
||||
/* file stream support, in the cases where file stream support is not */
|
||||
/* necessary such as memory loading of font files. */
|
||||
/* */
|
||||
/* #define FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* PNG bitmap support. */
|
||||
/* */
|
||||
/* FreeType now handles loading color bitmap glyphs in the PNG format. */
|
||||
/* This requires help from the external libpng library. Uncompressed */
|
||||
/* color bitmaps do not need any external libraries and will be */
|
||||
/* supported regardless of this configuration. */
|
||||
/* */
|
||||
/* Define this macro if you want to enable this `feature'. */
|
||||
/* */
|
||||
/* If you use a build system like cmake or the `configure' script, */
|
||||
/* options set by those programs have precendence, overwriting the */
|
||||
/* value here with the configured one. */
|
||||
/* */
|
||||
/* #undef FT_CONFIG_OPTION_USE_PNG */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* HarfBuzz support. */
|
||||
/* */
|
||||
/* FreeType uses the HarfBuzz library to improve auto-hinting of */
|
||||
/* OpenType fonts. If available, many glyphs not directly addressable */
|
||||
/* by a font's character map will be hinted also. */
|
||||
/* */
|
||||
/* Define this macro if you want to enable this `feature'. */
|
||||
/* */
|
||||
/* If you use a build system like cmake or the `configure' script, */
|
||||
/* options set by those programs have precendence, overwriting the */
|
||||
/* value here with the configured one. */
|
||||
/* */
|
||||
/* #undef FT_CONFIG_OPTION_USE_HARFBUZZ */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Glyph Postscript Names handling */
|
||||
/* */
|
||||
/* By default, FreeType 2 is compiled with the `psnames' module. This */
|
||||
/* module is in charge of converting a glyph name string into a */
|
||||
/* Unicode value, or return a Macintosh standard glyph name for the */
|
||||
/* use with the TrueType `post' table. */
|
||||
/* */
|
||||
/* Undefine this macro if you do not want `psnames' compiled in your */
|
||||
/* build of FreeType. This has the following effects: */
|
||||
/* */
|
||||
/* - The TrueType driver will provide its own set of glyph names, */
|
||||
/* if you build it to support postscript names in the TrueType */
|
||||
/* `post' table, but will not synthesize a missing Unicode charmap. */
|
||||
/* */
|
||||
/* - The Type 1 driver will not be able to synthesize a Unicode */
|
||||
/* charmap out of the glyphs found in the fonts. */
|
||||
/* */
|
||||
/* You would normally undefine this configuration macro when building */
|
||||
/* a version of FreeType that doesn't contain a Type 1 or CFF driver. */
|
||||
/* */
|
||||
#define FT_CONFIG_OPTION_POSTSCRIPT_NAMES
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Postscript Names to Unicode Values support */
|
||||
/* */
|
||||
/* By default, FreeType 2 is built with the `PSNames' module compiled */
|
||||
/* in. Among other things, the module is used to convert a glyph name */
|
||||
/* into a Unicode value. This is especially useful in order to */
|
||||
/* synthesize on the fly a Unicode charmap from the CFF/Type 1 driver */
|
||||
/* through a big table named the `Adobe Glyph List' (AGL). */
|
||||
/* */
|
||||
/* Undefine this macro if you do not want the Adobe Glyph List */
|
||||
/* compiled in your `PSNames' module. The Type 1 driver will not be */
|
||||
/* able to synthesize a Unicode charmap out of the glyphs found in the */
|
||||
/* fonts. */
|
||||
/* */
|
||||
#define FT_CONFIG_OPTION_ADOBE_GLYPH_LIST
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Support for Mac fonts */
|
||||
/* */
|
||||
/* Define this macro if you want support for outline fonts in Mac */
|
||||
/* format (mac dfont, mac resource, macbinary containing a mac */
|
||||
/* resource) on non-Mac platforms. */
|
||||
/* */
|
||||
/* Note that the `FOND' resource isn't checked. */
|
||||
/* */
|
||||
#define FT_CONFIG_OPTION_MAC_FONTS
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Guessing methods to access embedded resource forks */
|
||||
/* */
|
||||
/* Enable extra Mac fonts support on non-Mac platforms (e.g. */
|
||||
/* GNU/Linux). */
|
||||
/* */
|
||||
/* Resource forks which include fonts data are stored sometimes in */
|
||||
/* locations which users or developers don't expected. In some cases, */
|
||||
/* resource forks start with some offset from the head of a file. In */
|
||||
/* other cases, the actual resource fork is stored in file different */
|
||||
/* from what the user specifies. If this option is activated, */
|
||||
/* FreeType tries to guess whether such offsets or different file */
|
||||
/* names must be used. */
|
||||
/* */
|
||||
/* Note that normal, direct access of resource forks is controlled via */
|
||||
/* the FT_CONFIG_OPTION_MAC_FONTS option. */
|
||||
/* */
|
||||
#ifdef FT_CONFIG_OPTION_MAC_FONTS
|
||||
#define FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Allow the use of FT_Incremental_Interface to load typefaces that */
|
||||
/* contain no glyph data, but supply it via a callback function. */
|
||||
/* This is required by clients supporting document formats which */
|
||||
/* supply font data incrementally as the document is parsed, such */
|
||||
/* as the Ghostscript interpreter for the PostScript language. */
|
||||
/* */
|
||||
#define FT_CONFIG_OPTION_INCREMENTAL
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* The size in bytes of the render pool used by the scan-line converter */
|
||||
/* to do all of its work. */
|
||||
/* */
|
||||
#define FT_RENDER_POOL_SIZE 16384L
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* FT_MAX_MODULES */
|
||||
/* */
|
||||
/* The maximum number of modules that can be registered in a single */
|
||||
/* FreeType library object. 32 is the default. */
|
||||
/* */
|
||||
#define FT_MAX_MODULES 32
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Debug level */
|
||||
/* */
|
||||
/* FreeType can be compiled in debug or trace mode. In debug mode, */
|
||||
/* errors are reported through the `ftdebug' component. In trace */
|
||||
/* mode, additional messages are sent to the standard output during */
|
||||
/* execution. */
|
||||
/* */
|
||||
/* Define FT_DEBUG_LEVEL_ERROR to build the library in debug mode. */
|
||||
/* Define FT_DEBUG_LEVEL_TRACE to build it in trace mode. */
|
||||
/* */
|
||||
/* Don't define any of these macros to compile in `release' mode! */
|
||||
/* */
|
||||
/* Do not #undef these macros here since the build system might define */
|
||||
/* them for certain configurations only. */
|
||||
/* */
|
||||
/* #define FT_DEBUG_LEVEL_ERROR */
|
||||
/* #define FT_DEBUG_LEVEL_TRACE */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Autofitter debugging */
|
||||
/* */
|
||||
/* If FT_DEBUG_AUTOFIT is defined, FreeType provides some means to */
|
||||
/* control the autofitter behaviour for debugging purposes with global */
|
||||
/* boolean variables (consequently, you should *never* enable this */
|
||||
/* while compiling in `release' mode): */
|
||||
/* */
|
||||
/* _af_debug_disable_horz_hints */
|
||||
/* _af_debug_disable_vert_hints */
|
||||
/* _af_debug_disable_blue_hints */
|
||||
/* */
|
||||
/* Additionally, the following functions provide dumps of various */
|
||||
/* internal autofit structures to stdout (using `printf'): */
|
||||
/* */
|
||||
/* af_glyph_hints_dump_points */
|
||||
/* af_glyph_hints_dump_segments */
|
||||
/* af_glyph_hints_dump_edges */
|
||||
/* af_glyph_hints_get_num_segments */
|
||||
/* af_glyph_hints_get_segment_offset */
|
||||
/* */
|
||||
/* As an argument, they use another global variable: */
|
||||
/* */
|
||||
/* _af_debug_hints */
|
||||
/* */
|
||||
/* Please have a look at the `ftgrid' demo program to see how those */
|
||||
/* variables and macros should be used. */
|
||||
/* */
|
||||
/* Do not #undef these macros here since the build system might define */
|
||||
/* them for certain configurations only. */
|
||||
/* */
|
||||
/* #define FT_DEBUG_AUTOFIT */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Memory Debugging */
|
||||
/* */
|
||||
/* FreeType now comes with an integrated memory debugger that is */
|
||||
/* capable of detecting simple errors like memory leaks or double */
|
||||
/* deletes. To compile it within your build of the library, you */
|
||||
/* should define FT_DEBUG_MEMORY here. */
|
||||
/* */
|
||||
/* Note that the memory debugger is only activated at runtime when */
|
||||
/* when the _environment_ variable `FT2_DEBUG_MEMORY' is defined also! */
|
||||
/* */
|
||||
/* Do not #undef this macro here since the build system might define */
|
||||
/* it for certain configurations only. */
|
||||
/* */
|
||||
/* #define FT_DEBUG_MEMORY */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Module errors */
|
||||
/* */
|
||||
/* If this macro is set (which is _not_ the default), the higher byte */
|
||||
/* of an error code gives the module in which the error has occurred, */
|
||||
/* while the lower byte is the real error code. */
|
||||
/* */
|
||||
/* Setting this macro makes sense for debugging purposes only, since */
|
||||
/* it would break source compatibility of certain programs that use */
|
||||
/* FreeType 2. */
|
||||
/* */
|
||||
/* More details can be found in the files ftmoderr.h and fterrors.h. */
|
||||
/* */
|
||||
#undef FT_CONFIG_OPTION_USE_MODULE_ERRORS
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Position Independent Code */
|
||||
/* */
|
||||
/* If this macro is set (which is _not_ the default), FreeType2 will */
|
||||
/* avoid creating constants that require address fixups. Instead the */
|
||||
/* constants will be moved into a struct and additional intialization */
|
||||
/* code will be used. */
|
||||
/* */
|
||||
/* Setting this macro is needed for systems that prohibit address */
|
||||
/* fixups, such as BREW. [Note that standard compilers like gcc or */
|
||||
/* clang handle PIC generation automatically; you don't have to set */
|
||||
/* FT_CONFIG_OPTION_PIC, which is only necessary for very special */
|
||||
/* compilers.] */
|
||||
/* */
|
||||
/* Note that FT_CONFIG_OPTION_PIC support is not available for all */
|
||||
/* modules (see `modules.cfg' for a complete list). For building with */
|
||||
/* FT_CONFIG_OPTION_PIC support, do the following. */
|
||||
/* */
|
||||
/* 0. Clone the repository. */
|
||||
/* 1. Define FT_CONFIG_OPTION_PIC. */
|
||||
/* 2. Remove all subdirectories in `src' that don't have */
|
||||
/* FT_CONFIG_OPTION_PIC support. */
|
||||
/* 3. Comment out the corresponding modules in `modules.cfg'. */
|
||||
/* 4. Compile. */
|
||||
/* */
|
||||
/* #define FT_CONFIG_OPTION_PIC */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** S F N T D R I V E R C O N F I G U R A T I O N ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Define TT_CONFIG_OPTION_EMBEDDED_BITMAPS if you want to support */
|
||||
/* embedded bitmaps in all formats using the SFNT module (namely */
|
||||
/* TrueType & OpenType). */
|
||||
/* */
|
||||
#define TT_CONFIG_OPTION_EMBEDDED_BITMAPS
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Define TT_CONFIG_OPTION_POSTSCRIPT_NAMES if you want to be able to */
|
||||
/* load and enumerate the glyph Postscript names in a TrueType or */
|
||||
/* OpenType file. */
|
||||
/* */
|
||||
/* Note that when you do not compile the `PSNames' module by undefining */
|
||||
/* the above FT_CONFIG_OPTION_POSTSCRIPT_NAMES, the `sfnt' module will */
|
||||
/* contain additional code used to read the PS Names table from a font. */
|
||||
/* */
|
||||
/* (By default, the module uses `PSNames' to extract glyph names.) */
|
||||
/* */
|
||||
#define TT_CONFIG_OPTION_POSTSCRIPT_NAMES
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Define TT_CONFIG_OPTION_SFNT_NAMES if your applications need to */
|
||||
/* access the internal name table in a SFNT-based format like TrueType */
|
||||
/* or OpenType. The name table contains various strings used to */
|
||||
/* describe the font, like family name, copyright, version, etc. It */
|
||||
/* does not contain any glyph name though. */
|
||||
/* */
|
||||
/* Accessing SFNT names is done through the functions declared in */
|
||||
/* `ftsnames.h'. */
|
||||
/* */
|
||||
#define TT_CONFIG_OPTION_SFNT_NAMES
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* TrueType CMap support */
|
||||
/* */
|
||||
/* Here you can fine-tune which TrueType CMap table format shall be */
|
||||
/* supported. */
|
||||
#define TT_CONFIG_CMAP_FORMAT_0
|
||||
#define TT_CONFIG_CMAP_FORMAT_2
|
||||
#define TT_CONFIG_CMAP_FORMAT_4
|
||||
#define TT_CONFIG_CMAP_FORMAT_6
|
||||
#define TT_CONFIG_CMAP_FORMAT_8
|
||||
#define TT_CONFIG_CMAP_FORMAT_10
|
||||
#define TT_CONFIG_CMAP_FORMAT_12
|
||||
#define TT_CONFIG_CMAP_FORMAT_13
|
||||
#define TT_CONFIG_CMAP_FORMAT_14
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** T R U E T Y P E D R I V E R C O N F I G U R A T I O N ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Define TT_CONFIG_OPTION_BYTECODE_INTERPRETER if you want to compile */
|
||||
/* a bytecode interpreter in the TrueType driver. */
|
||||
/* */
|
||||
/* By undefining this, you will only compile the code necessary to load */
|
||||
/* TrueType glyphs without hinting. */
|
||||
/* */
|
||||
/* Do not #undef this macro here, since the build system might */
|
||||
/* define it for certain configurations only. */
|
||||
/* */
|
||||
#define TT_CONFIG_OPTION_BYTECODE_INTERPRETER
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Define TT_CONFIG_OPTION_SUBPIXEL_HINTING if you want to compile */
|
||||
/* subpixel hinting support into the TrueType driver. This modifies the */
|
||||
/* TrueType hinting mechanism when anything but FT_RENDER_MODE_MONO is */
|
||||
/* requested. */
|
||||
/* */
|
||||
/* In particular, it modifies the bytecode interpreter to interpret (or */
|
||||
/* not) instructions in a certain way so that all TrueType fonts look */
|
||||
/* like they do in a Windows ClearType (DirectWrite) environment. See */
|
||||
/* [1] for a technical overview on what this means. See `ttinterp.h' */
|
||||
/* for more details on the LEAN option. */
|
||||
/* */
|
||||
/* There are three possible values. */
|
||||
/* */
|
||||
/* Value 1: */
|
||||
/* This value is associated with the `Infinality' moniker, */
|
||||
/* contributed by an individual nicknamed Infinality with the goal of */
|
||||
/* making TrueType fonts render better than on Windows. A high */
|
||||
/* amount of configurability and flexibility, down to rules for */
|
||||
/* single glyphs in fonts, but also very slow. Its experimental and */
|
||||
/* slow nature and the original developer losing interest meant that */
|
||||
/* this option was never enabled in default builds. */
|
||||
/* */
|
||||
/* The corresponding interpreter version is v38. */
|
||||
/* */
|
||||
/* Value 2: */
|
||||
/* The new default mode for the TrueType driver. The Infinality code */
|
||||
/* base was stripped to the bare minimum and all configurability */
|
||||
/* removed in the name of speed and simplicity. The configurability */
|
||||
/* was mainly aimed at legacy fonts like Arial, Times New Roman, or */
|
||||
/* Courier. Legacy fonts are fonts that modify vertical stems to */
|
||||
/* achieve clean black-and-white bitmaps. The new mode focuses on */
|
||||
/* applying a minimal set of rules to all fonts indiscriminately so */
|
||||
/* that modern and web fonts render well while legacy fonts render */
|
||||
/* okay. */
|
||||
/* */
|
||||
/* The corresponding interpreter version is v40. */
|
||||
/* */
|
||||
/* Value 3: */
|
||||
/* Compile both, making both v38 and v40 available (the latter is the */
|
||||
/* default). */
|
||||
/* */
|
||||
/* By undefining these, you get rendering behavior like on Windows */
|
||||
/* without ClearType, i.e., Windows XP without ClearType enabled and */
|
||||
/* Win9x (interpreter version v35). Or not, depending on how much */
|
||||
/* hinting blood and testing tears the font designer put into a given */
|
||||
/* font. If you define one or both subpixel hinting options, you can */
|
||||
/* switch between between v35 and the ones you define (using */
|
||||
/* `FT_Property_Set'). */
|
||||
/* */
|
||||
/* This option requires TT_CONFIG_OPTION_BYTECODE_INTERPRETER to be */
|
||||
/* defined. */
|
||||
/* */
|
||||
/* [1] https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx */
|
||||
/* */
|
||||
/* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING 1 */
|
||||
#define TT_CONFIG_OPTION_SUBPIXEL_HINTING 2
|
||||
/* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING ( 1 | 2 ) */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Define TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED to compile the */
|
||||
/* TrueType glyph loader to use Apple's definition of how to handle */
|
||||
/* component offsets in composite glyphs. */
|
||||
/* */
|
||||
/* Apple and MS disagree on the default behavior of component offsets */
|
||||
/* in composites. Apple says that they should be scaled by the scaling */
|
||||
/* factors in the transformation matrix (roughly, it's more complex) */
|
||||
/* while MS says they should not. OpenType defines two bits in the */
|
||||
/* composite flags array which can be used to disambiguate, but old */
|
||||
/* fonts will not have them. */
|
||||
/* */
|
||||
/* https://www.microsoft.com/typography/otspec/glyf.htm */
|
||||
/* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6glyf.html */
|
||||
/* */
|
||||
#undef TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Define TT_CONFIG_OPTION_GX_VAR_SUPPORT if you want to include */
|
||||
/* support for Apple's distortable font technology (fvar, gvar, cvar, */
|
||||
/* and avar tables). This has many similarities to Type 1 Multiple */
|
||||
/* Masters support. */
|
||||
/* */
|
||||
#define TT_CONFIG_OPTION_GX_VAR_SUPPORT
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Define TT_CONFIG_OPTION_BDF if you want to include support for */
|
||||
/* an embedded `BDF ' table within SFNT-based bitmap formats. */
|
||||
/* */
|
||||
#define TT_CONFIG_OPTION_BDF
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Option TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES controls the maximum */
|
||||
/* number of bytecode instructions executed for a single run of the */
|
||||
/* bytecode interpreter, needed to prevent infinite loops. You don't */
|
||||
/* want to change this except for very special situations (e.g., making */
|
||||
/* a library fuzzer spend less time to handle broken fonts). */
|
||||
/* */
|
||||
/* It is not expected that this value is ever modified by a configuring */
|
||||
/* script; instead, it gets surrounded with #ifndef ... #endif so that */
|
||||
/* the value can be set as a preprocessor option on the compiler's */
|
||||
/* command line. */
|
||||
/* */
|
||||
#ifndef TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES
|
||||
#define TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES 1000000L
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** T Y P E 1 D R I V E R C O N F I G U R A T I O N ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* T1_MAX_DICT_DEPTH is the maximum depth of nest dictionaries and */
|
||||
/* arrays in the Type 1 stream (see t1load.c). A minimum of 4 is */
|
||||
/* required. */
|
||||
/* */
|
||||
#define T1_MAX_DICT_DEPTH 5
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* T1_MAX_SUBRS_CALLS details the maximum number of nested sub-routine */
|
||||
/* calls during glyph loading. */
|
||||
/* */
|
||||
#define T1_MAX_SUBRS_CALLS 16
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. A */
|
||||
/* minimum of 16 is required. */
|
||||
/* */
|
||||
/* The Chinese font MingTiEG-Medium (CNS 11643 character set) needs 256. */
|
||||
/* */
|
||||
#define T1_MAX_CHARSTRINGS_OPERANDS 256
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Define this configuration macro if you want to prevent the */
|
||||
/* compilation of `t1afm', which is in charge of reading Type 1 AFM */
|
||||
/* files into an existing face. Note that if set, the T1 driver will be */
|
||||
/* unable to produce kerning distances. */
|
||||
/* */
|
||||
#undef T1_CONFIG_OPTION_NO_AFM
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Define this configuration macro if you want to prevent the */
|
||||
/* compilation of the Multiple Masters font support in the Type 1 */
|
||||
/* driver. */
|
||||
/* */
|
||||
#undef T1_CONFIG_OPTION_NO_MM_SUPPORT
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* T1_CONFIG_OPTION_OLD_ENGINE controls whether the pre-Adobe Type 1 */
|
||||
/* engine gets compiled into FreeType. If defined, it is possible to */
|
||||
/* switch between the two engines using the `hinting-engine' property of */
|
||||
/* the type1 driver module. */
|
||||
/* */
|
||||
/* #define T1_CONFIG_OPTION_OLD_ENGINE */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** C F F D R I V E R C O N F I G U R A T I O N ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Using CFF_CONFIG_OPTION_DARKENING_PARAMETER_{X,Y}{1,2,3,4} it is */
|
||||
/* possible to set up the default values of the four control points that */
|
||||
/* define the stem darkening behaviour of the (new) CFF engine. For */
|
||||
/* more details please read the documentation of the */
|
||||
/* `darkening-parameters' property (file `ftdriver.h'), which allows the */
|
||||
/* control at run-time. */
|
||||
/* */
|
||||
/* Do *not* undefine these macros! */
|
||||
/* */
|
||||
#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 500
|
||||
#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1 400
|
||||
|
||||
#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 1000
|
||||
#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2 275
|
||||
|
||||
#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 1667
|
||||
#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3 275
|
||||
|
||||
#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4 2333
|
||||
#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4 0
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* CFF_CONFIG_OPTION_OLD_ENGINE controls whether the pre-Adobe CFF */
|
||||
/* engine gets compiled into FreeType. If defined, it is possible to */
|
||||
/* switch between the two engines using the `hinting-engine' property of */
|
||||
/* the cff driver module. */
|
||||
/* */
|
||||
/* #define CFF_CONFIG_OPTION_OLD_ENGINE */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** P C F D R I V E R C O N F I G U R A T I O N ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* There are many PCF fonts just called `Fixed' which look completely */
|
||||
/* different, and which have nothing to do with each other. When */
|
||||
/* selecting `Fixed' in KDE or Gnome one gets results that appear rather */
|
||||
/* random, the style changes often if one changes the size and one */
|
||||
/* cannot select some fonts at all. This option makes the PCF module */
|
||||
/* prepend the foundry name (plus a space) to the family name. */
|
||||
/* */
|
||||
/* We also check whether we have `wide' characters; all put together, we */
|
||||
/* get family names like `Sony Fixed' or `Misc Fixed Wide'. */
|
||||
/* */
|
||||
/* If this option is activated, it can be controlled with the */
|
||||
/* `no-long-family-names' property of the pcf driver module. */
|
||||
/* */
|
||||
/* #define PCF_CONFIG_OPTION_LONG_FAMILY_NAMES */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/**** ****/
|
||||
/**** A U T O F I T M O D U L E C O N F I G U R A T I O N ****/
|
||||
/**** ****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Compile autofit module with CJK (Chinese, Japanese, Korean) script */
|
||||
/* support. */
|
||||
/* */
|
||||
#define AF_CONFIG_OPTION_CJK
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Compile autofit module with fallback Indic script support, covering */
|
||||
/* some scripts that the `latin' submodule of the autofit module doesn't */
|
||||
/* (yet) handle. */
|
||||
/* */
|
||||
#define AF_CONFIG_OPTION_INDIC
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Compile autofit module with warp hinting. The idea of the warping */
|
||||
/* code is to slightly scale and shift a glyph within a single dimension */
|
||||
/* so that as much of its segments are aligned (more or less) on the */
|
||||
/* grid. To find out the optimal scaling and shifting value, various */
|
||||
/* parameter combinations are tried and scored. */
|
||||
/* */
|
||||
/* This experimental option is active only if the rendering mode is */
|
||||
/* FT_RENDER_MODE_LIGHT; you can switch warping on and off with the */
|
||||
/* `warping' property of the auto-hinter (see file `ftdriver.h' for more */
|
||||
/* information; by default it is switched off). */
|
||||
/* */
|
||||
#define AF_CONFIG_OPTION_USE_WARPER
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Use TrueType-like size metrics for `light' auto-hinting. */
|
||||
/* */
|
||||
/* It is strongly recommended to avoid this option, which exists only to */
|
||||
/* help some legacy applications retain its appearance and behaviour */
|
||||
/* with respect to auto-hinted TrueType fonts. */
|
||||
/* */
|
||||
/* The very reason this option exists at all are GNU/Linux distributions */
|
||||
/* like Fedora that did not un-patch the following change (which was */
|
||||
/* present in FreeType between versions 2.4.6 and 2.7.1, inclusive). */
|
||||
/* */
|
||||
/* 2011-07-16 Steven Chu <[email protected]> */
|
||||
/* */
|
||||
/* [truetype] Fix metrics on size request for scalable fonts. */
|
||||
/* */
|
||||
/* This problematic commit is now reverted (more or less). */
|
||||
/* */
|
||||
/* #define AF_CONFIG_OPTION_TT_SIZE_METRICS */
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
/*
|
||||
* This macro is obsolete. Support has been removed in FreeType
|
||||
* version 2.5.
|
||||
*/
|
||||
/* #define FT_CONFIG_OPTION_OLD_INTERNALS */
|
||||
|
||||
|
||||
/*
|
||||
* This macro is defined if native TrueType hinting is requested by the
|
||||
* definitions above.
|
||||
*/
|
||||
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
|
||||
#define TT_USE_BYTECODE_INTERPRETER
|
||||
|
||||
#ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING
|
||||
#if TT_CONFIG_OPTION_SUBPIXEL_HINTING & 1
|
||||
#define TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY
|
||||
#endif
|
||||
|
||||
#if TT_CONFIG_OPTION_SUBPIXEL_HINTING & 2
|
||||
#define TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Check CFF darkening parameters. The checks are the same as in function
|
||||
* `cff_property_set' in file `cffdrivr.c'.
|
||||
*/
|
||||
#if CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 < 0 || \
|
||||
CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 < 0 || \
|
||||
CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 < 0 || \
|
||||
CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4 < 0 || \
|
||||
\
|
||||
CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1 < 0 || \
|
||||
CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2 < 0 || \
|
||||
CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3 < 0 || \
|
||||
CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4 < 0 || \
|
||||
\
|
||||
CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 > \
|
||||
CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 || \
|
||||
CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 > \
|
||||
CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 || \
|
||||
CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 > \
|
||||
CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4 || \
|
||||
\
|
||||
CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1 > 500 || \
|
||||
CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2 > 500 || \
|
||||
CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3 > 500 || \
|
||||
CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4 > 500
|
||||
#error "Invalid CFF darkening parameters!"
|
||||
#endif
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
|
||||
#endif /* FTOPTION_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,175 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftstdlib.h */
|
||||
/* */
|
||||
/* ANSI-specific library and header configuration file (specification */
|
||||
/* only). */
|
||||
/* */
|
||||
/* Copyright 2002-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* This file is used to group all #includes to the ANSI C library that */
|
||||
/* FreeType normally requires. It also defines macros to rename the */
|
||||
/* standard functions within the FreeType source code. */
|
||||
/* */
|
||||
/* Load a file which defines FTSTDLIB_H_ before this one to override it. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTSTDLIB_H_
|
||||
#define FTSTDLIB_H_
|
||||
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#define ft_ptrdiff_t ptrdiff_t
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* */
|
||||
/* integer limits */
|
||||
/* */
|
||||
/* UINT_MAX and ULONG_MAX are used to automatically compute the size */
|
||||
/* of `int' and `long' in bytes at compile-time. So far, this works */
|
||||
/* for all platforms the library has been tested on. */
|
||||
/* */
|
||||
/* Note that on the extremely rare platforms that do not provide */
|
||||
/* integer types that are _exactly_ 16 and 32 bits wide (e.g. some */
|
||||
/* old Crays where `int' is 36 bits), we do not make any guarantee */
|
||||
/* about the correct behaviour of FT2 with all fonts. */
|
||||
/* */
|
||||
/* In these case, `ftconfig.h' will refuse to compile anyway with a */
|
||||
/* message like `couldn't find 32-bit type' or something similar. */
|
||||
/* */
|
||||
/**********************************************************************/
|
||||
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#define FT_CHAR_BIT CHAR_BIT
|
||||
#define FT_USHORT_MAX USHRT_MAX
|
||||
#define FT_INT_MAX INT_MAX
|
||||
#define FT_INT_MIN INT_MIN
|
||||
#define FT_UINT_MAX UINT_MAX
|
||||
#define FT_LONG_MIN LONG_MIN
|
||||
#define FT_LONG_MAX LONG_MAX
|
||||
#define FT_ULONG_MAX ULONG_MAX
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* */
|
||||
/* character and string processing */
|
||||
/* */
|
||||
/**********************************************************************/
|
||||
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define ft_memchr memchr
|
||||
#define ft_memcmp memcmp
|
||||
#define ft_memcpy memcpy
|
||||
#define ft_memmove memmove
|
||||
#define ft_memset memset
|
||||
#define ft_strcat strcat
|
||||
#define ft_strcmp strcmp
|
||||
#define ft_strcpy strcpy
|
||||
#define ft_strlen strlen
|
||||
#define ft_strncmp strncmp
|
||||
#define ft_strncpy strncpy
|
||||
#define ft_strrchr strrchr
|
||||
#define ft_strstr strstr
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* */
|
||||
/* file handling */
|
||||
/* */
|
||||
/**********************************************************************/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define FT_FILE FILE
|
||||
#define ft_fclose fclose
|
||||
#define ft_fopen fopen
|
||||
#define ft_fread fread
|
||||
#define ft_fseek fseek
|
||||
#define ft_ftell ftell
|
||||
#define ft_sprintf sprintf
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* */
|
||||
/* sorting */
|
||||
/* */
|
||||
/**********************************************************************/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define ft_qsort qsort
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* */
|
||||
/* memory allocation */
|
||||
/* */
|
||||
/**********************************************************************/
|
||||
|
||||
|
||||
#define ft_scalloc calloc
|
||||
#define ft_sfree free
|
||||
#define ft_smalloc malloc
|
||||
#define ft_srealloc realloc
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* */
|
||||
/* miscellaneous */
|
||||
/* */
|
||||
/**********************************************************************/
|
||||
|
||||
|
||||
#define ft_strtol strtol
|
||||
#define ft_getenv getenv
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
/* */
|
||||
/* execution control */
|
||||
/* */
|
||||
/**********************************************************************/
|
||||
|
||||
|
||||
#include <setjmp.h>
|
||||
|
||||
#define ft_jmp_buf jmp_buf /* note: this cannot be a typedef since */
|
||||
/* jmp_buf is defined as a macro */
|
||||
/* on certain platforms */
|
||||
|
||||
#define ft_longjmp longjmp
|
||||
#define ft_setjmp( b ) setjmp( *(ft_jmp_buf*) &(b) ) /* same thing here */
|
||||
|
||||
|
||||
/* the following is only used for debugging purposes, i.e., if */
|
||||
/* FT_DEBUG_LEVEL_ERROR or FT_DEBUG_LEVEL_TRACE are defined */
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
|
||||
#endif /* FTSTDLIB_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,4657 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* freetype.h */
|
||||
/* */
|
||||
/* FreeType high-level API and common types (specification only). */
|
||||
/* */
|
||||
/* Copyright 1996-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FREETYPE_H_
|
||||
#define FREETYPE_H_
|
||||
|
||||
|
||||
#ifndef FT_FREETYPE_H
|
||||
#error "`ft2build.h' hasn't been included yet!"
|
||||
#error "Please always use macros to include FreeType header files."
|
||||
#error "Example:"
|
||||
#error " #include <ft2build.h>"
|
||||
#error " #include FT_FREETYPE_H"
|
||||
#endif
|
||||
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_CONFIG_CONFIG_H
|
||||
#include FT_TYPES_H
|
||||
#include FT_ERRORS_H
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* header_inclusion */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* FreeType's header inclusion scheme */
|
||||
/* */
|
||||
/* <Abstract> */
|
||||
/* How client applications should include FreeType header files. */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* To be as flexible as possible (and for historical reasons), */
|
||||
/* FreeType uses a very special inclusion scheme to load header */
|
||||
/* files, for example */
|
||||
/* */
|
||||
/* { */
|
||||
/* #include <ft2build.h> */
|
||||
/* */
|
||||
/* #include FT_FREETYPE_H */
|
||||
/* #include FT_OUTLINE_H */
|
||||
/* } */
|
||||
/* */
|
||||
/* A compiler and its preprocessor only needs an include path to find */
|
||||
/* the file `ft2build.h'; the exact locations and names of the other */
|
||||
/* FreeType header files are hidden by preprocessor macro names, */
|
||||
/* loaded by `ft2build.h'. The API documentation always gives the */
|
||||
/* header macro name needed for a particular function. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* user_allocation */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* User allocation */
|
||||
/* */
|
||||
/* <Abstract> */
|
||||
/* How client applications should allocate FreeType data structures. */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* FreeType assumes that structures allocated by the user and passed */
|
||||
/* as arguments are zeroed out except for the actual data. In other */
|
||||
/* words, it is recommended to use `calloc' (or variants of it) */
|
||||
/* instead of `malloc' for allocation. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* B A S I C T Y P E S */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* base_interface */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* Base Interface */
|
||||
/* */
|
||||
/* <Abstract> */
|
||||
/* The FreeType~2 base font interface. */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This section describes the most important public high-level API */
|
||||
/* functions of FreeType~2. */
|
||||
/* */
|
||||
/* <Order> */
|
||||
/* FT_Library */
|
||||
/* FT_Face */
|
||||
/* FT_Size */
|
||||
/* FT_GlyphSlot */
|
||||
/* FT_CharMap */
|
||||
/* FT_Encoding */
|
||||
/* FT_ENC_TAG */
|
||||
/* */
|
||||
/* FT_FaceRec */
|
||||
/* */
|
||||
/* FT_FACE_FLAG_SCALABLE */
|
||||
/* FT_FACE_FLAG_FIXED_SIZES */
|
||||
/* FT_FACE_FLAG_FIXED_WIDTH */
|
||||
/* FT_FACE_FLAG_HORIZONTAL */
|
||||
/* FT_FACE_FLAG_VERTICAL */
|
||||
/* FT_FACE_FLAG_COLOR */
|
||||
/* FT_FACE_FLAG_SFNT */
|
||||
/* FT_FACE_FLAG_CID_KEYED */
|
||||
/* FT_FACE_FLAG_TRICKY */
|
||||
/* FT_FACE_FLAG_KERNING */
|
||||
/* FT_FACE_FLAG_MULTIPLE_MASTERS */
|
||||
/* FT_FACE_FLAG_VARIATION */
|
||||
/* FT_FACE_FLAG_GLYPH_NAMES */
|
||||
/* FT_FACE_FLAG_EXTERNAL_STREAM */
|
||||
/* FT_FACE_FLAG_HINTER */
|
||||
/* */
|
||||
/* FT_HAS_HORIZONTAL */
|
||||
/* FT_HAS_VERTICAL */
|
||||
/* FT_HAS_KERNING */
|
||||
/* FT_HAS_FIXED_SIZES */
|
||||
/* FT_HAS_GLYPH_NAMES */
|
||||
/* FT_HAS_COLOR */
|
||||
/* FT_HAS_MULTIPLE_MASTERS */
|
||||
/* */
|
||||
/* FT_IS_SFNT */
|
||||
/* FT_IS_SCALABLE */
|
||||
/* FT_IS_FIXED_WIDTH */
|
||||
/* FT_IS_CID_KEYED */
|
||||
/* FT_IS_TRICKY */
|
||||
/* FT_IS_NAMED_INSTANCE */
|
||||
/* FT_IS_VARIATION */
|
||||
/* */
|
||||
/* FT_STYLE_FLAG_BOLD */
|
||||
/* FT_STYLE_FLAG_ITALIC */
|
||||
/* */
|
||||
/* FT_SizeRec */
|
||||
/* FT_Size_Metrics */
|
||||
/* */
|
||||
/* FT_GlyphSlotRec */
|
||||
/* FT_Glyph_Metrics */
|
||||
/* FT_SubGlyph */
|
||||
/* */
|
||||
/* FT_Bitmap_Size */
|
||||
/* */
|
||||
/* FT_Init_FreeType */
|
||||
/* FT_Done_FreeType */
|
||||
/* */
|
||||
/* FT_New_Face */
|
||||
/* FT_Done_Face */
|
||||
/* FT_Reference_Face */
|
||||
/* FT_New_Memory_Face */
|
||||
/* FT_Face_Properties */
|
||||
/* FT_Open_Face */
|
||||
/* FT_Open_Args */
|
||||
/* FT_Parameter */
|
||||
/* FT_Attach_File */
|
||||
/* FT_Attach_Stream */
|
||||
/* */
|
||||
/* FT_Set_Char_Size */
|
||||
/* FT_Set_Pixel_Sizes */
|
||||
/* FT_Request_Size */
|
||||
/* FT_Select_Size */
|
||||
/* FT_Size_Request_Type */
|
||||
/* FT_Size_RequestRec */
|
||||
/* FT_Size_Request */
|
||||
/* FT_Set_Transform */
|
||||
/* FT_Load_Glyph */
|
||||
/* FT_Get_Char_Index */
|
||||
/* FT_Get_First_Char */
|
||||
/* FT_Get_Next_Char */
|
||||
/* FT_Get_Name_Index */
|
||||
/* FT_Load_Char */
|
||||
/* */
|
||||
/* FT_OPEN_MEMORY */
|
||||
/* FT_OPEN_STREAM */
|
||||
/* FT_OPEN_PATHNAME */
|
||||
/* FT_OPEN_DRIVER */
|
||||
/* FT_OPEN_PARAMS */
|
||||
/* */
|
||||
/* FT_LOAD_DEFAULT */
|
||||
/* FT_LOAD_RENDER */
|
||||
/* FT_LOAD_MONOCHROME */
|
||||
/* FT_LOAD_LINEAR_DESIGN */
|
||||
/* FT_LOAD_NO_SCALE */
|
||||
/* FT_LOAD_NO_HINTING */
|
||||
/* FT_LOAD_NO_BITMAP */
|
||||
/* FT_LOAD_NO_AUTOHINT */
|
||||
/* FT_LOAD_COLOR */
|
||||
/* */
|
||||
/* FT_LOAD_VERTICAL_LAYOUT */
|
||||
/* FT_LOAD_IGNORE_TRANSFORM */
|
||||
/* FT_LOAD_FORCE_AUTOHINT */
|
||||
/* FT_LOAD_NO_RECURSE */
|
||||
/* FT_LOAD_PEDANTIC */
|
||||
/* */
|
||||
/* FT_LOAD_TARGET_NORMAL */
|
||||
/* FT_LOAD_TARGET_LIGHT */
|
||||
/* FT_LOAD_TARGET_MONO */
|
||||
/* FT_LOAD_TARGET_LCD */
|
||||
/* FT_LOAD_TARGET_LCD_V */
|
||||
/* */
|
||||
/* FT_LOAD_TARGET_MODE */
|
||||
/* */
|
||||
/* FT_Render_Glyph */
|
||||
/* FT_Render_Mode */
|
||||
/* FT_Get_Kerning */
|
||||
/* FT_Kerning_Mode */
|
||||
/* FT_Get_Track_Kerning */
|
||||
/* FT_Get_Glyph_Name */
|
||||
/* FT_Get_Postscript_Name */
|
||||
/* */
|
||||
/* FT_CharMapRec */
|
||||
/* FT_Select_Charmap */
|
||||
/* FT_Set_Charmap */
|
||||
/* FT_Get_Charmap_Index */
|
||||
/* */
|
||||
/* FT_Get_FSType_Flags */
|
||||
/* FT_Get_SubGlyph_Info */
|
||||
/* */
|
||||
/* FT_Face_Internal */
|
||||
/* FT_Size_Internal */
|
||||
/* FT_Slot_Internal */
|
||||
/* */
|
||||
/* FT_FACE_FLAG_XXX */
|
||||
/* FT_STYLE_FLAG_XXX */
|
||||
/* FT_OPEN_XXX */
|
||||
/* FT_LOAD_XXX */
|
||||
/* FT_LOAD_TARGET_XXX */
|
||||
/* FT_SUBGLYPH_FLAG_XXX */
|
||||
/* FT_FSTYPE_XXX */
|
||||
/* */
|
||||
/* FT_HAS_FAST_GLYPHS */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_Glyph_Metrics */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure to model the metrics of a single glyph. The values */
|
||||
/* are expressed in 26.6 fractional pixel format; if the flag */
|
||||
/* @FT_LOAD_NO_SCALE has been used while loading the glyph, values */
|
||||
/* are expressed in font units instead. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* width :: */
|
||||
/* The glyph's width. */
|
||||
/* */
|
||||
/* height :: */
|
||||
/* The glyph's height. */
|
||||
/* */
|
||||
/* horiBearingX :: */
|
||||
/* Left side bearing for horizontal layout. */
|
||||
/* */
|
||||
/* horiBearingY :: */
|
||||
/* Top side bearing for horizontal layout. */
|
||||
/* */
|
||||
/* horiAdvance :: */
|
||||
/* Advance width for horizontal layout. */
|
||||
/* */
|
||||
/* vertBearingX :: */
|
||||
/* Left side bearing for vertical layout. */
|
||||
/* */
|
||||
/* vertBearingY :: */
|
||||
/* Top side bearing for vertical layout. Larger positive values */
|
||||
/* mean further below the vertical glyph origin. */
|
||||
/* */
|
||||
/* vertAdvance :: */
|
||||
/* Advance height for vertical layout. Positive values mean the */
|
||||
/* glyph has a positive advance downward. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* If not disabled with @FT_LOAD_NO_HINTING, the values represent */
|
||||
/* dimensions of the hinted glyph (in case hinting is applicable). */
|
||||
/* */
|
||||
/* Stroking a glyph with an outside border does not increase */
|
||||
/* `horiAdvance' or `vertAdvance'; you have to manually adjust these */
|
||||
/* values to account for the added width and height. */
|
||||
/* */
|
||||
/* FreeType doesn't use the `VORG' table data for CFF fonts because */
|
||||
/* it doesn't have an interface to quickly retrieve the glyph height. */
|
||||
/* The y~coordinate of the vertical origin can be simply computed as */
|
||||
/* `vertBearingY + height' after loading a glyph. */
|
||||
/* */
|
||||
typedef struct FT_Glyph_Metrics_
|
||||
{
|
||||
FT_Pos width;
|
||||
FT_Pos height;
|
||||
|
||||
FT_Pos horiBearingX;
|
||||
FT_Pos horiBearingY;
|
||||
FT_Pos horiAdvance;
|
||||
|
||||
FT_Pos vertBearingX;
|
||||
FT_Pos vertBearingY;
|
||||
FT_Pos vertAdvance;
|
||||
|
||||
} FT_Glyph_Metrics;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_Bitmap_Size */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This structure models the metrics of a bitmap strike (i.e., a set */
|
||||
/* of glyphs for a given point size and resolution) in a bitmap font. */
|
||||
/* It is used for the `available_sizes' field of @FT_Face. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* height :: The vertical distance, in pixels, between two */
|
||||
/* consecutive baselines. It is always positive. */
|
||||
/* */
|
||||
/* width :: The average width, in pixels, of all glyphs in the */
|
||||
/* strike. */
|
||||
/* */
|
||||
/* size :: The nominal size of the strike in 26.6 fractional */
|
||||
/* points. This field is not very useful. */
|
||||
/* */
|
||||
/* x_ppem :: The horizontal ppem (nominal width) in 26.6 fractional */
|
||||
/* pixels. */
|
||||
/* */
|
||||
/* y_ppem :: The vertical ppem (nominal height) in 26.6 fractional */
|
||||
/* pixels. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* Windows FNT: */
|
||||
/* The nominal size given in a FNT font is not reliable. If the */
|
||||
/* driver finds it incorrect, it sets `size' to some calculated */
|
||||
/* values, and `x_ppem' and `y_ppem' to the pixel width and height */
|
||||
/* given in the font, respectively. */
|
||||
/* */
|
||||
/* TrueType embedded bitmaps: */
|
||||
/* `size', `width', and `height' values are not contained in the */
|
||||
/* bitmap strike itself. They are computed from the global font */
|
||||
/* parameters. */
|
||||
/* */
|
||||
typedef struct FT_Bitmap_Size_
|
||||
{
|
||||
FT_Short height;
|
||||
FT_Short width;
|
||||
|
||||
FT_Pos size;
|
||||
|
||||
FT_Pos x_ppem;
|
||||
FT_Pos y_ppem;
|
||||
|
||||
} FT_Bitmap_Size;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* O B J E C T C L A S S E S */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Library */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to a FreeType library instance. Each `library' is */
|
||||
/* completely independent from the others; it is the `root' of a set */
|
||||
/* of objects like fonts, faces, sizes, etc. */
|
||||
/* */
|
||||
/* It also embeds a memory manager (see @FT_Memory), as well as a */
|
||||
/* scan-line converter object (see @FT_Raster). */
|
||||
/* */
|
||||
/* In multi-threaded applications it is easiest to use one */
|
||||
/* `FT_Library' object per thread. In case this is too cumbersome, */
|
||||
/* a single `FT_Library' object across threads is possible also */
|
||||
/* (since FreeType version 2.5.6), as long as a mutex lock is used */
|
||||
/* around @FT_New_Face and @FT_Done_Face. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* Library objects are normally created by @FT_Init_FreeType, and */
|
||||
/* destroyed with @FT_Done_FreeType. If you need reference-counting */
|
||||
/* (cf. @FT_Reference_Library), use @FT_New_Library and */
|
||||
/* @FT_Done_Library. */
|
||||
/* */
|
||||
typedef struct FT_LibraryRec_ *FT_Library;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* module_management */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Module */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to a given FreeType module object. A module can be a */
|
||||
/* font driver, a renderer, or anything else that provides services */
|
||||
/* to the former. */
|
||||
/* */
|
||||
typedef struct FT_ModuleRec_* FT_Module;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Driver */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to a given FreeType font driver object. A font driver */
|
||||
/* is a module capable of creating faces from font files. */
|
||||
/* */
|
||||
typedef struct FT_DriverRec_* FT_Driver;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Renderer */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to a given FreeType renderer. A renderer is a module in */
|
||||
/* charge of converting a glyph's outline image to a bitmap. It */
|
||||
/* supports a single glyph image format, and one or more target */
|
||||
/* surface depths. */
|
||||
/* */
|
||||
typedef struct FT_RendererRec_* FT_Renderer;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* base_interface */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Face */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to a typographic face object. A face object models a */
|
||||
/* given typeface, in a given style. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* A face object also owns a single @FT_GlyphSlot object, as well */
|
||||
/* as one or more @FT_Size objects. */
|
||||
/* */
|
||||
/* Use @FT_New_Face or @FT_Open_Face to create a new face object from */
|
||||
/* a given filepath or a custom input stream. */
|
||||
/* */
|
||||
/* Use @FT_Done_Face to destroy it (along with its slot and sizes). */
|
||||
/* */
|
||||
/* An `FT_Face' object can only be safely used from one thread at a */
|
||||
/* time. Similarly, creation and destruction of `FT_Face' with the */
|
||||
/* same @FT_Library object can only be done from one thread at a */
|
||||
/* time. On the other hand, functions like @FT_Load_Glyph and its */
|
||||
/* siblings are thread-safe and do not need the lock to be held as */
|
||||
/* long as the same `FT_Face' object is not used from multiple */
|
||||
/* threads at the same time. */
|
||||
/* */
|
||||
/* <Also> */
|
||||
/* See @FT_FaceRec for the publicly accessible fields of a given face */
|
||||
/* object. */
|
||||
/* */
|
||||
typedef struct FT_FaceRec_* FT_Face;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Size */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to an object that models a face scaled to a given */
|
||||
/* character size. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* An @FT_Face has one _active_ @FT_Size object that is used by */
|
||||
/* functions like @FT_Load_Glyph to determine the scaling */
|
||||
/* transformation that in turn is used to load and hint glyphs and */
|
||||
/* metrics. */
|
||||
/* */
|
||||
/* You can use @FT_Set_Char_Size, @FT_Set_Pixel_Sizes, */
|
||||
/* @FT_Request_Size or even @FT_Select_Size to change the content */
|
||||
/* (i.e., the scaling values) of the active @FT_Size. */
|
||||
/* */
|
||||
/* You can use @FT_New_Size to create additional size objects for a */
|
||||
/* given @FT_Face, but they won't be used by other functions until */
|
||||
/* you activate it through @FT_Activate_Size. Only one size can be */
|
||||
/* activated at any given time per face. */
|
||||
/* */
|
||||
/* <Also> */
|
||||
/* See @FT_SizeRec for the publicly accessible fields of a given size */
|
||||
/* object. */
|
||||
/* */
|
||||
typedef struct FT_SizeRec_* FT_Size;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_GlyphSlot */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to a given `glyph slot'. A slot is a container that can */
|
||||
/* hold any of the glyphs contained in its parent face. */
|
||||
/* */
|
||||
/* In other words, each time you call @FT_Load_Glyph or */
|
||||
/* @FT_Load_Char, the slot's content is erased by the new glyph data, */
|
||||
/* i.e., the glyph's metrics, its image (bitmap or outline), and */
|
||||
/* other control information. */
|
||||
/* */
|
||||
/* <Also> */
|
||||
/* See @FT_GlyphSlotRec for the publicly accessible glyph fields. */
|
||||
/* */
|
||||
typedef struct FT_GlyphSlotRec_* FT_GlyphSlot;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_CharMap */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to a character map (usually abbreviated to `charmap'). A */
|
||||
/* charmap is used to translate character codes in a given encoding */
|
||||
/* into glyph indexes for its parent's face. Some font formats may */
|
||||
/* provide several charmaps per font. */
|
||||
/* */
|
||||
/* Each face object owns zero or more charmaps, but only one of them */
|
||||
/* can be `active', providing the data used by @FT_Get_Char_Index or */
|
||||
/* @FT_Load_Char. */
|
||||
/* */
|
||||
/* The list of available charmaps in a face is available through the */
|
||||
/* `face->num_charmaps' and `face->charmaps' fields of @FT_FaceRec. */
|
||||
/* */
|
||||
/* The currently active charmap is available as `face->charmap'. */
|
||||
/* You should call @FT_Set_Charmap to change it. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* When a new face is created (either through @FT_New_Face or */
|
||||
/* @FT_Open_Face), the library looks for a Unicode charmap within */
|
||||
/* the list and automatically activates it. If there is no Unicode */
|
||||
/* charmap, FreeType doesn't set an `active' charmap. */
|
||||
/* */
|
||||
/* <Also> */
|
||||
/* See @FT_CharMapRec for the publicly accessible fields of a given */
|
||||
/* character map. */
|
||||
/* */
|
||||
typedef struct FT_CharMapRec_* FT_CharMap;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Macro> */
|
||||
/* FT_ENC_TAG */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This macro converts four-letter tags into an unsigned long. It is */
|
||||
/* used to define `encoding' identifiers (see @FT_Encoding). */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* Since many 16-bit compilers don't like 32-bit enumerations, you */
|
||||
/* should redefine this macro in case of problems to something like */
|
||||
/* this: */
|
||||
/* */
|
||||
/* { */
|
||||
/* #define FT_ENC_TAG( value, a, b, c, d ) value */
|
||||
/* } */
|
||||
/* */
|
||||
/* to get a simple enumeration without assigning special numbers. */
|
||||
/* */
|
||||
|
||||
#ifndef FT_ENC_TAG
|
||||
#define FT_ENC_TAG( value, a, b, c, d ) \
|
||||
value = ( ( (FT_UInt32)(a) << 24 ) | \
|
||||
( (FT_UInt32)(b) << 16 ) | \
|
||||
( (FT_UInt32)(c) << 8 ) | \
|
||||
(FT_UInt32)(d) )
|
||||
|
||||
#endif /* FT_ENC_TAG */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Enum> */
|
||||
/* FT_Encoding */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* An enumeration to specify character sets supported by charmaps. */
|
||||
/* Used in the @FT_Select_Charmap API function. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* Despite the name, this enumeration lists specific character */
|
||||
/* repertories (i.e., charsets), and not text encoding methods (e.g., */
|
||||
/* UTF-8, UTF-16, etc.). */
|
||||
/* */
|
||||
/* Other encodings might be defined in the future. */
|
||||
/* */
|
||||
/* <Values> */
|
||||
/* FT_ENCODING_NONE :: */
|
||||
/* The encoding value~0 is reserved. */
|
||||
/* */
|
||||
/* FT_ENCODING_UNICODE :: */
|
||||
/* The Unicode character set. This value covers all versions of */
|
||||
/* the Unicode repertoire, including ASCII and Latin-1. Most fonts */
|
||||
/* include a Unicode charmap, but not all of them. */
|
||||
/* */
|
||||
/* For example, if you want to access Unicode value U+1F028 (and */
|
||||
/* the font contains it), use value 0x1F028 as the input value for */
|
||||
/* @FT_Get_Char_Index. */
|
||||
/* */
|
||||
/* FT_ENCODING_MS_SYMBOL :: */
|
||||
/* Microsoft Symbol encoding, used to encode mathematical symbols */
|
||||
/* and wingdings. For more information, see */
|
||||
/* `https://www.microsoft.com/typography/otspec/recom.htm', */
|
||||
/* `http://www.kostis.net/charsets/symbol.htm', and */
|
||||
/* `http://www.kostis.net/charsets/wingding.htm'. */
|
||||
/* */
|
||||
/* This encoding uses character codes from the PUA (Private Unicode */
|
||||
/* Area) in the range U+F020-U+F0FF. */
|
||||
/* */
|
||||
/* FT_ENCODING_SJIS :: */
|
||||
/* Shift JIS encoding for Japanese. More info at */
|
||||
/* `https://en.wikipedia.org/wiki/Shift_JIS'. See note on */
|
||||
/* multi-byte encodings below. */
|
||||
/* */
|
||||
/* FT_ENCODING_PRC :: */
|
||||
/* Corresponds to encoding systems mainly for Simplified Chinese as */
|
||||
/* used in People's Republic of China (PRC). The encoding layout */
|
||||
/* is based on GB~2312 and its supersets GBK and GB~18030. */
|
||||
/* */
|
||||
/* FT_ENCODING_BIG5 :: */
|
||||
/* Corresponds to an encoding system for Traditional Chinese as */
|
||||
/* used in Taiwan and Hong Kong. */
|
||||
/* */
|
||||
/* FT_ENCODING_WANSUNG :: */
|
||||
/* Corresponds to the Korean encoding system known as Extended */
|
||||
/* Wansung (MS Windows code page 949). */
|
||||
/* For more information see */
|
||||
/* `https://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WindowsBestFit/bestfit949.txt'. */
|
||||
/* */
|
||||
/* FT_ENCODING_JOHAB :: */
|
||||
/* The Korean standard character set (KS~C 5601-1992), which */
|
||||
/* corresponds to MS Windows code page 1361. This character set */
|
||||
/* includes all possible Hangul character combinations. */
|
||||
/* */
|
||||
/* FT_ENCODING_ADOBE_LATIN_1 :: */
|
||||
/* Corresponds to a Latin-1 encoding as defined in a Type~1 */
|
||||
/* PostScript font. It is limited to 256 character codes. */
|
||||
/* */
|
||||
/* FT_ENCODING_ADOBE_STANDARD :: */
|
||||
/* Adobe Standard encoding, as found in Type~1, CFF, and */
|
||||
/* OpenType/CFF fonts. It is limited to 256 character codes. */
|
||||
/* */
|
||||
/* FT_ENCODING_ADOBE_EXPERT :: */
|
||||
/* Adobe Expert encoding, as found in Type~1, CFF, and OpenType/CFF */
|
||||
/* fonts. It is limited to 256 character codes. */
|
||||
/* */
|
||||
/* FT_ENCODING_ADOBE_CUSTOM :: */
|
||||
/* Corresponds to a custom encoding, as found in Type~1, CFF, and */
|
||||
/* OpenType/CFF fonts. It is limited to 256 character codes. */
|
||||
/* */
|
||||
/* FT_ENCODING_APPLE_ROMAN :: */
|
||||
/* Apple roman encoding. Many TrueType and OpenType fonts contain */
|
||||
/* a charmap for this 8-bit encoding, since older versions of Mac */
|
||||
/* OS are able to use it. */
|
||||
/* */
|
||||
/* FT_ENCODING_OLD_LATIN_2 :: */
|
||||
/* This value is deprecated and was neither used nor reported by */
|
||||
/* FreeType. Don't use or test for it. */
|
||||
/* */
|
||||
/* FT_ENCODING_MS_SJIS :: */
|
||||
/* Same as FT_ENCODING_SJIS. Deprecated. */
|
||||
/* */
|
||||
/* FT_ENCODING_MS_GB2312 :: */
|
||||
/* Same as FT_ENCODING_PRC. Deprecated. */
|
||||
/* */
|
||||
/* FT_ENCODING_MS_BIG5 :: */
|
||||
/* Same as FT_ENCODING_BIG5. Deprecated. */
|
||||
/* */
|
||||
/* FT_ENCODING_MS_WANSUNG :: */
|
||||
/* Same as FT_ENCODING_WANSUNG. Deprecated. */
|
||||
/* */
|
||||
/* FT_ENCODING_MS_JOHAB :: */
|
||||
/* Same as FT_ENCODING_JOHAB. Deprecated. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* By default, FreeType enables a Unicode charmap and tags it with */
|
||||
/* FT_ENCODING_UNICODE when it is either provided or can be generated */
|
||||
/* from PostScript glyph name dictionaries in the font file. */
|
||||
/* All other encodings are considered legacy and tagged only if */
|
||||
/* explicitly defined in the font file. Otherwise, FT_ENCODING_NONE */
|
||||
/* is used. */
|
||||
/* */
|
||||
/* FT_ENCODING_NONE is set by the BDF and PCF drivers if the charmap */
|
||||
/* is neither Unicode nor ISO-8859-1 (otherwise it is set to */
|
||||
/* FT_ENCODING_UNICODE). Use @FT_Get_BDF_Charset_ID to find out */
|
||||
/* which encoding is really present. If, for example, the */
|
||||
/* `cs_registry' field is `KOI8' and the `cs_encoding' field is `R', */
|
||||
/* the font is encoded in KOI8-R. */
|
||||
/* */
|
||||
/* FT_ENCODING_NONE is always set (with a single exception) by the */
|
||||
/* winfonts driver. Use @FT_Get_WinFNT_Header and examine the */
|
||||
/* `charset' field of the @FT_WinFNT_HeaderRec structure to find out */
|
||||
/* which encoding is really present. For example, */
|
||||
/* @FT_WinFNT_ID_CP1251 (204) means Windows code page 1251 (for */
|
||||
/* Russian). */
|
||||
/* */
|
||||
/* FT_ENCODING_NONE is set if `platform_id' is @TT_PLATFORM_MACINTOSH */
|
||||
/* and `encoding_id' is not `TT_MAC_ID_ROMAN' (otherwise it is set to */
|
||||
/* FT_ENCODING_APPLE_ROMAN). */
|
||||
/* */
|
||||
/* If `platform_id' is @TT_PLATFORM_MACINTOSH, use the function */
|
||||
/* @FT_Get_CMap_Language_ID to query the Mac language ID that may */
|
||||
/* be needed to be able to distinguish Apple encoding variants. See */
|
||||
/* */
|
||||
/* https://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/Readme.txt */
|
||||
/* */
|
||||
/* to get an idea how to do that. Basically, if the language ID */
|
||||
/* is~0, don't use it, otherwise subtract 1 from the language ID. */
|
||||
/* Then examine `encoding_id'. If, for example, `encoding_id' is */
|
||||
/* `TT_MAC_ID_ROMAN' and the language ID (minus~1) is */
|
||||
/* `TT_MAC_LANGID_GREEK', it is the Greek encoding, not Roman. */
|
||||
/* `TT_MAC_ID_ARABIC' with `TT_MAC_LANGID_FARSI' means the Farsi */
|
||||
/* variant the Arabic encoding. */
|
||||
/* */
|
||||
typedef enum FT_Encoding_
|
||||
{
|
||||
FT_ENC_TAG( FT_ENCODING_NONE, 0, 0, 0, 0 ),
|
||||
|
||||
FT_ENC_TAG( FT_ENCODING_MS_SYMBOL, 's', 'y', 'm', 'b' ),
|
||||
FT_ENC_TAG( FT_ENCODING_UNICODE, 'u', 'n', 'i', 'c' ),
|
||||
|
||||
FT_ENC_TAG( FT_ENCODING_SJIS, 's', 'j', 'i', 's' ),
|
||||
FT_ENC_TAG( FT_ENCODING_PRC, 'g', 'b', ' ', ' ' ),
|
||||
FT_ENC_TAG( FT_ENCODING_BIG5, 'b', 'i', 'g', '5' ),
|
||||
FT_ENC_TAG( FT_ENCODING_WANSUNG, 'w', 'a', 'n', 's' ),
|
||||
FT_ENC_TAG( FT_ENCODING_JOHAB, 'j', 'o', 'h', 'a' ),
|
||||
|
||||
/* for backward compatibility */
|
||||
FT_ENCODING_GB2312 = FT_ENCODING_PRC,
|
||||
FT_ENCODING_MS_SJIS = FT_ENCODING_SJIS,
|
||||
FT_ENCODING_MS_GB2312 = FT_ENCODING_PRC,
|
||||
FT_ENCODING_MS_BIG5 = FT_ENCODING_BIG5,
|
||||
FT_ENCODING_MS_WANSUNG = FT_ENCODING_WANSUNG,
|
||||
FT_ENCODING_MS_JOHAB = FT_ENCODING_JOHAB,
|
||||
|
||||
FT_ENC_TAG( FT_ENCODING_ADOBE_STANDARD, 'A', 'D', 'O', 'B' ),
|
||||
FT_ENC_TAG( FT_ENCODING_ADOBE_EXPERT, 'A', 'D', 'B', 'E' ),
|
||||
FT_ENC_TAG( FT_ENCODING_ADOBE_CUSTOM, 'A', 'D', 'B', 'C' ),
|
||||
FT_ENC_TAG( FT_ENCODING_ADOBE_LATIN_1, 'l', 'a', 't', '1' ),
|
||||
|
||||
FT_ENC_TAG( FT_ENCODING_OLD_LATIN_2, 'l', 'a', 't', '2' ),
|
||||
|
||||
FT_ENC_TAG( FT_ENCODING_APPLE_ROMAN, 'a', 'r', 'm', 'n' )
|
||||
|
||||
} FT_Encoding;
|
||||
|
||||
|
||||
/* these constants are deprecated; use the corresponding `FT_Encoding' */
|
||||
/* values instead */
|
||||
#define ft_encoding_none FT_ENCODING_NONE
|
||||
#define ft_encoding_unicode FT_ENCODING_UNICODE
|
||||
#define ft_encoding_symbol FT_ENCODING_MS_SYMBOL
|
||||
#define ft_encoding_latin_1 FT_ENCODING_ADOBE_LATIN_1
|
||||
#define ft_encoding_latin_2 FT_ENCODING_OLD_LATIN_2
|
||||
#define ft_encoding_sjis FT_ENCODING_SJIS
|
||||
#define ft_encoding_gb2312 FT_ENCODING_PRC
|
||||
#define ft_encoding_big5 FT_ENCODING_BIG5
|
||||
#define ft_encoding_wansung FT_ENCODING_WANSUNG
|
||||
#define ft_encoding_johab FT_ENCODING_JOHAB
|
||||
|
||||
#define ft_encoding_adobe_standard FT_ENCODING_ADOBE_STANDARD
|
||||
#define ft_encoding_adobe_expert FT_ENCODING_ADOBE_EXPERT
|
||||
#define ft_encoding_adobe_custom FT_ENCODING_ADOBE_CUSTOM
|
||||
#define ft_encoding_apple_roman FT_ENCODING_APPLE_ROMAN
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_CharMapRec */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The base charmap structure. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* face :: A handle to the parent face object. */
|
||||
/* */
|
||||
/* encoding :: An @FT_Encoding tag identifying the charmap. Use */
|
||||
/* this with @FT_Select_Charmap. */
|
||||
/* */
|
||||
/* platform_id :: An ID number describing the platform for the */
|
||||
/* following encoding ID. This comes directly from */
|
||||
/* the TrueType specification and gets emulated for */
|
||||
/* other formats. */
|
||||
/* */
|
||||
/* encoding_id :: A platform specific encoding number. This also */
|
||||
/* comes from the TrueType specification and gets */
|
||||
/* emulated similarly. */
|
||||
/* */
|
||||
typedef struct FT_CharMapRec_
|
||||
{
|
||||
FT_Face face;
|
||||
FT_Encoding encoding;
|
||||
FT_UShort platform_id;
|
||||
FT_UShort encoding_id;
|
||||
|
||||
} FT_CharMapRec;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* B A S E O B J E C T C L A S S E S */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Face_Internal */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* An opaque handle to an `FT_Face_InternalRec' structure that models */
|
||||
/* the private data of a given @FT_Face object. */
|
||||
/* */
|
||||
/* This structure might change between releases of FreeType~2 and is */
|
||||
/* not generally available to client applications. */
|
||||
/* */
|
||||
typedef struct FT_Face_InternalRec_* FT_Face_Internal;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_FaceRec */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* FreeType root face class structure. A face object models a */
|
||||
/* typeface in a font file. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* num_faces :: The number of faces in the font file. Some */
|
||||
/* font formats can have multiple faces in */
|
||||
/* a single font file. */
|
||||
/* */
|
||||
/* face_index :: This field holds two different values. */
|
||||
/* Bits 0-15 are the index of the face in the */
|
||||
/* font file (starting with value~0). They */
|
||||
/* are set to~0 if there is only one face in */
|
||||
/* the font file. */
|
||||
/* */
|
||||
/* [Since 2.6.1] Bits 16-30 are relevant to GX */
|
||||
/* and OpenType variation fonts only, holding */
|
||||
/* the named instance index for the current */
|
||||
/* face index (starting with value~1; value~0 */
|
||||
/* indicates font access without a named */
|
||||
/* instance). For non-variation fonts, bits */
|
||||
/* 16-30 are ignored. If we have the third */
|
||||
/* named instance of face~4, say, `face_index' */
|
||||
/* is set to 0x00030004. */
|
||||
/* */
|
||||
/* Bit 31 is always zero (this is, */
|
||||
/* `face_index' is always a positive value). */
|
||||
/* */
|
||||
/* [Since 2.9] Changing the design coordinates */
|
||||
/* with @FT_Set_Var_Design_Coordinates or */
|
||||
/* @FT_Set_Var_Blend_Coordinates does not */
|
||||
/* influence the named instance index value */
|
||||
/* (only @FT_Set_Named_Instance does that). */
|
||||
/* */
|
||||
/* face_flags :: A set of bit flags that give important */
|
||||
/* information about the face; see */
|
||||
/* @FT_FACE_FLAG_XXX for the details. */
|
||||
/* */
|
||||
/* style_flags :: The lower 16~bits contain a set of bit */
|
||||
/* flags indicating the style of the face; see */
|
||||
/* @FT_STYLE_FLAG_XXX for the details. */
|
||||
/* */
|
||||
/* [Since 2.6.1] Bits 16-30 hold the number */
|
||||
/* of named instances available for the */
|
||||
/* current face if we have a GX or OpenType */
|
||||
/* variation (sub)font. Bit 31 is always zero */
|
||||
/* (this is, `style_flags' is always a */
|
||||
/* positive value). Note that a variation */
|
||||
/* font has always at least one named */
|
||||
/* instance, namely the default instance. */
|
||||
/* */
|
||||
/* num_glyphs :: The number of glyphs in the face. If the */
|
||||
/* face is scalable and has sbits (see */
|
||||
/* `num_fixed_sizes'), it is set to the number */
|
||||
/* of outline glyphs. */
|
||||
/* */
|
||||
/* For CID-keyed fonts (not in an SFNT */
|
||||
/* wrapper) this value gives the highest CID */
|
||||
/* used in the font. */
|
||||
/* */
|
||||
/* family_name :: The face's family name. This is an ASCII */
|
||||
/* string, usually in English, that describes */
|
||||
/* the typeface's family (like `Times New */
|
||||
/* Roman', `Bodoni', `Garamond', etc). This */
|
||||
/* is a least common denominator used to list */
|
||||
/* fonts. Some formats (TrueType & OpenType) */
|
||||
/* provide localized and Unicode versions of */
|
||||
/* this string. Applications should use the */
|
||||
/* format specific interface to access them. */
|
||||
/* Can be NULL (e.g., in fonts embedded in a */
|
||||
/* PDF file). */
|
||||
/* */
|
||||
/* In case the font doesn't provide a specific */
|
||||
/* family name entry, FreeType tries to */
|
||||
/* synthesize one, deriving it from other name */
|
||||
/* entries. */
|
||||
/* */
|
||||
/* style_name :: The face's style name. This is an ASCII */
|
||||
/* string, usually in English, that describes */
|
||||
/* the typeface's style (like `Italic', */
|
||||
/* `Bold', `Condensed', etc). Not all font */
|
||||
/* formats provide a style name, so this field */
|
||||
/* is optional, and can be set to NULL. As */
|
||||
/* for `family_name', some formats provide */
|
||||
/* localized and Unicode versions of this */
|
||||
/* string. Applications should use the format */
|
||||
/* specific interface to access them. */
|
||||
/* */
|
||||
/* num_fixed_sizes :: The number of bitmap strikes in the face. */
|
||||
/* Even if the face is scalable, there might */
|
||||
/* still be bitmap strikes, which are called */
|
||||
/* `sbits' in that case. */
|
||||
/* */
|
||||
/* available_sizes :: An array of @FT_Bitmap_Size for all bitmap */
|
||||
/* strikes in the face. It is set to NULL if */
|
||||
/* there is no bitmap strike. */
|
||||
/* */
|
||||
/* Note that FreeType tries to sanitize the */
|
||||
/* strike data since they are sometimes sloppy */
|
||||
/* or incorrect, but this can easily fail. */
|
||||
/* */
|
||||
/* num_charmaps :: The number of charmaps in the face. */
|
||||
/* */
|
||||
/* charmaps :: An array of the charmaps of the face. */
|
||||
/* */
|
||||
/* generic :: A field reserved for client uses. See the */
|
||||
/* @FT_Generic type description. */
|
||||
/* */
|
||||
/* bbox :: The font bounding box. Coordinates are */
|
||||
/* expressed in font units (see */
|
||||
/* `units_per_EM'). The box is large enough */
|
||||
/* to contain any glyph from the font. Thus, */
|
||||
/* `bbox.yMax' can be seen as the `maximum */
|
||||
/* ascender', and `bbox.yMin' as the `minimum */
|
||||
/* descender'. Only relevant for scalable */
|
||||
/* formats. */
|
||||
/* */
|
||||
/* Note that the bounding box might be off by */
|
||||
/* (at least) one pixel for hinted fonts. See */
|
||||
/* @FT_Size_Metrics for further discussion. */
|
||||
/* */
|
||||
/* units_per_EM :: The number of font units per EM square for */
|
||||
/* this face. This is typically 2048 for */
|
||||
/* TrueType fonts, and 1000 for Type~1 fonts. */
|
||||
/* Only relevant for scalable formats. */
|
||||
/* */
|
||||
/* ascender :: The typographic ascender of the face, */
|
||||
/* expressed in font units. For font formats */
|
||||
/* not having this information, it is set to */
|
||||
/* `bbox.yMax'. Only relevant for scalable */
|
||||
/* formats. */
|
||||
/* */
|
||||
/* descender :: The typographic descender of the face, */
|
||||
/* expressed in font units. For font formats */
|
||||
/* not having this information, it is set to */
|
||||
/* `bbox.yMin'. Note that this field is */
|
||||
/* negative for values below the baseline. */
|
||||
/* Only relevant for scalable formats. */
|
||||
/* */
|
||||
/* height :: This value is the vertical distance */
|
||||
/* between two consecutive baselines, */
|
||||
/* expressed in font units. It is always */
|
||||
/* positive. Only relevant for scalable */
|
||||
/* formats. */
|
||||
/* */
|
||||
/* If you want the global glyph height, use */
|
||||
/* `ascender - descender'. */
|
||||
/* */
|
||||
/* max_advance_width :: The maximum advance width, in font units, */
|
||||
/* for all glyphs in this face. This can be */
|
||||
/* used to make word wrapping computations */
|
||||
/* faster. Only relevant for scalable */
|
||||
/* formats. */
|
||||
/* */
|
||||
/* max_advance_height :: The maximum advance height, in font units, */
|
||||
/* for all glyphs in this face. This is only */
|
||||
/* relevant for vertical layouts, and is set */
|
||||
/* to `height' for fonts that do not provide */
|
||||
/* vertical metrics. Only relevant for */
|
||||
/* scalable formats. */
|
||||
/* */
|
||||
/* underline_position :: The position, in font units, of the */
|
||||
/* underline line for this face. It is the */
|
||||
/* center of the underlining stem. Only */
|
||||
/* relevant for scalable formats. */
|
||||
/* */
|
||||
/* underline_thickness :: The thickness, in font units, of the */
|
||||
/* underline for this face. Only relevant for */
|
||||
/* scalable formats. */
|
||||
/* */
|
||||
/* glyph :: The face's associated glyph slot(s). */
|
||||
/* */
|
||||
/* size :: The current active size for this face. */
|
||||
/* */
|
||||
/* charmap :: The current active charmap for this face. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* Fields may be changed after a call to @FT_Attach_File or */
|
||||
/* @FT_Attach_Stream. */
|
||||
/* */
|
||||
/* For an OpenType variation font, the values of the following fields */
|
||||
/* can change after a call to @FT_Set_Var_Design_Coordinates (and */
|
||||
/* friends) if the font contains an `MVAR' table: `ascender', */
|
||||
/* `descender', `height', `underline_position', and */
|
||||
/* `underline_thickness'. */
|
||||
/* */
|
||||
/* Especially for TrueType fonts see also the documentation for */
|
||||
/* @FT_Size_Metrics. */
|
||||
/* */
|
||||
typedef struct FT_FaceRec_
|
||||
{
|
||||
FT_Long num_faces;
|
||||
FT_Long face_index;
|
||||
|
||||
FT_Long face_flags;
|
||||
FT_Long style_flags;
|
||||
|
||||
FT_Long num_glyphs;
|
||||
|
||||
FT_String* family_name;
|
||||
FT_String* style_name;
|
||||
|
||||
FT_Int num_fixed_sizes;
|
||||
FT_Bitmap_Size* available_sizes;
|
||||
|
||||
FT_Int num_charmaps;
|
||||
FT_CharMap* charmaps;
|
||||
|
||||
FT_Generic generic;
|
||||
|
||||
/*# The following member variables (down to `underline_thickness') */
|
||||
/*# are only relevant to scalable outlines; cf. @FT_Bitmap_Size */
|
||||
/*# for bitmap fonts. */
|
||||
FT_BBox bbox;
|
||||
|
||||
FT_UShort units_per_EM;
|
||||
FT_Short ascender;
|
||||
FT_Short descender;
|
||||
FT_Short height;
|
||||
|
||||
FT_Short max_advance_width;
|
||||
FT_Short max_advance_height;
|
||||
|
||||
FT_Short underline_position;
|
||||
FT_Short underline_thickness;
|
||||
|
||||
FT_GlyphSlot glyph;
|
||||
FT_Size size;
|
||||
FT_CharMap charmap;
|
||||
|
||||
/*@private begin */
|
||||
|
||||
FT_Driver driver;
|
||||
FT_Memory memory;
|
||||
FT_Stream stream;
|
||||
|
||||
FT_ListRec sizes_list;
|
||||
|
||||
FT_Generic autohint; /* face-specific auto-hinter data */
|
||||
void* extensions; /* unused */
|
||||
|
||||
FT_Face_Internal internal;
|
||||
|
||||
/*@private end */
|
||||
|
||||
} FT_FaceRec;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Enum> */
|
||||
/* FT_FACE_FLAG_XXX */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A list of bit flags used in the `face_flags' field of the */
|
||||
/* @FT_FaceRec structure. They inform client applications of */
|
||||
/* properties of the corresponding face. */
|
||||
/* */
|
||||
/* <Values> */
|
||||
/* FT_FACE_FLAG_SCALABLE :: */
|
||||
/* The face contains outline glyphs. Note that a face can contain */
|
||||
/* bitmap strikes also, i.e., a face can have both this flag and */
|
||||
/* @FT_FACE_FLAG_FIXED_SIZES set. */
|
||||
/* */
|
||||
/* FT_FACE_FLAG_FIXED_SIZES :: */
|
||||
/* The face contains bitmap strikes. See also the */
|
||||
/* `num_fixed_sizes' and `available_sizes' fields of @FT_FaceRec. */
|
||||
/* */
|
||||
/* FT_FACE_FLAG_FIXED_WIDTH :: */
|
||||
/* The face contains fixed-width characters (like Courier, Lucida, */
|
||||
/* MonoType, etc.). */
|
||||
/* */
|
||||
/* FT_FACE_FLAG_SFNT :: */
|
||||
/* The face uses the SFNT storage scheme. For now, this means */
|
||||
/* TrueType and OpenType. */
|
||||
/* */
|
||||
/* FT_FACE_FLAG_HORIZONTAL :: */
|
||||
/* The face contains horizontal glyph metrics. This should be set */
|
||||
/* for all common formats. */
|
||||
/* */
|
||||
/* FT_FACE_FLAG_VERTICAL :: */
|
||||
/* The face contains vertical glyph metrics. This is only */
|
||||
/* available in some formats, not all of them. */
|
||||
/* */
|
||||
/* FT_FACE_FLAG_KERNING :: */
|
||||
/* The face contains kerning information. If set, the kerning */
|
||||
/* distance can be retrieved using the function @FT_Get_Kerning. */
|
||||
/* Otherwise the function always return the vector (0,0). Note */
|
||||
/* that FreeType doesn't handle kerning data from the SFNT `GPOS' */
|
||||
/* table (as present in many OpenType fonts). */
|
||||
/* */
|
||||
/* FT_FACE_FLAG_FAST_GLYPHS :: */
|
||||
/* THIS FLAG IS DEPRECATED. DO NOT USE OR TEST IT. */
|
||||
/* */
|
||||
/* FT_FACE_FLAG_MULTIPLE_MASTERS :: */
|
||||
/* The face contains multiple masters and is capable of */
|
||||
/* interpolating between them. Supported formats are Adobe MM, */
|
||||
/* TrueType GX, and OpenType variation fonts. */
|
||||
/* */
|
||||
/* See section @multiple_masters for API details. */
|
||||
/* */
|
||||
/* FT_FACE_FLAG_GLYPH_NAMES :: */
|
||||
/* The face contains glyph names, which can be retrieved using */
|
||||
/* @FT_Get_Glyph_Name. Note that some TrueType fonts contain */
|
||||
/* broken glyph name tables. Use the function */
|
||||
/* @FT_Has_PS_Glyph_Names when needed. */
|
||||
/* */
|
||||
/* FT_FACE_FLAG_EXTERNAL_STREAM :: */
|
||||
/* Used internally by FreeType to indicate that a face's stream was */
|
||||
/* provided by the client application and should not be destroyed */
|
||||
/* when @FT_Done_Face is called. Don't read or test this flag. */
|
||||
/* */
|
||||
/* FT_FACE_FLAG_HINTER :: */
|
||||
/* The font driver has a hinting machine of its own. For example, */
|
||||
/* with TrueType fonts, it makes sense to use data from the SFNT */
|
||||
/* `gasp' table only if the native TrueType hinting engine (with */
|
||||
/* the bytecode interpreter) is available and active. */
|
||||
/* */
|
||||
/* FT_FACE_FLAG_CID_KEYED :: */
|
||||
/* The face is CID-keyed. In that case, the face is not accessed */
|
||||
/* by glyph indices but by CID values. For subsetted CID-keyed */
|
||||
/* fonts this has the consequence that not all index values are a */
|
||||
/* valid argument to @FT_Load_Glyph. Only the CID values for which */
|
||||
/* corresponding glyphs in the subsetted font exist make */
|
||||
/* `FT_Load_Glyph' return successfully; in all other cases you get */
|
||||
/* an `FT_Err_Invalid_Argument' error. */
|
||||
/* */
|
||||
/* Note that CID-keyed fonts that are in an SFNT wrapper (this is, */
|
||||
/* all OpenType/CFF fonts) don't have this flag set since the */
|
||||
/* glyphs are accessed in the normal way (using contiguous */
|
||||
/* indices); the `CID-ness' isn't visible to the application. */
|
||||
/* */
|
||||
/* FT_FACE_FLAG_TRICKY :: */
|
||||
/* The face is `tricky', this is, it always needs the font format's */
|
||||
/* native hinting engine to get a reasonable result. A typical */
|
||||
/* example is the old Chinese font `mingli.ttf' (but not */
|
||||
/* `mingliu.ttc') that uses TrueType bytecode instructions to move */
|
||||
/* and scale all of its subglyphs. */
|
||||
/* */
|
||||
/* It is not possible to auto-hint such fonts using */
|
||||
/* @FT_LOAD_FORCE_AUTOHINT; it will also ignore */
|
||||
/* @FT_LOAD_NO_HINTING. You have to set both @FT_LOAD_NO_HINTING */
|
||||
/* and @FT_LOAD_NO_AUTOHINT to really disable hinting; however, you */
|
||||
/* probably never want this except for demonstration purposes. */
|
||||
/* */
|
||||
/* Currently, there are about a dozen TrueType fonts in the list of */
|
||||
/* tricky fonts; they are hard-coded in file `ttobjs.c'. */
|
||||
/* */
|
||||
/* FT_FACE_FLAG_COLOR :: */
|
||||
/* [Since 2.5.1] The face has color glyph tables. To access color */
|
||||
/* glyphs use @FT_LOAD_COLOR. */
|
||||
/* */
|
||||
/* FT_FACE_FLAG_VARIATION :: */
|
||||
/* [Since 2.9] Set if the current face (or named instance) has been */
|
||||
/* altered with @FT_Set_MM_Design_Coordinates, */
|
||||
/* @FT_Set_Var_Design_Coordinates, or */
|
||||
/* @FT_Set_Var_Blend_Coordinates. This flag is unset by a call to */
|
||||
/* @FT_Set_Named_Instance. */
|
||||
/* */
|
||||
#define FT_FACE_FLAG_SCALABLE ( 1L << 0 )
|
||||
#define FT_FACE_FLAG_FIXED_SIZES ( 1L << 1 )
|
||||
#define FT_FACE_FLAG_FIXED_WIDTH ( 1L << 2 )
|
||||
#define FT_FACE_FLAG_SFNT ( 1L << 3 )
|
||||
#define FT_FACE_FLAG_HORIZONTAL ( 1L << 4 )
|
||||
#define FT_FACE_FLAG_VERTICAL ( 1L << 5 )
|
||||
#define FT_FACE_FLAG_KERNING ( 1L << 6 )
|
||||
#define FT_FACE_FLAG_FAST_GLYPHS ( 1L << 7 )
|
||||
#define FT_FACE_FLAG_MULTIPLE_MASTERS ( 1L << 8 )
|
||||
#define FT_FACE_FLAG_GLYPH_NAMES ( 1L << 9 )
|
||||
#define FT_FACE_FLAG_EXTERNAL_STREAM ( 1L << 10 )
|
||||
#define FT_FACE_FLAG_HINTER ( 1L << 11 )
|
||||
#define FT_FACE_FLAG_CID_KEYED ( 1L << 12 )
|
||||
#define FT_FACE_FLAG_TRICKY ( 1L << 13 )
|
||||
#define FT_FACE_FLAG_COLOR ( 1L << 14 )
|
||||
#define FT_FACE_FLAG_VARIATION ( 1L << 15 )
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_HAS_HORIZONTAL( face )
|
||||
*
|
||||
* @description:
|
||||
* A macro that returns true whenever a face object contains
|
||||
* horizontal metrics (this is true for all font formats though).
|
||||
*
|
||||
* @also:
|
||||
* @FT_HAS_VERTICAL can be used to check for vertical metrics.
|
||||
*
|
||||
*/
|
||||
#define FT_HAS_HORIZONTAL( face ) \
|
||||
( (face)->face_flags & FT_FACE_FLAG_HORIZONTAL )
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_HAS_VERTICAL( face )
|
||||
*
|
||||
* @description:
|
||||
* A macro that returns true whenever a face object contains real
|
||||
* vertical metrics (and not only synthesized ones).
|
||||
*
|
||||
*/
|
||||
#define FT_HAS_VERTICAL( face ) \
|
||||
( (face)->face_flags & FT_FACE_FLAG_VERTICAL )
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_HAS_KERNING( face )
|
||||
*
|
||||
* @description:
|
||||
* A macro that returns true whenever a face object contains kerning
|
||||
* data that can be accessed with @FT_Get_Kerning.
|
||||
*
|
||||
*/
|
||||
#define FT_HAS_KERNING( face ) \
|
||||
( (face)->face_flags & FT_FACE_FLAG_KERNING )
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_IS_SCALABLE( face )
|
||||
*
|
||||
* @description:
|
||||
* A macro that returns true whenever a face object contains a scalable
|
||||
* font face (true for TrueType, Type~1, Type~42, CID, OpenType/CFF,
|
||||
* and PFR font formats).
|
||||
*
|
||||
*/
|
||||
#define FT_IS_SCALABLE( face ) \
|
||||
( (face)->face_flags & FT_FACE_FLAG_SCALABLE )
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_IS_SFNT( face )
|
||||
*
|
||||
* @description:
|
||||
* A macro that returns true whenever a face object contains a font
|
||||
* whose format is based on the SFNT storage scheme. This usually
|
||||
* means: TrueType fonts, OpenType fonts, as well as SFNT-based embedded
|
||||
* bitmap fonts.
|
||||
*
|
||||
* If this macro is true, all functions defined in @FT_SFNT_NAMES_H and
|
||||
* @FT_TRUETYPE_TABLES_H are available.
|
||||
*
|
||||
*/
|
||||
#define FT_IS_SFNT( face ) \
|
||||
( (face)->face_flags & FT_FACE_FLAG_SFNT )
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_IS_FIXED_WIDTH( face )
|
||||
*
|
||||
* @description:
|
||||
* A macro that returns true whenever a face object contains a font face
|
||||
* that contains fixed-width (or `monospace', `fixed-pitch', etc.)
|
||||
* glyphs.
|
||||
*
|
||||
*/
|
||||
#define FT_IS_FIXED_WIDTH( face ) \
|
||||
( (face)->face_flags & FT_FACE_FLAG_FIXED_WIDTH )
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_HAS_FIXED_SIZES( face )
|
||||
*
|
||||
* @description:
|
||||
* A macro that returns true whenever a face object contains some
|
||||
* embedded bitmaps. See the `available_sizes' field of the
|
||||
* @FT_FaceRec structure.
|
||||
*
|
||||
*/
|
||||
#define FT_HAS_FIXED_SIZES( face ) \
|
||||
( (face)->face_flags & FT_FACE_FLAG_FIXED_SIZES )
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_HAS_FAST_GLYPHS( face )
|
||||
*
|
||||
* @description:
|
||||
* Deprecated.
|
||||
*
|
||||
*/
|
||||
#define FT_HAS_FAST_GLYPHS( face ) 0
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_HAS_GLYPH_NAMES( face )
|
||||
*
|
||||
* @description:
|
||||
* A macro that returns true whenever a face object contains some glyph
|
||||
* names that can be accessed through @FT_Get_Glyph_Name.
|
||||
*
|
||||
*/
|
||||
#define FT_HAS_GLYPH_NAMES( face ) \
|
||||
( (face)->face_flags & FT_FACE_FLAG_GLYPH_NAMES )
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_HAS_MULTIPLE_MASTERS( face )
|
||||
*
|
||||
* @description:
|
||||
* A macro that returns true whenever a face object contains some
|
||||
* multiple masters. The functions provided by @FT_MULTIPLE_MASTERS_H
|
||||
* are then available to choose the exact design you want.
|
||||
*
|
||||
*/
|
||||
#define FT_HAS_MULTIPLE_MASTERS( face ) \
|
||||
( (face)->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS )
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_IS_NAMED_INSTANCE( face )
|
||||
*
|
||||
* @description:
|
||||
* A macro that returns true whenever a face object is a named instance
|
||||
* of a GX or OpenType variation font.
|
||||
*
|
||||
* [Since 2.9] Changing the design coordinates with
|
||||
* @FT_Set_Var_Design_Coordinates or @FT_Set_Var_Blend_Coordinates does
|
||||
* not influence the return value of this macro (only
|
||||
* @FT_Set_Named_Instance does that).
|
||||
*
|
||||
* @since:
|
||||
* 2.7
|
||||
*
|
||||
*/
|
||||
#define FT_IS_NAMED_INSTANCE( face ) \
|
||||
( (face)->face_index & 0x7FFF0000L )
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_IS_VARIATION( face )
|
||||
*
|
||||
* @description:
|
||||
* A macro that returns true whenever a face object has been altered
|
||||
* by @FT_Set_MM_Design_Coordinates, @FT_Set_Var_Design_Coordinates, or
|
||||
* @FT_Set_Var_Blend_Coordinates.
|
||||
*
|
||||
* @since:
|
||||
* 2.9
|
||||
*
|
||||
*/
|
||||
#define FT_IS_VARIATION( face ) \
|
||||
( (face)->face_flags & FT_FACE_FLAG_VARIATION )
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_IS_CID_KEYED( face )
|
||||
*
|
||||
* @description:
|
||||
* A macro that returns true whenever a face object contains a CID-keyed
|
||||
* font. See the discussion of @FT_FACE_FLAG_CID_KEYED for more
|
||||
* details.
|
||||
*
|
||||
* If this macro is true, all functions defined in @FT_CID_H are
|
||||
* available.
|
||||
*
|
||||
*/
|
||||
#define FT_IS_CID_KEYED( face ) \
|
||||
( (face)->face_flags & FT_FACE_FLAG_CID_KEYED )
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_IS_TRICKY( face )
|
||||
*
|
||||
* @description:
|
||||
* A macro that returns true whenever a face represents a `tricky' font.
|
||||
* See the discussion of @FT_FACE_FLAG_TRICKY for more details.
|
||||
*
|
||||
*/
|
||||
#define FT_IS_TRICKY( face ) \
|
||||
( (face)->face_flags & FT_FACE_FLAG_TRICKY )
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_HAS_COLOR( face )
|
||||
*
|
||||
* @description:
|
||||
* A macro that returns true whenever a face object contains
|
||||
* tables for color glyphs.
|
||||
*
|
||||
* @since:
|
||||
* 2.5.1
|
||||
*
|
||||
*/
|
||||
#define FT_HAS_COLOR( face ) \
|
||||
( (face)->face_flags & FT_FACE_FLAG_COLOR )
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Const> */
|
||||
/* FT_STYLE_FLAG_XXX */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A list of bit flags to indicate the style of a given face. These */
|
||||
/* are used in the `style_flags' field of @FT_FaceRec. */
|
||||
/* */
|
||||
/* <Values> */
|
||||
/* FT_STYLE_FLAG_ITALIC :: */
|
||||
/* The face style is italic or oblique. */
|
||||
/* */
|
||||
/* FT_STYLE_FLAG_BOLD :: */
|
||||
/* The face is bold. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The style information as provided by FreeType is very basic. More */
|
||||
/* details are beyond the scope and should be done on a higher level */
|
||||
/* (for example, by analyzing various fields of the `OS/2' table in */
|
||||
/* SFNT based fonts). */
|
||||
/* */
|
||||
#define FT_STYLE_FLAG_ITALIC ( 1 << 0 )
|
||||
#define FT_STYLE_FLAG_BOLD ( 1 << 1 )
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Size_Internal */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* An opaque handle to an `FT_Size_InternalRec' structure, used to */
|
||||
/* model private data of a given @FT_Size object. */
|
||||
/* */
|
||||
typedef struct FT_Size_InternalRec_* FT_Size_Internal;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_Size_Metrics */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The size metrics structure gives the metrics of a size object. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* x_ppem :: The width of the scaled EM square in pixels, hence */
|
||||
/* the term `ppem' (pixels per EM). It is also */
|
||||
/* referred to as `nominal width'. */
|
||||
/* */
|
||||
/* y_ppem :: The height of the scaled EM square in pixels, */
|
||||
/* hence the term `ppem' (pixels per EM). It is also */
|
||||
/* referred to as `nominal height'. */
|
||||
/* */
|
||||
/* x_scale :: A 16.16 fractional scaling value to convert */
|
||||
/* horizontal metrics from font units to 26.6 */
|
||||
/* fractional pixels. Only relevant for scalable */
|
||||
/* font formats. */
|
||||
/* */
|
||||
/* y_scale :: A 16.16 fractional scaling value to convert */
|
||||
/* vertical metrics from font units to 26.6 */
|
||||
/* fractional pixels. Only relevant for scalable */
|
||||
/* font formats. */
|
||||
/* */
|
||||
/* ascender :: The ascender in 26.6 fractional pixels, rounded up */
|
||||
/* to an integer value. See @FT_FaceRec for the */
|
||||
/* details. */
|
||||
/* */
|
||||
/* descender :: The descender in 26.6 fractional pixels, rounded */
|
||||
/* down to an integer value. See @FT_FaceRec for the */
|
||||
/* details. */
|
||||
/* */
|
||||
/* height :: The height in 26.6 fractional pixels, rounded to */
|
||||
/* an integer value. See @FT_FaceRec for the */
|
||||
/* details. */
|
||||
/* */
|
||||
/* max_advance :: The maximum advance width in 26.6 fractional */
|
||||
/* pixels, rounded to an integer value. See */
|
||||
/* @FT_FaceRec for the details. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The scaling values, if relevant, are determined first during a */
|
||||
/* size changing operation. The remaining fields are then set by the */
|
||||
/* driver. For scalable formats, they are usually set to scaled */
|
||||
/* values of the corresponding fields in @FT_FaceRec. Some values */
|
||||
/* like ascender or descender are rounded for historical reasons; */
|
||||
/* more precise values (for outline fonts) can be derived by scaling */
|
||||
/* the corresponding @FT_FaceRec values manually, with code similar */
|
||||
/* to the following. */
|
||||
/* */
|
||||
/* { */
|
||||
/* scaled_ascender = FT_MulFix( face->ascender, */
|
||||
/* size_metrics->y_scale ); */
|
||||
/* } */
|
||||
/* */
|
||||
/* Note that due to glyph hinting and the selected rendering mode */
|
||||
/* these values are usually not exact; consequently, they must be */
|
||||
/* treated as unreliable with an error margin of at least one pixel! */
|
||||
/* */
|
||||
/* Indeed, the only way to get the exact metrics is to render _all_ */
|
||||
/* glyphs. As this would be a definite performance hit, it is up to */
|
||||
/* client applications to perform such computations. */
|
||||
/* */
|
||||
/* The `FT_Size_Metrics' structure is valid for bitmap fonts also. */
|
||||
/* */
|
||||
/* */
|
||||
/* *TrueType* *fonts* *with* *native* *bytecode* *hinting* */
|
||||
/* */
|
||||
/* All applications that handle TrueType fonts with native hinting */
|
||||
/* must be aware that TTFs expect different rounding of vertical font */
|
||||
/* dimensions. The application has to cater for this, especially if */
|
||||
/* it wants to rely on a TTF's vertical data (for example, to */
|
||||
/* properly align box characters vertically). */
|
||||
/* */
|
||||
/* Only the application knows _in_ _advance_ that it is going to use */
|
||||
/* native hinting for TTFs! FreeType, on the other hand, selects the */
|
||||
/* hinting mode not at the time of creating an @FT_Size object but */
|
||||
/* much later, namely while calling @FT_Load_Glyph. */
|
||||
/* */
|
||||
/* Here is some pseudo code that illustrates a possible solution. */
|
||||
/* */
|
||||
/* { */
|
||||
/* font_format = FT_Get_Font_Format( face ); */
|
||||
/* */
|
||||
/* if ( !strcmp( font_format, "TrueType" ) && */
|
||||
/* do_native_bytecode_hinting ) */
|
||||
/* { */
|
||||
/* ascender = ROUND( FT_MulFix( face->ascender, */
|
||||
/* size_metrics->y_scale ) ); */
|
||||
/* descender = ROUND( FT_MulFix( face->descender, */
|
||||
/* size_metrics->y_scale ) ); */
|
||||
/* } */
|
||||
/* else */
|
||||
/* { */
|
||||
/* ascender = size_metrics->ascender; */
|
||||
/* descender = size_metrics->descender; */
|
||||
/* } */
|
||||
/* */
|
||||
/* height = size_metrics->height; */
|
||||
/* max_advance = size_metrics->max_advance; */
|
||||
/* } */
|
||||
/* */
|
||||
typedef struct FT_Size_Metrics_
|
||||
{
|
||||
FT_UShort x_ppem; /* horizontal pixels per EM */
|
||||
FT_UShort y_ppem; /* vertical pixels per EM */
|
||||
|
||||
FT_Fixed x_scale; /* scaling values used to convert font */
|
||||
FT_Fixed y_scale; /* units to 26.6 fractional pixels */
|
||||
|
||||
FT_Pos ascender; /* ascender in 26.6 frac. pixels */
|
||||
FT_Pos descender; /* descender in 26.6 frac. pixels */
|
||||
FT_Pos height; /* text height in 26.6 frac. pixels */
|
||||
FT_Pos max_advance; /* max horizontal advance, in 26.6 pixels */
|
||||
|
||||
} FT_Size_Metrics;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_SizeRec */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* FreeType root size class structure. A size object models a face */
|
||||
/* object at a given size. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* face :: Handle to the parent face object. */
|
||||
/* */
|
||||
/* generic :: A typeless pointer, unused by the FreeType library or */
|
||||
/* any of its drivers. It can be used by client */
|
||||
/* applications to link their own data to each size */
|
||||
/* object. */
|
||||
/* */
|
||||
/* metrics :: Metrics for this size object. This field is read-only. */
|
||||
/* */
|
||||
typedef struct FT_SizeRec_
|
||||
{
|
||||
FT_Face face; /* parent face object */
|
||||
FT_Generic generic; /* generic pointer for client uses */
|
||||
FT_Size_Metrics metrics; /* size metrics */
|
||||
FT_Size_Internal internal;
|
||||
|
||||
} FT_SizeRec;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_SubGlyph */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The subglyph structure is an internal object used to describe */
|
||||
/* subglyphs (for example, in the case of composites). */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The subglyph implementation is not part of the high-level API, */
|
||||
/* hence the forward structure declaration. */
|
||||
/* */
|
||||
/* You can however retrieve subglyph information with */
|
||||
/* @FT_Get_SubGlyph_Info. */
|
||||
/* */
|
||||
typedef struct FT_SubGlyphRec_* FT_SubGlyph;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Slot_Internal */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* An opaque handle to an `FT_Slot_InternalRec' structure, used to */
|
||||
/* model private data of a given @FT_GlyphSlot object. */
|
||||
/* */
|
||||
typedef struct FT_Slot_InternalRec_* FT_Slot_Internal;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_GlyphSlotRec */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* FreeType root glyph slot class structure. A glyph slot is a */
|
||||
/* container where individual glyphs can be loaded, be they in */
|
||||
/* outline or bitmap format. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* library :: A handle to the FreeType library instance */
|
||||
/* this slot belongs to. */
|
||||
/* */
|
||||
/* face :: A handle to the parent face object. */
|
||||
/* */
|
||||
/* next :: In some cases (like some font tools), several */
|
||||
/* glyph slots per face object can be a good */
|
||||
/* thing. As this is rare, the glyph slots are */
|
||||
/* listed through a direct, single-linked list */
|
||||
/* using its `next' field. */
|
||||
/* */
|
||||
/* generic :: A typeless pointer unused by the FreeType */
|
||||
/* library or any of its drivers. It can be */
|
||||
/* used by client applications to link their own */
|
||||
/* data to each glyph slot object. */
|
||||
/* */
|
||||
/* metrics :: The metrics of the last loaded glyph in the */
|
||||
/* slot. The returned values depend on the last */
|
||||
/* load flags (see the @FT_Load_Glyph API */
|
||||
/* function) and can be expressed either in 26.6 */
|
||||
/* fractional pixels or font units. */
|
||||
/* */
|
||||
/* Note that even when the glyph image is */
|
||||
/* transformed, the metrics are not. */
|
||||
/* */
|
||||
/* linearHoriAdvance :: The advance width of the unhinted glyph. */
|
||||
/* Its value is expressed in 16.16 fractional */
|
||||
/* pixels, unless @FT_LOAD_LINEAR_DESIGN is set */
|
||||
/* when loading the glyph. This field can be */
|
||||
/* important to perform correct WYSIWYG layout. */
|
||||
/* Only relevant for outline glyphs. */
|
||||
/* */
|
||||
/* linearVertAdvance :: The advance height of the unhinted glyph. */
|
||||
/* Its value is expressed in 16.16 fractional */
|
||||
/* pixels, unless @FT_LOAD_LINEAR_DESIGN is set */
|
||||
/* when loading the glyph. This field can be */
|
||||
/* important to perform correct WYSIWYG layout. */
|
||||
/* Only relevant for outline glyphs. */
|
||||
/* */
|
||||
/* advance :: This shorthand is, depending on */
|
||||
/* @FT_LOAD_IGNORE_TRANSFORM, the transformed */
|
||||
/* (hinted) advance width for the glyph, in 26.6 */
|
||||
/* fractional pixel format. As specified with */
|
||||
/* @FT_LOAD_VERTICAL_LAYOUT, it uses either the */
|
||||
/* `horiAdvance' or the `vertAdvance' value of */
|
||||
/* `metrics' field. */
|
||||
/* */
|
||||
/* format :: This field indicates the format of the image */
|
||||
/* contained in the glyph slot. Typically */
|
||||
/* @FT_GLYPH_FORMAT_BITMAP, */
|
||||
/* @FT_GLYPH_FORMAT_OUTLINE, or */
|
||||
/* @FT_GLYPH_FORMAT_COMPOSITE, but other values */
|
||||
/* are possible. */
|
||||
/* */
|
||||
/* bitmap :: This field is used as a bitmap descriptor. */
|
||||
/* Note that the address and content of the */
|
||||
/* bitmap buffer can change between calls of */
|
||||
/* @FT_Load_Glyph and a few other functions. */
|
||||
/* */
|
||||
/* bitmap_left :: The bitmap's left bearing expressed in */
|
||||
/* integer pixels. */
|
||||
/* */
|
||||
/* bitmap_top :: The bitmap's top bearing expressed in integer */
|
||||
/* pixels. This is the distance from the */
|
||||
/* baseline to the top-most glyph scanline, */
|
||||
/* upwards y~coordinates being *positive*. */
|
||||
/* */
|
||||
/* outline :: The outline descriptor for the current glyph */
|
||||
/* image if its format is */
|
||||
/* @FT_GLYPH_FORMAT_OUTLINE. Once a glyph is */
|
||||
/* loaded, `outline' can be transformed, */
|
||||
/* distorted, emboldened, etc. However, it must */
|
||||
/* not be freed. */
|
||||
/* */
|
||||
/* num_subglyphs :: The number of subglyphs in a composite glyph. */
|
||||
/* This field is only valid for the composite */
|
||||
/* glyph format that should normally only be */
|
||||
/* loaded with the @FT_LOAD_NO_RECURSE flag. */
|
||||
/* */
|
||||
/* subglyphs :: An array of subglyph descriptors for */
|
||||
/* composite glyphs. There are `num_subglyphs' */
|
||||
/* elements in there. Currently internal to */
|
||||
/* FreeType. */
|
||||
/* */
|
||||
/* control_data :: Certain font drivers can also return the */
|
||||
/* control data for a given glyph image (e.g. */
|
||||
/* TrueType bytecode, Type~1 charstrings, etc.). */
|
||||
/* This field is a pointer to such data; it is */
|
||||
/* currently internal to FreeType. */
|
||||
/* */
|
||||
/* control_len :: This is the length in bytes of the control */
|
||||
/* data. Currently internal to FreeType. */
|
||||
/* */
|
||||
/* other :: Reserved. */
|
||||
/* */
|
||||
/* lsb_delta :: The difference between hinted and unhinted */
|
||||
/* left side bearing while auto-hinting is */
|
||||
/* active. Zero otherwise. */
|
||||
/* */
|
||||
/* rsb_delta :: The difference between hinted and unhinted */
|
||||
/* right side bearing while auto-hinting is */
|
||||
/* active. Zero otherwise. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* If @FT_Load_Glyph is called with default flags (see */
|
||||
/* @FT_LOAD_DEFAULT) the glyph image is loaded in the glyph slot in */
|
||||
/* its native format (e.g., an outline glyph for TrueType and Type~1 */
|
||||
/* formats). [Since 2.9] The prospective bitmap metrics are */
|
||||
/* calculated according to @FT_LOAD_TARGET_XXX and other flags even */
|
||||
/* for the outline glyph, even if @FT_LOAD_RENDER is not set. */
|
||||
/* */
|
||||
/* This image can later be converted into a bitmap by calling */
|
||||
/* @FT_Render_Glyph. This function searches the current renderer for */
|
||||
/* the native image's format, then invokes it. */
|
||||
/* */
|
||||
/* The renderer is in charge of transforming the native image through */
|
||||
/* the slot's face transformation fields, then converting it into a */
|
||||
/* bitmap that is returned in `slot->bitmap'. */
|
||||
/* */
|
||||
/* Note that `slot->bitmap_left' and `slot->bitmap_top' are also used */
|
||||
/* to specify the position of the bitmap relative to the current pen */
|
||||
/* position (e.g., coordinates (0,0) on the baseline). Of course, */
|
||||
/* `slot->format' is also changed to @FT_GLYPH_FORMAT_BITMAP. */
|
||||
/* */
|
||||
/* Here is a small pseudo code fragment that shows how to use */
|
||||
/* `lsb_delta' and `rsb_delta' to do fractional positioning of */
|
||||
/* glyphs: */
|
||||
/* */
|
||||
/* { */
|
||||
/* FT_GlyphSlot slot = face->glyph; */
|
||||
/* FT_Pos origin_x = 0; */
|
||||
/* */
|
||||
/* */
|
||||
/* for all glyphs do */
|
||||
/* <load glyph with `FT_Load_Glyph'> */
|
||||
/* */
|
||||
/* FT_Outline_Translate( slot->outline, origin_x & 63, 0 ); */
|
||||
/* */
|
||||
/* <save glyph image, or render glyph, or ...> */
|
||||
/* */
|
||||
/* <compute kern between current and next glyph */
|
||||
/* and add it to `origin_x'> */
|
||||
/* */
|
||||
/* origin_x += slot->advance.x; */
|
||||
/* origin_x += slot->rsb_delta - slot->lsb_delta; */
|
||||
/* endfor */
|
||||
/* } */
|
||||
/* */
|
||||
/* Here is another small pseudo code fragment that shows how to use */
|
||||
/* `lsb_delta' and `rsb_delta' to improve integer positioning of */
|
||||
/* glyphs: */
|
||||
/* */
|
||||
/* { */
|
||||
/* FT_GlyphSlot slot = face->glyph; */
|
||||
/* FT_Pos origin_x = 0; */
|
||||
/* FT_Pos prev_rsb_delta = 0; */
|
||||
/* */
|
||||
/* */
|
||||
/* for all glyphs do */
|
||||
/* <compute kern between current and previous glyph */
|
||||
/* and add it to `origin_x'> */
|
||||
/* */
|
||||
/* <load glyph with `FT_Load_Glyph'> */
|
||||
/* */
|
||||
/* if ( prev_rsb_delta - slot->lsb_delta > 32 ) */
|
||||
/* origin_x -= 64; */
|
||||
/* else if ( prev_rsb_delta - slot->lsb_delta < -31 ) */
|
||||
/* origin_x += 64; */
|
||||
/* */
|
||||
/* prev_rsb_delta = slot->rsb_delta; */
|
||||
/* */
|
||||
/* <save glyph image, or render glyph, or ...> */
|
||||
/* */
|
||||
/* origin_x += slot->advance.x; */
|
||||
/* endfor */
|
||||
/* } */
|
||||
/* */
|
||||
/* If you use strong auto-hinting, you *must* apply these delta */
|
||||
/* values! Otherwise you will experience far too large inter-glyph */
|
||||
/* spacing at small rendering sizes in most cases. Note that it */
|
||||
/* doesn't harm to use the above code for other hinting modes also, */
|
||||
/* since the delta values are zero then. */
|
||||
/* */
|
||||
typedef struct FT_GlyphSlotRec_
|
||||
{
|
||||
FT_Library library;
|
||||
FT_Face face;
|
||||
FT_GlyphSlot next;
|
||||
FT_UInt reserved; /* retained for binary compatibility */
|
||||
FT_Generic generic;
|
||||
|
||||
FT_Glyph_Metrics metrics;
|
||||
FT_Fixed linearHoriAdvance;
|
||||
FT_Fixed linearVertAdvance;
|
||||
FT_Vector advance;
|
||||
|
||||
FT_Glyph_Format format;
|
||||
|
||||
FT_Bitmap bitmap;
|
||||
FT_Int bitmap_left;
|
||||
FT_Int bitmap_top;
|
||||
|
||||
FT_Outline outline;
|
||||
|
||||
FT_UInt num_subglyphs;
|
||||
FT_SubGlyph subglyphs;
|
||||
|
||||
void* control_data;
|
||||
long control_len;
|
||||
|
||||
FT_Pos lsb_delta;
|
||||
FT_Pos rsb_delta;
|
||||
|
||||
void* other;
|
||||
|
||||
FT_Slot_Internal internal;
|
||||
|
||||
} FT_GlyphSlotRec;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* F U N C T I O N S */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Init_FreeType */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Initialize a new FreeType library object. The set of modules */
|
||||
/* that are registered by this function is determined at build time. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* alibrary :: A handle to a new library object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* In case you want to provide your own memory allocating routines, */
|
||||
/* use @FT_New_Library instead, followed by a call to */
|
||||
/* @FT_Add_Default_Modules (or a series of calls to @FT_Add_Module) */
|
||||
/* and @FT_Set_Default_Properties. */
|
||||
/* */
|
||||
/* See the documentation of @FT_Library and @FT_Face for */
|
||||
/* multi-threading issues. */
|
||||
/* */
|
||||
/* If you need reference-counting (cf. @FT_Reference_Library), use */
|
||||
/* @FT_New_Library and @FT_Done_Library. */
|
||||
/* */
|
||||
/* If compilation option FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES is */
|
||||
/* set, this function reads the `FREETYPE_PROPERTIES' environment */
|
||||
/* variable to control driver properties. See section @properties */
|
||||
/* for more. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Init_FreeType( FT_Library *alibrary );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Done_FreeType */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Destroy a given FreeType library object and all of its children, */
|
||||
/* including resources, drivers, faces, sizes, etc. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle to the target library object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Done_FreeType( FT_Library library );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Enum> */
|
||||
/* FT_OPEN_XXX */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A list of bit field constants used within the `flags' field of the */
|
||||
/* @FT_Open_Args structure. */
|
||||
/* */
|
||||
/* <Values> */
|
||||
/* FT_OPEN_MEMORY :: This is a memory-based stream. */
|
||||
/* */
|
||||
/* FT_OPEN_STREAM :: Copy the stream from the `stream' field. */
|
||||
/* */
|
||||
/* FT_OPEN_PATHNAME :: Create a new input stream from a C~path */
|
||||
/* name. */
|
||||
/* */
|
||||
/* FT_OPEN_DRIVER :: Use the `driver' field. */
|
||||
/* */
|
||||
/* FT_OPEN_PARAMS :: Use the `num_params' and `params' fields. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The `FT_OPEN_MEMORY', `FT_OPEN_STREAM', and `FT_OPEN_PATHNAME' */
|
||||
/* flags are mutually exclusive. */
|
||||
/* */
|
||||
#define FT_OPEN_MEMORY 0x1
|
||||
#define FT_OPEN_STREAM 0x2
|
||||
#define FT_OPEN_PATHNAME 0x4
|
||||
#define FT_OPEN_DRIVER 0x8
|
||||
#define FT_OPEN_PARAMS 0x10
|
||||
|
||||
|
||||
/* these constants are deprecated; use the corresponding `FT_OPEN_XXX' */
|
||||
/* values instead */
|
||||
#define ft_open_memory FT_OPEN_MEMORY
|
||||
#define ft_open_stream FT_OPEN_STREAM
|
||||
#define ft_open_pathname FT_OPEN_PATHNAME
|
||||
#define ft_open_driver FT_OPEN_DRIVER
|
||||
#define ft_open_params FT_OPEN_PARAMS
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_Parameter */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A simple structure to pass more or less generic parameters to */
|
||||
/* @FT_Open_Face and @FT_Face_Properties. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* tag :: A four-byte identification tag. */
|
||||
/* */
|
||||
/* data :: A pointer to the parameter data. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The ID and function of parameters are driver-specific. See */
|
||||
/* section @parameter_tags for more information. */
|
||||
/* */
|
||||
typedef struct FT_Parameter_
|
||||
{
|
||||
FT_ULong tag;
|
||||
FT_Pointer data;
|
||||
|
||||
} FT_Parameter;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_Open_Args */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure to indicate how to open a new font file or stream. A */
|
||||
/* pointer to such a structure can be used as a parameter for the */
|
||||
/* functions @FT_Open_Face and @FT_Attach_Stream. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* flags :: A set of bit flags indicating how to use the */
|
||||
/* structure. */
|
||||
/* */
|
||||
/* memory_base :: The first byte of the file in memory. */
|
||||
/* */
|
||||
/* memory_size :: The size in bytes of the file in memory. */
|
||||
/* */
|
||||
/* pathname :: A pointer to an 8-bit file pathname. */
|
||||
/* */
|
||||
/* stream :: A handle to a source stream object. */
|
||||
/* */
|
||||
/* driver :: This field is exclusively used by @FT_Open_Face; */
|
||||
/* it simply specifies the font driver to use for */
|
||||
/* opening the face. If set to NULL, FreeType tries */
|
||||
/* to load the face with each one of the drivers in */
|
||||
/* its list. */
|
||||
/* */
|
||||
/* num_params :: The number of extra parameters. */
|
||||
/* */
|
||||
/* params :: Extra parameters passed to the font driver when */
|
||||
/* opening a new face. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The stream type is determined by the contents of `flags' that */
|
||||
/* are tested in the following order by @FT_Open_Face: */
|
||||
/* */
|
||||
/* If the @FT_OPEN_MEMORY bit is set, assume that this is a */
|
||||
/* memory file of `memory_size' bytes, located at `memory_address'. */
|
||||
/* The data are not copied, and the client is responsible for */
|
||||
/* releasing and destroying them _after_ the corresponding call to */
|
||||
/* @FT_Done_Face. */
|
||||
/* */
|
||||
/* Otherwise, if the @FT_OPEN_STREAM bit is set, assume that a */
|
||||
/* custom input stream `stream' is used. */
|
||||
/* */
|
||||
/* Otherwise, if the @FT_OPEN_PATHNAME bit is set, assume that this */
|
||||
/* is a normal file and use `pathname' to open it. */
|
||||
/* */
|
||||
/* If the @FT_OPEN_DRIVER bit is set, @FT_Open_Face only tries to */
|
||||
/* open the file with the driver whose handler is in `driver'. */
|
||||
/* */
|
||||
/* If the @FT_OPEN_PARAMS bit is set, the parameters given by */
|
||||
/* `num_params' and `params' is used. They are ignored otherwise. */
|
||||
/* */
|
||||
/* Ideally, both the `pathname' and `params' fields should be tagged */
|
||||
/* as `const'; this is missing for API backward compatibility. In */
|
||||
/* other words, applications should treat them as read-only. */
|
||||
/* */
|
||||
typedef struct FT_Open_Args_
|
||||
{
|
||||
FT_UInt flags;
|
||||
const FT_Byte* memory_base;
|
||||
FT_Long memory_size;
|
||||
FT_String* pathname;
|
||||
FT_Stream stream;
|
||||
FT_Module driver;
|
||||
FT_Int num_params;
|
||||
FT_Parameter* params;
|
||||
|
||||
} FT_Open_Args;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_New_Face */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Call @FT_Open_Face to open a font by its pathname. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* library :: A handle to the library resource. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* pathname :: A path to the font file. */
|
||||
/* */
|
||||
/* face_index :: See @FT_Open_Face for a detailed description of this */
|
||||
/* parameter. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* aface :: A handle to a new face object. If `face_index' is */
|
||||
/* greater than or equal to zero, it must be non-NULL. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* Use @FT_Done_Face to destroy the created @FT_Face object (along */
|
||||
/* with its slot and sizes). */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_New_Face( FT_Library library,
|
||||
const char* filepathname,
|
||||
FT_Long face_index,
|
||||
FT_Face *aface );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_New_Memory_Face */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Call @FT_Open_Face to open a font that has been loaded into */
|
||||
/* memory. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* library :: A handle to the library resource. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* file_base :: A pointer to the beginning of the font data. */
|
||||
/* */
|
||||
/* file_size :: The size of the memory chunk used by the font data. */
|
||||
/* */
|
||||
/* face_index :: See @FT_Open_Face for a detailed description of this */
|
||||
/* parameter. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* aface :: A handle to a new face object. If `face_index' is */
|
||||
/* greater than or equal to zero, it must be non-NULL. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* You must not deallocate the memory before calling @FT_Done_Face. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_New_Memory_Face( FT_Library library,
|
||||
const FT_Byte* file_base,
|
||||
FT_Long file_size,
|
||||
FT_Long face_index,
|
||||
FT_Face *aface );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Open_Face */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Create a face object from a given resource described by */
|
||||
/* @FT_Open_Args. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* library :: A handle to the library resource. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* args :: A pointer to an `FT_Open_Args' structure that must */
|
||||
/* be filled by the caller. */
|
||||
/* */
|
||||
/* face_index :: This field holds two different values. Bits 0-15 */
|
||||
/* are the index of the face in the font file (starting */
|
||||
/* with value~0). Set it to~0 if there is only one */
|
||||
/* face in the font file. */
|
||||
/* */
|
||||
/* [Since 2.6.1] Bits 16-30 are relevant to GX and */
|
||||
/* OpenType variation fonts only, specifying the named */
|
||||
/* instance index for the current face index (starting */
|
||||
/* with value~1; value~0 makes FreeType ignore named */
|
||||
/* instances). For non-variation fonts, bits 16-30 are */
|
||||
/* ignored. Assuming that you want to access the third */
|
||||
/* named instance in face~4, `face_index' should be set */
|
||||
/* to 0x00030004. If you want to access face~4 without */
|
||||
/* variation handling, simply set `face_index' to */
|
||||
/* value~4. */
|
||||
/* */
|
||||
/* `FT_Open_Face' and its siblings can be used to */
|
||||
/* quickly check whether the font format of a given */
|
||||
/* font resource is supported by FreeType. In general, */
|
||||
/* if the `face_index' argument is negative, the */
|
||||
/* function's return value is~0 if the font format is */
|
||||
/* recognized, or non-zero otherwise. The function */
|
||||
/* allocates a more or less empty face handle in */
|
||||
/* `*aface' (if `aface' isn't NULL); the only two */
|
||||
/* useful fields in this special case are */
|
||||
/* `face->num_faces' and `face->style_flags'. For any */
|
||||
/* negative value of `face_index', `face->num_faces' */
|
||||
/* gives the number of faces within the font file. For */
|
||||
/* the negative value `-(N+1)' (with `N' a non-negative */
|
||||
/* 16-bit value), bits 16-30 in `face->style_flags' */
|
||||
/* give the number of named instances in face `N' if we */
|
||||
/* have a variation font (or zero otherwise). After */
|
||||
/* examination, the returned @FT_Face structure should */
|
||||
/* be deallocated with a call to @FT_Done_Face. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* aface :: A handle to a new face object. If `face_index' is */
|
||||
/* greater than or equal to zero, it must be non-NULL. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* Unlike FreeType 1.x, this function automatically creates a glyph */
|
||||
/* slot for the face object that can be accessed directly through */
|
||||
/* `face->glyph'. */
|
||||
/* */
|
||||
/* Each new face object created with this function also owns a */
|
||||
/* default @FT_Size object, accessible as `face->size'. */
|
||||
/* */
|
||||
/* One @FT_Library instance can have multiple face objects, this is, */
|
||||
/* @FT_Open_Face and its siblings can be called multiple times using */
|
||||
/* the same `library' argument. */
|
||||
/* */
|
||||
/* See the discussion of reference counters in the description of */
|
||||
/* @FT_Reference_Face. */
|
||||
/* */
|
||||
/* To loop over all faces, use code similar to the following snippet */
|
||||
/* (omitting the error handling). */
|
||||
/* */
|
||||
/* { */
|
||||
/* ... */
|
||||
/* FT_Face face; */
|
||||
/* FT_Long i, num_faces; */
|
||||
/* */
|
||||
/* */
|
||||
/* error = FT_Open_Face( library, args, -1, &face ); */
|
||||
/* if ( error ) { ... } */
|
||||
/* */
|
||||
/* num_faces = face->num_faces; */
|
||||
/* FT_Done_Face( face ); */
|
||||
/* */
|
||||
/* for ( i = 0; i < num_faces; i++ ) */
|
||||
/* { */
|
||||
/* ... */
|
||||
/* error = FT_Open_Face( library, args, i, &face ); */
|
||||
/* ... */
|
||||
/* FT_Done_Face( face ); */
|
||||
/* ... */
|
||||
/* } */
|
||||
/* } */
|
||||
/* */
|
||||
/* To loop over all valid values for `face_index', use something */
|
||||
/* similar to the following snippet, again without error handling. */
|
||||
/* The code accesses all faces immediately (thus only a single call */
|
||||
/* of `FT_Open_Face' within the do-loop), with and without named */
|
||||
/* instances. */
|
||||
/* */
|
||||
/* { */
|
||||
/* ... */
|
||||
/* FT_Face face; */
|
||||
/* */
|
||||
/* FT_Long num_faces = 0; */
|
||||
/* FT_Long num_instances = 0; */
|
||||
/* */
|
||||
/* FT_Long face_idx = 0; */
|
||||
/* FT_Long instance_idx = 0; */
|
||||
/* */
|
||||
/* */
|
||||
/* do */
|
||||
/* { */
|
||||
/* FT_Long id = ( instance_idx << 16 ) + face_idx; */
|
||||
/* */
|
||||
/* */
|
||||
/* error = FT_Open_Face( library, args, id, &face ); */
|
||||
/* if ( error ) { ... } */
|
||||
/* */
|
||||
/* num_faces = face->num_faces; */
|
||||
/* num_instances = face->style_flags >> 16; */
|
||||
/* */
|
||||
/* ... */
|
||||
/* */
|
||||
/* FT_Done_Face( face ); */
|
||||
/* */
|
||||
/* if ( instance_idx < num_instances ) */
|
||||
/* instance_idx++; */
|
||||
/* else */
|
||||
/* { */
|
||||
/* face_idx++; */
|
||||
/* instance_idx = 0; */
|
||||
/* } */
|
||||
/* */
|
||||
/* } while ( face_idx < num_faces ) */
|
||||
/* } */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Open_Face( FT_Library library,
|
||||
const FT_Open_Args* args,
|
||||
FT_Long face_index,
|
||||
FT_Face *aface );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Attach_File */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Call @FT_Attach_Stream to attach a file. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* face :: The target face object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* filepathname :: The pathname. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Attach_File( FT_Face face,
|
||||
const char* filepathname );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Attach_Stream */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* `Attach' data to a face object. Normally, this is used to read */
|
||||
/* additional information for the face object. For example, you can */
|
||||
/* attach an AFM file that comes with a Type~1 font to get the */
|
||||
/* kerning values and other metrics. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* face :: The target face object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* parameters :: A pointer to @FT_Open_Args that must be filled by */
|
||||
/* the caller. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The meaning of the `attach' (i.e., what really happens when the */
|
||||
/* new file is read) is not fixed by FreeType itself. It really */
|
||||
/* depends on the font format (and thus the font driver). */
|
||||
/* */
|
||||
/* Client applications are expected to know what they are doing */
|
||||
/* when invoking this function. Most drivers simply do not implement */
|
||||
/* file or stream attachments. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Attach_Stream( FT_Face face,
|
||||
FT_Open_Args* parameters );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Reference_Face */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A counter gets initialized to~1 at the time an @FT_Face structure */
|
||||
/* is created. This function increments the counter. @FT_Done_Face */
|
||||
/* then only destroys a face if the counter is~1, otherwise it simply */
|
||||
/* decrements the counter. */
|
||||
/* */
|
||||
/* This function helps in managing life-cycles of structures that */
|
||||
/* reference @FT_Face objects. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to a target face object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Since> */
|
||||
/* 2.4.2 */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Reference_Face( FT_Face face );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Done_Face */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Discard a given face object, as well as all of its child slots and */
|
||||
/* sizes. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to a target face object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* See the discussion of reference counters in the description of */
|
||||
/* @FT_Reference_Face. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Done_Face( FT_Face face );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Select_Size */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Select a bitmap strike. To be more precise, this function sets */
|
||||
/* the scaling factors of the active @FT_Size object in a face so */
|
||||
/* that bitmaps from this particular strike are taken by */
|
||||
/* @FT_Load_Glyph and friends. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* face :: A handle to a target face object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* strike_index :: The index of the bitmap strike in the */
|
||||
/* `available_sizes' field of @FT_FaceRec structure. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* For bitmaps embedded in outline fonts it is common that only a */
|
||||
/* subset of the available glyphs at a given ppem value is available. */
|
||||
/* FreeType silently uses outlines if there is no bitmap for a given */
|
||||
/* glyph index. */
|
||||
/* */
|
||||
/* For GX and OpenType variation fonts, a bitmap strike makes sense */
|
||||
/* only if the default instance is active (this is, no glyph */
|
||||
/* variation takes place); otherwise, FreeType simply ignores bitmap */
|
||||
/* strikes. The same is true for all named instances that are */
|
||||
/* different from the default instance. */
|
||||
/* */
|
||||
/* Don't use this function if you are using the FreeType cache API. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Select_Size( FT_Face face,
|
||||
FT_Int strike_index );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Enum> */
|
||||
/* FT_Size_Request_Type */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* An enumeration type that lists the supported size request types, */
|
||||
/* i.e., what input size (in font units) maps to the requested output */
|
||||
/* size (in pixels, as computed from the arguments of */
|
||||
/* @FT_Size_Request). */
|
||||
/* */
|
||||
/* <Values> */
|
||||
/* FT_SIZE_REQUEST_TYPE_NOMINAL :: */
|
||||
/* The nominal size. The `units_per_EM' field of @FT_FaceRec is */
|
||||
/* used to determine both scaling values. */
|
||||
/* */
|
||||
/* This is the standard scaling found in most applications. In */
|
||||
/* particular, use this size request type for TrueType fonts if */
|
||||
/* they provide optical scaling or something similar. Note, */
|
||||
/* however, that `units_per_EM' is a rather abstract value which */
|
||||
/* bears no relation to the actual size of the glyphs in a font. */
|
||||
/* */
|
||||
/* FT_SIZE_REQUEST_TYPE_REAL_DIM :: */
|
||||
/* The real dimension. The sum of the `ascender' and (minus of) */
|
||||
/* the `descender' fields of @FT_FaceRec is used to determine both */
|
||||
/* scaling values. */
|
||||
/* */
|
||||
/* FT_SIZE_REQUEST_TYPE_BBOX :: */
|
||||
/* The font bounding box. The width and height of the `bbox' field */
|
||||
/* of @FT_FaceRec are used to determine the horizontal and vertical */
|
||||
/* scaling value, respectively. */
|
||||
/* */
|
||||
/* FT_SIZE_REQUEST_TYPE_CELL :: */
|
||||
/* The `max_advance_width' field of @FT_FaceRec is used to */
|
||||
/* determine the horizontal scaling value; the vertical scaling */
|
||||
/* value is determined the same way as */
|
||||
/* @FT_SIZE_REQUEST_TYPE_REAL_DIM does. Finally, both scaling */
|
||||
/* values are set to the smaller one. This type is useful if you */
|
||||
/* want to specify the font size for, say, a window of a given */
|
||||
/* dimension and 80x24 cells. */
|
||||
/* */
|
||||
/* FT_SIZE_REQUEST_TYPE_SCALES :: */
|
||||
/* Specify the scaling values directly. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The above descriptions only apply to scalable formats. For bitmap */
|
||||
/* formats, the behaviour is up to the driver. */
|
||||
/* */
|
||||
/* See the note section of @FT_Size_Metrics if you wonder how size */
|
||||
/* requesting relates to scaling values. */
|
||||
/* */
|
||||
typedef enum FT_Size_Request_Type_
|
||||
{
|
||||
FT_SIZE_REQUEST_TYPE_NOMINAL,
|
||||
FT_SIZE_REQUEST_TYPE_REAL_DIM,
|
||||
FT_SIZE_REQUEST_TYPE_BBOX,
|
||||
FT_SIZE_REQUEST_TYPE_CELL,
|
||||
FT_SIZE_REQUEST_TYPE_SCALES,
|
||||
|
||||
FT_SIZE_REQUEST_TYPE_MAX
|
||||
|
||||
} FT_Size_Request_Type;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_Size_RequestRec */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure to model a size request. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* type :: See @FT_Size_Request_Type. */
|
||||
/* */
|
||||
/* width :: The desired width, given as a 26.6 fractional */
|
||||
/* point value (with 72pt = 1in). */
|
||||
/* */
|
||||
/* height :: The desired height, given as a 26.6 fractional */
|
||||
/* point value (with 72pt = 1in). */
|
||||
/* */
|
||||
/* horiResolution :: The horizontal resolution (dpi, i.e., pixels per */
|
||||
/* inch). If set to zero, `width' is treated as a */
|
||||
/* 26.6 fractional *pixel* value, which gets */
|
||||
/* internally rounded to an integer. */
|
||||
/* */
|
||||
/* vertResolution :: The vertical resolution (dpi, i.e., pixels per */
|
||||
/* inch). If set to zero, `height' is treated as a */
|
||||
/* 26.6 fractional *pixel* value, which gets */
|
||||
/* internally rounded to an integer. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* If `width' is zero, the horizontal scaling value is set equal */
|
||||
/* to the vertical scaling value, and vice versa. */
|
||||
/* */
|
||||
/* If `type' is FT_SIZE_REQUEST_TYPE_SCALES, `width' and `height' are */
|
||||
/* interpreted directly as 16.16 fractional scaling values, without */
|
||||
/* any further modification, and both `horiResolution' and */
|
||||
/* `vertResolution' are ignored. */
|
||||
/* */
|
||||
typedef struct FT_Size_RequestRec_
|
||||
{
|
||||
FT_Size_Request_Type type;
|
||||
FT_Long width;
|
||||
FT_Long height;
|
||||
FT_UInt horiResolution;
|
||||
FT_UInt vertResolution;
|
||||
|
||||
} FT_Size_RequestRec;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_Size_Request */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to a size request structure. */
|
||||
/* */
|
||||
typedef struct FT_Size_RequestRec_ *FT_Size_Request;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Request_Size */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Resize the scale of the active @FT_Size object in a face. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* face :: A handle to a target face object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* req :: A pointer to a @FT_Size_RequestRec. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* Although drivers may select the bitmap strike matching the */
|
||||
/* request, you should not rely on this if you intend to select a */
|
||||
/* particular bitmap strike. Use @FT_Select_Size instead in that */
|
||||
/* case. */
|
||||
/* */
|
||||
/* The relation between the requested size and the resulting glyph */
|
||||
/* size is dependent entirely on how the size is defined in the */
|
||||
/* source face. The font designer chooses the final size of each */
|
||||
/* glyph relative to this size. For more information refer to */
|
||||
/* `https://www.freetype.org/freetype2/docs/glyphs/glyphs-2.html'. */
|
||||
/* */
|
||||
/* Contrary to @FT_Set_Char_Size, this function doesn't have special */
|
||||
/* code to normalize zero-valued widths, heights, or resolutions */
|
||||
/* (which lead to errors in most cases). */
|
||||
/* */
|
||||
/* Don't use this function if you are using the FreeType cache API. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Request_Size( FT_Face face,
|
||||
FT_Size_Request req );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Set_Char_Size */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Call @FT_Request_Size to request the nominal size (in points). */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* face :: A handle to a target face object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* char_width :: The nominal width, in 26.6 fractional points. */
|
||||
/* */
|
||||
/* char_height :: The nominal height, in 26.6 fractional points. */
|
||||
/* */
|
||||
/* horz_resolution :: The horizontal resolution in dpi. */
|
||||
/* */
|
||||
/* vert_resolution :: The vertical resolution in dpi. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* While this function allows fractional points as input values, the */
|
||||
/* resulting ppem value for the given resolution is always rounded to */
|
||||
/* the nearest integer. */
|
||||
/* */
|
||||
/* If either the character width or height is zero, it is set equal */
|
||||
/* to the other value. */
|
||||
/* */
|
||||
/* If either the horizontal or vertical resolution is zero, it is set */
|
||||
/* equal to the other value. */
|
||||
/* */
|
||||
/* A character width or height smaller than 1pt is set to 1pt; if */
|
||||
/* both resolution values are zero, they are set to 72dpi. */
|
||||
/* */
|
||||
/* Don't use this function if you are using the FreeType cache API. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Set_Char_Size( FT_Face face,
|
||||
FT_F26Dot6 char_width,
|
||||
FT_F26Dot6 char_height,
|
||||
FT_UInt horz_resolution,
|
||||
FT_UInt vert_resolution );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Set_Pixel_Sizes */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Call @FT_Request_Size to request the nominal size (in pixels). */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* face :: A handle to the target face object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* pixel_width :: The nominal width, in pixels. */
|
||||
/* */
|
||||
/* pixel_height :: The nominal height, in pixels. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* You should not rely on the resulting glyphs matching or being */
|
||||
/* constrained to this pixel size. Refer to @FT_Request_Size to */
|
||||
/* understand how requested sizes relate to actual sizes. */
|
||||
/* */
|
||||
/* Don't use this function if you are using the FreeType cache API. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Set_Pixel_Sizes( FT_Face face,
|
||||
FT_UInt pixel_width,
|
||||
FT_UInt pixel_height );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Load_Glyph */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Load a glyph into the glyph slot of a face object. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* face :: A handle to the target face object where the glyph */
|
||||
/* is loaded. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* glyph_index :: The index of the glyph in the font file. For */
|
||||
/* CID-keyed fonts (either in PS or in CFF format) */
|
||||
/* this argument specifies the CID value. */
|
||||
/* */
|
||||
/* load_flags :: A flag indicating what to load for this glyph. The */
|
||||
/* @FT_LOAD_XXX constants can be used to control the */
|
||||
/* glyph loading process (e.g., whether the outline */
|
||||
/* should be scaled, whether to load bitmaps or not, */
|
||||
/* whether to hint the outline, etc). */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The loaded glyph may be transformed. See @FT_Set_Transform for */
|
||||
/* the details. */
|
||||
/* */
|
||||
/* For subsetted CID-keyed fonts, `FT_Err_Invalid_Argument' is */
|
||||
/* returned for invalid CID values (this is, for CID values that */
|
||||
/* don't have a corresponding glyph in the font). See the discussion */
|
||||
/* of the @FT_FACE_FLAG_CID_KEYED flag for more details. */
|
||||
/* */
|
||||
/* If you receive `FT_Err_Glyph_Too_Big', try getting the glyph */
|
||||
/* outline at EM size, then scale it manually and fill it as a */
|
||||
/* graphics operation. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Load_Glyph( FT_Face face,
|
||||
FT_UInt glyph_index,
|
||||
FT_Int32 load_flags );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Load_Char */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Load a glyph into the glyph slot of a face object, accessed by its */
|
||||
/* character code. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* face :: A handle to a target face object where the glyph */
|
||||
/* is loaded. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* char_code :: The glyph's character code, according to the */
|
||||
/* current charmap used in the face. */
|
||||
/* */
|
||||
/* load_flags :: A flag indicating what to load for this glyph. The */
|
||||
/* @FT_LOAD_XXX constants can be used to control the */
|
||||
/* glyph loading process (e.g., whether the outline */
|
||||
/* should be scaled, whether to load bitmaps or not, */
|
||||
/* whether to hint the outline, etc). */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This function simply calls @FT_Get_Char_Index and @FT_Load_Glyph. */
|
||||
/* */
|
||||
/* Many fonts contain glyphs that can't be loaded by this function */
|
||||
/* since its glyph indices are not listed in any of the font's */
|
||||
/* charmaps. */
|
||||
/* */
|
||||
/* If no active cmap is set up (i.e., `face->charmap' is zero), the */
|
||||
/* call to @FT_Get_Char_Index is omitted, and the function behaves */
|
||||
/* identically to @FT_Load_Glyph. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Load_Char( FT_Face face,
|
||||
FT_ULong char_code,
|
||||
FT_Int32 load_flags );
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @enum:
|
||||
* FT_LOAD_XXX
|
||||
*
|
||||
* @description:
|
||||
* A list of bit field constants for @FT_Load_Glyph to indicate what
|
||||
* kind of operations to perform during glyph loading.
|
||||
*
|
||||
* @values:
|
||||
* FT_LOAD_DEFAULT ::
|
||||
* Corresponding to~0, this value is used as the default glyph load
|
||||
* operation. In this case, the following happens:
|
||||
*
|
||||
* 1. FreeType looks for a bitmap for the glyph corresponding to the
|
||||
* face's current size. If one is found, the function returns.
|
||||
* The bitmap data can be accessed from the glyph slot (see note
|
||||
* below).
|
||||
*
|
||||
* 2. If no embedded bitmap is searched for or found, FreeType looks
|
||||
* for a scalable outline. If one is found, it is loaded from
|
||||
* the font file, scaled to device pixels, then `hinted' to the
|
||||
* pixel grid in order to optimize it. The outline data can be
|
||||
* accessed from the glyph slot (see note below).
|
||||
*
|
||||
* Note that by default the glyph loader doesn't render outlines into
|
||||
* bitmaps. The following flags are used to modify this default
|
||||
* behaviour to more specific and useful cases.
|
||||
*
|
||||
* FT_LOAD_NO_SCALE ::
|
||||
* Don't scale the loaded outline glyph but keep it in font units.
|
||||
*
|
||||
* This flag implies @FT_LOAD_NO_HINTING and @FT_LOAD_NO_BITMAP, and
|
||||
* unsets @FT_LOAD_RENDER.
|
||||
*
|
||||
* If the font is `tricky' (see @FT_FACE_FLAG_TRICKY for more), using
|
||||
* FT_LOAD_NO_SCALE usually yields meaningless outlines because the
|
||||
* subglyphs must be scaled and positioned with hinting instructions.
|
||||
* This can be solved by loading the font without FT_LOAD_NO_SCALE and
|
||||
* setting the character size to `font->units_per_EM'.
|
||||
*
|
||||
* FT_LOAD_NO_HINTING ::
|
||||
* Disable hinting. This generally generates `blurrier' bitmap glyphs
|
||||
* when the glyph are rendered in any of the anti-aliased modes. See
|
||||
* also the note below.
|
||||
*
|
||||
* This flag is implied by @FT_LOAD_NO_SCALE.
|
||||
*
|
||||
* FT_LOAD_RENDER ::
|
||||
* Call @FT_Render_Glyph after the glyph is loaded. By default, the
|
||||
* glyph is rendered in @FT_RENDER_MODE_NORMAL mode. This can be
|
||||
* overridden by @FT_LOAD_TARGET_XXX or @FT_LOAD_MONOCHROME.
|
||||
*
|
||||
* This flag is unset by @FT_LOAD_NO_SCALE.
|
||||
*
|
||||
* FT_LOAD_NO_BITMAP ::
|
||||
* Ignore bitmap strikes when loading. Bitmap-only fonts ignore this
|
||||
* flag.
|
||||
*
|
||||
* @FT_LOAD_NO_SCALE always sets this flag.
|
||||
*
|
||||
* FT_LOAD_VERTICAL_LAYOUT ::
|
||||
* Load the glyph for vertical text layout. In particular, the
|
||||
* `advance' value in the @FT_GlyphSlotRec structure is set to the
|
||||
* `vertAdvance' value of the `metrics' field.
|
||||
*
|
||||
* In case @FT_HAS_VERTICAL doesn't return true, you shouldn't use
|
||||
* this flag currently. Reason is that in this case vertical metrics
|
||||
* get synthesized, and those values are not always consistent across
|
||||
* various font formats.
|
||||
*
|
||||
* FT_LOAD_FORCE_AUTOHINT ::
|
||||
* Prefer the auto-hinter over the font's native hinter. See also
|
||||
* the note below.
|
||||
*
|
||||
* FT_LOAD_PEDANTIC ::
|
||||
* Make the font driver perform pedantic verifications during glyph
|
||||
* loading. This is mostly used to detect broken glyphs in fonts.
|
||||
* By default, FreeType tries to handle broken fonts also.
|
||||
*
|
||||
* In particular, errors from the TrueType bytecode engine are not
|
||||
* passed to the application if this flag is not set; this might
|
||||
* result in partially hinted or distorted glyphs in case a glyph's
|
||||
* bytecode is buggy.
|
||||
*
|
||||
* FT_LOAD_NO_RECURSE ::
|
||||
* Don't load composite glyphs recursively. Instead, the font
|
||||
* driver should set the `num_subglyph' and `subglyphs' values of
|
||||
* the glyph slot accordingly, and set `glyph->format' to
|
||||
* @FT_GLYPH_FORMAT_COMPOSITE. The description of subglyphs can
|
||||
* then be accessed with @FT_Get_SubGlyph_Info.
|
||||
*
|
||||
* This flag implies @FT_LOAD_NO_SCALE and @FT_LOAD_IGNORE_TRANSFORM.
|
||||
*
|
||||
* FT_LOAD_IGNORE_TRANSFORM ::
|
||||
* Ignore the transform matrix set by @FT_Set_Transform.
|
||||
*
|
||||
* FT_LOAD_MONOCHROME ::
|
||||
* This flag is used with @FT_LOAD_RENDER to indicate that you want to
|
||||
* render an outline glyph to a 1-bit monochrome bitmap glyph, with
|
||||
* 8~pixels packed into each byte of the bitmap data.
|
||||
*
|
||||
* Note that this has no effect on the hinting algorithm used. You
|
||||
* should rather use @FT_LOAD_TARGET_MONO so that the
|
||||
* monochrome-optimized hinting algorithm is used.
|
||||
*
|
||||
* FT_LOAD_LINEAR_DESIGN ::
|
||||
* Keep `linearHoriAdvance' and `linearVertAdvance' fields of
|
||||
* @FT_GlyphSlotRec in font units. See @FT_GlyphSlotRec for
|
||||
* details.
|
||||
*
|
||||
* FT_LOAD_NO_AUTOHINT ::
|
||||
* Disable the auto-hinter. See also the note below.
|
||||
*
|
||||
* FT_LOAD_COLOR ::
|
||||
* [Since 2.5] Load embedded color bitmap images. The resulting color
|
||||
* bitmaps, if available, will have the @FT_PIXEL_MODE_BGRA format.
|
||||
* If the flag is not set and color bitmaps are found, they are
|
||||
* converted to 256-level gray bitmaps transparently, using the
|
||||
* @FT_PIXEL_MODE_GRAY format.
|
||||
*
|
||||
* FT_LOAD_COMPUTE_METRICS ::
|
||||
* [Since 2.6.1] Compute glyph metrics from the glyph data, without
|
||||
* the use of bundled metrics tables (for example, the `hdmx' table in
|
||||
* TrueType fonts). This flag is mainly used by font validating or
|
||||
* font editing applications, which need to ignore, verify, or edit
|
||||
* those tables.
|
||||
*
|
||||
* Currently, this flag is only implemented for TrueType fonts.
|
||||
*
|
||||
* FT_LOAD_BITMAP_METRICS_ONLY ::
|
||||
* [Since 2.7.1] Request loading of the metrics and bitmap image
|
||||
* information of a (possibly embedded) bitmap glyph without
|
||||
* allocating or copying the bitmap image data itself. No effect if
|
||||
* the target glyph is not a bitmap image.
|
||||
*
|
||||
* This flag unsets @FT_LOAD_RENDER.
|
||||
*
|
||||
* FT_LOAD_CROP_BITMAP ::
|
||||
* Ignored. Deprecated.
|
||||
*
|
||||
* FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ::
|
||||
* Ignored. Deprecated.
|
||||
*
|
||||
* @note:
|
||||
* By default, hinting is enabled and the font's native hinter (see
|
||||
* @FT_FACE_FLAG_HINTER) is preferred over the auto-hinter. You can
|
||||
* disable hinting by setting @FT_LOAD_NO_HINTING or change the
|
||||
* precedence by setting @FT_LOAD_FORCE_AUTOHINT. You can also set
|
||||
* @FT_LOAD_NO_AUTOHINT in case you don't want the auto-hinter to be
|
||||
* used at all.
|
||||
*
|
||||
* See the description of @FT_FACE_FLAG_TRICKY for a special exception
|
||||
* (affecting only a handful of Asian fonts).
|
||||
*
|
||||
* Besides deciding which hinter to use, you can also decide which
|
||||
* hinting algorithm to use. See @FT_LOAD_TARGET_XXX for details.
|
||||
*
|
||||
* Note that the auto-hinter needs a valid Unicode cmap (either a native
|
||||
* one or synthesized by FreeType) for producing correct results. If a
|
||||
* font provides an incorrect mapping (for example, assigning the
|
||||
* character code U+005A, LATIN CAPITAL LETTER Z, to a glyph depicting a
|
||||
* mathematical integral sign), the auto-hinter might produce useless
|
||||
* results.
|
||||
*
|
||||
*/
|
||||
#define FT_LOAD_DEFAULT 0x0
|
||||
#define FT_LOAD_NO_SCALE ( 1L << 0 )
|
||||
#define FT_LOAD_NO_HINTING ( 1L << 1 )
|
||||
#define FT_LOAD_RENDER ( 1L << 2 )
|
||||
#define FT_LOAD_NO_BITMAP ( 1L << 3 )
|
||||
#define FT_LOAD_VERTICAL_LAYOUT ( 1L << 4 )
|
||||
#define FT_LOAD_FORCE_AUTOHINT ( 1L << 5 )
|
||||
#define FT_LOAD_CROP_BITMAP ( 1L << 6 )
|
||||
#define FT_LOAD_PEDANTIC ( 1L << 7 )
|
||||
#define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ( 1L << 9 )
|
||||
#define FT_LOAD_NO_RECURSE ( 1L << 10 )
|
||||
#define FT_LOAD_IGNORE_TRANSFORM ( 1L << 11 )
|
||||
#define FT_LOAD_MONOCHROME ( 1L << 12 )
|
||||
#define FT_LOAD_LINEAR_DESIGN ( 1L << 13 )
|
||||
#define FT_LOAD_NO_AUTOHINT ( 1L << 15 )
|
||||
/* Bits 16-19 are used by `FT_LOAD_TARGET_' */
|
||||
#define FT_LOAD_COLOR ( 1L << 20 )
|
||||
#define FT_LOAD_COMPUTE_METRICS ( 1L << 21 )
|
||||
#define FT_LOAD_BITMAP_METRICS_ONLY ( 1L << 22 )
|
||||
|
||||
/* */
|
||||
|
||||
/* used internally only by certain font drivers */
|
||||
#define FT_LOAD_ADVANCE_ONLY ( 1L << 8 )
|
||||
#define FT_LOAD_SBITS_ONLY ( 1L << 14 )
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @enum:
|
||||
* FT_LOAD_TARGET_XXX
|
||||
*
|
||||
* @description:
|
||||
* A list of values to select a specific hinting algorithm for the
|
||||
* hinter. You should OR one of these values to your `load_flags'
|
||||
* when calling @FT_Load_Glyph.
|
||||
*
|
||||
* Note that a font's native hinters may ignore the hinting algorithm
|
||||
* you have specified (e.g., the TrueType bytecode interpreter). You
|
||||
* can set @FT_LOAD_FORCE_AUTOHINT to ensure that the auto-hinter is
|
||||
* used.
|
||||
*
|
||||
* @values:
|
||||
* FT_LOAD_TARGET_NORMAL ::
|
||||
* The default hinting algorithm, optimized for standard gray-level
|
||||
* rendering. For monochrome output, use @FT_LOAD_TARGET_MONO
|
||||
* instead.
|
||||
*
|
||||
* FT_LOAD_TARGET_LIGHT ::
|
||||
* A lighter hinting algorithm for gray-level modes. Many generated
|
||||
* glyphs are fuzzier but better resemble their original shape. This
|
||||
* is achieved by snapping glyphs to the pixel grid only vertically
|
||||
* (Y-axis), as is done by FreeType's new CFF engine or Microsoft's
|
||||
* ClearType font renderer. This preserves inter-glyph spacing in
|
||||
* horizontal text. The snapping is done either by the native font
|
||||
* driver, if the driver itself and the font support it, or by the
|
||||
* auto-hinter.
|
||||
*
|
||||
* Advance widths are rounded to integer values; however, using the
|
||||
* `lsb_delta' and `rsb_delta' fields of @FT_GlyphSlotRec, it is
|
||||
* possible to get fractional advance widths for subpixel positioning
|
||||
* (which is recommended to use).
|
||||
*
|
||||
* If configuration option AF_CONFIG_OPTION_TT_SIZE_METRICS is active,
|
||||
* TrueType-like metrics are used to make this mode behave similarly
|
||||
* as in unpatched FreeType versions between 2.4.6 and 2.7.1
|
||||
* (inclusive).
|
||||
*
|
||||
* FT_LOAD_TARGET_MONO ::
|
||||
* Strong hinting algorithm that should only be used for monochrome
|
||||
* output. The result is probably unpleasant if the glyph is rendered
|
||||
* in non-monochrome modes.
|
||||
*
|
||||
* FT_LOAD_TARGET_LCD ::
|
||||
* A variant of @FT_LOAD_TARGET_LIGHT optimized for horizontally
|
||||
* decimated LCD displays.
|
||||
*
|
||||
* FT_LOAD_TARGET_LCD_V ::
|
||||
* A variant of @FT_LOAD_TARGET_NORMAL optimized for vertically
|
||||
* decimated LCD displays.
|
||||
*
|
||||
* @note:
|
||||
* You should use only _one_ of the FT_LOAD_TARGET_XXX values in your
|
||||
* `load_flags'. They can't be ORed.
|
||||
*
|
||||
* If @FT_LOAD_RENDER is also set, the glyph is rendered in the
|
||||
* corresponding mode (i.e., the mode that matches the used algorithm
|
||||
* best). An exception is FT_LOAD_TARGET_MONO since it implies
|
||||
* @FT_LOAD_MONOCHROME.
|
||||
*
|
||||
* You can use a hinting algorithm that doesn't correspond to the same
|
||||
* rendering mode. As an example, it is possible to use the `light'
|
||||
* hinting algorithm and have the results rendered in horizontal LCD
|
||||
* pixel mode, with code like
|
||||
*
|
||||
* {
|
||||
* FT_Load_Glyph( face, glyph_index,
|
||||
* load_flags | FT_LOAD_TARGET_LIGHT );
|
||||
*
|
||||
* FT_Render_Glyph( face->glyph, FT_RENDER_MODE_LCD );
|
||||
* }
|
||||
*
|
||||
* In general, you should stick with one rendering mode. For example,
|
||||
* switching between @FT_LOAD_TARGET_NORMAL and @FT_LOAD_TARGET_MONO
|
||||
* enforces a lot of recomputation for TrueType fonts, which is slow.
|
||||
* Another reason is caching: Selecting a different mode usually causes
|
||||
* changes in both the outlines and the rasterized bitmaps; it is thus
|
||||
* necessary to empty the cache after a mode switch to avoid false hits.
|
||||
*
|
||||
*/
|
||||
#define FT_LOAD_TARGET_( x ) ( (FT_Int32)( (x) & 15 ) << 16 )
|
||||
|
||||
#define FT_LOAD_TARGET_NORMAL FT_LOAD_TARGET_( FT_RENDER_MODE_NORMAL )
|
||||
#define FT_LOAD_TARGET_LIGHT FT_LOAD_TARGET_( FT_RENDER_MODE_LIGHT )
|
||||
#define FT_LOAD_TARGET_MONO FT_LOAD_TARGET_( FT_RENDER_MODE_MONO )
|
||||
#define FT_LOAD_TARGET_LCD FT_LOAD_TARGET_( FT_RENDER_MODE_LCD )
|
||||
#define FT_LOAD_TARGET_LCD_V FT_LOAD_TARGET_( FT_RENDER_MODE_LCD_V )
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_LOAD_TARGET_MODE
|
||||
*
|
||||
* @description:
|
||||
* Return the @FT_Render_Mode corresponding to a given
|
||||
* @FT_LOAD_TARGET_XXX value.
|
||||
*
|
||||
*/
|
||||
#define FT_LOAD_TARGET_MODE( x ) ( (FT_Render_Mode)( ( (x) >> 16 ) & 15 ) )
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Set_Transform */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Set the transformation that is applied to glyph images when they */
|
||||
/* are loaded into a glyph slot through @FT_Load_Glyph. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* face :: A handle to the source face object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* matrix :: A pointer to the transformation's 2x2 matrix. Use NULL */
|
||||
/* for the identity matrix. */
|
||||
/* delta :: A pointer to the translation vector. Use NULL for the */
|
||||
/* null vector. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The transformation is only applied to scalable image formats after */
|
||||
/* the glyph has been loaded. It means that hinting is unaltered by */
|
||||
/* the transformation and is performed on the character size given in */
|
||||
/* the last call to @FT_Set_Char_Size or @FT_Set_Pixel_Sizes. */
|
||||
/* */
|
||||
/* Note that this also transforms the `face.glyph.advance' field, but */
|
||||
/* *not* the values in `face.glyph.metrics'. */
|
||||
/* */
|
||||
FT_EXPORT( void )
|
||||
FT_Set_Transform( FT_Face face,
|
||||
FT_Matrix* matrix,
|
||||
FT_Vector* delta );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Enum> */
|
||||
/* FT_Render_Mode */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Render modes supported by FreeType~2. Each mode corresponds to a */
|
||||
/* specific type of scanline conversion performed on the outline. */
|
||||
/* */
|
||||
/* For bitmap fonts and embedded bitmaps the `bitmap->pixel_mode' */
|
||||
/* field in the @FT_GlyphSlotRec structure gives the format of the */
|
||||
/* returned bitmap. */
|
||||
/* */
|
||||
/* All modes except @FT_RENDER_MODE_MONO use 256 levels of opacity, */
|
||||
/* indicating pixel coverage. Use linear alpha blending and gamma */
|
||||
/* correction to correctly render non-monochrome glyph bitmaps onto a */
|
||||
/* surface; see @FT_Render_Glyph. */
|
||||
/* */
|
||||
/* <Values> */
|
||||
/* FT_RENDER_MODE_NORMAL :: */
|
||||
/* Default render mode; it corresponds to 8-bit anti-aliased */
|
||||
/* bitmaps. */
|
||||
/* */
|
||||
/* FT_RENDER_MODE_LIGHT :: */
|
||||
/* This is equivalent to @FT_RENDER_MODE_NORMAL. It is only */
|
||||
/* defined as a separate value because render modes are also used */
|
||||
/* indirectly to define hinting algorithm selectors. See */
|
||||
/* @FT_LOAD_TARGET_XXX for details. */
|
||||
/* */
|
||||
/* FT_RENDER_MODE_MONO :: */
|
||||
/* This mode corresponds to 1-bit bitmaps (with 2~levels of */
|
||||
/* opacity). */
|
||||
/* */
|
||||
/* FT_RENDER_MODE_LCD :: */
|
||||
/* This mode corresponds to horizontal RGB and BGR subpixel */
|
||||
/* displays like LCD screens. It produces 8-bit bitmaps that are */
|
||||
/* 3~times the width of the original glyph outline in pixels, and */
|
||||
/* which use the @FT_PIXEL_MODE_LCD mode. */
|
||||
/* */
|
||||
/* FT_RENDER_MODE_LCD_V :: */
|
||||
/* This mode corresponds to vertical RGB and BGR subpixel displays */
|
||||
/* (like PDA screens, rotated LCD displays, etc.). It produces */
|
||||
/* 8-bit bitmaps that are 3~times the height of the original */
|
||||
/* glyph outline in pixels and use the @FT_PIXEL_MODE_LCD_V mode. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* Should you define FT_CONFIG_OPTION_SUBPIXEL_RENDERING in your */
|
||||
/* `ftoption.h', which enables patented ClearType-style rendering, */
|
||||
/* the LCD-optimized glyph bitmaps should be filtered to reduce color */
|
||||
/* fringes inherent to this technology. You can either set up LCD */
|
||||
/* filtering with @FT_Library_SetLcdFilter or @FT_Face_Properties, */
|
||||
/* or do the filtering yourself. The default FreeType LCD rendering */
|
||||
/* technology does not require filtering. */
|
||||
/* */
|
||||
/* The selected render mode only affects vector glyphs of a font. */
|
||||
/* Embedded bitmaps often have a different pixel mode like */
|
||||
/* @FT_PIXEL_MODE_MONO. You can use @FT_Bitmap_Convert to transform */
|
||||
/* them into 8-bit pixmaps. */
|
||||
/* */
|
||||
typedef enum FT_Render_Mode_
|
||||
{
|
||||
FT_RENDER_MODE_NORMAL = 0,
|
||||
FT_RENDER_MODE_LIGHT,
|
||||
FT_RENDER_MODE_MONO,
|
||||
FT_RENDER_MODE_LCD,
|
||||
FT_RENDER_MODE_LCD_V,
|
||||
|
||||
FT_RENDER_MODE_MAX
|
||||
|
||||
} FT_Render_Mode;
|
||||
|
||||
|
||||
/* these constants are deprecated; use the corresponding */
|
||||
/* `FT_Render_Mode' values instead */
|
||||
#define ft_render_mode_normal FT_RENDER_MODE_NORMAL
|
||||
#define ft_render_mode_mono FT_RENDER_MODE_MONO
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Render_Glyph */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Convert a given glyph image to a bitmap. It does so by inspecting */
|
||||
/* the glyph image format, finding the relevant renderer, and */
|
||||
/* invoking it. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* slot :: A handle to the glyph slot containing the image to */
|
||||
/* convert. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* render_mode :: The render mode used to render the glyph image into */
|
||||
/* a bitmap. See @FT_Render_Mode for a list of */
|
||||
/* possible values. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* To get meaningful results, font scaling values must be set with */
|
||||
/* functions like @FT_Set_Char_Size before calling `FT_Render_Glyph'. */
|
||||
/* */
|
||||
/* When FreeType outputs a bitmap of a glyph, it really outputs an */
|
||||
/* alpha coverage map. If a pixel is completely covered by a */
|
||||
/* filled-in outline, the bitmap contains 0xFF at that pixel, meaning */
|
||||
/* that 0xFF/0xFF fraction of that pixel is covered, meaning the */
|
||||
/* pixel is 100% black (or 0% bright). If a pixel is only 50% */
|
||||
/* covered (value 0x80), the pixel is made 50% black (50% bright or a */
|
||||
/* middle shade of grey). 0% covered means 0% black (100% bright or */
|
||||
/* white). */
|
||||
/* */
|
||||
/* On high-DPI screens like on smartphones and tablets, the pixels */
|
||||
/* are so small that their chance of being completely covered and */
|
||||
/* therefore completely black are fairly good. On the low-DPI */
|
||||
/* screens, however, the situation is different. The pixels are too */
|
||||
/* large for most of the details of a glyph and shades of gray are */
|
||||
/* the norm rather than the exception. */
|
||||
/* */
|
||||
/* This is relevant because all our screens have a second problem: */
|
||||
/* they are not linear. 1~+~1 is not~2. Twice the value does not */
|
||||
/* result in twice the brightness. When a pixel is only 50% covered, */
|
||||
/* the coverage map says 50% black, and this translates to a pixel */
|
||||
/* value of 128 when you use 8~bits per channel (0-255). However, */
|
||||
/* this does not translate to 50% brightness for that pixel on our */
|
||||
/* sRGB and gamma~2.2 screens. Due to their non-linearity, they */
|
||||
/* dwell longer in the darks and only a pixel value of about 186 */
|
||||
/* results in 50% brightness -- 128 ends up too dark on both bright */
|
||||
/* and dark backgrounds. The net result is that dark text looks */
|
||||
/* burnt-out, pixely and blotchy on bright background, bright text */
|
||||
/* too frail on dark backgrounds, and colored text on colored */
|
||||
/* background (for example, red on green) seems to have dark halos or */
|
||||
/* `dirt' around it. The situation is especially ugly for diagonal */
|
||||
/* stems like in `w' glyph shapes where the quality of FreeType's */
|
||||
/* anti-aliasing depends on the correct display of grays. On */
|
||||
/* high-DPI screens where smaller, fully black pixels reign supreme, */
|
||||
/* this doesn't matter, but on our low-DPI screens with all the gray */
|
||||
/* shades, it does. 0% and 100% brightness are the same things in */
|
||||
/* linear and non-linear space, just all the shades in-between */
|
||||
/* aren't. */
|
||||
/* */
|
||||
/* The blending function for placing text over a background is */
|
||||
/* */
|
||||
/* { */
|
||||
/* dst = alpha * src + (1 - alpha) * dst , */
|
||||
/* } */
|
||||
/* */
|
||||
/* which is known as the OVER operator. */
|
||||
/* */
|
||||
/* To correctly composite an antialiased pixel of a glyph onto a */
|
||||
/* surface, */
|
||||
/* */
|
||||
/* 1. take the foreground and background colors (e.g., in sRGB space) */
|
||||
/* and apply gamma to get them in a linear space, */
|
||||
/* */
|
||||
/* 2. use OVER to blend the two linear colors using the glyph pixel */
|
||||
/* as the alpha value (remember, the glyph bitmap is an alpha */
|
||||
/* coverage bitmap), and */
|
||||
/* */
|
||||
/* 3. apply inverse gamma to the blended pixel and write it back to */
|
||||
/* the image. */
|
||||
/* */
|
||||
/* Internal testing at Adobe found that a target inverse gamma of~1.8 */
|
||||
/* for step~3 gives good results across a wide range of displays with */
|
||||
/* an sRGB gamma curve or a similar one. */
|
||||
/* */
|
||||
/* This process can cost performance. There is an approximation that */
|
||||
/* does not need to know about the background color; see */
|
||||
/* https://bel.fi/alankila/lcd/ and */
|
||||
/* https://bel.fi/alankila/lcd/alpcor.html for details. */
|
||||
/* */
|
||||
/* *ATTENTION*: Linear blending is even more important when dealing */
|
||||
/* with subpixel-rendered glyphs to prevent color-fringing! A */
|
||||
/* subpixel-rendered glyph must first be filtered with a filter that */
|
||||
/* gives equal weight to the three color primaries and does not */
|
||||
/* exceed a sum of 0x100, see section @lcd_filtering. Then the */
|
||||
/* only difference to gray linear blending is that subpixel-rendered */
|
||||
/* linear blending is done 3~times per pixel: red foreground subpixel */
|
||||
/* to red background subpixel and so on for green and blue. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Render_Glyph( FT_GlyphSlot slot,
|
||||
FT_Render_Mode render_mode );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Enum> */
|
||||
/* FT_Kerning_Mode */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* An enumeration to specify the format of kerning values returned by */
|
||||
/* @FT_Get_Kerning. */
|
||||
/* */
|
||||
/* <Values> */
|
||||
/* FT_KERNING_DEFAULT :: Return grid-fitted kerning distances in */
|
||||
/* 26.6 fractional pixels. */
|
||||
/* */
|
||||
/* FT_KERNING_UNFITTED :: Return un-grid-fitted kerning distances in */
|
||||
/* 26.6 fractional pixels. */
|
||||
/* */
|
||||
/* FT_KERNING_UNSCALED :: Return the kerning vector in original font */
|
||||
/* units. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* FT_KERNING_DEFAULT returns full pixel values; it also makes */
|
||||
/* FreeType heuristically scale down kerning distances at small ppem */
|
||||
/* values so that they don't become too big. */
|
||||
/* */
|
||||
/* Both FT_KERNING_DEFAULT and FT_KERNING_UNFITTED use the current */
|
||||
/* horizontal scaling factor (as set e.g. with @FT_Set_Char_Size) to */
|
||||
/* convert font units to pixels. */
|
||||
/* */
|
||||
typedef enum FT_Kerning_Mode_
|
||||
{
|
||||
FT_KERNING_DEFAULT = 0,
|
||||
FT_KERNING_UNFITTED,
|
||||
FT_KERNING_UNSCALED
|
||||
|
||||
} FT_Kerning_Mode;
|
||||
|
||||
|
||||
/* these constants are deprecated; use the corresponding */
|
||||
/* `FT_Kerning_Mode' values instead */
|
||||
#define ft_kerning_default FT_KERNING_DEFAULT
|
||||
#define ft_kerning_unfitted FT_KERNING_UNFITTED
|
||||
#define ft_kerning_unscaled FT_KERNING_UNSCALED
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_Kerning */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Return the kerning vector between two glyphs of the same face. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to a source face object. */
|
||||
/* */
|
||||
/* left_glyph :: The index of the left glyph in the kern pair. */
|
||||
/* */
|
||||
/* right_glyph :: The index of the right glyph in the kern pair. */
|
||||
/* */
|
||||
/* kern_mode :: See @FT_Kerning_Mode for more information. */
|
||||
/* Determines the scale and dimension of the returned */
|
||||
/* kerning vector. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* akerning :: The kerning vector. This is either in font units, */
|
||||
/* fractional pixels (26.6 format), or pixels for */
|
||||
/* scalable formats, and in pixels for fixed-sizes */
|
||||
/* formats. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* Only horizontal layouts (left-to-right & right-to-left) are */
|
||||
/* supported by this method. Other layouts, or more sophisticated */
|
||||
/* kernings, are out of the scope of this API function -- they can be */
|
||||
/* implemented through format-specific interfaces. */
|
||||
/* */
|
||||
/* Kerning for OpenType fonts implemented in a `GPOS' table is not */
|
||||
/* supported; use @FT_HAS_KERNING to find out whether a font has data */
|
||||
/* that can be extracted with `FT_Get_Kerning'. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Get_Kerning( FT_Face face,
|
||||
FT_UInt left_glyph,
|
||||
FT_UInt right_glyph,
|
||||
FT_UInt kern_mode,
|
||||
FT_Vector *akerning );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_Track_Kerning */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Return the track kerning for a given face object at a given size. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to a source face object. */
|
||||
/* */
|
||||
/* point_size :: The point size in 16.16 fractional points. */
|
||||
/* */
|
||||
/* degree :: The degree of tightness. Increasingly negative */
|
||||
/* values represent tighter track kerning, while */
|
||||
/* increasingly positive values represent looser track */
|
||||
/* kerning. Value zero means no track kerning. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* akerning :: The kerning in 16.16 fractional points, to be */
|
||||
/* uniformly applied between all glyphs. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* Currently, only the Type~1 font driver supports track kerning, */
|
||||
/* using data from AFM files (if attached with @FT_Attach_File or */
|
||||
/* @FT_Attach_Stream). */
|
||||
/* */
|
||||
/* Only very few AFM files come with track kerning data; please refer */
|
||||
/* to Adobe's AFM specification for more details. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Get_Track_Kerning( FT_Face face,
|
||||
FT_Fixed point_size,
|
||||
FT_Int degree,
|
||||
FT_Fixed* akerning );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_Glyph_Name */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Retrieve the ASCII name of a given glyph in a face. This only */
|
||||
/* works for those faces where @FT_HAS_GLYPH_NAMES(face) returns~1. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to a source face object. */
|
||||
/* */
|
||||
/* glyph_index :: The glyph index. */
|
||||
/* */
|
||||
/* buffer_max :: The maximum number of bytes available in the */
|
||||
/* buffer. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* buffer :: A pointer to a target buffer where the name is */
|
||||
/* copied to. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* An error is returned if the face doesn't provide glyph names or if */
|
||||
/* the glyph index is invalid. In all cases of failure, the first */
|
||||
/* byte of `buffer' is set to~0 to indicate an empty name. */
|
||||
/* */
|
||||
/* The glyph name is truncated to fit within the buffer if it is too */
|
||||
/* long. The returned string is always zero-terminated. */
|
||||
/* */
|
||||
/* Be aware that FreeType reorders glyph indices internally so that */
|
||||
/* glyph index~0 always corresponds to the `missing glyph' (called */
|
||||
/* `.notdef'). */
|
||||
/* */
|
||||
/* This function always returns an error if the config macro */
|
||||
/* `FT_CONFIG_OPTION_NO_GLYPH_NAMES' is not defined in `ftoption.h'. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Get_Glyph_Name( FT_Face face,
|
||||
FT_UInt glyph_index,
|
||||
FT_Pointer buffer,
|
||||
FT_UInt buffer_max );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_Postscript_Name */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Retrieve the ASCII PostScript name of a given face, if available. */
|
||||
/* This only works with PostScript, TrueType, and OpenType fonts. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the source face object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* A pointer to the face's PostScript name. NULL if unavailable. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The returned pointer is owned by the face and is destroyed with */
|
||||
/* it. */
|
||||
/* */
|
||||
/* For variation fonts, this string changes if you select a different */
|
||||
/* instance, and you have to call `FT_Get_PostScript_Name' again to */
|
||||
/* retrieve it. FreeType follows Adobe TechNote #5902, `Generating */
|
||||
/* PostScript Names for Fonts Using OpenType Font Variations'. */
|
||||
/* */
|
||||
/* https://download.macromedia.com/pub/developer/opentype/tech-notes/5902.AdobePSNameGeneration.html */
|
||||
/* */
|
||||
/* [Since 2.9] Special PostScript names for named instances are only */
|
||||
/* returned if the named instance is set with @FT_Set_Named_Instance */
|
||||
/* (and the font has corresponding entries in its `fvar' table). If */
|
||||
/* @FT_IS_VARIATION returns true, the algorithmically derived */
|
||||
/* PostScript name is provided, not looking up special entries for */
|
||||
/* named instances. */
|
||||
/* */
|
||||
FT_EXPORT( const char* )
|
||||
FT_Get_Postscript_Name( FT_Face face );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Select_Charmap */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Select a given charmap by its encoding tag (as listed in */
|
||||
/* `freetype.h'). */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* face :: A handle to the source face object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* encoding :: A handle to the selected encoding. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This function returns an error if no charmap in the face */
|
||||
/* corresponds to the encoding queried here. */
|
||||
/* */
|
||||
/* Because many fonts contain more than a single cmap for Unicode */
|
||||
/* encoding, this function has some special code to select the one */
|
||||
/* that covers Unicode best (`best' in the sense that a UCS-4 cmap is */
|
||||
/* preferred to a UCS-2 cmap). It is thus preferable to */
|
||||
/* @FT_Set_Charmap in this case. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Select_Charmap( FT_Face face,
|
||||
FT_Encoding encoding );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Set_Charmap */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Select a given charmap for character code to glyph index mapping. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* face :: A handle to the source face object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* charmap :: A handle to the selected charmap. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This function returns an error if the charmap is not part of */
|
||||
/* the face (i.e., if it is not listed in the `face->charmaps' */
|
||||
/* table). */
|
||||
/* */
|
||||
/* It also fails if an OpenType type~14 charmap is selected (which */
|
||||
/* doesn't map character codes to glyph indices at all). */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Set_Charmap( FT_Face face,
|
||||
FT_CharMap charmap );
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Get_Charmap_Index
|
||||
*
|
||||
* @description:
|
||||
* Retrieve index of a given charmap.
|
||||
*
|
||||
* @input:
|
||||
* charmap ::
|
||||
* A handle to a charmap.
|
||||
*
|
||||
* @return:
|
||||
* The index into the array of character maps within the face to which
|
||||
* `charmap' belongs. If an error occurs, -1 is returned.
|
||||
*
|
||||
*/
|
||||
FT_EXPORT( FT_Int )
|
||||
FT_Get_Charmap_Index( FT_CharMap charmap );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_Char_Index */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Return the glyph index of a given character code. This function */
|
||||
/* uses the currently selected charmap to do the mapping. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the source face object. */
|
||||
/* */
|
||||
/* charcode :: The character code. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The glyph index. 0~means `undefined character code'. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* If you use FreeType to manipulate the contents of font files */
|
||||
/* directly, be aware that the glyph index returned by this function */
|
||||
/* doesn't always correspond to the internal indices used within the */
|
||||
/* file. This is done to ensure that value~0 always corresponds to */
|
||||
/* the `missing glyph'. If the first glyph is not named `.notdef', */
|
||||
/* then for Type~1 and Type~42 fonts, `.notdef' will be moved into */
|
||||
/* the glyph ID~0 position, and whatever was there will be moved to */
|
||||
/* the position `.notdef' had. For Type~1 fonts, if there is no */
|
||||
/* `.notdef' glyph at all, then one will be created at index~0 and */
|
||||
/* whatever was there will be moved to the last index -- Type~42 */
|
||||
/* fonts are considered invalid under this condition. */
|
||||
/* */
|
||||
FT_EXPORT( FT_UInt )
|
||||
FT_Get_Char_Index( FT_Face face,
|
||||
FT_ULong charcode );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_First_Char */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Return the first character code in the current charmap of a given */
|
||||
/* face, together with its corresponding glyph index. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the source face object. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* agindex :: Glyph index of first character code. 0~if charmap is */
|
||||
/* empty. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The charmap's first character code. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* You should use this function together with @FT_Get_Next_Char to */
|
||||
/* parse all character codes available in a given charmap. The code */
|
||||
/* should look like this: */
|
||||
/* */
|
||||
/* { */
|
||||
/* FT_ULong charcode; */
|
||||
/* FT_UInt gindex; */
|
||||
/* */
|
||||
/* */
|
||||
/* charcode = FT_Get_First_Char( face, &gindex ); */
|
||||
/* while ( gindex != 0 ) */
|
||||
/* { */
|
||||
/* ... do something with (charcode,gindex) pair ... */
|
||||
/* */
|
||||
/* charcode = FT_Get_Next_Char( face, charcode, &gindex ); */
|
||||
/* } */
|
||||
/* } */
|
||||
/* */
|
||||
/* Be aware that character codes can have values up to 0xFFFFFFFF; */
|
||||
/* this might happen for non-Unicode or malformed cmaps. However, */
|
||||
/* even with regular Unicode encoding, so-called `last resort fonts' */
|
||||
/* (using SFNT cmap format 13, see function @FT_Get_CMap_Format) */
|
||||
/* normally have entries for all Unicode characters up to 0x1FFFFF, */
|
||||
/* which can cause *a lot* of iterations. */
|
||||
/* */
|
||||
/* Note that `*agindex' is set to~0 if the charmap is empty. The */
|
||||
/* result itself can be~0 in two cases: if the charmap is empty or */
|
||||
/* if the value~0 is the first valid character code. */
|
||||
/* */
|
||||
FT_EXPORT( FT_ULong )
|
||||
FT_Get_First_Char( FT_Face face,
|
||||
FT_UInt *agindex );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_Next_Char */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Return the next character code in the current charmap of a given */
|
||||
/* face following the value `char_code', as well as the corresponding */
|
||||
/* glyph index. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the source face object. */
|
||||
/* */
|
||||
/* char_code :: The starting character code. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* agindex :: Glyph index of next character code. 0~if charmap */
|
||||
/* is empty. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The charmap's next character code. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* You should use this function with @FT_Get_First_Char to walk */
|
||||
/* over all character codes available in a given charmap. See the */
|
||||
/* note for that function for a simple code example. */
|
||||
/* */
|
||||
/* Note that `*agindex' is set to~0 when there are no more codes in */
|
||||
/* the charmap. */
|
||||
/* */
|
||||
FT_EXPORT( FT_ULong )
|
||||
FT_Get_Next_Char( FT_Face face,
|
||||
FT_ULong char_code,
|
||||
FT_UInt *agindex );
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Face_Properties
|
||||
*
|
||||
* @description:
|
||||
* Set or override certain (library or module-wide) properties on a
|
||||
* face-by-face basis. Useful for finer-grained control and avoiding
|
||||
* locks on shared structures (threads can modify their own faces as
|
||||
* they see fit).
|
||||
*
|
||||
* Contrary to @FT_Property_Set, this function uses @FT_Parameter so
|
||||
* that you can pass multiple properties to the target face in one call.
|
||||
* Note that only a subset of the available properties can be
|
||||
* controlled.
|
||||
*
|
||||
* * @FT_PARAM_TAG_STEM_DARKENING (stem darkening, corresponding to the
|
||||
* property `no-stem-darkening' provided by the `autofit', `cff',
|
||||
* `type1', and `t1cid' modules; see @no-stem-darkening).
|
||||
*
|
||||
* * @FT_PARAM_TAG_LCD_FILTER_WEIGHTS (LCD filter weights, corresponding
|
||||
* to function @FT_Library_SetLcdFilterWeights).
|
||||
*
|
||||
* * @FT_PARAM_TAG_RANDOM_SEED (seed value for the CFF, Type~1, and CID
|
||||
* `random' operator, corresponding to the `random-seed' property
|
||||
* provided by the `cff', `type1', and `t1cid' modules; see
|
||||
* @random-seed).
|
||||
*
|
||||
* Pass NULL as `data' in @FT_Parameter for a given tag to reset the
|
||||
* option and use the library or module default again.
|
||||
*
|
||||
* @input:
|
||||
* face ::
|
||||
* A handle to the source face object.
|
||||
*
|
||||
* num_properties ::
|
||||
* The number of properties that follow.
|
||||
*
|
||||
* properties ::
|
||||
* A handle to an @FT_Parameter array with `num_properties' elements.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* Here an example that sets three properties. You must define
|
||||
* FT_CONFIG_OPTION_SUBPIXEL_RENDERING to make the LCD filter examples
|
||||
* work.
|
||||
*
|
||||
* {
|
||||
* FT_Parameter property1;
|
||||
* FT_Bool darken_stems = 1;
|
||||
*
|
||||
* FT_Parameter property2;
|
||||
* FT_LcdFiveTapFilter custom_weight =
|
||||
* { 0x11, 0x44, 0x56, 0x44, 0x11 };
|
||||
*
|
||||
* FT_Parameter property3;
|
||||
* FT_Int32 random_seed = 314159265;
|
||||
*
|
||||
* FT_Parameter properties[3] = { property1,
|
||||
* property2,
|
||||
* property3 };
|
||||
*
|
||||
*
|
||||
* property1.tag = FT_PARAM_TAG_STEM_DARKENING;
|
||||
* property1.data = &darken_stems;
|
||||
*
|
||||
* property2.tag = FT_PARAM_TAG_LCD_FILTER_WEIGHTS;
|
||||
* property2.data = custom_weight;
|
||||
*
|
||||
* property3.tag = FT_PARAM_TAG_RANDOM_SEED;
|
||||
* property3.data = &random_seed;
|
||||
*
|
||||
* FT_Face_Properties( face, 3, properties );
|
||||
* }
|
||||
*
|
||||
* The next example resets a single property to its default value.
|
||||
*
|
||||
* {
|
||||
* FT_Parameter property;
|
||||
*
|
||||
*
|
||||
* property.tag = FT_PARAM_TAG_LCD_FILTER_WEIGHTS;
|
||||
* property.data = NULL;
|
||||
*
|
||||
* FT_Face_Properties( face, 1, &property );
|
||||
* }
|
||||
*
|
||||
* @since:
|
||||
* 2.8
|
||||
*
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Face_Properties( FT_Face face,
|
||||
FT_UInt num_properties,
|
||||
FT_Parameter* properties );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_Name_Index */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Return the glyph index of a given glyph name. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the source face object. */
|
||||
/* */
|
||||
/* glyph_name :: The glyph name. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The glyph index. 0~means `undefined character code'. */
|
||||
/* */
|
||||
FT_EXPORT( FT_UInt )
|
||||
FT_Get_Name_Index( FT_Face face,
|
||||
FT_String* glyph_name );
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_SUBGLYPH_FLAG_XXX
|
||||
*
|
||||
* @description:
|
||||
* A list of constants describing subglyphs. Please refer to the
|
||||
* `glyf' table description in the OpenType specification for the
|
||||
* meaning of the various flags (which get synthesized for
|
||||
* non-OpenType subglyphs).
|
||||
*
|
||||
* @values:
|
||||
* FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS ::
|
||||
* FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES ::
|
||||
* FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID ::
|
||||
* FT_SUBGLYPH_FLAG_SCALE ::
|
||||
* FT_SUBGLYPH_FLAG_XY_SCALE ::
|
||||
* FT_SUBGLYPH_FLAG_2X2 ::
|
||||
* FT_SUBGLYPH_FLAG_USE_MY_METRICS ::
|
||||
*
|
||||
*/
|
||||
#define FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS 1
|
||||
#define FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES 2
|
||||
#define FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID 4
|
||||
#define FT_SUBGLYPH_FLAG_SCALE 8
|
||||
#define FT_SUBGLYPH_FLAG_XY_SCALE 0x40
|
||||
#define FT_SUBGLYPH_FLAG_2X2 0x80
|
||||
#define FT_SUBGLYPH_FLAG_USE_MY_METRICS 0x200
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @func:
|
||||
* FT_Get_SubGlyph_Info
|
||||
*
|
||||
* @description:
|
||||
* Retrieve a description of a given subglyph. Only use it if
|
||||
* `glyph->format' is @FT_GLYPH_FORMAT_COMPOSITE; an error is
|
||||
* returned otherwise.
|
||||
*
|
||||
* @input:
|
||||
* glyph ::
|
||||
* The source glyph slot.
|
||||
*
|
||||
* sub_index ::
|
||||
* The index of the subglyph. Must be less than
|
||||
* `glyph->num_subglyphs'.
|
||||
*
|
||||
* @output:
|
||||
* p_index ::
|
||||
* The glyph index of the subglyph.
|
||||
*
|
||||
* p_flags ::
|
||||
* The subglyph flags, see @FT_SUBGLYPH_FLAG_XXX.
|
||||
*
|
||||
* p_arg1 ::
|
||||
* The subglyph's first argument (if any).
|
||||
*
|
||||
* p_arg2 ::
|
||||
* The subglyph's second argument (if any).
|
||||
*
|
||||
* p_transform ::
|
||||
* The subglyph transformation (if any).
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* The values of `*p_arg1', `*p_arg2', and `*p_transform' must be
|
||||
* interpreted depending on the flags returned in `*p_flags'. See the
|
||||
* OpenType specification for details.
|
||||
*
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Get_SubGlyph_Info( FT_GlyphSlot glyph,
|
||||
FT_UInt sub_index,
|
||||
FT_Int *p_index,
|
||||
FT_UInt *p_flags,
|
||||
FT_Int *p_arg1,
|
||||
FT_Int *p_arg2,
|
||||
FT_Matrix *p_transform );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Enum> */
|
||||
/* FT_FSTYPE_XXX */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A list of bit flags used in the `fsType' field of the OS/2 table */
|
||||
/* in a TrueType or OpenType font and the `FSType' entry in a */
|
||||
/* PostScript font. These bit flags are returned by */
|
||||
/* @FT_Get_FSType_Flags; they inform client applications of embedding */
|
||||
/* and subsetting restrictions associated with a font. */
|
||||
/* */
|
||||
/* See */
|
||||
/* https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/FontPolicies.pdf */
|
||||
/* for more details. */
|
||||
/* */
|
||||
/* <Values> */
|
||||
/* FT_FSTYPE_INSTALLABLE_EMBEDDING :: */
|
||||
/* Fonts with no fsType bit set may be embedded and permanently */
|
||||
/* installed on the remote system by an application. */
|
||||
/* */
|
||||
/* FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING :: */
|
||||
/* Fonts that have only this bit set must not be modified, embedded */
|
||||
/* or exchanged in any manner without first obtaining permission of */
|
||||
/* the font software copyright owner. */
|
||||
/* */
|
||||
/* FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING :: */
|
||||
/* The font may be embedded and temporarily loaded on the remote */
|
||||
/* system. Documents containing Preview & Print fonts must be */
|
||||
/* opened `read-only'; no edits can be applied to the document. */
|
||||
/* */
|
||||
/* FT_FSTYPE_EDITABLE_EMBEDDING :: */
|
||||
/* The font may be embedded but must only be installed temporarily */
|
||||
/* on other systems. In contrast to Preview & Print fonts, */
|
||||
/* documents containing editable fonts may be opened for reading, */
|
||||
/* editing is permitted, and changes may be saved. */
|
||||
/* */
|
||||
/* FT_FSTYPE_NO_SUBSETTING :: */
|
||||
/* The font may not be subsetted prior to embedding. */
|
||||
/* */
|
||||
/* FT_FSTYPE_BITMAP_EMBEDDING_ONLY :: */
|
||||
/* Only bitmaps contained in the font may be embedded; no outline */
|
||||
/* data may be embedded. If there are no bitmaps available in the */
|
||||
/* font, then the font is unembeddable. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The flags are ORed together, thus more than a single value can be */
|
||||
/* returned. */
|
||||
/* */
|
||||
/* While the `fsType' flags can indicate that a font may be embedded, */
|
||||
/* a license with the font vendor may be separately required to use */
|
||||
/* the font in this way. */
|
||||
/* */
|
||||
#define FT_FSTYPE_INSTALLABLE_EMBEDDING 0x0000
|
||||
#define FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING 0x0002
|
||||
#define FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING 0x0004
|
||||
#define FT_FSTYPE_EDITABLE_EMBEDDING 0x0008
|
||||
#define FT_FSTYPE_NO_SUBSETTING 0x0100
|
||||
#define FT_FSTYPE_BITMAP_EMBEDDING_ONLY 0x0200
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_FSType_Flags */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Return the `fsType' flags for a font. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the source face object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The `fsType' flags, see @FT_FSTYPE_XXX. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* Use this function rather than directly reading the `fs_type' field */
|
||||
/* in the @PS_FontInfoRec structure, which is only guaranteed to */
|
||||
/* return the correct results for Type~1 fonts. */
|
||||
/* */
|
||||
/* <Since> */
|
||||
/* 2.3.8 */
|
||||
/* */
|
||||
FT_EXPORT( FT_UShort )
|
||||
FT_Get_FSType_Flags( FT_Face face );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* glyph_variants */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* Unicode Variation Sequences */
|
||||
/* */
|
||||
/* <Abstract> */
|
||||
/* The FreeType~2 interface to Unicode Variation Sequences (UVS), */
|
||||
/* using the SFNT cmap format~14. */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Many characters, especially for CJK scripts, have variant forms. */
|
||||
/* They are a sort of grey area somewhere between being totally */
|
||||
/* irrelevant and semantically distinct; for this reason, the Unicode */
|
||||
/* consortium decided to introduce Variation Sequences (VS), */
|
||||
/* consisting of a Unicode base character and a variation selector */
|
||||
/* instead of further extending the already huge number of */
|
||||
/* characters. */
|
||||
/* */
|
||||
/* Unicode maintains two different sets, namely `Standardized */
|
||||
/* Variation Sequences' and registered `Ideographic Variation */
|
||||
/* Sequences' (IVS), collected in the `Ideographic Variation */
|
||||
/* Database' (IVD). */
|
||||
/* */
|
||||
/* https://unicode.org/Public/UCD/latest/ucd/StandardizedVariants.txt */
|
||||
/* https://unicode.org/reports/tr37/ */
|
||||
/* https://unicode.org/ivd/ */
|
||||
/* */
|
||||
/* To date (January 2017), the character with the most ideographic */
|
||||
/* variations is U+9089, having 32 such IVS. */
|
||||
/* */
|
||||
/* Three Mongolian Variation Selectors have the values U+180B-U+180D; */
|
||||
/* 256 generic Variation Selectors are encoded in the ranges */
|
||||
/* U+FE00-U+FE0F and U+E0100-U+E01EF. IVS currently use Variation */
|
||||
/* Selectors from the range U+E0100-U+E01EF only. */
|
||||
/* */
|
||||
/* A VS consists of the base character value followed by a single */
|
||||
/* Variation Selector. For example, to get the first variation of */
|
||||
/* U+9089, you have to write the character sequence `U+9089 U+E0100'. */
|
||||
/* */
|
||||
/* Adobe and MS decided to support both standardized and ideographic */
|
||||
/* VS with a new cmap subtable (format~14). It is an odd subtable */
|
||||
/* because it is not a mapping of input code points to glyphs, but */
|
||||
/* contains lists of all variations supported by the font. */
|
||||
/* */
|
||||
/* A variation may be either `default' or `non-default' for a given */
|
||||
/* font. A default variation is the one you will get for that code */
|
||||
/* point if you look it up in the standard Unicode cmap. A */
|
||||
/* non-default variation is a different glyph. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Face_GetCharVariantIndex */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Return the glyph index of a given character code as modified by */
|
||||
/* the variation selector. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: */
|
||||
/* A handle to the source face object. */
|
||||
/* */
|
||||
/* charcode :: */
|
||||
/* The character code point in Unicode. */
|
||||
/* */
|
||||
/* variantSelector :: */
|
||||
/* The Unicode code point of the variation selector. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The glyph index. 0~means either `undefined character code', or */
|
||||
/* `undefined selector code', or `no variation selector cmap */
|
||||
/* subtable', or `current CharMap is not Unicode'. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* If you use FreeType to manipulate the contents of font files */
|
||||
/* directly, be aware that the glyph index returned by this function */
|
||||
/* doesn't always correspond to the internal indices used within */
|
||||
/* the file. This is done to ensure that value~0 always corresponds */
|
||||
/* to the `missing glyph'. */
|
||||
/* */
|
||||
/* This function is only meaningful if */
|
||||
/* a) the font has a variation selector cmap sub table, */
|
||||
/* and */
|
||||
/* b) the current charmap has a Unicode encoding. */
|
||||
/* */
|
||||
/* <Since> */
|
||||
/* 2.3.6 */
|
||||
/* */
|
||||
FT_EXPORT( FT_UInt )
|
||||
FT_Face_GetCharVariantIndex( FT_Face face,
|
||||
FT_ULong charcode,
|
||||
FT_ULong variantSelector );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Face_GetCharVariantIsDefault */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Check whether this variation of this Unicode character is the one */
|
||||
/* to be found in the `cmap'. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: */
|
||||
/* A handle to the source face object. */
|
||||
/* */
|
||||
/* charcode :: */
|
||||
/* The character codepoint in Unicode. */
|
||||
/* */
|
||||
/* variantSelector :: */
|
||||
/* The Unicode codepoint of the variation selector. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* 1~if found in the standard (Unicode) cmap, 0~if found in the */
|
||||
/* variation selector cmap, or -1 if it is not a variation. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This function is only meaningful if the font has a variation */
|
||||
/* selector cmap subtable. */
|
||||
/* */
|
||||
/* <Since> */
|
||||
/* 2.3.6 */
|
||||
/* */
|
||||
FT_EXPORT( FT_Int )
|
||||
FT_Face_GetCharVariantIsDefault( FT_Face face,
|
||||
FT_ULong charcode,
|
||||
FT_ULong variantSelector );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Face_GetVariantSelectors */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Return a zero-terminated list of Unicode variation selectors found */
|
||||
/* in the font. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: */
|
||||
/* A handle to the source face object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* A pointer to an array of selector code points, or NULL if there is */
|
||||
/* no valid variation selector cmap subtable. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The last item in the array is~0; the array is owned by the */
|
||||
/* @FT_Face object but can be overwritten or released on the next */
|
||||
/* call to a FreeType function. */
|
||||
/* */
|
||||
/* <Since> */
|
||||
/* 2.3.6 */
|
||||
/* */
|
||||
FT_EXPORT( FT_UInt32* )
|
||||
FT_Face_GetVariantSelectors( FT_Face face );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Face_GetVariantsOfChar */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Return a zero-terminated list of Unicode variation selectors found */
|
||||
/* for the specified character code. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: */
|
||||
/* A handle to the source face object. */
|
||||
/* */
|
||||
/* charcode :: */
|
||||
/* The character codepoint in Unicode. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* A pointer to an array of variation selector code points that are */
|
||||
/* active for the given character, or NULL if the corresponding list */
|
||||
/* is empty. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The last item in the array is~0; the array is owned by the */
|
||||
/* @FT_Face object but can be overwritten or released on the next */
|
||||
/* call to a FreeType function. */
|
||||
/* */
|
||||
/* <Since> */
|
||||
/* 2.3.6 */
|
||||
/* */
|
||||
FT_EXPORT( FT_UInt32* )
|
||||
FT_Face_GetVariantsOfChar( FT_Face face,
|
||||
FT_ULong charcode );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Face_GetCharsOfVariant */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Return a zero-terminated list of Unicode character codes found for */
|
||||
/* the specified variation selector. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: */
|
||||
/* A handle to the source face object. */
|
||||
/* */
|
||||
/* variantSelector :: */
|
||||
/* The variation selector code point in Unicode. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* A list of all the code points that are specified by this selector */
|
||||
/* (both default and non-default codes are returned) or NULL if there */
|
||||
/* is no valid cmap or the variation selector is invalid. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The last item in the array is~0; the array is owned by the */
|
||||
/* @FT_Face object but can be overwritten or released on the next */
|
||||
/* call to a FreeType function. */
|
||||
/* */
|
||||
/* <Since> */
|
||||
/* 2.3.6 */
|
||||
/* */
|
||||
FT_EXPORT( FT_UInt32* )
|
||||
FT_Face_GetCharsOfVariant( FT_Face face,
|
||||
FT_ULong variantSelector );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* computations */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* Computations */
|
||||
/* */
|
||||
/* <Abstract> */
|
||||
/* Crunching fixed numbers and vectors. */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This section contains various functions used to perform */
|
||||
/* computations on 16.16 fixed-float numbers or 2d vectors. */
|
||||
/* */
|
||||
/* <Order> */
|
||||
/* FT_MulDiv */
|
||||
/* FT_MulFix */
|
||||
/* FT_DivFix */
|
||||
/* FT_RoundFix */
|
||||
/* FT_CeilFix */
|
||||
/* FT_FloorFix */
|
||||
/* FT_Vector_Transform */
|
||||
/* FT_Matrix_Multiply */
|
||||
/* FT_Matrix_Invert */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_MulDiv */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Compute `(a*b)/c' with maximum accuracy, using a 64-bit */
|
||||
/* intermediate integer whenever necessary. */
|
||||
/* */
|
||||
/* This function isn't necessarily as fast as some processor specific */
|
||||
/* operations, but is at least completely portable. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* a :: The first multiplier. */
|
||||
/* */
|
||||
/* b :: The second multiplier. */
|
||||
/* */
|
||||
/* c :: The divisor. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The result of `(a*b)/c'. This function never traps when trying to */
|
||||
/* divide by zero; it simply returns `MaxInt' or `MinInt' depending */
|
||||
/* on the signs of `a' and `b'. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Long )
|
||||
FT_MulDiv( FT_Long a,
|
||||
FT_Long b,
|
||||
FT_Long c );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_MulFix */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Compute `(a*b)/0x10000' with maximum accuracy. Its main use is to */
|
||||
/* multiply a given value by a 16.16 fixed-point factor. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* a :: The first multiplier. */
|
||||
/* */
|
||||
/* b :: The second multiplier. Use a 16.16 factor here whenever */
|
||||
/* possible (see note below). */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The result of `(a*b)/0x10000'. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This function has been optimized for the case where the absolute */
|
||||
/* value of `a' is less than 2048, and `b' is a 16.16 scaling factor. */
|
||||
/* As this happens mainly when scaling from notional units to */
|
||||
/* fractional pixels in FreeType, it resulted in noticeable speed */
|
||||
/* improvements between versions 2.x and 1.x. */
|
||||
/* */
|
||||
/* As a conclusion, always try to place a 16.16 factor as the */
|
||||
/* _second_ argument of this function; this can make a great */
|
||||
/* difference. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Long )
|
||||
FT_MulFix( FT_Long a,
|
||||
FT_Long b );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_DivFix */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Compute `(a*0x10000)/b' with maximum accuracy. Its main use is to */
|
||||
/* divide a given value by a 16.16 fixed-point factor. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* a :: The numerator. */
|
||||
/* */
|
||||
/* b :: The denominator. Use a 16.16 factor here. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The result of `(a*0x10000)/b'. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Long )
|
||||
FT_DivFix( FT_Long a,
|
||||
FT_Long b );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_RoundFix */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Round a 16.16 fixed number. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* a :: The number to be rounded. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* `a' rounded to the nearest 16.16 fixed integer, halfway cases away */
|
||||
/* from zero. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The function uses wrap-around arithmetic. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Fixed )
|
||||
FT_RoundFix( FT_Fixed a );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_CeilFix */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Compute the smallest following integer of a 16.16 fixed number. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* a :: The number for which the ceiling function is to be computed. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* `a' rounded towards plus infinity. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The function uses wrap-around arithmetic. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Fixed )
|
||||
FT_CeilFix( FT_Fixed a );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_FloorFix */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Compute the largest previous integer of a 16.16 fixed number. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* a :: The number for which the floor function is to be computed. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* `a' rounded towards minus infinity. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Fixed )
|
||||
FT_FloorFix( FT_Fixed a );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Vector_Transform */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Transform a single vector through a 2x2 matrix. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* vector :: The target vector to transform. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* matrix :: A pointer to the source 2x2 matrix. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The result is undefined if either `vector' or `matrix' is invalid. */
|
||||
/* */
|
||||
FT_EXPORT( void )
|
||||
FT_Vector_Transform( FT_Vector* vec,
|
||||
const FT_Matrix* matrix );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* version */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* FreeType Version */
|
||||
/* */
|
||||
/* <Abstract> */
|
||||
/* Functions and macros related to FreeType versions. */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Note that those functions and macros are of limited use because */
|
||||
/* even a new release of FreeType with only documentation changes */
|
||||
/* increases the version number. */
|
||||
/* */
|
||||
/* <Order> */
|
||||
/* FT_Library_Version */
|
||||
/* */
|
||||
/* FREETYPE_MAJOR */
|
||||
/* FREETYPE_MINOR */
|
||||
/* FREETYPE_PATCH */
|
||||
/* */
|
||||
/* FT_Face_CheckTrueTypePatents */
|
||||
/* FT_Face_SetUnpatentedHinting */
|
||||
/* */
|
||||
/* FREETYPE_XXX */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @enum:
|
||||
* FREETYPE_XXX
|
||||
*
|
||||
* @description:
|
||||
* These three macros identify the FreeType source code version.
|
||||
* Use @FT_Library_Version to access them at runtime.
|
||||
*
|
||||
* @values:
|
||||
* FREETYPE_MAJOR :: The major version number.
|
||||
* FREETYPE_MINOR :: The minor version number.
|
||||
* FREETYPE_PATCH :: The patch level.
|
||||
*
|
||||
* @note:
|
||||
* The version number of FreeType if built as a dynamic link library
|
||||
* with the `libtool' package is _not_ controlled by these three
|
||||
* macros.
|
||||
*
|
||||
*/
|
||||
#define FREETYPE_MAJOR 2
|
||||
#define FREETYPE_MINOR 9
|
||||
#define FREETYPE_PATCH 1
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Library_Version */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Return the version of the FreeType library being used. This is */
|
||||
/* useful when dynamically linking to the library, since one cannot */
|
||||
/* use the macros @FREETYPE_MAJOR, @FREETYPE_MINOR, and */
|
||||
/* @FREETYPE_PATCH. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A source library handle. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* amajor :: The major version number. */
|
||||
/* */
|
||||
/* aminor :: The minor version number. */
|
||||
/* */
|
||||
/* apatch :: The patch version number. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The reason why this function takes a `library' argument is because */
|
||||
/* certain programs implement library initialization in a custom way */
|
||||
/* that doesn't use @FT_Init_FreeType. */
|
||||
/* */
|
||||
/* In such cases, the library version might not be available before */
|
||||
/* the library object has been created. */
|
||||
/* */
|
||||
FT_EXPORT( void )
|
||||
FT_Library_Version( FT_Library library,
|
||||
FT_Int *amajor,
|
||||
FT_Int *aminor,
|
||||
FT_Int *apatch );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Face_CheckTrueTypePatents */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Deprecated, does nothing. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A face handle. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* Always returns false. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* Since May 2010, TrueType hinting is no longer patented. */
|
||||
/* */
|
||||
/* <Since> */
|
||||
/* 2.3.5 */
|
||||
/* */
|
||||
FT_EXPORT( FT_Bool )
|
||||
FT_Face_CheckTrueTypePatents( FT_Face face );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Face_SetUnpatentedHinting */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Deprecated, does nothing. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A face handle. */
|
||||
/* */
|
||||
/* value :: New boolean setting. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* Always returns false. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* Since May 2010, TrueType hinting is no longer patented. */
|
||||
/* */
|
||||
/* <Since> */
|
||||
/* 2.3.5 */
|
||||
/* */
|
||||
FT_EXPORT( FT_Bool )
|
||||
FT_Face_SetUnpatentedHinting( FT_Face face,
|
||||
FT_Bool value );
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FREETYPE_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,187 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftadvanc.h */
|
||||
/* */
|
||||
/* Quick computation of advance widths (specification only). */
|
||||
/* */
|
||||
/* Copyright 2008-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTADVANC_H_
|
||||
#define FTADVANC_H_
|
||||
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#ifdef FREETYPE_H
|
||||
#error "freetype.h of FreeType 1 has been loaded!"
|
||||
#error "Please fix the directory search order for header files"
|
||||
#error "so that freetype.h of FreeType 2 is found first."
|
||||
#endif
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @section:
|
||||
* quick_advance
|
||||
*
|
||||
* @title:
|
||||
* Quick retrieval of advance values
|
||||
*
|
||||
* @abstract:
|
||||
* Retrieve horizontal and vertical advance values without processing
|
||||
* glyph outlines, if possible.
|
||||
*
|
||||
* @description:
|
||||
* This section contains functions to quickly extract advance values
|
||||
* without handling glyph outlines, if possible.
|
||||
*
|
||||
* @order:
|
||||
* FT_Get_Advance
|
||||
* FT_Get_Advances
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Const> */
|
||||
/* FT_ADVANCE_FLAG_FAST_ONLY */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A bit-flag to be OR-ed with the `flags' parameter of the */
|
||||
/* @FT_Get_Advance and @FT_Get_Advances functions. */
|
||||
/* */
|
||||
/* If set, it indicates that you want these functions to fail if the */
|
||||
/* corresponding hinting mode or font driver doesn't allow for very */
|
||||
/* quick advance computation. */
|
||||
/* */
|
||||
/* Typically, glyphs that are either unscaled, unhinted, bitmapped, */
|
||||
/* or light-hinted can have their advance width computed very */
|
||||
/* quickly. */
|
||||
/* */
|
||||
/* Normal and bytecode hinted modes that require loading, scaling, */
|
||||
/* and hinting of the glyph outline, are extremely slow by */
|
||||
/* comparison. */
|
||||
/* */
|
||||
#define FT_ADVANCE_FLAG_FAST_ONLY 0x20000000L
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_Advance */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Retrieve the advance value of a given glyph outline in an */
|
||||
/* @FT_Face. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: The source @FT_Face handle. */
|
||||
/* */
|
||||
/* gindex :: The glyph index. */
|
||||
/* */
|
||||
/* load_flags :: A set of bit flags similar to those used when */
|
||||
/* calling @FT_Load_Glyph, used to determine what kind */
|
||||
/* of advances you need. */
|
||||
/* <Output> */
|
||||
/* padvance :: The advance value. If scaling is performed (based on */
|
||||
/* the value of `load_flags'), the advance value is in */
|
||||
/* 16.16 format. Otherwise, it is in font units. */
|
||||
/* */
|
||||
/* If @FT_LOAD_VERTICAL_LAYOUT is set, this is the */
|
||||
/* vertical advance corresponding to a vertical layout. */
|
||||
/* Otherwise, it is the horizontal advance in a */
|
||||
/* horizontal layout. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This function may fail if you use @FT_ADVANCE_FLAG_FAST_ONLY and */
|
||||
/* if the corresponding font backend doesn't have a quick way to */
|
||||
/* retrieve the advances. */
|
||||
/* */
|
||||
/* A scaled advance is returned in 16.16 format but isn't transformed */
|
||||
/* by the affine transformation specified by @FT_Set_Transform. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Get_Advance( FT_Face face,
|
||||
FT_UInt gindex,
|
||||
FT_Int32 load_flags,
|
||||
FT_Fixed *padvance );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_Advances */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Retrieve the advance values of several glyph outlines in an */
|
||||
/* @FT_Face. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: The source @FT_Face handle. */
|
||||
/* */
|
||||
/* start :: The first glyph index. */
|
||||
/* */
|
||||
/* count :: The number of advance values you want to retrieve. */
|
||||
/* */
|
||||
/* load_flags :: A set of bit flags similar to those used when */
|
||||
/* calling @FT_Load_Glyph. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* padvance :: The advance values. This array, to be provided by the */
|
||||
/* caller, must contain at least `count' elements. */
|
||||
/* */
|
||||
/* If scaling is performed (based on the value of */
|
||||
/* `load_flags'), the advance values are in 16.16 format. */
|
||||
/* Otherwise, they are in font units. */
|
||||
/* */
|
||||
/* If @FT_LOAD_VERTICAL_LAYOUT is set, these are the */
|
||||
/* vertical advances corresponding to a vertical layout. */
|
||||
/* Otherwise, they are the horizontal advances in a */
|
||||
/* horizontal layout. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0 means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This function may fail if you use @FT_ADVANCE_FLAG_FAST_ONLY and */
|
||||
/* if the corresponding font backend doesn't have a quick way to */
|
||||
/* retrieve the advances. */
|
||||
/* */
|
||||
/* Scaled advances are returned in 16.16 format but aren't */
|
||||
/* transformed by the affine transformation specified by */
|
||||
/* @FT_Set_Transform. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Get_Advances( FT_Face face,
|
||||
FT_UInt start,
|
||||
FT_UInt count,
|
||||
FT_Int32 load_flags,
|
||||
FT_Fixed *padvances );
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTADVANC_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,101 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftbbox.h */
|
||||
/* */
|
||||
/* FreeType exact bbox computation (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* This component has a _single_ role: to compute exact outline bounding */
|
||||
/* boxes. */
|
||||
/* */
|
||||
/* It is separated from the rest of the engine for various technical */
|
||||
/* reasons. It may well be integrated in `ftoutln' later. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTBBOX_H_
|
||||
#define FTBBOX_H_
|
||||
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#ifdef FREETYPE_H
|
||||
#error "freetype.h of FreeType 1 has been loaded!"
|
||||
#error "Please fix the directory search order for header files"
|
||||
#error "so that freetype.h of FreeType 2 is found first."
|
||||
#endif
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* outline_processing */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Get_BBox */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Compute the exact bounding box of an outline. This is slower */
|
||||
/* than computing the control box. However, it uses an advanced */
|
||||
/* algorithm that returns _very_ quickly when the two boxes */
|
||||
/* coincide. Otherwise, the outline Bezier arcs are traversed to */
|
||||
/* extract their extrema. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* outline :: A pointer to the source outline. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* abbox :: The outline's exact bounding box. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* If the font is tricky and the glyph has been loaded with */
|
||||
/* @FT_LOAD_NO_SCALE, the resulting BBox is meaningless. To get */
|
||||
/* reasonable values for the BBox it is necessary to load the glyph */
|
||||
/* at a large ppem value (so that the hinting instructions can */
|
||||
/* properly shift and scale the subglyphs), then extracting the BBox, */
|
||||
/* which can be eventually converted back to font units. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Outline_Get_BBox( FT_Outline* outline,
|
||||
FT_BBox *abbox );
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTBBOX_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
|
||||
|
||||
/* Local Variables: */
|
||||
/* coding: utf-8 */
|
||||
/* End: */
|
||||
@@ -0,0 +1,210 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftbdf.h */
|
||||
/* */
|
||||
/* FreeType API for accessing BDF-specific strings (specification). */
|
||||
/* */
|
||||
/* Copyright 2002-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTBDF_H_
|
||||
#define FTBDF_H_
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#ifdef FREETYPE_H
|
||||
#error "freetype.h of FreeType 1 has been loaded!"
|
||||
#error "Please fix the directory search order for header files"
|
||||
#error "so that freetype.h of FreeType 2 is found first."
|
||||
#endif
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* bdf_fonts */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* BDF and PCF Files */
|
||||
/* */
|
||||
/* <Abstract> */
|
||||
/* BDF and PCF specific API. */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This section contains the declaration of functions specific to BDF */
|
||||
/* and PCF fonts. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* @enum:
|
||||
* BDF_PropertyType
|
||||
*
|
||||
* @description:
|
||||
* A list of BDF property types.
|
||||
*
|
||||
* @values:
|
||||
* BDF_PROPERTY_TYPE_NONE ::
|
||||
* Value~0 is used to indicate a missing property.
|
||||
*
|
||||
* BDF_PROPERTY_TYPE_ATOM ::
|
||||
* Property is a string atom.
|
||||
*
|
||||
* BDF_PROPERTY_TYPE_INTEGER ::
|
||||
* Property is a 32-bit signed integer.
|
||||
*
|
||||
* BDF_PROPERTY_TYPE_CARDINAL ::
|
||||
* Property is a 32-bit unsigned integer.
|
||||
*/
|
||||
typedef enum BDF_PropertyType_
|
||||
{
|
||||
BDF_PROPERTY_TYPE_NONE = 0,
|
||||
BDF_PROPERTY_TYPE_ATOM = 1,
|
||||
BDF_PROPERTY_TYPE_INTEGER = 2,
|
||||
BDF_PROPERTY_TYPE_CARDINAL = 3
|
||||
|
||||
} BDF_PropertyType;
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* @type:
|
||||
* BDF_Property
|
||||
*
|
||||
* @description:
|
||||
* A handle to a @BDF_PropertyRec structure to model a given
|
||||
* BDF/PCF property.
|
||||
*/
|
||||
typedef struct BDF_PropertyRec_* BDF_Property;
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* @struct:
|
||||
* BDF_PropertyRec
|
||||
*
|
||||
* @description:
|
||||
* This structure models a given BDF/PCF property.
|
||||
*
|
||||
* @fields:
|
||||
* type ::
|
||||
* The property type.
|
||||
*
|
||||
* u.atom ::
|
||||
* The atom string, if type is @BDF_PROPERTY_TYPE_ATOM. May be
|
||||
* NULL, indicating an empty string.
|
||||
*
|
||||
* u.integer ::
|
||||
* A signed integer, if type is @BDF_PROPERTY_TYPE_INTEGER.
|
||||
*
|
||||
* u.cardinal ::
|
||||
* An unsigned integer, if type is @BDF_PROPERTY_TYPE_CARDINAL.
|
||||
*/
|
||||
typedef struct BDF_PropertyRec_
|
||||
{
|
||||
BDF_PropertyType type;
|
||||
union {
|
||||
const char* atom;
|
||||
FT_Int32 integer;
|
||||
FT_UInt32 cardinal;
|
||||
|
||||
} u;
|
||||
|
||||
} BDF_PropertyRec;
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Get_BDF_Charset_ID
|
||||
*
|
||||
* @description:
|
||||
* Retrieve a BDF font character set identity, according to
|
||||
* the BDF specification.
|
||||
*
|
||||
* @input:
|
||||
* face ::
|
||||
* A handle to the input face.
|
||||
*
|
||||
* @output:
|
||||
* acharset_encoding ::
|
||||
* Charset encoding, as a C~string, owned by the face.
|
||||
*
|
||||
* acharset_registry ::
|
||||
* Charset registry, as a C~string, owned by the face.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* This function only works with BDF faces, returning an error otherwise.
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Get_BDF_Charset_ID( FT_Face face,
|
||||
const char* *acharset_encoding,
|
||||
const char* *acharset_registry );
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Get_BDF_Property
|
||||
*
|
||||
* @description:
|
||||
* Retrieve a BDF property from a BDF or PCF font file.
|
||||
*
|
||||
* @input:
|
||||
* face :: A handle to the input face.
|
||||
*
|
||||
* name :: The property name.
|
||||
*
|
||||
* @output:
|
||||
* aproperty :: The property.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* This function works with BDF _and_ PCF fonts. It returns an error
|
||||
* otherwise. It also returns an error if the property is not in the
|
||||
* font.
|
||||
*
|
||||
* A `property' is a either key-value pair within the STARTPROPERTIES
|
||||
* ... ENDPROPERTIES block of a BDF font or a key-value pair from the
|
||||
* `info->props' array within a `FontRec' structure of a PCF font.
|
||||
*
|
||||
* Integer properties are always stored as `signed' within PCF fonts;
|
||||
* consequently, @BDF_PROPERTY_TYPE_CARDINAL is a possible return value
|
||||
* for BDF fonts only.
|
||||
*
|
||||
* In case of error, `aproperty->type' is always set to
|
||||
* @BDF_PROPERTY_TYPE_NONE.
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Get_BDF_Property( FT_Face face,
|
||||
const char* prop_name,
|
||||
BDF_PropertyRec *aproperty );
|
||||
|
||||
/* */
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTBDF_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,240 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftbitmap.h */
|
||||
/* */
|
||||
/* FreeType utility functions for bitmaps (specification). */
|
||||
/* */
|
||||
/* Copyright 2004-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTBITMAP_H_
|
||||
#define FTBITMAP_H_
|
||||
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#ifdef FREETYPE_H
|
||||
#error "freetype.h of FreeType 1 has been loaded!"
|
||||
#error "Please fix the directory search order for header files"
|
||||
#error "so that freetype.h of FreeType 2 is found first."
|
||||
#endif
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* bitmap_handling */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* Bitmap Handling */
|
||||
/* */
|
||||
/* <Abstract> */
|
||||
/* Handling FT_Bitmap objects. */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This section contains functions for handling @FT_Bitmap objects. */
|
||||
/* Note that none of the functions changes the bitmap's `flow' (as */
|
||||
/* indicated by the sign of the `pitch' field in `FT_Bitmap'). */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Bitmap_Init */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Initialize a pointer to an @FT_Bitmap structure. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* abitmap :: A pointer to the bitmap structure. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* A deprecated name for the same function is `FT_Bitmap_New'. */
|
||||
/* */
|
||||
FT_EXPORT( void )
|
||||
FT_Bitmap_Init( FT_Bitmap *abitmap );
|
||||
|
||||
|
||||
/* deprecated */
|
||||
FT_EXPORT( void )
|
||||
FT_Bitmap_New( FT_Bitmap *abitmap );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Bitmap_Copy */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Copy a bitmap into another one. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle to a library object. */
|
||||
/* */
|
||||
/* source :: A handle to the source bitmap. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* target :: A handle to the target bitmap. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Bitmap_Copy( FT_Library library,
|
||||
const FT_Bitmap *source,
|
||||
FT_Bitmap *target );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Bitmap_Embolden */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Embolden a bitmap. The new bitmap will be about `xStrength' */
|
||||
/* pixels wider and `yStrength' pixels higher. The left and bottom */
|
||||
/* borders are kept unchanged. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle to a library object. */
|
||||
/* */
|
||||
/* xStrength :: How strong the glyph is emboldened horizontally. */
|
||||
/* Expressed in 26.6 pixel format. */
|
||||
/* */
|
||||
/* yStrength :: How strong the glyph is emboldened vertically. */
|
||||
/* Expressed in 26.6 pixel format. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* bitmap :: A handle to the target bitmap. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The current implementation restricts `xStrength' to be less than */
|
||||
/* or equal to~8 if bitmap is of pixel_mode @FT_PIXEL_MODE_MONO. */
|
||||
/* */
|
||||
/* If you want to embolden the bitmap owned by a @FT_GlyphSlotRec, */
|
||||
/* you should call @FT_GlyphSlot_Own_Bitmap on the slot first. */
|
||||
/* */
|
||||
/* Bitmaps in @FT_PIXEL_MODE_GRAY2 and @FT_PIXEL_MODE_GRAY@ format */
|
||||
/* are converted to @FT_PIXEL_MODE_GRAY format (i.e., 8bpp). */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Bitmap_Embolden( FT_Library library,
|
||||
FT_Bitmap* bitmap,
|
||||
FT_Pos xStrength,
|
||||
FT_Pos yStrength );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Bitmap_Convert */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Convert a bitmap object with depth 1bpp, 2bpp, 4bpp, 8bpp or 32bpp */
|
||||
/* to a bitmap object with depth 8bpp, making the number of used */
|
||||
/* bytes line (a.k.a. the `pitch') a multiple of `alignment'. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle to a library object. */
|
||||
/* */
|
||||
/* source :: The source bitmap. */
|
||||
/* */
|
||||
/* alignment :: The pitch of the bitmap is a multiple of this */
|
||||
/* parameter. Common values are 1, 2, or 4. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* target :: The target bitmap. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* It is possible to call @FT_Bitmap_Convert multiple times without */
|
||||
/* calling @FT_Bitmap_Done (the memory is simply reallocated). */
|
||||
/* */
|
||||
/* Use @FT_Bitmap_Done to finally remove the bitmap object. */
|
||||
/* */
|
||||
/* The `library' argument is taken to have access to FreeType's */
|
||||
/* memory handling functions. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Bitmap_Convert( FT_Library library,
|
||||
const FT_Bitmap *source,
|
||||
FT_Bitmap *target,
|
||||
FT_Int alignment );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_GlyphSlot_Own_Bitmap */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Make sure that a glyph slot owns `slot->bitmap'. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* slot :: The glyph slot. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This function is to be used in combination with */
|
||||
/* @FT_Bitmap_Embolden. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_GlyphSlot_Own_Bitmap( FT_GlyphSlot slot );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Bitmap_Done */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Destroy a bitmap object initialized with @FT_Bitmap_Init. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle to a library object. */
|
||||
/* */
|
||||
/* bitmap :: The bitmap object to be freed. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The `library' argument is taken to have access to FreeType's */
|
||||
/* memory handling functions. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Bitmap_Done( FT_Library library,
|
||||
FT_Bitmap *bitmap );
|
||||
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTBITMAP_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,102 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftbzip2.h */
|
||||
/* */
|
||||
/* Bzip2-compressed stream support. */
|
||||
/* */
|
||||
/* Copyright 2010-2018 by */
|
||||
/* Joel Klinghed. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTBZIP2_H_
|
||||
#define FTBZIP2_H_
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#ifdef FREETYPE_H
|
||||
#error "freetype.h of FreeType 1 has been loaded!"
|
||||
#error "Please fix the directory search order for header files"
|
||||
#error "so that freetype.h of FreeType 2 is found first."
|
||||
#endif
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* bzip2 */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* BZIP2 Streams */
|
||||
/* */
|
||||
/* <Abstract> */
|
||||
/* Using bzip2-compressed font files. */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This section contains the declaration of Bzip2-specific functions. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/************************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Stream_OpenBzip2
|
||||
*
|
||||
* @description:
|
||||
* Open a new stream to parse bzip2-compressed font files. This is
|
||||
* mainly used to support the compressed `*.pcf.bz2' fonts that come
|
||||
* with XFree86.
|
||||
*
|
||||
* @input:
|
||||
* stream ::
|
||||
* The target embedding stream.
|
||||
*
|
||||
* source ::
|
||||
* The source stream.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* The source stream must be opened _before_ calling this function.
|
||||
*
|
||||
* Calling the internal function `FT_Stream_Close' on the new stream will
|
||||
* *not* call `FT_Stream_Close' on the source stream. None of the stream
|
||||
* objects will be released to the heap.
|
||||
*
|
||||
* The stream implementation is very basic and resets the decompression
|
||||
* process each time seeking backwards is needed within the stream.
|
||||
*
|
||||
* In certain builds of the library, bzip2 compression recognition is
|
||||
* automatically handled when calling @FT_New_Face or @FT_Open_Face.
|
||||
* This means that if no font driver is capable of handling the raw
|
||||
* compressed file, the library will try to open a bzip2 compressed stream
|
||||
* from it and re-open the face with it.
|
||||
*
|
||||
* This function may return `FT_Err_Unimplemented_Feature' if your build
|
||||
* of FreeType was not compiled with bzip2 support.
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Stream_OpenBzip2( FT_Stream stream,
|
||||
FT_Stream source );
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTBZIP2_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,1042 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftcache.h */
|
||||
/* */
|
||||
/* FreeType Cache subsystem (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTCACHE_H_
|
||||
#define FTCACHE_H_
|
||||
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_GLYPH_H
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* <Section>
|
||||
* cache_subsystem
|
||||
*
|
||||
* <Title>
|
||||
* Cache Sub-System
|
||||
*
|
||||
* <Abstract>
|
||||
* How to cache face, size, and glyph data with FreeType~2.
|
||||
*
|
||||
* <Description>
|
||||
* This section describes the FreeType~2 cache sub-system, which is used
|
||||
* to limit the number of concurrently opened @FT_Face and @FT_Size
|
||||
* objects, as well as caching information like character maps and glyph
|
||||
* images while limiting their maximum memory usage.
|
||||
*
|
||||
* Note that all types and functions begin with the `FTC_' prefix.
|
||||
*
|
||||
* The cache is highly portable and thus doesn't know anything about the
|
||||
* fonts installed on your system, or how to access them. This implies
|
||||
* the following scheme:
|
||||
*
|
||||
* First, available or installed font faces are uniquely identified by
|
||||
* @FTC_FaceID values, provided to the cache by the client. Note that
|
||||
* the cache only stores and compares these values, and doesn't try to
|
||||
* interpret them in any way.
|
||||
*
|
||||
* Second, the cache calls, only when needed, a client-provided function
|
||||
* to convert an @FTC_FaceID into a new @FT_Face object. The latter is
|
||||
* then completely managed by the cache, including its termination
|
||||
* through @FT_Done_Face. To monitor termination of face objects, the
|
||||
* finalizer callback in the `generic' field of the @FT_Face object can
|
||||
* be used, which might also be used to store the @FTC_FaceID of the
|
||||
* face.
|
||||
*
|
||||
* Clients are free to map face IDs to anything else. The most simple
|
||||
* usage is to associate them to a (pathname,face_index) pair that is
|
||||
* used to call @FT_New_Face. However, more complex schemes are also
|
||||
* possible.
|
||||
*
|
||||
* Note that for the cache to work correctly, the face ID values must be
|
||||
* *persistent*, which means that the contents they point to should not
|
||||
* change at runtime, or that their value should not become invalid.
|
||||
*
|
||||
* If this is unavoidable (e.g., when a font is uninstalled at runtime),
|
||||
* you should call @FTC_Manager_RemoveFaceID as soon as possible, to let
|
||||
* the cache get rid of any references to the old @FTC_FaceID it may
|
||||
* keep internally. Failure to do so will lead to incorrect behaviour
|
||||
* or even crashes.
|
||||
*
|
||||
* To use the cache, start with calling @FTC_Manager_New to create a new
|
||||
* @FTC_Manager object, which models a single cache instance. You can
|
||||
* then look up @FT_Face and @FT_Size objects with
|
||||
* @FTC_Manager_LookupFace and @FTC_Manager_LookupSize, respectively.
|
||||
*
|
||||
* If you want to use the charmap caching, call @FTC_CMapCache_New, then
|
||||
* later use @FTC_CMapCache_Lookup to perform the equivalent of
|
||||
* @FT_Get_Char_Index, only much faster.
|
||||
*
|
||||
* If you want to use the @FT_Glyph caching, call @FTC_ImageCache, then
|
||||
* later use @FTC_ImageCache_Lookup to retrieve the corresponding
|
||||
* @FT_Glyph objects from the cache.
|
||||
*
|
||||
* If you need lots of small bitmaps, it is much more memory efficient
|
||||
* to call @FTC_SBitCache_New followed by @FTC_SBitCache_Lookup. This
|
||||
* returns @FTC_SBitRec structures, which are used to store small
|
||||
* bitmaps directly. (A small bitmap is one whose metrics and
|
||||
* dimensions all fit into 8-bit integers).
|
||||
*
|
||||
* We hope to also provide a kerning cache in the near future.
|
||||
*
|
||||
*
|
||||
* <Order>
|
||||
* FTC_Manager
|
||||
* FTC_FaceID
|
||||
* FTC_Face_Requester
|
||||
*
|
||||
* FTC_Manager_New
|
||||
* FTC_Manager_Reset
|
||||
* FTC_Manager_Done
|
||||
* FTC_Manager_LookupFace
|
||||
* FTC_Manager_LookupSize
|
||||
* FTC_Manager_RemoveFaceID
|
||||
*
|
||||
* FTC_Node
|
||||
* FTC_Node_Unref
|
||||
*
|
||||
* FTC_ImageCache
|
||||
* FTC_ImageCache_New
|
||||
* FTC_ImageCache_Lookup
|
||||
*
|
||||
* FTC_SBit
|
||||
* FTC_SBitCache
|
||||
* FTC_SBitCache_New
|
||||
* FTC_SBitCache_Lookup
|
||||
*
|
||||
* FTC_CMapCache
|
||||
* FTC_CMapCache_New
|
||||
* FTC_CMapCache_Lookup
|
||||
*
|
||||
*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/***** *****/
|
||||
/***** BASIC TYPE DEFINITIONS *****/
|
||||
/***** *****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @type: FTC_FaceID
|
||||
*
|
||||
* @description:
|
||||
* An opaque pointer type that is used to identity face objects. The
|
||||
* contents of such objects is application-dependent.
|
||||
*
|
||||
* These pointers are typically used to point to a user-defined
|
||||
* structure containing a font file path, and face index.
|
||||
*
|
||||
* @note:
|
||||
* Never use NULL as a valid @FTC_FaceID.
|
||||
*
|
||||
* Face IDs are passed by the client to the cache manager that calls,
|
||||
* when needed, the @FTC_Face_Requester to translate them into new
|
||||
* @FT_Face objects.
|
||||
*
|
||||
* If the content of a given face ID changes at runtime, or if the value
|
||||
* becomes invalid (e.g., when uninstalling a font), you should
|
||||
* immediately call @FTC_Manager_RemoveFaceID before any other cache
|
||||
* function.
|
||||
*
|
||||
* Failure to do so will result in incorrect behaviour or even
|
||||
* memory leaks and crashes.
|
||||
*/
|
||||
typedef FT_Pointer FTC_FaceID;
|
||||
|
||||
|
||||
/************************************************************************
|
||||
*
|
||||
* @functype:
|
||||
* FTC_Face_Requester
|
||||
*
|
||||
* @description:
|
||||
* A callback function provided by client applications. It is used by
|
||||
* the cache manager to translate a given @FTC_FaceID into a new valid
|
||||
* @FT_Face object, on demand.
|
||||
*
|
||||
* <Input>
|
||||
* face_id ::
|
||||
* The face ID to resolve.
|
||||
*
|
||||
* library ::
|
||||
* A handle to a FreeType library object.
|
||||
*
|
||||
* req_data ::
|
||||
* Application-provided request data (see note below).
|
||||
*
|
||||
* <Output>
|
||||
* aface ::
|
||||
* A new @FT_Face handle.
|
||||
*
|
||||
* <Return>
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* <Note>
|
||||
* The third parameter `req_data' is the same as the one passed by the
|
||||
* client when @FTC_Manager_New is called.
|
||||
*
|
||||
* The face requester should not perform funny things on the returned
|
||||
* face object, like creating a new @FT_Size for it, or setting a
|
||||
* transformation through @FT_Set_Transform!
|
||||
*/
|
||||
typedef FT_Error
|
||||
(*FTC_Face_Requester)( FTC_FaceID face_id,
|
||||
FT_Library library,
|
||||
FT_Pointer req_data,
|
||||
FT_Face* aface );
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/***** *****/
|
||||
/***** CACHE MANAGER OBJECT *****/
|
||||
/***** *****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FTC_Manager */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This object corresponds to one instance of the cache-subsystem. */
|
||||
/* It is used to cache one or more @FT_Face objects, along with */
|
||||
/* corresponding @FT_Size objects. */
|
||||
/* */
|
||||
/* The manager intentionally limits the total number of opened */
|
||||
/* @FT_Face and @FT_Size objects to control memory usage. See the */
|
||||
/* `max_faces' and `max_sizes' parameters of @FTC_Manager_New. */
|
||||
/* */
|
||||
/* The manager is also used to cache `nodes' of various types while */
|
||||
/* limiting their total memory usage. */
|
||||
/* */
|
||||
/* All limitations are enforced by keeping lists of managed objects */
|
||||
/* in most-recently-used order, and flushing old nodes to make room */
|
||||
/* for new ones. */
|
||||
/* */
|
||||
typedef struct FTC_ManagerRec_* FTC_Manager;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FTC_Node */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* An opaque handle to a cache node object. Each cache node is */
|
||||
/* reference-counted. A node with a count of~0 might be flushed */
|
||||
/* out of a full cache whenever a lookup request is performed. */
|
||||
/* */
|
||||
/* If you look up nodes, you have the ability to `acquire' them, */
|
||||
/* i.e., to increment their reference count. This will prevent the */
|
||||
/* node from being flushed out of the cache until you explicitly */
|
||||
/* `release' it (see @FTC_Node_Unref). */
|
||||
/* */
|
||||
/* See also @FTC_SBitCache_Lookup and @FTC_ImageCache_Lookup. */
|
||||
/* */
|
||||
typedef struct FTC_NodeRec_* FTC_Node;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FTC_Manager_New */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Create a new cache manager. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: The parent FreeType library handle to use. */
|
||||
/* */
|
||||
/* max_faces :: Maximum number of opened @FT_Face objects managed by */
|
||||
/* this cache instance. Use~0 for defaults. */
|
||||
/* */
|
||||
/* max_sizes :: Maximum number of opened @FT_Size objects managed by */
|
||||
/* this cache instance. Use~0 for defaults. */
|
||||
/* */
|
||||
/* max_bytes :: Maximum number of bytes to use for cached data nodes. */
|
||||
/* Use~0 for defaults. Note that this value does not */
|
||||
/* account for managed @FT_Face and @FT_Size objects. */
|
||||
/* */
|
||||
/* requester :: An application-provided callback used to translate */
|
||||
/* face IDs into real @FT_Face objects. */
|
||||
/* */
|
||||
/* req_data :: A generic pointer that is passed to the requester */
|
||||
/* each time it is called (see @FTC_Face_Requester). */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* amanager :: A handle to a new manager object. 0~in case of */
|
||||
/* failure. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FTC_Manager_New( FT_Library library,
|
||||
FT_UInt max_faces,
|
||||
FT_UInt max_sizes,
|
||||
FT_ULong max_bytes,
|
||||
FTC_Face_Requester requester,
|
||||
FT_Pointer req_data,
|
||||
FTC_Manager *amanager );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FTC_Manager_Reset */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Empty a given cache manager. This simply gets rid of all the */
|
||||
/* currently cached @FT_Face and @FT_Size objects within the manager. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* manager :: A handle to the manager. */
|
||||
/* */
|
||||
FT_EXPORT( void )
|
||||
FTC_Manager_Reset( FTC_Manager manager );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FTC_Manager_Done */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Destroy a given manager after emptying it. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* manager :: A handle to the target cache manager object. */
|
||||
/* */
|
||||
FT_EXPORT( void )
|
||||
FTC_Manager_Done( FTC_Manager manager );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FTC_Manager_LookupFace */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Retrieve the @FT_Face object that corresponds to a given face ID */
|
||||
/* through a cache manager. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* manager :: A handle to the cache manager. */
|
||||
/* */
|
||||
/* face_id :: The ID of the face object. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* aface :: A handle to the face object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The returned @FT_Face object is always owned by the manager. You */
|
||||
/* should never try to discard it yourself. */
|
||||
/* */
|
||||
/* The @FT_Face object doesn't necessarily have a current size object */
|
||||
/* (i.e., face->size can be~0). If you need a specific `font size', */
|
||||
/* use @FTC_Manager_LookupSize instead. */
|
||||
/* */
|
||||
/* Never change the face's transformation matrix (i.e., never call */
|
||||
/* the @FT_Set_Transform function) on a returned face! If you need */
|
||||
/* to transform glyphs, do it yourself after glyph loading. */
|
||||
/* */
|
||||
/* When you perform a lookup, out-of-memory errors are detected */
|
||||
/* _within_ the lookup and force incremental flushes of the cache */
|
||||
/* until enough memory is released for the lookup to succeed. */
|
||||
/* */
|
||||
/* If a lookup fails with `FT_Err_Out_Of_Memory' the cache has */
|
||||
/* already been completely flushed, and still no memory was available */
|
||||
/* for the operation. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FTC_Manager_LookupFace( FTC_Manager manager,
|
||||
FTC_FaceID face_id,
|
||||
FT_Face *aface );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FTC_ScalerRec */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to describe a given character size in either */
|
||||
/* pixels or points to the cache manager. See */
|
||||
/* @FTC_Manager_LookupSize. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* face_id :: The source face ID. */
|
||||
/* */
|
||||
/* width :: The character width. */
|
||||
/* */
|
||||
/* height :: The character height. */
|
||||
/* */
|
||||
/* pixel :: A Boolean. If 1, the `width' and `height' fields are */
|
||||
/* interpreted as integer pixel character sizes. */
|
||||
/* Otherwise, they are expressed as 1/64th of points. */
|
||||
/* */
|
||||
/* x_res :: Only used when `pixel' is value~0 to indicate the */
|
||||
/* horizontal resolution in dpi. */
|
||||
/* */
|
||||
/* y_res :: Only used when `pixel' is value~0 to indicate the */
|
||||
/* vertical resolution in dpi. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This type is mainly used to retrieve @FT_Size objects through the */
|
||||
/* cache manager. */
|
||||
/* */
|
||||
typedef struct FTC_ScalerRec_
|
||||
{
|
||||
FTC_FaceID face_id;
|
||||
FT_UInt width;
|
||||
FT_UInt height;
|
||||
FT_Int pixel;
|
||||
FT_UInt x_res;
|
||||
FT_UInt y_res;
|
||||
|
||||
} FTC_ScalerRec;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FTC_Scaler */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to an @FTC_ScalerRec structure. */
|
||||
/* */
|
||||
typedef struct FTC_ScalerRec_* FTC_Scaler;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FTC_Manager_LookupSize */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Retrieve the @FT_Size object that corresponds to a given */
|
||||
/* @FTC_ScalerRec pointer through a cache manager. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* manager :: A handle to the cache manager. */
|
||||
/* */
|
||||
/* scaler :: A scaler handle. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* asize :: A handle to the size object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The returned @FT_Size object is always owned by the manager. You */
|
||||
/* should never try to discard it by yourself. */
|
||||
/* */
|
||||
/* You can access the parent @FT_Face object simply as `size->face' */
|
||||
/* if you need it. Note that this object is also owned by the */
|
||||
/* manager. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* When you perform a lookup, out-of-memory errors are detected */
|
||||
/* _within_ the lookup and force incremental flushes of the cache */
|
||||
/* until enough memory is released for the lookup to succeed. */
|
||||
/* */
|
||||
/* If a lookup fails with `FT_Err_Out_Of_Memory' the cache has */
|
||||
/* already been completely flushed, and still no memory is available */
|
||||
/* for the operation. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FTC_Manager_LookupSize( FTC_Manager manager,
|
||||
FTC_Scaler scaler,
|
||||
FT_Size *asize );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FTC_Node_Unref */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Decrement a cache node's internal reference count. When the count */
|
||||
/* reaches 0, it is not destroyed but becomes eligible for subsequent */
|
||||
/* cache flushes. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* node :: The cache node handle. */
|
||||
/* */
|
||||
/* manager :: The cache manager handle. */
|
||||
/* */
|
||||
FT_EXPORT( void )
|
||||
FTC_Node_Unref( FTC_Node node,
|
||||
FTC_Manager manager );
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FTC_Manager_RemoveFaceID
|
||||
*
|
||||
* @description:
|
||||
* A special function used to indicate to the cache manager that
|
||||
* a given @FTC_FaceID is no longer valid, either because its
|
||||
* content changed, or because it was deallocated or uninstalled.
|
||||
*
|
||||
* @input:
|
||||
* manager ::
|
||||
* The cache manager handle.
|
||||
*
|
||||
* face_id ::
|
||||
* The @FTC_FaceID to be removed.
|
||||
*
|
||||
* @note:
|
||||
* This function flushes all nodes from the cache corresponding to this
|
||||
* `face_id', with the exception of nodes with a non-null reference
|
||||
* count.
|
||||
*
|
||||
* Such nodes are however modified internally so as to never appear
|
||||
* in later lookups with the same `face_id' value, and to be immediately
|
||||
* destroyed when released by all their users.
|
||||
*
|
||||
*/
|
||||
FT_EXPORT( void )
|
||||
FTC_Manager_RemoveFaceID( FTC_Manager manager,
|
||||
FTC_FaceID face_id );
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @type:
|
||||
* FTC_CMapCache
|
||||
*
|
||||
* @description:
|
||||
* An opaque handle used to model a charmap cache. This cache is to
|
||||
* hold character codes -> glyph indices mappings.
|
||||
*
|
||||
*/
|
||||
typedef struct FTC_CMapCacheRec_* FTC_CMapCache;
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FTC_CMapCache_New
|
||||
*
|
||||
* @description:
|
||||
* Create a new charmap cache.
|
||||
*
|
||||
* @input:
|
||||
* manager ::
|
||||
* A handle to the cache manager.
|
||||
*
|
||||
* @output:
|
||||
* acache ::
|
||||
* A new cache handle. NULL in case of error.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* Like all other caches, this one will be destroyed with the cache
|
||||
* manager.
|
||||
*
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FTC_CMapCache_New( FTC_Manager manager,
|
||||
FTC_CMapCache *acache );
|
||||
|
||||
|
||||
/************************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FTC_CMapCache_Lookup
|
||||
*
|
||||
* @description:
|
||||
* Translate a character code into a glyph index, using the charmap
|
||||
* cache.
|
||||
*
|
||||
* @input:
|
||||
* cache ::
|
||||
* A charmap cache handle.
|
||||
*
|
||||
* face_id ::
|
||||
* The source face ID.
|
||||
*
|
||||
* cmap_index ::
|
||||
* The index of the charmap in the source face. Any negative value
|
||||
* means to use the cache @FT_Face's default charmap.
|
||||
*
|
||||
* char_code ::
|
||||
* The character code (in the corresponding charmap).
|
||||
*
|
||||
* @return:
|
||||
* Glyph index. 0~means `no glyph'.
|
||||
*
|
||||
*/
|
||||
FT_EXPORT( FT_UInt )
|
||||
FTC_CMapCache_Lookup( FTC_CMapCache cache,
|
||||
FTC_FaceID face_id,
|
||||
FT_Int cmap_index,
|
||||
FT_UInt32 char_code );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/***** *****/
|
||||
/***** IMAGE CACHE OBJECT *****/
|
||||
/***** *****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @struct:
|
||||
* FTC_ImageTypeRec
|
||||
*
|
||||
* @description:
|
||||
* A structure used to model the type of images in a glyph cache.
|
||||
*
|
||||
* @fields:
|
||||
* face_id ::
|
||||
* The face ID.
|
||||
*
|
||||
* width ::
|
||||
* The width in pixels.
|
||||
*
|
||||
* height ::
|
||||
* The height in pixels.
|
||||
*
|
||||
* flags ::
|
||||
* The load flags, as in @FT_Load_Glyph.
|
||||
*
|
||||
*/
|
||||
typedef struct FTC_ImageTypeRec_
|
||||
{
|
||||
FTC_FaceID face_id;
|
||||
FT_UInt width;
|
||||
FT_UInt height;
|
||||
FT_Int32 flags;
|
||||
|
||||
} FTC_ImageTypeRec;
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @type:
|
||||
* FTC_ImageType
|
||||
*
|
||||
* @description:
|
||||
* A handle to an @FTC_ImageTypeRec structure.
|
||||
*
|
||||
*/
|
||||
typedef struct FTC_ImageTypeRec_* FTC_ImageType;
|
||||
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
#define FTC_IMAGE_TYPE_COMPARE( d1, d2 ) \
|
||||
( (d1)->face_id == (d2)->face_id && \
|
||||
(d1)->width == (d2)->width && \
|
||||
(d1)->flags == (d2)->flags )
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FTC_ImageCache */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to a glyph image cache object. They are designed to */
|
||||
/* hold many distinct glyph images while not exceeding a certain */
|
||||
/* memory threshold. */
|
||||
/* */
|
||||
typedef struct FTC_ImageCacheRec_* FTC_ImageCache;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FTC_ImageCache_New */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Create a new glyph image cache. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* manager :: The parent manager for the image cache. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* acache :: A handle to the new glyph image cache object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FTC_ImageCache_New( FTC_Manager manager,
|
||||
FTC_ImageCache *acache );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FTC_ImageCache_Lookup */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Retrieve a given glyph image from a glyph image cache. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* cache :: A handle to the source glyph image cache. */
|
||||
/* */
|
||||
/* type :: A pointer to a glyph image type descriptor. */
|
||||
/* */
|
||||
/* gindex :: The glyph index to retrieve. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* aglyph :: The corresponding @FT_Glyph object. 0~in case of */
|
||||
/* failure. */
|
||||
/* */
|
||||
/* anode :: Used to return the address of the corresponding cache */
|
||||
/* node after incrementing its reference count (see note */
|
||||
/* below). */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The returned glyph is owned and managed by the glyph image cache. */
|
||||
/* Never try to transform or discard it manually! You can however */
|
||||
/* create a copy with @FT_Glyph_Copy and modify the new one. */
|
||||
/* */
|
||||
/* If `anode' is _not_ NULL, it receives the address of the cache */
|
||||
/* node containing the glyph image, after increasing its reference */
|
||||
/* count. This ensures that the node (as well as the @FT_Glyph) will */
|
||||
/* always be kept in the cache until you call @FTC_Node_Unref to */
|
||||
/* `release' it. */
|
||||
/* */
|
||||
/* If `anode' is NULL, the cache node is left unchanged, which means */
|
||||
/* that the @FT_Glyph could be flushed out of the cache on the next */
|
||||
/* call to one of the caching sub-system APIs. Don't assume that it */
|
||||
/* is persistent! */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FTC_ImageCache_Lookup( FTC_ImageCache cache,
|
||||
FTC_ImageType type,
|
||||
FT_UInt gindex,
|
||||
FT_Glyph *aglyph,
|
||||
FTC_Node *anode );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FTC_ImageCache_LookupScaler */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A variant of @FTC_ImageCache_Lookup that uses an @FTC_ScalerRec */
|
||||
/* to specify the face ID and its size. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* cache :: A handle to the source glyph image cache. */
|
||||
/* */
|
||||
/* scaler :: A pointer to a scaler descriptor. */
|
||||
/* */
|
||||
/* load_flags :: The corresponding load flags. */
|
||||
/* */
|
||||
/* gindex :: The glyph index to retrieve. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* aglyph :: The corresponding @FT_Glyph object. 0~in case of */
|
||||
/* failure. */
|
||||
/* */
|
||||
/* anode :: Used to return the address of the corresponding */
|
||||
/* cache node after incrementing its reference count */
|
||||
/* (see note below). */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The returned glyph is owned and managed by the glyph image cache. */
|
||||
/* Never try to transform or discard it manually! You can however */
|
||||
/* create a copy with @FT_Glyph_Copy and modify the new one. */
|
||||
/* */
|
||||
/* If `anode' is _not_ NULL, it receives the address of the cache */
|
||||
/* node containing the glyph image, after increasing its reference */
|
||||
/* count. This ensures that the node (as well as the @FT_Glyph) will */
|
||||
/* always be kept in the cache until you call @FTC_Node_Unref to */
|
||||
/* `release' it. */
|
||||
/* */
|
||||
/* If `anode' is NULL, the cache node is left unchanged, which means */
|
||||
/* that the @FT_Glyph could be flushed out of the cache on the next */
|
||||
/* call to one of the caching sub-system APIs. Don't assume that it */
|
||||
/* is persistent! */
|
||||
/* */
|
||||
/* Calls to @FT_Set_Char_Size and friends have no effect on cached */
|
||||
/* glyphs; you should always use the FreeType cache API instead. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FTC_ImageCache_LookupScaler( FTC_ImageCache cache,
|
||||
FTC_Scaler scaler,
|
||||
FT_ULong load_flags,
|
||||
FT_UInt gindex,
|
||||
FT_Glyph *aglyph,
|
||||
FTC_Node *anode );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FTC_SBit */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to a small bitmap descriptor. See the @FTC_SBitRec */
|
||||
/* structure for details. */
|
||||
/* */
|
||||
typedef struct FTC_SBitRec_* FTC_SBit;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FTC_SBitRec */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A very compact structure used to describe a small glyph bitmap. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* width :: The bitmap width in pixels. */
|
||||
/* */
|
||||
/* height :: The bitmap height in pixels. */
|
||||
/* */
|
||||
/* left :: The horizontal distance from the pen position to the */
|
||||
/* left bitmap border (a.k.a. `left side bearing', or */
|
||||
/* `lsb'). */
|
||||
/* */
|
||||
/* top :: The vertical distance from the pen position (on the */
|
||||
/* baseline) to the upper bitmap border (a.k.a. `top */
|
||||
/* side bearing'). The distance is positive for upwards */
|
||||
/* y~coordinates. */
|
||||
/* */
|
||||
/* format :: The format of the glyph bitmap (monochrome or gray). */
|
||||
/* */
|
||||
/* max_grays :: Maximum gray level value (in the range 1 to~255). */
|
||||
/* */
|
||||
/* pitch :: The number of bytes per bitmap line. May be positive */
|
||||
/* or negative. */
|
||||
/* */
|
||||
/* xadvance :: The horizontal advance width in pixels. */
|
||||
/* */
|
||||
/* yadvance :: The vertical advance height in pixels. */
|
||||
/* */
|
||||
/* buffer :: A pointer to the bitmap pixels. */
|
||||
/* */
|
||||
typedef struct FTC_SBitRec_
|
||||
{
|
||||
FT_Byte width;
|
||||
FT_Byte height;
|
||||
FT_Char left;
|
||||
FT_Char top;
|
||||
|
||||
FT_Byte format;
|
||||
FT_Byte max_grays;
|
||||
FT_Short pitch;
|
||||
FT_Char xadvance;
|
||||
FT_Char yadvance;
|
||||
|
||||
FT_Byte* buffer;
|
||||
|
||||
} FTC_SBitRec;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FTC_SBitCache */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to a small bitmap cache. These are special cache objects */
|
||||
/* used to store small glyph bitmaps (and anti-aliased pixmaps) in a */
|
||||
/* much more efficient way than the traditional glyph image cache */
|
||||
/* implemented by @FTC_ImageCache. */
|
||||
/* */
|
||||
typedef struct FTC_SBitCacheRec_* FTC_SBitCache;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FTC_SBitCache_New */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Create a new cache to store small glyph bitmaps. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* manager :: A handle to the source cache manager. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* acache :: A handle to the new sbit cache. NULL in case of error. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FTC_SBitCache_New( FTC_Manager manager,
|
||||
FTC_SBitCache *acache );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FTC_SBitCache_Lookup */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Look up a given small glyph bitmap in a given sbit cache and */
|
||||
/* `lock' it to prevent its flushing from the cache until needed. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* cache :: A handle to the source sbit cache. */
|
||||
/* */
|
||||
/* type :: A pointer to the glyph image type descriptor. */
|
||||
/* */
|
||||
/* gindex :: The glyph index. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* sbit :: A handle to a small bitmap descriptor. */
|
||||
/* */
|
||||
/* anode :: Used to return the address of the corresponding cache */
|
||||
/* node after incrementing its reference count (see note */
|
||||
/* below). */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The small bitmap descriptor and its bit buffer are owned by the */
|
||||
/* cache and should never be freed by the application. They might */
|
||||
/* as well disappear from memory on the next cache lookup, so don't */
|
||||
/* treat them as persistent data. */
|
||||
/* */
|
||||
/* The descriptor's `buffer' field is set to~0 to indicate a missing */
|
||||
/* glyph bitmap. */
|
||||
/* */
|
||||
/* If `anode' is _not_ NULL, it receives the address of the cache */
|
||||
/* node containing the bitmap, after increasing its reference count. */
|
||||
/* This ensures that the node (as well as the image) will always be */
|
||||
/* kept in the cache until you call @FTC_Node_Unref to `release' it. */
|
||||
/* */
|
||||
/* If `anode' is NULL, the cache node is left unchanged, which means */
|
||||
/* that the bitmap could be flushed out of the cache on the next */
|
||||
/* call to one of the caching sub-system APIs. Don't assume that it */
|
||||
/* is persistent! */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FTC_SBitCache_Lookup( FTC_SBitCache cache,
|
||||
FTC_ImageType type,
|
||||
FT_UInt gindex,
|
||||
FTC_SBit *sbit,
|
||||
FTC_Node *anode );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FTC_SBitCache_LookupScaler */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A variant of @FTC_SBitCache_Lookup that uses an @FTC_ScalerRec */
|
||||
/* to specify the face ID and its size. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* cache :: A handle to the source sbit cache. */
|
||||
/* */
|
||||
/* scaler :: A pointer to the scaler descriptor. */
|
||||
/* */
|
||||
/* load_flags :: The corresponding load flags. */
|
||||
/* */
|
||||
/* gindex :: The glyph index. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* sbit :: A handle to a small bitmap descriptor. */
|
||||
/* */
|
||||
/* anode :: Used to return the address of the corresponding */
|
||||
/* cache node after incrementing its reference count */
|
||||
/* (see note below). */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The small bitmap descriptor and its bit buffer are owned by the */
|
||||
/* cache and should never be freed by the application. They might */
|
||||
/* as well disappear from memory on the next cache lookup, so don't */
|
||||
/* treat them as persistent data. */
|
||||
/* */
|
||||
/* The descriptor's `buffer' field is set to~0 to indicate a missing */
|
||||
/* glyph bitmap. */
|
||||
/* */
|
||||
/* If `anode' is _not_ NULL, it receives the address of the cache */
|
||||
/* node containing the bitmap, after increasing its reference count. */
|
||||
/* This ensures that the node (as well as the image) will always be */
|
||||
/* kept in the cache until you call @FTC_Node_Unref to `release' it. */
|
||||
/* */
|
||||
/* If `anode' is NULL, the cache node is left unchanged, which means */
|
||||
/* that the bitmap could be flushed out of the cache on the next */
|
||||
/* call to one of the caching sub-system APIs. Don't assume that it */
|
||||
/* is persistent! */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FTC_SBitCache_LookupScaler( FTC_SBitCache cache,
|
||||
FTC_Scaler scaler,
|
||||
FT_ULong load_flags,
|
||||
FT_UInt gindex,
|
||||
FTC_SBit *sbit,
|
||||
FTC_Node *anode );
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTCACHE_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,139 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* This file defines the structure of the FreeType reference. */
|
||||
/* It is used by the python script that generates the HTML files. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* <Chapter> */
|
||||
/* general_remarks */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* General Remarks */
|
||||
/* */
|
||||
/* <Sections> */
|
||||
/* header_inclusion */
|
||||
/* user_allocation */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* <Chapter> */
|
||||
/* core_api */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* Core API */
|
||||
/* */
|
||||
/* <Sections> */
|
||||
/* version */
|
||||
/* basic_types */
|
||||
/* base_interface */
|
||||
/* glyph_variants */
|
||||
/* glyph_management */
|
||||
/* mac_specific */
|
||||
/* sizes_management */
|
||||
/* header_file_macros */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* <Chapter> */
|
||||
/* format_specific */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* Format-Specific API */
|
||||
/* */
|
||||
/* <Sections> */
|
||||
/* multiple_masters */
|
||||
/* truetype_tables */
|
||||
/* type1_tables */
|
||||
/* sfnt_names */
|
||||
/* bdf_fonts */
|
||||
/* cid_fonts */
|
||||
/* pfr_fonts */
|
||||
/* winfnt_fonts */
|
||||
/* font_formats */
|
||||
/* gasp_table */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* <Chapter> */
|
||||
/* module_specific */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* Controlling FreeType Modules */
|
||||
/* */
|
||||
/* <Sections> */
|
||||
/* auto_hinter */
|
||||
/* cff_driver */
|
||||
/* t1_cid_driver */
|
||||
/* tt_driver */
|
||||
/* pcf_driver */
|
||||
/* properties */
|
||||
/* parameter_tags */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* <Chapter> */
|
||||
/* cache_subsystem */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* Cache Sub-System */
|
||||
/* */
|
||||
/* <Sections> */
|
||||
/* cache_subsystem */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* <Chapter> */
|
||||
/* support_api */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* Support API */
|
||||
/* */
|
||||
/* <Sections> */
|
||||
/* computations */
|
||||
/* list_processing */
|
||||
/* outline_processing */
|
||||
/* quick_advance */
|
||||
/* bitmap_handling */
|
||||
/* raster */
|
||||
/* glyph_stroker */
|
||||
/* system_interface */
|
||||
/* module_management */
|
||||
/* gzip */
|
||||
/* lzw */
|
||||
/* bzip2 */
|
||||
/* lcd_filtering */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* <Chapter> */
|
||||
/* error_codes */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* Error Codes */
|
||||
/* */
|
||||
/* <Sections> */
|
||||
/* error_enumerations */
|
||||
/* error_code_values */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
@@ -0,0 +1,168 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftcid.h */
|
||||
/* */
|
||||
/* FreeType API for accessing CID font information (specification). */
|
||||
/* */
|
||||
/* Copyright 2007-2018 by */
|
||||
/* Dereg Clegg and Michael Toftdal. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTCID_H_
|
||||
#define FTCID_H_
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#ifdef FREETYPE_H
|
||||
#error "freetype.h of FreeType 1 has been loaded!"
|
||||
#error "Please fix the directory search order for header files"
|
||||
#error "so that freetype.h of FreeType 2 is found first."
|
||||
#endif
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* cid_fonts */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* CID Fonts */
|
||||
/* */
|
||||
/* <Abstract> */
|
||||
/* CID-keyed font specific API. */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This section contains the declaration of CID-keyed font specific */
|
||||
/* functions. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Get_CID_Registry_Ordering_Supplement
|
||||
*
|
||||
* @description:
|
||||
* Retrieve the Registry/Ordering/Supplement triple (also known as the
|
||||
* "R/O/S") from a CID-keyed font.
|
||||
*
|
||||
* @input:
|
||||
* face ::
|
||||
* A handle to the input face.
|
||||
*
|
||||
* @output:
|
||||
* registry ::
|
||||
* The registry, as a C~string, owned by the face.
|
||||
*
|
||||
* ordering ::
|
||||
* The ordering, as a C~string, owned by the face.
|
||||
*
|
||||
* supplement ::
|
||||
* The supplement.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* This function only works with CID faces, returning an error
|
||||
* otherwise.
|
||||
*
|
||||
* @since:
|
||||
* 2.3.6
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Get_CID_Registry_Ordering_Supplement( FT_Face face,
|
||||
const char* *registry,
|
||||
const char* *ordering,
|
||||
FT_Int *supplement );
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Get_CID_Is_Internally_CID_Keyed
|
||||
*
|
||||
* @description:
|
||||
* Retrieve the type of the input face, CID keyed or not. In
|
||||
* contrast to the @FT_IS_CID_KEYED macro this function returns
|
||||
* successfully also for CID-keyed fonts in an SFNT wrapper.
|
||||
*
|
||||
* @input:
|
||||
* face ::
|
||||
* A handle to the input face.
|
||||
*
|
||||
* @output:
|
||||
* is_cid ::
|
||||
* The type of the face as an @FT_Bool.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* This function only works with CID faces and OpenType fonts,
|
||||
* returning an error otherwise.
|
||||
*
|
||||
* @since:
|
||||
* 2.3.9
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Get_CID_Is_Internally_CID_Keyed( FT_Face face,
|
||||
FT_Bool *is_cid );
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Get_CID_From_Glyph_Index
|
||||
*
|
||||
* @description:
|
||||
* Retrieve the CID of the input glyph index.
|
||||
*
|
||||
* @input:
|
||||
* face ::
|
||||
* A handle to the input face.
|
||||
*
|
||||
* glyph_index ::
|
||||
* The input glyph index.
|
||||
*
|
||||
* @output:
|
||||
* cid ::
|
||||
* The CID as an @FT_UInt.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* This function only works with CID faces and OpenType fonts,
|
||||
* returning an error otherwise.
|
||||
*
|
||||
* @since:
|
||||
* 2.3.9
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Get_CID_From_Glyph_Index( FT_Face face,
|
||||
FT_UInt glyph_index,
|
||||
FT_UInt *cid );
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTCID_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,1225 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftdriver.h */
|
||||
/* */
|
||||
/* FreeType API for controlling driver modules (specification only). */
|
||||
/* */
|
||||
/* Copyright 2017-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTDRIVER_H_
|
||||
#define FTDRIVER_H_
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_PARAMETER_TAGS_H
|
||||
|
||||
#ifdef FREETYPE_H
|
||||
#error "freetype.h of FreeType 1 has been loaded!"
|
||||
#error "Please fix the directory search order for header files"
|
||||
#error "so that freetype.h of FreeType 2 is found first."
|
||||
#endif
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @section:
|
||||
* auto_hinter
|
||||
*
|
||||
* @title:
|
||||
* The auto-hinter
|
||||
*
|
||||
* @abstract:
|
||||
* Controlling the auto-hinting module.
|
||||
*
|
||||
* @description:
|
||||
* While FreeType's auto-hinter doesn't expose API functions by itself,
|
||||
* it is possible to control its behaviour with @FT_Property_Set and
|
||||
* @FT_Property_Get. The following lists the available properties
|
||||
* together with the necessary macros and structures.
|
||||
*
|
||||
* Note that the auto-hinter's module name is `autofitter' for
|
||||
* historical reasons.
|
||||
*
|
||||
* Available properties are @increase-x-height, @no-stem-darkening
|
||||
* (experimental), @darkening-parameters (experimental), @warping
|
||||
* (experimental), @glyph-to-script-map (experimental), @fallback-script
|
||||
* (experimental), and @default-script (experimental), as documented in
|
||||
* the @properties section.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @section:
|
||||
* cff_driver
|
||||
*
|
||||
* @title:
|
||||
* The CFF driver
|
||||
*
|
||||
* @abstract:
|
||||
* Controlling the CFF driver module.
|
||||
*
|
||||
* @description:
|
||||
* While FreeType's CFF driver doesn't expose API functions by itself,
|
||||
* it is possible to control its behaviour with @FT_Property_Set and
|
||||
* @FT_Property_Get.
|
||||
*
|
||||
* The CFF driver's module name is `cff'.
|
||||
*
|
||||
* Available properties are @hinting-engine, @no-stem-darkening,
|
||||
* @darkening-parameters, and @random-seed, as documented in the
|
||||
* @properties section.
|
||||
*
|
||||
*
|
||||
* *Hinting* *and* *antialiasing* *principles* *of* *the* *new* *engine*
|
||||
*
|
||||
* The rasterizer is positioning horizontal features (e.g., ascender
|
||||
* height & x-height, or crossbars) on the pixel grid and minimizing the
|
||||
* amount of antialiasing applied to them, while placing vertical
|
||||
* features (vertical stems) on the pixel grid without hinting, thus
|
||||
* representing the stem position and weight accurately. Sometimes the
|
||||
* vertical stems may be only partially black. In this context,
|
||||
* `antialiasing' means that stems are not positioned exactly on pixel
|
||||
* borders, causing a fuzzy appearance.
|
||||
*
|
||||
* There are two principles behind this approach.
|
||||
*
|
||||
* 1) No hinting in the horizontal direction: Unlike `superhinted'
|
||||
* TrueType, which changes glyph widths to accommodate regular
|
||||
* inter-glyph spacing, Adobe's approach is `faithful to the design' in
|
||||
* representing both the glyph width and the inter-glyph spacing
|
||||
* designed for the font. This makes the screen display as close as it
|
||||
* can be to the result one would get with infinite resolution, while
|
||||
* preserving what is considered the key characteristics of each glyph.
|
||||
* Note that the distances between unhinted and grid-fitted positions at
|
||||
* small sizes are comparable to kerning values and thus would be
|
||||
* noticeable (and distracting) while reading if hinting were applied.
|
||||
*
|
||||
* One of the reasons to not hint horizontally is antialiasing for LCD
|
||||
* screens: The pixel geometry of modern displays supplies three
|
||||
* vertical subpixels as the eye moves horizontally across each visible
|
||||
* pixel. On devices where we can be certain this characteristic is
|
||||
* present a rasterizer can take advantage of the subpixels to add
|
||||
* increments of weight. In Western writing systems this turns out to
|
||||
* be the more critical direction anyway; the weights and spacing of
|
||||
* vertical stems (see above) are central to Armenian, Cyrillic, Greek,
|
||||
* and Latin type designs. Even when the rasterizer uses greyscale
|
||||
* antialiasing instead of color (a necessary compromise when one
|
||||
* doesn't know the screen characteristics), the unhinted vertical
|
||||
* features preserve the design's weight and spacing much better than
|
||||
* aliased type would.
|
||||
*
|
||||
* 2) Alignment in the vertical direction: Weights and spacing along the
|
||||
* y~axis are less critical; what is much more important is the visual
|
||||
* alignment of related features (like cap-height and x-height). The
|
||||
* sense of alignment for these is enhanced by the sharpness of grid-fit
|
||||
* edges, while the cruder vertical resolution (full pixels instead of
|
||||
* 1/3 pixels) is less of a problem.
|
||||
*
|
||||
* On the technical side, horizontal alignment zones for ascender,
|
||||
* x-height, and other important height values (traditionally called
|
||||
* `blue zones') as defined in the font are positioned independently,
|
||||
* each being rounded to the nearest pixel edge, taking care of
|
||||
* overshoot suppression at small sizes, stem darkening, and scaling.
|
||||
*
|
||||
* Hstems (this is, hint values defined in the font to help align
|
||||
* horizontal features) that fall within a blue zone are said to be
|
||||
* `captured' and are aligned to that zone. Uncaptured stems are moved
|
||||
* in one of four ways, top edge up or down, bottom edge up or down.
|
||||
* Unless there are conflicting hstems, the smallest movement is taken
|
||||
* to minimize distortion.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @section:
|
||||
* pcf_driver
|
||||
*
|
||||
* @title:
|
||||
* The PCF driver
|
||||
*
|
||||
* @abstract:
|
||||
* Controlling the PCF driver module.
|
||||
*
|
||||
* @description:
|
||||
* While FreeType's PCF driver doesn't expose API functions by itself,
|
||||
* it is possible to control its behaviour with @FT_Property_Set and
|
||||
* @FT_Property_Get. Right now, there is a single property
|
||||
* @no-long-family-names available if FreeType is compiled with
|
||||
* PCF_CONFIG_OPTION_LONG_FAMILY_NAMES.
|
||||
*
|
||||
* The PCF driver's module name is `pcf'.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @section:
|
||||
* t1_cid_driver
|
||||
*
|
||||
* @title:
|
||||
* The Type 1 and CID drivers
|
||||
*
|
||||
* @abstract:
|
||||
* Controlling the Type~1 and CID driver modules.
|
||||
*
|
||||
* @description:
|
||||
* It is possible to control the behaviour of FreeType's Type~1 and
|
||||
* Type~1 CID drivers with @FT_Property_Set and @FT_Property_Get.
|
||||
*
|
||||
* Behind the scenes, both drivers use the Adobe CFF engine for hinting;
|
||||
* however, the used properties must be specified separately.
|
||||
*
|
||||
* The Type~1 driver's module name is `type1'; the CID driver's module
|
||||
* name is `t1cid'.
|
||||
*
|
||||
* Available properties are @hinting-engine, @no-stem-darkening,
|
||||
* @darkening-parameters, and @random-seed, as documented in the
|
||||
* @properties section.
|
||||
*
|
||||
* Please see the @cff_driver section for more details on the new
|
||||
* hinting engine.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @section:
|
||||
* tt_driver
|
||||
*
|
||||
* @title:
|
||||
* The TrueType driver
|
||||
*
|
||||
* @abstract:
|
||||
* Controlling the TrueType driver module.
|
||||
*
|
||||
* @description:
|
||||
* While FreeType's TrueType driver doesn't expose API functions by
|
||||
* itself, it is possible to control its behaviour with @FT_Property_Set
|
||||
* and @FT_Property_Get. The following lists the available properties
|
||||
* together with the necessary macros and structures.
|
||||
*
|
||||
* The TrueType driver's module name is `truetype'.
|
||||
*
|
||||
* A single property @interpreter-version is available, as documented in
|
||||
* the @properties section.
|
||||
*
|
||||
* We start with a list of definitions, kindly provided by Greg
|
||||
* Hitchcock.
|
||||
*
|
||||
* _Bi-Level_ _Rendering_
|
||||
*
|
||||
* Monochromatic rendering, exclusively used in the early days of
|
||||
* TrueType by both Apple and Microsoft. Microsoft's GDI interface
|
||||
* supported hinting of the right-side bearing point, such that the
|
||||
* advance width could be non-linear. Most often this was done to
|
||||
* achieve some level of glyph symmetry. To enable reasonable
|
||||
* performance (e.g., not having to run hinting on all glyphs just to
|
||||
* get the widths) there was a bit in the head table indicating if the
|
||||
* side bearing was hinted, and additional tables, `hdmx' and `LTSH', to
|
||||
* cache hinting widths across multiple sizes and device aspect ratios.
|
||||
*
|
||||
* _Font_ _Smoothing_
|
||||
*
|
||||
* Microsoft's GDI implementation of anti-aliasing. Not traditional
|
||||
* anti-aliasing as the outlines were hinted before the sampling. The
|
||||
* widths matched the bi-level rendering.
|
||||
*
|
||||
* _ClearType_ _Rendering_
|
||||
*
|
||||
* Technique that uses physical subpixels to improve rendering on LCD
|
||||
* (and other) displays. Because of the higher resolution, many methods
|
||||
* of improving symmetry in glyphs through hinting the right-side
|
||||
* bearing were no longer necessary. This lead to what GDI calls
|
||||
* `natural widths' ClearType, see
|
||||
* http://www.beatstamm.com/typography/RTRCh4.htm#Sec21. Since hinting
|
||||
* has extra resolution, most non-linearity went away, but it is still
|
||||
* possible for hints to change the advance widths in this mode.
|
||||
*
|
||||
* _ClearType_ _Compatible_ _Widths_
|
||||
*
|
||||
* One of the earliest challenges with ClearType was allowing the
|
||||
* implementation in GDI to be selected without requiring all UI and
|
||||
* documents to reflow. To address this, a compatible method of
|
||||
* rendering ClearType was added where the font hints are executed once
|
||||
* to determine the width in bi-level rendering, and then re-run in
|
||||
* ClearType, with the difference in widths being absorbed in the font
|
||||
* hints for ClearType (mostly in the white space of hints); see
|
||||
* http://www.beatstamm.com/typography/RTRCh4.htm#Sec20. Somewhat by
|
||||
* definition, compatible width ClearType allows for non-linear widths,
|
||||
* but only when the bi-level version has non-linear widths.
|
||||
*
|
||||
* _ClearType_ _Subpixel_ _Positioning_
|
||||
*
|
||||
* One of the nice benefits of ClearType is the ability to more crisply
|
||||
* display fractional widths; unfortunately, the GDI model of integer
|
||||
* bitmaps did not support this. However, the WPF and Direct Write
|
||||
* frameworks do support fractional widths. DWrite calls this `natural
|
||||
* mode', not to be confused with GDI's `natural widths'. Subpixel
|
||||
* positioning, in the current implementation of Direct Write,
|
||||
* unfortunately does not support hinted advance widths, see
|
||||
* http://www.beatstamm.com/typography/RTRCh4.htm#Sec22. Note that the
|
||||
* TrueType interpreter fully allows the advance width to be adjusted in
|
||||
* this mode, just the DWrite client will ignore those changes.
|
||||
*
|
||||
* _ClearType_ _Backward_ _Compatibility_
|
||||
*
|
||||
* This is a set of exceptions made in the TrueType interpreter to
|
||||
* minimize hinting techniques that were problematic with the extra
|
||||
* resolution of ClearType; see
|
||||
* http://www.beatstamm.com/typography/RTRCh4.htm#Sec1 and
|
||||
* https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx.
|
||||
* This technique is not to be confused with ClearType compatible
|
||||
* widths. ClearType backward compatibility has no direct impact on
|
||||
* changing advance widths, but there might be an indirect impact on
|
||||
* disabling some deltas. This could be worked around in backward
|
||||
* compatibility mode.
|
||||
*
|
||||
* _Native_ _ClearType_ _Mode_
|
||||
*
|
||||
* (Not to be confused with `natural widths'.) This mode removes all
|
||||
* the exceptions in the TrueType interpreter when running with
|
||||
* ClearType. Any issues on widths would still apply, though.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @section:
|
||||
* properties
|
||||
*
|
||||
* @title:
|
||||
* Driver properties
|
||||
*
|
||||
* @abstract:
|
||||
* Controlling driver modules.
|
||||
*
|
||||
* @description:
|
||||
* Driver modules can be controlled by setting and unsetting properties,
|
||||
* using the functions @FT_Property_Set and @FT_Property_Get. This
|
||||
* section documents the available properties, together with auxiliary
|
||||
* macros and structures.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @enum:
|
||||
* FT_HINTING_XXX
|
||||
*
|
||||
* @description:
|
||||
* A list of constants used for the @hinting-engine property to
|
||||
* select the hinting engine for CFF, Type~1, and CID fonts.
|
||||
*
|
||||
* @values:
|
||||
* FT_HINTING_FREETYPE ::
|
||||
* Use the old FreeType hinting engine.
|
||||
*
|
||||
* FT_HINTING_ADOBE ::
|
||||
* Use the hinting engine contributed by Adobe.
|
||||
*
|
||||
* @since:
|
||||
* 2.9
|
||||
*
|
||||
*/
|
||||
#define FT_HINTING_FREETYPE 0
|
||||
#define FT_HINTING_ADOBE 1
|
||||
|
||||
/* these constants (introduced in 2.4.12) are deprecated */
|
||||
#define FT_CFF_HINTING_FREETYPE FT_HINTING_FREETYPE
|
||||
#define FT_CFF_HINTING_ADOBE FT_HINTING_ADOBE
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @property:
|
||||
* hinting-engine
|
||||
*
|
||||
* @description:
|
||||
* Thanks to Adobe, which contributed a new hinting (and parsing)
|
||||
* engine, an application can select between `freetype' and `adobe' if
|
||||
* compiled with CFF_CONFIG_OPTION_OLD_ENGINE. If this configuration
|
||||
* macro isn't defined, `hinting-engine' does nothing.
|
||||
*
|
||||
* The same holds for the Type~1 and CID modules if compiled with
|
||||
* T1_CONFIG_OPTION_OLD_ENGINE.
|
||||
*
|
||||
* For the `cff' module, the default engine is `freetype' if
|
||||
* CFF_CONFIG_OPTION_OLD_ENGINE is defined, and `adobe' otherwise.
|
||||
*
|
||||
* For both the `type1' and `t1cid' modules, the default engine is
|
||||
* `freetype' if T1_CONFIG_OPTION_OLD_ENGINE is defined, and `adobe'
|
||||
* otherwise.
|
||||
*
|
||||
* The following example code demonstrates how to select Adobe's hinting
|
||||
* engine for the `cff' module (omitting the error handling).
|
||||
*
|
||||
* {
|
||||
* FT_Library library;
|
||||
* FT_UInt hinting_engine = FT_CFF_HINTING_ADOBE;
|
||||
*
|
||||
*
|
||||
* FT_Init_FreeType( &library );
|
||||
*
|
||||
* FT_Property_Set( library, "cff",
|
||||
* "hinting-engine", &hinting_engine );
|
||||
* }
|
||||
*
|
||||
* @note:
|
||||
* This property can be used with @FT_Property_Get also.
|
||||
*
|
||||
* This property can be set via the `FREETYPE_PROPERTIES' environment
|
||||
* variable (using values `adobe' or `freetype').
|
||||
*
|
||||
* @since:
|
||||
* 2.4.12 (for `cff' module)
|
||||
*
|
||||
* 2.9 (for `type1' and `t1cid' modules)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @property:
|
||||
* no-stem-darkening
|
||||
*
|
||||
* @description:
|
||||
* All glyphs that pass through the auto-hinter will be emboldened
|
||||
* unless this property is set to TRUE. The same is true for the CFF,
|
||||
* Type~1, and CID font modules if the `Adobe' engine is selected (which
|
||||
* is the default).
|
||||
*
|
||||
* Stem darkening emboldens glyphs at smaller sizes to make them more
|
||||
* readable on common low-DPI screens when using linear alpha blending
|
||||
* and gamma correction, see @FT_Render_Glyph. When not using linear
|
||||
* alpha blending and gamma correction, glyphs will appear heavy and
|
||||
* fuzzy!
|
||||
*
|
||||
* Gamma correction essentially lightens fonts since shades of grey are
|
||||
* shifted to higher pixel values (=~higher brightness) to match the
|
||||
* original intention to the reality of our screens. The side-effect is
|
||||
* that glyphs `thin out'. Mac OS~X and Adobe's proprietary font
|
||||
* rendering library implement a counter-measure: stem darkening at
|
||||
* smaller sizes where shades of gray dominate. By emboldening a glyph
|
||||
* slightly in relation to its pixel size, individual pixels get higher
|
||||
* coverage of filled-in outlines and are therefore `blacker'. This
|
||||
* counteracts the `thinning out' of glyphs, making text remain readable
|
||||
* at smaller sizes.
|
||||
*
|
||||
* By default, the Adobe engines for CFF, Type~1, and CID fonts darken
|
||||
* stems at smaller sizes, regardless of hinting, to enhance contrast.
|
||||
* Setting this property, stem darkening gets switched off.
|
||||
*
|
||||
* For the auto-hinter, stem-darkening is experimental currently and
|
||||
* thus switched off by default (this is, `no-stem-darkening' is set to
|
||||
* TRUE by default). Total consistency with the CFF driver is not
|
||||
* achieved right now because the emboldening method differs and glyphs
|
||||
* must be scaled down on the Y-axis to keep outline points inside their
|
||||
* precomputed blue zones. The smaller the size (especially 9ppem and
|
||||
* down), the higher the loss of emboldening versus the CFF driver.
|
||||
*
|
||||
* Note that stem darkening is never applied if @FT_LOAD_NO_SCALE is
|
||||
* set.
|
||||
*
|
||||
* {
|
||||
* FT_Library library;
|
||||
* FT_Bool no_stem_darkening = TRUE;
|
||||
*
|
||||
*
|
||||
* FT_Init_FreeType( &library );
|
||||
*
|
||||
* FT_Property_Set( library, "cff",
|
||||
* "no-stem-darkening", &no_stem_darkening );
|
||||
* }
|
||||
*
|
||||
* @note:
|
||||
* This property can be used with @FT_Property_Get also.
|
||||
*
|
||||
* This property can be set via the `FREETYPE_PROPERTIES' environment
|
||||
* variable (using values 1 and 0 for `on' and `off', respectively).
|
||||
* It can also be set per face using @FT_Face_Properties with
|
||||
* @FT_PARAM_TAG_STEM_DARKENING.
|
||||
*
|
||||
* @since:
|
||||
* 2.4.12 (for `cff' module)
|
||||
*
|
||||
* 2.6.2 (for `autofitter' module)
|
||||
*
|
||||
* 2.9 (for `type1' and `t1cid' modules)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @property:
|
||||
* darkening-parameters
|
||||
*
|
||||
* @description:
|
||||
* By default, the Adobe hinting engine, as used by the CFF, Type~1, and
|
||||
* CID font drivers, darkens stems as follows (if the
|
||||
* `no-stem-darkening' property isn't set):
|
||||
*
|
||||
* {
|
||||
* stem width <= 0.5px: darkening amount = 0.4px
|
||||
* stem width = 1px: darkening amount = 0.275px
|
||||
* stem width = 1.667px: darkening amount = 0.275px
|
||||
* stem width >= 2.333px: darkening amount = 0px
|
||||
* }
|
||||
*
|
||||
* and piecewise linear in-between. At configuration time, these four
|
||||
* control points can be set with the macro
|
||||
* `CFF_CONFIG_OPTION_DARKENING_PARAMETERS'; the CFF, Type~1, and CID
|
||||
* drivers share these values. At runtime, the control points can be
|
||||
* changed using the `darkening-parameters' property, as the following
|
||||
* example demonstrates for the Type~1 driver.
|
||||
*
|
||||
* {
|
||||
* FT_Library library;
|
||||
* FT_Int darken_params[8] = { 500, 300, // x1, y1
|
||||
* 1000, 200, // x2, y2
|
||||
* 1500, 100, // x3, y3
|
||||
* 2000, 0 }; // x4, y4
|
||||
*
|
||||
*
|
||||
* FT_Init_FreeType( &library );
|
||||
*
|
||||
* FT_Property_Set( library, "type1",
|
||||
* "darkening-parameters", darken_params );
|
||||
* }
|
||||
*
|
||||
* The x~values give the stem width, and the y~values the darkening
|
||||
* amount. The unit is 1000th of pixels. All coordinate values must be
|
||||
* positive; the x~values must be monotonically increasing; the
|
||||
* y~values must be monotonically decreasing and smaller than or
|
||||
* equal to 500 (corresponding to half a pixel); the slope of each
|
||||
* linear piece must be shallower than -1 (e.g., -.4).
|
||||
*
|
||||
* The auto-hinter provides this property, too, as an experimental
|
||||
* feature. See @no-stem-darkening for more.
|
||||
*
|
||||
* @note:
|
||||
* This property can be used with @FT_Property_Get also.
|
||||
*
|
||||
* This property can be set via the `FREETYPE_PROPERTIES' environment
|
||||
* variable, using eight comma-separated integers without spaces. Here
|
||||
* the above example, using `\' to break the line for readability.
|
||||
*
|
||||
* {
|
||||
* FREETYPE_PROPERTIES=\
|
||||
* type1:darkening-parameters=500,300,1000,200,1500,100,2000,0
|
||||
* }
|
||||
*
|
||||
* @since:
|
||||
* 2.5.1 (for `cff' module)
|
||||
*
|
||||
* 2.6.2 (for `autofitter' module)
|
||||
*
|
||||
* 2.9 (for `type1' and `t1cid' modules)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @property:
|
||||
* random-seed
|
||||
*
|
||||
* @description:
|
||||
* By default, the seed value for the CFF `random' operator and the
|
||||
* similar `0 28 callothersubr pop' command for the Type~1 and CID
|
||||
* drivers is set to a random value. However, mainly for debugging
|
||||
* purposes, it is often necessary to use a known value as a seed so
|
||||
* that the pseudo-random number sequences generated by `random' are
|
||||
* repeatable.
|
||||
*
|
||||
* The `random-seed' property does that. Its argument is a signed 32bit
|
||||
* integer; if the value is zero or negative, the seed given by the
|
||||
* `intitialRandomSeed' private DICT operator in a CFF file gets used
|
||||
* (or a default value if there is no such operator). If the value is
|
||||
* positive, use it instead of `initialRandomSeed', which is
|
||||
* consequently ignored.
|
||||
*
|
||||
* @note:
|
||||
* This property can be set via the `FREETYPE_PROPERTIES' environment
|
||||
* variable. It can also be set per face using @FT_Face_Properties with
|
||||
* @FT_PARAM_TAG_RANDOM_SEED.
|
||||
*
|
||||
* @since:
|
||||
* 2.8 (for `cff' module)
|
||||
*
|
||||
* 2.9 (for `type1' and `t1cid' modules)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @property:
|
||||
* no-long-family-names
|
||||
*
|
||||
* @description:
|
||||
* If PCF_CONFIG_OPTION_LONG_FAMILY_NAMES is active while compiling
|
||||
* FreeType, the PCF driver constructs long family names.
|
||||
*
|
||||
* There are many PCF fonts just called `Fixed' which look completely
|
||||
* different, and which have nothing to do with each other. When
|
||||
* selecting `Fixed' in KDE or Gnome one gets results that appear rather
|
||||
* random, the style changes often if one changes the size and one
|
||||
* cannot select some fonts at all. The improve this situation, the PCF
|
||||
* module prepends the foundry name (plus a space) to the family name.
|
||||
* It also checks whether there are `wide' characters; all put together,
|
||||
* family names like `Sony Fixed' or `Misc Fixed Wide' are constructed.
|
||||
*
|
||||
* If `no-long-family-names' is set, this feature gets switched off.
|
||||
*
|
||||
* {
|
||||
* FT_Library library;
|
||||
* FT_Bool no_long_family_names = TRUE;
|
||||
*
|
||||
*
|
||||
* FT_Init_FreeType( &library );
|
||||
*
|
||||
* FT_Property_Set( library, "pcf",
|
||||
* "no-long-family-names",
|
||||
* &no_long_family_names );
|
||||
* }
|
||||
*
|
||||
* @note:
|
||||
* This property can be used with @FT_Property_Get also.
|
||||
*
|
||||
* This property can be set via the `FREETYPE_PROPERTIES' environment
|
||||
* variable (using values 1 and 0 for `on' and `off', respectively).
|
||||
*
|
||||
* @since:
|
||||
* 2.8
|
||||
*/
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @enum:
|
||||
* TT_INTERPRETER_VERSION_XXX
|
||||
*
|
||||
* @description:
|
||||
* A list of constants used for the @interpreter-version property to
|
||||
* select the hinting engine for Truetype fonts.
|
||||
*
|
||||
* The numeric value in the constant names represents the version
|
||||
* number as returned by the `GETINFO' bytecode instruction.
|
||||
*
|
||||
* @values:
|
||||
* TT_INTERPRETER_VERSION_35 ::
|
||||
* Version~35 corresponds to MS rasterizer v.1.7 as used e.g. in
|
||||
* Windows~98; only grayscale and B/W rasterizing is supported.
|
||||
*
|
||||
* TT_INTERPRETER_VERSION_38 ::
|
||||
* Version~38 corresponds to MS rasterizer v.1.9; it is roughly
|
||||
* equivalent to the hinting provided by DirectWrite ClearType (as can
|
||||
* be found, for example, in the Internet Explorer~9 running on
|
||||
* Windows~7). It is used in FreeType to select the `Infinality'
|
||||
* subpixel hinting code. The code may be removed in a future
|
||||
* version.
|
||||
*
|
||||
* TT_INTERPRETER_VERSION_40 ::
|
||||
* Version~40 corresponds to MS rasterizer v.2.1; it is roughly
|
||||
* equivalent to the hinting provided by DirectWrite ClearType (as can
|
||||
* be found, for example, in Microsoft's Edge Browser on Windows~10).
|
||||
* It is used in FreeType to select the `minimal' subpixel hinting
|
||||
* code, a stripped-down and higher performance version of the
|
||||
* `Infinality' code.
|
||||
*
|
||||
* @note:
|
||||
* This property controls the behaviour of the bytecode interpreter
|
||||
* and thus how outlines get hinted. It does *not* control how glyph
|
||||
* get rasterized! In particular, it does not control subpixel color
|
||||
* filtering.
|
||||
*
|
||||
* If FreeType has not been compiled with the configuration option
|
||||
* TT_CONFIG_OPTION_SUBPIXEL_HINTING, selecting version~38 or~40 causes
|
||||
* an `FT_Err_Unimplemented_Feature' error.
|
||||
*
|
||||
* Depending on the graphics framework, Microsoft uses different
|
||||
* bytecode and rendering engines. As a consequence, the version
|
||||
* numbers returned by a call to the `GETINFO' bytecode instruction are
|
||||
* more convoluted than desired.
|
||||
*
|
||||
* Here are two tables that try to shed some light on the possible
|
||||
* values for the MS rasterizer engine, together with the additional
|
||||
* features introduced by it.
|
||||
*
|
||||
* {
|
||||
* GETINFO framework version feature
|
||||
* -------------------------------------------------------------------
|
||||
* 3 GDI (Win 3.1), v1.0 16-bit, first version
|
||||
* TrueImage
|
||||
* 33 GDI (Win NT 3.1), v1.5 32-bit
|
||||
* HP Laserjet
|
||||
* 34 GDI (Win 95) v1.6 font smoothing,
|
||||
* new SCANTYPE opcode
|
||||
* 35 GDI (Win 98/2000) v1.7 (UN)SCALED_COMPONENT_OFFSET
|
||||
* bits in composite glyphs
|
||||
* 36 MGDI (Win CE 2) v1.6+ classic ClearType
|
||||
* 37 GDI (XP and later), v1.8 ClearType
|
||||
* GDI+ old (before Vista)
|
||||
* 38 GDI+ old (Vista, Win 7), v1.9 subpixel ClearType,
|
||||
* WPF Y-direction ClearType,
|
||||
* additional error checking
|
||||
* 39 DWrite (before Win 8) v2.0 subpixel ClearType flags
|
||||
* in GETINFO opcode,
|
||||
* bug fixes
|
||||
* 40 GDI+ (after Win 7), v2.1 Y-direction ClearType flag
|
||||
* DWrite (Win 8) in GETINFO opcode,
|
||||
* Gray ClearType
|
||||
* }
|
||||
*
|
||||
* The `version' field gives a rough orientation only, since some
|
||||
* applications provided certain features much earlier (as an example,
|
||||
* Microsoft Reader used subpixel and Y-direction ClearType already in
|
||||
* Windows 2000). Similarly, updates to a given framework might include
|
||||
* improved hinting support.
|
||||
*
|
||||
* {
|
||||
* version sampling rendering comment
|
||||
* x y x y
|
||||
* --------------------------------------------------------------
|
||||
* v1.0 normal normal B/W B/W bi-level
|
||||
* v1.6 high high gray gray grayscale
|
||||
* v1.8 high normal color-filter B/W (GDI) ClearType
|
||||
* v1.9 high high color-filter gray Color ClearType
|
||||
* v2.1 high normal gray B/W Gray ClearType
|
||||
* v2.1 high high gray gray Gray ClearType
|
||||
* }
|
||||
*
|
||||
* Color and Gray ClearType are the two available variants of
|
||||
* `Y-direction ClearType', meaning grayscale rasterization along the
|
||||
* Y-direction; the name used in the TrueType specification for this
|
||||
* feature is `symmetric smoothing'. `Classic ClearType' is the
|
||||
* original algorithm used before introducing a modified version in
|
||||
* Win~XP. Another name for v1.6's grayscale rendering is `font
|
||||
* smoothing', and `Color ClearType' is sometimes also called `DWrite
|
||||
* ClearType'. To differentiate between today's Color ClearType and the
|
||||
* earlier ClearType variant with B/W rendering along the vertical axis,
|
||||
* the latter is sometimes called `GDI ClearType'.
|
||||
*
|
||||
* `Normal' and `high' sampling describe the (virtual) resolution to
|
||||
* access the rasterized outline after the hinting process. `Normal'
|
||||
* means 1 sample per grid line (i.e., B/W). In the current Microsoft
|
||||
* implementation, `high' means an extra virtual resolution of 16x16 (or
|
||||
* 16x1) grid lines per pixel for bytecode instructions like `MIRP'.
|
||||
* After hinting, these 16 grid lines are mapped to 6x5 (or 6x1) grid
|
||||
* lines for color filtering if Color ClearType is activated.
|
||||
*
|
||||
* Note that `Gray ClearType' is essentially the same as v1.6's
|
||||
* grayscale rendering. However, the GETINFO instruction handles it
|
||||
* differently: v1.6 returns bit~12 (hinting for grayscale), while v2.1
|
||||
* returns bits~13 (hinting for ClearType), 18 (symmetrical smoothing),
|
||||
* and~19 (Gray ClearType). Also, this mode respects bits 2 and~3 for
|
||||
* the version~1 gasp table exclusively (like Color ClearType), while
|
||||
* v1.6 only respects the values of version~0 (bits 0 and~1).
|
||||
*
|
||||
* Keep in mind that the features of the above interpreter versions
|
||||
* might not map exactly to FreeType features or behavior because it is
|
||||
* a fundamentally different library with different internals.
|
||||
*
|
||||
*/
|
||||
#define TT_INTERPRETER_VERSION_35 35
|
||||
#define TT_INTERPRETER_VERSION_38 38
|
||||
#define TT_INTERPRETER_VERSION_40 40
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @property:
|
||||
* interpreter-version
|
||||
*
|
||||
* @description:
|
||||
* Currently, three versions are available, two representing the
|
||||
* bytecode interpreter with subpixel hinting support (old `Infinality'
|
||||
* code and new stripped-down and higher performance `minimal' code) and
|
||||
* one without, respectively. The default is subpixel support if
|
||||
* TT_CONFIG_OPTION_SUBPIXEL_HINTING is defined, and no subpixel support
|
||||
* otherwise (since it isn't available then).
|
||||
*
|
||||
* If subpixel hinting is on, many TrueType bytecode instructions behave
|
||||
* differently compared to B/W or grayscale rendering (except if `native
|
||||
* ClearType' is selected by the font). Microsoft's main idea is to
|
||||
* render at a much increased horizontal resolution, then sampling down
|
||||
* the created output to subpixel precision. However, many older fonts
|
||||
* are not suited to this and must be specially taken care of by
|
||||
* applying (hardcoded) tweaks in Microsoft's interpreter.
|
||||
*
|
||||
* Details on subpixel hinting and some of the necessary tweaks can be
|
||||
* found in Greg Hitchcock's whitepaper at
|
||||
* `https://www.microsoft.com/typography/cleartype/truetypecleartype.aspx'.
|
||||
* Note that FreeType currently doesn't really `subpixel hint' (6x1, 6x2,
|
||||
* or 6x5 supersampling) like discussed in the paper. Depending on the
|
||||
* chosen interpreter, it simply ignores instructions on vertical stems
|
||||
* to arrive at very similar results.
|
||||
*
|
||||
* The following example code demonstrates how to deactivate subpixel
|
||||
* hinting (omitting the error handling).
|
||||
*
|
||||
* {
|
||||
* FT_Library library;
|
||||
* FT_Face face;
|
||||
* FT_UInt interpreter_version = TT_INTERPRETER_VERSION_35;
|
||||
*
|
||||
*
|
||||
* FT_Init_FreeType( &library );
|
||||
*
|
||||
* FT_Property_Set( library, "truetype",
|
||||
* "interpreter-version",
|
||||
* &interpreter_version );
|
||||
* }
|
||||
*
|
||||
* @note:
|
||||
* This property can be used with @FT_Property_Get also.
|
||||
*
|
||||
* This property can be set via the `FREETYPE_PROPERTIES' environment
|
||||
* variable (using values `35', `38', or `40').
|
||||
*
|
||||
* @since:
|
||||
* 2.5
|
||||
*/
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @property:
|
||||
* glyph-to-script-map
|
||||
*
|
||||
* @description:
|
||||
* *Experimental* *only*
|
||||
*
|
||||
* The auto-hinter provides various script modules to hint glyphs.
|
||||
* Examples of supported scripts are Latin or CJK. Before a glyph is
|
||||
* auto-hinted, the Unicode character map of the font gets examined, and
|
||||
* the script is then determined based on Unicode character ranges, see
|
||||
* below.
|
||||
*
|
||||
* OpenType fonts, however, often provide much more glyphs than
|
||||
* character codes (small caps, superscripts, ligatures, swashes, etc.),
|
||||
* to be controlled by so-called `features'. Handling OpenType features
|
||||
* can be quite complicated and thus needs a separate library on top of
|
||||
* FreeType.
|
||||
*
|
||||
* The mapping between glyph indices and scripts (in the auto-hinter
|
||||
* sense, see the @FT_AUTOHINTER_SCRIPT_XXX values) is stored as an
|
||||
* array with `num_glyphs' elements, as found in the font's @FT_Face
|
||||
* structure. The `glyph-to-script-map' property returns a pointer to
|
||||
* this array, which can be modified as needed. Note that the
|
||||
* modification should happen before the first glyph gets processed by
|
||||
* the auto-hinter so that the global analysis of the font shapes
|
||||
* actually uses the modified mapping.
|
||||
*
|
||||
* The following example code demonstrates how to access it (omitting
|
||||
* the error handling).
|
||||
*
|
||||
* {
|
||||
* FT_Library library;
|
||||
* FT_Face face;
|
||||
* FT_Prop_GlyphToScriptMap prop;
|
||||
*
|
||||
*
|
||||
* FT_Init_FreeType( &library );
|
||||
* FT_New_Face( library, "foo.ttf", 0, &face );
|
||||
*
|
||||
* prop.face = face;
|
||||
*
|
||||
* FT_Property_Get( library, "autofitter",
|
||||
* "glyph-to-script-map", &prop );
|
||||
*
|
||||
* // adjust `prop.map' as needed right here
|
||||
*
|
||||
* FT_Load_Glyph( face, ..., FT_LOAD_FORCE_AUTOHINT );
|
||||
* }
|
||||
*
|
||||
* @since:
|
||||
* 2.4.11
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @enum:
|
||||
* FT_AUTOHINTER_SCRIPT_XXX
|
||||
*
|
||||
* @description:
|
||||
* *Experimental* *only*
|
||||
*
|
||||
* A list of constants used for the @glyph-to-script-map property to
|
||||
* specify the script submodule the auto-hinter should use for hinting a
|
||||
* particular glyph.
|
||||
*
|
||||
* @values:
|
||||
* FT_AUTOHINTER_SCRIPT_NONE ::
|
||||
* Don't auto-hint this glyph.
|
||||
*
|
||||
* FT_AUTOHINTER_SCRIPT_LATIN ::
|
||||
* Apply the latin auto-hinter. For the auto-hinter, `latin' is a
|
||||
* very broad term, including Cyrillic and Greek also since characters
|
||||
* from those scripts share the same design constraints.
|
||||
*
|
||||
* By default, characters from the following Unicode ranges are
|
||||
* assigned to this submodule.
|
||||
*
|
||||
* {
|
||||
* U+0020 - U+007F // Basic Latin (no control characters)
|
||||
* U+00A0 - U+00FF // Latin-1 Supplement (no control characters)
|
||||
* U+0100 - U+017F // Latin Extended-A
|
||||
* U+0180 - U+024F // Latin Extended-B
|
||||
* U+0250 - U+02AF // IPA Extensions
|
||||
* U+02B0 - U+02FF // Spacing Modifier Letters
|
||||
* U+0300 - U+036F // Combining Diacritical Marks
|
||||
* U+0370 - U+03FF // Greek and Coptic
|
||||
* U+0400 - U+04FF // Cyrillic
|
||||
* U+0500 - U+052F // Cyrillic Supplement
|
||||
* U+1D00 - U+1D7F // Phonetic Extensions
|
||||
* U+1D80 - U+1DBF // Phonetic Extensions Supplement
|
||||
* U+1DC0 - U+1DFF // Combining Diacritical Marks Supplement
|
||||
* U+1E00 - U+1EFF // Latin Extended Additional
|
||||
* U+1F00 - U+1FFF // Greek Extended
|
||||
* U+2000 - U+206F // General Punctuation
|
||||
* U+2070 - U+209F // Superscripts and Subscripts
|
||||
* U+20A0 - U+20CF // Currency Symbols
|
||||
* U+2150 - U+218F // Number Forms
|
||||
* U+2460 - U+24FF // Enclosed Alphanumerics
|
||||
* U+2C60 - U+2C7F // Latin Extended-C
|
||||
* U+2DE0 - U+2DFF // Cyrillic Extended-A
|
||||
* U+2E00 - U+2E7F // Supplemental Punctuation
|
||||
* U+A640 - U+A69F // Cyrillic Extended-B
|
||||
* U+A720 - U+A7FF // Latin Extended-D
|
||||
* U+FB00 - U+FB06 // Alphab. Present. Forms (Latin Ligatures)
|
||||
* U+1D400 - U+1D7FF // Mathematical Alphanumeric Symbols
|
||||
* U+1F100 - U+1F1FF // Enclosed Alphanumeric Supplement
|
||||
* }
|
||||
*
|
||||
* FT_AUTOHINTER_SCRIPT_CJK ::
|
||||
* Apply the CJK auto-hinter, covering Chinese, Japanese, Korean, old
|
||||
* Vietnamese, and some other scripts.
|
||||
*
|
||||
* By default, characters from the following Unicode ranges are
|
||||
* assigned to this submodule.
|
||||
*
|
||||
* {
|
||||
* U+1100 - U+11FF // Hangul Jamo
|
||||
* U+2E80 - U+2EFF // CJK Radicals Supplement
|
||||
* U+2F00 - U+2FDF // Kangxi Radicals
|
||||
* U+2FF0 - U+2FFF // Ideographic Description Characters
|
||||
* U+3000 - U+303F // CJK Symbols and Punctuation
|
||||
* U+3040 - U+309F // Hiragana
|
||||
* U+30A0 - U+30FF // Katakana
|
||||
* U+3100 - U+312F // Bopomofo
|
||||
* U+3130 - U+318F // Hangul Compatibility Jamo
|
||||
* U+3190 - U+319F // Kanbun
|
||||
* U+31A0 - U+31BF // Bopomofo Extended
|
||||
* U+31C0 - U+31EF // CJK Strokes
|
||||
* U+31F0 - U+31FF // Katakana Phonetic Extensions
|
||||
* U+3200 - U+32FF // Enclosed CJK Letters and Months
|
||||
* U+3300 - U+33FF // CJK Compatibility
|
||||
* U+3400 - U+4DBF // CJK Unified Ideographs Extension A
|
||||
* U+4DC0 - U+4DFF // Yijing Hexagram Symbols
|
||||
* U+4E00 - U+9FFF // CJK Unified Ideographs
|
||||
* U+A960 - U+A97F // Hangul Jamo Extended-A
|
||||
* U+AC00 - U+D7AF // Hangul Syllables
|
||||
* U+D7B0 - U+D7FF // Hangul Jamo Extended-B
|
||||
* U+F900 - U+FAFF // CJK Compatibility Ideographs
|
||||
* U+FE10 - U+FE1F // Vertical forms
|
||||
* U+FE30 - U+FE4F // CJK Compatibility Forms
|
||||
* U+FF00 - U+FFEF // Halfwidth and Fullwidth Forms
|
||||
* U+1B000 - U+1B0FF // Kana Supplement
|
||||
* U+1D300 - U+1D35F // Tai Xuan Hing Symbols
|
||||
* U+1F200 - U+1F2FF // Enclosed Ideographic Supplement
|
||||
* U+20000 - U+2A6DF // CJK Unified Ideographs Extension B
|
||||
* U+2A700 - U+2B73F // CJK Unified Ideographs Extension C
|
||||
* U+2B740 - U+2B81F // CJK Unified Ideographs Extension D
|
||||
* U+2F800 - U+2FA1F // CJK Compatibility Ideographs Supplement
|
||||
* }
|
||||
*
|
||||
* FT_AUTOHINTER_SCRIPT_INDIC ::
|
||||
* Apply the indic auto-hinter, covering all major scripts from the
|
||||
* Indian sub-continent and some other related scripts like Thai, Lao,
|
||||
* or Tibetan.
|
||||
*
|
||||
* By default, characters from the following Unicode ranges are
|
||||
* assigned to this submodule.
|
||||
*
|
||||
* {
|
||||
* U+0900 - U+0DFF // Indic Range
|
||||
* U+0F00 - U+0FFF // Tibetan
|
||||
* U+1900 - U+194F // Limbu
|
||||
* U+1B80 - U+1BBF // Sundanese
|
||||
* U+A800 - U+A82F // Syloti Nagri
|
||||
* U+ABC0 - U+ABFF // Meetei Mayek
|
||||
* U+11800 - U+118DF // Sharada
|
||||
* }
|
||||
*
|
||||
* Note that currently Indic support is rudimentary only, missing blue
|
||||
* zone support.
|
||||
*
|
||||
* @since:
|
||||
* 2.4.11
|
||||
*
|
||||
*/
|
||||
#define FT_AUTOHINTER_SCRIPT_NONE 0
|
||||
#define FT_AUTOHINTER_SCRIPT_LATIN 1
|
||||
#define FT_AUTOHINTER_SCRIPT_CJK 2
|
||||
#define FT_AUTOHINTER_SCRIPT_INDIC 3
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @struct:
|
||||
* FT_Prop_GlyphToScriptMap
|
||||
*
|
||||
* @description:
|
||||
* *Experimental* *only*
|
||||
*
|
||||
* The data exchange structure for the @glyph-to-script-map property.
|
||||
*
|
||||
* @since:
|
||||
* 2.4.11
|
||||
*
|
||||
*/
|
||||
typedef struct FT_Prop_GlyphToScriptMap_
|
||||
{
|
||||
FT_Face face;
|
||||
FT_UShort* map;
|
||||
|
||||
} FT_Prop_GlyphToScriptMap;
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @property:
|
||||
* fallback-script
|
||||
*
|
||||
* @description:
|
||||
* *Experimental* *only*
|
||||
*
|
||||
* If no auto-hinter script module can be assigned to a glyph, a
|
||||
* fallback script gets assigned to it (see also the
|
||||
* @glyph-to-script-map property). By default, this is
|
||||
* @FT_AUTOHINTER_SCRIPT_CJK. Using the `fallback-script' property,
|
||||
* this fallback value can be changed.
|
||||
*
|
||||
* {
|
||||
* FT_Library library;
|
||||
* FT_UInt fallback_script = FT_AUTOHINTER_SCRIPT_NONE;
|
||||
*
|
||||
*
|
||||
* FT_Init_FreeType( &library );
|
||||
*
|
||||
* FT_Property_Set( library, "autofitter",
|
||||
* "fallback-script", &fallback_script );
|
||||
* }
|
||||
*
|
||||
* @note:
|
||||
* This property can be used with @FT_Property_Get also.
|
||||
*
|
||||
* It's important to use the right timing for changing this value: The
|
||||
* creation of the glyph-to-script map that eventually uses the
|
||||
* fallback script value gets triggered either by setting or reading a
|
||||
* face-specific property like @glyph-to-script-map, or by auto-hinting
|
||||
* any glyph from that face. In particular, if you have already created
|
||||
* an @FT_Face structure but not loaded any glyph (using the
|
||||
* auto-hinter), a change of the fallback script will affect this face.
|
||||
*
|
||||
* @since:
|
||||
* 2.4.11
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @property:
|
||||
* default-script
|
||||
*
|
||||
* @description:
|
||||
* *Experimental* *only*
|
||||
*
|
||||
* If FreeType gets compiled with FT_CONFIG_OPTION_USE_HARFBUZZ to make
|
||||
* the HarfBuzz library access OpenType features for getting better
|
||||
* glyph coverages, this property sets the (auto-fitter) script to be
|
||||
* used for the default (OpenType) script data of a font's GSUB table.
|
||||
* Features for the default script are intended for all scripts not
|
||||
* explicitly handled in GSUB; an example is a `dlig' feature,
|
||||
* containing the combination of the characters `T', `E', and `L' to
|
||||
* form a `TEL' ligature.
|
||||
*
|
||||
* By default, this is @FT_AUTOHINTER_SCRIPT_LATIN. Using the
|
||||
* `default-script' property, this default value can be changed.
|
||||
*
|
||||
* {
|
||||
* FT_Library library;
|
||||
* FT_UInt default_script = FT_AUTOHINTER_SCRIPT_NONE;
|
||||
*
|
||||
*
|
||||
* FT_Init_FreeType( &library );
|
||||
*
|
||||
* FT_Property_Set( library, "autofitter",
|
||||
* "default-script", &default_script );
|
||||
* }
|
||||
*
|
||||
* @note:
|
||||
* This property can be used with @FT_Property_Get also.
|
||||
*
|
||||
* It's important to use the right timing for changing this value: The
|
||||
* creation of the glyph-to-script map that eventually uses the
|
||||
* default script value gets triggered either by setting or reading a
|
||||
* face-specific property like @glyph-to-script-map, or by auto-hinting
|
||||
* any glyph from that face. In particular, if you have already created
|
||||
* an @FT_Face structure but not loaded any glyph (using the
|
||||
* auto-hinter), a change of the default script will affect this face.
|
||||
*
|
||||
* @since:
|
||||
* 2.5.3
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @property:
|
||||
* increase-x-height
|
||||
*
|
||||
* @description:
|
||||
* For ppem values in the range 6~<= ppem <= `increase-x-height', round
|
||||
* up the font's x~height much more often than normally. If the value
|
||||
* is set to~0, which is the default, this feature is switched off. Use
|
||||
* this property to improve the legibility of small font sizes if
|
||||
* necessary.
|
||||
*
|
||||
* {
|
||||
* FT_Library library;
|
||||
* FT_Face face;
|
||||
* FT_Prop_IncreaseXHeight prop;
|
||||
*
|
||||
*
|
||||
* FT_Init_FreeType( &library );
|
||||
* FT_New_Face( library, "foo.ttf", 0, &face );
|
||||
* FT_Set_Char_Size( face, 10 * 64, 0, 72, 0 );
|
||||
*
|
||||
* prop.face = face;
|
||||
* prop.limit = 14;
|
||||
*
|
||||
* FT_Property_Set( library, "autofitter",
|
||||
* "increase-x-height", &prop );
|
||||
* }
|
||||
*
|
||||
* @note:
|
||||
* This property can be used with @FT_Property_Get also.
|
||||
*
|
||||
* Set this value right after calling @FT_Set_Char_Size, but before
|
||||
* loading any glyph (using the auto-hinter).
|
||||
*
|
||||
* @since:
|
||||
* 2.4.11
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @struct:
|
||||
* FT_Prop_IncreaseXHeight
|
||||
*
|
||||
* @description:
|
||||
* The data exchange structure for the @increase-x-height property.
|
||||
*
|
||||
*/
|
||||
typedef struct FT_Prop_IncreaseXHeight_
|
||||
{
|
||||
FT_Face face;
|
||||
FT_UInt limit;
|
||||
|
||||
} FT_Prop_IncreaseXHeight;
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @property:
|
||||
* warping
|
||||
*
|
||||
* @description:
|
||||
* *Experimental* *only*
|
||||
*
|
||||
* If FreeType gets compiled with option AF_CONFIG_OPTION_USE_WARPER to
|
||||
* activate the warp hinting code in the auto-hinter, this property
|
||||
* switches warping on and off.
|
||||
*
|
||||
* Warping only works in `normal' auto-hinting mode replacing it.
|
||||
* The idea of the code is to slightly scale and shift a glyph along
|
||||
* the non-hinted dimension (which is usually the horizontal axis) so
|
||||
* that as much of its segments are aligned (more or less) to the grid.
|
||||
* To find out a glyph's optimal scaling and shifting value, various
|
||||
* parameter combinations are tried and scored.
|
||||
*
|
||||
* By default, warping is off. The example below shows how to switch on
|
||||
* warping (omitting the error handling).
|
||||
*
|
||||
* {
|
||||
* FT_Library library;
|
||||
* FT_Bool warping = 1;
|
||||
*
|
||||
*
|
||||
* FT_Init_FreeType( &library );
|
||||
*
|
||||
* FT_Property_Set( library, "autofitter",
|
||||
* "warping", &warping );
|
||||
* }
|
||||
*
|
||||
* @note:
|
||||
* This property can be used with @FT_Property_Get also.
|
||||
*
|
||||
* This property can be set via the `FREETYPE_PROPERTIES' environment
|
||||
* variable (using values 1 and 0 for `on' and `off', respectively).
|
||||
*
|
||||
* The warping code can also change advance widths. Have a look at the
|
||||
* `lsb_delta' and `rsb_delta' fields in the @FT_GlyphSlotRec structure
|
||||
* for details on improving inter-glyph distances while rendering.
|
||||
*
|
||||
* Since warping is a global property of the auto-hinter it is best to
|
||||
* change its value before rendering any face. Otherwise, you should
|
||||
* reload all faces that get auto-hinted in `normal' hinting mode.
|
||||
*
|
||||
* @since:
|
||||
* 2.6
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
|
||||
#endif /* FTDRIVER_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,280 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* fterrdef.h */
|
||||
/* */
|
||||
/* FreeType error codes (specification). */
|
||||
/* */
|
||||
/* Copyright 2002-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* error_code_values */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* Error Code Values */
|
||||
/* */
|
||||
/* <Abstract> */
|
||||
/* All possible error codes returned by FreeType functions. */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The list below is taken verbatim from the file `fterrdef.h' */
|
||||
/* (loaded automatically by including `FT_FREETYPE_H'). The first */
|
||||
/* argument of the `FT_ERROR_DEF_' macro is the error label; by */
|
||||
/* default, the prefix `FT_Err_' gets added so that you get error */
|
||||
/* names like `FT_Err_Cannot_Open_Resource'. The second argument is */
|
||||
/* the error code, and the last argument an error string, which is not */
|
||||
/* used by FreeType. */
|
||||
/* */
|
||||
/* Within your application you should *only* use error names and */
|
||||
/* *never* its numeric values! The latter might (and actually do) */
|
||||
/* change in forthcoming FreeType versions. */
|
||||
/* */
|
||||
/* Macro `FT_NOERRORDEF_' defines `FT_Err_Ok', which is always zero. */
|
||||
/* See the `Error Enumerations' subsection how to automatically */
|
||||
/* generate a list of error strings. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Enum> */
|
||||
/* FT_Err_XXX */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
/* generic errors */
|
||||
|
||||
FT_NOERRORDEF_( Ok, 0x00,
|
||||
"no error" )
|
||||
|
||||
FT_ERRORDEF_( Cannot_Open_Resource, 0x01,
|
||||
"cannot open resource" )
|
||||
FT_ERRORDEF_( Unknown_File_Format, 0x02,
|
||||
"unknown file format" )
|
||||
FT_ERRORDEF_( Invalid_File_Format, 0x03,
|
||||
"broken file" )
|
||||
FT_ERRORDEF_( Invalid_Version, 0x04,
|
||||
"invalid FreeType version" )
|
||||
FT_ERRORDEF_( Lower_Module_Version, 0x05,
|
||||
"module version is too low" )
|
||||
FT_ERRORDEF_( Invalid_Argument, 0x06,
|
||||
"invalid argument" )
|
||||
FT_ERRORDEF_( Unimplemented_Feature, 0x07,
|
||||
"unimplemented feature" )
|
||||
FT_ERRORDEF_( Invalid_Table, 0x08,
|
||||
"broken table" )
|
||||
FT_ERRORDEF_( Invalid_Offset, 0x09,
|
||||
"broken offset within table" )
|
||||
FT_ERRORDEF_( Array_Too_Large, 0x0A,
|
||||
"array allocation size too large" )
|
||||
FT_ERRORDEF_( Missing_Module, 0x0B,
|
||||
"missing module" )
|
||||
FT_ERRORDEF_( Missing_Property, 0x0C,
|
||||
"missing property" )
|
||||
|
||||
/* glyph/character errors */
|
||||
|
||||
FT_ERRORDEF_( Invalid_Glyph_Index, 0x10,
|
||||
"invalid glyph index" )
|
||||
FT_ERRORDEF_( Invalid_Character_Code, 0x11,
|
||||
"invalid character code" )
|
||||
FT_ERRORDEF_( Invalid_Glyph_Format, 0x12,
|
||||
"unsupported glyph image format" )
|
||||
FT_ERRORDEF_( Cannot_Render_Glyph, 0x13,
|
||||
"cannot render this glyph format" )
|
||||
FT_ERRORDEF_( Invalid_Outline, 0x14,
|
||||
"invalid outline" )
|
||||
FT_ERRORDEF_( Invalid_Composite, 0x15,
|
||||
"invalid composite glyph" )
|
||||
FT_ERRORDEF_( Too_Many_Hints, 0x16,
|
||||
"too many hints" )
|
||||
FT_ERRORDEF_( Invalid_Pixel_Size, 0x17,
|
||||
"invalid pixel size" )
|
||||
|
||||
/* handle errors */
|
||||
|
||||
FT_ERRORDEF_( Invalid_Handle, 0x20,
|
||||
"invalid object handle" )
|
||||
FT_ERRORDEF_( Invalid_Library_Handle, 0x21,
|
||||
"invalid library handle" )
|
||||
FT_ERRORDEF_( Invalid_Driver_Handle, 0x22,
|
||||
"invalid module handle" )
|
||||
FT_ERRORDEF_( Invalid_Face_Handle, 0x23,
|
||||
"invalid face handle" )
|
||||
FT_ERRORDEF_( Invalid_Size_Handle, 0x24,
|
||||
"invalid size handle" )
|
||||
FT_ERRORDEF_( Invalid_Slot_Handle, 0x25,
|
||||
"invalid glyph slot handle" )
|
||||
FT_ERRORDEF_( Invalid_CharMap_Handle, 0x26,
|
||||
"invalid charmap handle" )
|
||||
FT_ERRORDEF_( Invalid_Cache_Handle, 0x27,
|
||||
"invalid cache manager handle" )
|
||||
FT_ERRORDEF_( Invalid_Stream_Handle, 0x28,
|
||||
"invalid stream handle" )
|
||||
|
||||
/* driver errors */
|
||||
|
||||
FT_ERRORDEF_( Too_Many_Drivers, 0x30,
|
||||
"too many modules" )
|
||||
FT_ERRORDEF_( Too_Many_Extensions, 0x31,
|
||||
"too many extensions" )
|
||||
|
||||
/* memory errors */
|
||||
|
||||
FT_ERRORDEF_( Out_Of_Memory, 0x40,
|
||||
"out of memory" )
|
||||
FT_ERRORDEF_( Unlisted_Object, 0x41,
|
||||
"unlisted object" )
|
||||
|
||||
/* stream errors */
|
||||
|
||||
FT_ERRORDEF_( Cannot_Open_Stream, 0x51,
|
||||
"cannot open stream" )
|
||||
FT_ERRORDEF_( Invalid_Stream_Seek, 0x52,
|
||||
"invalid stream seek" )
|
||||
FT_ERRORDEF_( Invalid_Stream_Skip, 0x53,
|
||||
"invalid stream skip" )
|
||||
FT_ERRORDEF_( Invalid_Stream_Read, 0x54,
|
||||
"invalid stream read" )
|
||||
FT_ERRORDEF_( Invalid_Stream_Operation, 0x55,
|
||||
"invalid stream operation" )
|
||||
FT_ERRORDEF_( Invalid_Frame_Operation, 0x56,
|
||||
"invalid frame operation" )
|
||||
FT_ERRORDEF_( Nested_Frame_Access, 0x57,
|
||||
"nested frame access" )
|
||||
FT_ERRORDEF_( Invalid_Frame_Read, 0x58,
|
||||
"invalid frame read" )
|
||||
|
||||
/* raster errors */
|
||||
|
||||
FT_ERRORDEF_( Raster_Uninitialized, 0x60,
|
||||
"raster uninitialized" )
|
||||
FT_ERRORDEF_( Raster_Corrupted, 0x61,
|
||||
"raster corrupted" )
|
||||
FT_ERRORDEF_( Raster_Overflow, 0x62,
|
||||
"raster overflow" )
|
||||
FT_ERRORDEF_( Raster_Negative_Height, 0x63,
|
||||
"negative height while rastering" )
|
||||
|
||||
/* cache errors */
|
||||
|
||||
FT_ERRORDEF_( Too_Many_Caches, 0x70,
|
||||
"too many registered caches" )
|
||||
|
||||
/* TrueType and SFNT errors */
|
||||
|
||||
FT_ERRORDEF_( Invalid_Opcode, 0x80,
|
||||
"invalid opcode" )
|
||||
FT_ERRORDEF_( Too_Few_Arguments, 0x81,
|
||||
"too few arguments" )
|
||||
FT_ERRORDEF_( Stack_Overflow, 0x82,
|
||||
"stack overflow" )
|
||||
FT_ERRORDEF_( Code_Overflow, 0x83,
|
||||
"code overflow" )
|
||||
FT_ERRORDEF_( Bad_Argument, 0x84,
|
||||
"bad argument" )
|
||||
FT_ERRORDEF_( Divide_By_Zero, 0x85,
|
||||
"division by zero" )
|
||||
FT_ERRORDEF_( Invalid_Reference, 0x86,
|
||||
"invalid reference" )
|
||||
FT_ERRORDEF_( Debug_OpCode, 0x87,
|
||||
"found debug opcode" )
|
||||
FT_ERRORDEF_( ENDF_In_Exec_Stream, 0x88,
|
||||
"found ENDF opcode in execution stream" )
|
||||
FT_ERRORDEF_( Nested_DEFS, 0x89,
|
||||
"nested DEFS" )
|
||||
FT_ERRORDEF_( Invalid_CodeRange, 0x8A,
|
||||
"invalid code range" )
|
||||
FT_ERRORDEF_( Execution_Too_Long, 0x8B,
|
||||
"execution context too long" )
|
||||
FT_ERRORDEF_( Too_Many_Function_Defs, 0x8C,
|
||||
"too many function definitions" )
|
||||
FT_ERRORDEF_( Too_Many_Instruction_Defs, 0x8D,
|
||||
"too many instruction definitions" )
|
||||
FT_ERRORDEF_( Table_Missing, 0x8E,
|
||||
"SFNT font table missing" )
|
||||
FT_ERRORDEF_( Horiz_Header_Missing, 0x8F,
|
||||
"horizontal header (hhea) table missing" )
|
||||
FT_ERRORDEF_( Locations_Missing, 0x90,
|
||||
"locations (loca) table missing" )
|
||||
FT_ERRORDEF_( Name_Table_Missing, 0x91,
|
||||
"name table missing" )
|
||||
FT_ERRORDEF_( CMap_Table_Missing, 0x92,
|
||||
"character map (cmap) table missing" )
|
||||
FT_ERRORDEF_( Hmtx_Table_Missing, 0x93,
|
||||
"horizontal metrics (hmtx) table missing" )
|
||||
FT_ERRORDEF_( Post_Table_Missing, 0x94,
|
||||
"PostScript (post) table missing" )
|
||||
FT_ERRORDEF_( Invalid_Horiz_Metrics, 0x95,
|
||||
"invalid horizontal metrics" )
|
||||
FT_ERRORDEF_( Invalid_CharMap_Format, 0x96,
|
||||
"invalid character map (cmap) format" )
|
||||
FT_ERRORDEF_( Invalid_PPem, 0x97,
|
||||
"invalid ppem value" )
|
||||
FT_ERRORDEF_( Invalid_Vert_Metrics, 0x98,
|
||||
"invalid vertical metrics" )
|
||||
FT_ERRORDEF_( Could_Not_Find_Context, 0x99,
|
||||
"could not find context" )
|
||||
FT_ERRORDEF_( Invalid_Post_Table_Format, 0x9A,
|
||||
"invalid PostScript (post) table format" )
|
||||
FT_ERRORDEF_( Invalid_Post_Table, 0x9B,
|
||||
"invalid PostScript (post) table" )
|
||||
FT_ERRORDEF_( DEF_In_Glyf_Bytecode, 0x9C,
|
||||
"found FDEF or IDEF opcode in glyf bytecode" )
|
||||
FT_ERRORDEF_( Missing_Bitmap, 0x9D,
|
||||
"missing bitmap in strike" )
|
||||
|
||||
/* CFF, CID, and Type 1 errors */
|
||||
|
||||
FT_ERRORDEF_( Syntax_Error, 0xA0,
|
||||
"opcode syntax error" )
|
||||
FT_ERRORDEF_( Stack_Underflow, 0xA1,
|
||||
"argument stack underflow" )
|
||||
FT_ERRORDEF_( Ignore, 0xA2,
|
||||
"ignore" )
|
||||
FT_ERRORDEF_( No_Unicode_Glyph_Name, 0xA3,
|
||||
"no Unicode glyph name found" )
|
||||
FT_ERRORDEF_( Glyph_Too_Big, 0xA4,
|
||||
"glyph too big for hinting" )
|
||||
|
||||
/* BDF errors */
|
||||
|
||||
FT_ERRORDEF_( Missing_Startfont_Field, 0xB0,
|
||||
"`STARTFONT' field missing" )
|
||||
FT_ERRORDEF_( Missing_Font_Field, 0xB1,
|
||||
"`FONT' field missing" )
|
||||
FT_ERRORDEF_( Missing_Size_Field, 0xB2,
|
||||
"`SIZE' field missing" )
|
||||
FT_ERRORDEF_( Missing_Fontboundingbox_Field, 0xB3,
|
||||
"`FONTBOUNDINGBOX' field missing" )
|
||||
FT_ERRORDEF_( Missing_Chars_Field, 0xB4,
|
||||
"`CHARS' field missing" )
|
||||
FT_ERRORDEF_( Missing_Startchar_Field, 0xB5,
|
||||
"`STARTCHAR' field missing" )
|
||||
FT_ERRORDEF_( Missing_Encoding_Field, 0xB6,
|
||||
"`ENCODING' field missing" )
|
||||
FT_ERRORDEF_( Missing_Bbx_Field, 0xB7,
|
||||
"`BBX' field missing" )
|
||||
FT_ERRORDEF_( Bbx_Too_Big, 0xB8,
|
||||
"`BBX' too big" )
|
||||
FT_ERRORDEF_( Corrupted_Font_Header, 0xB9,
|
||||
"Font header corrupted or missing fields" )
|
||||
FT_ERRORDEF_( Corrupted_Font_Glyphs, 0xBA,
|
||||
"Font glyphs corrupted or missing fields" )
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,226 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* fterrors.h */
|
||||
/* */
|
||||
/* FreeType error code handling (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* error_enumerations */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* Error Enumerations */
|
||||
/* */
|
||||
/* <Abstract> */
|
||||
/* How to handle errors and error strings. */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The header file `fterrors.h' (which is automatically included by */
|
||||
/* `freetype.h' defines the handling of FreeType's enumeration */
|
||||
/* constants. It can also be used to generate error message strings */
|
||||
/* with a small macro trick explained below. */
|
||||
/* */
|
||||
/* *Error* *Formats* */
|
||||
/* */
|
||||
/* The configuration macro FT_CONFIG_OPTION_USE_MODULE_ERRORS can be */
|
||||
/* defined in `ftoption.h' in order to make the higher byte indicate */
|
||||
/* the module where the error has happened (this is not compatible */
|
||||
/* with standard builds of FreeType~2, however). See the file */
|
||||
/* `ftmoderr.h' for more details. */
|
||||
/* */
|
||||
/* *Error* *Message* *Strings* */
|
||||
/* */
|
||||
/* Error definitions are set up with special macros that allow client */
|
||||
/* applications to build a table of error message strings. The */
|
||||
/* strings are not included in a normal build of FreeType~2 to save */
|
||||
/* space (most client applications do not use them). */
|
||||
/* */
|
||||
/* To do so, you have to define the following macros before including */
|
||||
/* this file. */
|
||||
/* */
|
||||
/* { */
|
||||
/* FT_ERROR_START_LIST */
|
||||
/* } */
|
||||
/* */
|
||||
/* This macro is called before anything else to define the start of */
|
||||
/* the error list. It is followed by several FT_ERROR_DEF calls. */
|
||||
/* */
|
||||
/* { */
|
||||
/* FT_ERROR_DEF( e, v, s ) */
|
||||
/* } */
|
||||
/* */
|
||||
/* This macro is called to define one single error. `e' is the error */
|
||||
/* code identifier (e.g., `Invalid_Argument'), `v' is the error's */
|
||||
/* numerical value, and `s' is the corresponding error string. */
|
||||
/* */
|
||||
/* { */
|
||||
/* FT_ERROR_END_LIST */
|
||||
/* } */
|
||||
/* */
|
||||
/* This macro ends the list. */
|
||||
/* */
|
||||
/* Additionally, you have to undefine `FTERRORS_H_' before #including */
|
||||
/* this file. */
|
||||
/* */
|
||||
/* Here is a simple example. */
|
||||
/* */
|
||||
/* { */
|
||||
/* #undef FTERRORS_H_ */
|
||||
/* #define FT_ERRORDEF( e, v, s ) { e, s }, */
|
||||
/* #define FT_ERROR_START_LIST { */
|
||||
/* #define FT_ERROR_END_LIST { 0, NULL } }; */
|
||||
/* */
|
||||
/* const struct */
|
||||
/* { */
|
||||
/* int err_code; */
|
||||
/* const char* err_msg; */
|
||||
/* } ft_errors[] = */
|
||||
/* */
|
||||
/* #include FT_ERRORS_H */
|
||||
/* } */
|
||||
/* */
|
||||
/* Note that `FT_Err_Ok' is _not_ defined with `FT_ERRORDEF' but with */
|
||||
/* `FT_NOERRORDEF'; it is always zero. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
/* */
|
||||
|
||||
/* In previous FreeType versions we used `__FTERRORS_H__'. However, */
|
||||
/* using two successive underscores in a non-system symbol name */
|
||||
/* violates the C (and C++) standard, so it was changed to the */
|
||||
/* current form. In spite of this, we have to make */
|
||||
/* */
|
||||
/* #undefine __FTERRORS_H__ */
|
||||
/* */
|
||||
/* work for backward compatibility. */
|
||||
/* */
|
||||
#if !( defined( FTERRORS_H_ ) && defined ( __FTERRORS_H__ ) )
|
||||
#define FTERRORS_H_
|
||||
#define __FTERRORS_H__
|
||||
|
||||
|
||||
/* include module base error codes */
|
||||
#include FT_MODULE_ERRORS_H
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*******************************************************************/
|
||||
/***** *****/
|
||||
/***** SETUP MACROS *****/
|
||||
/***** *****/
|
||||
/*******************************************************************/
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
#undef FT_NEED_EXTERN_C
|
||||
|
||||
|
||||
/* FT_ERR_PREFIX is used as a prefix for error identifiers. */
|
||||
/* By default, we use `FT_Err_'. */
|
||||
/* */
|
||||
#ifndef FT_ERR_PREFIX
|
||||
#define FT_ERR_PREFIX FT_Err_
|
||||
#endif
|
||||
|
||||
|
||||
/* FT_ERR_BASE is used as the base for module-specific errors. */
|
||||
/* */
|
||||
#ifdef FT_CONFIG_OPTION_USE_MODULE_ERRORS
|
||||
|
||||
#ifndef FT_ERR_BASE
|
||||
#define FT_ERR_BASE FT_Mod_Err_Base
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#undef FT_ERR_BASE
|
||||
#define FT_ERR_BASE 0
|
||||
|
||||
#endif /* FT_CONFIG_OPTION_USE_MODULE_ERRORS */
|
||||
|
||||
|
||||
/* If FT_ERRORDEF is not defined, we need to define a simple */
|
||||
/* enumeration type. */
|
||||
/* */
|
||||
#ifndef FT_ERRORDEF
|
||||
|
||||
#define FT_ERRORDEF( e, v, s ) e = v,
|
||||
#define FT_ERROR_START_LIST enum {
|
||||
#define FT_ERROR_END_LIST FT_ERR_CAT( FT_ERR_PREFIX, Max ) };
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define FT_NEED_EXTERN_C
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#endif /* !FT_ERRORDEF */
|
||||
|
||||
|
||||
/* this macro is used to define an error */
|
||||
#define FT_ERRORDEF_( e, v, s ) \
|
||||
FT_ERRORDEF( FT_ERR_CAT( FT_ERR_PREFIX, e ), v + FT_ERR_BASE, s )
|
||||
|
||||
/* this is only used for <module>_Err_Ok, which must be 0! */
|
||||
#define FT_NOERRORDEF_( e, v, s ) \
|
||||
FT_ERRORDEF( FT_ERR_CAT( FT_ERR_PREFIX, e ), v, s )
|
||||
|
||||
|
||||
#ifdef FT_ERROR_START_LIST
|
||||
FT_ERROR_START_LIST
|
||||
#endif
|
||||
|
||||
|
||||
/* now include the error codes */
|
||||
#include FT_ERROR_DEFINITIONS_H
|
||||
|
||||
|
||||
#ifdef FT_ERROR_END_LIST
|
||||
FT_ERROR_END_LIST
|
||||
#endif
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*******************************************************************/
|
||||
/***** *****/
|
||||
/***** SIMPLE CLEANUP *****/
|
||||
/***** *****/
|
||||
/*******************************************************************/
|
||||
/*******************************************************************/
|
||||
|
||||
#ifdef FT_NEED_EXTERN_C
|
||||
}
|
||||
#endif
|
||||
|
||||
#undef FT_ERROR_START_LIST
|
||||
#undef FT_ERROR_END_LIST
|
||||
|
||||
#undef FT_ERRORDEF
|
||||
#undef FT_ERRORDEF_
|
||||
#undef FT_NOERRORDEF_
|
||||
|
||||
#undef FT_NEED_EXTERN_C
|
||||
#undef FT_ERR_BASE
|
||||
|
||||
/* FT_ERR_PREFIX is needed internally */
|
||||
#ifndef FT2_BUILD_LIBRARY
|
||||
#undef FT_ERR_PREFIX
|
||||
#endif
|
||||
|
||||
#endif /* !(FTERRORS_H_ && __FTERRORS_H__) */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,95 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftfntfmt.h */
|
||||
/* */
|
||||
/* Support functions for font formats. */
|
||||
/* */
|
||||
/* Copyright 2002-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTFNTFMT_H_
|
||||
#define FTFNTFMT_H_
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#ifdef FREETYPE_H
|
||||
#error "freetype.h of FreeType 1 has been loaded!"
|
||||
#error "Please fix the directory search order for header files"
|
||||
#error "so that freetype.h of FreeType 2 is found first."
|
||||
#endif
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* font_formats */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* Font Formats */
|
||||
/* */
|
||||
/* <Abstract> */
|
||||
/* Getting the font format. */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The single function in this section can be used to get the font */
|
||||
/* format. Note that this information is not needed normally; */
|
||||
/* however, there are special cases (like in PDF devices) where it is */
|
||||
/* important to differentiate, in spite of FreeType's uniform API. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_Font_Format */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Return a string describing the format of a given face. Possible */
|
||||
/* values are `TrueType', `Type~1', `BDF', `PCF', `Type~42', */
|
||||
/* `CID~Type~1', `CFF', `PFR', and `Windows~FNT'. */
|
||||
/* */
|
||||
/* The return value is suitable to be used as an X11 FONT_PROPERTY. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: */
|
||||
/* Input face handle. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* Font format string. NULL in case of error. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* A deprecated name for the same function is */
|
||||
/* `FT_Get_X11_Font_Format'. */
|
||||
/* */
|
||||
FT_EXPORT( const char* )
|
||||
FT_Get_Font_Format( FT_Face face );
|
||||
|
||||
|
||||
/* deprecated */
|
||||
FT_EXPORT( const char* )
|
||||
FT_Get_X11_Font_Format( FT_Face face );
|
||||
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTFNTFMT_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,142 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftgasp.h */
|
||||
/* */
|
||||
/* Access of TrueType's `gasp' table (specification). */
|
||||
/* */
|
||||
/* Copyright 2007-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTGASP_H_
|
||||
#define FTGASP_H_
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#ifdef FREETYPE_H
|
||||
#error "freetype.h of FreeType 1 has been loaded!"
|
||||
#error "Please fix the directory search order for header files"
|
||||
#error "so that freetype.h of FreeType 2 is found first."
|
||||
#endif
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
*
|
||||
* @section:
|
||||
* gasp_table
|
||||
*
|
||||
* @title:
|
||||
* Gasp Table
|
||||
*
|
||||
* @abstract:
|
||||
* Retrieving TrueType `gasp' table entries.
|
||||
*
|
||||
* @description:
|
||||
* The function @FT_Get_Gasp can be used to query a TrueType or OpenType
|
||||
* font for specific entries in its `gasp' table, if any. This is
|
||||
* mainly useful when implementing native TrueType hinting with the
|
||||
* bytecode interpreter to duplicate the Windows text rendering results.
|
||||
*/
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @enum:
|
||||
* FT_GASP_XXX
|
||||
*
|
||||
* @description:
|
||||
* A list of values and/or bit-flags returned by the @FT_Get_Gasp
|
||||
* function.
|
||||
*
|
||||
* @values:
|
||||
* FT_GASP_NO_TABLE ::
|
||||
* This special value means that there is no GASP table in this face.
|
||||
* It is up to the client to decide what to do.
|
||||
*
|
||||
* FT_GASP_DO_GRIDFIT ::
|
||||
* Grid-fitting and hinting should be performed at the specified ppem.
|
||||
* This *really* means TrueType bytecode interpretation. If this bit
|
||||
* is not set, no hinting gets applied.
|
||||
*
|
||||
* FT_GASP_DO_GRAY ::
|
||||
* Anti-aliased rendering should be performed at the specified ppem.
|
||||
* If not set, do monochrome rendering.
|
||||
*
|
||||
* FT_GASP_SYMMETRIC_SMOOTHING ::
|
||||
* If set, smoothing along multiple axes must be used with ClearType.
|
||||
*
|
||||
* FT_GASP_SYMMETRIC_GRIDFIT ::
|
||||
* Grid-fitting must be used with ClearType's symmetric smoothing.
|
||||
*
|
||||
* @note:
|
||||
* The bit-flags `FT_GASP_DO_GRIDFIT' and `FT_GASP_DO_GRAY' are to be
|
||||
* used for standard font rasterization only. Independently of that,
|
||||
* `FT_GASP_SYMMETRIC_SMOOTHING' and `FT_GASP_SYMMETRIC_GRIDFIT' are to
|
||||
* be used if ClearType is enabled (and `FT_GASP_DO_GRIDFIT' and
|
||||
* `FT_GASP_DO_GRAY' are consequently ignored).
|
||||
*
|
||||
* `ClearType' is Microsoft's implementation of LCD rendering, partly
|
||||
* protected by patents.
|
||||
*
|
||||
* @since:
|
||||
* 2.3.0
|
||||
*/
|
||||
#define FT_GASP_NO_TABLE -1
|
||||
#define FT_GASP_DO_GRIDFIT 0x01
|
||||
#define FT_GASP_DO_GRAY 0x02
|
||||
#define FT_GASP_SYMMETRIC_GRIDFIT 0x04
|
||||
#define FT_GASP_SYMMETRIC_SMOOTHING 0x08
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @func:
|
||||
* FT_Get_Gasp
|
||||
*
|
||||
* @description:
|
||||
* For a TrueType or OpenType font file, return the rasterizer behaviour
|
||||
* flags from the font's `gasp' table corresponding to a given
|
||||
* character pixel size.
|
||||
*
|
||||
* @input:
|
||||
* face :: The source face handle.
|
||||
*
|
||||
* ppem :: The vertical character pixel size.
|
||||
*
|
||||
* @return:
|
||||
* Bit flags (see @FT_GASP_XXX), or @FT_GASP_NO_TABLE if there is no
|
||||
* `gasp' table in the face.
|
||||
*
|
||||
* @note:
|
||||
* If you want to use the MM functionality of OpenType variation fonts
|
||||
* (i.e., using @FT_Set_Var_Design_Coordinates and friends), call this
|
||||
* function *after* setting an instance since the return values can
|
||||
* change.
|
||||
*
|
||||
* @since:
|
||||
* 2.3.0
|
||||
*/
|
||||
FT_EXPORT( FT_Int )
|
||||
FT_Get_Gasp( FT_Face face,
|
||||
FT_UInt ppem );
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTGASP_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,614 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftglyph.h */
|
||||
/* */
|
||||
/* FreeType convenience functions to handle glyphs (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* This file contains the definition of several convenience functions */
|
||||
/* that can be used by client applications to easily retrieve glyph */
|
||||
/* bitmaps and outlines from a given face. */
|
||||
/* */
|
||||
/* These functions should be optional if you are writing a font server */
|
||||
/* or text layout engine on top of FreeType. However, they are pretty */
|
||||
/* handy for many other simple uses of the library. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTGLYPH_H_
|
||||
#define FTGLYPH_H_
|
||||
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#ifdef FREETYPE_H
|
||||
#error "freetype.h of FreeType 1 has been loaded!"
|
||||
#error "Please fix the directory search order for header files"
|
||||
#error "so that freetype.h of FreeType 2 is found first."
|
||||
#endif
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* glyph_management */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* Glyph Management */
|
||||
/* */
|
||||
/* <Abstract> */
|
||||
/* Generic interface to manage individual glyph data. */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This section contains definitions used to manage glyph data */
|
||||
/* through generic FT_Glyph objects. Each of them can contain a */
|
||||
/* bitmap, a vector outline, or even images in other formats. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/* forward declaration to a private type */
|
||||
typedef struct FT_Glyph_Class_ FT_Glyph_Class;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Glyph */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Handle to an object used to model generic glyph images. It is a */
|
||||
/* pointer to the @FT_GlyphRec structure and can contain a glyph */
|
||||
/* bitmap or pointer. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* Glyph objects are not owned by the library. You must thus release */
|
||||
/* them manually (through @FT_Done_Glyph) _before_ calling */
|
||||
/* @FT_Done_FreeType. */
|
||||
/* */
|
||||
typedef struct FT_GlyphRec_* FT_Glyph;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_GlyphRec */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The root glyph structure contains a given glyph image plus its */
|
||||
/* advance width in 16.16 fixed-point format. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* library :: A handle to the FreeType library object. */
|
||||
/* */
|
||||
/* clazz :: A pointer to the glyph's class. Private. */
|
||||
/* */
|
||||
/* format :: The format of the glyph's image. */
|
||||
/* */
|
||||
/* advance :: A 16.16 vector that gives the glyph's advance width. */
|
||||
/* */
|
||||
typedef struct FT_GlyphRec_
|
||||
{
|
||||
FT_Library library;
|
||||
const FT_Glyph_Class* clazz;
|
||||
FT_Glyph_Format format;
|
||||
FT_Vector advance;
|
||||
|
||||
} FT_GlyphRec;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_BitmapGlyph */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to an object used to model a bitmap glyph image. This is */
|
||||
/* a sub-class of @FT_Glyph, and a pointer to @FT_BitmapGlyphRec. */
|
||||
/* */
|
||||
typedef struct FT_BitmapGlyphRec_* FT_BitmapGlyph;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_BitmapGlyphRec */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used for bitmap glyph images. This really is a */
|
||||
/* `sub-class' of @FT_GlyphRec. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* root :: The root @FT_Glyph fields. */
|
||||
/* */
|
||||
/* left :: The left-side bearing, i.e., the horizontal distance */
|
||||
/* from the current pen position to the left border of the */
|
||||
/* glyph bitmap. */
|
||||
/* */
|
||||
/* top :: The top-side bearing, i.e., the vertical distance from */
|
||||
/* the current pen position to the top border of the glyph */
|
||||
/* bitmap. This distance is positive for upwards~y! */
|
||||
/* */
|
||||
/* bitmap :: A descriptor for the bitmap. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* You can typecast an @FT_Glyph to @FT_BitmapGlyph if you have */
|
||||
/* `glyph->format == FT_GLYPH_FORMAT_BITMAP'. This lets you access */
|
||||
/* the bitmap's contents easily. */
|
||||
/* */
|
||||
/* The corresponding pixel buffer is always owned by @FT_BitmapGlyph */
|
||||
/* and is thus created and destroyed with it. */
|
||||
/* */
|
||||
typedef struct FT_BitmapGlyphRec_
|
||||
{
|
||||
FT_GlyphRec root;
|
||||
FT_Int left;
|
||||
FT_Int top;
|
||||
FT_Bitmap bitmap;
|
||||
|
||||
} FT_BitmapGlyphRec;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_OutlineGlyph */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to an object used to model an outline glyph image. This */
|
||||
/* is a sub-class of @FT_Glyph, and a pointer to @FT_OutlineGlyphRec. */
|
||||
/* */
|
||||
typedef struct FT_OutlineGlyphRec_* FT_OutlineGlyph;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_OutlineGlyphRec */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used for outline (vectorial) glyph images. This */
|
||||
/* really is a `sub-class' of @FT_GlyphRec. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* root :: The root @FT_Glyph fields. */
|
||||
/* */
|
||||
/* outline :: A descriptor for the outline. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* You can typecast an @FT_Glyph to @FT_OutlineGlyph if you have */
|
||||
/* `glyph->format == FT_GLYPH_FORMAT_OUTLINE'. This lets you access */
|
||||
/* the outline's content easily. */
|
||||
/* */
|
||||
/* As the outline is extracted from a glyph slot, its coordinates are */
|
||||
/* expressed normally in 26.6 pixels, unless the flag */
|
||||
/* @FT_LOAD_NO_SCALE was used in @FT_Load_Glyph() or @FT_Load_Char(). */
|
||||
/* */
|
||||
/* The outline's tables are always owned by the object and are */
|
||||
/* destroyed with it. */
|
||||
/* */
|
||||
typedef struct FT_OutlineGlyphRec_
|
||||
{
|
||||
FT_GlyphRec root;
|
||||
FT_Outline outline;
|
||||
|
||||
} FT_OutlineGlyphRec;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_Glyph */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A function used to extract a glyph image from a slot. Note that */
|
||||
/* the created @FT_Glyph object must be released with @FT_Done_Glyph. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* slot :: A handle to the source glyph slot. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* aglyph :: A handle to the glyph object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* Because `*aglyph->advance.x' and '*aglyph->advance.y' are 16.16 */
|
||||
/* fixed-point numbers, `slot->advance.x' and `slot->advance.y' */
|
||||
/* (which are in 26.6 fixed-point format) must be in the range */
|
||||
/* ]-32768;32768[. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Get_Glyph( FT_GlyphSlot slot,
|
||||
FT_Glyph *aglyph );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Glyph_Copy */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A function used to copy a glyph image. Note that the created */
|
||||
/* @FT_Glyph object must be released with @FT_Done_Glyph. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* source :: A handle to the source glyph object. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* target :: A handle to the target glyph object. 0~in case of */
|
||||
/* error. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Glyph_Copy( FT_Glyph source,
|
||||
FT_Glyph *target );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Glyph_Transform */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Transform a glyph image if its format is scalable. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* glyph :: A handle to the target glyph object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* matrix :: A pointer to a 2x2 matrix to apply. */
|
||||
/* */
|
||||
/* delta :: A pointer to a 2d vector to apply. Coordinates are */
|
||||
/* expressed in 1/64th of a pixel. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code (if not 0, the glyph format is not scalable). */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The 2x2 transformation matrix is also applied to the glyph's */
|
||||
/* advance vector. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Glyph_Transform( FT_Glyph glyph,
|
||||
FT_Matrix* matrix,
|
||||
FT_Vector* delta );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Enum> */
|
||||
/* FT_Glyph_BBox_Mode */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The mode how the values of @FT_Glyph_Get_CBox are returned. */
|
||||
/* */
|
||||
/* <Values> */
|
||||
/* FT_GLYPH_BBOX_UNSCALED :: */
|
||||
/* Return unscaled font units. */
|
||||
/* */
|
||||
/* FT_GLYPH_BBOX_SUBPIXELS :: */
|
||||
/* Return unfitted 26.6 coordinates. */
|
||||
/* */
|
||||
/* FT_GLYPH_BBOX_GRIDFIT :: */
|
||||
/* Return grid-fitted 26.6 coordinates. */
|
||||
/* */
|
||||
/* FT_GLYPH_BBOX_TRUNCATE :: */
|
||||
/* Return coordinates in integer pixels. */
|
||||
/* */
|
||||
/* FT_GLYPH_BBOX_PIXELS :: */
|
||||
/* Return grid-fitted pixel coordinates. */
|
||||
/* */
|
||||
typedef enum FT_Glyph_BBox_Mode_
|
||||
{
|
||||
FT_GLYPH_BBOX_UNSCALED = 0,
|
||||
FT_GLYPH_BBOX_SUBPIXELS = 0,
|
||||
FT_GLYPH_BBOX_GRIDFIT = 1,
|
||||
FT_GLYPH_BBOX_TRUNCATE = 2,
|
||||
FT_GLYPH_BBOX_PIXELS = 3
|
||||
|
||||
} FT_Glyph_BBox_Mode;
|
||||
|
||||
|
||||
/* these constants are deprecated; use the corresponding */
|
||||
/* `FT_Glyph_BBox_Mode' values instead */
|
||||
#define ft_glyph_bbox_unscaled FT_GLYPH_BBOX_UNSCALED
|
||||
#define ft_glyph_bbox_subpixels FT_GLYPH_BBOX_SUBPIXELS
|
||||
#define ft_glyph_bbox_gridfit FT_GLYPH_BBOX_GRIDFIT
|
||||
#define ft_glyph_bbox_truncate FT_GLYPH_BBOX_TRUNCATE
|
||||
#define ft_glyph_bbox_pixels FT_GLYPH_BBOX_PIXELS
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Glyph_Get_CBox */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Return a glyph's `control box'. The control box encloses all the */
|
||||
/* outline's points, including Bezier control points. Though it */
|
||||
/* coincides with the exact bounding box for most glyphs, it can be */
|
||||
/* slightly larger in some situations (like when rotating an outline */
|
||||
/* that contains Bezier outside arcs). */
|
||||
/* */
|
||||
/* Computing the control box is very fast, while getting the bounding */
|
||||
/* box can take much more time as it needs to walk over all segments */
|
||||
/* and arcs in the outline. To get the latter, you can use the */
|
||||
/* `ftbbox' component, which is dedicated to this single task. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* glyph :: A handle to the source glyph object. */
|
||||
/* */
|
||||
/* mode :: The mode that indicates how to interpret the returned */
|
||||
/* bounding box values. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* acbox :: The glyph coordinate bounding box. Coordinates are */
|
||||
/* expressed in 1/64th of pixels if it is grid-fitted. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* Coordinates are relative to the glyph origin, using the y~upwards */
|
||||
/* convention. */
|
||||
/* */
|
||||
/* If the glyph has been loaded with @FT_LOAD_NO_SCALE, `bbox_mode' */
|
||||
/* must be set to @FT_GLYPH_BBOX_UNSCALED to get unscaled font */
|
||||
/* units in 26.6 pixel format. The value @FT_GLYPH_BBOX_SUBPIXELS */
|
||||
/* is another name for this constant. */
|
||||
/* */
|
||||
/* If the font is tricky and the glyph has been loaded with */
|
||||
/* @FT_LOAD_NO_SCALE, the resulting CBox is meaningless. To get */
|
||||
/* reasonable values for the CBox it is necessary to load the glyph */
|
||||
/* at a large ppem value (so that the hinting instructions can */
|
||||
/* properly shift and scale the subglyphs), then extracting the CBox, */
|
||||
/* which can be eventually converted back to font units. */
|
||||
/* */
|
||||
/* Note that the maximum coordinates are exclusive, which means that */
|
||||
/* one can compute the width and height of the glyph image (be it in */
|
||||
/* integer or 26.6 pixels) as: */
|
||||
/* */
|
||||
/* { */
|
||||
/* width = bbox.xMax - bbox.xMin; */
|
||||
/* height = bbox.yMax - bbox.yMin; */
|
||||
/* } */
|
||||
/* */
|
||||
/* Note also that for 26.6 coordinates, if `bbox_mode' is set to */
|
||||
/* @FT_GLYPH_BBOX_GRIDFIT, the coordinates will also be grid-fitted, */
|
||||
/* which corresponds to: */
|
||||
/* */
|
||||
/* { */
|
||||
/* bbox.xMin = FLOOR(bbox.xMin); */
|
||||
/* bbox.yMin = FLOOR(bbox.yMin); */
|
||||
/* bbox.xMax = CEILING(bbox.xMax); */
|
||||
/* bbox.yMax = CEILING(bbox.yMax); */
|
||||
/* } */
|
||||
/* */
|
||||
/* To get the bbox in pixel coordinates, set `bbox_mode' to */
|
||||
/* @FT_GLYPH_BBOX_TRUNCATE. */
|
||||
/* */
|
||||
/* To get the bbox in grid-fitted pixel coordinates, set `bbox_mode' */
|
||||
/* to @FT_GLYPH_BBOX_PIXELS. */
|
||||
/* */
|
||||
FT_EXPORT( void )
|
||||
FT_Glyph_Get_CBox( FT_Glyph glyph,
|
||||
FT_UInt bbox_mode,
|
||||
FT_BBox *acbox );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Glyph_To_Bitmap */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Convert a given glyph object to a bitmap glyph object. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* the_glyph :: A pointer to a handle to the target glyph. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* render_mode :: An enumeration that describes how the data is */
|
||||
/* rendered. */
|
||||
/* */
|
||||
/* origin :: A pointer to a vector used to translate the glyph */
|
||||
/* image before rendering. Can be~0 (if no */
|
||||
/* translation). The origin is expressed in */
|
||||
/* 26.6 pixels. */
|
||||
/* */
|
||||
/* destroy :: A boolean that indicates that the original glyph */
|
||||
/* image should be destroyed by this function. It is */
|
||||
/* never destroyed in case of error. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This function does nothing if the glyph format isn't scalable. */
|
||||
/* */
|
||||
/* The glyph image is translated with the `origin' vector before */
|
||||
/* rendering. */
|
||||
/* */
|
||||
/* The first parameter is a pointer to an @FT_Glyph handle, that will */
|
||||
/* be _replaced_ by this function (with newly allocated data). */
|
||||
/* Typically, you would use (omitting error handling): */
|
||||
/* */
|
||||
/* */
|
||||
/* { */
|
||||
/* FT_Glyph glyph; */
|
||||
/* FT_BitmapGlyph glyph_bitmap; */
|
||||
/* */
|
||||
/* */
|
||||
/* // load glyph */
|
||||
/* error = FT_Load_Char( face, glyph_index, FT_LOAD_DEFAULT ); */
|
||||
/* */
|
||||
/* // extract glyph image */
|
||||
/* error = FT_Get_Glyph( face->glyph, &glyph ); */
|
||||
/* */
|
||||
/* // convert to a bitmap (default render mode + destroying old) */
|
||||
/* if ( glyph->format != FT_GLYPH_FORMAT_BITMAP ) */
|
||||
/* { */
|
||||
/* error = FT_Glyph_To_Bitmap( &glyph, FT_RENDER_MODE_NORMAL, */
|
||||
/* 0, 1 ); */
|
||||
/* if ( error ) // `glyph' unchanged */
|
||||
/* ... */
|
||||
/* } */
|
||||
/* */
|
||||
/* // access bitmap content by typecasting */
|
||||
/* glyph_bitmap = (FT_BitmapGlyph)glyph; */
|
||||
/* */
|
||||
/* // do funny stuff with it, like blitting/drawing */
|
||||
/* ... */
|
||||
/* */
|
||||
/* // discard glyph image (bitmap or not) */
|
||||
/* FT_Done_Glyph( glyph ); */
|
||||
/* } */
|
||||
/* */
|
||||
/* */
|
||||
/* Here another example, again without error handling: */
|
||||
/* */
|
||||
/* */
|
||||
/* { */
|
||||
/* FT_Glyph glyphs[MAX_GLYPHS] */
|
||||
/* */
|
||||
/* */
|
||||
/* ... */
|
||||
/* */
|
||||
/* for ( idx = 0; i < MAX_GLYPHS; i++ ) */
|
||||
/* error = FT_Load_Glyph( face, idx, FT_LOAD_DEFAULT ) || */
|
||||
/* FT_Get_Glyph ( face->glyph, &glyph[idx] ); */
|
||||
/* */
|
||||
/* ... */
|
||||
/* */
|
||||
/* for ( idx = 0; i < MAX_GLYPHS; i++ ) */
|
||||
/* { */
|
||||
/* FT_Glyph bitmap = glyphs[idx]; */
|
||||
/* */
|
||||
/* */
|
||||
/* ... */
|
||||
/* */
|
||||
/* // after this call, `bitmap' no longer points into */
|
||||
/* // the `glyphs' array (and the old value isn't destroyed) */
|
||||
/* FT_Glyph_To_Bitmap( &bitmap, FT_RENDER_MODE_MONO, 0, 0 ); */
|
||||
/* */
|
||||
/* ... */
|
||||
/* */
|
||||
/* FT_Done_Glyph( bitmap ); */
|
||||
/* } */
|
||||
/* */
|
||||
/* ... */
|
||||
/* */
|
||||
/* for ( idx = 0; i < MAX_GLYPHS; i++ ) */
|
||||
/* FT_Done_Glyph( glyphs[idx] ); */
|
||||
/* } */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Glyph_To_Bitmap( FT_Glyph* the_glyph,
|
||||
FT_Render_Mode render_mode,
|
||||
FT_Vector* origin,
|
||||
FT_Bool destroy );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Done_Glyph */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Destroy a given glyph. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* glyph :: A handle to the target glyph object. */
|
||||
/* */
|
||||
FT_EXPORT( void )
|
||||
FT_Done_Glyph( FT_Glyph glyph );
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
/* other helpful functions */
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* computations */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Matrix_Multiply */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Perform the matrix operation `b = a*b'. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* a :: A pointer to matrix `a'. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* b :: A pointer to matrix `b'. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The result is undefined if either `a' or `b' is zero. */
|
||||
/* */
|
||||
/* Since the function uses wrap-around arithmetic, results become */
|
||||
/* meaningless if the arguments are very large. */
|
||||
/* */
|
||||
FT_EXPORT( void )
|
||||
FT_Matrix_Multiply( const FT_Matrix* a,
|
||||
FT_Matrix* b );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Matrix_Invert */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Invert a 2x2 matrix. Return an error if it can't be inverted. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* matrix :: A pointer to the target matrix. Remains untouched in */
|
||||
/* case of error. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Matrix_Invert( FT_Matrix* matrix );
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTGLYPH_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
|
||||
|
||||
/* Local Variables: */
|
||||
/* coding: utf-8 */
|
||||
/* End: */
|
||||
@@ -0,0 +1,357 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftgxval.h */
|
||||
/* */
|
||||
/* FreeType API for validating TrueTypeGX/AAT tables (specification). */
|
||||
/* */
|
||||
/* Copyright 2004-2018 by */
|
||||
/* Masatake YAMATO, Redhat K.K, */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* gxvalid is derived from both gxlayout module and otvalid module. */
|
||||
/* Development of gxlayout is supported by the Information-technology */
|
||||
/* Promotion Agency(IPA), Japan. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTGXVAL_H_
|
||||
#define FTGXVAL_H_
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#ifdef FREETYPE_H
|
||||
#error "freetype.h of FreeType 1 has been loaded!"
|
||||
#error "Please fix the directory search order for header files"
|
||||
#error "so that freetype.h of FreeType 2 is found first."
|
||||
#endif
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* gx_validation */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* TrueTypeGX/AAT Validation */
|
||||
/* */
|
||||
/* <Abstract> */
|
||||
/* An API to validate TrueTypeGX/AAT tables. */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This section contains the declaration of functions to validate */
|
||||
/* some TrueTypeGX tables (feat, mort, morx, bsln, just, kern, opbd, */
|
||||
/* trak, prop, lcar). */
|
||||
/* */
|
||||
/* <Order> */
|
||||
/* FT_TrueTypeGX_Validate */
|
||||
/* FT_TrueTypeGX_Free */
|
||||
/* */
|
||||
/* FT_ClassicKern_Validate */
|
||||
/* FT_ClassicKern_Free */
|
||||
/* */
|
||||
/* FT_VALIDATE_GX_LENGTH */
|
||||
/* FT_VALIDATE_GXXXX */
|
||||
/* FT_VALIDATE_CKERNXXX */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* */
|
||||
/* Warning: Use FT_VALIDATE_XXX to validate a table. */
|
||||
/* Following definitions are for gxvalid developers. */
|
||||
/* */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
#define FT_VALIDATE_feat_INDEX 0
|
||||
#define FT_VALIDATE_mort_INDEX 1
|
||||
#define FT_VALIDATE_morx_INDEX 2
|
||||
#define FT_VALIDATE_bsln_INDEX 3
|
||||
#define FT_VALIDATE_just_INDEX 4
|
||||
#define FT_VALIDATE_kern_INDEX 5
|
||||
#define FT_VALIDATE_opbd_INDEX 6
|
||||
#define FT_VALIDATE_trak_INDEX 7
|
||||
#define FT_VALIDATE_prop_INDEX 8
|
||||
#define FT_VALIDATE_lcar_INDEX 9
|
||||
#define FT_VALIDATE_GX_LAST_INDEX FT_VALIDATE_lcar_INDEX
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_VALIDATE_GX_LENGTH
|
||||
*
|
||||
* @description:
|
||||
* The number of tables checked in this module. Use it as a parameter
|
||||
* for the `table-length' argument of function @FT_TrueTypeGX_Validate.
|
||||
*/
|
||||
#define FT_VALIDATE_GX_LENGTH ( FT_VALIDATE_GX_LAST_INDEX + 1 )
|
||||
|
||||
/* */
|
||||
|
||||
/* Up to 0x1000 is used by otvalid.
|
||||
Ox2xxx is reserved for feature OT extension. */
|
||||
#define FT_VALIDATE_GX_START 0x4000
|
||||
#define FT_VALIDATE_GX_BITFIELD( tag ) \
|
||||
( FT_VALIDATE_GX_START << FT_VALIDATE_##tag##_INDEX )
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* @enum:
|
||||
* FT_VALIDATE_GXXXX
|
||||
*
|
||||
* @description:
|
||||
* A list of bit-field constants used with @FT_TrueTypeGX_Validate to
|
||||
* indicate which TrueTypeGX/AAT Type tables should be validated.
|
||||
*
|
||||
* @values:
|
||||
* FT_VALIDATE_feat ::
|
||||
* Validate `feat' table.
|
||||
*
|
||||
* FT_VALIDATE_mort ::
|
||||
* Validate `mort' table.
|
||||
*
|
||||
* FT_VALIDATE_morx ::
|
||||
* Validate `morx' table.
|
||||
*
|
||||
* FT_VALIDATE_bsln ::
|
||||
* Validate `bsln' table.
|
||||
*
|
||||
* FT_VALIDATE_just ::
|
||||
* Validate `just' table.
|
||||
*
|
||||
* FT_VALIDATE_kern ::
|
||||
* Validate `kern' table.
|
||||
*
|
||||
* FT_VALIDATE_opbd ::
|
||||
* Validate `opbd' table.
|
||||
*
|
||||
* FT_VALIDATE_trak ::
|
||||
* Validate `trak' table.
|
||||
*
|
||||
* FT_VALIDATE_prop ::
|
||||
* Validate `prop' table.
|
||||
*
|
||||
* FT_VALIDATE_lcar ::
|
||||
* Validate `lcar' table.
|
||||
*
|
||||
* FT_VALIDATE_GX ::
|
||||
* Validate all TrueTypeGX tables (feat, mort, morx, bsln, just, kern,
|
||||
* opbd, trak, prop and lcar).
|
||||
*
|
||||
*/
|
||||
|
||||
#define FT_VALIDATE_feat FT_VALIDATE_GX_BITFIELD( feat )
|
||||
#define FT_VALIDATE_mort FT_VALIDATE_GX_BITFIELD( mort )
|
||||
#define FT_VALIDATE_morx FT_VALIDATE_GX_BITFIELD( morx )
|
||||
#define FT_VALIDATE_bsln FT_VALIDATE_GX_BITFIELD( bsln )
|
||||
#define FT_VALIDATE_just FT_VALIDATE_GX_BITFIELD( just )
|
||||
#define FT_VALIDATE_kern FT_VALIDATE_GX_BITFIELD( kern )
|
||||
#define FT_VALIDATE_opbd FT_VALIDATE_GX_BITFIELD( opbd )
|
||||
#define FT_VALIDATE_trak FT_VALIDATE_GX_BITFIELD( trak )
|
||||
#define FT_VALIDATE_prop FT_VALIDATE_GX_BITFIELD( prop )
|
||||
#define FT_VALIDATE_lcar FT_VALIDATE_GX_BITFIELD( lcar )
|
||||
|
||||
#define FT_VALIDATE_GX ( FT_VALIDATE_feat | \
|
||||
FT_VALIDATE_mort | \
|
||||
FT_VALIDATE_morx | \
|
||||
FT_VALIDATE_bsln | \
|
||||
FT_VALIDATE_just | \
|
||||
FT_VALIDATE_kern | \
|
||||
FT_VALIDATE_opbd | \
|
||||
FT_VALIDATE_trak | \
|
||||
FT_VALIDATE_prop | \
|
||||
FT_VALIDATE_lcar )
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_TrueTypeGX_Validate
|
||||
*
|
||||
* @description:
|
||||
* Validate various TrueTypeGX tables to assure that all offsets and
|
||||
* indices are valid. The idea is that a higher-level library that
|
||||
* actually does the text layout can access those tables without
|
||||
* error checking (which can be quite time consuming).
|
||||
*
|
||||
* @input:
|
||||
* face ::
|
||||
* A handle to the input face.
|
||||
*
|
||||
* validation_flags ::
|
||||
* A bit field that specifies the tables to be validated. See
|
||||
* @FT_VALIDATE_GXXXX for possible values.
|
||||
*
|
||||
* table_length ::
|
||||
* The size of the `tables' array. Normally, @FT_VALIDATE_GX_LENGTH
|
||||
* should be passed.
|
||||
*
|
||||
* @output:
|
||||
* tables ::
|
||||
* The array where all validated sfnt tables are stored.
|
||||
* The array itself must be allocated by a client.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* This function only works with TrueTypeGX fonts, returning an error
|
||||
* otherwise.
|
||||
*
|
||||
* After use, the application should deallocate the buffers pointed to by
|
||||
* each `tables' element, by calling @FT_TrueTypeGX_Free. A NULL value
|
||||
* indicates that the table either doesn't exist in the font, the
|
||||
* application hasn't asked for validation, or the validator doesn't have
|
||||
* the ability to validate the sfnt table.
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_TrueTypeGX_Validate( FT_Face face,
|
||||
FT_UInt validation_flags,
|
||||
FT_Bytes tables[FT_VALIDATE_GX_LENGTH],
|
||||
FT_UInt table_length );
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_TrueTypeGX_Free
|
||||
*
|
||||
* @description:
|
||||
* Free the buffer allocated by TrueTypeGX validator.
|
||||
*
|
||||
* @input:
|
||||
* face ::
|
||||
* A handle to the input face.
|
||||
*
|
||||
* table ::
|
||||
* The pointer to the buffer allocated by
|
||||
* @FT_TrueTypeGX_Validate.
|
||||
*
|
||||
* @note:
|
||||
* This function must be used to free the buffer allocated by
|
||||
* @FT_TrueTypeGX_Validate only.
|
||||
*/
|
||||
FT_EXPORT( void )
|
||||
FT_TrueTypeGX_Free( FT_Face face,
|
||||
FT_Bytes table );
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* @enum:
|
||||
* FT_VALIDATE_CKERNXXX
|
||||
*
|
||||
* @description:
|
||||
* A list of bit-field constants used with @FT_ClassicKern_Validate
|
||||
* to indicate the classic kern dialect or dialects. If the selected
|
||||
* type doesn't fit, @FT_ClassicKern_Validate regards the table as
|
||||
* invalid.
|
||||
*
|
||||
* @values:
|
||||
* FT_VALIDATE_MS ::
|
||||
* Handle the `kern' table as a classic Microsoft kern table.
|
||||
*
|
||||
* FT_VALIDATE_APPLE ::
|
||||
* Handle the `kern' table as a classic Apple kern table.
|
||||
*
|
||||
* FT_VALIDATE_CKERN ::
|
||||
* Handle the `kern' as either classic Apple or Microsoft kern table.
|
||||
*/
|
||||
#define FT_VALIDATE_MS ( FT_VALIDATE_GX_START << 0 )
|
||||
#define FT_VALIDATE_APPLE ( FT_VALIDATE_GX_START << 1 )
|
||||
|
||||
#define FT_VALIDATE_CKERN ( FT_VALIDATE_MS | FT_VALIDATE_APPLE )
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_ClassicKern_Validate
|
||||
*
|
||||
* @description:
|
||||
* Validate classic (16-bit format) kern table to assure that the offsets
|
||||
* and indices are valid. The idea is that a higher-level library that
|
||||
* actually does the text layout can access those tables without error
|
||||
* checking (which can be quite time consuming).
|
||||
*
|
||||
* The `kern' table validator in @FT_TrueTypeGX_Validate deals with both
|
||||
* the new 32-bit format and the classic 16-bit format, while
|
||||
* FT_ClassicKern_Validate only supports the classic 16-bit format.
|
||||
*
|
||||
* @input:
|
||||
* face ::
|
||||
* A handle to the input face.
|
||||
*
|
||||
* validation_flags ::
|
||||
* A bit field that specifies the dialect to be validated. See
|
||||
* @FT_VALIDATE_CKERNXXX for possible values.
|
||||
*
|
||||
* @output:
|
||||
* ckern_table ::
|
||||
* A pointer to the kern table.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* After use, the application should deallocate the buffers pointed to by
|
||||
* `ckern_table', by calling @FT_ClassicKern_Free. A NULL value
|
||||
* indicates that the table doesn't exist in the font.
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_ClassicKern_Validate( FT_Face face,
|
||||
FT_UInt validation_flags,
|
||||
FT_Bytes *ckern_table );
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_ClassicKern_Free
|
||||
*
|
||||
* @description:
|
||||
* Free the buffer allocated by classic Kern validator.
|
||||
*
|
||||
* @input:
|
||||
* face ::
|
||||
* A handle to the input face.
|
||||
*
|
||||
* table ::
|
||||
* The pointer to the buffer that is allocated by
|
||||
* @FT_ClassicKern_Validate.
|
||||
*
|
||||
* @note:
|
||||
* This function must be used to free the buffer allocated by
|
||||
* @FT_ClassicKern_Validate only.
|
||||
*/
|
||||
FT_EXPORT( void )
|
||||
FT_ClassicKern_Free( FT_Face face,
|
||||
FT_Bytes table );
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTGXVAL_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,151 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftgzip.h */
|
||||
/* */
|
||||
/* Gzip-compressed stream support. */
|
||||
/* */
|
||||
/* Copyright 2002-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTGZIP_H_
|
||||
#define FTGZIP_H_
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#ifdef FREETYPE_H
|
||||
#error "freetype.h of FreeType 1 has been loaded!"
|
||||
#error "Please fix the directory search order for header files"
|
||||
#error "so that freetype.h of FreeType 2 is found first."
|
||||
#endif
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* gzip */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* GZIP Streams */
|
||||
/* */
|
||||
/* <Abstract> */
|
||||
/* Using gzip-compressed font files. */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This section contains the declaration of Gzip-specific functions. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/************************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Stream_OpenGzip
|
||||
*
|
||||
* @description:
|
||||
* Open a new stream to parse gzip-compressed font files. This is
|
||||
* mainly used to support the compressed `*.pcf.gz' fonts that come
|
||||
* with XFree86.
|
||||
*
|
||||
* @input:
|
||||
* stream ::
|
||||
* The target embedding stream.
|
||||
*
|
||||
* source ::
|
||||
* The source stream.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* The source stream must be opened _before_ calling this function.
|
||||
*
|
||||
* Calling the internal function `FT_Stream_Close' on the new stream will
|
||||
* *not* call `FT_Stream_Close' on the source stream. None of the stream
|
||||
* objects will be released to the heap.
|
||||
*
|
||||
* The stream implementation is very basic and resets the decompression
|
||||
* process each time seeking backwards is needed within the stream.
|
||||
*
|
||||
* In certain builds of the library, gzip compression recognition is
|
||||
* automatically handled when calling @FT_New_Face or @FT_Open_Face.
|
||||
* This means that if no font driver is capable of handling the raw
|
||||
* compressed file, the library will try to open a gzipped stream from
|
||||
* it and re-open the face with it.
|
||||
*
|
||||
* This function may return `FT_Err_Unimplemented_Feature' if your build
|
||||
* of FreeType was not compiled with zlib support.
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Stream_OpenGzip( FT_Stream stream,
|
||||
FT_Stream source );
|
||||
|
||||
|
||||
/************************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Gzip_Uncompress
|
||||
*
|
||||
* @description:
|
||||
* Decompress a zipped input buffer into an output buffer. This function
|
||||
* is modeled after zlib's `uncompress' function.
|
||||
*
|
||||
* @input:
|
||||
* memory ::
|
||||
* A FreeType memory handle.
|
||||
*
|
||||
* input ::
|
||||
* The input buffer.
|
||||
*
|
||||
* input_len ::
|
||||
* The length of the input buffer.
|
||||
*
|
||||
* @output:
|
||||
* output::
|
||||
* The output buffer.
|
||||
*
|
||||
* @inout:
|
||||
* output_len ::
|
||||
* Before calling the function, this is the total size of the output
|
||||
* buffer, which must be large enough to hold the entire uncompressed
|
||||
* data (so the size of the uncompressed data must be known in
|
||||
* advance). After calling the function, `output_len' is the size of
|
||||
* the used data in `output'.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* This function may return `FT_Err_Unimplemented_Feature' if your build
|
||||
* of FreeType was not compiled with zlib support.
|
||||
*
|
||||
* @since:
|
||||
* 2.5.1
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Gzip_Uncompress( FT_Memory memory,
|
||||
FT_Byte* output,
|
||||
FT_ULong* output_len,
|
||||
const FT_Byte* input,
|
||||
FT_ULong input_len );
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTGZIP_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,1205 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftimage.h */
|
||||
/* */
|
||||
/* FreeType glyph image formats and default raster interface */
|
||||
/* (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Note: A `raster' is simply a scan-line converter, used to render */
|
||||
/* FT_Outlines into FT_Bitmaps. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTIMAGE_H_
|
||||
#define FTIMAGE_H_
|
||||
|
||||
|
||||
/* STANDALONE_ is from ftgrays.c */
|
||||
#ifndef STANDALONE_
|
||||
#include <ft2build.h>
|
||||
#endif
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* basic_types */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Pos */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The type FT_Pos is used to store vectorial coordinates. Depending */
|
||||
/* on the context, these can represent distances in integer font */
|
||||
/* units, or 16.16, or 26.6 fixed-point pixel coordinates. */
|
||||
/* */
|
||||
typedef signed long FT_Pos;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_Vector */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A simple structure used to store a 2D vector; coordinates are of */
|
||||
/* the FT_Pos type. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* x :: The horizontal coordinate. */
|
||||
/* y :: The vertical coordinate. */
|
||||
/* */
|
||||
typedef struct FT_Vector_
|
||||
{
|
||||
FT_Pos x;
|
||||
FT_Pos y;
|
||||
|
||||
} FT_Vector;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_BBox */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to hold an outline's bounding box, i.e., the */
|
||||
/* coordinates of its extrema in the horizontal and vertical */
|
||||
/* directions. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* xMin :: The horizontal minimum (left-most). */
|
||||
/* */
|
||||
/* yMin :: The vertical minimum (bottom-most). */
|
||||
/* */
|
||||
/* xMax :: The horizontal maximum (right-most). */
|
||||
/* */
|
||||
/* yMax :: The vertical maximum (top-most). */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The bounding box is specified with the coordinates of the lower */
|
||||
/* left and the upper right corner. In PostScript, those values are */
|
||||
/* often called (llx,lly) and (urx,ury), respectively. */
|
||||
/* */
|
||||
/* If `yMin' is negative, this value gives the glyph's descender. */
|
||||
/* Otherwise, the glyph doesn't descend below the baseline. */
|
||||
/* Similarly, if `ymax' is positive, this value gives the glyph's */
|
||||
/* ascender. */
|
||||
/* */
|
||||
/* `xMin' gives the horizontal distance from the glyph's origin to */
|
||||
/* the left edge of the glyph's bounding box. If `xMin' is negative, */
|
||||
/* the glyph extends to the left of the origin. */
|
||||
/* */
|
||||
typedef struct FT_BBox_
|
||||
{
|
||||
FT_Pos xMin, yMin;
|
||||
FT_Pos xMax, yMax;
|
||||
|
||||
} FT_BBox;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Enum> */
|
||||
/* FT_Pixel_Mode */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* An enumeration type used to describe the format of pixels in a */
|
||||
/* given bitmap. Note that additional formats may be added in the */
|
||||
/* future. */
|
||||
/* */
|
||||
/* <Values> */
|
||||
/* FT_PIXEL_MODE_NONE :: */
|
||||
/* Value~0 is reserved. */
|
||||
/* */
|
||||
/* FT_PIXEL_MODE_MONO :: */
|
||||
/* A monochrome bitmap, using 1~bit per pixel. Note that pixels */
|
||||
/* are stored in most-significant order (MSB), which means that */
|
||||
/* the left-most pixel in a byte has value 128. */
|
||||
/* */
|
||||
/* FT_PIXEL_MODE_GRAY :: */
|
||||
/* An 8-bit bitmap, generally used to represent anti-aliased glyph */
|
||||
/* images. Each pixel is stored in one byte. Note that the number */
|
||||
/* of `gray' levels is stored in the `num_grays' field of the */
|
||||
/* @FT_Bitmap structure (it generally is 256). */
|
||||
/* */
|
||||
/* FT_PIXEL_MODE_GRAY2 :: */
|
||||
/* A 2-bit per pixel bitmap, used to represent embedded */
|
||||
/* anti-aliased bitmaps in font files according to the OpenType */
|
||||
/* specification. We haven't found a single font using this */
|
||||
/* format, however. */
|
||||
/* */
|
||||
/* FT_PIXEL_MODE_GRAY4 :: */
|
||||
/* A 4-bit per pixel bitmap, representing embedded anti-aliased */
|
||||
/* bitmaps in font files according to the OpenType specification. */
|
||||
/* We haven't found a single font using this format, however. */
|
||||
/* */
|
||||
/* FT_PIXEL_MODE_LCD :: */
|
||||
/* An 8-bit bitmap, representing RGB or BGR decimated glyph images */
|
||||
/* used for display on LCD displays; the bitmap is three times */
|
||||
/* wider than the original glyph image. See also */
|
||||
/* @FT_RENDER_MODE_LCD. */
|
||||
/* */
|
||||
/* FT_PIXEL_MODE_LCD_V :: */
|
||||
/* An 8-bit bitmap, representing RGB or BGR decimated glyph images */
|
||||
/* used for display on rotated LCD displays; the bitmap is three */
|
||||
/* times taller than the original glyph image. See also */
|
||||
/* @FT_RENDER_MODE_LCD_V. */
|
||||
/* */
|
||||
/* FT_PIXEL_MODE_BGRA :: */
|
||||
/* [Since 2.5] An image with four 8-bit channels per pixel, */
|
||||
/* representing a color image (such as emoticons) with alpha */
|
||||
/* channel. For each pixel, the format is BGRA, which means, the */
|
||||
/* blue channel comes first in memory. The color channels are */
|
||||
/* pre-multiplied and in the sRGB colorspace. For example, full */
|
||||
/* red at half-translucent opacity will be represented as */
|
||||
/* `00,00,80,80', not `00,00,FF,80'. See also @FT_LOAD_COLOR. */
|
||||
/* */
|
||||
typedef enum FT_Pixel_Mode_
|
||||
{
|
||||
FT_PIXEL_MODE_NONE = 0,
|
||||
FT_PIXEL_MODE_MONO,
|
||||
FT_PIXEL_MODE_GRAY,
|
||||
FT_PIXEL_MODE_GRAY2,
|
||||
FT_PIXEL_MODE_GRAY4,
|
||||
FT_PIXEL_MODE_LCD,
|
||||
FT_PIXEL_MODE_LCD_V,
|
||||
FT_PIXEL_MODE_BGRA,
|
||||
|
||||
FT_PIXEL_MODE_MAX /* do not remove */
|
||||
|
||||
} FT_Pixel_Mode;
|
||||
|
||||
|
||||
/* these constants are deprecated; use the corresponding `FT_Pixel_Mode' */
|
||||
/* values instead. */
|
||||
#define ft_pixel_mode_none FT_PIXEL_MODE_NONE
|
||||
#define ft_pixel_mode_mono FT_PIXEL_MODE_MONO
|
||||
#define ft_pixel_mode_grays FT_PIXEL_MODE_GRAY
|
||||
#define ft_pixel_mode_pal2 FT_PIXEL_MODE_GRAY2
|
||||
#define ft_pixel_mode_pal4 FT_PIXEL_MODE_GRAY4
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_Bitmap */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to describe a bitmap or pixmap to the raster. */
|
||||
/* Note that we now manage pixmaps of various depths through the */
|
||||
/* `pixel_mode' field. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* rows :: The number of bitmap rows. */
|
||||
/* */
|
||||
/* width :: The number of pixels in bitmap row. */
|
||||
/* */
|
||||
/* pitch :: The pitch's absolute value is the number of bytes */
|
||||
/* taken by one bitmap row, including padding. */
|
||||
/* However, the pitch is positive when the bitmap has */
|
||||
/* a `down' flow, and negative when it has an `up' */
|
||||
/* flow. In all cases, the pitch is an offset to add */
|
||||
/* to a bitmap pointer in order to go down one row. */
|
||||
/* */
|
||||
/* Note that `padding' means the alignment of a */
|
||||
/* bitmap to a byte border, and FreeType functions */
|
||||
/* normally align to the smallest possible integer */
|
||||
/* value. */
|
||||
/* */
|
||||
/* For the B/W rasterizer, `pitch' is always an even */
|
||||
/* number. */
|
||||
/* */
|
||||
/* To change the pitch of a bitmap (say, to make it a */
|
||||
/* multiple of 4), use @FT_Bitmap_Convert. */
|
||||
/* Alternatively, you might use callback functions to */
|
||||
/* directly render to the application's surface; see */
|
||||
/* the file `example2.cpp' in the tutorial for a */
|
||||
/* demonstration. */
|
||||
/* */
|
||||
/* buffer :: A typeless pointer to the bitmap buffer. This */
|
||||
/* value should be aligned on 32-bit boundaries in */
|
||||
/* most cases. */
|
||||
/* */
|
||||
/* num_grays :: This field is only used with */
|
||||
/* @FT_PIXEL_MODE_GRAY; it gives the number of gray */
|
||||
/* levels used in the bitmap. */
|
||||
/* */
|
||||
/* pixel_mode :: The pixel mode, i.e., how pixel bits are stored. */
|
||||
/* See @FT_Pixel_Mode for possible values. */
|
||||
/* */
|
||||
/* palette_mode :: This field is intended for paletted pixel modes; */
|
||||
/* it indicates how the palette is stored. Not */
|
||||
/* used currently. */
|
||||
/* */
|
||||
/* palette :: A typeless pointer to the bitmap palette; this */
|
||||
/* field is intended for paletted pixel modes. Not */
|
||||
/* used currently. */
|
||||
/* */
|
||||
typedef struct FT_Bitmap_
|
||||
{
|
||||
unsigned int rows;
|
||||
unsigned int width;
|
||||
int pitch;
|
||||
unsigned char* buffer;
|
||||
unsigned short num_grays;
|
||||
unsigned char pixel_mode;
|
||||
unsigned char palette_mode;
|
||||
void* palette;
|
||||
|
||||
} FT_Bitmap;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* outline_processing */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_Outline */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This structure is used to describe an outline to the scan-line */
|
||||
/* converter. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* n_contours :: The number of contours in the outline. */
|
||||
/* */
|
||||
/* n_points :: The number of points in the outline. */
|
||||
/* */
|
||||
/* points :: A pointer to an array of `n_points' @FT_Vector */
|
||||
/* elements, giving the outline's point coordinates. */
|
||||
/* */
|
||||
/* tags :: A pointer to an array of `n_points' chars, giving */
|
||||
/* each outline point's type. */
|
||||
/* */
|
||||
/* If bit~0 is unset, the point is `off' the curve, */
|
||||
/* i.e., a Bezier control point, while it is `on' if */
|
||||
/* set. */
|
||||
/* */
|
||||
/* Bit~1 is meaningful for `off' points only. If set, */
|
||||
/* it indicates a third-order Bezier arc control point; */
|
||||
/* and a second-order control point if unset. */
|
||||
/* */
|
||||
/* If bit~2 is set, bits 5-7 contain the drop-out mode */
|
||||
/* (as defined in the OpenType specification; the value */
|
||||
/* is the same as the argument to the SCANMODE */
|
||||
/* instruction). */
|
||||
/* */
|
||||
/* Bits 3 and~4 are reserved for internal purposes. */
|
||||
/* */
|
||||
/* contours :: An array of `n_contours' shorts, giving the end */
|
||||
/* point of each contour within the outline. For */
|
||||
/* example, the first contour is defined by the points */
|
||||
/* `0' to `contours[0]', the second one is defined by */
|
||||
/* the points `contours[0]+1' to `contours[1]', etc. */
|
||||
/* */
|
||||
/* flags :: A set of bit flags used to characterize the outline */
|
||||
/* and give hints to the scan-converter and hinter on */
|
||||
/* how to convert/grid-fit it. See @FT_OUTLINE_XXX. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The B/W rasterizer only checks bit~2 in the `tags' array for the */
|
||||
/* first point of each contour. The drop-out mode as given with */
|
||||
/* @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, and */
|
||||
/* @FT_OUTLINE_INCLUDE_STUBS in `flags' is then overridden. */
|
||||
/* */
|
||||
typedef struct FT_Outline_
|
||||
{
|
||||
short n_contours; /* number of contours in glyph */
|
||||
short n_points; /* number of points in the glyph */
|
||||
|
||||
FT_Vector* points; /* the outline's points */
|
||||
char* tags; /* the points flags */
|
||||
short* contours; /* the contour end points */
|
||||
|
||||
int flags; /* outline masks */
|
||||
|
||||
} FT_Outline;
|
||||
|
||||
/* */
|
||||
|
||||
/* Following limits must be consistent with */
|
||||
/* FT_Outline.{n_contours,n_points} */
|
||||
#define FT_OUTLINE_CONTOURS_MAX SHRT_MAX
|
||||
#define FT_OUTLINE_POINTS_MAX SHRT_MAX
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Enum> */
|
||||
/* FT_OUTLINE_XXX */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A list of bit-field constants use for the flags in an outline's */
|
||||
/* `flags' field. */
|
||||
/* */
|
||||
/* <Values> */
|
||||
/* FT_OUTLINE_NONE :: */
|
||||
/* Value~0 is reserved. */
|
||||
/* */
|
||||
/* FT_OUTLINE_OWNER :: */
|
||||
/* If set, this flag indicates that the outline's field arrays */
|
||||
/* (i.e., `points', `flags', and `contours') are `owned' by the */
|
||||
/* outline object, and should thus be freed when it is destroyed. */
|
||||
/* */
|
||||
/* FT_OUTLINE_EVEN_ODD_FILL :: */
|
||||
/* By default, outlines are filled using the non-zero winding rule. */
|
||||
/* If set to 1, the outline will be filled using the even-odd fill */
|
||||
/* rule (only works with the smooth rasterizer). */
|
||||
/* */
|
||||
/* FT_OUTLINE_REVERSE_FILL :: */
|
||||
/* By default, outside contours of an outline are oriented in */
|
||||
/* clock-wise direction, as defined in the TrueType specification. */
|
||||
/* This flag is set if the outline uses the opposite direction */
|
||||
/* (typically for Type~1 fonts). This flag is ignored by the scan */
|
||||
/* converter. */
|
||||
/* */
|
||||
/* FT_OUTLINE_IGNORE_DROPOUTS :: */
|
||||
/* By default, the scan converter will try to detect drop-outs in */
|
||||
/* an outline and correct the glyph bitmap to ensure consistent */
|
||||
/* shape continuity. If set, this flag hints the scan-line */
|
||||
/* converter to ignore such cases. See below for more information. */
|
||||
/* */
|
||||
/* FT_OUTLINE_SMART_DROPOUTS :: */
|
||||
/* Select smart dropout control. If unset, use simple dropout */
|
||||
/* control. Ignored if @FT_OUTLINE_IGNORE_DROPOUTS is set. See */
|
||||
/* below for more information. */
|
||||
/* */
|
||||
/* FT_OUTLINE_INCLUDE_STUBS :: */
|
||||
/* If set, turn pixels on for `stubs', otherwise exclude them. */
|
||||
/* Ignored if @FT_OUTLINE_IGNORE_DROPOUTS is set. See below for */
|
||||
/* more information. */
|
||||
/* */
|
||||
/* FT_OUTLINE_HIGH_PRECISION :: */
|
||||
/* This flag indicates that the scan-line converter should try to */
|
||||
/* convert this outline to bitmaps with the highest possible */
|
||||
/* quality. It is typically set for small character sizes. Note */
|
||||
/* that this is only a hint that might be completely ignored by a */
|
||||
/* given scan-converter. */
|
||||
/* */
|
||||
/* FT_OUTLINE_SINGLE_PASS :: */
|
||||
/* This flag is set to force a given scan-converter to only use a */
|
||||
/* single pass over the outline to render a bitmap glyph image. */
|
||||
/* Normally, it is set for very large character sizes. It is only */
|
||||
/* a hint that might be completely ignored by a given */
|
||||
/* scan-converter. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The flags @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, */
|
||||
/* and @FT_OUTLINE_INCLUDE_STUBS are ignored by the smooth */
|
||||
/* rasterizer. */
|
||||
/* */
|
||||
/* There exists a second mechanism to pass the drop-out mode to the */
|
||||
/* B/W rasterizer; see the `tags' field in @FT_Outline. */
|
||||
/* */
|
||||
/* Please refer to the description of the `SCANTYPE' instruction in */
|
||||
/* the OpenType specification (in file `ttinst1.doc') how simple */
|
||||
/* drop-outs, smart drop-outs, and stubs are defined. */
|
||||
/* */
|
||||
#define FT_OUTLINE_NONE 0x0
|
||||
#define FT_OUTLINE_OWNER 0x1
|
||||
#define FT_OUTLINE_EVEN_ODD_FILL 0x2
|
||||
#define FT_OUTLINE_REVERSE_FILL 0x4
|
||||
#define FT_OUTLINE_IGNORE_DROPOUTS 0x8
|
||||
#define FT_OUTLINE_SMART_DROPOUTS 0x10
|
||||
#define FT_OUTLINE_INCLUDE_STUBS 0x20
|
||||
|
||||
#define FT_OUTLINE_HIGH_PRECISION 0x100
|
||||
#define FT_OUTLINE_SINGLE_PASS 0x200
|
||||
|
||||
|
||||
/* these constants are deprecated; use the corresponding */
|
||||
/* `FT_OUTLINE_XXX' values instead */
|
||||
#define ft_outline_none FT_OUTLINE_NONE
|
||||
#define ft_outline_owner FT_OUTLINE_OWNER
|
||||
#define ft_outline_even_odd_fill FT_OUTLINE_EVEN_ODD_FILL
|
||||
#define ft_outline_reverse_fill FT_OUTLINE_REVERSE_FILL
|
||||
#define ft_outline_ignore_dropouts FT_OUTLINE_IGNORE_DROPOUTS
|
||||
#define ft_outline_high_precision FT_OUTLINE_HIGH_PRECISION
|
||||
#define ft_outline_single_pass FT_OUTLINE_SINGLE_PASS
|
||||
|
||||
/* */
|
||||
|
||||
#define FT_CURVE_TAG( flag ) ( flag & 3 )
|
||||
|
||||
#define FT_CURVE_TAG_ON 1
|
||||
#define FT_CURVE_TAG_CONIC 0
|
||||
#define FT_CURVE_TAG_CUBIC 2
|
||||
|
||||
#define FT_CURVE_TAG_HAS_SCANMODE 4
|
||||
|
||||
#define FT_CURVE_TAG_TOUCH_X 8 /* reserved for the TrueType hinter */
|
||||
#define FT_CURVE_TAG_TOUCH_Y 16 /* reserved for the TrueType hinter */
|
||||
|
||||
#define FT_CURVE_TAG_TOUCH_BOTH ( FT_CURVE_TAG_TOUCH_X | \
|
||||
FT_CURVE_TAG_TOUCH_Y )
|
||||
|
||||
#define FT_Curve_Tag_On FT_CURVE_TAG_ON
|
||||
#define FT_Curve_Tag_Conic FT_CURVE_TAG_CONIC
|
||||
#define FT_Curve_Tag_Cubic FT_CURVE_TAG_CUBIC
|
||||
#define FT_Curve_Tag_Touch_X FT_CURVE_TAG_TOUCH_X
|
||||
#define FT_Curve_Tag_Touch_Y FT_CURVE_TAG_TOUCH_Y
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* FT_Outline_MoveToFunc */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A function pointer type used to describe the signature of a `move */
|
||||
/* to' function during outline walking/decomposition. */
|
||||
/* */
|
||||
/* A `move to' is emitted to start a new contour in an outline. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* to :: A pointer to the target point of the `move to'. */
|
||||
/* */
|
||||
/* user :: A typeless pointer, which is passed from the caller of the */
|
||||
/* decomposition function. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* Error code. 0~means success. */
|
||||
/* */
|
||||
typedef int
|
||||
(*FT_Outline_MoveToFunc)( const FT_Vector* to,
|
||||
void* user );
|
||||
|
||||
#define FT_Outline_MoveTo_Func FT_Outline_MoveToFunc
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* FT_Outline_LineToFunc */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A function pointer type used to describe the signature of a `line */
|
||||
/* to' function during outline walking/decomposition. */
|
||||
/* */
|
||||
/* A `line to' is emitted to indicate a segment in the outline. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* to :: A pointer to the target point of the `line to'. */
|
||||
/* */
|
||||
/* user :: A typeless pointer, which is passed from the caller of the */
|
||||
/* decomposition function. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* Error code. 0~means success. */
|
||||
/* */
|
||||
typedef int
|
||||
(*FT_Outline_LineToFunc)( const FT_Vector* to,
|
||||
void* user );
|
||||
|
||||
#define FT_Outline_LineTo_Func FT_Outline_LineToFunc
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* FT_Outline_ConicToFunc */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A function pointer type used to describe the signature of a `conic */
|
||||
/* to' function during outline walking or decomposition. */
|
||||
/* */
|
||||
/* A `conic to' is emitted to indicate a second-order Bezier arc in */
|
||||
/* the outline. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* control :: An intermediate control point between the last position */
|
||||
/* and the new target in `to'. */
|
||||
/* */
|
||||
/* to :: A pointer to the target end point of the conic arc. */
|
||||
/* */
|
||||
/* user :: A typeless pointer, which is passed from the caller of */
|
||||
/* the decomposition function. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* Error code. 0~means success. */
|
||||
/* */
|
||||
typedef int
|
||||
(*FT_Outline_ConicToFunc)( const FT_Vector* control,
|
||||
const FT_Vector* to,
|
||||
void* user );
|
||||
|
||||
#define FT_Outline_ConicTo_Func FT_Outline_ConicToFunc
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* FT_Outline_CubicToFunc */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A function pointer type used to describe the signature of a `cubic */
|
||||
/* to' function during outline walking or decomposition. */
|
||||
/* */
|
||||
/* A `cubic to' is emitted to indicate a third-order Bezier arc. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* control1 :: A pointer to the first Bezier control point. */
|
||||
/* */
|
||||
/* control2 :: A pointer to the second Bezier control point. */
|
||||
/* */
|
||||
/* to :: A pointer to the target end point. */
|
||||
/* */
|
||||
/* user :: A typeless pointer, which is passed from the caller of */
|
||||
/* the decomposition function. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* Error code. 0~means success. */
|
||||
/* */
|
||||
typedef int
|
||||
(*FT_Outline_CubicToFunc)( const FT_Vector* control1,
|
||||
const FT_Vector* control2,
|
||||
const FT_Vector* to,
|
||||
void* user );
|
||||
|
||||
#define FT_Outline_CubicTo_Func FT_Outline_CubicToFunc
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_Outline_Funcs */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure to hold various function pointers used during outline */
|
||||
/* decomposition in order to emit segments, conic, and cubic Beziers. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* move_to :: The `move to' emitter. */
|
||||
/* */
|
||||
/* line_to :: The segment emitter. */
|
||||
/* */
|
||||
/* conic_to :: The second-order Bezier arc emitter. */
|
||||
/* */
|
||||
/* cubic_to :: The third-order Bezier arc emitter. */
|
||||
/* */
|
||||
/* shift :: The shift that is applied to coordinates before they */
|
||||
/* are sent to the emitter. */
|
||||
/* */
|
||||
/* delta :: The delta that is applied to coordinates before they */
|
||||
/* are sent to the emitter, but after the shift. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The point coordinates sent to the emitters are the transformed */
|
||||
/* version of the original coordinates (this is important for high */
|
||||
/* accuracy during scan-conversion). The transformation is simple: */
|
||||
/* */
|
||||
/* { */
|
||||
/* x' = (x << shift) - delta */
|
||||
/* y' = (y << shift) - delta */
|
||||
/* } */
|
||||
/* */
|
||||
/* Set the values of `shift' and `delta' to~0 to get the original */
|
||||
/* point coordinates. */
|
||||
/* */
|
||||
typedef struct FT_Outline_Funcs_
|
||||
{
|
||||
FT_Outline_MoveToFunc move_to;
|
||||
FT_Outline_LineToFunc line_to;
|
||||
FT_Outline_ConicToFunc conic_to;
|
||||
FT_Outline_CubicToFunc cubic_to;
|
||||
|
||||
int shift;
|
||||
FT_Pos delta;
|
||||
|
||||
} FT_Outline_Funcs;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* basic_types */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Macro> */
|
||||
/* FT_IMAGE_TAG */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This macro converts four-letter tags to an unsigned long type. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* Since many 16-bit compilers don't like 32-bit enumerations, you */
|
||||
/* should redefine this macro in case of problems to something like */
|
||||
/* this: */
|
||||
/* */
|
||||
/* { */
|
||||
/* #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) value */
|
||||
/* } */
|
||||
/* */
|
||||
/* to get a simple enumeration without assigning special numbers. */
|
||||
/* */
|
||||
#ifndef FT_IMAGE_TAG
|
||||
#define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) \
|
||||
value = ( ( (unsigned long)_x1 << 24 ) | \
|
||||
( (unsigned long)_x2 << 16 ) | \
|
||||
( (unsigned long)_x3 << 8 ) | \
|
||||
(unsigned long)_x4 )
|
||||
#endif /* FT_IMAGE_TAG */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Enum> */
|
||||
/* FT_Glyph_Format */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* An enumeration type used to describe the format of a given glyph */
|
||||
/* image. Note that this version of FreeType only supports two image */
|
||||
/* formats, even though future font drivers will be able to register */
|
||||
/* their own format. */
|
||||
/* */
|
||||
/* <Values> */
|
||||
/* FT_GLYPH_FORMAT_NONE :: */
|
||||
/* The value~0 is reserved. */
|
||||
/* */
|
||||
/* FT_GLYPH_FORMAT_COMPOSITE :: */
|
||||
/* The glyph image is a composite of several other images. This */
|
||||
/* format is _only_ used with @FT_LOAD_NO_RECURSE, and is used to */
|
||||
/* report compound glyphs (like accented characters). */
|
||||
/* */
|
||||
/* FT_GLYPH_FORMAT_BITMAP :: */
|
||||
/* The glyph image is a bitmap, and can be described as an */
|
||||
/* @FT_Bitmap. You generally need to access the `bitmap' field of */
|
||||
/* the @FT_GlyphSlotRec structure to read it. */
|
||||
/* */
|
||||
/* FT_GLYPH_FORMAT_OUTLINE :: */
|
||||
/* The glyph image is a vectorial outline made of line segments */
|
||||
/* and Bezier arcs; it can be described as an @FT_Outline; you */
|
||||
/* generally want to access the `outline' field of the */
|
||||
/* @FT_GlyphSlotRec structure to read it. */
|
||||
/* */
|
||||
/* FT_GLYPH_FORMAT_PLOTTER :: */
|
||||
/* The glyph image is a vectorial path with no inside and outside */
|
||||
/* contours. Some Type~1 fonts, like those in the Hershey family, */
|
||||
/* contain glyphs in this format. These are described as */
|
||||
/* @FT_Outline, but FreeType isn't currently capable of rendering */
|
||||
/* them correctly. */
|
||||
/* */
|
||||
typedef enum FT_Glyph_Format_
|
||||
{
|
||||
FT_IMAGE_TAG( FT_GLYPH_FORMAT_NONE, 0, 0, 0, 0 ),
|
||||
|
||||
FT_IMAGE_TAG( FT_GLYPH_FORMAT_COMPOSITE, 'c', 'o', 'm', 'p' ),
|
||||
FT_IMAGE_TAG( FT_GLYPH_FORMAT_BITMAP, 'b', 'i', 't', 's' ),
|
||||
FT_IMAGE_TAG( FT_GLYPH_FORMAT_OUTLINE, 'o', 'u', 't', 'l' ),
|
||||
FT_IMAGE_TAG( FT_GLYPH_FORMAT_PLOTTER, 'p', 'l', 'o', 't' )
|
||||
|
||||
} FT_Glyph_Format;
|
||||
|
||||
|
||||
/* these constants are deprecated; use the corresponding */
|
||||
/* `FT_Glyph_Format' values instead. */
|
||||
#define ft_glyph_format_none FT_GLYPH_FORMAT_NONE
|
||||
#define ft_glyph_format_composite FT_GLYPH_FORMAT_COMPOSITE
|
||||
#define ft_glyph_format_bitmap FT_GLYPH_FORMAT_BITMAP
|
||||
#define ft_glyph_format_outline FT_GLYPH_FORMAT_OUTLINE
|
||||
#define ft_glyph_format_plotter FT_GLYPH_FORMAT_PLOTTER
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/***** *****/
|
||||
/***** R A S T E R D E F I N I T I O N S *****/
|
||||
/***** *****/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* A raster is a scan converter, in charge of rendering an outline into */
|
||||
/* a bitmap. This section contains the public API for rasters. */
|
||||
/* */
|
||||
/* Note that in FreeType 2, all rasters are now encapsulated within */
|
||||
/* specific modules called `renderers'. See `ftrender.h' for more */
|
||||
/* details on renderers. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* raster */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* Scanline Converter */
|
||||
/* */
|
||||
/* <Abstract> */
|
||||
/* How vectorial outlines are converted into bitmaps and pixmaps. */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This section contains technical definitions. */
|
||||
/* */
|
||||
/* <Order> */
|
||||
/* FT_Raster */
|
||||
/* FT_Span */
|
||||
/* FT_SpanFunc */
|
||||
/* */
|
||||
/* FT_Raster_Params */
|
||||
/* FT_RASTER_FLAG_XXX */
|
||||
/* */
|
||||
/* FT_Raster_NewFunc */
|
||||
/* FT_Raster_DoneFunc */
|
||||
/* FT_Raster_ResetFunc */
|
||||
/* FT_Raster_SetModeFunc */
|
||||
/* FT_Raster_RenderFunc */
|
||||
/* FT_Raster_Funcs */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Raster */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* An opaque handle (pointer) to a raster object. Each object can be */
|
||||
/* used independently to convert an outline into a bitmap or pixmap. */
|
||||
/* */
|
||||
typedef struct FT_RasterRec_* FT_Raster;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_Span */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to model a single span of gray pixels when */
|
||||
/* rendering an anti-aliased bitmap. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* x :: The span's horizontal start position. */
|
||||
/* */
|
||||
/* len :: The span's length in pixels. */
|
||||
/* */
|
||||
/* coverage :: The span color/coverage, ranging from 0 (background) */
|
||||
/* to 255 (foreground). */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This structure is used by the span drawing callback type named */
|
||||
/* @FT_SpanFunc that takes the y~coordinate of the span as a */
|
||||
/* parameter. */
|
||||
/* */
|
||||
/* The coverage value is always between 0 and 255. If you want less */
|
||||
/* gray values, the callback function has to reduce them. */
|
||||
/* */
|
||||
typedef struct FT_Span_
|
||||
{
|
||||
short x;
|
||||
unsigned short len;
|
||||
unsigned char coverage;
|
||||
|
||||
} FT_Span;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* FT_SpanFunc */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A function used as a call-back by the anti-aliased renderer in */
|
||||
/* order to let client applications draw themselves the gray pixel */
|
||||
/* spans on each scan line. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* y :: The scanline's y~coordinate. */
|
||||
/* */
|
||||
/* count :: The number of spans to draw on this scanline. */
|
||||
/* */
|
||||
/* spans :: A table of `count' spans to draw on the scanline. */
|
||||
/* */
|
||||
/* user :: User-supplied data that is passed to the callback. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This callback allows client applications to directly render the */
|
||||
/* gray spans of the anti-aliased bitmap to any kind of surfaces. */
|
||||
/* */
|
||||
/* This can be used to write anti-aliased outlines directly to a */
|
||||
/* given background bitmap, and even perform translucency. */
|
||||
/* */
|
||||
typedef void
|
||||
(*FT_SpanFunc)( int y,
|
||||
int count,
|
||||
const FT_Span* spans,
|
||||
void* user );
|
||||
|
||||
#define FT_Raster_Span_Func FT_SpanFunc
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* FT_Raster_BitTest_Func */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Deprecated, unimplemented. */
|
||||
/* */
|
||||
typedef int
|
||||
(*FT_Raster_BitTest_Func)( int y,
|
||||
int x,
|
||||
void* user );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* FT_Raster_BitSet_Func */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Deprecated, unimplemented. */
|
||||
/* */
|
||||
typedef void
|
||||
(*FT_Raster_BitSet_Func)( int y,
|
||||
int x,
|
||||
void* user );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Enum> */
|
||||
/* FT_RASTER_FLAG_XXX */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A list of bit flag constants as used in the `flags' field of a */
|
||||
/* @FT_Raster_Params structure. */
|
||||
/* */
|
||||
/* <Values> */
|
||||
/* FT_RASTER_FLAG_DEFAULT :: This value is 0. */
|
||||
/* */
|
||||
/* FT_RASTER_FLAG_AA :: This flag is set to indicate that an */
|
||||
/* anti-aliased glyph image should be */
|
||||
/* generated. Otherwise, it will be */
|
||||
/* monochrome (1-bit). */
|
||||
/* */
|
||||
/* FT_RASTER_FLAG_DIRECT :: This flag is set to indicate direct */
|
||||
/* rendering. In this mode, client */
|
||||
/* applications must provide their own span */
|
||||
/* callback. This lets them directly */
|
||||
/* draw or compose over an existing bitmap. */
|
||||
/* If this bit is not set, the target */
|
||||
/* pixmap's buffer _must_ be zeroed before */
|
||||
/* rendering. */
|
||||
/* */
|
||||
/* Direct rendering is only possible with */
|
||||
/* anti-aliased glyphs. */
|
||||
/* */
|
||||
/* FT_RASTER_FLAG_CLIP :: This flag is only used in direct */
|
||||
/* rendering mode. If set, the output will */
|
||||
/* be clipped to a box specified in the */
|
||||
/* `clip_box' field of the */
|
||||
/* @FT_Raster_Params structure. */
|
||||
/* */
|
||||
/* Note that by default, the glyph bitmap */
|
||||
/* is clipped to the target pixmap, except */
|
||||
/* in direct rendering mode where all spans */
|
||||
/* are generated if no clipping box is set. */
|
||||
/* */
|
||||
#define FT_RASTER_FLAG_DEFAULT 0x0
|
||||
#define FT_RASTER_FLAG_AA 0x1
|
||||
#define FT_RASTER_FLAG_DIRECT 0x2
|
||||
#define FT_RASTER_FLAG_CLIP 0x4
|
||||
|
||||
/* these constants are deprecated; use the corresponding */
|
||||
/* `FT_RASTER_FLAG_XXX' values instead */
|
||||
#define ft_raster_flag_default FT_RASTER_FLAG_DEFAULT
|
||||
#define ft_raster_flag_aa FT_RASTER_FLAG_AA
|
||||
#define ft_raster_flag_direct FT_RASTER_FLAG_DIRECT
|
||||
#define ft_raster_flag_clip FT_RASTER_FLAG_CLIP
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_Raster_Params */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure to hold the arguments used by a raster's render */
|
||||
/* function. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* target :: The target bitmap. */
|
||||
/* */
|
||||
/* source :: A pointer to the source glyph image (e.g., an */
|
||||
/* @FT_Outline). */
|
||||
/* */
|
||||
/* flags :: The rendering flags. */
|
||||
/* */
|
||||
/* gray_spans :: The gray span drawing callback. */
|
||||
/* */
|
||||
/* black_spans :: Unused. */
|
||||
/* */
|
||||
/* bit_test :: Unused. */
|
||||
/* */
|
||||
/* bit_set :: Unused. */
|
||||
/* */
|
||||
/* user :: User-supplied data that is passed to each drawing */
|
||||
/* callback. */
|
||||
/* */
|
||||
/* clip_box :: An optional clipping box. It is only used in */
|
||||
/* direct rendering mode. Note that coordinates here */
|
||||
/* should be expressed in _integer_ pixels (and not in */
|
||||
/* 26.6 fixed-point units). */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* An anti-aliased glyph bitmap is drawn if the @FT_RASTER_FLAG_AA */
|
||||
/* bit flag is set in the `flags' field, otherwise a monochrome */
|
||||
/* bitmap is generated. */
|
||||
/* */
|
||||
/* If the @FT_RASTER_FLAG_DIRECT bit flag is set in `flags', the */
|
||||
/* raster will call the `gray_spans' callback to draw gray pixel */
|
||||
/* spans. This allows direct composition over a pre-existing bitmap */
|
||||
/* through user-provided callbacks to perform the span drawing and */
|
||||
/* composition. Not supported by the monochrome rasterizer. */
|
||||
/* */
|
||||
typedef struct FT_Raster_Params_
|
||||
{
|
||||
const FT_Bitmap* target;
|
||||
const void* source;
|
||||
int flags;
|
||||
FT_SpanFunc gray_spans;
|
||||
FT_SpanFunc black_spans; /* unused */
|
||||
FT_Raster_BitTest_Func bit_test; /* unused */
|
||||
FT_Raster_BitSet_Func bit_set; /* unused */
|
||||
void* user;
|
||||
FT_BBox clip_box;
|
||||
|
||||
} FT_Raster_Params;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* FT_Raster_NewFunc */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A function used to create a new raster object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* memory :: A handle to the memory allocator. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* raster :: A handle to the new raster object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* Error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The `memory' parameter is a typeless pointer in order to avoid */
|
||||
/* un-wanted dependencies on the rest of the FreeType code. In */
|
||||
/* practice, it is an @FT_Memory object, i.e., a handle to the */
|
||||
/* standard FreeType memory allocator. However, this field can be */
|
||||
/* completely ignored by a given raster implementation. */
|
||||
/* */
|
||||
typedef int
|
||||
(*FT_Raster_NewFunc)( void* memory,
|
||||
FT_Raster* raster );
|
||||
|
||||
#define FT_Raster_New_Func FT_Raster_NewFunc
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* FT_Raster_DoneFunc */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A function used to destroy a given raster object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* raster :: A handle to the raster object. */
|
||||
/* */
|
||||
typedef void
|
||||
(*FT_Raster_DoneFunc)( FT_Raster raster );
|
||||
|
||||
#define FT_Raster_Done_Func FT_Raster_DoneFunc
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* FT_Raster_ResetFunc */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* FreeType used to provide an area of memory called the `render */
|
||||
/* pool' available to all registered rasterizers. This was not */
|
||||
/* thread safe, however, and now FreeType never allocates this pool. */
|
||||
/* */
|
||||
/* This function is called after a new raster object is created. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* raster :: A handle to the new raster object. */
|
||||
/* */
|
||||
/* pool_base :: Previously, the address in memory of the render pool. */
|
||||
/* Set this to NULL. */
|
||||
/* */
|
||||
/* pool_size :: Previously, the size in bytes of the render pool. */
|
||||
/* Set this to 0. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* Rasterizers should rely on dynamic or stack allocation if they */
|
||||
/* want to (a handle to the memory allocator is passed to the */
|
||||
/* rasterizer constructor). */
|
||||
/* */
|
||||
typedef void
|
||||
(*FT_Raster_ResetFunc)( FT_Raster raster,
|
||||
unsigned char* pool_base,
|
||||
unsigned long pool_size );
|
||||
|
||||
#define FT_Raster_Reset_Func FT_Raster_ResetFunc
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* FT_Raster_SetModeFunc */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This function is a generic facility to change modes or attributes */
|
||||
/* in a given raster. This can be used for debugging purposes, or */
|
||||
/* simply to allow implementation-specific `features' in a given */
|
||||
/* raster module. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* raster :: A handle to the new raster object. */
|
||||
/* */
|
||||
/* mode :: A 4-byte tag used to name the mode or property. */
|
||||
/* */
|
||||
/* args :: A pointer to the new mode/property to use. */
|
||||
/* */
|
||||
typedef int
|
||||
(*FT_Raster_SetModeFunc)( FT_Raster raster,
|
||||
unsigned long mode,
|
||||
void* args );
|
||||
|
||||
#define FT_Raster_Set_Mode_Func FT_Raster_SetModeFunc
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* FT_Raster_RenderFunc */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Invoke a given raster to scan-convert a given glyph image into a */
|
||||
/* target bitmap. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* raster :: A handle to the raster object. */
|
||||
/* */
|
||||
/* params :: A pointer to an @FT_Raster_Params structure used to */
|
||||
/* store the rendering parameters. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* Error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The exact format of the source image depends on the raster's glyph */
|
||||
/* format defined in its @FT_Raster_Funcs structure. It can be an */
|
||||
/* @FT_Outline or anything else in order to support a large array of */
|
||||
/* glyph formats. */
|
||||
/* */
|
||||
/* Note also that the render function can fail and return a */
|
||||
/* `FT_Err_Unimplemented_Feature' error code if the raster used does */
|
||||
/* not support direct composition. */
|
||||
/* */
|
||||
/* XXX: For now, the standard raster doesn't support direct */
|
||||
/* composition but this should change for the final release (see */
|
||||
/* the files `demos/src/ftgrays.c' and `demos/src/ftgrays2.c' */
|
||||
/* for examples of distinct implementations that support direct */
|
||||
/* composition). */
|
||||
/* */
|
||||
typedef int
|
||||
(*FT_Raster_RenderFunc)( FT_Raster raster,
|
||||
const FT_Raster_Params* params );
|
||||
|
||||
#define FT_Raster_Render_Func FT_Raster_RenderFunc
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_Raster_Funcs */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to describe a given raster class to the library. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* glyph_format :: The supported glyph format for this raster. */
|
||||
/* */
|
||||
/* raster_new :: The raster constructor. */
|
||||
/* */
|
||||
/* raster_reset :: Used to reset the render pool within the raster. */
|
||||
/* */
|
||||
/* raster_render :: A function to render a glyph into a given bitmap. */
|
||||
/* */
|
||||
/* raster_done :: The raster destructor. */
|
||||
/* */
|
||||
typedef struct FT_Raster_Funcs_
|
||||
{
|
||||
FT_Glyph_Format glyph_format;
|
||||
|
||||
FT_Raster_NewFunc raster_new;
|
||||
FT_Raster_ResetFunc raster_reset;
|
||||
FT_Raster_SetModeFunc raster_set_mode;
|
||||
FT_Raster_RenderFunc raster_render;
|
||||
FT_Raster_DoneFunc raster_done;
|
||||
|
||||
} FT_Raster_Funcs;
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTIMAGE_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
|
||||
|
||||
/* Local Variables: */
|
||||
/* coding: utf-8 */
|
||||
/* End: */
|
||||
@@ -0,0 +1,343 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftincrem.h */
|
||||
/* */
|
||||
/* FreeType incremental loading (specification). */
|
||||
/* */
|
||||
/* Copyright 2002-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTINCREM_H_
|
||||
#define FTINCREM_H_
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_PARAMETER_TAGS_H
|
||||
|
||||
#ifdef FREETYPE_H
|
||||
#error "freetype.h of FreeType 1 has been loaded!"
|
||||
#error "Please fix the directory search order for header files"
|
||||
#error "so that freetype.h of FreeType 2 is found first."
|
||||
#endif
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
/***************************************************************************
|
||||
*
|
||||
* @section:
|
||||
* incremental
|
||||
*
|
||||
* @title:
|
||||
* Incremental Loading
|
||||
*
|
||||
* @abstract:
|
||||
* Custom Glyph Loading.
|
||||
*
|
||||
* @description:
|
||||
* This section contains various functions used to perform so-called
|
||||
* `incremental' glyph loading. This is a mode where all glyphs loaded
|
||||
* from a given @FT_Face are provided by the client application.
|
||||
*
|
||||
* Apart from that, all other tables are loaded normally from the font
|
||||
* file. This mode is useful when FreeType is used within another
|
||||
* engine, e.g., a PostScript Imaging Processor.
|
||||
*
|
||||
* To enable this mode, you must use @FT_Open_Face, passing an
|
||||
* @FT_Parameter with the @FT_PARAM_TAG_INCREMENTAL tag and an
|
||||
* @FT_Incremental_Interface value. See the comments for
|
||||
* @FT_Incremental_InterfaceRec for an example.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
*
|
||||
* @type:
|
||||
* FT_Incremental
|
||||
*
|
||||
* @description:
|
||||
* An opaque type describing a user-provided object used to implement
|
||||
* `incremental' glyph loading within FreeType. This is used to support
|
||||
* embedded fonts in certain environments (e.g., PostScript interpreters),
|
||||
* where the glyph data isn't in the font file, or must be overridden by
|
||||
* different values.
|
||||
*
|
||||
* @note:
|
||||
* It is up to client applications to create and implement @FT_Incremental
|
||||
* objects, as long as they provide implementations for the methods
|
||||
* @FT_Incremental_GetGlyphDataFunc, @FT_Incremental_FreeGlyphDataFunc
|
||||
* and @FT_Incremental_GetGlyphMetricsFunc.
|
||||
*
|
||||
* See the description of @FT_Incremental_InterfaceRec to understand how
|
||||
* to use incremental objects with FreeType.
|
||||
*
|
||||
*/
|
||||
typedef struct FT_IncrementalRec_* FT_Incremental;
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
*
|
||||
* @struct:
|
||||
* FT_Incremental_MetricsRec
|
||||
*
|
||||
* @description:
|
||||
* A small structure used to contain the basic glyph metrics returned
|
||||
* by the @FT_Incremental_GetGlyphMetricsFunc method.
|
||||
*
|
||||
* @fields:
|
||||
* bearing_x ::
|
||||
* Left bearing, in font units.
|
||||
*
|
||||
* bearing_y ::
|
||||
* Top bearing, in font units.
|
||||
*
|
||||
* advance ::
|
||||
* Horizontal component of glyph advance, in font units.
|
||||
*
|
||||
* advance_v ::
|
||||
* Vertical component of glyph advance, in font units.
|
||||
*
|
||||
* @note:
|
||||
* These correspond to horizontal or vertical metrics depending on the
|
||||
* value of the `vertical' argument to the function
|
||||
* @FT_Incremental_GetGlyphMetricsFunc.
|
||||
*
|
||||
*/
|
||||
typedef struct FT_Incremental_MetricsRec_
|
||||
{
|
||||
FT_Long bearing_x;
|
||||
FT_Long bearing_y;
|
||||
FT_Long advance;
|
||||
FT_Long advance_v; /* since 2.3.12 */
|
||||
|
||||
} FT_Incremental_MetricsRec;
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
*
|
||||
* @struct:
|
||||
* FT_Incremental_Metrics
|
||||
*
|
||||
* @description:
|
||||
* A handle to an @FT_Incremental_MetricsRec structure.
|
||||
*
|
||||
*/
|
||||
typedef struct FT_Incremental_MetricsRec_* FT_Incremental_Metrics;
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
*
|
||||
* @type:
|
||||
* FT_Incremental_GetGlyphDataFunc
|
||||
*
|
||||
* @description:
|
||||
* A function called by FreeType to access a given glyph's data bytes
|
||||
* during @FT_Load_Glyph or @FT_Load_Char if incremental loading is
|
||||
* enabled.
|
||||
*
|
||||
* Note that the format of the glyph's data bytes depends on the font
|
||||
* file format. For TrueType, it must correspond to the raw bytes within
|
||||
* the `glyf' table. For PostScript formats, it must correspond to the
|
||||
* *unencrypted* charstring bytes, without any `lenIV' header. It is
|
||||
* undefined for any other format.
|
||||
*
|
||||
* @input:
|
||||
* incremental ::
|
||||
* Handle to an opaque @FT_Incremental handle provided by the client
|
||||
* application.
|
||||
*
|
||||
* glyph_index ::
|
||||
* Index of relevant glyph.
|
||||
*
|
||||
* @output:
|
||||
* adata ::
|
||||
* A structure describing the returned glyph data bytes (which will be
|
||||
* accessed as a read-only byte block).
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* If this function returns successfully the method
|
||||
* @FT_Incremental_FreeGlyphDataFunc will be called later to release
|
||||
* the data bytes.
|
||||
*
|
||||
* Nested calls to @FT_Incremental_GetGlyphDataFunc can happen for
|
||||
* compound glyphs.
|
||||
*
|
||||
*/
|
||||
typedef FT_Error
|
||||
(*FT_Incremental_GetGlyphDataFunc)( FT_Incremental incremental,
|
||||
FT_UInt glyph_index,
|
||||
FT_Data* adata );
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
*
|
||||
* @type:
|
||||
* FT_Incremental_FreeGlyphDataFunc
|
||||
*
|
||||
* @description:
|
||||
* A function used to release the glyph data bytes returned by a
|
||||
* successful call to @FT_Incremental_GetGlyphDataFunc.
|
||||
*
|
||||
* @input:
|
||||
* incremental ::
|
||||
* A handle to an opaque @FT_Incremental handle provided by the client
|
||||
* application.
|
||||
*
|
||||
* data ::
|
||||
* A structure describing the glyph data bytes (which will be accessed
|
||||
* as a read-only byte block).
|
||||
*
|
||||
*/
|
||||
typedef void
|
||||
(*FT_Incremental_FreeGlyphDataFunc)( FT_Incremental incremental,
|
||||
FT_Data* data );
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
*
|
||||
* @type:
|
||||
* FT_Incremental_GetGlyphMetricsFunc
|
||||
*
|
||||
* @description:
|
||||
* A function used to retrieve the basic metrics of a given glyph index
|
||||
* before accessing its data. This is necessary because, in certain
|
||||
* formats like TrueType, the metrics are stored in a different place from
|
||||
* the glyph images proper.
|
||||
*
|
||||
* @input:
|
||||
* incremental ::
|
||||
* A handle to an opaque @FT_Incremental handle provided by the client
|
||||
* application.
|
||||
*
|
||||
* glyph_index ::
|
||||
* Index of relevant glyph.
|
||||
*
|
||||
* vertical ::
|
||||
* If true, return vertical metrics.
|
||||
*
|
||||
* ametrics ::
|
||||
* This parameter is used for both input and output.
|
||||
* The original glyph metrics, if any, in font units. If metrics are
|
||||
* not available all the values must be set to zero.
|
||||
*
|
||||
* @output:
|
||||
* ametrics ::
|
||||
* The replacement glyph metrics in font units.
|
||||
*
|
||||
*/
|
||||
typedef FT_Error
|
||||
(*FT_Incremental_GetGlyphMetricsFunc)
|
||||
( FT_Incremental incremental,
|
||||
FT_UInt glyph_index,
|
||||
FT_Bool vertical,
|
||||
FT_Incremental_MetricsRec *ametrics );
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @struct:
|
||||
* FT_Incremental_FuncsRec
|
||||
*
|
||||
* @description:
|
||||
* A table of functions for accessing fonts that load data
|
||||
* incrementally. Used in @FT_Incremental_InterfaceRec.
|
||||
*
|
||||
* @fields:
|
||||
* get_glyph_data ::
|
||||
* The function to get glyph data. Must not be null.
|
||||
*
|
||||
* free_glyph_data ::
|
||||
* The function to release glyph data. Must not be null.
|
||||
*
|
||||
* get_glyph_metrics ::
|
||||
* The function to get glyph metrics. May be null if the font does
|
||||
* not provide overriding glyph metrics.
|
||||
*
|
||||
*/
|
||||
typedef struct FT_Incremental_FuncsRec_
|
||||
{
|
||||
FT_Incremental_GetGlyphDataFunc get_glyph_data;
|
||||
FT_Incremental_FreeGlyphDataFunc free_glyph_data;
|
||||
FT_Incremental_GetGlyphMetricsFunc get_glyph_metrics;
|
||||
|
||||
} FT_Incremental_FuncsRec;
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
*
|
||||
* @struct:
|
||||
* FT_Incremental_InterfaceRec
|
||||
*
|
||||
* @description:
|
||||
* A structure to be used with @FT_Open_Face to indicate that the user
|
||||
* wants to support incremental glyph loading. You should use it with
|
||||
* @FT_PARAM_TAG_INCREMENTAL as in the following example:
|
||||
*
|
||||
* {
|
||||
* FT_Incremental_InterfaceRec inc_int;
|
||||
* FT_Parameter parameter;
|
||||
* FT_Open_Args open_args;
|
||||
*
|
||||
*
|
||||
* // set up incremental descriptor
|
||||
* inc_int.funcs = my_funcs;
|
||||
* inc_int.object = my_object;
|
||||
*
|
||||
* // set up optional parameter
|
||||
* parameter.tag = FT_PARAM_TAG_INCREMENTAL;
|
||||
* parameter.data = &inc_int;
|
||||
*
|
||||
* // set up FT_Open_Args structure
|
||||
* open_args.flags = FT_OPEN_PATHNAME | FT_OPEN_PARAMS;
|
||||
* open_args.pathname = my_font_pathname;
|
||||
* open_args.num_params = 1;
|
||||
* open_args.params = ¶meter; // we use one optional argument
|
||||
*
|
||||
* // open the font
|
||||
* error = FT_Open_Face( library, &open_args, index, &face );
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
*/
|
||||
typedef struct FT_Incremental_InterfaceRec_
|
||||
{
|
||||
const FT_Incremental_FuncsRec* funcs;
|
||||
FT_Incremental object;
|
||||
|
||||
} FT_Incremental_InterfaceRec;
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
*
|
||||
* @type:
|
||||
* FT_Incremental_Interface
|
||||
*
|
||||
* @description:
|
||||
* A pointer to an @FT_Incremental_InterfaceRec structure.
|
||||
*
|
||||
*/
|
||||
typedef FT_Incremental_InterfaceRec* FT_Incremental_Interface;
|
||||
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTINCREM_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,309 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftlcdfil.h */
|
||||
/* */
|
||||
/* FreeType API for color filtering of subpixel bitmap glyphs */
|
||||
/* (specification). */
|
||||
/* */
|
||||
/* Copyright 2006-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTLCDFIL_H_
|
||||
#define FTLCDFIL_H_
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_PARAMETER_TAGS_H
|
||||
|
||||
#ifdef FREETYPE_H
|
||||
#error "freetype.h of FreeType 1 has been loaded!"
|
||||
#error "Please fix the directory search order for header files"
|
||||
#error "so that freetype.h of FreeType 2 is found first."
|
||||
#endif
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
/***************************************************************************
|
||||
*
|
||||
* @section:
|
||||
* lcd_filtering
|
||||
*
|
||||
* @title:
|
||||
* LCD Filtering
|
||||
*
|
||||
* @abstract:
|
||||
* Reduce color fringes of subpixel-rendered bitmaps.
|
||||
*
|
||||
* @description:
|
||||
* Should you #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING in your
|
||||
* `ftoption.h', which enables patented ClearType-style rendering,
|
||||
* the LCD-optimized glyph bitmaps should be filtered to reduce color
|
||||
* fringes inherent to this technology. The default FreeType LCD
|
||||
* rendering uses different technology, and API described below,
|
||||
* although available, does nothing.
|
||||
*
|
||||
* ClearType-style LCD rendering exploits the color-striped structure of
|
||||
* LCD pixels, increasing the available resolution in the direction of
|
||||
* the stripe (usually horizontal RGB) by a factor of~3. Since these
|
||||
* subpixels are color pixels, using them unfiltered creates severe
|
||||
* color fringes. Use the @FT_Library_SetLcdFilter API to specify a
|
||||
* low-pass filter, which is then applied to subpixel-rendered bitmaps
|
||||
* generated through @FT_Render_Glyph. The filter sacrifices some of
|
||||
* the higher resolution to reduce color fringes, making the glyph image
|
||||
* slightly blurrier. Positional improvements will remain.
|
||||
*
|
||||
* A filter should have two properties:
|
||||
*
|
||||
* 1) It should be normalized, meaning the sum of the 5~components
|
||||
* should be 256 (0x100). It is possible to go above or under this
|
||||
* target sum, however: going under means tossing out contrast, going
|
||||
* over means invoking clamping and thereby non-linearities that
|
||||
* increase contrast somewhat at the expense of greater distortion
|
||||
* and color-fringing. Contrast is better enhanced through stem
|
||||
* darkening.
|
||||
*
|
||||
* 2) It should be color-balanced, meaning a filter `{~a, b, c, b, a~}'
|
||||
* where a~+ b~=~c. It distributes the computed coverage for one
|
||||
* subpixel to all subpixels equally, sacrificing some won resolution
|
||||
* but drastically reducing color-fringing. Positioning improvements
|
||||
* remain! Note that color-fringing can only really be minimized
|
||||
* when using a color-balanced filter and alpha-blending the glyph
|
||||
* onto a surface in linear space; see @FT_Render_Glyph.
|
||||
*
|
||||
* Regarding the form, a filter can be a `boxy' filter or a `beveled'
|
||||
* filter. Boxy filters are sharper but are less forgiving of non-ideal
|
||||
* gamma curves of a screen (viewing angles!), beveled filters are
|
||||
* fuzzier but more tolerant.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* - [0x10 0x40 0x70 0x40 0x10] is beveled and neither balanced nor
|
||||
* normalized.
|
||||
*
|
||||
* - [0x1A 0x33 0x4D 0x33 0x1A] is beveled and balanced but not
|
||||
* normalized.
|
||||
*
|
||||
* - [0x19 0x33 0x66 0x4c 0x19] is beveled and normalized but not
|
||||
* balanced.
|
||||
*
|
||||
* - [0x00 0x4c 0x66 0x4c 0x00] is boxily beveled and normalized but not
|
||||
* balanced.
|
||||
*
|
||||
* - [0x00 0x55 0x56 0x55 0x00] is boxy, normalized, and almost
|
||||
* balanced.
|
||||
*
|
||||
* - [0x08 0x4D 0x56 0x4D 0x08] is beveled, normalized and, almost
|
||||
* balanced.
|
||||
*
|
||||
* The filter affects glyph bitmaps rendered through @FT_Render_Glyph,
|
||||
* @FT_Load_Glyph, and @FT_Load_Char. It does _not_ affect the output
|
||||
* of @FT_Outline_Render and @FT_Outline_Get_Bitmap.
|
||||
*
|
||||
* If this feature is activated, the dimensions of LCD glyph bitmaps are
|
||||
* either wider or taller than the dimensions of the corresponding
|
||||
* outline with regard to the pixel grid. For example, for
|
||||
* @FT_RENDER_MODE_LCD, the filter adds 3~subpixels to the left, and
|
||||
* 3~subpixels to the right. The bitmap offset values are adjusted
|
||||
* accordingly, so clients shouldn't need to modify their layout and
|
||||
* glyph positioning code when enabling the filter.
|
||||
*
|
||||
* It is important to understand that linear alpha blending and gamma
|
||||
* correction is critical for correctly rendering glyphs onto surfaces
|
||||
* without artifacts and even more critical when subpixel rendering is
|
||||
* involved.
|
||||
*
|
||||
* Each of the 3~alpha values (subpixels) is independently used to blend
|
||||
* one color channel. That is, red alpha blends the red channel of the
|
||||
* text color with the red channel of the background pixel. The
|
||||
* distribution of density values by the color-balanced filter assumes
|
||||
* alpha blending is done in linear space; only then color artifacts
|
||||
* cancel out.
|
||||
*/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* @enum:
|
||||
* FT_LcdFilter
|
||||
*
|
||||
* @description:
|
||||
* A list of values to identify various types of LCD filters.
|
||||
*
|
||||
* @values:
|
||||
* FT_LCD_FILTER_NONE ::
|
||||
* Do not perform filtering. When used with subpixel rendering, this
|
||||
* results in sometimes severe color fringes.
|
||||
*
|
||||
* FT_LCD_FILTER_DEFAULT ::
|
||||
* The default filter reduces color fringes considerably, at the cost
|
||||
* of a slight blurriness in the output.
|
||||
*
|
||||
* It is a beveled, normalized, and color-balanced five-tap filter
|
||||
* that is more forgiving to screens with non-ideal gamma curves and
|
||||
* viewing angles. Note that while color-fringing is reduced, it can
|
||||
* only be minimized by using linear alpha blending and gamma
|
||||
* correction to render glyphs onto surfaces. The default filter
|
||||
* weights are [0x08 0x4D 0x56 0x4D 0x08].
|
||||
*
|
||||
* FT_LCD_FILTER_LIGHT ::
|
||||
* The light filter is a variant that is sharper at the cost of
|
||||
* slightly more color fringes than the default one.
|
||||
*
|
||||
* It is a boxy, normalized, and color-balanced three-tap filter that
|
||||
* is less forgiving to screens with non-ideal gamma curves and
|
||||
* viewing angles. This filter works best when the rendering system
|
||||
* uses linear alpha blending and gamma correction to render glyphs
|
||||
* onto surfaces. The light filter weights are
|
||||
* [0x00 0x55 0x56 0x55 0x00].
|
||||
*
|
||||
* FT_LCD_FILTER_LEGACY ::
|
||||
* This filter corresponds to the original libXft color filter. It
|
||||
* provides high contrast output but can exhibit really bad color
|
||||
* fringes if glyphs are not extremely well hinted to the pixel grid.
|
||||
* In other words, it only works well if the TrueType bytecode
|
||||
* interpreter is enabled *and* high-quality hinted fonts are used.
|
||||
*
|
||||
* This filter is only provided for comparison purposes, and might be
|
||||
* disabled or stay unsupported in the future.
|
||||
*
|
||||
* FT_LCD_FILTER_LEGACY1 ::
|
||||
* For historical reasons, the FontConfig library returns a different
|
||||
* enumeration value for legacy LCD filtering. To make code work that
|
||||
* (incorrectly) forwards FontConfig's enumeration value to
|
||||
* @FT_Library_SetLcdFilter without proper mapping, it is thus easiest
|
||||
* to have another enumeration value, which is completely equal to
|
||||
* `FT_LCD_FILTER_LEGACY'.
|
||||
*
|
||||
* @since:
|
||||
* 2.3.0 (`FT_LCD_FILTER_LEGACY1' since 2.6.2)
|
||||
*/
|
||||
typedef enum FT_LcdFilter_
|
||||
{
|
||||
FT_LCD_FILTER_NONE = 0,
|
||||
FT_LCD_FILTER_DEFAULT = 1,
|
||||
FT_LCD_FILTER_LIGHT = 2,
|
||||
FT_LCD_FILTER_LEGACY1 = 3,
|
||||
FT_LCD_FILTER_LEGACY = 16,
|
||||
|
||||
FT_LCD_FILTER_MAX /* do not remove */
|
||||
|
||||
} FT_LcdFilter;
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @func:
|
||||
* FT_Library_SetLcdFilter
|
||||
*
|
||||
* @description:
|
||||
* This function is used to apply color filtering to LCD decimated
|
||||
* bitmaps, like the ones used when calling @FT_Render_Glyph with
|
||||
* @FT_RENDER_MODE_LCD or @FT_RENDER_MODE_LCD_V.
|
||||
*
|
||||
* @input:
|
||||
* library ::
|
||||
* A handle to the target library instance.
|
||||
*
|
||||
* filter ::
|
||||
* The filter type.
|
||||
*
|
||||
* You can use @FT_LCD_FILTER_NONE here to disable this feature, or
|
||||
* @FT_LCD_FILTER_DEFAULT to use a default filter that should work
|
||||
* well on most LCD screens.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* This feature is always disabled by default. Clients must make an
|
||||
* explicit call to this function with a `filter' value other than
|
||||
* @FT_LCD_FILTER_NONE in order to enable it.
|
||||
*
|
||||
* Due to *PATENTS* covering subpixel rendering, this function doesn't
|
||||
* do anything except returning `FT_Err_Unimplemented_Feature' if the
|
||||
* configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING is not
|
||||
* defined in your build of the library, which should correspond to all
|
||||
* default builds of FreeType.
|
||||
*
|
||||
* @since:
|
||||
* 2.3.0
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Library_SetLcdFilter( FT_Library library,
|
||||
FT_LcdFilter filter );
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @func:
|
||||
* FT_Library_SetLcdFilterWeights
|
||||
*
|
||||
* @description:
|
||||
* This function can be used to enable LCD filter with custom weights,
|
||||
* instead of using presets in @FT_Library_SetLcdFilter.
|
||||
*
|
||||
* @input:
|
||||
* library ::
|
||||
* A handle to the target library instance.
|
||||
*
|
||||
* weights ::
|
||||
* A pointer to an array; the function copies the first five bytes and
|
||||
* uses them to specify the filter weights.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* Due to *PATENTS* covering subpixel rendering, this function doesn't
|
||||
* do anything except returning `FT_Err_Unimplemented_Feature' if the
|
||||
* configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING is not
|
||||
* defined in your build of the library, which should correspond to all
|
||||
* default builds of FreeType.
|
||||
*
|
||||
* LCD filter weights can also be set per face using @FT_Face_Properties
|
||||
* with @FT_PARAM_TAG_LCD_FILTER_WEIGHTS.
|
||||
*
|
||||
* @since:
|
||||
* 2.4.0
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Library_SetLcdFilterWeights( FT_Library library,
|
||||
unsigned char *weights );
|
||||
|
||||
|
||||
/*
|
||||
* @type:
|
||||
* FT_LcdFiveTapFilter
|
||||
*
|
||||
* @description:
|
||||
* A typedef for passing the five LCD filter weights to
|
||||
* @FT_Face_Properties within an @FT_Parameter structure.
|
||||
*
|
||||
* @since:
|
||||
* 2.8
|
||||
*
|
||||
*/
|
||||
#define FT_LCD_FILTER_FIVE_TAPS 5
|
||||
|
||||
typedef FT_Byte FT_LcdFiveTapFilter[FT_LCD_FILTER_FIVE_TAPS];
|
||||
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTLCDFIL_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,276 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftlist.h */
|
||||
/* */
|
||||
/* Generic list support for FreeType (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* This file implements functions relative to list processing. Its */
|
||||
/* data structures are defined in `freetype.h'. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTLIST_H_
|
||||
#define FTLIST_H_
|
||||
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#ifdef FREETYPE_H
|
||||
#error "freetype.h of FreeType 1 has been loaded!"
|
||||
#error "Please fix the directory search order for header files"
|
||||
#error "so that freetype.h of FreeType 2 is found first."
|
||||
#endif
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* list_processing */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* List Processing */
|
||||
/* */
|
||||
/* <Abstract> */
|
||||
/* Simple management of lists. */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This section contains various definitions related to list */
|
||||
/* processing using doubly-linked nodes. */
|
||||
/* */
|
||||
/* <Order> */
|
||||
/* FT_List */
|
||||
/* FT_ListNode */
|
||||
/* FT_ListRec */
|
||||
/* FT_ListNodeRec */
|
||||
/* */
|
||||
/* FT_List_Add */
|
||||
/* FT_List_Insert */
|
||||
/* FT_List_Find */
|
||||
/* FT_List_Remove */
|
||||
/* FT_List_Up */
|
||||
/* FT_List_Iterate */
|
||||
/* FT_List_Iterator */
|
||||
/* FT_List_Finalize */
|
||||
/* FT_List_Destructor */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_List_Find */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Find the list node for a given listed object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* list :: A pointer to the parent list. */
|
||||
/* data :: The address of the listed object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* List node. NULL if it wasn't found. */
|
||||
/* */
|
||||
FT_EXPORT( FT_ListNode )
|
||||
FT_List_Find( FT_List list,
|
||||
void* data );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_List_Add */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Append an element to the end of a list. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* list :: A pointer to the parent list. */
|
||||
/* node :: The node to append. */
|
||||
/* */
|
||||
FT_EXPORT( void )
|
||||
FT_List_Add( FT_List list,
|
||||
FT_ListNode node );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_List_Insert */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Insert an element at the head of a list. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* list :: A pointer to parent list. */
|
||||
/* node :: The node to insert. */
|
||||
/* */
|
||||
FT_EXPORT( void )
|
||||
FT_List_Insert( FT_List list,
|
||||
FT_ListNode node );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_List_Remove */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Remove a node from a list. This function doesn't check whether */
|
||||
/* the node is in the list! */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* node :: The node to remove. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* list :: A pointer to the parent list. */
|
||||
/* */
|
||||
FT_EXPORT( void )
|
||||
FT_List_Remove( FT_List list,
|
||||
FT_ListNode node );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_List_Up */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Move a node to the head/top of a list. Used to maintain LRU */
|
||||
/* lists. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* list :: A pointer to the parent list. */
|
||||
/* node :: The node to move. */
|
||||
/* */
|
||||
FT_EXPORT( void )
|
||||
FT_List_Up( FT_List list,
|
||||
FT_ListNode node );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* FT_List_Iterator */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* An FT_List iterator function that is called during a list parse */
|
||||
/* by @FT_List_Iterate. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* node :: The current iteration list node. */
|
||||
/* */
|
||||
/* user :: A typeless pointer passed to @FT_List_Iterate. */
|
||||
/* Can be used to point to the iteration's state. */
|
||||
/* */
|
||||
typedef FT_Error
|
||||
(*FT_List_Iterator)( FT_ListNode node,
|
||||
void* user );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_List_Iterate */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Parse a list and calls a given iterator function on each element. */
|
||||
/* Note that parsing is stopped as soon as one of the iterator calls */
|
||||
/* returns a non-zero value. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* list :: A handle to the list. */
|
||||
/* iterator :: An iterator function, called on each node of the list. */
|
||||
/* user :: A user-supplied field that is passed as the second */
|
||||
/* argument to the iterator. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The result (a FreeType error code) of the last iterator call. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_List_Iterate( FT_List list,
|
||||
FT_List_Iterator iterator,
|
||||
void* user );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* FT_List_Destructor */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* An @FT_List iterator function that is called during a list */
|
||||
/* finalization by @FT_List_Finalize to destroy all elements in a */
|
||||
/* given list. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* system :: The current system object. */
|
||||
/* */
|
||||
/* data :: The current object to destroy. */
|
||||
/* */
|
||||
/* user :: A typeless pointer passed to @FT_List_Iterate. It can */
|
||||
/* be used to point to the iteration's state. */
|
||||
/* */
|
||||
typedef void
|
||||
(*FT_List_Destructor)( FT_Memory memory,
|
||||
void* data,
|
||||
void* user );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_List_Finalize */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Destroy all elements in the list as well as the list itself. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* list :: A handle to the list. */
|
||||
/* */
|
||||
/* destroy :: A list destructor that will be applied to each element */
|
||||
/* of the list. Set this to NULL if not needed. */
|
||||
/* */
|
||||
/* memory :: The current memory object that handles deallocation. */
|
||||
/* */
|
||||
/* user :: A user-supplied field that is passed as the last */
|
||||
/* argument to the destructor. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This function expects that all nodes added by @FT_List_Add or */
|
||||
/* @FT_List_Insert have been dynamically allocated. */
|
||||
/* */
|
||||
FT_EXPORT( void )
|
||||
FT_List_Finalize( FT_List list,
|
||||
FT_List_Destructor destroy,
|
||||
FT_Memory memory,
|
||||
void* user );
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTLIST_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,99 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftlzw.h */
|
||||
/* */
|
||||
/* LZW-compressed stream support. */
|
||||
/* */
|
||||
/* Copyright 2004-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTLZW_H_
|
||||
#define FTLZW_H_
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#ifdef FREETYPE_H
|
||||
#error "freetype.h of FreeType 1 has been loaded!"
|
||||
#error "Please fix the directory search order for header files"
|
||||
#error "so that freetype.h of FreeType 2 is found first."
|
||||
#endif
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* lzw */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* LZW Streams */
|
||||
/* */
|
||||
/* <Abstract> */
|
||||
/* Using LZW-compressed font files. */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This section contains the declaration of LZW-specific functions. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
/************************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Stream_OpenLZW
|
||||
*
|
||||
* @description:
|
||||
* Open a new stream to parse LZW-compressed font files. This is
|
||||
* mainly used to support the compressed `*.pcf.Z' fonts that come
|
||||
* with XFree86.
|
||||
*
|
||||
* @input:
|
||||
* stream :: The target embedding stream.
|
||||
*
|
||||
* source :: The source stream.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* The source stream must be opened _before_ calling this function.
|
||||
*
|
||||
* Calling the internal function `FT_Stream_Close' on the new stream will
|
||||
* *not* call `FT_Stream_Close' on the source stream. None of the stream
|
||||
* objects will be released to the heap.
|
||||
*
|
||||
* The stream implementation is very basic and resets the decompression
|
||||
* process each time seeking backwards is needed within the stream
|
||||
*
|
||||
* In certain builds of the library, LZW compression recognition is
|
||||
* automatically handled when calling @FT_New_Face or @FT_Open_Face.
|
||||
* This means that if no font driver is capable of handling the raw
|
||||
* compressed file, the library will try to open a LZW stream from it
|
||||
* and re-open the face with it.
|
||||
*
|
||||
* This function may return `FT_Err_Unimplemented_Feature' if your build
|
||||
* of FreeType was not compiled with LZW support.
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Stream_OpenLZW( FT_Stream stream,
|
||||
FT_Stream source );
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTLZW_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,275 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftmac.h */
|
||||
/* */
|
||||
/* Additional Mac-specific API. */
|
||||
/* */
|
||||
/* Copyright 1996-2018 by */
|
||||
/* Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* NOTE: Include this file after FT_FREETYPE_H and after any */
|
||||
/* Mac-specific headers (because this header uses Mac types such as */
|
||||
/* Handle, FSSpec, FSRef, etc.) */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTMAC_H_
|
||||
#define FTMAC_H_
|
||||
|
||||
|
||||
#include <ft2build.h>
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/* gcc-3.1 and later can warn about functions tagged as deprecated */
|
||||
#ifndef FT_DEPRECATED_ATTRIBUTE
|
||||
#if defined( __GNUC__ ) && \
|
||||
( ( __GNUC__ >= 4 ) || \
|
||||
( ( __GNUC__ == 3 ) && ( __GNUC_MINOR__ >= 1 ) ) )
|
||||
#define FT_DEPRECATED_ATTRIBUTE __attribute__(( deprecated ))
|
||||
#else
|
||||
#define FT_DEPRECATED_ATTRIBUTE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* mac_specific */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* Mac Specific Interface */
|
||||
/* */
|
||||
/* <Abstract> */
|
||||
/* Only available on the Macintosh. */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The following definitions are only available if FreeType is */
|
||||
/* compiled on a Macintosh. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_New_Face_From_FOND */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Create a new face object from a FOND resource. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* library :: A handle to the library resource. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* fond :: A FOND resource. */
|
||||
/* */
|
||||
/* face_index :: Only supported for the -1 `sanity check' special */
|
||||
/* case. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* aface :: A handle to a new face object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Notes> */
|
||||
/* This function can be used to create @FT_Face objects from fonts */
|
||||
/* that are installed in the system as follows. */
|
||||
/* */
|
||||
/* { */
|
||||
/* fond = GetResource( 'FOND', fontName ); */
|
||||
/* error = FT_New_Face_From_FOND( library, fond, 0, &face ); */
|
||||
/* } */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_New_Face_From_FOND( FT_Library library,
|
||||
Handle fond,
|
||||
FT_Long face_index,
|
||||
FT_Face *aface )
|
||||
FT_DEPRECATED_ATTRIBUTE;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_GetFile_From_Mac_Name */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Return an FSSpec for the disk file containing the named font. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* fontName :: Mac OS name of the font (e.g., Times New Roman */
|
||||
/* Bold). */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* pathSpec :: FSSpec to the file. For passing to */
|
||||
/* @FT_New_Face_From_FSSpec. */
|
||||
/* */
|
||||
/* face_index :: Index of the face. For passing to */
|
||||
/* @FT_New_Face_From_FSSpec. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_GetFile_From_Mac_Name( const char* fontName,
|
||||
FSSpec* pathSpec,
|
||||
FT_Long* face_index )
|
||||
FT_DEPRECATED_ATTRIBUTE;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_GetFile_From_Mac_ATS_Name */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Return an FSSpec for the disk file containing the named font. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* fontName :: Mac OS name of the font in ATS framework. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* pathSpec :: FSSpec to the file. For passing to */
|
||||
/* @FT_New_Face_From_FSSpec. */
|
||||
/* */
|
||||
/* face_index :: Index of the face. For passing to */
|
||||
/* @FT_New_Face_From_FSSpec. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_GetFile_From_Mac_ATS_Name( const char* fontName,
|
||||
FSSpec* pathSpec,
|
||||
FT_Long* face_index )
|
||||
FT_DEPRECATED_ATTRIBUTE;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_GetFilePath_From_Mac_ATS_Name */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Return a pathname of the disk file and face index for given font */
|
||||
/* name that is handled by ATS framework. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* fontName :: Mac OS name of the font in ATS framework. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* path :: Buffer to store pathname of the file. For passing */
|
||||
/* to @FT_New_Face. The client must allocate this */
|
||||
/* buffer before calling this function. */
|
||||
/* */
|
||||
/* maxPathSize :: Lengths of the buffer `path' that client allocated. */
|
||||
/* */
|
||||
/* face_index :: Index of the face. For passing to @FT_New_Face. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_GetFilePath_From_Mac_ATS_Name( const char* fontName,
|
||||
UInt8* path,
|
||||
UInt32 maxPathSize,
|
||||
FT_Long* face_index )
|
||||
FT_DEPRECATED_ATTRIBUTE;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_New_Face_From_FSSpec */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Create a new face object from a given resource and typeface index */
|
||||
/* using an FSSpec to the font file. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* library :: A handle to the library resource. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* spec :: FSSpec to the font file. */
|
||||
/* */
|
||||
/* face_index :: The index of the face within the resource. The */
|
||||
/* first face has index~0. */
|
||||
/* <Output> */
|
||||
/* aface :: A handle to a new face object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* @FT_New_Face_From_FSSpec is identical to @FT_New_Face except */
|
||||
/* it accepts an FSSpec instead of a path. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_New_Face_From_FSSpec( FT_Library library,
|
||||
const FSSpec *spec,
|
||||
FT_Long face_index,
|
||||
FT_Face *aface )
|
||||
FT_DEPRECATED_ATTRIBUTE;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_New_Face_From_FSRef */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Create a new face object from a given resource and typeface index */
|
||||
/* using an FSRef to the font file. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* library :: A handle to the library resource. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* spec :: FSRef to the font file. */
|
||||
/* */
|
||||
/* face_index :: The index of the face within the resource. The */
|
||||
/* first face has index~0. */
|
||||
/* <Output> */
|
||||
/* aface :: A handle to a new face object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* @FT_New_Face_From_FSRef is identical to @FT_New_Face except */
|
||||
/* it accepts an FSRef instead of a path. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_New_Face_From_FSRef( FT_Library library,
|
||||
const FSRef *ref,
|
||||
FT_Long face_index,
|
||||
FT_Face *aface )
|
||||
FT_DEPRECATED_ATTRIBUTE;
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
|
||||
#endif /* FTMAC_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,638 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftmm.h */
|
||||
/* */
|
||||
/* FreeType Multiple Master font interface (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTMM_H_
|
||||
#define FTMM_H_
|
||||
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_TYPE1_TABLES_H
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* multiple_masters */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* Multiple Masters */
|
||||
/* */
|
||||
/* <Abstract> */
|
||||
/* How to manage Multiple Masters fonts. */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The following types and functions are used to manage Multiple */
|
||||
/* Master fonts, i.e., the selection of specific design instances by */
|
||||
/* setting design axis coordinates. */
|
||||
/* */
|
||||
/* Besides Adobe MM fonts, the interface supports Apple's TrueType GX */
|
||||
/* and OpenType variation fonts. Some of the routines only work with */
|
||||
/* Adobe MM fonts, others will work with all three types. They are */
|
||||
/* similar enough that a consistent interface makes sense. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_MM_Axis */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure to model a given axis in design space for Multiple */
|
||||
/* Masters fonts. */
|
||||
/* */
|
||||
/* This structure can't be used for TrueType GX or OpenType variation */
|
||||
/* fonts. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* name :: The axis's name. */
|
||||
/* */
|
||||
/* minimum :: The axis's minimum design coordinate. */
|
||||
/* */
|
||||
/* maximum :: The axis's maximum design coordinate. */
|
||||
/* */
|
||||
typedef struct FT_MM_Axis_
|
||||
{
|
||||
FT_String* name;
|
||||
FT_Long minimum;
|
||||
FT_Long maximum;
|
||||
|
||||
} FT_MM_Axis;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_Multi_Master */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure to model the axes and space of a Multiple Masters */
|
||||
/* font. */
|
||||
/* */
|
||||
/* This structure can't be used for TrueType GX or OpenType variation */
|
||||
/* fonts. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* num_axis :: Number of axes. Cannot exceed~4. */
|
||||
/* */
|
||||
/* num_designs :: Number of designs; should be normally 2^num_axis */
|
||||
/* even though the Type~1 specification strangely */
|
||||
/* allows for intermediate designs to be present. */
|
||||
/* This number cannot exceed~16. */
|
||||
/* */
|
||||
/* axis :: A table of axis descriptors. */
|
||||
/* */
|
||||
typedef struct FT_Multi_Master_
|
||||
{
|
||||
FT_UInt num_axis;
|
||||
FT_UInt num_designs;
|
||||
FT_MM_Axis axis[T1_MAX_MM_AXIS];
|
||||
|
||||
} FT_Multi_Master;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_Var_Axis */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure to model a given axis in design space for Multiple */
|
||||
/* Masters, TrueType GX, and OpenType variation fonts. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* name :: The axis's name. */
|
||||
/* Not always meaningful for TrueType GX or OpenType */
|
||||
/* variation fonts. */
|
||||
/* */
|
||||
/* minimum :: The axis's minimum design coordinate. */
|
||||
/* */
|
||||
/* def :: The axis's default design coordinate. */
|
||||
/* FreeType computes meaningful default values for Adobe */
|
||||
/* MM fonts. */
|
||||
/* */
|
||||
/* maximum :: The axis's maximum design coordinate. */
|
||||
/* */
|
||||
/* tag :: The axis's tag (the equivalent to `name' for TrueType */
|
||||
/* GX and OpenType variation fonts). FreeType provides */
|
||||
/* default values for Adobe MM fonts if possible. */
|
||||
/* */
|
||||
/* strid :: The axis name entry in the font's `name' table. This */
|
||||
/* is another (and often better) version of the `name' */
|
||||
/* field for TrueType GX or OpenType variation fonts. Not */
|
||||
/* meaningful for Adobe MM fonts. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The fields `minimum', `def', and `maximum' are 16.16 fractional */
|
||||
/* values for TrueType GX and OpenType variation fonts. For Adobe MM */
|
||||
/* fonts, the values are integers. */
|
||||
/* */
|
||||
typedef struct FT_Var_Axis_
|
||||
{
|
||||
FT_String* name;
|
||||
|
||||
FT_Fixed minimum;
|
||||
FT_Fixed def;
|
||||
FT_Fixed maximum;
|
||||
|
||||
FT_ULong tag;
|
||||
FT_UInt strid;
|
||||
|
||||
} FT_Var_Axis;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_Var_Named_Style */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure to model a named instance in a TrueType GX or OpenType */
|
||||
/* variation font. */
|
||||
/* */
|
||||
/* This structure can't be used for Adobe MM fonts. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* coords :: The design coordinates for this instance. */
|
||||
/* This is an array with one entry for each axis. */
|
||||
/* */
|
||||
/* strid :: The entry in `name' table identifying this instance. */
|
||||
/* */
|
||||
/* psid :: The entry in `name' table identifying a PostScript name */
|
||||
/* for this instance. Value 0xFFFF indicates a missing */
|
||||
/* entry. */
|
||||
/* */
|
||||
typedef struct FT_Var_Named_Style_
|
||||
{
|
||||
FT_Fixed* coords;
|
||||
FT_UInt strid;
|
||||
FT_UInt psid; /* since 2.7.1 */
|
||||
|
||||
} FT_Var_Named_Style;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_MM_Var */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure to model the axes and space of an Adobe MM, TrueType */
|
||||
/* GX, or OpenType variation font. */
|
||||
/* */
|
||||
/* Some fields are specific to one format and not to the others. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* num_axis :: The number of axes. The maximum value is~4 for */
|
||||
/* Adobe MM fonts; no limit in TrueType GX or */
|
||||
/* OpenType variation fonts. */
|
||||
/* */
|
||||
/* num_designs :: The number of designs; should be normally */
|
||||
/* 2^num_axis for Adobe MM fonts. Not meaningful */
|
||||
/* for TrueType GX or OpenType variation fonts */
|
||||
/* (where every glyph could have a different */
|
||||
/* number of designs). */
|
||||
/* */
|
||||
/* num_namedstyles :: The number of named styles; a `named style' is */
|
||||
/* a tuple of design coordinates that has a string */
|
||||
/* ID (in the `name' table) associated with it. */
|
||||
/* The font can tell the user that, for example, */
|
||||
/* [Weight=1.5,Width=1.1] is `Bold'. Another name */
|
||||
/* for `named style' is `named instance'. */
|
||||
/* */
|
||||
/* For Adobe Multiple Masters fonts, this value is */
|
||||
/* always zero because the format does not support */
|
||||
/* named styles. */
|
||||
/* */
|
||||
/* axis :: An axis descriptor table. */
|
||||
/* TrueType GX and OpenType variation fonts */
|
||||
/* contain slightly more data than Adobe MM fonts. */
|
||||
/* Memory management of this pointer is done */
|
||||
/* internally by FreeType. */
|
||||
/* */
|
||||
/* namedstyle :: A named style (instance) table. */
|
||||
/* Only meaningful for TrueType GX and OpenType */
|
||||
/* variation fonts. Memory management of this */
|
||||
/* pointer is done internally by FreeType. */
|
||||
/* */
|
||||
typedef struct FT_MM_Var_
|
||||
{
|
||||
FT_UInt num_axis;
|
||||
FT_UInt num_designs;
|
||||
FT_UInt num_namedstyles;
|
||||
FT_Var_Axis* axis;
|
||||
FT_Var_Named_Style* namedstyle;
|
||||
|
||||
} FT_MM_Var;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_Multi_Master */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Retrieve a variation descriptor of a given Adobe MM font. */
|
||||
/* */
|
||||
/* This function can't be used with TrueType GX or OpenType variation */
|
||||
/* fonts. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the source face. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* amaster :: The Multiple Masters descriptor. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Get_Multi_Master( FT_Face face,
|
||||
FT_Multi_Master *amaster );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_MM_Var */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Retrieve a variation descriptor for a given font. */
|
||||
/* */
|
||||
/* This function works with all supported variation formats. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the source face. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* amaster :: The variation descriptor. */
|
||||
/* Allocates a data structure, which the user must */
|
||||
/* deallocate with a call to @FT_Done_MM_Var after use. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Get_MM_Var( FT_Face face,
|
||||
FT_MM_Var* *amaster );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Done_MM_Var */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Free the memory allocated by @FT_Get_MM_Var. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle of the face's parent library object that was */
|
||||
/* used in the call to @FT_Get_MM_Var to create `amaster'. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Done_MM_Var( FT_Library library,
|
||||
FT_MM_Var *amaster );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Set_MM_Design_Coordinates */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* For Adobe MM fonts, choose an interpolated font design through */
|
||||
/* design coordinates. */
|
||||
/* */
|
||||
/* This function can't be used with TrueType GX or OpenType variation */
|
||||
/* fonts. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* face :: A handle to the source face. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* num_coords :: The number of available design coordinates. If it */
|
||||
/* is larger than the number of axes, ignore the excess */
|
||||
/* values. If it is smaller than the number of axes, */
|
||||
/* use default values for the remaining axes. */
|
||||
/* */
|
||||
/* coords :: An array of design coordinates. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* [Since 2.8.1] To reset all axes to the default values, call the */
|
||||
/* function with `num_coords' set to zero and `coords' set to NULL. */
|
||||
/* */
|
||||
/* [Since 2.9] If `num_coords' is larger than zero, this function */
|
||||
/* sets the @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags' */
|
||||
/* field (i.e., @FT_IS_VARIATION will return true). If `num_coords' */
|
||||
/* is zero, this bit flag gets unset. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Set_MM_Design_Coordinates( FT_Face face,
|
||||
FT_UInt num_coords,
|
||||
FT_Long* coords );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Set_Var_Design_Coordinates */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Choose an interpolated font design through design coordinates. */
|
||||
/* */
|
||||
/* This function works with all supported variation formats. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* face :: A handle to the source face. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* num_coords :: The number of available design coordinates. If it */
|
||||
/* is larger than the number of axes, ignore the excess */
|
||||
/* values. If it is smaller than the number of axes, */
|
||||
/* use default values for the remaining axes. */
|
||||
/* */
|
||||
/* coords :: An array of design coordinates. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* [Since 2.8.1] To reset all axes to the default values, call the */
|
||||
/* function with `num_coords' set to zero and `coords' set to NULL. */
|
||||
/* [Since 2.9] `Default values' means the currently selected named */
|
||||
/* instance (or the base font if no named instance is selected). */
|
||||
/* */
|
||||
/* [Since 2.9] If `num_coords' is larger than zero, this function */
|
||||
/* sets the @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags' */
|
||||
/* field (i.e., @FT_IS_VARIATION will return true). If `num_coords' */
|
||||
/* is zero, this bit flag gets unset. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Set_Var_Design_Coordinates( FT_Face face,
|
||||
FT_UInt num_coords,
|
||||
FT_Fixed* coords );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_Var_Design_Coordinates */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Get the design coordinates of the currently selected interpolated */
|
||||
/* font. */
|
||||
/* */
|
||||
/* This function works with all supported variation formats. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the source face. */
|
||||
/* */
|
||||
/* num_coords :: The number of design coordinates to retrieve. If it */
|
||||
/* is larger than the number of axes, set the excess */
|
||||
/* values to~0. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* coords :: The design coordinates array. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Since> */
|
||||
/* 2.7.1 */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Get_Var_Design_Coordinates( FT_Face face,
|
||||
FT_UInt num_coords,
|
||||
FT_Fixed* coords );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Set_MM_Blend_Coordinates */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Choose an interpolated font design through normalized blend */
|
||||
/* coordinates. */
|
||||
/* */
|
||||
/* This function works with all supported variation formats. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* face :: A handle to the source face. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* num_coords :: The number of available design coordinates. If it */
|
||||
/* is larger than the number of axes, ignore the excess */
|
||||
/* values. If it is smaller than the number of axes, */
|
||||
/* use default values for the remaining axes. */
|
||||
/* */
|
||||
/* coords :: The design coordinates array (each element must be */
|
||||
/* between 0 and 1.0 for Adobe MM fonts, and between */
|
||||
/* -1.0 and 1.0 for TrueType GX and OpenType variation */
|
||||
/* fonts). */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* [Since 2.8.1] To reset all axes to the default values, call the */
|
||||
/* function with `num_coords' set to zero and `coords' set to NULL. */
|
||||
/* [Since 2.9] `Default values' means the currently selected named */
|
||||
/* instance (or the base font if no named instance is selected). */
|
||||
/* */
|
||||
/* [Since 2.9] If `num_coords' is larger than zero, this function */
|
||||
/* sets the @FT_FACE_FLAG_VARIATION bit in @FT_Face's `face_flags' */
|
||||
/* field (i.e., @FT_IS_VARIATION will return true). If `num_coords' */
|
||||
/* is zero, this bit flag gets unset. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Set_MM_Blend_Coordinates( FT_Face face,
|
||||
FT_UInt num_coords,
|
||||
FT_Fixed* coords );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_MM_Blend_Coordinates */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Get the normalized blend coordinates of the currently selected */
|
||||
/* interpolated font. */
|
||||
/* */
|
||||
/* This function works with all supported variation formats. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the source face. */
|
||||
/* */
|
||||
/* num_coords :: The number of normalized blend coordinates to */
|
||||
/* retrieve. If it is larger than the number of axes, */
|
||||
/* set the excess values to~0.5 for Adobe MM fonts, and */
|
||||
/* to~0 for TrueType GX and OpenType variation fonts. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* coords :: The normalized blend coordinates array. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Since> */
|
||||
/* 2.7.1 */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Get_MM_Blend_Coordinates( FT_Face face,
|
||||
FT_UInt num_coords,
|
||||
FT_Fixed* coords );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Set_Var_Blend_Coordinates */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This is another name of @FT_Set_MM_Blend_Coordinates. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Set_Var_Blend_Coordinates( FT_Face face,
|
||||
FT_UInt num_coords,
|
||||
FT_Fixed* coords );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_Var_Blend_Coordinates */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This is another name of @FT_Get_MM_Blend_Coordinates. */
|
||||
/* */
|
||||
/* <Since> */
|
||||
/* 2.7.1 */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Get_Var_Blend_Coordinates( FT_Face face,
|
||||
FT_UInt num_coords,
|
||||
FT_Fixed* coords );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Enum> */
|
||||
/* FT_VAR_AXIS_FLAG_XXX */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A list of bit flags used in the return value of */
|
||||
/* @FT_Get_Var_Axis_Flags. */
|
||||
/* */
|
||||
/* <Values> */
|
||||
/* FT_VAR_AXIS_FLAG_HIDDEN :: */
|
||||
/* The variation axis should not be exposed to user interfaces. */
|
||||
/* */
|
||||
/* <Since> */
|
||||
/* 2.8.1 */
|
||||
/* */
|
||||
#define FT_VAR_AXIS_FLAG_HIDDEN 1
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_Var_Axis_Flags */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Get the `flags' field of an OpenType Variation Axis Record. */
|
||||
/* */
|
||||
/* Not meaningful for Adobe MM fonts (`*flags' is always zero). */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* master :: The variation descriptor. */
|
||||
/* */
|
||||
/* axis_index :: The index of the requested variation axis. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* flags :: The `flags' field. See @FT_VAR_AXIS_FLAG_XXX for */
|
||||
/* possible values. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Since> */
|
||||
/* 2.8.1 */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Get_Var_Axis_Flags( FT_MM_Var* master,
|
||||
FT_UInt axis_index,
|
||||
FT_UInt* flags );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Set_Named_Instance */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Set or change the current named instance. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the source face. */
|
||||
/* */
|
||||
/* instance_index :: The index of the requested instance, starting */
|
||||
/* with value 1. If set to value 0, FreeType */
|
||||
/* switches to font access without a named */
|
||||
/* instance. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The function uses the value of `instance_index' to set bits 16-30 */
|
||||
/* of the face's `face_index' field. It also resets any variation */
|
||||
/* applied to the font, and the @FT_FACE_FLAG_VARIATION bit of the */
|
||||
/* face's `face_flags' field gets reset to zero (i.e., */
|
||||
/* @FT_IS_VARIATION will return false). */
|
||||
/* */
|
||||
/* For Adobe MM fonts (which don't have named instances) this */
|
||||
/* function simply resets the current face to the default instance. */
|
||||
/* */
|
||||
/* <Since> */
|
||||
/* 2.9 */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Set_Named_Instance( FT_Face face,
|
||||
FT_UInt instance_index );
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTMM_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,711 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftmodapi.h */
|
||||
/* */
|
||||
/* FreeType modules public interface (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTMODAPI_H_
|
||||
#define FTMODAPI_H_
|
||||
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#ifdef FREETYPE_H
|
||||
#error "freetype.h of FreeType 1 has been loaded!"
|
||||
#error "Please fix the directory search order for header files"
|
||||
#error "so that freetype.h of FreeType 2 is found first."
|
||||
#endif
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* module_management */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* Module Management */
|
||||
/* */
|
||||
/* <Abstract> */
|
||||
/* How to add, upgrade, remove, and control modules from FreeType. */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The definitions below are used to manage modules within FreeType. */
|
||||
/* Modules can be added, upgraded, and removed at runtime. */
|
||||
/* Additionally, some module properties can be controlled also. */
|
||||
/* */
|
||||
/* Here is a list of possible values of the `module_name' field in */
|
||||
/* the @FT_Module_Class structure. */
|
||||
/* */
|
||||
/* { */
|
||||
/* autofitter */
|
||||
/* bdf */
|
||||
/* cff */
|
||||
/* gxvalid */
|
||||
/* otvalid */
|
||||
/* pcf */
|
||||
/* pfr */
|
||||
/* psaux */
|
||||
/* pshinter */
|
||||
/* psnames */
|
||||
/* raster1 */
|
||||
/* sfnt */
|
||||
/* smooth, smooth-lcd, smooth-lcdv */
|
||||
/* truetype */
|
||||
/* type1 */
|
||||
/* type42 */
|
||||
/* t1cid */
|
||||
/* winfonts */
|
||||
/* } */
|
||||
/* */
|
||||
/* Note that the FreeType Cache sub-system is not a FreeType module. */
|
||||
/* */
|
||||
/* <Order> */
|
||||
/* FT_Module */
|
||||
/* FT_Module_Constructor */
|
||||
/* FT_Module_Destructor */
|
||||
/* FT_Module_Requester */
|
||||
/* FT_Module_Class */
|
||||
/* */
|
||||
/* FT_Add_Module */
|
||||
/* FT_Get_Module */
|
||||
/* FT_Remove_Module */
|
||||
/* FT_Add_Default_Modules */
|
||||
/* */
|
||||
/* FT_Property_Set */
|
||||
/* FT_Property_Get */
|
||||
/* FT_Set_Default_Properties */
|
||||
/* */
|
||||
/* FT_New_Library */
|
||||
/* FT_Done_Library */
|
||||
/* FT_Reference_Library */
|
||||
/* */
|
||||
/* FT_Renderer */
|
||||
/* FT_Renderer_Class */
|
||||
/* */
|
||||
/* FT_Get_Renderer */
|
||||
/* FT_Set_Renderer */
|
||||
/* */
|
||||
/* FT_Set_Debug_Hook */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/* module bit flags */
|
||||
#define FT_MODULE_FONT_DRIVER 1 /* this module is a font driver */
|
||||
#define FT_MODULE_RENDERER 2 /* this module is a renderer */
|
||||
#define FT_MODULE_HINTER 4 /* this module is a glyph hinter */
|
||||
#define FT_MODULE_STYLER 8 /* this module is a styler */
|
||||
|
||||
#define FT_MODULE_DRIVER_SCALABLE 0x100 /* the driver supports */
|
||||
/* scalable fonts */
|
||||
#define FT_MODULE_DRIVER_NO_OUTLINES 0x200 /* the driver does not */
|
||||
/* support vector outlines */
|
||||
#define FT_MODULE_DRIVER_HAS_HINTER 0x400 /* the driver provides its */
|
||||
/* own hinter */
|
||||
#define FT_MODULE_DRIVER_HINTS_LIGHTLY 0x800 /* the driver's hinter */
|
||||
/* produces LIGHT hints */
|
||||
|
||||
|
||||
/* deprecated values */
|
||||
#define ft_module_font_driver FT_MODULE_FONT_DRIVER
|
||||
#define ft_module_renderer FT_MODULE_RENDERER
|
||||
#define ft_module_hinter FT_MODULE_HINTER
|
||||
#define ft_module_styler FT_MODULE_STYLER
|
||||
|
||||
#define ft_module_driver_scalable FT_MODULE_DRIVER_SCALABLE
|
||||
#define ft_module_driver_no_outlines FT_MODULE_DRIVER_NO_OUTLINES
|
||||
#define ft_module_driver_has_hinter FT_MODULE_DRIVER_HAS_HINTER
|
||||
#define ft_module_driver_hints_lightly FT_MODULE_DRIVER_HINTS_LIGHTLY
|
||||
|
||||
|
||||
typedef FT_Pointer FT_Module_Interface;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* FT_Module_Constructor */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A function used to initialize (not create) a new module object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* module :: The module to initialize. */
|
||||
/* */
|
||||
typedef FT_Error
|
||||
(*FT_Module_Constructor)( FT_Module module );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* FT_Module_Destructor */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A function used to finalize (not destroy) a given module object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* module :: The module to finalize. */
|
||||
/* */
|
||||
typedef void
|
||||
(*FT_Module_Destructor)( FT_Module module );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* FT_Module_Requester */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A function used to query a given module for a specific interface. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* module :: The module to be searched. */
|
||||
/* */
|
||||
/* name :: The name of the interface in the module. */
|
||||
/* */
|
||||
typedef FT_Module_Interface
|
||||
(*FT_Module_Requester)( FT_Module module,
|
||||
const char* name );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_Module_Class */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The module class descriptor. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* module_flags :: Bit flags describing the module. */
|
||||
/* */
|
||||
/* module_size :: The size of one module object/instance in */
|
||||
/* bytes. */
|
||||
/* */
|
||||
/* module_name :: The name of the module. */
|
||||
/* */
|
||||
/* module_version :: The version, as a 16.16 fixed number */
|
||||
/* (major.minor). */
|
||||
/* */
|
||||
/* module_requires :: The version of FreeType this module requires, */
|
||||
/* as a 16.16 fixed number (major.minor). Starts */
|
||||
/* at version 2.0, i.e., 0x20000. */
|
||||
/* */
|
||||
/* module_init :: The initializing function. */
|
||||
/* */
|
||||
/* module_done :: The finalizing function. */
|
||||
/* */
|
||||
/* get_interface :: The interface requesting function. */
|
||||
/* */
|
||||
typedef struct FT_Module_Class_
|
||||
{
|
||||
FT_ULong module_flags;
|
||||
FT_Long module_size;
|
||||
const FT_String* module_name;
|
||||
FT_Fixed module_version;
|
||||
FT_Fixed module_requires;
|
||||
|
||||
const void* module_interface;
|
||||
|
||||
FT_Module_Constructor module_init;
|
||||
FT_Module_Destructor module_done;
|
||||
FT_Module_Requester get_interface;
|
||||
|
||||
} FT_Module_Class;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Add_Module */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Add a new module to a given library instance. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* library :: A handle to the library object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* clazz :: A pointer to class descriptor for the module. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* An error will be returned if a module already exists by that name, */
|
||||
/* or if the module requires a version of FreeType that is too great. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Add_Module( FT_Library library,
|
||||
const FT_Module_Class* clazz );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_Module */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Find a module by its name. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle to the library object. */
|
||||
/* */
|
||||
/* module_name :: The module's name (as an ASCII string). */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* A module handle. 0~if none was found. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* FreeType's internal modules aren't documented very well, and you */
|
||||
/* should look up the source code for details. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Module )
|
||||
FT_Get_Module( FT_Library library,
|
||||
const char* module_name );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Remove_Module */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Remove a given module from a library instance. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* library :: A handle to a library object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* module :: A handle to a module object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The module object is destroyed by the function in case of success. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Remove_Module( FT_Library library,
|
||||
FT_Module module );
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Property_Set
|
||||
*
|
||||
* @description:
|
||||
* Set a property for a given module.
|
||||
*
|
||||
* @input:
|
||||
* library ::
|
||||
* A handle to the library the module is part of.
|
||||
*
|
||||
* module_name ::
|
||||
* The module name.
|
||||
*
|
||||
* property_name ::
|
||||
* The property name. Properties are described in section
|
||||
* @properties.
|
||||
*
|
||||
* Note that only a few modules have properties.
|
||||
*
|
||||
* value ::
|
||||
* A generic pointer to a variable or structure that gives the new
|
||||
* value of the property. The exact definition of `value' is
|
||||
* dependent on the property; see section @properties.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* If `module_name' isn't a valid module name, or `property_name'
|
||||
* doesn't specify a valid property, or if `value' doesn't represent a
|
||||
* valid value for the given property, an error is returned.
|
||||
*
|
||||
* The following example sets property `bar' (a simple integer) in
|
||||
* module `foo' to value~1.
|
||||
*
|
||||
* {
|
||||
* FT_UInt bar;
|
||||
*
|
||||
*
|
||||
* bar = 1;
|
||||
* FT_Property_Set( library, "foo", "bar", &bar );
|
||||
* }
|
||||
*
|
||||
* Note that the FreeType Cache sub-system doesn't recognize module
|
||||
* property changes. To avoid glyph lookup confusion within the cache
|
||||
* you should call @FTC_Manager_Reset to completely flush the cache if
|
||||
* a module property gets changed after @FTC_Manager_New has been
|
||||
* called.
|
||||
*
|
||||
* It is not possible to set properties of the FreeType Cache
|
||||
* sub-system itself with FT_Property_Set; use @FTC_Property_Set
|
||||
* instead.
|
||||
*
|
||||
* @since:
|
||||
* 2.4.11
|
||||
*
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Property_Set( FT_Library library,
|
||||
const FT_String* module_name,
|
||||
const FT_String* property_name,
|
||||
const void* value );
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Property_Get
|
||||
*
|
||||
* @description:
|
||||
* Get a module's property value.
|
||||
*
|
||||
* @input:
|
||||
* library ::
|
||||
* A handle to the library the module is part of.
|
||||
*
|
||||
* module_name ::
|
||||
* The module name.
|
||||
*
|
||||
* property_name ::
|
||||
* The property name. Properties are described in section
|
||||
* @properties.
|
||||
*
|
||||
* @inout:
|
||||
* value ::
|
||||
* A generic pointer to a variable or structure that gives the
|
||||
* value of the property. The exact definition of `value' is
|
||||
* dependent on the property; see section @properties.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* If `module_name' isn't a valid module name, or `property_name'
|
||||
* doesn't specify a valid property, or if `value' doesn't represent a
|
||||
* valid value for the given property, an error is returned.
|
||||
*
|
||||
* The following example gets property `baz' (a range) in module `foo'.
|
||||
*
|
||||
* {
|
||||
* typedef range_
|
||||
* {
|
||||
* FT_Int32 min;
|
||||
* FT_Int32 max;
|
||||
*
|
||||
* } range;
|
||||
*
|
||||
* range baz;
|
||||
*
|
||||
*
|
||||
* FT_Property_Get( library, "foo", "baz", &baz );
|
||||
* }
|
||||
*
|
||||
* It is not possible to retrieve properties of the FreeType Cache
|
||||
* sub-system with FT_Property_Get; use @FTC_Property_Get instead.
|
||||
*
|
||||
* @since:
|
||||
* 2.4.11
|
||||
*
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Property_Get( FT_Library library,
|
||||
const FT_String* module_name,
|
||||
const FT_String* property_name,
|
||||
void* value );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Set_Default_Properties */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* If compilation option FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES is */
|
||||
/* set, this function reads the `FREETYPE_PROPERTIES' environment */
|
||||
/* variable to control driver properties. See section @properties */
|
||||
/* for more. */
|
||||
/* */
|
||||
/* If the compilation option is not set, this function does nothing. */
|
||||
/* */
|
||||
/* `FREETYPE_PROPERTIES' has the following syntax form (broken here */
|
||||
/* into multiple lines for better readability). */
|
||||
/* */
|
||||
/* { */
|
||||
/* <optional whitespace> */
|
||||
/* <module-name1> ':' */
|
||||
/* <property-name1> '=' <property-value1> */
|
||||
/* <whitespace> */
|
||||
/* <module-name2> ':' */
|
||||
/* <property-name2> '=' <property-value2> */
|
||||
/* ... */
|
||||
/* } */
|
||||
/* */
|
||||
/* Example: */
|
||||
/* */
|
||||
/* { */
|
||||
/* FREETYPE_PROPERTIES=truetype:interpreter-version=35 \ */
|
||||
/* cff:no-stem-darkening=1 \ */
|
||||
/* autofitter:warping=1 */
|
||||
/* } */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* library :: A handle to a new library object. */
|
||||
/* */
|
||||
/* <Since> */
|
||||
/* 2.8 */
|
||||
/* */
|
||||
FT_EXPORT( void )
|
||||
FT_Set_Default_Properties( FT_Library library );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Reference_Library */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A counter gets initialized to~1 at the time an @FT_Library */
|
||||
/* structure is created. This function increments the counter. */
|
||||
/* @FT_Done_Library then only destroys a library if the counter is~1, */
|
||||
/* otherwise it simply decrements the counter. */
|
||||
/* */
|
||||
/* This function helps in managing life-cycles of structures that */
|
||||
/* reference @FT_Library objects. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle to a target library object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Since> */
|
||||
/* 2.4.2 */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Reference_Library( FT_Library library );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_New_Library */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This function is used to create a new FreeType library instance */
|
||||
/* from a given memory object. It is thus possible to use libraries */
|
||||
/* with distinct memory allocators within the same program. Note, */
|
||||
/* however, that the used @FT_Memory structure is expected to remain */
|
||||
/* valid for the life of the @FT_Library object. */
|
||||
/* */
|
||||
/* Normally, you would call this function (followed by a call to */
|
||||
/* @FT_Add_Default_Modules or a series of calls to @FT_Add_Module, */
|
||||
/* and a call to @FT_Set_Default_Properties) instead of */
|
||||
/* @FT_Init_FreeType to initialize the FreeType library. */
|
||||
/* */
|
||||
/* Don't use @FT_Done_FreeType but @FT_Done_Library to destroy a */
|
||||
/* library instance. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* memory :: A handle to the original memory object. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* alibrary :: A pointer to handle of a new library object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* See the discussion of reference counters in the description of */
|
||||
/* @FT_Reference_Library. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_New_Library( FT_Memory memory,
|
||||
FT_Library *alibrary );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Done_Library */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Discard a given library object. This closes all drivers and */
|
||||
/* discards all resource objects. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle to the target library. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* See the discussion of reference counters in the description of */
|
||||
/* @FT_Reference_Library. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Done_Library( FT_Library library );
|
||||
|
||||
/* */
|
||||
|
||||
typedef void
|
||||
(*FT_DebugHook_Func)( void* arg );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Set_Debug_Hook */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Set a debug hook function for debugging the interpreter of a font */
|
||||
/* format. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* library :: A handle to the library object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* hook_index :: The index of the debug hook. You should use the */
|
||||
/* values defined in `ftobjs.h', e.g., */
|
||||
/* `FT_DEBUG_HOOK_TRUETYPE'. */
|
||||
/* */
|
||||
/* debug_hook :: The function used to debug the interpreter. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* Currently, four debug hook slots are available, but only two (for */
|
||||
/* the TrueType and the Type~1 interpreter) are defined. */
|
||||
/* */
|
||||
/* Since the internal headers of FreeType are no longer installed, */
|
||||
/* the symbol `FT_DEBUG_HOOK_TRUETYPE' isn't available publicly. */
|
||||
/* This is a bug and will be fixed in a forthcoming release. */
|
||||
/* */
|
||||
FT_EXPORT( void )
|
||||
FT_Set_Debug_Hook( FT_Library library,
|
||||
FT_UInt hook_index,
|
||||
FT_DebugHook_Func debug_hook );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Add_Default_Modules */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Add the set of default drivers to a given library object. */
|
||||
/* This is only useful when you create a library object with */
|
||||
/* @FT_New_Library (usually to plug a custom memory manager). */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* library :: A handle to a new library object. */
|
||||
/* */
|
||||
FT_EXPORT( void )
|
||||
FT_Add_Default_Modules( FT_Library library );
|
||||
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @section:
|
||||
* truetype_engine
|
||||
*
|
||||
* @title:
|
||||
* The TrueType Engine
|
||||
*
|
||||
* @abstract:
|
||||
* TrueType bytecode support.
|
||||
*
|
||||
* @description:
|
||||
* This section contains a function used to query the level of TrueType
|
||||
* bytecode support compiled in this version of the library.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @enum:
|
||||
* FT_TrueTypeEngineType
|
||||
*
|
||||
* @description:
|
||||
* A list of values describing which kind of TrueType bytecode
|
||||
* engine is implemented in a given FT_Library instance. It is used
|
||||
* by the @FT_Get_TrueType_Engine_Type function.
|
||||
*
|
||||
* @values:
|
||||
* FT_TRUETYPE_ENGINE_TYPE_NONE ::
|
||||
* The library doesn't implement any kind of bytecode interpreter.
|
||||
*
|
||||
* FT_TRUETYPE_ENGINE_TYPE_UNPATENTED ::
|
||||
* Deprecated and removed.
|
||||
*
|
||||
* FT_TRUETYPE_ENGINE_TYPE_PATENTED ::
|
||||
* The library implements a bytecode interpreter that covers
|
||||
* the full instruction set of the TrueType virtual machine (this
|
||||
* was governed by patents until May 2010, hence the name).
|
||||
*
|
||||
* @since:
|
||||
* 2.2
|
||||
*
|
||||
*/
|
||||
typedef enum FT_TrueTypeEngineType_
|
||||
{
|
||||
FT_TRUETYPE_ENGINE_TYPE_NONE = 0,
|
||||
FT_TRUETYPE_ENGINE_TYPE_UNPATENTED,
|
||||
FT_TRUETYPE_ENGINE_TYPE_PATENTED
|
||||
|
||||
} FT_TrueTypeEngineType;
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @func:
|
||||
* FT_Get_TrueType_Engine_Type
|
||||
*
|
||||
* @description:
|
||||
* Return an @FT_TrueTypeEngineType value to indicate which level of
|
||||
* the TrueType virtual machine a given library instance supports.
|
||||
*
|
||||
* @input:
|
||||
* library ::
|
||||
* A library instance.
|
||||
*
|
||||
* @return:
|
||||
* A value indicating which level is supported.
|
||||
*
|
||||
* @since:
|
||||
* 2.2
|
||||
*
|
||||
*/
|
||||
FT_EXPORT( FT_TrueTypeEngineType )
|
||||
FT_Get_TrueType_Engine_Type( FT_Library library );
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTMODAPI_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,194 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftmoderr.h */
|
||||
/* */
|
||||
/* FreeType module error offsets (specification). */
|
||||
/* */
|
||||
/* Copyright 2001-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* This file is used to define the FreeType module error codes. */
|
||||
/* */
|
||||
/* If the macro FT_CONFIG_OPTION_USE_MODULE_ERRORS in `ftoption.h' is */
|
||||
/* set, the lower byte of an error value identifies the error code as */
|
||||
/* usual. In addition, the higher byte identifies the module. For */
|
||||
/* example, the error `FT_Err_Invalid_File_Format' has value 0x0003, the */
|
||||
/* error `TT_Err_Invalid_File_Format' has value 0x1303, the error */
|
||||
/* `T1_Err_Invalid_File_Format' has value 0x1403, etc. */
|
||||
/* */
|
||||
/* Note that `FT_Err_Ok', `TT_Err_Ok', etc. are always equal to zero, */
|
||||
/* including the high byte. */
|
||||
/* */
|
||||
/* If FT_CONFIG_OPTION_USE_MODULE_ERRORS isn't set, the higher byte of */
|
||||
/* an error value is set to zero. */
|
||||
/* */
|
||||
/* To hide the various `XXX_Err_' prefixes in the source code, FreeType */
|
||||
/* provides some macros in `fttypes.h'. */
|
||||
/* */
|
||||
/* FT_ERR( err ) */
|
||||
/* Add current error module prefix (as defined with the */
|
||||
/* `FT_ERR_PREFIX' macro) to `err'. For example, in the BDF module */
|
||||
/* the line */
|
||||
/* */
|
||||
/* error = FT_ERR( Invalid_Outline ); */
|
||||
/* */
|
||||
/* expands to */
|
||||
/* */
|
||||
/* error = BDF_Err_Invalid_Outline; */
|
||||
/* */
|
||||
/* For simplicity, you can always use `FT_Err_Ok' directly instead */
|
||||
/* of `FT_ERR( Ok )'. */
|
||||
/* */
|
||||
/* FT_ERR_EQ( errcode, err ) */
|
||||
/* FT_ERR_NEQ( errcode, err ) */
|
||||
/* Compare error code `errcode' with the error `err' for equality */
|
||||
/* and inequality, respectively. Example: */
|
||||
/* */
|
||||
/* if ( FT_ERR_EQ( error, Invalid_Outline ) ) */
|
||||
/* ... */
|
||||
/* */
|
||||
/* Using this macro you don't have to think about error prefixes. */
|
||||
/* Of course, if module errors are not active, the above example is */
|
||||
/* the same as */
|
||||
/* */
|
||||
/* if ( error == FT_Err_Invalid_Outline ) */
|
||||
/* ... */
|
||||
/* */
|
||||
/* FT_ERROR_BASE( errcode ) */
|
||||
/* FT_ERROR_MODULE( errcode ) */
|
||||
/* Get base error and module error code, respectively. */
|
||||
/* */
|
||||
/* */
|
||||
/* It can also be used to create a module error message table easily */
|
||||
/* with something like */
|
||||
/* */
|
||||
/* { */
|
||||
/* #undef FTMODERR_H_ */
|
||||
/* #define FT_MODERRDEF( e, v, s ) { FT_Mod_Err_ ## e, s }, */
|
||||
/* #define FT_MODERR_START_LIST { */
|
||||
/* #define FT_MODERR_END_LIST { 0, 0 } }; */
|
||||
/* */
|
||||
/* const struct */
|
||||
/* { */
|
||||
/* int mod_err_offset; */
|
||||
/* const char* mod_err_msg */
|
||||
/* } ft_mod_errors[] = */
|
||||
/* */
|
||||
/* #include FT_MODULE_ERRORS_H */
|
||||
/* } */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTMODERR_H_
|
||||
#define FTMODERR_H_
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*******************************************************************/
|
||||
/***** *****/
|
||||
/***** SETUP MACROS *****/
|
||||
/***** *****/
|
||||
/*******************************************************************/
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
#undef FT_NEED_EXTERN_C
|
||||
|
||||
#ifndef FT_MODERRDEF
|
||||
|
||||
#ifdef FT_CONFIG_OPTION_USE_MODULE_ERRORS
|
||||
#define FT_MODERRDEF( e, v, s ) FT_Mod_Err_ ## e = v,
|
||||
#else
|
||||
#define FT_MODERRDEF( e, v, s ) FT_Mod_Err_ ## e = 0,
|
||||
#endif
|
||||
|
||||
#define FT_MODERR_START_LIST enum {
|
||||
#define FT_MODERR_END_LIST FT_Mod_Err_Max };
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define FT_NEED_EXTERN_C
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#endif /* !FT_MODERRDEF */
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*******************************************************************/
|
||||
/***** *****/
|
||||
/***** LIST MODULE ERROR BASES *****/
|
||||
/***** *****/
|
||||
/*******************************************************************/
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
#ifdef FT_MODERR_START_LIST
|
||||
FT_MODERR_START_LIST
|
||||
#endif
|
||||
|
||||
|
||||
FT_MODERRDEF( Base, 0x000, "base module" )
|
||||
FT_MODERRDEF( Autofit, 0x100, "autofitter module" )
|
||||
FT_MODERRDEF( BDF, 0x200, "BDF module" )
|
||||
FT_MODERRDEF( Bzip2, 0x300, "Bzip2 module" )
|
||||
FT_MODERRDEF( Cache, 0x400, "cache module" )
|
||||
FT_MODERRDEF( CFF, 0x500, "CFF module" )
|
||||
FT_MODERRDEF( CID, 0x600, "CID module" )
|
||||
FT_MODERRDEF( Gzip, 0x700, "Gzip module" )
|
||||
FT_MODERRDEF( LZW, 0x800, "LZW module" )
|
||||
FT_MODERRDEF( OTvalid, 0x900, "OpenType validation module" )
|
||||
FT_MODERRDEF( PCF, 0xA00, "PCF module" )
|
||||
FT_MODERRDEF( PFR, 0xB00, "PFR module" )
|
||||
FT_MODERRDEF( PSaux, 0xC00, "PS auxiliary module" )
|
||||
FT_MODERRDEF( PShinter, 0xD00, "PS hinter module" )
|
||||
FT_MODERRDEF( PSnames, 0xE00, "PS names module" )
|
||||
FT_MODERRDEF( Raster, 0xF00, "raster module" )
|
||||
FT_MODERRDEF( SFNT, 0x1000, "SFNT module" )
|
||||
FT_MODERRDEF( Smooth, 0x1100, "smooth raster module" )
|
||||
FT_MODERRDEF( TrueType, 0x1200, "TrueType module" )
|
||||
FT_MODERRDEF( Type1, 0x1300, "Type 1 module" )
|
||||
FT_MODERRDEF( Type42, 0x1400, "Type 42 module" )
|
||||
FT_MODERRDEF( Winfonts, 0x1500, "Windows FON/FNT module" )
|
||||
FT_MODERRDEF( GXvalid, 0x1600, "GX validation module" )
|
||||
|
||||
|
||||
#ifdef FT_MODERR_END_LIST
|
||||
FT_MODERR_END_LIST
|
||||
#endif
|
||||
|
||||
|
||||
/*******************************************************************/
|
||||
/*******************************************************************/
|
||||
/***** *****/
|
||||
/***** CLEANUP *****/
|
||||
/***** *****/
|
||||
/*******************************************************************/
|
||||
/*******************************************************************/
|
||||
|
||||
|
||||
#ifdef FT_NEED_EXTERN_C
|
||||
}
|
||||
#endif
|
||||
|
||||
#undef FT_MODERR_START_LIST
|
||||
#undef FT_MODERR_END_LIST
|
||||
#undef FT_MODERRDEF
|
||||
#undef FT_NEED_EXTERN_C
|
||||
|
||||
|
||||
#endif /* FTMODERR_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,204 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftotval.h */
|
||||
/* */
|
||||
/* FreeType API for validating OpenType tables (specification). */
|
||||
/* */
|
||||
/* Copyright 2004-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* */
|
||||
/* Warning: This module might be moved to a different library in the */
|
||||
/* future to avoid a tight dependency between FreeType and the */
|
||||
/* OpenType specification. */
|
||||
/* */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTOTVAL_H_
|
||||
#define FTOTVAL_H_
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#ifdef FREETYPE_H
|
||||
#error "freetype.h of FreeType 1 has been loaded!"
|
||||
#error "Please fix the directory search order for header files"
|
||||
#error "so that freetype.h of FreeType 2 is found first."
|
||||
#endif
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* ot_validation */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* OpenType Validation */
|
||||
/* */
|
||||
/* <Abstract> */
|
||||
/* An API to validate OpenType tables. */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This section contains the declaration of functions to validate */
|
||||
/* some OpenType tables (BASE, GDEF, GPOS, GSUB, JSTF, MATH). */
|
||||
/* */
|
||||
/* <Order> */
|
||||
/* FT_OpenType_Validate */
|
||||
/* FT_OpenType_Free */
|
||||
/* */
|
||||
/* FT_VALIDATE_OTXXX */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* @enum:
|
||||
* FT_VALIDATE_OTXXX
|
||||
*
|
||||
* @description:
|
||||
* A list of bit-field constants used with @FT_OpenType_Validate to
|
||||
* indicate which OpenType tables should be validated.
|
||||
*
|
||||
* @values:
|
||||
* FT_VALIDATE_BASE ::
|
||||
* Validate BASE table.
|
||||
*
|
||||
* FT_VALIDATE_GDEF ::
|
||||
* Validate GDEF table.
|
||||
*
|
||||
* FT_VALIDATE_GPOS ::
|
||||
* Validate GPOS table.
|
||||
*
|
||||
* FT_VALIDATE_GSUB ::
|
||||
* Validate GSUB table.
|
||||
*
|
||||
* FT_VALIDATE_JSTF ::
|
||||
* Validate JSTF table.
|
||||
*
|
||||
* FT_VALIDATE_MATH ::
|
||||
* Validate MATH table.
|
||||
*
|
||||
* FT_VALIDATE_OT ::
|
||||
* Validate all OpenType tables (BASE, GDEF, GPOS, GSUB, JSTF, MATH).
|
||||
*
|
||||
*/
|
||||
#define FT_VALIDATE_BASE 0x0100
|
||||
#define FT_VALIDATE_GDEF 0x0200
|
||||
#define FT_VALIDATE_GPOS 0x0400
|
||||
#define FT_VALIDATE_GSUB 0x0800
|
||||
#define FT_VALIDATE_JSTF 0x1000
|
||||
#define FT_VALIDATE_MATH 0x2000
|
||||
|
||||
#define FT_VALIDATE_OT ( FT_VALIDATE_BASE | \
|
||||
FT_VALIDATE_GDEF | \
|
||||
FT_VALIDATE_GPOS | \
|
||||
FT_VALIDATE_GSUB | \
|
||||
FT_VALIDATE_JSTF | \
|
||||
FT_VALIDATE_MATH )
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_OpenType_Validate
|
||||
*
|
||||
* @description:
|
||||
* Validate various OpenType tables to assure that all offsets and
|
||||
* indices are valid. The idea is that a higher-level library that
|
||||
* actually does the text layout can access those tables without
|
||||
* error checking (which can be quite time consuming).
|
||||
*
|
||||
* @input:
|
||||
* face ::
|
||||
* A handle to the input face.
|
||||
*
|
||||
* validation_flags ::
|
||||
* A bit field that specifies the tables to be validated. See
|
||||
* @FT_VALIDATE_OTXXX for possible values.
|
||||
*
|
||||
* @output:
|
||||
* BASE_table ::
|
||||
* A pointer to the BASE table.
|
||||
*
|
||||
* GDEF_table ::
|
||||
* A pointer to the GDEF table.
|
||||
*
|
||||
* GPOS_table ::
|
||||
* A pointer to the GPOS table.
|
||||
*
|
||||
* GSUB_table ::
|
||||
* A pointer to the GSUB table.
|
||||
*
|
||||
* JSTF_table ::
|
||||
* A pointer to the JSTF table.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* This function only works with OpenType fonts, returning an error
|
||||
* otherwise.
|
||||
*
|
||||
* After use, the application should deallocate the five tables with
|
||||
* @FT_OpenType_Free. A NULL value indicates that the table either
|
||||
* doesn't exist in the font, or the application hasn't asked for
|
||||
* validation.
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_OpenType_Validate( FT_Face face,
|
||||
FT_UInt validation_flags,
|
||||
FT_Bytes *BASE_table,
|
||||
FT_Bytes *GDEF_table,
|
||||
FT_Bytes *GPOS_table,
|
||||
FT_Bytes *GSUB_table,
|
||||
FT_Bytes *JSTF_table );
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_OpenType_Free
|
||||
*
|
||||
* @description:
|
||||
* Free the buffer allocated by OpenType validator.
|
||||
*
|
||||
* @input:
|
||||
* face ::
|
||||
* A handle to the input face.
|
||||
*
|
||||
* table ::
|
||||
* The pointer to the buffer that is allocated by
|
||||
* @FT_OpenType_Validate.
|
||||
*
|
||||
* @note:
|
||||
* This function must be used to free the buffer allocated by
|
||||
* @FT_OpenType_Validate only.
|
||||
*/
|
||||
FT_EXPORT( void )
|
||||
FT_OpenType_Free( FT_Face face,
|
||||
FT_Bytes table );
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTOTVAL_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,582 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftoutln.h */
|
||||
/* */
|
||||
/* Support for the FT_Outline type used to store glyph shapes of */
|
||||
/* most scalable font formats (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTOUTLN_H_
|
||||
#define FTOUTLN_H_
|
||||
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#ifdef FREETYPE_H
|
||||
#error "freetype.h of FreeType 1 has been loaded!"
|
||||
#error "Please fix the directory search order for header files"
|
||||
#error "so that freetype.h of FreeType 2 is found first."
|
||||
#endif
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* outline_processing */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* Outline Processing */
|
||||
/* */
|
||||
/* <Abstract> */
|
||||
/* Functions to create, transform, and render vectorial glyph images. */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This section contains routines used to create and destroy scalable */
|
||||
/* glyph images known as `outlines'. These can also be measured, */
|
||||
/* transformed, and converted into bitmaps and pixmaps. */
|
||||
/* */
|
||||
/* <Order> */
|
||||
/* FT_Outline */
|
||||
/* FT_Outline_New */
|
||||
/* FT_Outline_Done */
|
||||
/* FT_Outline_Copy */
|
||||
/* FT_Outline_Translate */
|
||||
/* FT_Outline_Transform */
|
||||
/* FT_Outline_Embolden */
|
||||
/* FT_Outline_EmboldenXY */
|
||||
/* FT_Outline_Reverse */
|
||||
/* FT_Outline_Check */
|
||||
/* */
|
||||
/* FT_Outline_Get_CBox */
|
||||
/* FT_Outline_Get_BBox */
|
||||
/* */
|
||||
/* FT_Outline_Get_Bitmap */
|
||||
/* FT_Outline_Render */
|
||||
/* FT_Outline_Decompose */
|
||||
/* FT_Outline_Funcs */
|
||||
/* FT_Outline_MoveToFunc */
|
||||
/* FT_Outline_LineToFunc */
|
||||
/* FT_Outline_ConicToFunc */
|
||||
/* FT_Outline_CubicToFunc */
|
||||
/* */
|
||||
/* FT_Orientation */
|
||||
/* FT_Outline_Get_Orientation */
|
||||
/* */
|
||||
/* FT_OUTLINE_XXX */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Decompose */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Walk over an outline's structure to decompose it into individual */
|
||||
/* segments and Bezier arcs. This function also emits `move to' */
|
||||
/* operations to indicate the start of new contours in the outline. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* outline :: A pointer to the source target. */
|
||||
/* */
|
||||
/* func_interface :: A table of `emitters', i.e., function pointers */
|
||||
/* called during decomposition to indicate path */
|
||||
/* operations. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* user :: A typeless pointer that is passed to each */
|
||||
/* emitter during the decomposition. It can be */
|
||||
/* used to store the state during the */
|
||||
/* decomposition. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* A contour that contains a single point only is represented by a */
|
||||
/* `move to' operation followed by `line to' to the same point. In */
|
||||
/* most cases, it is best to filter this out before using the */
|
||||
/* outline for stroking purposes (otherwise it would result in a */
|
||||
/* visible dot when round caps are used). */
|
||||
/* */
|
||||
/* Similarly, the function returns success for an empty outline also */
|
||||
/* (doing nothing, this is, not calling any emitter); if necessary, */
|
||||
/* you should filter this out, too. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Outline_Decompose( FT_Outline* outline,
|
||||
const FT_Outline_Funcs* func_interface,
|
||||
void* user );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_New */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Create a new outline of a given size. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle to the library object from where the */
|
||||
/* outline is allocated. Note however that the new */
|
||||
/* outline will *not* necessarily be *freed*, when */
|
||||
/* destroying the library, by @FT_Done_FreeType. */
|
||||
/* */
|
||||
/* numPoints :: The maximum number of points within the outline. */
|
||||
/* Must be smaller than or equal to 0xFFFF (65535). */
|
||||
/* */
|
||||
/* numContours :: The maximum number of contours within the outline. */
|
||||
/* This value must be in the range 0 to `numPoints'. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* anoutline :: A handle to the new outline. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The reason why this function takes a `library' parameter is simply */
|
||||
/* to use the library's memory allocator. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Outline_New( FT_Library library,
|
||||
FT_UInt numPoints,
|
||||
FT_Int numContours,
|
||||
FT_Outline *anoutline );
|
||||
|
||||
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Outline_New_Internal( FT_Memory memory,
|
||||
FT_UInt numPoints,
|
||||
FT_Int numContours,
|
||||
FT_Outline *anoutline );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Done */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Destroy an outline created with @FT_Outline_New. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle of the library object used to allocate the */
|
||||
/* outline. */
|
||||
/* */
|
||||
/* outline :: A pointer to the outline object to be discarded. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* If the outline's `owner' field is not set, only the outline */
|
||||
/* descriptor will be released. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Outline_Done( FT_Library library,
|
||||
FT_Outline* outline );
|
||||
|
||||
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Outline_Done_Internal( FT_Memory memory,
|
||||
FT_Outline* outline );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Check */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Check the contents of an outline descriptor. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* outline :: A handle to a source outline. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* An empty outline, or an outline with a single point only is also */
|
||||
/* valid. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Outline_Check( FT_Outline* outline );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Get_CBox */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Return an outline's `control box'. The control box encloses all */
|
||||
/* the outline's points, including Bezier control points. Though it */
|
||||
/* coincides with the exact bounding box for most glyphs, it can be */
|
||||
/* slightly larger in some situations (like when rotating an outline */
|
||||
/* that contains Bezier outside arcs). */
|
||||
/* */
|
||||
/* Computing the control box is very fast, while getting the bounding */
|
||||
/* box can take much more time as it needs to walk over all segments */
|
||||
/* and arcs in the outline. To get the latter, you can use the */
|
||||
/* `ftbbox' component, which is dedicated to this single task. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* outline :: A pointer to the source outline descriptor. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* acbox :: The outline's control box. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* See @FT_Glyph_Get_CBox for a discussion of tricky fonts. */
|
||||
/* */
|
||||
FT_EXPORT( void )
|
||||
FT_Outline_Get_CBox( const FT_Outline* outline,
|
||||
FT_BBox *acbox );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Translate */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Apply a simple translation to the points of an outline. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* outline :: A pointer to the target outline descriptor. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* xOffset :: The horizontal offset. */
|
||||
/* */
|
||||
/* yOffset :: The vertical offset. */
|
||||
/* */
|
||||
FT_EXPORT( void )
|
||||
FT_Outline_Translate( const FT_Outline* outline,
|
||||
FT_Pos xOffset,
|
||||
FT_Pos yOffset );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Copy */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Copy an outline into another one. Both objects must have the */
|
||||
/* same sizes (number of points & number of contours) when this */
|
||||
/* function is called. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* source :: A handle to the source outline. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* target :: A handle to the target outline. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Outline_Copy( const FT_Outline* source,
|
||||
FT_Outline *target );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Transform */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Apply a simple 2x2 matrix to all of an outline's points. Useful */
|
||||
/* for applying rotations, slanting, flipping, etc. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* outline :: A pointer to the target outline descriptor. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* matrix :: A pointer to the transformation matrix. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* You can use @FT_Outline_Translate if you need to translate the */
|
||||
/* outline's points. */
|
||||
/* */
|
||||
FT_EXPORT( void )
|
||||
FT_Outline_Transform( const FT_Outline* outline,
|
||||
const FT_Matrix* matrix );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Embolden */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Embolden an outline. The new outline will be at most 4~times */
|
||||
/* `strength' pixels wider and higher. You may think of the left and */
|
||||
/* bottom borders as unchanged. */
|
||||
/* */
|
||||
/* Negative `strength' values to reduce the outline thickness are */
|
||||
/* possible also. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* outline :: A handle to the target outline. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* strength :: How strong the glyph is emboldened. Expressed in */
|
||||
/* 26.6 pixel format. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The used algorithm to increase or decrease the thickness of the */
|
||||
/* glyph doesn't change the number of points; this means that certain */
|
||||
/* situations like acute angles or intersections are sometimes */
|
||||
/* handled incorrectly. */
|
||||
/* */
|
||||
/* If you need `better' metrics values you should call */
|
||||
/* @FT_Outline_Get_CBox or @FT_Outline_Get_BBox. */
|
||||
/* */
|
||||
/* Example call: */
|
||||
/* */
|
||||
/* { */
|
||||
/* FT_Load_Glyph( face, index, FT_LOAD_DEFAULT ); */
|
||||
/* if ( face->glyph->format == FT_GLYPH_FORMAT_OUTLINE ) */
|
||||
/* FT_Outline_Embolden( &face->glyph->outline, strength ); */
|
||||
/* } */
|
||||
/* */
|
||||
/* To get meaningful results, font scaling values must be set with */
|
||||
/* functions like @FT_Set_Char_Size before calling FT_Render_Glyph. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Outline_Embolden( FT_Outline* outline,
|
||||
FT_Pos strength );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_EmboldenXY */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Embolden an outline. The new outline will be `xstrength' pixels */
|
||||
/* wider and `ystrength' pixels higher. Otherwise, it is similar to */
|
||||
/* @FT_Outline_Embolden, which uses the same strength in both */
|
||||
/* directions. */
|
||||
/* */
|
||||
/* <Since> */
|
||||
/* 2.4.10 */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Outline_EmboldenXY( FT_Outline* outline,
|
||||
FT_Pos xstrength,
|
||||
FT_Pos ystrength );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Reverse */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Reverse the drawing direction of an outline. This is used to */
|
||||
/* ensure consistent fill conventions for mirrored glyphs. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* outline :: A pointer to the target outline descriptor. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This function toggles the bit flag @FT_OUTLINE_REVERSE_FILL in */
|
||||
/* the outline's `flags' field. */
|
||||
/* */
|
||||
/* It shouldn't be used by a normal client application, unless it */
|
||||
/* knows what it is doing. */
|
||||
/* */
|
||||
FT_EXPORT( void )
|
||||
FT_Outline_Reverse( FT_Outline* outline );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Get_Bitmap */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Render an outline within a bitmap. The outline's image is simply */
|
||||
/* OR-ed to the target bitmap. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle to a FreeType library object. */
|
||||
/* */
|
||||
/* outline :: A pointer to the source outline descriptor. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* abitmap :: A pointer to the target bitmap descriptor. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This function does NOT CREATE the bitmap, it only renders an */
|
||||
/* outline image within the one you pass to it! Consequently, the */
|
||||
/* various fields in `abitmap' should be set accordingly. */
|
||||
/* */
|
||||
/* It will use the raster corresponding to the default glyph format. */
|
||||
/* */
|
||||
/* The value of the `num_grays' field in `abitmap' is ignored. If */
|
||||
/* you select the gray-level rasterizer, and you want less than 256 */
|
||||
/* gray levels, you have to use @FT_Outline_Render directly. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Outline_Get_Bitmap( FT_Library library,
|
||||
FT_Outline* outline,
|
||||
const FT_Bitmap *abitmap );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Outline_Render */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Render an outline within a bitmap using the current scan-convert. */
|
||||
/* This function uses an @FT_Raster_Params structure as an argument, */
|
||||
/* allowing advanced features like direct composition, translucency, */
|
||||
/* etc. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle to a FreeType library object. */
|
||||
/* */
|
||||
/* outline :: A pointer to the source outline descriptor. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* params :: A pointer to an @FT_Raster_Params structure used to */
|
||||
/* describe the rendering operation. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* You should know what you are doing and how @FT_Raster_Params works */
|
||||
/* to use this function. */
|
||||
/* */
|
||||
/* The field `params.source' will be set to `outline' before the scan */
|
||||
/* converter is called, which means that the value you give to it is */
|
||||
/* actually ignored. */
|
||||
/* */
|
||||
/* The gray-level rasterizer always uses 256 gray levels. If you */
|
||||
/* want less gray levels, you have to provide your own span callback. */
|
||||
/* See the @FT_RASTER_FLAG_DIRECT value of the `flags' field in the */
|
||||
/* @FT_Raster_Params structure for more details. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Outline_Render( FT_Library library,
|
||||
FT_Outline* outline,
|
||||
FT_Raster_Params* params );
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @enum:
|
||||
* FT_Orientation
|
||||
*
|
||||
* @description:
|
||||
* A list of values used to describe an outline's contour orientation.
|
||||
*
|
||||
* The TrueType and PostScript specifications use different conventions
|
||||
* to determine whether outline contours should be filled or unfilled.
|
||||
*
|
||||
* @values:
|
||||
* FT_ORIENTATION_TRUETYPE ::
|
||||
* According to the TrueType specification, clockwise contours must
|
||||
* be filled, and counter-clockwise ones must be unfilled.
|
||||
*
|
||||
* FT_ORIENTATION_POSTSCRIPT ::
|
||||
* According to the PostScript specification, counter-clockwise contours
|
||||
* must be filled, and clockwise ones must be unfilled.
|
||||
*
|
||||
* FT_ORIENTATION_FILL_RIGHT ::
|
||||
* This is identical to @FT_ORIENTATION_TRUETYPE, but is used to
|
||||
* remember that in TrueType, everything that is to the right of
|
||||
* the drawing direction of a contour must be filled.
|
||||
*
|
||||
* FT_ORIENTATION_FILL_LEFT ::
|
||||
* This is identical to @FT_ORIENTATION_POSTSCRIPT, but is used to
|
||||
* remember that in PostScript, everything that is to the left of
|
||||
* the drawing direction of a contour must be filled.
|
||||
*
|
||||
* FT_ORIENTATION_NONE ::
|
||||
* The orientation cannot be determined. That is, different parts of
|
||||
* the glyph have different orientation.
|
||||
*
|
||||
*/
|
||||
typedef enum FT_Orientation_
|
||||
{
|
||||
FT_ORIENTATION_TRUETYPE = 0,
|
||||
FT_ORIENTATION_POSTSCRIPT = 1,
|
||||
FT_ORIENTATION_FILL_RIGHT = FT_ORIENTATION_TRUETYPE,
|
||||
FT_ORIENTATION_FILL_LEFT = FT_ORIENTATION_POSTSCRIPT,
|
||||
FT_ORIENTATION_NONE
|
||||
|
||||
} FT_Orientation;
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Outline_Get_Orientation
|
||||
*
|
||||
* @description:
|
||||
* This function analyzes a glyph outline and tries to compute its
|
||||
* fill orientation (see @FT_Orientation). This is done by integrating
|
||||
* the total area covered by the outline. The positive integral
|
||||
* corresponds to the clockwise orientation and @FT_ORIENTATION_POSTSCRIPT
|
||||
* is returned. The negative integral corresponds to the counter-clockwise
|
||||
* orientation and @FT_ORIENTATION_TRUETYPE is returned.
|
||||
*
|
||||
* Note that this will return @FT_ORIENTATION_TRUETYPE for empty
|
||||
* outlines.
|
||||
*
|
||||
* @input:
|
||||
* outline ::
|
||||
* A handle to the source outline.
|
||||
*
|
||||
* @return:
|
||||
* The orientation.
|
||||
*
|
||||
*/
|
||||
FT_EXPORT( FT_Orientation )
|
||||
FT_Outline_Get_Orientation( FT_Outline* outline );
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTOUTLN_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
|
||||
|
||||
/* Local Variables: */
|
||||
/* coding: utf-8 */
|
||||
/* End: */
|
||||
@@ -0,0 +1,205 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftparams.h */
|
||||
/* */
|
||||
/* FreeType API for possible FT_Parameter tags (specification only). */
|
||||
/* */
|
||||
/* Copyright 2017-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTPARAMS_H_
|
||||
#define FTPARAMS_H_
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#ifdef FREETYPE_H
|
||||
#error "freetype.h of FreeType 1 has been loaded!"
|
||||
#error "Please fix the directory search order for header files"
|
||||
#error "so that freetype.h of FreeType 2 is found first."
|
||||
#endif
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @section:
|
||||
* parameter_tags
|
||||
*
|
||||
* @title:
|
||||
* Parameter Tags
|
||||
*
|
||||
* @abstract:
|
||||
* Macros for driver property and font loading parameter tags.
|
||||
*
|
||||
* @description:
|
||||
* This section contains macros for the @FT_Parameter structure that are
|
||||
* used with various functions to activate some special functionality or
|
||||
* different behaviour of various components of FreeType.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
*
|
||||
* @constant:
|
||||
* FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_FAMILY
|
||||
*
|
||||
* @description:
|
||||
* A tag for @FT_Parameter to make @FT_Open_Face ignore typographic
|
||||
* family names in the `name' table (introduced in OpenType version
|
||||
* 1.4). Use this for backward compatibility with legacy systems that
|
||||
* have a four-faces-per-family restriction.
|
||||
*
|
||||
* @since:
|
||||
* 2.8
|
||||
*
|
||||
*/
|
||||
#define FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_FAMILY \
|
||||
FT_MAKE_TAG( 'i', 'g', 'p', 'f' )
|
||||
|
||||
|
||||
/* this constant is deprecated */
|
||||
#define FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY \
|
||||
FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_FAMILY
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
*
|
||||
* @constant:
|
||||
* FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_SUBFAMILY
|
||||
*
|
||||
* @description:
|
||||
* A tag for @FT_Parameter to make @FT_Open_Face ignore typographic
|
||||
* subfamily names in the `name' table (introduced in OpenType version
|
||||
* 1.4). Use this for backward compatibility with legacy systems that
|
||||
* have a four-faces-per-family restriction.
|
||||
*
|
||||
* @since:
|
||||
* 2.8
|
||||
*
|
||||
*/
|
||||
#define FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_SUBFAMILY \
|
||||
FT_MAKE_TAG( 'i', 'g', 'p', 's' )
|
||||
|
||||
|
||||
/* this constant is deprecated */
|
||||
#define FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY \
|
||||
FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_SUBFAMILY
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
*
|
||||
* @constant:
|
||||
* FT_PARAM_TAG_INCREMENTAL
|
||||
*
|
||||
* @description:
|
||||
* An @FT_Parameter tag to be used with @FT_Open_Face to indicate
|
||||
* incremental glyph loading.
|
||||
*
|
||||
*/
|
||||
#define FT_PARAM_TAG_INCREMENTAL \
|
||||
FT_MAKE_TAG( 'i', 'n', 'c', 'r' )
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @constant:
|
||||
* FT_PARAM_TAG_LCD_FILTER_WEIGHTS
|
||||
*
|
||||
* @description:
|
||||
* An @FT_Parameter tag to be used with @FT_Face_Properties. The
|
||||
* corresponding argument specifies the five LCD filter weights for a
|
||||
* given face (if using @FT_LOAD_TARGET_LCD, for example), overriding
|
||||
* the global default values or the values set up with
|
||||
* @FT_Library_SetLcdFilterWeights.
|
||||
*
|
||||
* @since:
|
||||
* 2.8
|
||||
*
|
||||
*/
|
||||
#define FT_PARAM_TAG_LCD_FILTER_WEIGHTS \
|
||||
FT_MAKE_TAG( 'l', 'c', 'd', 'f' )
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @constant:
|
||||
* FT_PARAM_TAG_RANDOM_SEED
|
||||
*
|
||||
* @description:
|
||||
* An @FT_Parameter tag to be used with @FT_Face_Properties. The
|
||||
* corresponding 32bit signed integer argument overrides the font
|
||||
* driver's random seed value with a face-specific one; see
|
||||
* @random-seed.
|
||||
*
|
||||
* @since:
|
||||
* 2.8
|
||||
*
|
||||
*/
|
||||
#define FT_PARAM_TAG_RANDOM_SEED \
|
||||
FT_MAKE_TAG( 's', 'e', 'e', 'd' )
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @constant:
|
||||
* FT_PARAM_TAG_STEM_DARKENING
|
||||
*
|
||||
* @description:
|
||||
* An @FT_Parameter tag to be used with @FT_Face_Properties. The
|
||||
* corresponding Boolean argument specifies whether to apply stem
|
||||
* darkening, overriding the global default values or the values set up
|
||||
* with @FT_Property_Set (see @no-stem-darkening).
|
||||
*
|
||||
* This is a passive setting that only takes effect if the font driver
|
||||
* or autohinter honors it, which the CFF, Type~1, and CID drivers
|
||||
* always do, but the autohinter only in `light' hinting mode (as of
|
||||
* version 2.9).
|
||||
*
|
||||
* @since:
|
||||
* 2.8
|
||||
*
|
||||
*/
|
||||
#define FT_PARAM_TAG_STEM_DARKENING \
|
||||
FT_MAKE_TAG( 'd', 'a', 'r', 'k' )
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
*
|
||||
* @constant:
|
||||
* FT_PARAM_TAG_UNPATENTED_HINTING
|
||||
*
|
||||
* @description:
|
||||
* Deprecated, no effect.
|
||||
*
|
||||
* Previously: A constant used as the tag of an @FT_Parameter structure to
|
||||
* indicate that unpatented methods only should be used by the TrueType
|
||||
* bytecode interpreter for a typeface opened by @FT_Open_Face.
|
||||
*
|
||||
*/
|
||||
#define FT_PARAM_TAG_UNPATENTED_HINTING \
|
||||
FT_MAKE_TAG( 'u', 'n', 'p', 'a' )
|
||||
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
|
||||
#endif /* FTPARAMS_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,172 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftpfr.h */
|
||||
/* */
|
||||
/* FreeType API for accessing PFR-specific data (specification only). */
|
||||
/* */
|
||||
/* Copyright 2002-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTPFR_H_
|
||||
#define FTPFR_H_
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#ifdef FREETYPE_H
|
||||
#error "freetype.h of FreeType 1 has been loaded!"
|
||||
#error "Please fix the directory search order for header files"
|
||||
#error "so that freetype.h of FreeType 2 is found first."
|
||||
#endif
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* pfr_fonts */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* PFR Fonts */
|
||||
/* */
|
||||
/* <Abstract> */
|
||||
/* PFR/TrueDoc specific API. */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This section contains the declaration of PFR-specific functions. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Get_PFR_Metrics
|
||||
*
|
||||
* @description:
|
||||
* Return the outline and metrics resolutions of a given PFR face.
|
||||
*
|
||||
* @input:
|
||||
* face :: Handle to the input face. It can be a non-PFR face.
|
||||
*
|
||||
* @output:
|
||||
* aoutline_resolution ::
|
||||
* Outline resolution. This is equivalent to `face->units_per_EM'
|
||||
* for non-PFR fonts. Optional (parameter can be NULL).
|
||||
*
|
||||
* ametrics_resolution ::
|
||||
* Metrics resolution. This is equivalent to `outline_resolution'
|
||||
* for non-PFR fonts. Optional (parameter can be NULL).
|
||||
*
|
||||
* ametrics_x_scale ::
|
||||
* A 16.16 fixed-point number used to scale distance expressed
|
||||
* in metrics units to device subpixels. This is equivalent to
|
||||
* `face->size->x_scale', but for metrics only. Optional (parameter
|
||||
* can be NULL).
|
||||
*
|
||||
* ametrics_y_scale ::
|
||||
* Same as `ametrics_x_scale' but for the vertical direction.
|
||||
* optional (parameter can be NULL).
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* If the input face is not a PFR, this function will return an error.
|
||||
* However, in all cases, it will return valid values.
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Get_PFR_Metrics( FT_Face face,
|
||||
FT_UInt *aoutline_resolution,
|
||||
FT_UInt *ametrics_resolution,
|
||||
FT_Fixed *ametrics_x_scale,
|
||||
FT_Fixed *ametrics_y_scale );
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Get_PFR_Kerning
|
||||
*
|
||||
* @description:
|
||||
* Return the kerning pair corresponding to two glyphs in a PFR face.
|
||||
* The distance is expressed in metrics units, unlike the result of
|
||||
* @FT_Get_Kerning.
|
||||
*
|
||||
* @input:
|
||||
* face :: A handle to the input face.
|
||||
*
|
||||
* left :: Index of the left glyph.
|
||||
*
|
||||
* right :: Index of the right glyph.
|
||||
*
|
||||
* @output:
|
||||
* avector :: A kerning vector.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* This function always return distances in original PFR metrics
|
||||
* units. This is unlike @FT_Get_Kerning with the @FT_KERNING_UNSCALED
|
||||
* mode, which always returns distances converted to outline units.
|
||||
*
|
||||
* You can use the value of the `x_scale' and `y_scale' parameters
|
||||
* returned by @FT_Get_PFR_Metrics to scale these to device subpixels.
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Get_PFR_Kerning( FT_Face face,
|
||||
FT_UInt left,
|
||||
FT_UInt right,
|
||||
FT_Vector *avector );
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Get_PFR_Advance
|
||||
*
|
||||
* @description:
|
||||
* Return a given glyph advance, expressed in original metrics units,
|
||||
* from a PFR font.
|
||||
*
|
||||
* @input:
|
||||
* face :: A handle to the input face.
|
||||
*
|
||||
* gindex :: The glyph index.
|
||||
*
|
||||
* @output:
|
||||
* aadvance :: The glyph advance in metrics units.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* You can use the `x_scale' or `y_scale' results of @FT_Get_PFR_Metrics
|
||||
* to convert the advance to device subpixels (i.e., 1/64th of pixels).
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Get_PFR_Advance( FT_Face face,
|
||||
FT_UInt gindex,
|
||||
FT_Pos *aadvance );
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTPFR_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,233 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftrender.h */
|
||||
/* */
|
||||
/* FreeType renderer modules public interface (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTRENDER_H_
|
||||
#define FTRENDER_H_
|
||||
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_MODULE_H
|
||||
#include FT_GLYPH_H
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* module_management */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/* create a new glyph object */
|
||||
typedef FT_Error
|
||||
(*FT_Glyph_InitFunc)( FT_Glyph glyph,
|
||||
FT_GlyphSlot slot );
|
||||
|
||||
/* destroys a given glyph object */
|
||||
typedef void
|
||||
(*FT_Glyph_DoneFunc)( FT_Glyph glyph );
|
||||
|
||||
typedef void
|
||||
(*FT_Glyph_TransformFunc)( FT_Glyph glyph,
|
||||
const FT_Matrix* matrix,
|
||||
const FT_Vector* delta );
|
||||
|
||||
typedef void
|
||||
(*FT_Glyph_GetBBoxFunc)( FT_Glyph glyph,
|
||||
FT_BBox* abbox );
|
||||
|
||||
typedef FT_Error
|
||||
(*FT_Glyph_CopyFunc)( FT_Glyph source,
|
||||
FT_Glyph target );
|
||||
|
||||
typedef FT_Error
|
||||
(*FT_Glyph_PrepareFunc)( FT_Glyph glyph,
|
||||
FT_GlyphSlot slot );
|
||||
|
||||
/* deprecated */
|
||||
#define FT_Glyph_Init_Func FT_Glyph_InitFunc
|
||||
#define FT_Glyph_Done_Func FT_Glyph_DoneFunc
|
||||
#define FT_Glyph_Transform_Func FT_Glyph_TransformFunc
|
||||
#define FT_Glyph_BBox_Func FT_Glyph_GetBBoxFunc
|
||||
#define FT_Glyph_Copy_Func FT_Glyph_CopyFunc
|
||||
#define FT_Glyph_Prepare_Func FT_Glyph_PrepareFunc
|
||||
|
||||
|
||||
struct FT_Glyph_Class_
|
||||
{
|
||||
FT_Long glyph_size;
|
||||
FT_Glyph_Format glyph_format;
|
||||
|
||||
FT_Glyph_InitFunc glyph_init;
|
||||
FT_Glyph_DoneFunc glyph_done;
|
||||
FT_Glyph_CopyFunc glyph_copy;
|
||||
FT_Glyph_TransformFunc glyph_transform;
|
||||
FT_Glyph_GetBBoxFunc glyph_bbox;
|
||||
FT_Glyph_PrepareFunc glyph_prepare;
|
||||
};
|
||||
|
||||
|
||||
typedef FT_Error
|
||||
(*FT_Renderer_RenderFunc)( FT_Renderer renderer,
|
||||
FT_GlyphSlot slot,
|
||||
FT_Render_Mode mode,
|
||||
const FT_Vector* origin );
|
||||
|
||||
typedef FT_Error
|
||||
(*FT_Renderer_TransformFunc)( FT_Renderer renderer,
|
||||
FT_GlyphSlot slot,
|
||||
const FT_Matrix* matrix,
|
||||
const FT_Vector* delta );
|
||||
|
||||
|
||||
typedef void
|
||||
(*FT_Renderer_GetCBoxFunc)( FT_Renderer renderer,
|
||||
FT_GlyphSlot slot,
|
||||
FT_BBox* cbox );
|
||||
|
||||
|
||||
typedef FT_Error
|
||||
(*FT_Renderer_SetModeFunc)( FT_Renderer renderer,
|
||||
FT_ULong mode_tag,
|
||||
FT_Pointer mode_ptr );
|
||||
|
||||
/* deprecated identifiers */
|
||||
#define FTRenderer_render FT_Renderer_RenderFunc
|
||||
#define FTRenderer_transform FT_Renderer_TransformFunc
|
||||
#define FTRenderer_getCBox FT_Renderer_GetCBoxFunc
|
||||
#define FTRenderer_setMode FT_Renderer_SetModeFunc
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_Renderer_Class */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The renderer module class descriptor. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* root :: The root @FT_Module_Class fields. */
|
||||
/* */
|
||||
/* glyph_format :: The glyph image format this renderer handles. */
|
||||
/* */
|
||||
/* render_glyph :: A method used to render the image that is in a */
|
||||
/* given glyph slot into a bitmap. */
|
||||
/* */
|
||||
/* transform_glyph :: A method used to transform the image that is in */
|
||||
/* a given glyph slot. */
|
||||
/* */
|
||||
/* get_glyph_cbox :: A method used to access the glyph's cbox. */
|
||||
/* */
|
||||
/* set_mode :: A method used to pass additional parameters. */
|
||||
/* */
|
||||
/* raster_class :: For @FT_GLYPH_FORMAT_OUTLINE renderers only. */
|
||||
/* This is a pointer to its raster's class. */
|
||||
/* */
|
||||
typedef struct FT_Renderer_Class_
|
||||
{
|
||||
FT_Module_Class root;
|
||||
|
||||
FT_Glyph_Format glyph_format;
|
||||
|
||||
FT_Renderer_RenderFunc render_glyph;
|
||||
FT_Renderer_TransformFunc transform_glyph;
|
||||
FT_Renderer_GetCBoxFunc get_glyph_cbox;
|
||||
FT_Renderer_SetModeFunc set_mode;
|
||||
|
||||
FT_Raster_Funcs* raster_class;
|
||||
|
||||
} FT_Renderer_Class;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_Renderer */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Retrieve the current renderer for a given glyph format. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* library :: A handle to the library object. */
|
||||
/* */
|
||||
/* format :: The glyph format. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* A renderer handle. 0~if none found. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* An error will be returned if a module already exists by that name, */
|
||||
/* or if the module requires a version of FreeType that is too great. */
|
||||
/* */
|
||||
/* To add a new renderer, simply use @FT_Add_Module. To retrieve a */
|
||||
/* renderer by its name, use @FT_Get_Module. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Renderer )
|
||||
FT_Get_Renderer( FT_Library library,
|
||||
FT_Glyph_Format format );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Set_Renderer */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Set the current renderer to use, and set additional mode. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* library :: A handle to the library object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* renderer :: A handle to the renderer object. */
|
||||
/* */
|
||||
/* num_params :: The number of additional parameters. */
|
||||
/* */
|
||||
/* parameters :: Additional parameters. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* In case of success, the renderer will be used to convert glyph */
|
||||
/* images in the renderer's known format into bitmaps. */
|
||||
/* */
|
||||
/* This doesn't change the current renderer for other formats. */
|
||||
/* */
|
||||
/* Currently, no FreeType renderer module uses `parameters'; you */
|
||||
/* should thus always pass NULL as the value. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Set_Renderer( FT_Library library,
|
||||
FT_Renderer renderer,
|
||||
FT_UInt num_params,
|
||||
FT_Parameter* parameters );
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTRENDER_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,159 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftsizes.h */
|
||||
/* */
|
||||
/* FreeType size objects management (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Typical application would normally not need to use these functions. */
|
||||
/* However, they have been placed in a public API for the rare cases */
|
||||
/* where they are needed. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTSIZES_H_
|
||||
#define FTSIZES_H_
|
||||
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#ifdef FREETYPE_H
|
||||
#error "freetype.h of FreeType 1 has been loaded!"
|
||||
#error "Please fix the directory search order for header files"
|
||||
#error "so that freetype.h of FreeType 2 is found first."
|
||||
#endif
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* sizes_management */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* Size Management */
|
||||
/* */
|
||||
/* <Abstract> */
|
||||
/* Managing multiple sizes per face. */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* When creating a new face object (e.g., with @FT_New_Face), an */
|
||||
/* @FT_Size object is automatically created and used to store all */
|
||||
/* pixel-size dependent information, available in the `face->size' */
|
||||
/* field. */
|
||||
/* */
|
||||
/* It is however possible to create more sizes for a given face, */
|
||||
/* mostly in order to manage several character pixel sizes of the */
|
||||
/* same font family and style. See @FT_New_Size and @FT_Done_Size. */
|
||||
/* */
|
||||
/* Note that @FT_Set_Pixel_Sizes and @FT_Set_Char_Size only */
|
||||
/* modify the contents of the current `active' size; you thus need */
|
||||
/* to use @FT_Activate_Size to change it. */
|
||||
/* */
|
||||
/* 99% of applications won't need the functions provided here, */
|
||||
/* especially if they use the caching sub-system, so be cautious */
|
||||
/* when using these. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_New_Size */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Create a new size object from a given face object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to a parent face object. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* asize :: A handle to a new size object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* You need to call @FT_Activate_Size in order to select the new size */
|
||||
/* for upcoming calls to @FT_Set_Pixel_Sizes, @FT_Set_Char_Size, */
|
||||
/* @FT_Load_Glyph, @FT_Load_Char, etc. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_New_Size( FT_Face face,
|
||||
FT_Size* size );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Done_Size */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Discard a given size object. Note that @FT_Done_Face */
|
||||
/* automatically discards all size objects allocated with */
|
||||
/* @FT_New_Size. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* size :: A handle to a target size object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Done_Size( FT_Size size );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Activate_Size */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Even though it is possible to create several size objects for a */
|
||||
/* given face (see @FT_New_Size for details), functions like */
|
||||
/* @FT_Load_Glyph or @FT_Load_Char only use the one that has been */
|
||||
/* activated last to determine the `current character pixel size'. */
|
||||
/* */
|
||||
/* This function can be used to `activate' a previously created size */
|
||||
/* object. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* size :: A handle to a target size object. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* If `face' is the size's parent face object, this function changes */
|
||||
/* the value of `face->size' to the input size handle. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Activate_Size( FT_Size size );
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTSIZES_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,253 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftsnames.h */
|
||||
/* */
|
||||
/* Simple interface to access SFNT `name' tables (which are used */
|
||||
/* to hold font names, copyright info, notices, etc.) (specification). */
|
||||
/* */
|
||||
/* This is _not_ used to retrieve glyph names! */
|
||||
/* */
|
||||
/* Copyright 1996-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTSNAMES_H_
|
||||
#define FTSNAMES_H_
|
||||
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_PARAMETER_TAGS_H
|
||||
|
||||
#ifdef FREETYPE_H
|
||||
#error "freetype.h of FreeType 1 has been loaded!"
|
||||
#error "Please fix the directory search order for header files"
|
||||
#error "so that freetype.h of FreeType 2 is found first."
|
||||
#endif
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* sfnt_names */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* SFNT Names */
|
||||
/* */
|
||||
/* <Abstract> */
|
||||
/* Access the names embedded in TrueType and OpenType files. */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The TrueType and OpenType specifications allow the inclusion of */
|
||||
/* a special names table (`name') in font files. This table contains */
|
||||
/* textual (and internationalized) information regarding the font, */
|
||||
/* like family name, copyright, version, etc. */
|
||||
/* */
|
||||
/* The definitions below are used to access them if available. */
|
||||
/* */
|
||||
/* Note that this has nothing to do with glyph names! */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_SfntName */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to model an SFNT `name' table entry. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* platform_id :: The platform ID for `string'. */
|
||||
/* See @TT_PLATFORM_XXX for possible values. */
|
||||
/* */
|
||||
/* encoding_id :: The encoding ID for `string'. */
|
||||
/* See @TT_APPLE_ID_XXX, @TT_MAC_ID_XXX, */
|
||||
/* @TT_ISO_ID_XXX, @TT_MS_ID_XXX, and @TT_ADOBE_ID_XXX */
|
||||
/* for possible values. */
|
||||
/* */
|
||||
/* language_id :: The language ID for `string'. */
|
||||
/* See @TT_MAC_LANGID_XXX and @TT_MS_LANGID_XXX for */
|
||||
/* possible values. */
|
||||
/* */
|
||||
/* Registered OpenType values for `language_id' are */
|
||||
/* always smaller than 0x8000; values equal or larger */
|
||||
/* than 0x8000 usually indicate a language tag string */
|
||||
/* (introduced in OpenType version 1.6). Use function */
|
||||
/* @FT_Get_Sfnt_LangTag with `language_id' as its */
|
||||
/* argument to retrieve the associated language tag. */
|
||||
/* */
|
||||
/* name_id :: An identifier for `string'. */
|
||||
/* See @TT_NAME_ID_XXX for possible values. */
|
||||
/* */
|
||||
/* string :: The `name' string. Note that its format differs */
|
||||
/* depending on the (platform,encoding) pair, being */
|
||||
/* either a string of bytes (without a terminating */
|
||||
/* NULL byte) or containing UTF-16BE entities. */
|
||||
/* */
|
||||
/* string_len :: The length of `string' in bytes. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* Please refer to the TrueType or OpenType specification for more */
|
||||
/* details. */
|
||||
/* */
|
||||
typedef struct FT_SfntName_
|
||||
{
|
||||
FT_UShort platform_id;
|
||||
FT_UShort encoding_id;
|
||||
FT_UShort language_id;
|
||||
FT_UShort name_id;
|
||||
|
||||
FT_Byte* string; /* this string is *not* null-terminated! */
|
||||
FT_UInt string_len; /* in bytes */
|
||||
|
||||
} FT_SfntName;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_Sfnt_Name_Count */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Retrieve the number of name strings in the SFNT `name' table. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the source face. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The number of strings in the `name' table. */
|
||||
/* */
|
||||
FT_EXPORT( FT_UInt )
|
||||
FT_Get_Sfnt_Name_Count( FT_Face face );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_Sfnt_Name */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Retrieve a string of the SFNT `name' table for a given index. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the source face. */
|
||||
/* */
|
||||
/* idx :: The index of the `name' string. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* aname :: The indexed @FT_SfntName structure. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The `string' array returned in the `aname' structure is not */
|
||||
/* null-terminated. Note that you don't have to deallocate `string' */
|
||||
/* by yourself; FreeType takes care of it if you call @FT_Done_Face. */
|
||||
/* */
|
||||
/* Use @FT_Get_Sfnt_Name_Count to get the total number of available */
|
||||
/* `name' table entries, then do a loop until you get the right */
|
||||
/* platform, encoding, and name ID. */
|
||||
/* */
|
||||
/* `name' table format~1 entries can use language tags also, see */
|
||||
/* @FT_Get_Sfnt_LangTag. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Get_Sfnt_Name( FT_Face face,
|
||||
FT_UInt idx,
|
||||
FT_SfntName *aname );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_SfntLangTag */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure to model a language tag entry from an SFNT `name' */
|
||||
/* table. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* string :: The language tag string, encoded in UTF-16BE */
|
||||
/* (without trailing NULL bytes). */
|
||||
/* */
|
||||
/* string_len :: The length of `string' in *bytes*. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* Please refer to the TrueType or OpenType specification for more */
|
||||
/* details. */
|
||||
/* */
|
||||
/* <Since> */
|
||||
/* 2.8 */
|
||||
/* */
|
||||
typedef struct FT_SfntLangTag_
|
||||
{
|
||||
FT_Byte* string; /* this string is *not* null-terminated! */
|
||||
FT_UInt string_len; /* in bytes */
|
||||
|
||||
} FT_SfntLangTag;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_Sfnt_LangTag */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Retrieve the language tag associated with a language ID of an SFNT */
|
||||
/* `name' table entry. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the source face. */
|
||||
/* */
|
||||
/* langID :: The language ID, as returned by @FT_Get_Sfnt_Name. */
|
||||
/* This is always a value larger than 0x8000. */
|
||||
/* */
|
||||
/* <Output> */
|
||||
/* alangTag :: The language tag associated with the `name' table */
|
||||
/* entry's language ID. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* FreeType error code. 0~means success. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The `string' array returned in the `alangTag' structure is not */
|
||||
/* null-terminated. Note that you don't have to deallocate `string' */
|
||||
/* by yourself; FreeType takes care of it if you call @FT_Done_Face. */
|
||||
/* */
|
||||
/* Only `name' table format~1 supports language tags. For format~0 */
|
||||
/* tables, this function always returns FT_Err_Invalid_Table. For */
|
||||
/* invalid format~1 language ID values, FT_Err_Invalid_Argument is */
|
||||
/* returned. */
|
||||
/* */
|
||||
/* <Since> */
|
||||
/* 2.8 */
|
||||
/* */
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Get_Sfnt_LangTag( FT_Face face,
|
||||
FT_UInt langID,
|
||||
FT_SfntLangTag *alangTag );
|
||||
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTSNAMES_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,785 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftstroke.h */
|
||||
/* */
|
||||
/* FreeType path stroker (specification). */
|
||||
/* */
|
||||
/* Copyright 2002-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTSTROKE_H_
|
||||
#define FTSTROKE_H_
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_OUTLINE_H
|
||||
#include FT_GLYPH_H
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/************************************************************************
|
||||
*
|
||||
* @section:
|
||||
* glyph_stroker
|
||||
*
|
||||
* @title:
|
||||
* Glyph Stroker
|
||||
*
|
||||
* @abstract:
|
||||
* Generating bordered and stroked glyphs.
|
||||
*
|
||||
* @description:
|
||||
* This component generates stroked outlines of a given vectorial
|
||||
* glyph. It also allows you to retrieve the `outside' and/or the
|
||||
* `inside' borders of the stroke.
|
||||
*
|
||||
* This can be useful to generate `bordered' glyph, i.e., glyphs
|
||||
* displayed with a coloured (and anti-aliased) border around their
|
||||
* shape.
|
||||
*
|
||||
* @order:
|
||||
* FT_Stroker
|
||||
*
|
||||
* FT_Stroker_LineJoin
|
||||
* FT_Stroker_LineCap
|
||||
* FT_StrokerBorder
|
||||
*
|
||||
* FT_Outline_GetInsideBorder
|
||||
* FT_Outline_GetOutsideBorder
|
||||
*
|
||||
* FT_Glyph_Stroke
|
||||
* FT_Glyph_StrokeBorder
|
||||
*
|
||||
* FT_Stroker_New
|
||||
* FT_Stroker_Set
|
||||
* FT_Stroker_Rewind
|
||||
* FT_Stroker_ParseOutline
|
||||
* FT_Stroker_Done
|
||||
*
|
||||
* FT_Stroker_BeginSubPath
|
||||
* FT_Stroker_EndSubPath
|
||||
*
|
||||
* FT_Stroker_LineTo
|
||||
* FT_Stroker_ConicTo
|
||||
* FT_Stroker_CubicTo
|
||||
*
|
||||
* FT_Stroker_GetBorderCounts
|
||||
* FT_Stroker_ExportBorder
|
||||
* FT_Stroker_GetCounts
|
||||
* FT_Stroker_Export
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**************************************************************
|
||||
*
|
||||
* @type:
|
||||
* FT_Stroker
|
||||
*
|
||||
* @description:
|
||||
* Opaque handle to a path stroker object.
|
||||
*/
|
||||
typedef struct FT_StrokerRec_* FT_Stroker;
|
||||
|
||||
|
||||
/**************************************************************
|
||||
*
|
||||
* @enum:
|
||||
* FT_Stroker_LineJoin
|
||||
*
|
||||
* @description:
|
||||
* These values determine how two joining lines are rendered
|
||||
* in a stroker.
|
||||
*
|
||||
* @values:
|
||||
* FT_STROKER_LINEJOIN_ROUND ::
|
||||
* Used to render rounded line joins. Circular arcs are used
|
||||
* to join two lines smoothly.
|
||||
*
|
||||
* FT_STROKER_LINEJOIN_BEVEL ::
|
||||
* Used to render beveled line joins. The outer corner of
|
||||
* the joined lines is filled by enclosing the triangular
|
||||
* region of the corner with a straight line between the
|
||||
* outer corners of each stroke.
|
||||
*
|
||||
* FT_STROKER_LINEJOIN_MITER_FIXED ::
|
||||
* Used to render mitered line joins, with fixed bevels if the
|
||||
* miter limit is exceeded. The outer edges of the strokes
|
||||
* for the two segments are extended until they meet at an
|
||||
* angle. If the segments meet at too sharp an angle (such
|
||||
* that the miter would extend from the intersection of the
|
||||
* segments a distance greater than the product of the miter
|
||||
* limit value and the border radius), then a bevel join (see
|
||||
* above) is used instead. This prevents long spikes being
|
||||
* created. FT_STROKER_LINEJOIN_MITER_FIXED generates a miter
|
||||
* line join as used in PostScript and PDF.
|
||||
*
|
||||
* FT_STROKER_LINEJOIN_MITER_VARIABLE ::
|
||||
* FT_STROKER_LINEJOIN_MITER ::
|
||||
* Used to render mitered line joins, with variable bevels if
|
||||
* the miter limit is exceeded. The intersection of the
|
||||
* strokes is clipped at a line perpendicular to the bisector
|
||||
* of the angle between the strokes, at the distance from the
|
||||
* intersection of the segments equal to the product of the
|
||||
* miter limit value and the border radius. This prevents
|
||||
* long spikes being created.
|
||||
* FT_STROKER_LINEJOIN_MITER_VARIABLE generates a mitered line
|
||||
* join as used in XPS. FT_STROKER_LINEJOIN_MITER is an alias
|
||||
* for FT_STROKER_LINEJOIN_MITER_VARIABLE, retained for
|
||||
* backward compatibility.
|
||||
*/
|
||||
typedef enum FT_Stroker_LineJoin_
|
||||
{
|
||||
FT_STROKER_LINEJOIN_ROUND = 0,
|
||||
FT_STROKER_LINEJOIN_BEVEL = 1,
|
||||
FT_STROKER_LINEJOIN_MITER_VARIABLE = 2,
|
||||
FT_STROKER_LINEJOIN_MITER = FT_STROKER_LINEJOIN_MITER_VARIABLE,
|
||||
FT_STROKER_LINEJOIN_MITER_FIXED = 3
|
||||
|
||||
} FT_Stroker_LineJoin;
|
||||
|
||||
|
||||
/**************************************************************
|
||||
*
|
||||
* @enum:
|
||||
* FT_Stroker_LineCap
|
||||
*
|
||||
* @description:
|
||||
* These values determine how the end of opened sub-paths are
|
||||
* rendered in a stroke.
|
||||
*
|
||||
* @values:
|
||||
* FT_STROKER_LINECAP_BUTT ::
|
||||
* The end of lines is rendered as a full stop on the last
|
||||
* point itself.
|
||||
*
|
||||
* FT_STROKER_LINECAP_ROUND ::
|
||||
* The end of lines is rendered as a half-circle around the
|
||||
* last point.
|
||||
*
|
||||
* FT_STROKER_LINECAP_SQUARE ::
|
||||
* The end of lines is rendered as a square around the
|
||||
* last point.
|
||||
*/
|
||||
typedef enum FT_Stroker_LineCap_
|
||||
{
|
||||
FT_STROKER_LINECAP_BUTT = 0,
|
||||
FT_STROKER_LINECAP_ROUND,
|
||||
FT_STROKER_LINECAP_SQUARE
|
||||
|
||||
} FT_Stroker_LineCap;
|
||||
|
||||
|
||||
/**************************************************************
|
||||
*
|
||||
* @enum:
|
||||
* FT_StrokerBorder
|
||||
*
|
||||
* @description:
|
||||
* These values are used to select a given stroke border
|
||||
* in @FT_Stroker_GetBorderCounts and @FT_Stroker_ExportBorder.
|
||||
*
|
||||
* @values:
|
||||
* FT_STROKER_BORDER_LEFT ::
|
||||
* Select the left border, relative to the drawing direction.
|
||||
*
|
||||
* FT_STROKER_BORDER_RIGHT ::
|
||||
* Select the right border, relative to the drawing direction.
|
||||
*
|
||||
* @note:
|
||||
* Applications are generally interested in the `inside' and `outside'
|
||||
* borders. However, there is no direct mapping between these and the
|
||||
* `left' and `right' ones, since this really depends on the glyph's
|
||||
* drawing orientation, which varies between font formats.
|
||||
*
|
||||
* You can however use @FT_Outline_GetInsideBorder and
|
||||
* @FT_Outline_GetOutsideBorder to get these.
|
||||
*/
|
||||
typedef enum FT_StrokerBorder_
|
||||
{
|
||||
FT_STROKER_BORDER_LEFT = 0,
|
||||
FT_STROKER_BORDER_RIGHT
|
||||
|
||||
} FT_StrokerBorder;
|
||||
|
||||
|
||||
/**************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Outline_GetInsideBorder
|
||||
*
|
||||
* @description:
|
||||
* Retrieve the @FT_StrokerBorder value corresponding to the
|
||||
* `inside' borders of a given outline.
|
||||
*
|
||||
* @input:
|
||||
* outline ::
|
||||
* The source outline handle.
|
||||
*
|
||||
* @return:
|
||||
* The border index. @FT_STROKER_BORDER_RIGHT for empty or invalid
|
||||
* outlines.
|
||||
*/
|
||||
FT_EXPORT( FT_StrokerBorder )
|
||||
FT_Outline_GetInsideBorder( FT_Outline* outline );
|
||||
|
||||
|
||||
/**************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Outline_GetOutsideBorder
|
||||
*
|
||||
* @description:
|
||||
* Retrieve the @FT_StrokerBorder value corresponding to the
|
||||
* `outside' borders of a given outline.
|
||||
*
|
||||
* @input:
|
||||
* outline ::
|
||||
* The source outline handle.
|
||||
*
|
||||
* @return:
|
||||
* The border index. @FT_STROKER_BORDER_LEFT for empty or invalid
|
||||
* outlines.
|
||||
*/
|
||||
FT_EXPORT( FT_StrokerBorder )
|
||||
FT_Outline_GetOutsideBorder( FT_Outline* outline );
|
||||
|
||||
|
||||
/**************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Stroker_New
|
||||
*
|
||||
* @description:
|
||||
* Create a new stroker object.
|
||||
*
|
||||
* @input:
|
||||
* library ::
|
||||
* FreeType library handle.
|
||||
*
|
||||
* @output:
|
||||
* astroker ::
|
||||
* A new stroker object handle. NULL in case of error.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Stroker_New( FT_Library library,
|
||||
FT_Stroker *astroker );
|
||||
|
||||
|
||||
/**************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Stroker_Set
|
||||
*
|
||||
* @description:
|
||||
* Reset a stroker object's attributes.
|
||||
*
|
||||
* @input:
|
||||
* stroker ::
|
||||
* The target stroker handle.
|
||||
*
|
||||
* radius ::
|
||||
* The border radius.
|
||||
*
|
||||
* line_cap ::
|
||||
* The line cap style.
|
||||
*
|
||||
* line_join ::
|
||||
* The line join style.
|
||||
*
|
||||
* miter_limit ::
|
||||
* The miter limit for the FT_STROKER_LINEJOIN_MITER_FIXED and
|
||||
* FT_STROKER_LINEJOIN_MITER_VARIABLE line join styles,
|
||||
* expressed as 16.16 fixed-point value.
|
||||
*
|
||||
* @note:
|
||||
* The radius is expressed in the same units as the outline
|
||||
* coordinates.
|
||||
*
|
||||
* This function calls @FT_Stroker_Rewind automatically.
|
||||
*/
|
||||
FT_EXPORT( void )
|
||||
FT_Stroker_Set( FT_Stroker stroker,
|
||||
FT_Fixed radius,
|
||||
FT_Stroker_LineCap line_cap,
|
||||
FT_Stroker_LineJoin line_join,
|
||||
FT_Fixed miter_limit );
|
||||
|
||||
|
||||
/**************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Stroker_Rewind
|
||||
*
|
||||
* @description:
|
||||
* Reset a stroker object without changing its attributes.
|
||||
* You should call this function before beginning a new
|
||||
* series of calls to @FT_Stroker_BeginSubPath or
|
||||
* @FT_Stroker_EndSubPath.
|
||||
*
|
||||
* @input:
|
||||
* stroker ::
|
||||
* The target stroker handle.
|
||||
*/
|
||||
FT_EXPORT( void )
|
||||
FT_Stroker_Rewind( FT_Stroker stroker );
|
||||
|
||||
|
||||
/**************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Stroker_ParseOutline
|
||||
*
|
||||
* @description:
|
||||
* A convenience function used to parse a whole outline with
|
||||
* the stroker. The resulting outline(s) can be retrieved
|
||||
* later by functions like @FT_Stroker_GetCounts and @FT_Stroker_Export.
|
||||
*
|
||||
* @input:
|
||||
* stroker ::
|
||||
* The target stroker handle.
|
||||
*
|
||||
* outline ::
|
||||
* The source outline.
|
||||
*
|
||||
* opened ::
|
||||
* A boolean. If~1, the outline is treated as an open path instead
|
||||
* of a closed one.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* If `opened' is~0 (the default), the outline is treated as a closed
|
||||
* path, and the stroker generates two distinct `border' outlines.
|
||||
*
|
||||
* If `opened' is~1, the outline is processed as an open path, and the
|
||||
* stroker generates a single `stroke' outline.
|
||||
*
|
||||
* This function calls @FT_Stroker_Rewind automatically.
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Stroker_ParseOutline( FT_Stroker stroker,
|
||||
FT_Outline* outline,
|
||||
FT_Bool opened );
|
||||
|
||||
|
||||
/**************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Stroker_BeginSubPath
|
||||
*
|
||||
* @description:
|
||||
* Start a new sub-path in the stroker.
|
||||
*
|
||||
* @input:
|
||||
* stroker ::
|
||||
* The target stroker handle.
|
||||
*
|
||||
* to ::
|
||||
* A pointer to the start vector.
|
||||
*
|
||||
* open ::
|
||||
* A boolean. If~1, the sub-path is treated as an open one.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* This function is useful when you need to stroke a path that is
|
||||
* not stored as an @FT_Outline object.
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Stroker_BeginSubPath( FT_Stroker stroker,
|
||||
FT_Vector* to,
|
||||
FT_Bool open );
|
||||
|
||||
|
||||
/**************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Stroker_EndSubPath
|
||||
*
|
||||
* @description:
|
||||
* Close the current sub-path in the stroker.
|
||||
*
|
||||
* @input:
|
||||
* stroker ::
|
||||
* The target stroker handle.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* You should call this function after @FT_Stroker_BeginSubPath.
|
||||
* If the subpath was not `opened', this function `draws' a
|
||||
* single line segment to the start position when needed.
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Stroker_EndSubPath( FT_Stroker stroker );
|
||||
|
||||
|
||||
/**************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Stroker_LineTo
|
||||
*
|
||||
* @description:
|
||||
* `Draw' a single line segment in the stroker's current sub-path,
|
||||
* from the last position.
|
||||
*
|
||||
* @input:
|
||||
* stroker ::
|
||||
* The target stroker handle.
|
||||
*
|
||||
* to ::
|
||||
* A pointer to the destination point.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* You should call this function between @FT_Stroker_BeginSubPath and
|
||||
* @FT_Stroker_EndSubPath.
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Stroker_LineTo( FT_Stroker stroker,
|
||||
FT_Vector* to );
|
||||
|
||||
|
||||
/**************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Stroker_ConicTo
|
||||
*
|
||||
* @description:
|
||||
* `Draw' a single quadratic Bezier in the stroker's current sub-path,
|
||||
* from the last position.
|
||||
*
|
||||
* @input:
|
||||
* stroker ::
|
||||
* The target stroker handle.
|
||||
*
|
||||
* control ::
|
||||
* A pointer to a Bezier control point.
|
||||
*
|
||||
* to ::
|
||||
* A pointer to the destination point.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* You should call this function between @FT_Stroker_BeginSubPath and
|
||||
* @FT_Stroker_EndSubPath.
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Stroker_ConicTo( FT_Stroker stroker,
|
||||
FT_Vector* control,
|
||||
FT_Vector* to );
|
||||
|
||||
|
||||
/**************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Stroker_CubicTo
|
||||
*
|
||||
* @description:
|
||||
* `Draw' a single cubic Bezier in the stroker's current sub-path,
|
||||
* from the last position.
|
||||
*
|
||||
* @input:
|
||||
* stroker ::
|
||||
* The target stroker handle.
|
||||
*
|
||||
* control1 ::
|
||||
* A pointer to the first Bezier control point.
|
||||
*
|
||||
* control2 ::
|
||||
* A pointer to second Bezier control point.
|
||||
*
|
||||
* to ::
|
||||
* A pointer to the destination point.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* You should call this function between @FT_Stroker_BeginSubPath and
|
||||
* @FT_Stroker_EndSubPath.
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Stroker_CubicTo( FT_Stroker stroker,
|
||||
FT_Vector* control1,
|
||||
FT_Vector* control2,
|
||||
FT_Vector* to );
|
||||
|
||||
|
||||
/**************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Stroker_GetBorderCounts
|
||||
*
|
||||
* @description:
|
||||
* Call this function once you have finished parsing your paths
|
||||
* with the stroker. It returns the number of points and
|
||||
* contours necessary to export one of the `border' or `stroke'
|
||||
* outlines generated by the stroker.
|
||||
*
|
||||
* @input:
|
||||
* stroker ::
|
||||
* The target stroker handle.
|
||||
*
|
||||
* border ::
|
||||
* The border index.
|
||||
*
|
||||
* @output:
|
||||
* anum_points ::
|
||||
* The number of points.
|
||||
*
|
||||
* anum_contours ::
|
||||
* The number of contours.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* When an outline, or a sub-path, is `closed', the stroker generates
|
||||
* two independent `border' outlines, named `left' and `right'.
|
||||
*
|
||||
* When the outline, or a sub-path, is `opened', the stroker merges
|
||||
* the `border' outlines with caps. The `left' border receives all
|
||||
* points, while the `right' border becomes empty.
|
||||
*
|
||||
* Use the function @FT_Stroker_GetCounts instead if you want to
|
||||
* retrieve the counts associated to both borders.
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Stroker_GetBorderCounts( FT_Stroker stroker,
|
||||
FT_StrokerBorder border,
|
||||
FT_UInt *anum_points,
|
||||
FT_UInt *anum_contours );
|
||||
|
||||
|
||||
/**************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Stroker_ExportBorder
|
||||
*
|
||||
* @description:
|
||||
* Call this function after @FT_Stroker_GetBorderCounts to
|
||||
* export the corresponding border to your own @FT_Outline
|
||||
* structure.
|
||||
*
|
||||
* Note that this function appends the border points and
|
||||
* contours to your outline, but does not try to resize its
|
||||
* arrays.
|
||||
*
|
||||
* @input:
|
||||
* stroker ::
|
||||
* The target stroker handle.
|
||||
*
|
||||
* border ::
|
||||
* The border index.
|
||||
*
|
||||
* outline ::
|
||||
* The target outline handle.
|
||||
*
|
||||
* @note:
|
||||
* Always call this function after @FT_Stroker_GetBorderCounts to
|
||||
* get sure that there is enough room in your @FT_Outline object to
|
||||
* receive all new data.
|
||||
*
|
||||
* When an outline, or a sub-path, is `closed', the stroker generates
|
||||
* two independent `border' outlines, named `left' and `right'.
|
||||
*
|
||||
* When the outline, or a sub-path, is `opened', the stroker merges
|
||||
* the `border' outlines with caps. The `left' border receives all
|
||||
* points, while the `right' border becomes empty.
|
||||
*
|
||||
* Use the function @FT_Stroker_Export instead if you want to
|
||||
* retrieve all borders at once.
|
||||
*/
|
||||
FT_EXPORT( void )
|
||||
FT_Stroker_ExportBorder( FT_Stroker stroker,
|
||||
FT_StrokerBorder border,
|
||||
FT_Outline* outline );
|
||||
|
||||
|
||||
/**************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Stroker_GetCounts
|
||||
*
|
||||
* @description:
|
||||
* Call this function once you have finished parsing your paths
|
||||
* with the stroker. It returns the number of points and
|
||||
* contours necessary to export all points/borders from the stroked
|
||||
* outline/path.
|
||||
*
|
||||
* @input:
|
||||
* stroker ::
|
||||
* The target stroker handle.
|
||||
*
|
||||
* @output:
|
||||
* anum_points ::
|
||||
* The number of points.
|
||||
*
|
||||
* anum_contours ::
|
||||
* The number of contours.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Stroker_GetCounts( FT_Stroker stroker,
|
||||
FT_UInt *anum_points,
|
||||
FT_UInt *anum_contours );
|
||||
|
||||
|
||||
/**************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Stroker_Export
|
||||
*
|
||||
* @description:
|
||||
* Call this function after @FT_Stroker_GetBorderCounts to
|
||||
* export all borders to your own @FT_Outline structure.
|
||||
*
|
||||
* Note that this function appends the border points and
|
||||
* contours to your outline, but does not try to resize its
|
||||
* arrays.
|
||||
*
|
||||
* @input:
|
||||
* stroker ::
|
||||
* The target stroker handle.
|
||||
*
|
||||
* outline ::
|
||||
* The target outline handle.
|
||||
*/
|
||||
FT_EXPORT( void )
|
||||
FT_Stroker_Export( FT_Stroker stroker,
|
||||
FT_Outline* outline );
|
||||
|
||||
|
||||
/**************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Stroker_Done
|
||||
*
|
||||
* @description:
|
||||
* Destroy a stroker object.
|
||||
*
|
||||
* @input:
|
||||
* stroker ::
|
||||
* A stroker handle. Can be NULL.
|
||||
*/
|
||||
FT_EXPORT( void )
|
||||
FT_Stroker_Done( FT_Stroker stroker );
|
||||
|
||||
|
||||
/**************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Glyph_Stroke
|
||||
*
|
||||
* @description:
|
||||
* Stroke a given outline glyph object with a given stroker.
|
||||
*
|
||||
* @inout:
|
||||
* pglyph ::
|
||||
* Source glyph handle on input, new glyph handle on output.
|
||||
*
|
||||
* @input:
|
||||
* stroker ::
|
||||
* A stroker handle.
|
||||
*
|
||||
* destroy ::
|
||||
* A Boolean. If~1, the source glyph object is destroyed
|
||||
* on success.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* The source glyph is untouched in case of error.
|
||||
*
|
||||
* Adding stroke may yield a significantly wider and taller glyph
|
||||
* depending on how large of a radius was used to stroke the glyph. You
|
||||
* may need to manually adjust horizontal and vertical advance amounts
|
||||
* to account for this added size.
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Glyph_Stroke( FT_Glyph *pglyph,
|
||||
FT_Stroker stroker,
|
||||
FT_Bool destroy );
|
||||
|
||||
|
||||
/**************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Glyph_StrokeBorder
|
||||
*
|
||||
* @description:
|
||||
* Stroke a given outline glyph object with a given stroker, but
|
||||
* only return either its inside or outside border.
|
||||
*
|
||||
* @inout:
|
||||
* pglyph ::
|
||||
* Source glyph handle on input, new glyph handle on output.
|
||||
*
|
||||
* @input:
|
||||
* stroker ::
|
||||
* A stroker handle.
|
||||
*
|
||||
* inside ::
|
||||
* A Boolean. If~1, return the inside border, otherwise
|
||||
* the outside border.
|
||||
*
|
||||
* destroy ::
|
||||
* A Boolean. If~1, the source glyph object is destroyed
|
||||
* on success.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* The source glyph is untouched in case of error.
|
||||
*
|
||||
* Adding stroke may yield a significantly wider and taller glyph
|
||||
* depending on how large of a radius was used to stroke the glyph. You
|
||||
* may need to manually adjust horizontal and vertical advance amounts
|
||||
* to account for this added size.
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Glyph_StrokeBorder( FT_Glyph *pglyph,
|
||||
FT_Stroker stroker,
|
||||
FT_Bool inside,
|
||||
FT_Bool destroy );
|
||||
|
||||
/* */
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTSTROKE_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
|
||||
|
||||
/* Local Variables: */
|
||||
/* coding: utf-8 */
|
||||
/* End: */
|
||||
@@ -0,0 +1,84 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftsynth.h */
|
||||
/* */
|
||||
/* FreeType synthesizing code for emboldening and slanting */
|
||||
/* (specification). */
|
||||
/* */
|
||||
/* Copyright 2000-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/********* *********/
|
||||
/********* WARNING, THIS IS ALPHA CODE! THIS API *********/
|
||||
/********* IS DUE TO CHANGE UNTIL STRICTLY NOTIFIED BY THE *********/
|
||||
/********* FREETYPE DEVELOPMENT TEAM *********/
|
||||
/********* *********/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/* Main reason for not lifting the functions in this module to a */
|
||||
/* `standard' API is that the used parameters for emboldening and */
|
||||
/* slanting are not configurable. Consider the functions as a */
|
||||
/* code resource that should be copied into the application and */
|
||||
/* adapted to the particular needs. */
|
||||
|
||||
|
||||
#ifndef FTSYNTH_H_
|
||||
#define FTSYNTH_H_
|
||||
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#ifdef FREETYPE_H
|
||||
#error "freetype.h of FreeType 1 has been loaded!"
|
||||
#error "Please fix the directory search order for header files"
|
||||
#error "so that freetype.h of FreeType 2 is found first."
|
||||
#endif
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
/* Embolden a glyph by a `reasonable' value (which is highly a matter of */
|
||||
/* taste). This function is actually a convenience function, providing */
|
||||
/* a wrapper for @FT_Outline_Embolden and @FT_Bitmap_Embolden. */
|
||||
/* */
|
||||
/* For emboldened outlines the height, width, and advance metrics are */
|
||||
/* increased by the strength of the emboldening -- this even affects */
|
||||
/* mono-width fonts! */
|
||||
/* */
|
||||
/* You can also call @FT_Outline_Get_CBox to get precise values. */
|
||||
FT_EXPORT( void )
|
||||
FT_GlyphSlot_Embolden( FT_GlyphSlot slot );
|
||||
|
||||
/* Slant an outline glyph to the right by about 12 degrees. */
|
||||
FT_EXPORT( void )
|
||||
FT_GlyphSlot_Oblique( FT_GlyphSlot slot );
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTSYNTH_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,355 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftsystem.h */
|
||||
/* */
|
||||
/* FreeType low-level system interface definition (specification). */
|
||||
/* */
|
||||
/* Copyright 1996-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTSYSTEM_H_
|
||||
#define FTSYSTEM_H_
|
||||
|
||||
|
||||
#include <ft2build.h>
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* system_interface */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* System Interface */
|
||||
/* */
|
||||
/* <Abstract> */
|
||||
/* How FreeType manages memory and i/o. */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This section contains various definitions related to memory */
|
||||
/* management and i/o access. You need to understand this */
|
||||
/* information if you want to use a custom memory manager or you own */
|
||||
/* i/o streams. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* M E M O R Y M A N A G E M E N T */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @type:
|
||||
* FT_Memory
|
||||
*
|
||||
* @description:
|
||||
* A handle to a given memory manager object, defined with an
|
||||
* @FT_MemoryRec structure.
|
||||
*
|
||||
*/
|
||||
typedef struct FT_MemoryRec_* FT_Memory;
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @functype:
|
||||
* FT_Alloc_Func
|
||||
*
|
||||
* @description:
|
||||
* A function used to allocate `size' bytes from `memory'.
|
||||
*
|
||||
* @input:
|
||||
* memory ::
|
||||
* A handle to the source memory manager.
|
||||
*
|
||||
* size ::
|
||||
* The size in bytes to allocate.
|
||||
*
|
||||
* @return:
|
||||
* Address of new memory block. 0~in case of failure.
|
||||
*
|
||||
*/
|
||||
typedef void*
|
||||
(*FT_Alloc_Func)( FT_Memory memory,
|
||||
long size );
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @functype:
|
||||
* FT_Free_Func
|
||||
*
|
||||
* @description:
|
||||
* A function used to release a given block of memory.
|
||||
*
|
||||
* @input:
|
||||
* memory ::
|
||||
* A handle to the source memory manager.
|
||||
*
|
||||
* block ::
|
||||
* The address of the target memory block.
|
||||
*
|
||||
*/
|
||||
typedef void
|
||||
(*FT_Free_Func)( FT_Memory memory,
|
||||
void* block );
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @functype:
|
||||
* FT_Realloc_Func
|
||||
*
|
||||
* @description:
|
||||
* A function used to re-allocate a given block of memory.
|
||||
*
|
||||
* @input:
|
||||
* memory ::
|
||||
* A handle to the source memory manager.
|
||||
*
|
||||
* cur_size ::
|
||||
* The block's current size in bytes.
|
||||
*
|
||||
* new_size ::
|
||||
* The block's requested new size.
|
||||
*
|
||||
* block ::
|
||||
* The block's current address.
|
||||
*
|
||||
* @return:
|
||||
* New block address. 0~in case of memory shortage.
|
||||
*
|
||||
* @note:
|
||||
* In case of error, the old block must still be available.
|
||||
*
|
||||
*/
|
||||
typedef void*
|
||||
(*FT_Realloc_Func)( FT_Memory memory,
|
||||
long cur_size,
|
||||
long new_size,
|
||||
void* block );
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @struct:
|
||||
* FT_MemoryRec
|
||||
*
|
||||
* @description:
|
||||
* A structure used to describe a given memory manager to FreeType~2.
|
||||
*
|
||||
* @fields:
|
||||
* user ::
|
||||
* A generic typeless pointer for user data.
|
||||
*
|
||||
* alloc ::
|
||||
* A pointer type to an allocation function.
|
||||
*
|
||||
* free ::
|
||||
* A pointer type to an memory freeing function.
|
||||
*
|
||||
* realloc ::
|
||||
* A pointer type to a reallocation function.
|
||||
*
|
||||
*/
|
||||
struct FT_MemoryRec_
|
||||
{
|
||||
void* user;
|
||||
FT_Alloc_Func alloc;
|
||||
FT_Free_Func free;
|
||||
FT_Realloc_Func realloc;
|
||||
};
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* I / O M A N A G E M E N T */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @type:
|
||||
* FT_Stream
|
||||
*
|
||||
* @description:
|
||||
* A handle to an input stream.
|
||||
*
|
||||
* @also:
|
||||
* See @FT_StreamRec for the publicly accessible fields of a given
|
||||
* stream object.
|
||||
*
|
||||
*/
|
||||
typedef struct FT_StreamRec_* FT_Stream;
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @struct:
|
||||
* FT_StreamDesc
|
||||
*
|
||||
* @description:
|
||||
* A union type used to store either a long or a pointer. This is used
|
||||
* to store a file descriptor or a `FILE*' in an input stream.
|
||||
*
|
||||
*/
|
||||
typedef union FT_StreamDesc_
|
||||
{
|
||||
long value;
|
||||
void* pointer;
|
||||
|
||||
} FT_StreamDesc;
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @functype:
|
||||
* FT_Stream_IoFunc
|
||||
*
|
||||
* @description:
|
||||
* A function used to seek and read data from a given input stream.
|
||||
*
|
||||
* @input:
|
||||
* stream ::
|
||||
* A handle to the source stream.
|
||||
*
|
||||
* offset ::
|
||||
* The offset of read in stream (always from start).
|
||||
*
|
||||
* buffer ::
|
||||
* The address of the read buffer.
|
||||
*
|
||||
* count ::
|
||||
* The number of bytes to read from the stream.
|
||||
*
|
||||
* @return:
|
||||
* The number of bytes effectively read by the stream.
|
||||
*
|
||||
* @note:
|
||||
* This function might be called to perform a seek or skip operation
|
||||
* with a `count' of~0. A non-zero return value then indicates an
|
||||
* error.
|
||||
*
|
||||
*/
|
||||
typedef unsigned long
|
||||
(*FT_Stream_IoFunc)( FT_Stream stream,
|
||||
unsigned long offset,
|
||||
unsigned char* buffer,
|
||||
unsigned long count );
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @functype:
|
||||
* FT_Stream_CloseFunc
|
||||
*
|
||||
* @description:
|
||||
* A function used to close a given input stream.
|
||||
*
|
||||
* @input:
|
||||
* stream ::
|
||||
* A handle to the target stream.
|
||||
*
|
||||
*/
|
||||
typedef void
|
||||
(*FT_Stream_CloseFunc)( FT_Stream stream );
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @struct:
|
||||
* FT_StreamRec
|
||||
*
|
||||
* @description:
|
||||
* A structure used to describe an input stream.
|
||||
*
|
||||
* @input:
|
||||
* base ::
|
||||
* For memory-based streams, this is the address of the first stream
|
||||
* byte in memory. This field should always be set to NULL for
|
||||
* disk-based streams.
|
||||
*
|
||||
* size ::
|
||||
* The stream size in bytes.
|
||||
*
|
||||
* In case of compressed streams where the size is unknown before
|
||||
* actually doing the decompression, the value is set to 0x7FFFFFFF.
|
||||
* (Note that this size value can occur for normal streams also; it is
|
||||
* thus just a hint.)
|
||||
*
|
||||
* pos ::
|
||||
* The current position within the stream.
|
||||
*
|
||||
* descriptor ::
|
||||
* This field is a union that can hold an integer or a pointer. It is
|
||||
* used by stream implementations to store file descriptors or `FILE*'
|
||||
* pointers.
|
||||
*
|
||||
* pathname ::
|
||||
* This field is completely ignored by FreeType. However, it is often
|
||||
* useful during debugging to use it to store the stream's filename
|
||||
* (where available).
|
||||
*
|
||||
* read ::
|
||||
* The stream's input function.
|
||||
*
|
||||
* close ::
|
||||
* The stream's close function.
|
||||
*
|
||||
* memory ::
|
||||
* The memory manager to use to preload frames. This is set
|
||||
* internally by FreeType and shouldn't be touched by stream
|
||||
* implementations.
|
||||
*
|
||||
* cursor ::
|
||||
* This field is set and used internally by FreeType when parsing
|
||||
* frames.
|
||||
*
|
||||
* limit ::
|
||||
* This field is set and used internally by FreeType when parsing
|
||||
* frames.
|
||||
*
|
||||
*/
|
||||
typedef struct FT_StreamRec_
|
||||
{
|
||||
unsigned char* base;
|
||||
unsigned long size;
|
||||
unsigned long pos;
|
||||
|
||||
FT_StreamDesc descriptor;
|
||||
FT_StreamDesc pathname;
|
||||
FT_Stream_IoFunc read;
|
||||
FT_Stream_CloseFunc close;
|
||||
|
||||
FT_Memory memory;
|
||||
unsigned char* cursor;
|
||||
unsigned char* limit;
|
||||
|
||||
} FT_StreamRec;
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTSYSTEM_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,350 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* fttrigon.h */
|
||||
/* */
|
||||
/* FreeType trigonometric functions (specification). */
|
||||
/* */
|
||||
/* Copyright 2001-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTTRIGON_H_
|
||||
#define FTTRIGON_H_
|
||||
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#ifdef FREETYPE_H
|
||||
#error "freetype.h of FreeType 1 has been loaded!"
|
||||
#error "Please fix the directory search order for header files"
|
||||
#error "so that freetype.h of FreeType 2 is found first."
|
||||
#endif
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* computations */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @type:
|
||||
* FT_Angle
|
||||
*
|
||||
* @description:
|
||||
* This type is used to model angle values in FreeType. Note that the
|
||||
* angle is a 16.16 fixed-point value expressed in degrees.
|
||||
*
|
||||
*/
|
||||
typedef FT_Fixed FT_Angle;
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_ANGLE_PI
|
||||
*
|
||||
* @description:
|
||||
* The angle pi expressed in @FT_Angle units.
|
||||
*
|
||||
*/
|
||||
#define FT_ANGLE_PI ( 180L << 16 )
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_ANGLE_2PI
|
||||
*
|
||||
* @description:
|
||||
* The angle 2*pi expressed in @FT_Angle units.
|
||||
*
|
||||
*/
|
||||
#define FT_ANGLE_2PI ( FT_ANGLE_PI * 2 )
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_ANGLE_PI2
|
||||
*
|
||||
* @description:
|
||||
* The angle pi/2 expressed in @FT_Angle units.
|
||||
*
|
||||
*/
|
||||
#define FT_ANGLE_PI2 ( FT_ANGLE_PI / 2 )
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @macro:
|
||||
* FT_ANGLE_PI4
|
||||
*
|
||||
* @description:
|
||||
* The angle pi/4 expressed in @FT_Angle units.
|
||||
*
|
||||
*/
|
||||
#define FT_ANGLE_PI4 ( FT_ANGLE_PI / 4 )
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Sin
|
||||
*
|
||||
* @description:
|
||||
* Return the sinus of a given angle in fixed-point format.
|
||||
*
|
||||
* @input:
|
||||
* angle ::
|
||||
* The input angle.
|
||||
*
|
||||
* @return:
|
||||
* The sinus value.
|
||||
*
|
||||
* @note:
|
||||
* If you need both the sinus and cosinus for a given angle, use the
|
||||
* function @FT_Vector_Unit.
|
||||
*
|
||||
*/
|
||||
FT_EXPORT( FT_Fixed )
|
||||
FT_Sin( FT_Angle angle );
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Cos
|
||||
*
|
||||
* @description:
|
||||
* Return the cosinus of a given angle in fixed-point format.
|
||||
*
|
||||
* @input:
|
||||
* angle ::
|
||||
* The input angle.
|
||||
*
|
||||
* @return:
|
||||
* The cosinus value.
|
||||
*
|
||||
* @note:
|
||||
* If you need both the sinus and cosinus for a given angle, use the
|
||||
* function @FT_Vector_Unit.
|
||||
*
|
||||
*/
|
||||
FT_EXPORT( FT_Fixed )
|
||||
FT_Cos( FT_Angle angle );
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Tan
|
||||
*
|
||||
* @description:
|
||||
* Return the tangent of a given angle in fixed-point format.
|
||||
*
|
||||
* @input:
|
||||
* angle ::
|
||||
* The input angle.
|
||||
*
|
||||
* @return:
|
||||
* The tangent value.
|
||||
*
|
||||
*/
|
||||
FT_EXPORT( FT_Fixed )
|
||||
FT_Tan( FT_Angle angle );
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Atan2
|
||||
*
|
||||
* @description:
|
||||
* Return the arc-tangent corresponding to a given vector (x,y) in
|
||||
* the 2d plane.
|
||||
*
|
||||
* @input:
|
||||
* x ::
|
||||
* The horizontal vector coordinate.
|
||||
*
|
||||
* y ::
|
||||
* The vertical vector coordinate.
|
||||
*
|
||||
* @return:
|
||||
* The arc-tangent value (i.e. angle).
|
||||
*
|
||||
*/
|
||||
FT_EXPORT( FT_Angle )
|
||||
FT_Atan2( FT_Fixed x,
|
||||
FT_Fixed y );
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Angle_Diff
|
||||
*
|
||||
* @description:
|
||||
* Return the difference between two angles. The result is always
|
||||
* constrained to the ]-PI..PI] interval.
|
||||
*
|
||||
* @input:
|
||||
* angle1 ::
|
||||
* First angle.
|
||||
*
|
||||
* angle2 ::
|
||||
* Second angle.
|
||||
*
|
||||
* @return:
|
||||
* Constrained value of `value2-value1'.
|
||||
*
|
||||
*/
|
||||
FT_EXPORT( FT_Angle )
|
||||
FT_Angle_Diff( FT_Angle angle1,
|
||||
FT_Angle angle2 );
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Vector_Unit
|
||||
*
|
||||
* @description:
|
||||
* Return the unit vector corresponding to a given angle. After the
|
||||
* call, the value of `vec.x' will be `cos(angle)', and the value of
|
||||
* `vec.y' will be `sin(angle)'.
|
||||
*
|
||||
* This function is useful to retrieve both the sinus and cosinus of a
|
||||
* given angle quickly.
|
||||
*
|
||||
* @output:
|
||||
* vec ::
|
||||
* The address of target vector.
|
||||
*
|
||||
* @input:
|
||||
* angle ::
|
||||
* The input angle.
|
||||
*
|
||||
*/
|
||||
FT_EXPORT( void )
|
||||
FT_Vector_Unit( FT_Vector* vec,
|
||||
FT_Angle angle );
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Vector_Rotate
|
||||
*
|
||||
* @description:
|
||||
* Rotate a vector by a given angle.
|
||||
*
|
||||
* @inout:
|
||||
* vec ::
|
||||
* The address of target vector.
|
||||
*
|
||||
* @input:
|
||||
* angle ::
|
||||
* The input angle.
|
||||
*
|
||||
*/
|
||||
FT_EXPORT( void )
|
||||
FT_Vector_Rotate( FT_Vector* vec,
|
||||
FT_Angle angle );
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Vector_Length
|
||||
*
|
||||
* @description:
|
||||
* Return the length of a given vector.
|
||||
*
|
||||
* @input:
|
||||
* vec ::
|
||||
* The address of target vector.
|
||||
*
|
||||
* @return:
|
||||
* The vector length, expressed in the same units that the original
|
||||
* vector coordinates.
|
||||
*
|
||||
*/
|
||||
FT_EXPORT( FT_Fixed )
|
||||
FT_Vector_Length( FT_Vector* vec );
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Vector_Polarize
|
||||
*
|
||||
* @description:
|
||||
* Compute both the length and angle of a given vector.
|
||||
*
|
||||
* @input:
|
||||
* vec ::
|
||||
* The address of source vector.
|
||||
*
|
||||
* @output:
|
||||
* length ::
|
||||
* The vector length.
|
||||
*
|
||||
* angle ::
|
||||
* The vector angle.
|
||||
*
|
||||
*/
|
||||
FT_EXPORT( void )
|
||||
FT_Vector_Polarize( FT_Vector* vec,
|
||||
FT_Fixed *length,
|
||||
FT_Angle *angle );
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Vector_From_Polar
|
||||
*
|
||||
* @description:
|
||||
* Compute vector coordinates from a length and angle.
|
||||
*
|
||||
* @output:
|
||||
* vec ::
|
||||
* The address of source vector.
|
||||
*
|
||||
* @input:
|
||||
* length ::
|
||||
* The vector length.
|
||||
*
|
||||
* angle ::
|
||||
* The vector angle.
|
||||
*
|
||||
*/
|
||||
FT_EXPORT( void )
|
||||
FT_Vector_From_Polar( FT_Vector* vec,
|
||||
FT_Fixed length,
|
||||
FT_Angle angle );
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTTRIGON_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,602 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* fttypes.h */
|
||||
/* */
|
||||
/* FreeType simple types definitions (specification only). */
|
||||
/* */
|
||||
/* Copyright 1996-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTTYPES_H_
|
||||
#define FTTYPES_H_
|
||||
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_CONFIG_CONFIG_H
|
||||
#include FT_SYSTEM_H
|
||||
#include FT_IMAGE_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* basic_types */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* Basic Data Types */
|
||||
/* */
|
||||
/* <Abstract> */
|
||||
/* The basic data types defined by the library. */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This section contains the basic data types defined by FreeType~2, */
|
||||
/* ranging from simple scalar types to bitmap descriptors. More */
|
||||
/* font-specific structures are defined in a different section. */
|
||||
/* */
|
||||
/* <Order> */
|
||||
/* FT_Byte */
|
||||
/* FT_Bytes */
|
||||
/* FT_Char */
|
||||
/* FT_Int */
|
||||
/* FT_UInt */
|
||||
/* FT_Int16 */
|
||||
/* FT_UInt16 */
|
||||
/* FT_Int32 */
|
||||
/* FT_UInt32 */
|
||||
/* FT_Int64 */
|
||||
/* FT_UInt64 */
|
||||
/* FT_Short */
|
||||
/* FT_UShort */
|
||||
/* FT_Long */
|
||||
/* FT_ULong */
|
||||
/* FT_Bool */
|
||||
/* FT_Offset */
|
||||
/* FT_PtrDist */
|
||||
/* FT_String */
|
||||
/* FT_Tag */
|
||||
/* FT_Error */
|
||||
/* FT_Fixed */
|
||||
/* FT_Pointer */
|
||||
/* FT_Pos */
|
||||
/* FT_Vector */
|
||||
/* FT_BBox */
|
||||
/* FT_Matrix */
|
||||
/* FT_FWord */
|
||||
/* FT_UFWord */
|
||||
/* FT_F2Dot14 */
|
||||
/* FT_UnitVector */
|
||||
/* FT_F26Dot6 */
|
||||
/* FT_Data */
|
||||
/* */
|
||||
/* FT_MAKE_TAG */
|
||||
/* */
|
||||
/* FT_Generic */
|
||||
/* FT_Generic_Finalizer */
|
||||
/* */
|
||||
/* FT_Bitmap */
|
||||
/* FT_Pixel_Mode */
|
||||
/* FT_Palette_Mode */
|
||||
/* FT_Glyph_Format */
|
||||
/* FT_IMAGE_TAG */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Bool */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A typedef of unsigned char, used for simple booleans. As usual, */
|
||||
/* values 1 and~0 represent true and false, respectively. */
|
||||
/* */
|
||||
typedef unsigned char FT_Bool;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_FWord */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A signed 16-bit integer used to store a distance in original font */
|
||||
/* units. */
|
||||
/* */
|
||||
typedef signed short FT_FWord; /* distance in FUnits */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_UFWord */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* An unsigned 16-bit integer used to store a distance in original */
|
||||
/* font units. */
|
||||
/* */
|
||||
typedef unsigned short FT_UFWord; /* unsigned distance */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Char */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A simple typedef for the _signed_ char type. */
|
||||
/* */
|
||||
typedef signed char FT_Char;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Byte */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A simple typedef for the _unsigned_ char type. */
|
||||
/* */
|
||||
typedef unsigned char FT_Byte;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Bytes */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A typedef for constant memory areas. */
|
||||
/* */
|
||||
typedef const FT_Byte* FT_Bytes;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Tag */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A typedef for 32-bit tags (as used in the SFNT format). */
|
||||
/* */
|
||||
typedef FT_UInt32 FT_Tag;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_String */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A simple typedef for the char type, usually used for strings. */
|
||||
/* */
|
||||
typedef char FT_String;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Short */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A typedef for signed short. */
|
||||
/* */
|
||||
typedef signed short FT_Short;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_UShort */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A typedef for unsigned short. */
|
||||
/* */
|
||||
typedef unsigned short FT_UShort;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Int */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A typedef for the int type. */
|
||||
/* */
|
||||
typedef signed int FT_Int;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_UInt */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A typedef for the unsigned int type. */
|
||||
/* */
|
||||
typedef unsigned int FT_UInt;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Long */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A typedef for signed long. */
|
||||
/* */
|
||||
typedef signed long FT_Long;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_ULong */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A typedef for unsigned long. */
|
||||
/* */
|
||||
typedef unsigned long FT_ULong;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_F2Dot14 */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A signed 2.14 fixed-point type used for unit vectors. */
|
||||
/* */
|
||||
typedef signed short FT_F2Dot14;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_F26Dot6 */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A signed 26.6 fixed-point type used for vectorial pixel */
|
||||
/* coordinates. */
|
||||
/* */
|
||||
typedef signed long FT_F26Dot6;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Fixed */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This type is used to store 16.16 fixed-point values, like scaling */
|
||||
/* values or matrix coefficients. */
|
||||
/* */
|
||||
typedef signed long FT_Fixed;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Error */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The FreeType error code type. A value of~0 is always interpreted */
|
||||
/* as a successful operation. */
|
||||
/* */
|
||||
typedef int FT_Error;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Pointer */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A simple typedef for a typeless pointer. */
|
||||
/* */
|
||||
typedef void* FT_Pointer;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_Offset */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This is equivalent to the ANSI~C `size_t' type, i.e., the largest */
|
||||
/* _unsigned_ integer type used to express a file size or position, */
|
||||
/* or a memory block size. */
|
||||
/* */
|
||||
typedef size_t FT_Offset;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_PtrDist */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This is equivalent to the ANSI~C `ptrdiff_t' type, i.e., the */
|
||||
/* largest _signed_ integer type used to express the distance */
|
||||
/* between two pointers. */
|
||||
/* */
|
||||
typedef ft_ptrdiff_t FT_PtrDist;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_UnitVector */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A simple structure used to store a 2D vector unit vector. Uses */
|
||||
/* FT_F2Dot14 types. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* x :: Horizontal coordinate. */
|
||||
/* */
|
||||
/* y :: Vertical coordinate. */
|
||||
/* */
|
||||
typedef struct FT_UnitVector_
|
||||
{
|
||||
FT_F2Dot14 x;
|
||||
FT_F2Dot14 y;
|
||||
|
||||
} FT_UnitVector;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_Matrix */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A simple structure used to store a 2x2 matrix. Coefficients are */
|
||||
/* in 16.16 fixed-point format. The computation performed is: */
|
||||
/* */
|
||||
/* { */
|
||||
/* x' = x*xx + y*xy */
|
||||
/* y' = x*yx + y*yy */
|
||||
/* } */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* xx :: Matrix coefficient. */
|
||||
/* */
|
||||
/* xy :: Matrix coefficient. */
|
||||
/* */
|
||||
/* yx :: Matrix coefficient. */
|
||||
/* */
|
||||
/* yy :: Matrix coefficient. */
|
||||
/* */
|
||||
typedef struct FT_Matrix_
|
||||
{
|
||||
FT_Fixed xx, xy;
|
||||
FT_Fixed yx, yy;
|
||||
|
||||
} FT_Matrix;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_Data */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Read-only binary data represented as a pointer and a length. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* pointer :: The data. */
|
||||
/* */
|
||||
/* length :: The length of the data in bytes. */
|
||||
/* */
|
||||
typedef struct FT_Data_
|
||||
{
|
||||
const FT_Byte* pointer;
|
||||
FT_Int length;
|
||||
|
||||
} FT_Data;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <FuncType> */
|
||||
/* FT_Generic_Finalizer */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Describe a function used to destroy the `client' data of any */
|
||||
/* FreeType object. See the description of the @FT_Generic type for */
|
||||
/* details of usage. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* The address of the FreeType object that is under finalization. */
|
||||
/* Its client data is accessed through its `generic' field. */
|
||||
/* */
|
||||
typedef void (*FT_Generic_Finalizer)( void* object );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_Generic */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Client applications often need to associate their own data to a */
|
||||
/* variety of FreeType core objects. For example, a text layout API */
|
||||
/* might want to associate a glyph cache to a given size object. */
|
||||
/* */
|
||||
/* Some FreeType object contains a `generic' field, of type */
|
||||
/* FT_Generic, which usage is left to client applications and font */
|
||||
/* servers. */
|
||||
/* */
|
||||
/* It can be used to store a pointer to client-specific data, as well */
|
||||
/* as the address of a `finalizer' function, which will be called by */
|
||||
/* FreeType when the object is destroyed (for example, the previous */
|
||||
/* client example would put the address of the glyph cache destructor */
|
||||
/* in the `finalizer' field). */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* data :: A typeless pointer to any client-specified data. This */
|
||||
/* field is completely ignored by the FreeType library. */
|
||||
/* */
|
||||
/* finalizer :: A pointer to a `generic finalizer' function, which */
|
||||
/* will be called when the object is destroyed. If this */
|
||||
/* field is set to NULL, no code will be called. */
|
||||
/* */
|
||||
typedef struct FT_Generic_
|
||||
{
|
||||
void* data;
|
||||
FT_Generic_Finalizer finalizer;
|
||||
|
||||
} FT_Generic;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Macro> */
|
||||
/* FT_MAKE_TAG */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This macro converts four-letter tags that are used to label */
|
||||
/* TrueType tables into an unsigned long, to be used within FreeType. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The produced values *must* be 32-bit integers. Don't redefine */
|
||||
/* this macro. */
|
||||
/* */
|
||||
#define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \
|
||||
(FT_Tag) \
|
||||
( ( (FT_ULong)_x1 << 24 ) | \
|
||||
( (FT_ULong)_x2 << 16 ) | \
|
||||
( (FT_ULong)_x3 << 8 ) | \
|
||||
(FT_ULong)_x4 )
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* L I S T M A N A G E M E N T */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* list_processing */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_ListNode */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Many elements and objects in FreeType are listed through an */
|
||||
/* @FT_List record (see @FT_ListRec). As its name suggests, an */
|
||||
/* FT_ListNode is a handle to a single list element. */
|
||||
/* */
|
||||
typedef struct FT_ListNodeRec_* FT_ListNode;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Type> */
|
||||
/* FT_List */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to a list record (see @FT_ListRec). */
|
||||
/* */
|
||||
typedef struct FT_ListRec_* FT_List;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_ListNodeRec */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to hold a single list element. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* prev :: The previous element in the list. NULL if first. */
|
||||
/* */
|
||||
/* next :: The next element in the list. NULL if last. */
|
||||
/* */
|
||||
/* data :: A typeless pointer to the listed object. */
|
||||
/* */
|
||||
typedef struct FT_ListNodeRec_
|
||||
{
|
||||
FT_ListNode prev;
|
||||
FT_ListNode next;
|
||||
void* data;
|
||||
|
||||
} FT_ListNodeRec;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_ListRec */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to hold a simple doubly-linked list. These are */
|
||||
/* used in many parts of FreeType. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* head :: The head (first element) of doubly-linked list. */
|
||||
/* */
|
||||
/* tail :: The tail (last element) of doubly-linked list. */
|
||||
/* */
|
||||
typedef struct FT_ListRec_
|
||||
{
|
||||
FT_ListNode head;
|
||||
FT_ListNode tail;
|
||||
|
||||
} FT_ListRec;
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
#define FT_IS_EMPTY( list ) ( (list).head == 0 )
|
||||
#define FT_BOOL( x ) ( (FT_Bool)( x ) )
|
||||
|
||||
/* concatenate C tokens */
|
||||
#define FT_ERR_XCAT( x, y ) x ## y
|
||||
#define FT_ERR_CAT( x, y ) FT_ERR_XCAT( x, y )
|
||||
|
||||
/* see `ftmoderr.h' for descriptions of the following macros */
|
||||
|
||||
#define FT_ERR( e ) FT_ERR_CAT( FT_ERR_PREFIX, e )
|
||||
|
||||
#define FT_ERROR_BASE( x ) ( (x) & 0xFF )
|
||||
#define FT_ERROR_MODULE( x ) ( (x) & 0xFF00U )
|
||||
|
||||
#define FT_ERR_EQ( x, e ) \
|
||||
( FT_ERROR_BASE( x ) == FT_ERROR_BASE( FT_ERR( e ) ) )
|
||||
#define FT_ERR_NEQ( x, e ) \
|
||||
( FT_ERROR_BASE( x ) != FT_ERROR_BASE( FT_ERR( e ) ) )
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTTYPES_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,275 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftwinfnt.h */
|
||||
/* */
|
||||
/* FreeType API for accessing Windows fnt-specific data. */
|
||||
/* */
|
||||
/* Copyright 2003-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FTWINFNT_H_
|
||||
#define FTWINFNT_H_
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#ifdef FREETYPE_H
|
||||
#error "freetype.h of FreeType 1 has been loaded!"
|
||||
#error "Please fix the directory search order for header files"
|
||||
#error "so that freetype.h of FreeType 2 is found first."
|
||||
#endif
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* winfnt_fonts */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* Window FNT Files */
|
||||
/* */
|
||||
/* <Abstract> */
|
||||
/* Windows FNT specific API. */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This section contains the declaration of Windows FNT specific */
|
||||
/* functions. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
*
|
||||
* @enum:
|
||||
* FT_WinFNT_ID_XXX
|
||||
*
|
||||
* @description:
|
||||
* A list of valid values for the `charset' byte in
|
||||
* @FT_WinFNT_HeaderRec. Exact mapping tables for the various cpXXXX
|
||||
* encodings (except for cp1361) can be found at
|
||||
* ftp://ftp.unicode.org/Public in the MAPPINGS/VENDORS/MICSFT/WINDOWS
|
||||
* subdirectory. cp1361 is roughly a superset of
|
||||
* MAPPINGS/OBSOLETE/EASTASIA/KSC/JOHAB.TXT.
|
||||
*
|
||||
* @values:
|
||||
* FT_WinFNT_ID_DEFAULT ::
|
||||
* This is used for font enumeration and font creation as a
|
||||
* `don't care' value. Valid font files don't contain this value.
|
||||
* When querying for information about the character set of the font
|
||||
* that is currently selected into a specified device context, this
|
||||
* return value (of the related Windows API) simply denotes failure.
|
||||
*
|
||||
* FT_WinFNT_ID_SYMBOL ::
|
||||
* There is no known mapping table available.
|
||||
*
|
||||
* FT_WinFNT_ID_MAC ::
|
||||
* Mac Roman encoding.
|
||||
*
|
||||
* FT_WinFNT_ID_OEM ::
|
||||
* From Michael Poettgen <michael@poettgen.de>:
|
||||
*
|
||||
* The `Windows Font Mapping' article says that FT_WinFNT_ID_OEM
|
||||
* is used for the charset of vector fonts, like `modern.fon',
|
||||
* `roman.fon', and `script.fon' on Windows.
|
||||
*
|
||||
* The `CreateFont' documentation says: The FT_WinFNT_ID_OEM value
|
||||
* specifies a character set that is operating-system dependent.
|
||||
*
|
||||
* The `IFIMETRICS' documentation from the `Windows Driver
|
||||
* Development Kit' says: This font supports an OEM-specific
|
||||
* character set. The OEM character set is system dependent.
|
||||
*
|
||||
* In general OEM, as opposed to ANSI (i.e., cp1252), denotes the
|
||||
* second default codepage that most international versions of
|
||||
* Windows have. It is one of the OEM codepages from
|
||||
*
|
||||
* https://msdn.microsoft.com/en-us/goglobal/bb964655,
|
||||
*
|
||||
* and is used for the `DOS boxes', to support legacy applications.
|
||||
* A German Windows version for example usually uses ANSI codepage
|
||||
* 1252 and OEM codepage 850.
|
||||
*
|
||||
* FT_WinFNT_ID_CP874 ::
|
||||
* A superset of Thai TIS 620 and ISO 8859-11.
|
||||
*
|
||||
* FT_WinFNT_ID_CP932 ::
|
||||
* A superset of Japanese Shift-JIS (with minor deviations).
|
||||
*
|
||||
* FT_WinFNT_ID_CP936 ::
|
||||
* A superset of simplified Chinese GB 2312-1980 (with different
|
||||
* ordering and minor deviations).
|
||||
*
|
||||
* FT_WinFNT_ID_CP949 ::
|
||||
* A superset of Korean Hangul KS~C 5601-1987 (with different
|
||||
* ordering and minor deviations).
|
||||
*
|
||||
* FT_WinFNT_ID_CP950 ::
|
||||
* A superset of traditional Chinese Big~5 ETen (with different
|
||||
* ordering and minor deviations).
|
||||
*
|
||||
* FT_WinFNT_ID_CP1250 ::
|
||||
* A superset of East European ISO 8859-2 (with slightly different
|
||||
* ordering).
|
||||
*
|
||||
* FT_WinFNT_ID_CP1251 ::
|
||||
* A superset of Russian ISO 8859-5 (with different ordering).
|
||||
*
|
||||
* FT_WinFNT_ID_CP1252 ::
|
||||
* ANSI encoding. A superset of ISO 8859-1.
|
||||
*
|
||||
* FT_WinFNT_ID_CP1253 ::
|
||||
* A superset of Greek ISO 8859-7 (with minor modifications).
|
||||
*
|
||||
* FT_WinFNT_ID_CP1254 ::
|
||||
* A superset of Turkish ISO 8859-9.
|
||||
*
|
||||
* FT_WinFNT_ID_CP1255 ::
|
||||
* A superset of Hebrew ISO 8859-8 (with some modifications).
|
||||
*
|
||||
* FT_WinFNT_ID_CP1256 ::
|
||||
* A superset of Arabic ISO 8859-6 (with different ordering).
|
||||
*
|
||||
* FT_WinFNT_ID_CP1257 ::
|
||||
* A superset of Baltic ISO 8859-13 (with some deviations).
|
||||
*
|
||||
* FT_WinFNT_ID_CP1258 ::
|
||||
* For Vietnamese. This encoding doesn't cover all necessary
|
||||
* characters.
|
||||
*
|
||||
* FT_WinFNT_ID_CP1361 ::
|
||||
* Korean (Johab).
|
||||
*/
|
||||
|
||||
#define FT_WinFNT_ID_CP1252 0
|
||||
#define FT_WinFNT_ID_DEFAULT 1
|
||||
#define FT_WinFNT_ID_SYMBOL 2
|
||||
#define FT_WinFNT_ID_MAC 77
|
||||
#define FT_WinFNT_ID_CP932 128
|
||||
#define FT_WinFNT_ID_CP949 129
|
||||
#define FT_WinFNT_ID_CP1361 130
|
||||
#define FT_WinFNT_ID_CP936 134
|
||||
#define FT_WinFNT_ID_CP950 136
|
||||
#define FT_WinFNT_ID_CP1253 161
|
||||
#define FT_WinFNT_ID_CP1254 162
|
||||
#define FT_WinFNT_ID_CP1258 163
|
||||
#define FT_WinFNT_ID_CP1255 177
|
||||
#define FT_WinFNT_ID_CP1256 178
|
||||
#define FT_WinFNT_ID_CP1257 186
|
||||
#define FT_WinFNT_ID_CP1251 204
|
||||
#define FT_WinFNT_ID_CP874 222
|
||||
#define FT_WinFNT_ID_CP1250 238
|
||||
#define FT_WinFNT_ID_OEM 255
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_WinFNT_HeaderRec */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Windows FNT Header info. */
|
||||
/* */
|
||||
typedef struct FT_WinFNT_HeaderRec_
|
||||
{
|
||||
FT_UShort version;
|
||||
FT_ULong file_size;
|
||||
FT_Byte copyright[60];
|
||||
FT_UShort file_type;
|
||||
FT_UShort nominal_point_size;
|
||||
FT_UShort vertical_resolution;
|
||||
FT_UShort horizontal_resolution;
|
||||
FT_UShort ascent;
|
||||
FT_UShort internal_leading;
|
||||
FT_UShort external_leading;
|
||||
FT_Byte italic;
|
||||
FT_Byte underline;
|
||||
FT_Byte strike_out;
|
||||
FT_UShort weight;
|
||||
FT_Byte charset;
|
||||
FT_UShort pixel_width;
|
||||
FT_UShort pixel_height;
|
||||
FT_Byte pitch_and_family;
|
||||
FT_UShort avg_width;
|
||||
FT_UShort max_width;
|
||||
FT_Byte first_char;
|
||||
FT_Byte last_char;
|
||||
FT_Byte default_char;
|
||||
FT_Byte break_char;
|
||||
FT_UShort bytes_per_row;
|
||||
FT_ULong device_offset;
|
||||
FT_ULong face_name_offset;
|
||||
FT_ULong bits_pointer;
|
||||
FT_ULong bits_offset;
|
||||
FT_Byte reserved;
|
||||
FT_ULong flags;
|
||||
FT_UShort A_space;
|
||||
FT_UShort B_space;
|
||||
FT_UShort C_space;
|
||||
FT_UShort color_table_offset;
|
||||
FT_ULong reserved1[4];
|
||||
|
||||
} FT_WinFNT_HeaderRec;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* FT_WinFNT_Header */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to an @FT_WinFNT_HeaderRec structure. */
|
||||
/* */
|
||||
typedef struct FT_WinFNT_HeaderRec_* FT_WinFNT_Header;
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Get_WinFNT_Header
|
||||
*
|
||||
* @description:
|
||||
* Retrieve a Windows FNT font info header.
|
||||
*
|
||||
* @input:
|
||||
* face :: A handle to the input face.
|
||||
*
|
||||
* @output:
|
||||
* aheader :: The WinFNT header.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* This function only works with Windows FNT faces, returning an error
|
||||
* otherwise.
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Get_WinFNT_Header( FT_Face face,
|
||||
FT_WinFNT_HeaderRec *aheader );
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* FTWINFNT_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
|
||||
|
||||
/* Local Variables: */
|
||||
/* coding: utf-8 */
|
||||
/* End: */
|
||||
@@ -0,0 +1,770 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* t1tables.h */
|
||||
/* */
|
||||
/* Basic Type 1/Type 2 tables definitions and interface (specification */
|
||||
/* only). */
|
||||
/* */
|
||||
/* Copyright 1996-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef T1TABLES_H_
|
||||
#define T1TABLES_H_
|
||||
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#ifdef FREETYPE_H
|
||||
#error "freetype.h of FreeType 1 has been loaded!"
|
||||
#error "Please fix the directory search order for header files"
|
||||
#error "so that freetype.h of FreeType 2 is found first."
|
||||
#endif
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* type1_tables */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* Type 1 Tables */
|
||||
/* */
|
||||
/* <Abstract> */
|
||||
/* Type~1 (PostScript) specific font tables. */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This section contains the definition of Type 1-specific tables, */
|
||||
/* including structures related to other PostScript font formats. */
|
||||
/* */
|
||||
/* <Order> */
|
||||
/* PS_FontInfoRec */
|
||||
/* PS_FontInfo */
|
||||
/* PS_PrivateRec */
|
||||
/* PS_Private */
|
||||
/* */
|
||||
/* CID_FaceDictRec */
|
||||
/* CID_FaceDict */
|
||||
/* CID_FaceInfoRec */
|
||||
/* CID_FaceInfo */
|
||||
/* */
|
||||
/* FT_Has_PS_Glyph_Names */
|
||||
/* FT_Get_PS_Font_Info */
|
||||
/* FT_Get_PS_Font_Private */
|
||||
/* FT_Get_PS_Font_Value */
|
||||
/* */
|
||||
/* T1_Blend_Flags */
|
||||
/* T1_EncodingType */
|
||||
/* PS_Dict_Keys */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/* Note that we separate font data in PS_FontInfoRec and PS_PrivateRec */
|
||||
/* structures in order to support Multiple Master fonts. */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* PS_FontInfoRec */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to model a Type~1 or Type~2 FontInfo dictionary. */
|
||||
/* Note that for Multiple Master fonts, each instance has its own */
|
||||
/* FontInfo dictionary. */
|
||||
/* */
|
||||
typedef struct PS_FontInfoRec_
|
||||
{
|
||||
FT_String* version;
|
||||
FT_String* notice;
|
||||
FT_String* full_name;
|
||||
FT_String* family_name;
|
||||
FT_String* weight;
|
||||
FT_Long italic_angle;
|
||||
FT_Bool is_fixed_pitch;
|
||||
FT_Short underline_position;
|
||||
FT_UShort underline_thickness;
|
||||
|
||||
} PS_FontInfoRec;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* PS_FontInfo */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to a @PS_FontInfoRec structure. */
|
||||
/* */
|
||||
typedef struct PS_FontInfoRec_* PS_FontInfo;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* T1_FontInfo */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This type is equivalent to @PS_FontInfoRec. It is deprecated but */
|
||||
/* kept to maintain source compatibility between various versions of */
|
||||
/* FreeType. */
|
||||
/* */
|
||||
typedef PS_FontInfoRec T1_FontInfo;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* PS_PrivateRec */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to model a Type~1 or Type~2 private dictionary. */
|
||||
/* Note that for Multiple Master fonts, each instance has its own */
|
||||
/* Private dictionary. */
|
||||
/* */
|
||||
typedef struct PS_PrivateRec_
|
||||
{
|
||||
FT_Int unique_id;
|
||||
FT_Int lenIV;
|
||||
|
||||
FT_Byte num_blue_values;
|
||||
FT_Byte num_other_blues;
|
||||
FT_Byte num_family_blues;
|
||||
FT_Byte num_family_other_blues;
|
||||
|
||||
FT_Short blue_values[14];
|
||||
FT_Short other_blues[10];
|
||||
|
||||
FT_Short family_blues [14];
|
||||
FT_Short family_other_blues[10];
|
||||
|
||||
FT_Fixed blue_scale;
|
||||
FT_Int blue_shift;
|
||||
FT_Int blue_fuzz;
|
||||
|
||||
FT_UShort standard_width[1];
|
||||
FT_UShort standard_height[1];
|
||||
|
||||
FT_Byte num_snap_widths;
|
||||
FT_Byte num_snap_heights;
|
||||
FT_Bool force_bold;
|
||||
FT_Bool round_stem_up;
|
||||
|
||||
FT_Short snap_widths [13]; /* including std width */
|
||||
FT_Short snap_heights[13]; /* including std height */
|
||||
|
||||
FT_Fixed expansion_factor;
|
||||
|
||||
FT_Long language_group;
|
||||
FT_Long password;
|
||||
|
||||
FT_Short min_feature[2];
|
||||
|
||||
} PS_PrivateRec;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* PS_Private */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to a @PS_PrivateRec structure. */
|
||||
/* */
|
||||
typedef struct PS_PrivateRec_* PS_Private;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* T1_Private */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This type is equivalent to @PS_PrivateRec. It is deprecated but */
|
||||
/* kept to maintain source compatibility between various versions of */
|
||||
/* FreeType. */
|
||||
/* */
|
||||
typedef PS_PrivateRec T1_Private;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Enum> */
|
||||
/* T1_Blend_Flags */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A set of flags used to indicate which fields are present in a */
|
||||
/* given blend dictionary (font info or private). Used to support */
|
||||
/* Multiple Masters fonts. */
|
||||
/* */
|
||||
/* <Values> */
|
||||
/* T1_BLEND_UNDERLINE_POSITION :: */
|
||||
/* T1_BLEND_UNDERLINE_THICKNESS :: */
|
||||
/* T1_BLEND_ITALIC_ANGLE :: */
|
||||
/* T1_BLEND_BLUE_VALUES :: */
|
||||
/* T1_BLEND_OTHER_BLUES :: */
|
||||
/* T1_BLEND_STANDARD_WIDTH :: */
|
||||
/* T1_BLEND_STANDARD_HEIGHT :: */
|
||||
/* T1_BLEND_STEM_SNAP_WIDTHS :: */
|
||||
/* T1_BLEND_STEM_SNAP_HEIGHTS :: */
|
||||
/* T1_BLEND_BLUE_SCALE :: */
|
||||
/* T1_BLEND_BLUE_SHIFT :: */
|
||||
/* T1_BLEND_FAMILY_BLUES :: */
|
||||
/* T1_BLEND_FAMILY_OTHER_BLUES :: */
|
||||
/* T1_BLEND_FORCE_BOLD :: */
|
||||
/* */
|
||||
typedef enum T1_Blend_Flags_
|
||||
{
|
||||
/* required fields in a FontInfo blend dictionary */
|
||||
T1_BLEND_UNDERLINE_POSITION = 0,
|
||||
T1_BLEND_UNDERLINE_THICKNESS,
|
||||
T1_BLEND_ITALIC_ANGLE,
|
||||
|
||||
/* required fields in a Private blend dictionary */
|
||||
T1_BLEND_BLUE_VALUES,
|
||||
T1_BLEND_OTHER_BLUES,
|
||||
T1_BLEND_STANDARD_WIDTH,
|
||||
T1_BLEND_STANDARD_HEIGHT,
|
||||
T1_BLEND_STEM_SNAP_WIDTHS,
|
||||
T1_BLEND_STEM_SNAP_HEIGHTS,
|
||||
T1_BLEND_BLUE_SCALE,
|
||||
T1_BLEND_BLUE_SHIFT,
|
||||
T1_BLEND_FAMILY_BLUES,
|
||||
T1_BLEND_FAMILY_OTHER_BLUES,
|
||||
T1_BLEND_FORCE_BOLD,
|
||||
|
||||
T1_BLEND_MAX /* do not remove */
|
||||
|
||||
} T1_Blend_Flags;
|
||||
|
||||
|
||||
/* these constants are deprecated; use the corresponding */
|
||||
/* `T1_Blend_Flags' values instead */
|
||||
#define t1_blend_underline_position T1_BLEND_UNDERLINE_POSITION
|
||||
#define t1_blend_underline_thickness T1_BLEND_UNDERLINE_THICKNESS
|
||||
#define t1_blend_italic_angle T1_BLEND_ITALIC_ANGLE
|
||||
#define t1_blend_blue_values T1_BLEND_BLUE_VALUES
|
||||
#define t1_blend_other_blues T1_BLEND_OTHER_BLUES
|
||||
#define t1_blend_standard_widths T1_BLEND_STANDARD_WIDTH
|
||||
#define t1_blend_standard_height T1_BLEND_STANDARD_HEIGHT
|
||||
#define t1_blend_stem_snap_widths T1_BLEND_STEM_SNAP_WIDTHS
|
||||
#define t1_blend_stem_snap_heights T1_BLEND_STEM_SNAP_HEIGHTS
|
||||
#define t1_blend_blue_scale T1_BLEND_BLUE_SCALE
|
||||
#define t1_blend_blue_shift T1_BLEND_BLUE_SHIFT
|
||||
#define t1_blend_family_blues T1_BLEND_FAMILY_BLUES
|
||||
#define t1_blend_family_other_blues T1_BLEND_FAMILY_OTHER_BLUES
|
||||
#define t1_blend_force_bold T1_BLEND_FORCE_BOLD
|
||||
#define t1_blend_max T1_BLEND_MAX
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
/* maximum number of Multiple Masters designs, as defined in the spec */
|
||||
#define T1_MAX_MM_DESIGNS 16
|
||||
|
||||
/* maximum number of Multiple Masters axes, as defined in the spec */
|
||||
#define T1_MAX_MM_AXIS 4
|
||||
|
||||
/* maximum number of elements in a design map */
|
||||
#define T1_MAX_MM_MAP_POINTS 20
|
||||
|
||||
|
||||
/* this structure is used to store the BlendDesignMap entry for an axis */
|
||||
typedef struct PS_DesignMap_
|
||||
{
|
||||
FT_Byte num_points;
|
||||
FT_Long* design_points;
|
||||
FT_Fixed* blend_points;
|
||||
|
||||
} PS_DesignMapRec, *PS_DesignMap;
|
||||
|
||||
/* backward compatible definition */
|
||||
typedef PS_DesignMapRec T1_DesignMap;
|
||||
|
||||
|
||||
typedef struct PS_BlendRec_
|
||||
{
|
||||
FT_UInt num_designs;
|
||||
FT_UInt num_axis;
|
||||
|
||||
FT_String* axis_names[T1_MAX_MM_AXIS];
|
||||
FT_Fixed* design_pos[T1_MAX_MM_DESIGNS];
|
||||
PS_DesignMapRec design_map[T1_MAX_MM_AXIS];
|
||||
|
||||
FT_Fixed* weight_vector;
|
||||
FT_Fixed* default_weight_vector;
|
||||
|
||||
PS_FontInfo font_infos[T1_MAX_MM_DESIGNS + 1];
|
||||
PS_Private privates [T1_MAX_MM_DESIGNS + 1];
|
||||
|
||||
FT_ULong blend_bitflags;
|
||||
|
||||
FT_BBox* bboxes [T1_MAX_MM_DESIGNS + 1];
|
||||
|
||||
/* since 2.3.0 */
|
||||
|
||||
/* undocumented, optional: the default design instance; */
|
||||
/* corresponds to default_weight_vector -- */
|
||||
/* num_default_design_vector == 0 means it is not present */
|
||||
/* in the font and associated metrics files */
|
||||
FT_UInt default_design_vector[T1_MAX_MM_DESIGNS];
|
||||
FT_UInt num_default_design_vector;
|
||||
|
||||
} PS_BlendRec, *PS_Blend;
|
||||
|
||||
|
||||
/* backward compatible definition */
|
||||
typedef PS_BlendRec T1_Blend;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* CID_FaceDictRec */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to represent data in a CID top-level dictionary. */
|
||||
/* */
|
||||
typedef struct CID_FaceDictRec_
|
||||
{
|
||||
PS_PrivateRec private_dict;
|
||||
|
||||
FT_UInt len_buildchar;
|
||||
FT_Fixed forcebold_threshold;
|
||||
FT_Pos stroke_width;
|
||||
FT_Fixed expansion_factor;
|
||||
|
||||
FT_Byte paint_type;
|
||||
FT_Byte font_type;
|
||||
FT_Matrix font_matrix;
|
||||
FT_Vector font_offset;
|
||||
|
||||
FT_UInt num_subrs;
|
||||
FT_ULong subrmap_offset;
|
||||
FT_Int sd_bytes;
|
||||
|
||||
} CID_FaceDictRec;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* CID_FaceDict */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to a @CID_FaceDictRec structure. */
|
||||
/* */
|
||||
typedef struct CID_FaceDictRec_* CID_FaceDict;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* CID_FontDict */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This type is equivalent to @CID_FaceDictRec. It is deprecated but */
|
||||
/* kept to maintain source compatibility between various versions of */
|
||||
/* FreeType. */
|
||||
/* */
|
||||
typedef CID_FaceDictRec CID_FontDict;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* CID_FaceInfoRec */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to represent CID Face information. */
|
||||
/* */
|
||||
typedef struct CID_FaceInfoRec_
|
||||
{
|
||||
FT_String* cid_font_name;
|
||||
FT_Fixed cid_version;
|
||||
FT_Int cid_font_type;
|
||||
|
||||
FT_String* registry;
|
||||
FT_String* ordering;
|
||||
FT_Int supplement;
|
||||
|
||||
PS_FontInfoRec font_info;
|
||||
FT_BBox font_bbox;
|
||||
FT_ULong uid_base;
|
||||
|
||||
FT_Int num_xuid;
|
||||
FT_ULong xuid[16];
|
||||
|
||||
FT_ULong cidmap_offset;
|
||||
FT_Int fd_bytes;
|
||||
FT_Int gd_bytes;
|
||||
FT_ULong cid_count;
|
||||
|
||||
FT_Int num_dicts;
|
||||
CID_FaceDict font_dicts;
|
||||
|
||||
FT_ULong data_offset;
|
||||
|
||||
} CID_FaceInfoRec;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* CID_FaceInfo */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A handle to a @CID_FaceInfoRec structure. */
|
||||
/* */
|
||||
typedef struct CID_FaceInfoRec_* CID_FaceInfo;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* CID_Info */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This type is equivalent to @CID_FaceInfoRec. It is deprecated but */
|
||||
/* kept to maintain source compatibility between various versions of */
|
||||
/* FreeType. */
|
||||
/* */
|
||||
typedef CID_FaceInfoRec CID_Info;
|
||||
|
||||
|
||||
/************************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Has_PS_Glyph_Names
|
||||
*
|
||||
* @description:
|
||||
* Return true if a given face provides reliable PostScript glyph
|
||||
* names. This is similar to using the @FT_HAS_GLYPH_NAMES macro,
|
||||
* except that certain fonts (mostly TrueType) contain incorrect
|
||||
* glyph name tables.
|
||||
*
|
||||
* When this function returns true, the caller is sure that the glyph
|
||||
* names returned by @FT_Get_Glyph_Name are reliable.
|
||||
*
|
||||
* @input:
|
||||
* face ::
|
||||
* face handle
|
||||
*
|
||||
* @return:
|
||||
* Boolean. True if glyph names are reliable.
|
||||
*
|
||||
*/
|
||||
FT_EXPORT( FT_Int )
|
||||
FT_Has_PS_Glyph_Names( FT_Face face );
|
||||
|
||||
|
||||
/************************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Get_PS_Font_Info
|
||||
*
|
||||
* @description:
|
||||
* Retrieve the @PS_FontInfoRec structure corresponding to a given
|
||||
* PostScript font.
|
||||
*
|
||||
* @input:
|
||||
* face ::
|
||||
* PostScript face handle.
|
||||
*
|
||||
* @output:
|
||||
* afont_info ::
|
||||
* Output font info structure pointer.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* String pointers within the @PS_FontInfoRec structure are owned by
|
||||
* the face and don't need to be freed by the caller. Missing entries
|
||||
* in the font's FontInfo dictionary are represented by NULL pointers.
|
||||
*
|
||||
* If the font's format is not PostScript-based, this function will
|
||||
* return the `FT_Err_Invalid_Argument' error code.
|
||||
*
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Get_PS_Font_Info( FT_Face face,
|
||||
PS_FontInfo afont_info );
|
||||
|
||||
|
||||
/************************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Get_PS_Font_Private
|
||||
*
|
||||
* @description:
|
||||
* Retrieve the @PS_PrivateRec structure corresponding to a given
|
||||
* PostScript font.
|
||||
*
|
||||
* @input:
|
||||
* face ::
|
||||
* PostScript face handle.
|
||||
*
|
||||
* @output:
|
||||
* afont_private ::
|
||||
* Output private dictionary structure pointer.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* The string pointers within the @PS_PrivateRec structure are owned by
|
||||
* the face and don't need to be freed by the caller.
|
||||
*
|
||||
* If the font's format is not PostScript-based, this function returns
|
||||
* the `FT_Err_Invalid_Argument' error code.
|
||||
*
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Get_PS_Font_Private( FT_Face face,
|
||||
PS_Private afont_private );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Enum> */
|
||||
/* T1_EncodingType */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* An enumeration describing the `Encoding' entry in a Type 1 */
|
||||
/* dictionary. */
|
||||
/* */
|
||||
/* <Values> */
|
||||
/* T1_ENCODING_TYPE_NONE :: */
|
||||
/* T1_ENCODING_TYPE_ARRAY :: */
|
||||
/* T1_ENCODING_TYPE_STANDARD :: */
|
||||
/* T1_ENCODING_TYPE_ISOLATIN1 :: */
|
||||
/* T1_ENCODING_TYPE_EXPERT :: */
|
||||
/* */
|
||||
/* <Since> */
|
||||
/* 2.4.8 */
|
||||
/* */
|
||||
typedef enum T1_EncodingType_
|
||||
{
|
||||
T1_ENCODING_TYPE_NONE = 0,
|
||||
T1_ENCODING_TYPE_ARRAY,
|
||||
T1_ENCODING_TYPE_STANDARD,
|
||||
T1_ENCODING_TYPE_ISOLATIN1,
|
||||
T1_ENCODING_TYPE_EXPERT
|
||||
|
||||
} T1_EncodingType;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Enum> */
|
||||
/* PS_Dict_Keys */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* An enumeration used in calls to @FT_Get_PS_Font_Value to identify */
|
||||
/* the Type~1 dictionary entry to retrieve. */
|
||||
/* */
|
||||
/* <Values> */
|
||||
/* PS_DICT_FONT_TYPE :: */
|
||||
/* PS_DICT_FONT_MATRIX :: */
|
||||
/* PS_DICT_FONT_BBOX :: */
|
||||
/* PS_DICT_PAINT_TYPE :: */
|
||||
/* PS_DICT_FONT_NAME :: */
|
||||
/* PS_DICT_UNIQUE_ID :: */
|
||||
/* PS_DICT_NUM_CHAR_STRINGS :: */
|
||||
/* PS_DICT_CHAR_STRING_KEY :: */
|
||||
/* PS_DICT_CHAR_STRING :: */
|
||||
/* PS_DICT_ENCODING_TYPE :: */
|
||||
/* PS_DICT_ENCODING_ENTRY :: */
|
||||
/* PS_DICT_NUM_SUBRS :: */
|
||||
/* PS_DICT_SUBR :: */
|
||||
/* PS_DICT_STD_HW :: */
|
||||
/* PS_DICT_STD_VW :: */
|
||||
/* PS_DICT_NUM_BLUE_VALUES :: */
|
||||
/* PS_DICT_BLUE_VALUE :: */
|
||||
/* PS_DICT_BLUE_FUZZ :: */
|
||||
/* PS_DICT_NUM_OTHER_BLUES :: */
|
||||
/* PS_DICT_OTHER_BLUE :: */
|
||||
/* PS_DICT_NUM_FAMILY_BLUES :: */
|
||||
/* PS_DICT_FAMILY_BLUE :: */
|
||||
/* PS_DICT_NUM_FAMILY_OTHER_BLUES :: */
|
||||
/* PS_DICT_FAMILY_OTHER_BLUE :: */
|
||||
/* PS_DICT_BLUE_SCALE :: */
|
||||
/* PS_DICT_BLUE_SHIFT :: */
|
||||
/* PS_DICT_NUM_STEM_SNAP_H :: */
|
||||
/* PS_DICT_STEM_SNAP_H :: */
|
||||
/* PS_DICT_NUM_STEM_SNAP_V :: */
|
||||
/* PS_DICT_STEM_SNAP_V :: */
|
||||
/* PS_DICT_FORCE_BOLD :: */
|
||||
/* PS_DICT_RND_STEM_UP :: */
|
||||
/* PS_DICT_MIN_FEATURE :: */
|
||||
/* PS_DICT_LEN_IV :: */
|
||||
/* PS_DICT_PASSWORD :: */
|
||||
/* PS_DICT_LANGUAGE_GROUP :: */
|
||||
/* PS_DICT_VERSION :: */
|
||||
/* PS_DICT_NOTICE :: */
|
||||
/* PS_DICT_FULL_NAME :: */
|
||||
/* PS_DICT_FAMILY_NAME :: */
|
||||
/* PS_DICT_WEIGHT :: */
|
||||
/* PS_DICT_IS_FIXED_PITCH :: */
|
||||
/* PS_DICT_UNDERLINE_POSITION :: */
|
||||
/* PS_DICT_UNDERLINE_THICKNESS :: */
|
||||
/* PS_DICT_FS_TYPE :: */
|
||||
/* PS_DICT_ITALIC_ANGLE :: */
|
||||
/* */
|
||||
/* <Since> */
|
||||
/* 2.4.8 */
|
||||
/* */
|
||||
typedef enum PS_Dict_Keys_
|
||||
{
|
||||
/* conventionally in the font dictionary */
|
||||
PS_DICT_FONT_TYPE, /* FT_Byte */
|
||||
PS_DICT_FONT_MATRIX, /* FT_Fixed */
|
||||
PS_DICT_FONT_BBOX, /* FT_Fixed */
|
||||
PS_DICT_PAINT_TYPE, /* FT_Byte */
|
||||
PS_DICT_FONT_NAME, /* FT_String* */
|
||||
PS_DICT_UNIQUE_ID, /* FT_Int */
|
||||
PS_DICT_NUM_CHAR_STRINGS, /* FT_Int */
|
||||
PS_DICT_CHAR_STRING_KEY, /* FT_String* */
|
||||
PS_DICT_CHAR_STRING, /* FT_String* */
|
||||
PS_DICT_ENCODING_TYPE, /* T1_EncodingType */
|
||||
PS_DICT_ENCODING_ENTRY, /* FT_String* */
|
||||
|
||||
/* conventionally in the font Private dictionary */
|
||||
PS_DICT_NUM_SUBRS, /* FT_Int */
|
||||
PS_DICT_SUBR, /* FT_String* */
|
||||
PS_DICT_STD_HW, /* FT_UShort */
|
||||
PS_DICT_STD_VW, /* FT_UShort */
|
||||
PS_DICT_NUM_BLUE_VALUES, /* FT_Byte */
|
||||
PS_DICT_BLUE_VALUE, /* FT_Short */
|
||||
PS_DICT_BLUE_FUZZ, /* FT_Int */
|
||||
PS_DICT_NUM_OTHER_BLUES, /* FT_Byte */
|
||||
PS_DICT_OTHER_BLUE, /* FT_Short */
|
||||
PS_DICT_NUM_FAMILY_BLUES, /* FT_Byte */
|
||||
PS_DICT_FAMILY_BLUE, /* FT_Short */
|
||||
PS_DICT_NUM_FAMILY_OTHER_BLUES, /* FT_Byte */
|
||||
PS_DICT_FAMILY_OTHER_BLUE, /* FT_Short */
|
||||
PS_DICT_BLUE_SCALE, /* FT_Fixed */
|
||||
PS_DICT_BLUE_SHIFT, /* FT_Int */
|
||||
PS_DICT_NUM_STEM_SNAP_H, /* FT_Byte */
|
||||
PS_DICT_STEM_SNAP_H, /* FT_Short */
|
||||
PS_DICT_NUM_STEM_SNAP_V, /* FT_Byte */
|
||||
PS_DICT_STEM_SNAP_V, /* FT_Short */
|
||||
PS_DICT_FORCE_BOLD, /* FT_Bool */
|
||||
PS_DICT_RND_STEM_UP, /* FT_Bool */
|
||||
PS_DICT_MIN_FEATURE, /* FT_Short */
|
||||
PS_DICT_LEN_IV, /* FT_Int */
|
||||
PS_DICT_PASSWORD, /* FT_Long */
|
||||
PS_DICT_LANGUAGE_GROUP, /* FT_Long */
|
||||
|
||||
/* conventionally in the font FontInfo dictionary */
|
||||
PS_DICT_VERSION, /* FT_String* */
|
||||
PS_DICT_NOTICE, /* FT_String* */
|
||||
PS_DICT_FULL_NAME, /* FT_String* */
|
||||
PS_DICT_FAMILY_NAME, /* FT_String* */
|
||||
PS_DICT_WEIGHT, /* FT_String* */
|
||||
PS_DICT_IS_FIXED_PITCH, /* FT_Bool */
|
||||
PS_DICT_UNDERLINE_POSITION, /* FT_Short */
|
||||
PS_DICT_UNDERLINE_THICKNESS, /* FT_UShort */
|
||||
PS_DICT_FS_TYPE, /* FT_UShort */
|
||||
PS_DICT_ITALIC_ANGLE, /* FT_Long */
|
||||
|
||||
PS_DICT_MAX = PS_DICT_ITALIC_ANGLE
|
||||
|
||||
} PS_Dict_Keys;
|
||||
|
||||
|
||||
/************************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Get_PS_Font_Value
|
||||
*
|
||||
* @description:
|
||||
* Retrieve the value for the supplied key from a PostScript font.
|
||||
*
|
||||
* @input:
|
||||
* face ::
|
||||
* PostScript face handle.
|
||||
*
|
||||
* key ::
|
||||
* An enumeration value representing the dictionary key to retrieve.
|
||||
*
|
||||
* idx ::
|
||||
* For array values, this specifies the index to be returned.
|
||||
*
|
||||
* value ::
|
||||
* A pointer to memory into which to write the value.
|
||||
*
|
||||
* valen_len ::
|
||||
* The size, in bytes, of the memory supplied for the value.
|
||||
*
|
||||
* @output:
|
||||
* value ::
|
||||
* The value matching the above key, if it exists.
|
||||
*
|
||||
* @return:
|
||||
* The amount of memory (in bytes) required to hold the requested
|
||||
* value (if it exists, -1 otherwise).
|
||||
*
|
||||
* @note:
|
||||
* The values returned are not pointers into the internal structures of
|
||||
* the face, but are `fresh' copies, so that the memory containing them
|
||||
* belongs to the calling application. This also enforces the
|
||||
* `read-only' nature of these values, i.e., this function cannot be
|
||||
* used to manipulate the face.
|
||||
*
|
||||
* `value' is a void pointer because the values returned can be of
|
||||
* various types.
|
||||
*
|
||||
* If either `value' is NULL or `value_len' is too small, just the
|
||||
* required memory size for the requested entry is returned.
|
||||
*
|
||||
* The `idx' parameter is used, not only to retrieve elements of, for
|
||||
* example, the FontMatrix or FontBBox, but also to retrieve name keys
|
||||
* from the CharStrings dictionary, and the charstrings themselves. It
|
||||
* is ignored for atomic values.
|
||||
*
|
||||
* PS_DICT_BLUE_SCALE returns a value that is scaled up by 1000. To
|
||||
* get the value as in the font stream, you need to divide by
|
||||
* 65536000.0 (to remove the FT_Fixed scale, and the x1000 scale).
|
||||
*
|
||||
* IMPORTANT: Only key/value pairs read by the FreeType interpreter can
|
||||
* be retrieved. So, for example, PostScript procedures such as NP,
|
||||
* ND, and RD are not available. Arbitrary keys are, obviously, not be
|
||||
* available either.
|
||||
*
|
||||
* If the font's format is not PostScript-based, this function returns
|
||||
* the `FT_Err_Invalid_Argument' error code.
|
||||
*
|
||||
* @since:
|
||||
* 2.4.8
|
||||
*
|
||||
*/
|
||||
FT_EXPORT( FT_Long )
|
||||
FT_Get_PS_Font_Value( FT_Face face,
|
||||
PS_Dict_Keys key,
|
||||
FT_UInt idx,
|
||||
void *value,
|
||||
FT_Long value_len );
|
||||
|
||||
/* */
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* T1TABLES_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,1236 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ttnameid.h */
|
||||
/* */
|
||||
/* TrueType name ID definitions (specification only). */
|
||||
/* */
|
||||
/* Copyright 1996-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef TTNAMEID_H_
|
||||
#define TTNAMEID_H_
|
||||
|
||||
|
||||
#include <ft2build.h>
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* truetype_tables */
|
||||
/* */
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* Possible values for the `platform' identifier code in the name */
|
||||
/* records of an SFNT `name' table. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* @enum:
|
||||
* TT_PLATFORM_XXX
|
||||
*
|
||||
* @description:
|
||||
* A list of valid values for the `platform_id' identifier code in
|
||||
* @FT_CharMapRec and @FT_SfntName structures.
|
||||
*
|
||||
* @values:
|
||||
* TT_PLATFORM_APPLE_UNICODE ::
|
||||
* Used by Apple to indicate a Unicode character map and/or name entry.
|
||||
* See @TT_APPLE_ID_XXX for corresponding `encoding_id' values. Note
|
||||
* that name entries in this format are coded as big-endian UCS-2
|
||||
* character codes _only_.
|
||||
*
|
||||
* TT_PLATFORM_MACINTOSH ::
|
||||
* Used by Apple to indicate a MacOS-specific charmap and/or name entry.
|
||||
* See @TT_MAC_ID_XXX for corresponding `encoding_id' values. Note that
|
||||
* most TrueType fonts contain an Apple roman charmap to be usable on
|
||||
* MacOS systems (even if they contain a Microsoft charmap as well).
|
||||
*
|
||||
* TT_PLATFORM_ISO ::
|
||||
* This value was used to specify ISO/IEC 10646 charmaps. It is however
|
||||
* now deprecated. See @TT_ISO_ID_XXX for a list of corresponding
|
||||
* `encoding_id' values.
|
||||
*
|
||||
* TT_PLATFORM_MICROSOFT ::
|
||||
* Used by Microsoft to indicate Windows-specific charmaps. See
|
||||
* @TT_MS_ID_XXX for a list of corresponding `encoding_id' values.
|
||||
* Note that most fonts contain a Unicode charmap using
|
||||
* (TT_PLATFORM_MICROSOFT, @TT_MS_ID_UNICODE_CS).
|
||||
*
|
||||
* TT_PLATFORM_CUSTOM ::
|
||||
* Used to indicate application-specific charmaps.
|
||||
*
|
||||
* TT_PLATFORM_ADOBE ::
|
||||
* This value isn't part of any font format specification, but is used
|
||||
* by FreeType to report Adobe-specific charmaps in an @FT_CharMapRec
|
||||
* structure. See @TT_ADOBE_ID_XXX.
|
||||
*/
|
||||
|
||||
#define TT_PLATFORM_APPLE_UNICODE 0
|
||||
#define TT_PLATFORM_MACINTOSH 1
|
||||
#define TT_PLATFORM_ISO 2 /* deprecated */
|
||||
#define TT_PLATFORM_MICROSOFT 3
|
||||
#define TT_PLATFORM_CUSTOM 4
|
||||
#define TT_PLATFORM_ADOBE 7 /* artificial */
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* @enum:
|
||||
* TT_APPLE_ID_XXX
|
||||
*
|
||||
* @description:
|
||||
* A list of valid values for the `encoding_id' for
|
||||
* @TT_PLATFORM_APPLE_UNICODE charmaps and name entries.
|
||||
*
|
||||
* @values:
|
||||
* TT_APPLE_ID_DEFAULT ::
|
||||
* Unicode version 1.0.
|
||||
*
|
||||
* TT_APPLE_ID_UNICODE_1_1 ::
|
||||
* Unicode 1.1; specifies Hangul characters starting at U+34xx.
|
||||
*
|
||||
* TT_APPLE_ID_ISO_10646 ::
|
||||
* Deprecated (identical to preceding).
|
||||
*
|
||||
* TT_APPLE_ID_UNICODE_2_0 ::
|
||||
* Unicode 2.0 and beyond (UTF-16 BMP only).
|
||||
*
|
||||
* TT_APPLE_ID_UNICODE_32 ::
|
||||
* Unicode 3.1 and beyond, using UTF-32.
|
||||
*
|
||||
* TT_APPLE_ID_VARIANT_SELECTOR ::
|
||||
* From Adobe, not Apple. Not a normal cmap. Specifies variations
|
||||
* on a real cmap.
|
||||
*
|
||||
* TT_APPLE_ID_FULL_UNICODE ::
|
||||
* Used for fallback fonts that provide complete Unicode coverage with
|
||||
* a type~13 cmap.
|
||||
*/
|
||||
|
||||
#define TT_APPLE_ID_DEFAULT 0 /* Unicode 1.0 */
|
||||
#define TT_APPLE_ID_UNICODE_1_1 1 /* specify Hangul at U+34xx */
|
||||
#define TT_APPLE_ID_ISO_10646 2 /* deprecated */
|
||||
#define TT_APPLE_ID_UNICODE_2_0 3 /* or later */
|
||||
#define TT_APPLE_ID_UNICODE_32 4 /* 2.0 or later, full repertoire */
|
||||
#define TT_APPLE_ID_VARIANT_SELECTOR 5 /* variation selector data */
|
||||
#define TT_APPLE_ID_FULL_UNICODE 6 /* used with type 13 cmaps */
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* @enum:
|
||||
* TT_MAC_ID_XXX
|
||||
*
|
||||
* @description:
|
||||
* A list of valid values for the `encoding_id' for
|
||||
* @TT_PLATFORM_MACINTOSH charmaps and name entries.
|
||||
*/
|
||||
|
||||
#define TT_MAC_ID_ROMAN 0
|
||||
#define TT_MAC_ID_JAPANESE 1
|
||||
#define TT_MAC_ID_TRADITIONAL_CHINESE 2
|
||||
#define TT_MAC_ID_KOREAN 3
|
||||
#define TT_MAC_ID_ARABIC 4
|
||||
#define TT_MAC_ID_HEBREW 5
|
||||
#define TT_MAC_ID_GREEK 6
|
||||
#define TT_MAC_ID_RUSSIAN 7
|
||||
#define TT_MAC_ID_RSYMBOL 8
|
||||
#define TT_MAC_ID_DEVANAGARI 9
|
||||
#define TT_MAC_ID_GURMUKHI 10
|
||||
#define TT_MAC_ID_GUJARATI 11
|
||||
#define TT_MAC_ID_ORIYA 12
|
||||
#define TT_MAC_ID_BENGALI 13
|
||||
#define TT_MAC_ID_TAMIL 14
|
||||
#define TT_MAC_ID_TELUGU 15
|
||||
#define TT_MAC_ID_KANNADA 16
|
||||
#define TT_MAC_ID_MALAYALAM 17
|
||||
#define TT_MAC_ID_SINHALESE 18
|
||||
#define TT_MAC_ID_BURMESE 19
|
||||
#define TT_MAC_ID_KHMER 20
|
||||
#define TT_MAC_ID_THAI 21
|
||||
#define TT_MAC_ID_LAOTIAN 22
|
||||
#define TT_MAC_ID_GEORGIAN 23
|
||||
#define TT_MAC_ID_ARMENIAN 24
|
||||
#define TT_MAC_ID_MALDIVIAN 25
|
||||
#define TT_MAC_ID_SIMPLIFIED_CHINESE 25
|
||||
#define TT_MAC_ID_TIBETAN 26
|
||||
#define TT_MAC_ID_MONGOLIAN 27
|
||||
#define TT_MAC_ID_GEEZ 28
|
||||
#define TT_MAC_ID_SLAVIC 29
|
||||
#define TT_MAC_ID_VIETNAMESE 30
|
||||
#define TT_MAC_ID_SINDHI 31
|
||||
#define TT_MAC_ID_UNINTERP 32
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* @enum:
|
||||
* TT_ISO_ID_XXX
|
||||
*
|
||||
* @description:
|
||||
* A list of valid values for the `encoding_id' for
|
||||
* @TT_PLATFORM_ISO charmaps and name entries.
|
||||
*
|
||||
* Their use is now deprecated.
|
||||
*
|
||||
* @values:
|
||||
* TT_ISO_ID_7BIT_ASCII ::
|
||||
* ASCII.
|
||||
* TT_ISO_ID_10646 ::
|
||||
* ISO/10646.
|
||||
* TT_ISO_ID_8859_1 ::
|
||||
* Also known as Latin-1.
|
||||
*/
|
||||
|
||||
#define TT_ISO_ID_7BIT_ASCII 0
|
||||
#define TT_ISO_ID_10646 1
|
||||
#define TT_ISO_ID_8859_1 2
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* @enum:
|
||||
* TT_MS_ID_XXX
|
||||
*
|
||||
* @description:
|
||||
* A list of valid values for the `encoding_id' for
|
||||
* @TT_PLATFORM_MICROSOFT charmaps and name entries.
|
||||
*
|
||||
* @values:
|
||||
* TT_MS_ID_SYMBOL_CS ::
|
||||
* Microsoft symbol encoding. See @FT_ENCODING_MS_SYMBOL.
|
||||
*
|
||||
* TT_MS_ID_UNICODE_CS ::
|
||||
* Microsoft WGL4 charmap, matching Unicode. See
|
||||
* @FT_ENCODING_UNICODE.
|
||||
*
|
||||
* TT_MS_ID_SJIS ::
|
||||
* Shift JIS Japanese encoding. See @FT_ENCODING_SJIS.
|
||||
*
|
||||
* TT_MS_ID_PRC ::
|
||||
* Chinese encodings as used in the People's Republic of China (PRC).
|
||||
* This means the encodings GB~2312 and its supersets GBK and
|
||||
* GB~18030. See @FT_ENCODING_PRC.
|
||||
*
|
||||
* TT_MS_ID_BIG_5 ::
|
||||
* Traditional Chinese as used in Taiwan and Hong Kong. See
|
||||
* @FT_ENCODING_BIG5.
|
||||
*
|
||||
* TT_MS_ID_WANSUNG ::
|
||||
* Korean Extended Wansung encoding. See @FT_ENCODING_WANSUNG.
|
||||
*
|
||||
* TT_MS_ID_JOHAB ::
|
||||
* Korean Johab encoding. See @FT_ENCODING_JOHAB.
|
||||
*
|
||||
* TT_MS_ID_UCS_4 ::
|
||||
* UCS-4 or UTF-32 charmaps. This has been added to the OpenType
|
||||
* specification version 1.4 (mid-2001).
|
||||
*/
|
||||
|
||||
#define TT_MS_ID_SYMBOL_CS 0
|
||||
#define TT_MS_ID_UNICODE_CS 1
|
||||
#define TT_MS_ID_SJIS 2
|
||||
#define TT_MS_ID_PRC 3
|
||||
#define TT_MS_ID_BIG_5 4
|
||||
#define TT_MS_ID_WANSUNG 5
|
||||
#define TT_MS_ID_JOHAB 6
|
||||
#define TT_MS_ID_UCS_4 10
|
||||
|
||||
/* this value is deprecated */
|
||||
#define TT_MS_ID_GB2312 TT_MS_ID_PRC
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* @enum:
|
||||
* TT_ADOBE_ID_XXX
|
||||
*
|
||||
* @description:
|
||||
* A list of valid values for the `encoding_id' for
|
||||
* @TT_PLATFORM_ADOBE charmaps. This is a FreeType-specific extension!
|
||||
*
|
||||
* @values:
|
||||
* TT_ADOBE_ID_STANDARD ::
|
||||
* Adobe standard encoding.
|
||||
* TT_ADOBE_ID_EXPERT ::
|
||||
* Adobe expert encoding.
|
||||
* TT_ADOBE_ID_CUSTOM ::
|
||||
* Adobe custom encoding.
|
||||
* TT_ADOBE_ID_LATIN_1 ::
|
||||
* Adobe Latin~1 encoding.
|
||||
*/
|
||||
|
||||
#define TT_ADOBE_ID_STANDARD 0
|
||||
#define TT_ADOBE_ID_EXPERT 1
|
||||
#define TT_ADOBE_ID_CUSTOM 2
|
||||
#define TT_ADOBE_ID_LATIN_1 3
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* @enum:
|
||||
* TT_MAC_LANGID_XXX
|
||||
*
|
||||
* @description:
|
||||
* Possible values of the language identifier field in the name records
|
||||
* of the SFNT `name' table if the `platform' identifier code is
|
||||
* @TT_PLATFORM_MACINTOSH. These values are also used as return values
|
||||
* for function @FT_Get_CMap_Language_ID.
|
||||
*
|
||||
* The canonical source for Apple's IDs is
|
||||
*
|
||||
* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6name.html
|
||||
*/
|
||||
|
||||
#define TT_MAC_LANGID_ENGLISH 0
|
||||
#define TT_MAC_LANGID_FRENCH 1
|
||||
#define TT_MAC_LANGID_GERMAN 2
|
||||
#define TT_MAC_LANGID_ITALIAN 3
|
||||
#define TT_MAC_LANGID_DUTCH 4
|
||||
#define TT_MAC_LANGID_SWEDISH 5
|
||||
#define TT_MAC_LANGID_SPANISH 6
|
||||
#define TT_MAC_LANGID_DANISH 7
|
||||
#define TT_MAC_LANGID_PORTUGUESE 8
|
||||
#define TT_MAC_LANGID_NORWEGIAN 9
|
||||
#define TT_MAC_LANGID_HEBREW 10
|
||||
#define TT_MAC_LANGID_JAPANESE 11
|
||||
#define TT_MAC_LANGID_ARABIC 12
|
||||
#define TT_MAC_LANGID_FINNISH 13
|
||||
#define TT_MAC_LANGID_GREEK 14
|
||||
#define TT_MAC_LANGID_ICELANDIC 15
|
||||
#define TT_MAC_LANGID_MALTESE 16
|
||||
#define TT_MAC_LANGID_TURKISH 17
|
||||
#define TT_MAC_LANGID_CROATIAN 18
|
||||
#define TT_MAC_LANGID_CHINESE_TRADITIONAL 19
|
||||
#define TT_MAC_LANGID_URDU 20
|
||||
#define TT_MAC_LANGID_HINDI 21
|
||||
#define TT_MAC_LANGID_THAI 22
|
||||
#define TT_MAC_LANGID_KOREAN 23
|
||||
#define TT_MAC_LANGID_LITHUANIAN 24
|
||||
#define TT_MAC_LANGID_POLISH 25
|
||||
#define TT_MAC_LANGID_HUNGARIAN 26
|
||||
#define TT_MAC_LANGID_ESTONIAN 27
|
||||
#define TT_MAC_LANGID_LETTISH 28
|
||||
#define TT_MAC_LANGID_SAAMISK 29
|
||||
#define TT_MAC_LANGID_FAEROESE 30
|
||||
#define TT_MAC_LANGID_FARSI 31
|
||||
#define TT_MAC_LANGID_RUSSIAN 32
|
||||
#define TT_MAC_LANGID_CHINESE_SIMPLIFIED 33
|
||||
#define TT_MAC_LANGID_FLEMISH 34
|
||||
#define TT_MAC_LANGID_IRISH 35
|
||||
#define TT_MAC_LANGID_ALBANIAN 36
|
||||
#define TT_MAC_LANGID_ROMANIAN 37
|
||||
#define TT_MAC_LANGID_CZECH 38
|
||||
#define TT_MAC_LANGID_SLOVAK 39
|
||||
#define TT_MAC_LANGID_SLOVENIAN 40
|
||||
#define TT_MAC_LANGID_YIDDISH 41
|
||||
#define TT_MAC_LANGID_SERBIAN 42
|
||||
#define TT_MAC_LANGID_MACEDONIAN 43
|
||||
#define TT_MAC_LANGID_BULGARIAN 44
|
||||
#define TT_MAC_LANGID_UKRAINIAN 45
|
||||
#define TT_MAC_LANGID_BYELORUSSIAN 46
|
||||
#define TT_MAC_LANGID_UZBEK 47
|
||||
#define TT_MAC_LANGID_KAZAKH 48
|
||||
#define TT_MAC_LANGID_AZERBAIJANI 49
|
||||
#define TT_MAC_LANGID_AZERBAIJANI_CYRILLIC_SCRIPT 49
|
||||
#define TT_MAC_LANGID_AZERBAIJANI_ARABIC_SCRIPT 50
|
||||
#define TT_MAC_LANGID_ARMENIAN 51
|
||||
#define TT_MAC_LANGID_GEORGIAN 52
|
||||
#define TT_MAC_LANGID_MOLDAVIAN 53
|
||||
#define TT_MAC_LANGID_KIRGHIZ 54
|
||||
#define TT_MAC_LANGID_TAJIKI 55
|
||||
#define TT_MAC_LANGID_TURKMEN 56
|
||||
#define TT_MAC_LANGID_MONGOLIAN 57
|
||||
#define TT_MAC_LANGID_MONGOLIAN_MONGOLIAN_SCRIPT 57
|
||||
#define TT_MAC_LANGID_MONGOLIAN_CYRILLIC_SCRIPT 58
|
||||
#define TT_MAC_LANGID_PASHTO 59
|
||||
#define TT_MAC_LANGID_KURDISH 60
|
||||
#define TT_MAC_LANGID_KASHMIRI 61
|
||||
#define TT_MAC_LANGID_SINDHI 62
|
||||
#define TT_MAC_LANGID_TIBETAN 63
|
||||
#define TT_MAC_LANGID_NEPALI 64
|
||||
#define TT_MAC_LANGID_SANSKRIT 65
|
||||
#define TT_MAC_LANGID_MARATHI 66
|
||||
#define TT_MAC_LANGID_BENGALI 67
|
||||
#define TT_MAC_LANGID_ASSAMESE 68
|
||||
#define TT_MAC_LANGID_GUJARATI 69
|
||||
#define TT_MAC_LANGID_PUNJABI 70
|
||||
#define TT_MAC_LANGID_ORIYA 71
|
||||
#define TT_MAC_LANGID_MALAYALAM 72
|
||||
#define TT_MAC_LANGID_KANNADA 73
|
||||
#define TT_MAC_LANGID_TAMIL 74
|
||||
#define TT_MAC_LANGID_TELUGU 75
|
||||
#define TT_MAC_LANGID_SINHALESE 76
|
||||
#define TT_MAC_LANGID_BURMESE 77
|
||||
#define TT_MAC_LANGID_KHMER 78
|
||||
#define TT_MAC_LANGID_LAO 79
|
||||
#define TT_MAC_LANGID_VIETNAMESE 80
|
||||
#define TT_MAC_LANGID_INDONESIAN 81
|
||||
#define TT_MAC_LANGID_TAGALOG 82
|
||||
#define TT_MAC_LANGID_MALAY_ROMAN_SCRIPT 83
|
||||
#define TT_MAC_LANGID_MALAY_ARABIC_SCRIPT 84
|
||||
#define TT_MAC_LANGID_AMHARIC 85
|
||||
#define TT_MAC_LANGID_TIGRINYA 86
|
||||
#define TT_MAC_LANGID_GALLA 87
|
||||
#define TT_MAC_LANGID_SOMALI 88
|
||||
#define TT_MAC_LANGID_SWAHILI 89
|
||||
#define TT_MAC_LANGID_RUANDA 90
|
||||
#define TT_MAC_LANGID_RUNDI 91
|
||||
#define TT_MAC_LANGID_CHEWA 92
|
||||
#define TT_MAC_LANGID_MALAGASY 93
|
||||
#define TT_MAC_LANGID_ESPERANTO 94
|
||||
#define TT_MAC_LANGID_WELSH 128
|
||||
#define TT_MAC_LANGID_BASQUE 129
|
||||
#define TT_MAC_LANGID_CATALAN 130
|
||||
#define TT_MAC_LANGID_LATIN 131
|
||||
#define TT_MAC_LANGID_QUECHUA 132
|
||||
#define TT_MAC_LANGID_GUARANI 133
|
||||
#define TT_MAC_LANGID_AYMARA 134
|
||||
#define TT_MAC_LANGID_TATAR 135
|
||||
#define TT_MAC_LANGID_UIGHUR 136
|
||||
#define TT_MAC_LANGID_DZONGKHA 137
|
||||
#define TT_MAC_LANGID_JAVANESE 138
|
||||
#define TT_MAC_LANGID_SUNDANESE 139
|
||||
|
||||
/* The following codes are new as of 2000-03-10 */
|
||||
#define TT_MAC_LANGID_GALICIAN 140
|
||||
#define TT_MAC_LANGID_AFRIKAANS 141
|
||||
#define TT_MAC_LANGID_BRETON 142
|
||||
#define TT_MAC_LANGID_INUKTITUT 143
|
||||
#define TT_MAC_LANGID_SCOTTISH_GAELIC 144
|
||||
#define TT_MAC_LANGID_MANX_GAELIC 145
|
||||
#define TT_MAC_LANGID_IRISH_GAELIC 146
|
||||
#define TT_MAC_LANGID_TONGAN 147
|
||||
#define TT_MAC_LANGID_GREEK_POLYTONIC 148
|
||||
#define TT_MAC_LANGID_GREELANDIC 149
|
||||
#define TT_MAC_LANGID_AZERBAIJANI_ROMAN_SCRIPT 150
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* @enum:
|
||||
* TT_MS_LANGID_XXX
|
||||
*
|
||||
* @description:
|
||||
* Possible values of the language identifier field in the name records
|
||||
* of the SFNT `name' table if the `platform' identifier code is
|
||||
* @TT_PLATFORM_MICROSOFT. These values are also used as return values
|
||||
* for function @FT_Get_CMap_Language_ID.
|
||||
*
|
||||
* The canonical source for Microsoft's IDs is
|
||||
*
|
||||
* https://www.microsoft.com/globaldev/reference/lcid-all.mspx ,
|
||||
*
|
||||
* however, we only provide macros for language identifiers present in
|
||||
* the OpenType specification: Microsoft has abandoned the concept of
|
||||
* LCIDs (language code identifiers), and format~1 of the `name' table
|
||||
* provides a better mechanism for languages not covered here.
|
||||
*
|
||||
* More legacy values not listed in the reference can be found in the
|
||||
* @FT_TRUETYPE_IDS_H header file.
|
||||
*/
|
||||
|
||||
#define TT_MS_LANGID_ARABIC_SAUDI_ARABIA 0x0401
|
||||
#define TT_MS_LANGID_ARABIC_IRAQ 0x0801
|
||||
#define TT_MS_LANGID_ARABIC_EGYPT 0x0C01
|
||||
#define TT_MS_LANGID_ARABIC_LIBYA 0x1001
|
||||
#define TT_MS_LANGID_ARABIC_ALGERIA 0x1401
|
||||
#define TT_MS_LANGID_ARABIC_MOROCCO 0x1801
|
||||
#define TT_MS_LANGID_ARABIC_TUNISIA 0x1C01
|
||||
#define TT_MS_LANGID_ARABIC_OMAN 0x2001
|
||||
#define TT_MS_LANGID_ARABIC_YEMEN 0x2401
|
||||
#define TT_MS_LANGID_ARABIC_SYRIA 0x2801
|
||||
#define TT_MS_LANGID_ARABIC_JORDAN 0x2C01
|
||||
#define TT_MS_LANGID_ARABIC_LEBANON 0x3001
|
||||
#define TT_MS_LANGID_ARABIC_KUWAIT 0x3401
|
||||
#define TT_MS_LANGID_ARABIC_UAE 0x3801
|
||||
#define TT_MS_LANGID_ARABIC_BAHRAIN 0x3C01
|
||||
#define TT_MS_LANGID_ARABIC_QATAR 0x4001
|
||||
#define TT_MS_LANGID_BULGARIAN_BULGARIA 0x0402
|
||||
#define TT_MS_LANGID_CATALAN_CATALAN 0x0403
|
||||
#define TT_MS_LANGID_CHINESE_TAIWAN 0x0404
|
||||
#define TT_MS_LANGID_CHINESE_PRC 0x0804
|
||||
#define TT_MS_LANGID_CHINESE_HONG_KONG 0x0C04
|
||||
#define TT_MS_LANGID_CHINESE_SINGAPORE 0x1004
|
||||
#define TT_MS_LANGID_CHINESE_MACAO 0x1404
|
||||
#define TT_MS_LANGID_CZECH_CZECH_REPUBLIC 0x0405
|
||||
#define TT_MS_LANGID_DANISH_DENMARK 0x0406
|
||||
#define TT_MS_LANGID_GERMAN_GERMANY 0x0407
|
||||
#define TT_MS_LANGID_GERMAN_SWITZERLAND 0x0807
|
||||
#define TT_MS_LANGID_GERMAN_AUSTRIA 0x0C07
|
||||
#define TT_MS_LANGID_GERMAN_LUXEMBOURG 0x1007
|
||||
#define TT_MS_LANGID_GERMAN_LIECHTENSTEIN 0x1407
|
||||
#define TT_MS_LANGID_GREEK_GREECE 0x0408
|
||||
#define TT_MS_LANGID_ENGLISH_UNITED_STATES 0x0409
|
||||
#define TT_MS_LANGID_ENGLISH_UNITED_KINGDOM 0x0809
|
||||
#define TT_MS_LANGID_ENGLISH_AUSTRALIA 0x0C09
|
||||
#define TT_MS_LANGID_ENGLISH_CANADA 0x1009
|
||||
#define TT_MS_LANGID_ENGLISH_NEW_ZEALAND 0x1409
|
||||
#define TT_MS_LANGID_ENGLISH_IRELAND 0x1809
|
||||
#define TT_MS_LANGID_ENGLISH_SOUTH_AFRICA 0x1C09
|
||||
#define TT_MS_LANGID_ENGLISH_JAMAICA 0x2009
|
||||
#define TT_MS_LANGID_ENGLISH_CARIBBEAN 0x2409
|
||||
#define TT_MS_LANGID_ENGLISH_BELIZE 0x2809
|
||||
#define TT_MS_LANGID_ENGLISH_TRINIDAD 0x2C09
|
||||
#define TT_MS_LANGID_ENGLISH_ZIMBABWE 0x3009
|
||||
#define TT_MS_LANGID_ENGLISH_PHILIPPINES 0x3409
|
||||
#define TT_MS_LANGID_ENGLISH_INDIA 0x4009
|
||||
#define TT_MS_LANGID_ENGLISH_MALAYSIA 0x4409
|
||||
#define TT_MS_LANGID_ENGLISH_SINGAPORE 0x4809
|
||||
#define TT_MS_LANGID_SPANISH_SPAIN_TRADITIONAL_SORT 0x040A
|
||||
#define TT_MS_LANGID_SPANISH_MEXICO 0x080A
|
||||
#define TT_MS_LANGID_SPANISH_SPAIN_MODERN_SORT 0x0C0A
|
||||
#define TT_MS_LANGID_SPANISH_GUATEMALA 0x100A
|
||||
#define TT_MS_LANGID_SPANISH_COSTA_RICA 0x140A
|
||||
#define TT_MS_LANGID_SPANISH_PANAMA 0x180A
|
||||
#define TT_MS_LANGID_SPANISH_DOMINICAN_REPUBLIC 0x1C0A
|
||||
#define TT_MS_LANGID_SPANISH_VENEZUELA 0x200A
|
||||
#define TT_MS_LANGID_SPANISH_COLOMBIA 0x240A
|
||||
#define TT_MS_LANGID_SPANISH_PERU 0x280A
|
||||
#define TT_MS_LANGID_SPANISH_ARGENTINA 0x2C0A
|
||||
#define TT_MS_LANGID_SPANISH_ECUADOR 0x300A
|
||||
#define TT_MS_LANGID_SPANISH_CHILE 0x340A
|
||||
#define TT_MS_LANGID_SPANISH_URUGUAY 0x380A
|
||||
#define TT_MS_LANGID_SPANISH_PARAGUAY 0x3C0A
|
||||
#define TT_MS_LANGID_SPANISH_BOLIVIA 0x400A
|
||||
#define TT_MS_LANGID_SPANISH_EL_SALVADOR 0x440A
|
||||
#define TT_MS_LANGID_SPANISH_HONDURAS 0x480A
|
||||
#define TT_MS_LANGID_SPANISH_NICARAGUA 0x4C0A
|
||||
#define TT_MS_LANGID_SPANISH_PUERTO_RICO 0x500A
|
||||
#define TT_MS_LANGID_SPANISH_UNITED_STATES 0x540A
|
||||
#define TT_MS_LANGID_FINNISH_FINLAND 0x040B
|
||||
#define TT_MS_LANGID_FRENCH_FRANCE 0x040C
|
||||
#define TT_MS_LANGID_FRENCH_BELGIUM 0x080C
|
||||
#define TT_MS_LANGID_FRENCH_CANADA 0x0C0C
|
||||
#define TT_MS_LANGID_FRENCH_SWITZERLAND 0x100C
|
||||
#define TT_MS_LANGID_FRENCH_LUXEMBOURG 0x140C
|
||||
#define TT_MS_LANGID_FRENCH_MONACO 0x180C
|
||||
#define TT_MS_LANGID_HEBREW_ISRAEL 0x040D
|
||||
#define TT_MS_LANGID_HUNGARIAN_HUNGARY 0x040E
|
||||
#define TT_MS_LANGID_ICELANDIC_ICELAND 0x040F
|
||||
#define TT_MS_LANGID_ITALIAN_ITALY 0x0410
|
||||
#define TT_MS_LANGID_ITALIAN_SWITZERLAND 0x0810
|
||||
#define TT_MS_LANGID_JAPANESE_JAPAN 0x0411
|
||||
#define TT_MS_LANGID_KOREAN_KOREA 0x0412
|
||||
#define TT_MS_LANGID_DUTCH_NETHERLANDS 0x0413
|
||||
#define TT_MS_LANGID_DUTCH_BELGIUM 0x0813
|
||||
#define TT_MS_LANGID_NORWEGIAN_NORWAY_BOKMAL 0x0414
|
||||
#define TT_MS_LANGID_NORWEGIAN_NORWAY_NYNORSK 0x0814
|
||||
#define TT_MS_LANGID_POLISH_POLAND 0x0415
|
||||
#define TT_MS_LANGID_PORTUGUESE_BRAZIL 0x0416
|
||||
#define TT_MS_LANGID_PORTUGUESE_PORTUGAL 0x0816
|
||||
#define TT_MS_LANGID_ROMANSH_SWITZERLAND 0x0417
|
||||
#define TT_MS_LANGID_ROMANIAN_ROMANIA 0x0418
|
||||
#define TT_MS_LANGID_RUSSIAN_RUSSIA 0x0419
|
||||
#define TT_MS_LANGID_CROATIAN_CROATIA 0x041A
|
||||
#define TT_MS_LANGID_SERBIAN_SERBIA_LATIN 0x081A
|
||||
#define TT_MS_LANGID_SERBIAN_SERBIA_CYRILLIC 0x0C1A
|
||||
#define TT_MS_LANGID_CROATIAN_BOSNIA_HERZEGOVINA 0x101A
|
||||
#define TT_MS_LANGID_BOSNIAN_BOSNIA_HERZEGOVINA 0x141A
|
||||
#define TT_MS_LANGID_SERBIAN_BOSNIA_HERZ_LATIN 0x181A
|
||||
#define TT_MS_LANGID_SERBIAN_BOSNIA_HERZ_CYRILLIC 0x1C1A
|
||||
#define TT_MS_LANGID_BOSNIAN_BOSNIA_HERZ_CYRILLIC 0x201A
|
||||
#define TT_MS_LANGID_SLOVAK_SLOVAKIA 0x041B
|
||||
#define TT_MS_LANGID_ALBANIAN_ALBANIA 0x041C
|
||||
#define TT_MS_LANGID_SWEDISH_SWEDEN 0x041D
|
||||
#define TT_MS_LANGID_SWEDISH_FINLAND 0x081D
|
||||
#define TT_MS_LANGID_THAI_THAILAND 0x041E
|
||||
#define TT_MS_LANGID_TURKISH_TURKEY 0x041F
|
||||
#define TT_MS_LANGID_URDU_PAKISTAN 0x0420
|
||||
#define TT_MS_LANGID_INDONESIAN_INDONESIA 0x0421
|
||||
#define TT_MS_LANGID_UKRAINIAN_UKRAINE 0x0422
|
||||
#define TT_MS_LANGID_BELARUSIAN_BELARUS 0x0423
|
||||
#define TT_MS_LANGID_SLOVENIAN_SLOVENIA 0x0424
|
||||
#define TT_MS_LANGID_ESTONIAN_ESTONIA 0x0425
|
||||
#define TT_MS_LANGID_LATVIAN_LATVIA 0x0426
|
||||
#define TT_MS_LANGID_LITHUANIAN_LITHUANIA 0x0427
|
||||
#define TT_MS_LANGID_TAJIK_TAJIKISTAN 0x0428
|
||||
#define TT_MS_LANGID_VIETNAMESE_VIET_NAM 0x042A
|
||||
#define TT_MS_LANGID_ARMENIAN_ARMENIA 0x042B
|
||||
#define TT_MS_LANGID_AZERI_AZERBAIJAN_LATIN 0x042C
|
||||
#define TT_MS_LANGID_AZERI_AZERBAIJAN_CYRILLIC 0x082C
|
||||
#define TT_MS_LANGID_BASQUE_BASQUE 0x042D
|
||||
#define TT_MS_LANGID_UPPER_SORBIAN_GERMANY 0x042E
|
||||
#define TT_MS_LANGID_LOWER_SORBIAN_GERMANY 0x082E
|
||||
#define TT_MS_LANGID_MACEDONIAN_MACEDONIA 0x042F
|
||||
#define TT_MS_LANGID_SETSWANA_SOUTH_AFRICA 0x0432
|
||||
#define TT_MS_LANGID_ISIXHOSA_SOUTH_AFRICA 0x0434
|
||||
#define TT_MS_LANGID_ISIZULU_SOUTH_AFRICA 0x0435
|
||||
#define TT_MS_LANGID_AFRIKAANS_SOUTH_AFRICA 0x0436
|
||||
#define TT_MS_LANGID_GEORGIAN_GEORGIA 0x0437
|
||||
#define TT_MS_LANGID_FAEROESE_FAEROE_ISLANDS 0x0438
|
||||
#define TT_MS_LANGID_HINDI_INDIA 0x0439
|
||||
#define TT_MS_LANGID_MALTESE_MALTA 0x043A
|
||||
#define TT_MS_LANGID_SAMI_NORTHERN_NORWAY 0x043B
|
||||
#define TT_MS_LANGID_SAMI_NORTHERN_SWEDEN 0x083B
|
||||
#define TT_MS_LANGID_SAMI_NORTHERN_FINLAND 0x0C3B
|
||||
#define TT_MS_LANGID_SAMI_LULE_NORWAY 0x103B
|
||||
#define TT_MS_LANGID_SAMI_LULE_SWEDEN 0x143B
|
||||
#define TT_MS_LANGID_SAMI_SOUTHERN_NORWAY 0x183B
|
||||
#define TT_MS_LANGID_SAMI_SOUTHERN_SWEDEN 0x1C3B
|
||||
#define TT_MS_LANGID_SAMI_SKOLT_FINLAND 0x203B
|
||||
#define TT_MS_LANGID_SAMI_INARI_FINLAND 0x243B
|
||||
#define TT_MS_LANGID_IRISH_IRELAND 0x083C
|
||||
#define TT_MS_LANGID_MALAY_MALAYSIA 0x043E
|
||||
#define TT_MS_LANGID_MALAY_BRUNEI_DARUSSALAM 0x083E
|
||||
#define TT_MS_LANGID_KAZAKH_KAZAKHSTAN 0x043F
|
||||
#define TT_MS_LANGID_KYRGYZ_KYRGYZSTAN /* Cyrillic*/ 0x0440
|
||||
#define TT_MS_LANGID_KISWAHILI_KENYA 0x0441
|
||||
#define TT_MS_LANGID_TURKMEN_TURKMENISTAN 0x0442
|
||||
#define TT_MS_LANGID_UZBEK_UZBEKISTAN_LATIN 0x0443
|
||||
#define TT_MS_LANGID_UZBEK_UZBEKISTAN_CYRILLIC 0x0843
|
||||
#define TT_MS_LANGID_TATAR_RUSSIA 0x0444
|
||||
#define TT_MS_LANGID_BENGALI_INDIA 0x0445
|
||||
#define TT_MS_LANGID_BENGALI_BANGLADESH 0x0845
|
||||
#define TT_MS_LANGID_PUNJABI_INDIA 0x0446
|
||||
#define TT_MS_LANGID_GUJARATI_INDIA 0x0447
|
||||
#define TT_MS_LANGID_ODIA_INDIA 0x0448
|
||||
#define TT_MS_LANGID_TAMIL_INDIA 0x0449
|
||||
#define TT_MS_LANGID_TELUGU_INDIA 0x044A
|
||||
#define TT_MS_LANGID_KANNADA_INDIA 0x044B
|
||||
#define TT_MS_LANGID_MALAYALAM_INDIA 0x044C
|
||||
#define TT_MS_LANGID_ASSAMESE_INDIA 0x044D
|
||||
#define TT_MS_LANGID_MARATHI_INDIA 0x044E
|
||||
#define TT_MS_LANGID_SANSKRIT_INDIA 0x044F
|
||||
#define TT_MS_LANGID_MONGOLIAN_MONGOLIA /* Cyrillic */ 0x0450
|
||||
#define TT_MS_LANGID_MONGOLIAN_PRC 0x0850
|
||||
#define TT_MS_LANGID_TIBETAN_PRC 0x0451
|
||||
#define TT_MS_LANGID_WELSH_UNITED_KINGDOM 0x0452
|
||||
#define TT_MS_LANGID_KHMER_CAMBODIA 0x0453
|
||||
#define TT_MS_LANGID_LAO_LAOS 0x0454
|
||||
#define TT_MS_LANGID_GALICIAN_GALICIAN 0x0456
|
||||
#define TT_MS_LANGID_KONKANI_INDIA 0x0457
|
||||
#define TT_MS_LANGID_SYRIAC_SYRIA 0x045A
|
||||
#define TT_MS_LANGID_SINHALA_SRI_LANKA 0x045B
|
||||
#define TT_MS_LANGID_INUKTITUT_CANADA 0x045D
|
||||
#define TT_MS_LANGID_INUKTITUT_CANADA_LATIN 0x085D
|
||||
#define TT_MS_LANGID_AMHARIC_ETHIOPIA 0x045E
|
||||
#define TT_MS_LANGID_TAMAZIGHT_ALGERIA 0x085F
|
||||
#define TT_MS_LANGID_NEPALI_NEPAL 0x0461
|
||||
#define TT_MS_LANGID_FRISIAN_NETHERLANDS 0x0462
|
||||
#define TT_MS_LANGID_PASHTO_AFGHANISTAN 0x0463
|
||||
#define TT_MS_LANGID_FILIPINO_PHILIPPINES 0x0464
|
||||
#define TT_MS_LANGID_DHIVEHI_MALDIVES 0x0465
|
||||
#define TT_MS_LANGID_HAUSA_NIGERIA 0x0468
|
||||
#define TT_MS_LANGID_YORUBA_NIGERIA 0x046A
|
||||
#define TT_MS_LANGID_QUECHUA_BOLIVIA 0x046B
|
||||
#define TT_MS_LANGID_QUECHUA_ECUADOR 0x086B
|
||||
#define TT_MS_LANGID_QUECHUA_PERU 0x0C6B
|
||||
#define TT_MS_LANGID_SESOTHO_SA_LEBOA_SOUTH_AFRICA 0x046C
|
||||
#define TT_MS_LANGID_BASHKIR_RUSSIA 0x046D
|
||||
#define TT_MS_LANGID_LUXEMBOURGISH_LUXEMBOURG 0x046E
|
||||
#define TT_MS_LANGID_GREENLANDIC_GREENLAND 0x046F
|
||||
#define TT_MS_LANGID_IGBO_NIGERIA 0x0470
|
||||
#define TT_MS_LANGID_YI_PRC 0x0478
|
||||
#define TT_MS_LANGID_MAPUDUNGUN_CHILE 0x047A
|
||||
#define TT_MS_LANGID_MOHAWK_MOHAWK 0x047C
|
||||
#define TT_MS_LANGID_BRETON_FRANCE 0x047E
|
||||
#define TT_MS_LANGID_UIGHUR_PRC 0x0480
|
||||
#define TT_MS_LANGID_MAORI_NEW_ZEALAND 0x0481
|
||||
#define TT_MS_LANGID_OCCITAN_FRANCE 0x0482
|
||||
#define TT_MS_LANGID_CORSICAN_FRANCE 0x0483
|
||||
#define TT_MS_LANGID_ALSATIAN_FRANCE 0x0484
|
||||
#define TT_MS_LANGID_YAKUT_RUSSIA 0x0485
|
||||
#define TT_MS_LANGID_KICHE_GUATEMALA 0x0486
|
||||
#define TT_MS_LANGID_KINYARWANDA_RWANDA 0x0487
|
||||
#define TT_MS_LANGID_WOLOF_SENEGAL 0x0488
|
||||
#define TT_MS_LANGID_DARI_AFGHANISTAN 0x048C
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
/* legacy macro definitions not present in OpenType 1.8.1 */
|
||||
#define TT_MS_LANGID_ARABIC_GENERAL 0x0001
|
||||
#define TT_MS_LANGID_CATALAN_SPAIN \
|
||||
TT_MS_LANGID_CATALAN_CATALAN
|
||||
#define TT_MS_LANGID_CHINESE_GENERAL 0x0004
|
||||
#define TT_MS_LANGID_CHINESE_MACAU \
|
||||
TT_MS_LANGID_CHINESE_MACAO
|
||||
#define TT_MS_LANGID_GERMAN_LIECHTENSTEI \
|
||||
TT_MS_LANGID_GERMAN_LIECHTENSTEIN
|
||||
#define TT_MS_LANGID_ENGLISH_GENERAL 0x0009
|
||||
#define TT_MS_LANGID_ENGLISH_INDONESIA 0x3809
|
||||
#define TT_MS_LANGID_ENGLISH_HONG_KONG 0x3C09
|
||||
#define TT_MS_LANGID_SPANISH_SPAIN_INTERNATIONAL_SORT \
|
||||
TT_MS_LANGID_SPANISH_SPAIN_MODERN_SORT
|
||||
#define TT_MS_LANGID_SPANISH_LATIN_AMERICA 0xE40AU
|
||||
#define TT_MS_LANGID_FRENCH_WEST_INDIES 0x1C0C
|
||||
#define TT_MS_LANGID_FRENCH_REUNION 0x200C
|
||||
#define TT_MS_LANGID_FRENCH_CONGO 0x240C
|
||||
/* which was formerly: */
|
||||
#define TT_MS_LANGID_FRENCH_ZAIRE \
|
||||
TT_MS_LANGID_FRENCH_CONGO
|
||||
#define TT_MS_LANGID_FRENCH_SENEGAL 0x280C
|
||||
#define TT_MS_LANGID_FRENCH_CAMEROON 0x2C0C
|
||||
#define TT_MS_LANGID_FRENCH_COTE_D_IVOIRE 0x300C
|
||||
#define TT_MS_LANGID_FRENCH_MALI 0x340C
|
||||
#define TT_MS_LANGID_FRENCH_MOROCCO 0x380C
|
||||
#define TT_MS_LANGID_FRENCH_HAITI 0x3C0C
|
||||
#define TT_MS_LANGID_FRENCH_NORTH_AFRICA 0xE40CU
|
||||
#define TT_MS_LANGID_KOREAN_EXTENDED_WANSUNG_KOREA \
|
||||
TT_MS_LANGID_KOREAN_KOREA
|
||||
#define TT_MS_LANGID_KOREAN_JOHAB_KOREA 0x0812
|
||||
#define TT_MS_LANGID_RHAETO_ROMANIC_SWITZERLAND \
|
||||
TT_MS_LANGID_ROMANSH_SWITZERLAND
|
||||
#define TT_MS_LANGID_MOLDAVIAN_MOLDAVIA 0x0818
|
||||
#define TT_MS_LANGID_RUSSIAN_MOLDAVIA 0x0819
|
||||
#define TT_MS_LANGID_URDU_INDIA 0x0820
|
||||
#define TT_MS_LANGID_CLASSIC_LITHUANIAN_LITHUANIA 0x0827
|
||||
#define TT_MS_LANGID_SLOVENE_SLOVENIA \
|
||||
TT_MS_LANGID_SLOVENIAN_SLOVENIA
|
||||
#define TT_MS_LANGID_FARSI_IRAN 0x0429
|
||||
#define TT_MS_LANGID_BASQUE_SPAIN \
|
||||
TT_MS_LANGID_BASQUE_BASQUE
|
||||
#define TT_MS_LANGID_SORBIAN_GERMANY \
|
||||
TT_MS_LANGID_UPPER_SORBIAN_GERMANY
|
||||
#define TT_MS_LANGID_SUTU_SOUTH_AFRICA 0x0430
|
||||
#define TT_MS_LANGID_TSONGA_SOUTH_AFRICA 0x0431
|
||||
#define TT_MS_LANGID_TSWANA_SOUTH_AFRICA \
|
||||
TT_MS_LANGID_SETSWANA_SOUTH_AFRICA
|
||||
#define TT_MS_LANGID_VENDA_SOUTH_AFRICA 0x0433
|
||||
#define TT_MS_LANGID_XHOSA_SOUTH_AFRICA \
|
||||
TT_MS_LANGID_ISIXHOSA_SOUTH_AFRICA
|
||||
#define TT_MS_LANGID_ZULU_SOUTH_AFRICA \
|
||||
TT_MS_LANGID_ISIZULU_SOUTH_AFRICA
|
||||
#define TT_MS_LANGID_SAAMI_LAPONIA 0x043B
|
||||
/* the next two values are incorrectly inverted */
|
||||
#define TT_MS_LANGID_IRISH_GAELIC_IRELAND 0x043C
|
||||
#define TT_MS_LANGID_SCOTTISH_GAELIC_UNITED_KINGDOM 0x083C
|
||||
#define TT_MS_LANGID_YIDDISH_GERMANY 0x043D
|
||||
#define TT_MS_LANGID_KAZAK_KAZAKSTAN \
|
||||
TT_MS_LANGID_KAZAKH_KAZAKHSTAN
|
||||
#define TT_MS_LANGID_KIRGHIZ_KIRGHIZ_REPUBLIC \
|
||||
TT_MS_LANGID_KYRGYZ_KYRGYZSTAN
|
||||
#define TT_MS_LANGID_KIRGHIZ_KIRGHIZSTAN \
|
||||
TT_MS_LANGID_KYRGYZ_KYRGYZSTAN
|
||||
#define TT_MS_LANGID_SWAHILI_KENYA \
|
||||
TT_MS_LANGID_KISWAHILI_KENYA
|
||||
#define TT_MS_LANGID_TATAR_TATARSTAN \
|
||||
TT_MS_LANGID_TATAR_RUSSIA
|
||||
#define TT_MS_LANGID_PUNJABI_ARABIC_PAKISTAN 0x0846
|
||||
#define TT_MS_LANGID_ORIYA_INDIA \
|
||||
TT_MS_LANGID_ODIA_INDIA
|
||||
#define TT_MS_LANGID_MONGOLIAN_MONGOLIA_MONGOLIAN \
|
||||
TT_MS_LANGID_MONGOLIAN_PRC
|
||||
#define TT_MS_LANGID_TIBETAN_CHINA \
|
||||
TT_MS_LANGID_TIBETAN_PRC
|
||||
#define TT_MS_LANGID_DZONGHKA_BHUTAN 0x0851
|
||||
#define TT_MS_LANGID_TIBETAN_BHUTAN \
|
||||
TT_MS_LANGID_DZONGHKA_BHUTAN
|
||||
#define TT_MS_LANGID_WELSH_WALES \
|
||||
TT_MS_LANGID_WELSH_UNITED_KINGDOM
|
||||
#define TT_MS_LANGID_BURMESE_MYANMAR 0x0455
|
||||
#define TT_MS_LANGID_GALICIAN_SPAIN \
|
||||
TT_MS_LANGID_GALICIAN_GALICIAN
|
||||
#define TT_MS_LANGID_MANIPURI_INDIA /* Bengali */ 0x0458
|
||||
#define TT_MS_LANGID_SINDHI_INDIA /* Arabic */ 0x0459
|
||||
#define TT_MS_LANGID_SINDHI_PAKISTAN 0x0859
|
||||
#define TT_MS_LANGID_SINHALESE_SRI_LANKA \
|
||||
TT_MS_LANGID_SINHALA_SRI_LANKA
|
||||
#define TT_MS_LANGID_CHEROKEE_UNITED_STATES 0x045C
|
||||
#define TT_MS_LANGID_TAMAZIGHT_MOROCCO /* Arabic */ 0x045F
|
||||
#define TT_MS_LANGID_TAMAZIGHT_MOROCCO_LATIN \
|
||||
TT_MS_LANGID_TAMAZIGHT_ALGERIA
|
||||
#define TT_MS_LANGID_KASHMIRI_PAKISTAN /* Arabic */ 0x0460
|
||||
#define TT_MS_LANGID_KASHMIRI_SASIA 0x0860
|
||||
#define TT_MS_LANGID_KASHMIRI_INDIA \
|
||||
TT_MS_LANGID_KASHMIRI_SASIA
|
||||
#define TT_MS_LANGID_NEPALI_INDIA 0x0861
|
||||
#define TT_MS_LANGID_DIVEHI_MALDIVES \
|
||||
TT_MS_LANGID_DHIVEHI_MALDIVES
|
||||
#define TT_MS_LANGID_EDO_NIGERIA 0x0466
|
||||
#define TT_MS_LANGID_FULFULDE_NIGERIA 0x0467
|
||||
#define TT_MS_LANGID_IBIBIO_NIGERIA 0x0469
|
||||
#define TT_MS_LANGID_SEPEDI_SOUTH_AFRICA \
|
||||
TT_MS_LANGID_SESOTHO_SA_LEBOA_SOUTH_AFRICA
|
||||
#define TT_MS_LANGID_SOTHO_SOUTHERN_SOUTH_AFRICA \
|
||||
TT_MS_LANGID_SESOTHO_SA_LEBOA_SOUTH_AFRICA
|
||||
#define TT_MS_LANGID_KANURI_NIGERIA 0x0471
|
||||
#define TT_MS_LANGID_OROMO_ETHIOPIA 0x0472
|
||||
#define TT_MS_LANGID_TIGRIGNA_ETHIOPIA 0x0473
|
||||
#define TT_MS_LANGID_TIGRIGNA_ERYTHREA 0x0873
|
||||
#define TT_MS_LANGID_TIGRIGNA_ERYTREA \
|
||||
TT_MS_LANGID_TIGRIGNA_ERYTHREA
|
||||
#define TT_MS_LANGID_GUARANI_PARAGUAY 0x0474
|
||||
#define TT_MS_LANGID_HAWAIIAN_UNITED_STATES 0x0475
|
||||
#define TT_MS_LANGID_LATIN 0x0476
|
||||
#define TT_MS_LANGID_SOMALI_SOMALIA 0x0477
|
||||
#define TT_MS_LANGID_YI_CHINA \
|
||||
TT_MS_LANGID_YI_PRC
|
||||
#define TT_MS_LANGID_PAPIAMENTU_NETHERLANDS_ANTILLES 0x0479
|
||||
#define TT_MS_LANGID_UIGHUR_CHINA \
|
||||
TT_MS_LANGID_UIGHUR_PRC
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* @enum:
|
||||
* TT_NAME_ID_XXX
|
||||
*
|
||||
* @description:
|
||||
* Possible values of the `name' identifier field in the name records of
|
||||
* an SFNT `name' table. These values are platform independent.
|
||||
*/
|
||||
|
||||
#define TT_NAME_ID_COPYRIGHT 0
|
||||
#define TT_NAME_ID_FONT_FAMILY 1
|
||||
#define TT_NAME_ID_FONT_SUBFAMILY 2
|
||||
#define TT_NAME_ID_UNIQUE_ID 3
|
||||
#define TT_NAME_ID_FULL_NAME 4
|
||||
#define TT_NAME_ID_VERSION_STRING 5
|
||||
#define TT_NAME_ID_PS_NAME 6
|
||||
#define TT_NAME_ID_TRADEMARK 7
|
||||
|
||||
/* the following values are from the OpenType spec */
|
||||
#define TT_NAME_ID_MANUFACTURER 8
|
||||
#define TT_NAME_ID_DESIGNER 9
|
||||
#define TT_NAME_ID_DESCRIPTION 10
|
||||
#define TT_NAME_ID_VENDOR_URL 11
|
||||
#define TT_NAME_ID_DESIGNER_URL 12
|
||||
#define TT_NAME_ID_LICENSE 13
|
||||
#define TT_NAME_ID_LICENSE_URL 14
|
||||
/* number 15 is reserved */
|
||||
#define TT_NAME_ID_TYPOGRAPHIC_FAMILY 16
|
||||
#define TT_NAME_ID_TYPOGRAPHIC_SUBFAMILY 17
|
||||
#define TT_NAME_ID_MAC_FULL_NAME 18
|
||||
|
||||
/* The following code is new as of 2000-01-21 */
|
||||
#define TT_NAME_ID_SAMPLE_TEXT 19
|
||||
|
||||
/* This is new in OpenType 1.3 */
|
||||
#define TT_NAME_ID_CID_FINDFONT_NAME 20
|
||||
|
||||
/* This is new in OpenType 1.5 */
|
||||
#define TT_NAME_ID_WWS_FAMILY 21
|
||||
#define TT_NAME_ID_WWS_SUBFAMILY 22
|
||||
|
||||
/* This is new in OpenType 1.7 */
|
||||
#define TT_NAME_ID_LIGHT_BACKGROUND 23
|
||||
#define TT_NAME_ID_DARK_BACKGROUND 24
|
||||
|
||||
/* This is new in OpenType 1.8 */
|
||||
#define TT_NAME_ID_VARIATIONS_PREFIX 25
|
||||
|
||||
/* these two values are deprecated */
|
||||
#define TT_NAME_ID_PREFERRED_FAMILY TT_NAME_ID_TYPOGRAPHIC_FAMILY
|
||||
#define TT_NAME_ID_PREFERRED_SUBFAMILY TT_NAME_ID_TYPOGRAPHIC_SUBFAMILY
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* @enum:
|
||||
* TT_UCR_XXX
|
||||
*
|
||||
* @description:
|
||||
* Possible bit mask values for the `ulUnicodeRangeX' fields in an SFNT
|
||||
* `OS/2' table.
|
||||
*/
|
||||
|
||||
/* ulUnicodeRange1 */
|
||||
/* --------------- */
|
||||
|
||||
/* Bit 0 Basic Latin */
|
||||
#define TT_UCR_BASIC_LATIN (1L << 0) /* U+0020-U+007E */
|
||||
/* Bit 1 C1 Controls and Latin-1 Supplement */
|
||||
#define TT_UCR_LATIN1_SUPPLEMENT (1L << 1) /* U+0080-U+00FF */
|
||||
/* Bit 2 Latin Extended-A */
|
||||
#define TT_UCR_LATIN_EXTENDED_A (1L << 2) /* U+0100-U+017F */
|
||||
/* Bit 3 Latin Extended-B */
|
||||
#define TT_UCR_LATIN_EXTENDED_B (1L << 3) /* U+0180-U+024F */
|
||||
/* Bit 4 IPA Extensions */
|
||||
/* Phonetic Extensions */
|
||||
/* Phonetic Extensions Supplement */
|
||||
#define TT_UCR_IPA_EXTENSIONS (1L << 4) /* U+0250-U+02AF */
|
||||
/* U+1D00-U+1D7F */
|
||||
/* U+1D80-U+1DBF */
|
||||
/* Bit 5 Spacing Modifier Letters */
|
||||
/* Modifier Tone Letters */
|
||||
#define TT_UCR_SPACING_MODIFIER (1L << 5) /* U+02B0-U+02FF */
|
||||
/* U+A700-U+A71F */
|
||||
/* Bit 6 Combining Diacritical Marks */
|
||||
/* Combining Diacritical Marks Supplement */
|
||||
#define TT_UCR_COMBINING_DIACRITICAL_MARKS (1L << 6) /* U+0300-U+036F */
|
||||
/* U+1DC0-U+1DFF */
|
||||
/* Bit 7 Greek and Coptic */
|
||||
#define TT_UCR_GREEK (1L << 7) /* U+0370-U+03FF */
|
||||
/* Bit 8 Coptic */
|
||||
#define TT_UCR_COPTIC (1L << 8) /* U+2C80-U+2CFF */
|
||||
/* Bit 9 Cyrillic */
|
||||
/* Cyrillic Supplement */
|
||||
/* Cyrillic Extended-A */
|
||||
/* Cyrillic Extended-B */
|
||||
#define TT_UCR_CYRILLIC (1L << 9) /* U+0400-U+04FF */
|
||||
/* U+0500-U+052F */
|
||||
/* U+2DE0-U+2DFF */
|
||||
/* U+A640-U+A69F */
|
||||
/* Bit 10 Armenian */
|
||||
#define TT_UCR_ARMENIAN (1L << 10) /* U+0530-U+058F */
|
||||
/* Bit 11 Hebrew */
|
||||
#define TT_UCR_HEBREW (1L << 11) /* U+0590-U+05FF */
|
||||
/* Bit 12 Vai */
|
||||
#define TT_UCR_VAI (1L << 12) /* U+A500-U+A63F */
|
||||
/* Bit 13 Arabic */
|
||||
/* Arabic Supplement */
|
||||
#define TT_UCR_ARABIC (1L << 13) /* U+0600-U+06FF */
|
||||
/* U+0750-U+077F */
|
||||
/* Bit 14 NKo */
|
||||
#define TT_UCR_NKO (1L << 14) /* U+07C0-U+07FF */
|
||||
/* Bit 15 Devanagari */
|
||||
#define TT_UCR_DEVANAGARI (1L << 15) /* U+0900-U+097F */
|
||||
/* Bit 16 Bengali */
|
||||
#define TT_UCR_BENGALI (1L << 16) /* U+0980-U+09FF */
|
||||
/* Bit 17 Gurmukhi */
|
||||
#define TT_UCR_GURMUKHI (1L << 17) /* U+0A00-U+0A7F */
|
||||
/* Bit 18 Gujarati */
|
||||
#define TT_UCR_GUJARATI (1L << 18) /* U+0A80-U+0AFF */
|
||||
/* Bit 19 Oriya */
|
||||
#define TT_UCR_ORIYA (1L << 19) /* U+0B00-U+0B7F */
|
||||
/* Bit 20 Tamil */
|
||||
#define TT_UCR_TAMIL (1L << 20) /* U+0B80-U+0BFF */
|
||||
/* Bit 21 Telugu */
|
||||
#define TT_UCR_TELUGU (1L << 21) /* U+0C00-U+0C7F */
|
||||
/* Bit 22 Kannada */
|
||||
#define TT_UCR_KANNADA (1L << 22) /* U+0C80-U+0CFF */
|
||||
/* Bit 23 Malayalam */
|
||||
#define TT_UCR_MALAYALAM (1L << 23) /* U+0D00-U+0D7F */
|
||||
/* Bit 24 Thai */
|
||||
#define TT_UCR_THAI (1L << 24) /* U+0E00-U+0E7F */
|
||||
/* Bit 25 Lao */
|
||||
#define TT_UCR_LAO (1L << 25) /* U+0E80-U+0EFF */
|
||||
/* Bit 26 Georgian */
|
||||
/* Georgian Supplement */
|
||||
#define TT_UCR_GEORGIAN (1L << 26) /* U+10A0-U+10FF */
|
||||
/* U+2D00-U+2D2F */
|
||||
/* Bit 27 Balinese */
|
||||
#define TT_UCR_BALINESE (1L << 27) /* U+1B00-U+1B7F */
|
||||
/* Bit 28 Hangul Jamo */
|
||||
#define TT_UCR_HANGUL_JAMO (1L << 28) /* U+1100-U+11FF */
|
||||
/* Bit 29 Latin Extended Additional */
|
||||
/* Latin Extended-C */
|
||||
/* Latin Extended-D */
|
||||
#define TT_UCR_LATIN_EXTENDED_ADDITIONAL (1L << 29) /* U+1E00-U+1EFF */
|
||||
/* U+2C60-U+2C7F */
|
||||
/* U+A720-U+A7FF */
|
||||
/* Bit 30 Greek Extended */
|
||||
#define TT_UCR_GREEK_EXTENDED (1L << 30) /* U+1F00-U+1FFF */
|
||||
/* Bit 31 General Punctuation */
|
||||
/* Supplemental Punctuation */
|
||||
#define TT_UCR_GENERAL_PUNCTUATION (1L << 31) /* U+2000-U+206F */
|
||||
/* U+2E00-U+2E7F */
|
||||
|
||||
/* ulUnicodeRange2 */
|
||||
/* --------------- */
|
||||
|
||||
/* Bit 32 Superscripts And Subscripts */
|
||||
#define TT_UCR_SUPERSCRIPTS_SUBSCRIPTS (1L << 0) /* U+2070-U+209F */
|
||||
/* Bit 33 Currency Symbols */
|
||||
#define TT_UCR_CURRENCY_SYMBOLS (1L << 1) /* U+20A0-U+20CF */
|
||||
/* Bit 34 Combining Diacritical Marks For Symbols */
|
||||
#define TT_UCR_COMBINING_DIACRITICAL_MARKS_SYMB \
|
||||
(1L << 2) /* U+20D0-U+20FF */
|
||||
/* Bit 35 Letterlike Symbols */
|
||||
#define TT_UCR_LETTERLIKE_SYMBOLS (1L << 3) /* U+2100-U+214F */
|
||||
/* Bit 36 Number Forms */
|
||||
#define TT_UCR_NUMBER_FORMS (1L << 4) /* U+2150-U+218F */
|
||||
/* Bit 37 Arrows */
|
||||
/* Supplemental Arrows-A */
|
||||
/* Supplemental Arrows-B */
|
||||
/* Miscellaneous Symbols and Arrows */
|
||||
#define TT_UCR_ARROWS (1L << 5) /* U+2190-U+21FF */
|
||||
/* U+27F0-U+27FF */
|
||||
/* U+2900-U+297F */
|
||||
/* U+2B00-U+2BFF */
|
||||
/* Bit 38 Mathematical Operators */
|
||||
/* Supplemental Mathematical Operators */
|
||||
/* Miscellaneous Mathematical Symbols-A */
|
||||
/* Miscellaneous Mathematical Symbols-B */
|
||||
#define TT_UCR_MATHEMATICAL_OPERATORS (1L << 6) /* U+2200-U+22FF */
|
||||
/* U+2A00-U+2AFF */
|
||||
/* U+27C0-U+27EF */
|
||||
/* U+2980-U+29FF */
|
||||
/* Bit 39 Miscellaneous Technical */
|
||||
#define TT_UCR_MISCELLANEOUS_TECHNICAL (1L << 7) /* U+2300-U+23FF */
|
||||
/* Bit 40 Control Pictures */
|
||||
#define TT_UCR_CONTROL_PICTURES (1L << 8) /* U+2400-U+243F */
|
||||
/* Bit 41 Optical Character Recognition */
|
||||
#define TT_UCR_OCR (1L << 9) /* U+2440-U+245F */
|
||||
/* Bit 42 Enclosed Alphanumerics */
|
||||
#define TT_UCR_ENCLOSED_ALPHANUMERICS (1L << 10) /* U+2460-U+24FF */
|
||||
/* Bit 43 Box Drawing */
|
||||
#define TT_UCR_BOX_DRAWING (1L << 11) /* U+2500-U+257F */
|
||||
/* Bit 44 Block Elements */
|
||||
#define TT_UCR_BLOCK_ELEMENTS (1L << 12) /* U+2580-U+259F */
|
||||
/* Bit 45 Geometric Shapes */
|
||||
#define TT_UCR_GEOMETRIC_SHAPES (1L << 13) /* U+25A0-U+25FF */
|
||||
/* Bit 46 Miscellaneous Symbols */
|
||||
#define TT_UCR_MISCELLANEOUS_SYMBOLS (1L << 14) /* U+2600-U+26FF */
|
||||
/* Bit 47 Dingbats */
|
||||
#define TT_UCR_DINGBATS (1L << 15) /* U+2700-U+27BF */
|
||||
/* Bit 48 CJK Symbols and Punctuation */
|
||||
#define TT_UCR_CJK_SYMBOLS (1L << 16) /* U+3000-U+303F */
|
||||
/* Bit 49 Hiragana */
|
||||
#define TT_UCR_HIRAGANA (1L << 17) /* U+3040-U+309F */
|
||||
/* Bit 50 Katakana */
|
||||
/* Katakana Phonetic Extensions */
|
||||
#define TT_UCR_KATAKANA (1L << 18) /* U+30A0-U+30FF */
|
||||
/* U+31F0-U+31FF */
|
||||
/* Bit 51 Bopomofo */
|
||||
/* Bopomofo Extended */
|
||||
#define TT_UCR_BOPOMOFO (1L << 19) /* U+3100-U+312F */
|
||||
/* U+31A0-U+31BF */
|
||||
/* Bit 52 Hangul Compatibility Jamo */
|
||||
#define TT_UCR_HANGUL_COMPATIBILITY_JAMO (1L << 20) /* U+3130-U+318F */
|
||||
/* Bit 53 Phags-Pa */
|
||||
#define TT_UCR_CJK_MISC (1L << 21) /* U+A840-U+A87F */
|
||||
#define TT_UCR_KANBUN TT_UCR_CJK_MISC /* deprecated */
|
||||
#define TT_UCR_PHAGSPA
|
||||
/* Bit 54 Enclosed CJK Letters and Months */
|
||||
#define TT_UCR_ENCLOSED_CJK_LETTERS_MONTHS (1L << 22) /* U+3200-U+32FF */
|
||||
/* Bit 55 CJK Compatibility */
|
||||
#define TT_UCR_CJK_COMPATIBILITY (1L << 23) /* U+3300-U+33FF */
|
||||
/* Bit 56 Hangul Syllables */
|
||||
#define TT_UCR_HANGUL (1L << 24) /* U+AC00-U+D7A3 */
|
||||
/* Bit 57 High Surrogates */
|
||||
/* High Private Use Surrogates */
|
||||
/* Low Surrogates */
|
||||
|
||||
/* According to OpenType specs v.1.3+, */
|
||||
/* setting bit 57 implies that there is */
|
||||
/* at least one codepoint beyond the */
|
||||
/* Basic Multilingual Plane that is */
|
||||
/* supported by this font. So it really */
|
||||
/* means >= U+10000. */
|
||||
#define TT_UCR_SURROGATES (1L << 25) /* U+D800-U+DB7F */
|
||||
/* U+DB80-U+DBFF */
|
||||
/* U+DC00-U+DFFF */
|
||||
#define TT_UCR_NON_PLANE_0 TT_UCR_SURROGATES
|
||||
/* Bit 58 Phoenician */
|
||||
#define TT_UCR_PHOENICIAN (1L << 26) /*U+10900-U+1091F*/
|
||||
/* Bit 59 CJK Unified Ideographs */
|
||||
/* CJK Radicals Supplement */
|
||||
/* Kangxi Radicals */
|
||||
/* Ideographic Description Characters */
|
||||
/* CJK Unified Ideographs Extension A */
|
||||
/* CJK Unified Ideographs Extension B */
|
||||
/* Kanbun */
|
||||
#define TT_UCR_CJK_UNIFIED_IDEOGRAPHS (1L << 27) /* U+4E00-U+9FFF */
|
||||
/* U+2E80-U+2EFF */
|
||||
/* U+2F00-U+2FDF */
|
||||
/* U+2FF0-U+2FFF */
|
||||
/* U+3400-U+4DB5 */
|
||||
/*U+20000-U+2A6DF*/
|
||||
/* U+3190-U+319F */
|
||||
/* Bit 60 Private Use */
|
||||
#define TT_UCR_PRIVATE_USE (1L << 28) /* U+E000-U+F8FF */
|
||||
/* Bit 61 CJK Strokes */
|
||||
/* CJK Compatibility Ideographs */
|
||||
/* CJK Compatibility Ideographs Supplement */
|
||||
#define TT_UCR_CJK_COMPATIBILITY_IDEOGRAPHS (1L << 29) /* U+31C0-U+31EF */
|
||||
/* U+F900-U+FAFF */
|
||||
/*U+2F800-U+2FA1F*/
|
||||
/* Bit 62 Alphabetic Presentation Forms */
|
||||
#define TT_UCR_ALPHABETIC_PRESENTATION_FORMS (1L << 30) /* U+FB00-U+FB4F */
|
||||
/* Bit 63 Arabic Presentation Forms-A */
|
||||
#define TT_UCR_ARABIC_PRESENTATION_FORMS_A (1L << 31) /* U+FB50-U+FDFF */
|
||||
|
||||
/* ulUnicodeRange3 */
|
||||
/* --------------- */
|
||||
|
||||
/* Bit 64 Combining Half Marks */
|
||||
#define TT_UCR_COMBINING_HALF_MARKS (1L << 0) /* U+FE20-U+FE2F */
|
||||
/* Bit 65 Vertical forms */
|
||||
/* CJK Compatibility Forms */
|
||||
#define TT_UCR_CJK_COMPATIBILITY_FORMS (1L << 1) /* U+FE10-U+FE1F */
|
||||
/* U+FE30-U+FE4F */
|
||||
/* Bit 66 Small Form Variants */
|
||||
#define TT_UCR_SMALL_FORM_VARIANTS (1L << 2) /* U+FE50-U+FE6F */
|
||||
/* Bit 67 Arabic Presentation Forms-B */
|
||||
#define TT_UCR_ARABIC_PRESENTATION_FORMS_B (1L << 3) /* U+FE70-U+FEFE */
|
||||
/* Bit 68 Halfwidth and Fullwidth Forms */
|
||||
#define TT_UCR_HALFWIDTH_FULLWIDTH_FORMS (1L << 4) /* U+FF00-U+FFEF */
|
||||
/* Bit 69 Specials */
|
||||
#define TT_UCR_SPECIALS (1L << 5) /* U+FFF0-U+FFFD */
|
||||
/* Bit 70 Tibetan */
|
||||
#define TT_UCR_TIBETAN (1L << 6) /* U+0F00-U+0FFF */
|
||||
/* Bit 71 Syriac */
|
||||
#define TT_UCR_SYRIAC (1L << 7) /* U+0700-U+074F */
|
||||
/* Bit 72 Thaana */
|
||||
#define TT_UCR_THAANA (1L << 8) /* U+0780-U+07BF */
|
||||
/* Bit 73 Sinhala */
|
||||
#define TT_UCR_SINHALA (1L << 9) /* U+0D80-U+0DFF */
|
||||
/* Bit 74 Myanmar */
|
||||
#define TT_UCR_MYANMAR (1L << 10) /* U+1000-U+109F */
|
||||
/* Bit 75 Ethiopic */
|
||||
/* Ethiopic Supplement */
|
||||
/* Ethiopic Extended */
|
||||
#define TT_UCR_ETHIOPIC (1L << 11) /* U+1200-U+137F */
|
||||
/* U+1380-U+139F */
|
||||
/* U+2D80-U+2DDF */
|
||||
/* Bit 76 Cherokee */
|
||||
#define TT_UCR_CHEROKEE (1L << 12) /* U+13A0-U+13FF */
|
||||
/* Bit 77 Unified Canadian Aboriginal Syllabics */
|
||||
#define TT_UCR_CANADIAN_ABORIGINAL_SYLLABICS (1L << 13) /* U+1400-U+167F */
|
||||
/* Bit 78 Ogham */
|
||||
#define TT_UCR_OGHAM (1L << 14) /* U+1680-U+169F */
|
||||
/* Bit 79 Runic */
|
||||
#define TT_UCR_RUNIC (1L << 15) /* U+16A0-U+16FF */
|
||||
/* Bit 80 Khmer */
|
||||
/* Khmer Symbols */
|
||||
#define TT_UCR_KHMER (1L << 16) /* U+1780-U+17FF */
|
||||
/* U+19E0-U+19FF */
|
||||
/* Bit 81 Mongolian */
|
||||
#define TT_UCR_MONGOLIAN (1L << 17) /* U+1800-U+18AF */
|
||||
/* Bit 82 Braille Patterns */
|
||||
#define TT_UCR_BRAILLE (1L << 18) /* U+2800-U+28FF */
|
||||
/* Bit 83 Yi Syllables */
|
||||
/* Yi Radicals */
|
||||
#define TT_UCR_YI (1L << 19) /* U+A000-U+A48F */
|
||||
/* U+A490-U+A4CF */
|
||||
/* Bit 84 Tagalog */
|
||||
/* Hanunoo */
|
||||
/* Buhid */
|
||||
/* Tagbanwa */
|
||||
#define TT_UCR_PHILIPPINE (1L << 20) /* U+1700-U+171F */
|
||||
/* U+1720-U+173F */
|
||||
/* U+1740-U+175F */
|
||||
/* U+1760-U+177F */
|
||||
/* Bit 85 Old Italic */
|
||||
#define TT_UCR_OLD_ITALIC (1L << 21) /*U+10300-U+1032F*/
|
||||
/* Bit 86 Gothic */
|
||||
#define TT_UCR_GOTHIC (1L << 22) /*U+10330-U+1034F*/
|
||||
/* Bit 87 Deseret */
|
||||
#define TT_UCR_DESERET (1L << 23) /*U+10400-U+1044F*/
|
||||
/* Bit 88 Byzantine Musical Symbols */
|
||||
/* Musical Symbols */
|
||||
/* Ancient Greek Musical Notation */
|
||||
#define TT_UCR_MUSICAL_SYMBOLS (1L << 24) /*U+1D000-U+1D0FF*/
|
||||
/*U+1D100-U+1D1FF*/
|
||||
/*U+1D200-U+1D24F*/
|
||||
/* Bit 89 Mathematical Alphanumeric Symbols */
|
||||
#define TT_UCR_MATH_ALPHANUMERIC_SYMBOLS (1L << 25) /*U+1D400-U+1D7FF*/
|
||||
/* Bit 90 Private Use (plane 15) */
|
||||
/* Private Use (plane 16) */
|
||||
#define TT_UCR_PRIVATE_USE_SUPPLEMENTARY (1L << 26) /*U+F0000-U+FFFFD*/
|
||||
/*U+100000-U+10FFFD*/
|
||||
/* Bit 91 Variation Selectors */
|
||||
/* Variation Selectors Supplement */
|
||||
#define TT_UCR_VARIATION_SELECTORS (1L << 27) /* U+FE00-U+FE0F */
|
||||
/*U+E0100-U+E01EF*/
|
||||
/* Bit 92 Tags */
|
||||
#define TT_UCR_TAGS (1L << 28) /*U+E0000-U+E007F*/
|
||||
/* Bit 93 Limbu */
|
||||
#define TT_UCR_LIMBU (1L << 29) /* U+1900-U+194F */
|
||||
/* Bit 94 Tai Le */
|
||||
#define TT_UCR_TAI_LE (1L << 30) /* U+1950-U+197F */
|
||||
/* Bit 95 New Tai Lue */
|
||||
#define TT_UCR_NEW_TAI_LUE (1L << 31) /* U+1980-U+19DF */
|
||||
|
||||
/* ulUnicodeRange4 */
|
||||
/* --------------- */
|
||||
|
||||
/* Bit 96 Buginese */
|
||||
#define TT_UCR_BUGINESE (1L << 0) /* U+1A00-U+1A1F */
|
||||
/* Bit 97 Glagolitic */
|
||||
#define TT_UCR_GLAGOLITIC (1L << 1) /* U+2C00-U+2C5F */
|
||||
/* Bit 98 Tifinagh */
|
||||
#define TT_UCR_TIFINAGH (1L << 2) /* U+2D30-U+2D7F */
|
||||
/* Bit 99 Yijing Hexagram Symbols */
|
||||
#define TT_UCR_YIJING (1L << 3) /* U+4DC0-U+4DFF */
|
||||
/* Bit 100 Syloti Nagri */
|
||||
#define TT_UCR_SYLOTI_NAGRI (1L << 4) /* U+A800-U+A82F */
|
||||
/* Bit 101 Linear B Syllabary */
|
||||
/* Linear B Ideograms */
|
||||
/* Aegean Numbers */
|
||||
#define TT_UCR_LINEAR_B (1L << 5) /*U+10000-U+1007F*/
|
||||
/*U+10080-U+100FF*/
|
||||
/*U+10100-U+1013F*/
|
||||
/* Bit 102 Ancient Greek Numbers */
|
||||
#define TT_UCR_ANCIENT_GREEK_NUMBERS (1L << 6) /*U+10140-U+1018F*/
|
||||
/* Bit 103 Ugaritic */
|
||||
#define TT_UCR_UGARITIC (1L << 7) /*U+10380-U+1039F*/
|
||||
/* Bit 104 Old Persian */
|
||||
#define TT_UCR_OLD_PERSIAN (1L << 8) /*U+103A0-U+103DF*/
|
||||
/* Bit 105 Shavian */
|
||||
#define TT_UCR_SHAVIAN (1L << 9) /*U+10450-U+1047F*/
|
||||
/* Bit 106 Osmanya */
|
||||
#define TT_UCR_OSMANYA (1L << 10) /*U+10480-U+104AF*/
|
||||
/* Bit 107 Cypriot Syllabary */
|
||||
#define TT_UCR_CYPRIOT_SYLLABARY (1L << 11) /*U+10800-U+1083F*/
|
||||
/* Bit 108 Kharoshthi */
|
||||
#define TT_UCR_KHAROSHTHI (1L << 12) /*U+10A00-U+10A5F*/
|
||||
/* Bit 109 Tai Xuan Jing Symbols */
|
||||
#define TT_UCR_TAI_XUAN_JING (1L << 13) /*U+1D300-U+1D35F*/
|
||||
/* Bit 110 Cuneiform */
|
||||
/* Cuneiform Numbers and Punctuation */
|
||||
#define TT_UCR_CUNEIFORM (1L << 14) /*U+12000-U+123FF*/
|
||||
/*U+12400-U+1247F*/
|
||||
/* Bit 111 Counting Rod Numerals */
|
||||
#define TT_UCR_COUNTING_ROD_NUMERALS (1L << 15) /*U+1D360-U+1D37F*/
|
||||
/* Bit 112 Sundanese */
|
||||
#define TT_UCR_SUNDANESE (1L << 16) /* U+1B80-U+1BBF */
|
||||
/* Bit 113 Lepcha */
|
||||
#define TT_UCR_LEPCHA (1L << 17) /* U+1C00-U+1C4F */
|
||||
/* Bit 114 Ol Chiki */
|
||||
#define TT_UCR_OL_CHIKI (1L << 18) /* U+1C50-U+1C7F */
|
||||
/* Bit 115 Saurashtra */
|
||||
#define TT_UCR_SAURASHTRA (1L << 19) /* U+A880-U+A8DF */
|
||||
/* Bit 116 Kayah Li */
|
||||
#define TT_UCR_KAYAH_LI (1L << 20) /* U+A900-U+A92F */
|
||||
/* Bit 117 Rejang */
|
||||
#define TT_UCR_REJANG (1L << 21) /* U+A930-U+A95F */
|
||||
/* Bit 118 Cham */
|
||||
#define TT_UCR_CHAM (1L << 22) /* U+AA00-U+AA5F */
|
||||
/* Bit 119 Ancient Symbols */
|
||||
#define TT_UCR_ANCIENT_SYMBOLS (1L << 23) /*U+10190-U+101CF*/
|
||||
/* Bit 120 Phaistos Disc */
|
||||
#define TT_UCR_PHAISTOS_DISC (1L << 24) /*U+101D0-U+101FF*/
|
||||
/* Bit 121 Carian */
|
||||
/* Lycian */
|
||||
/* Lydian */
|
||||
#define TT_UCR_OLD_ANATOLIAN (1L << 25) /*U+102A0-U+102DF*/
|
||||
/*U+10280-U+1029F*/
|
||||
/*U+10920-U+1093F*/
|
||||
/* Bit 122 Domino Tiles */
|
||||
/* Mahjong Tiles */
|
||||
#define TT_UCR_GAME_TILES (1L << 26) /*U+1F030-U+1F09F*/
|
||||
/*U+1F000-U+1F02F*/
|
||||
/* Bit 123-127 Reserved for process-internal usage */
|
||||
|
||||
/* */
|
||||
|
||||
/* for backward compatibility with older FreeType versions */
|
||||
#define TT_UCR_ARABIC_PRESENTATION_A \
|
||||
TT_UCR_ARABIC_PRESENTATION_FORMS_A
|
||||
#define TT_UCR_ARABIC_PRESENTATION_B \
|
||||
TT_UCR_ARABIC_PRESENTATION_FORMS_B
|
||||
|
||||
#define TT_UCR_COMBINING_DIACRITICS \
|
||||
TT_UCR_COMBINING_DIACRITICAL_MARKS
|
||||
#define TT_UCR_COMBINING_DIACRITICS_SYMB \
|
||||
TT_UCR_COMBINING_DIACRITICAL_MARKS_SYMB
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* TTNAMEID_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,846 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* tttables.h */
|
||||
/* */
|
||||
/* Basic SFNT/TrueType tables definitions and interface */
|
||||
/* (specification only). */
|
||||
/* */
|
||||
/* Copyright 1996-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef TTTABLES_H_
|
||||
#define TTTABLES_H_
|
||||
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#ifdef FREETYPE_H
|
||||
#error "freetype.h of FreeType 1 has been loaded!"
|
||||
#error "Please fix the directory search order for header files"
|
||||
#error "so that freetype.h of FreeType 2 is found first."
|
||||
#endif
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Section> */
|
||||
/* truetype_tables */
|
||||
/* */
|
||||
/* <Title> */
|
||||
/* TrueType Tables */
|
||||
/* */
|
||||
/* <Abstract> */
|
||||
/* TrueType specific table types and functions. */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* This section contains definitions of some basic tables specific to */
|
||||
/* TrueType and OpenType as well as some routines used to access and */
|
||||
/* process them. */
|
||||
/* */
|
||||
/* <Order> */
|
||||
/* TT_Header */
|
||||
/* TT_HoriHeader */
|
||||
/* TT_VertHeader */
|
||||
/* TT_OS2 */
|
||||
/* TT_Postscript */
|
||||
/* TT_PCLT */
|
||||
/* TT_MaxProfile */
|
||||
/* */
|
||||
/* FT_Sfnt_Tag */
|
||||
/* FT_Get_Sfnt_Table */
|
||||
/* FT_Load_Sfnt_Table */
|
||||
/* FT_Sfnt_Table_Info */
|
||||
/* */
|
||||
/* FT_Get_CMap_Language_ID */
|
||||
/* FT_Get_CMap_Format */
|
||||
/* */
|
||||
/* FT_PARAM_TAG_UNPATENTED_HINTING */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* TT_Header */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure to model a TrueType font header table. All fields */
|
||||
/* follow the OpenType specification. */
|
||||
/* */
|
||||
typedef struct TT_Header_
|
||||
{
|
||||
FT_Fixed Table_Version;
|
||||
FT_Fixed Font_Revision;
|
||||
|
||||
FT_Long CheckSum_Adjust;
|
||||
FT_Long Magic_Number;
|
||||
|
||||
FT_UShort Flags;
|
||||
FT_UShort Units_Per_EM;
|
||||
|
||||
FT_Long Created [2];
|
||||
FT_Long Modified[2];
|
||||
|
||||
FT_Short xMin;
|
||||
FT_Short yMin;
|
||||
FT_Short xMax;
|
||||
FT_Short yMax;
|
||||
|
||||
FT_UShort Mac_Style;
|
||||
FT_UShort Lowest_Rec_PPEM;
|
||||
|
||||
FT_Short Font_Direction;
|
||||
FT_Short Index_To_Loc_Format;
|
||||
FT_Short Glyph_Data_Format;
|
||||
|
||||
} TT_Header;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* TT_HoriHeader */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure to model a TrueType horizontal header, the `hhea' */
|
||||
/* table, as well as the corresponding horizontal metrics table, */
|
||||
/* `hmtx'. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* Version :: The table version. */
|
||||
/* */
|
||||
/* Ascender :: The font's ascender, i.e., the distance */
|
||||
/* from the baseline to the top-most of all */
|
||||
/* glyph points found in the font. */
|
||||
/* */
|
||||
/* This value is invalid in many fonts, as */
|
||||
/* it is usually set by the font designer, */
|
||||
/* and often reflects only a portion of the */
|
||||
/* glyphs found in the font (maybe ASCII). */
|
||||
/* */
|
||||
/* You should use the `sTypoAscender' field */
|
||||
/* of the `OS/2' table instead if you want */
|
||||
/* the correct one. */
|
||||
/* */
|
||||
/* Descender :: The font's descender, i.e., the distance */
|
||||
/* from the baseline to the bottom-most of */
|
||||
/* all glyph points found in the font. It */
|
||||
/* is negative. */
|
||||
/* */
|
||||
/* This value is invalid in many fonts, as */
|
||||
/* it is usually set by the font designer, */
|
||||
/* and often reflects only a portion of the */
|
||||
/* glyphs found in the font (maybe ASCII). */
|
||||
/* */
|
||||
/* You should use the `sTypoDescender' */
|
||||
/* field of the `OS/2' table instead if you */
|
||||
/* want the correct one. */
|
||||
/* */
|
||||
/* Line_Gap :: The font's line gap, i.e., the distance */
|
||||
/* to add to the ascender and descender to */
|
||||
/* get the BTB, i.e., the */
|
||||
/* baseline-to-baseline distance for the */
|
||||
/* font. */
|
||||
/* */
|
||||
/* advance_Width_Max :: This field is the maximum of all advance */
|
||||
/* widths found in the font. It can be */
|
||||
/* used to compute the maximum width of an */
|
||||
/* arbitrary string of text. */
|
||||
/* */
|
||||
/* min_Left_Side_Bearing :: The minimum left side bearing of all */
|
||||
/* glyphs within the font. */
|
||||
/* */
|
||||
/* min_Right_Side_Bearing :: The minimum right side bearing of all */
|
||||
/* glyphs within the font. */
|
||||
/* */
|
||||
/* xMax_Extent :: The maximum horizontal extent (i.e., the */
|
||||
/* `width' of a glyph's bounding box) for */
|
||||
/* all glyphs in the font. */
|
||||
/* */
|
||||
/* caret_Slope_Rise :: The rise coefficient of the cursor's */
|
||||
/* slope of the cursor (slope=rise/run). */
|
||||
/* */
|
||||
/* caret_Slope_Run :: The run coefficient of the cursor's */
|
||||
/* slope. */
|
||||
/* */
|
||||
/* caret_Offset :: The cursor's offset for slanted fonts. */
|
||||
/* */
|
||||
/* Reserved :: 8~reserved bytes. */
|
||||
/* */
|
||||
/* metric_Data_Format :: Always~0. */
|
||||
/* */
|
||||
/* number_Of_HMetrics :: Number of HMetrics entries in the `hmtx' */
|
||||
/* table -- this value can be smaller than */
|
||||
/* the total number of glyphs in the font. */
|
||||
/* */
|
||||
/* long_metrics :: A pointer into the `hmtx' table. */
|
||||
/* */
|
||||
/* short_metrics :: A pointer into the `hmtx' table. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* For an OpenType variation font, the values of the following fields */
|
||||
/* can change after a call to @FT_Set_Var_Design_Coordinates (and */
|
||||
/* friends) if the font contains an `MVAR' table: `caret_Slope_Rise', */
|
||||
/* `caret_Slope_Run', and `caret_Offset'. */
|
||||
/* */
|
||||
typedef struct TT_HoriHeader_
|
||||
{
|
||||
FT_Fixed Version;
|
||||
FT_Short Ascender;
|
||||
FT_Short Descender;
|
||||
FT_Short Line_Gap;
|
||||
|
||||
FT_UShort advance_Width_Max; /* advance width maximum */
|
||||
|
||||
FT_Short min_Left_Side_Bearing; /* minimum left-sb */
|
||||
FT_Short min_Right_Side_Bearing; /* minimum right-sb */
|
||||
FT_Short xMax_Extent; /* xmax extents */
|
||||
FT_Short caret_Slope_Rise;
|
||||
FT_Short caret_Slope_Run;
|
||||
FT_Short caret_Offset;
|
||||
|
||||
FT_Short Reserved[4];
|
||||
|
||||
FT_Short metric_Data_Format;
|
||||
FT_UShort number_Of_HMetrics;
|
||||
|
||||
/* The following fields are not defined by the OpenType specification */
|
||||
/* but they are used to connect the metrics header to the relevant */
|
||||
/* `hmtx' table. */
|
||||
|
||||
void* long_metrics;
|
||||
void* short_metrics;
|
||||
|
||||
} TT_HoriHeader;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* TT_VertHeader */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure used to model a TrueType vertical header, the `vhea' */
|
||||
/* table, as well as the corresponding vertical metrics table, */
|
||||
/* `vmtx'. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* Version :: The table version. */
|
||||
/* */
|
||||
/* Ascender :: The font's ascender, i.e., the distance */
|
||||
/* from the baseline to the top-most of */
|
||||
/* all glyph points found in the font. */
|
||||
/* */
|
||||
/* This value is invalid in many fonts, as */
|
||||
/* it is usually set by the font designer, */
|
||||
/* and often reflects only a portion of */
|
||||
/* the glyphs found in the font (maybe */
|
||||
/* ASCII). */
|
||||
/* */
|
||||
/* You should use the `sTypoAscender' */
|
||||
/* field of the `OS/2' table instead if */
|
||||
/* you want the correct one. */
|
||||
/* */
|
||||
/* Descender :: The font's descender, i.e., the */
|
||||
/* distance from the baseline to the */
|
||||
/* bottom-most of all glyph points found */
|
||||
/* in the font. It is negative. */
|
||||
/* */
|
||||
/* This value is invalid in many fonts, as */
|
||||
/* it is usually set by the font designer, */
|
||||
/* and often reflects only a portion of */
|
||||
/* the glyphs found in the font (maybe */
|
||||
/* ASCII). */
|
||||
/* */
|
||||
/* You should use the `sTypoDescender' */
|
||||
/* field of the `OS/2' table instead if */
|
||||
/* you want the correct one. */
|
||||
/* */
|
||||
/* Line_Gap :: The font's line gap, i.e., the distance */
|
||||
/* to add to the ascender and descender to */
|
||||
/* get the BTB, i.e., the */
|
||||
/* baseline-to-baseline distance for the */
|
||||
/* font. */
|
||||
/* */
|
||||
/* advance_Height_Max :: This field is the maximum of all */
|
||||
/* advance heights found in the font. It */
|
||||
/* can be used to compute the maximum */
|
||||
/* height of an arbitrary string of text. */
|
||||
/* */
|
||||
/* min_Top_Side_Bearing :: The minimum top side bearing of all */
|
||||
/* glyphs within the font. */
|
||||
/* */
|
||||
/* min_Bottom_Side_Bearing :: The minimum bottom side bearing of all */
|
||||
/* glyphs within the font. */
|
||||
/* */
|
||||
/* yMax_Extent :: The maximum vertical extent (i.e., the */
|
||||
/* `height' of a glyph's bounding box) for */
|
||||
/* all glyphs in the font. */
|
||||
/* */
|
||||
/* caret_Slope_Rise :: The rise coefficient of the cursor's */
|
||||
/* slope of the cursor (slope=rise/run). */
|
||||
/* */
|
||||
/* caret_Slope_Run :: The run coefficient of the cursor's */
|
||||
/* slope. */
|
||||
/* */
|
||||
/* caret_Offset :: The cursor's offset for slanted fonts. */
|
||||
/* */
|
||||
/* Reserved :: 8~reserved bytes. */
|
||||
/* */
|
||||
/* metric_Data_Format :: Always~0. */
|
||||
/* */
|
||||
/* number_Of_VMetrics :: Number of VMetrics entries in the */
|
||||
/* `vmtx' table -- this value can be */
|
||||
/* smaller than the total number of glyphs */
|
||||
/* in the font. */
|
||||
/* */
|
||||
/* long_metrics :: A pointer into the `vmtx' table. */
|
||||
/* */
|
||||
/* short_metrics :: A pointer into the `vmtx' table. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* For an OpenType variation font, the values of the following fields */
|
||||
/* can change after a call to @FT_Set_Var_Design_Coordinates (and */
|
||||
/* friends) if the font contains an `MVAR' table: `Ascender', */
|
||||
/* `Descender', `Line_Gap', `caret_Slope_Rise', `caret_Slope_Run', */
|
||||
/* and `caret_Offset'. */
|
||||
/* */
|
||||
typedef struct TT_VertHeader_
|
||||
{
|
||||
FT_Fixed Version;
|
||||
FT_Short Ascender;
|
||||
FT_Short Descender;
|
||||
FT_Short Line_Gap;
|
||||
|
||||
FT_UShort advance_Height_Max; /* advance height maximum */
|
||||
|
||||
FT_Short min_Top_Side_Bearing; /* minimum top-sb */
|
||||
FT_Short min_Bottom_Side_Bearing; /* minimum bottom-sb */
|
||||
FT_Short yMax_Extent; /* ymax extents */
|
||||
FT_Short caret_Slope_Rise;
|
||||
FT_Short caret_Slope_Run;
|
||||
FT_Short caret_Offset;
|
||||
|
||||
FT_Short Reserved[4];
|
||||
|
||||
FT_Short metric_Data_Format;
|
||||
FT_UShort number_Of_VMetrics;
|
||||
|
||||
/* The following fields are not defined by the OpenType specification */
|
||||
/* but they are used to connect the metrics header to the relevant */
|
||||
/* `vmtx' table. */
|
||||
|
||||
void* long_metrics;
|
||||
void* short_metrics;
|
||||
|
||||
} TT_VertHeader;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* TT_OS2 */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure to model a TrueType `OS/2' table. All fields comply */
|
||||
/* to the OpenType specification. */
|
||||
/* */
|
||||
/* Note that we now support old Mac fonts that do not include an */
|
||||
/* `OS/2' table. In this case, the `version' field is always set to */
|
||||
/* 0xFFFF. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* For an OpenType variation font, the values of the following fields */
|
||||
/* can change after a call to @FT_Set_Var_Design_Coordinates (and */
|
||||
/* friends) if the font contains an `MVAR' table: `sCapHeight', */
|
||||
/* `sTypoAscender', `sTypoDescender', `sTypoLineGap', `sxHeight', */
|
||||
/* `usWinAscent', `usWinDescent', `yStrikeoutPosition', */
|
||||
/* `yStrikeoutSize', `ySubscriptXOffset', `ySubScriptXSize', */
|
||||
/* `ySubscriptYOffset', `ySubscriptYSize', `ySuperscriptXOffset', */
|
||||
/* `ySuperscriptXSize', `ySuperscriptYOffset', and */
|
||||
/* `ySuperscriptYSize'. */
|
||||
/* */
|
||||
/* Possible values for bits in the `ulUnicodeRangeX' fields are given */
|
||||
/* by the @TT_UCR_XXX macros. */
|
||||
/* */
|
||||
|
||||
typedef struct TT_OS2_
|
||||
{
|
||||
FT_UShort version; /* 0x0001 - more or 0xFFFF */
|
||||
FT_Short xAvgCharWidth;
|
||||
FT_UShort usWeightClass;
|
||||
FT_UShort usWidthClass;
|
||||
FT_UShort fsType;
|
||||
FT_Short ySubscriptXSize;
|
||||
FT_Short ySubscriptYSize;
|
||||
FT_Short ySubscriptXOffset;
|
||||
FT_Short ySubscriptYOffset;
|
||||
FT_Short ySuperscriptXSize;
|
||||
FT_Short ySuperscriptYSize;
|
||||
FT_Short ySuperscriptXOffset;
|
||||
FT_Short ySuperscriptYOffset;
|
||||
FT_Short yStrikeoutSize;
|
||||
FT_Short yStrikeoutPosition;
|
||||
FT_Short sFamilyClass;
|
||||
|
||||
FT_Byte panose[10];
|
||||
|
||||
FT_ULong ulUnicodeRange1; /* Bits 0-31 */
|
||||
FT_ULong ulUnicodeRange2; /* Bits 32-63 */
|
||||
FT_ULong ulUnicodeRange3; /* Bits 64-95 */
|
||||
FT_ULong ulUnicodeRange4; /* Bits 96-127 */
|
||||
|
||||
FT_Char achVendID[4];
|
||||
|
||||
FT_UShort fsSelection;
|
||||
FT_UShort usFirstCharIndex;
|
||||
FT_UShort usLastCharIndex;
|
||||
FT_Short sTypoAscender;
|
||||
FT_Short sTypoDescender;
|
||||
FT_Short sTypoLineGap;
|
||||
FT_UShort usWinAscent;
|
||||
FT_UShort usWinDescent;
|
||||
|
||||
/* only version 1 and higher: */
|
||||
|
||||
FT_ULong ulCodePageRange1; /* Bits 0-31 */
|
||||
FT_ULong ulCodePageRange2; /* Bits 32-63 */
|
||||
|
||||
/* only version 2 and higher: */
|
||||
|
||||
FT_Short sxHeight;
|
||||
FT_Short sCapHeight;
|
||||
FT_UShort usDefaultChar;
|
||||
FT_UShort usBreakChar;
|
||||
FT_UShort usMaxContext;
|
||||
|
||||
/* only version 5 and higher: */
|
||||
|
||||
FT_UShort usLowerOpticalPointSize; /* in twips (1/20th points) */
|
||||
FT_UShort usUpperOpticalPointSize; /* in twips (1/20th points) */
|
||||
|
||||
} TT_OS2;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* TT_Postscript */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure to model a TrueType `post' table. All fields comply */
|
||||
/* to the OpenType specification. This structure does not reference */
|
||||
/* a font's PostScript glyph names; use @FT_Get_Glyph_Name to */
|
||||
/* retrieve them. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* For an OpenType variation font, the values of the following fields */
|
||||
/* can change after a call to @FT_Set_Var_Design_Coordinates (and */
|
||||
/* friends) if the font contains an `MVAR' table: `underlinePosition' */
|
||||
/* and `underlineThickness'. */
|
||||
/* */
|
||||
typedef struct TT_Postscript_
|
||||
{
|
||||
FT_Fixed FormatType;
|
||||
FT_Fixed italicAngle;
|
||||
FT_Short underlinePosition;
|
||||
FT_Short underlineThickness;
|
||||
FT_ULong isFixedPitch;
|
||||
FT_ULong minMemType42;
|
||||
FT_ULong maxMemType42;
|
||||
FT_ULong minMemType1;
|
||||
FT_ULong maxMemType1;
|
||||
|
||||
/* Glyph names follow in the `post' table, but we don't */
|
||||
/* load them by default. */
|
||||
|
||||
} TT_Postscript;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* TT_PCLT */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* A structure to model a TrueType `PCLT' table. All fields comply */
|
||||
/* to the OpenType specification. */
|
||||
/* */
|
||||
typedef struct TT_PCLT_
|
||||
{
|
||||
FT_Fixed Version;
|
||||
FT_ULong FontNumber;
|
||||
FT_UShort Pitch;
|
||||
FT_UShort xHeight;
|
||||
FT_UShort Style;
|
||||
FT_UShort TypeFamily;
|
||||
FT_UShort CapHeight;
|
||||
FT_UShort SymbolSet;
|
||||
FT_Char TypeFace[16];
|
||||
FT_Char CharacterComplement[8];
|
||||
FT_Char FileName[6];
|
||||
FT_Char StrokeWeight;
|
||||
FT_Char WidthType;
|
||||
FT_Byte SerifStyle;
|
||||
FT_Byte Reserved;
|
||||
|
||||
} TT_PCLT;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Struct> */
|
||||
/* TT_MaxProfile */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* The maximum profile (`maxp') table contains many max values, which */
|
||||
/* can be used to pre-allocate arrays for speeding up glyph loading */
|
||||
/* and hinting. */
|
||||
/* */
|
||||
/* <Fields> */
|
||||
/* version :: The version number. */
|
||||
/* */
|
||||
/* numGlyphs :: The number of glyphs in this TrueType */
|
||||
/* font. */
|
||||
/* */
|
||||
/* maxPoints :: The maximum number of points in a */
|
||||
/* non-composite TrueType glyph. See also */
|
||||
/* `maxCompositePoints'. */
|
||||
/* */
|
||||
/* maxContours :: The maximum number of contours in a */
|
||||
/* non-composite TrueType glyph. See also */
|
||||
/* `maxCompositeContours'. */
|
||||
/* */
|
||||
/* maxCompositePoints :: The maximum number of points in a */
|
||||
/* composite TrueType glyph. See also */
|
||||
/* `maxPoints'. */
|
||||
/* */
|
||||
/* maxCompositeContours :: The maximum number of contours in a */
|
||||
/* composite TrueType glyph. See also */
|
||||
/* `maxContours'. */
|
||||
/* */
|
||||
/* maxZones :: The maximum number of zones used for */
|
||||
/* glyph hinting. */
|
||||
/* */
|
||||
/* maxTwilightPoints :: The maximum number of points in the */
|
||||
/* twilight zone used for glyph hinting. */
|
||||
/* */
|
||||
/* maxStorage :: The maximum number of elements in the */
|
||||
/* storage area used for glyph hinting. */
|
||||
/* */
|
||||
/* maxFunctionDefs :: The maximum number of function */
|
||||
/* definitions in the TrueType bytecode for */
|
||||
/* this font. */
|
||||
/* */
|
||||
/* maxInstructionDefs :: The maximum number of instruction */
|
||||
/* definitions in the TrueType bytecode for */
|
||||
/* this font. */
|
||||
/* */
|
||||
/* maxStackElements :: The maximum number of stack elements used */
|
||||
/* during bytecode interpretation. */
|
||||
/* */
|
||||
/* maxSizeOfInstructions :: The maximum number of TrueType opcodes */
|
||||
/* used for glyph hinting. */
|
||||
/* */
|
||||
/* maxComponentElements :: The maximum number of simple (i.e., non- */
|
||||
/* composite) glyphs in a composite glyph. */
|
||||
/* */
|
||||
/* maxComponentDepth :: The maximum nesting depth of composite */
|
||||
/* glyphs. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* This structure is only used during font loading. */
|
||||
/* */
|
||||
typedef struct TT_MaxProfile_
|
||||
{
|
||||
FT_Fixed version;
|
||||
FT_UShort numGlyphs;
|
||||
FT_UShort maxPoints;
|
||||
FT_UShort maxContours;
|
||||
FT_UShort maxCompositePoints;
|
||||
FT_UShort maxCompositeContours;
|
||||
FT_UShort maxZones;
|
||||
FT_UShort maxTwilightPoints;
|
||||
FT_UShort maxStorage;
|
||||
FT_UShort maxFunctionDefs;
|
||||
FT_UShort maxInstructionDefs;
|
||||
FT_UShort maxStackElements;
|
||||
FT_UShort maxSizeOfInstructions;
|
||||
FT_UShort maxComponentElements;
|
||||
FT_UShort maxComponentDepth;
|
||||
|
||||
} TT_MaxProfile;
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Enum> */
|
||||
/* FT_Sfnt_Tag */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* An enumeration to specify indices of SFNT tables loaded and parsed */
|
||||
/* by FreeType during initialization of an SFNT font. Used in the */
|
||||
/* @FT_Get_Sfnt_Table API function. */
|
||||
/* */
|
||||
/* <Values> */
|
||||
/* FT_SFNT_HEAD :: To access the font's @TT_Header structure. */
|
||||
/* */
|
||||
/* FT_SFNT_MAXP :: To access the font's @TT_MaxProfile structure. */
|
||||
/* */
|
||||
/* FT_SFNT_OS2 :: To access the font's @TT_OS2 structure. */
|
||||
/* */
|
||||
/* FT_SFNT_HHEA :: To access the font's @TT_HoriHeader structure. */
|
||||
/* */
|
||||
/* FT_SFNT_VHEA :: To access the font's @TT_VertHeader structure. */
|
||||
/* */
|
||||
/* FT_SFNT_POST :: To access the font's @TT_Postscript structure. */
|
||||
/* */
|
||||
/* FT_SFNT_PCLT :: To access the font's @TT_PCLT structure. */
|
||||
/* */
|
||||
typedef enum FT_Sfnt_Tag_
|
||||
{
|
||||
FT_SFNT_HEAD,
|
||||
FT_SFNT_MAXP,
|
||||
FT_SFNT_OS2,
|
||||
FT_SFNT_HHEA,
|
||||
FT_SFNT_VHEA,
|
||||
FT_SFNT_POST,
|
||||
FT_SFNT_PCLT,
|
||||
|
||||
FT_SFNT_MAX
|
||||
|
||||
} FT_Sfnt_Tag;
|
||||
|
||||
/* these constants are deprecated; use the corresponding `FT_Sfnt_Tag' */
|
||||
/* values instead */
|
||||
#define ft_sfnt_head FT_SFNT_HEAD
|
||||
#define ft_sfnt_maxp FT_SFNT_MAXP
|
||||
#define ft_sfnt_os2 FT_SFNT_OS2
|
||||
#define ft_sfnt_hhea FT_SFNT_HHEA
|
||||
#define ft_sfnt_vhea FT_SFNT_VHEA
|
||||
#define ft_sfnt_post FT_SFNT_POST
|
||||
#define ft_sfnt_pclt FT_SFNT_PCLT
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_Sfnt_Table */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Return a pointer to a given SFNT table stored within a face. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* face :: A handle to the source. */
|
||||
/* */
|
||||
/* tag :: The index of the SFNT table. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* A type-less pointer to the table. This will be NULL in case of */
|
||||
/* error, or if the corresponding table was not found *OR* loaded */
|
||||
/* from the file. */
|
||||
/* */
|
||||
/* Use a typecast according to `tag' to access the structure */
|
||||
/* elements. */
|
||||
/* */
|
||||
/* <Note> */
|
||||
/* The table is owned by the face object and disappears with it. */
|
||||
/* */
|
||||
/* This function is only useful to access SFNT tables that are loaded */
|
||||
/* by the sfnt, truetype, and opentype drivers. See @FT_Sfnt_Tag for */
|
||||
/* a list. */
|
||||
/* */
|
||||
/* Here an example how to access the `vhea' table: */
|
||||
/* */
|
||||
/* { */
|
||||
/* TT_VertHeader* vert_header; */
|
||||
/* */
|
||||
/* */
|
||||
/* vert_header = */
|
||||
/* (TT_VertHeader*)FT_Get_Sfnt_Table( face, FT_SFNT_VHEA ); */
|
||||
/* } */
|
||||
/* */
|
||||
FT_EXPORT( void* )
|
||||
FT_Get_Sfnt_Table( FT_Face face,
|
||||
FT_Sfnt_Tag tag );
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Load_Sfnt_Table
|
||||
*
|
||||
* @description:
|
||||
* Load any SFNT font table into client memory.
|
||||
*
|
||||
* @input:
|
||||
* face ::
|
||||
* A handle to the source face.
|
||||
*
|
||||
* tag ::
|
||||
* The four-byte tag of the table to load. Use value~0 if you want
|
||||
* to access the whole font file. Otherwise, you can use one of the
|
||||
* definitions found in the @FT_TRUETYPE_TAGS_H file, or forge a new
|
||||
* one with @FT_MAKE_TAG.
|
||||
*
|
||||
* offset ::
|
||||
* The starting offset in the table (or file if tag~==~0).
|
||||
*
|
||||
* @output:
|
||||
* buffer ::
|
||||
* The target buffer address. The client must ensure that the memory
|
||||
* array is big enough to hold the data.
|
||||
*
|
||||
* @inout:
|
||||
* length ::
|
||||
* If the `length' parameter is NULL, try to load the whole table.
|
||||
* Return an error code if it fails.
|
||||
*
|
||||
* Else, if `*length' is~0, exit immediately while returning the
|
||||
* table's (or file) full size in it.
|
||||
*
|
||||
* Else the number of bytes to read from the table or file, from the
|
||||
* starting offset.
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* If you need to determine the table's length you should first call this
|
||||
* function with `*length' set to~0, as in the following example:
|
||||
*
|
||||
* {
|
||||
* FT_ULong length = 0;
|
||||
*
|
||||
*
|
||||
* error = FT_Load_Sfnt_Table( face, tag, 0, NULL, &length );
|
||||
* if ( error ) { ... table does not exist ... }
|
||||
*
|
||||
* buffer = malloc( length );
|
||||
* if ( buffer == NULL ) { ... not enough memory ... }
|
||||
*
|
||||
* error = FT_Load_Sfnt_Table( face, tag, 0, buffer, &length );
|
||||
* if ( error ) { ... could not load table ... }
|
||||
* }
|
||||
*
|
||||
* Note that structures like @TT_Header or @TT_OS2 can't be used with
|
||||
* this function; they are limited to @FT_Get_Sfnt_Table. Reason is that
|
||||
* those structures depend on the processor architecture, with varying
|
||||
* size (e.g. 32bit vs. 64bit) or order (big endian vs. little endian).
|
||||
*
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Load_Sfnt_Table( FT_Face face,
|
||||
FT_ULong tag,
|
||||
FT_Long offset,
|
||||
FT_Byte* buffer,
|
||||
FT_ULong* length );
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*
|
||||
* @function:
|
||||
* FT_Sfnt_Table_Info
|
||||
*
|
||||
* @description:
|
||||
* Return information on an SFNT table.
|
||||
*
|
||||
* @input:
|
||||
* face ::
|
||||
* A handle to the source face.
|
||||
*
|
||||
* table_index ::
|
||||
* The index of an SFNT table. The function returns
|
||||
* FT_Err_Table_Missing for an invalid value.
|
||||
*
|
||||
* @inout:
|
||||
* tag ::
|
||||
* The name tag of the SFNT table. If the value is NULL, `table_index'
|
||||
* is ignored, and `length' returns the number of SFNT tables in the
|
||||
* font.
|
||||
*
|
||||
* @output:
|
||||
* length ::
|
||||
* The length of the SFNT table (or the number of SFNT tables, depending
|
||||
* on `tag').
|
||||
*
|
||||
* @return:
|
||||
* FreeType error code. 0~means success.
|
||||
*
|
||||
* @note:
|
||||
* While parsing fonts, FreeType handles SFNT tables with length zero as
|
||||
* missing.
|
||||
*
|
||||
*/
|
||||
FT_EXPORT( FT_Error )
|
||||
FT_Sfnt_Table_Info( FT_Face face,
|
||||
FT_UInt table_index,
|
||||
FT_ULong *tag,
|
||||
FT_ULong *length );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_CMap_Language_ID */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Return cmap language ID as specified in the OpenType standard. */
|
||||
/* Definitions of language ID values are in file @FT_TRUETYPE_IDS_H. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* charmap :: */
|
||||
/* The target charmap. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The language ID of `charmap'. If `charmap' doesn't belong to an */
|
||||
/* SFNT face, just return~0 as the default value. */
|
||||
/* */
|
||||
/* For a format~14 cmap (to access Unicode IVS), the return value is */
|
||||
/* 0xFFFFFFFF. */
|
||||
/* */
|
||||
FT_EXPORT( FT_ULong )
|
||||
FT_Get_CMap_Language_ID( FT_CharMap charmap );
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* FT_Get_CMap_Format */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Return the format of an SFNT `cmap' table. */
|
||||
/* */
|
||||
/* <Input> */
|
||||
/* charmap :: */
|
||||
/* The target charmap. */
|
||||
/* */
|
||||
/* <Return> */
|
||||
/* The format of `charmap'. If `charmap' doesn't belong to an SFNT */
|
||||
/* face, return -1. */
|
||||
/* */
|
||||
FT_EXPORT( FT_Long )
|
||||
FT_Get_CMap_Format( FT_CharMap charmap );
|
||||
|
||||
/* */
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* TTTABLES_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,121 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* tttags.h */
|
||||
/* */
|
||||
/* Tags for TrueType and OpenType tables (specification only). */
|
||||
/* */
|
||||
/* Copyright 1996-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
#ifndef TTAGS_H_
|
||||
#define TTAGS_H_
|
||||
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#ifdef FREETYPE_H
|
||||
#error "freetype.h of FreeType 1 has been loaded!"
|
||||
#error "Please fix the directory search order for header files"
|
||||
#error "so that freetype.h of FreeType 2 is found first."
|
||||
#endif
|
||||
|
||||
|
||||
FT_BEGIN_HEADER
|
||||
|
||||
|
||||
#define TTAG_avar FT_MAKE_TAG( 'a', 'v', 'a', 'r' )
|
||||
#define TTAG_BASE FT_MAKE_TAG( 'B', 'A', 'S', 'E' )
|
||||
#define TTAG_bdat FT_MAKE_TAG( 'b', 'd', 'a', 't' )
|
||||
#define TTAG_BDF FT_MAKE_TAG( 'B', 'D', 'F', ' ' )
|
||||
#define TTAG_bhed FT_MAKE_TAG( 'b', 'h', 'e', 'd' )
|
||||
#define TTAG_bloc FT_MAKE_TAG( 'b', 'l', 'o', 'c' )
|
||||
#define TTAG_bsln FT_MAKE_TAG( 'b', 's', 'l', 'n' )
|
||||
#define TTAG_CBDT FT_MAKE_TAG( 'C', 'B', 'D', 'T' )
|
||||
#define TTAG_CBLC FT_MAKE_TAG( 'C', 'B', 'L', 'C' )
|
||||
#define TTAG_CFF FT_MAKE_TAG( 'C', 'F', 'F', ' ' )
|
||||
#define TTAG_CFF2 FT_MAKE_TAG( 'C', 'F', 'F', '2' )
|
||||
#define TTAG_CID FT_MAKE_TAG( 'C', 'I', 'D', ' ' )
|
||||
#define TTAG_cmap FT_MAKE_TAG( 'c', 'm', 'a', 'p' )
|
||||
#define TTAG_cvar FT_MAKE_TAG( 'c', 'v', 'a', 'r' )
|
||||
#define TTAG_cvt FT_MAKE_TAG( 'c', 'v', 't', ' ' )
|
||||
#define TTAG_DSIG FT_MAKE_TAG( 'D', 'S', 'I', 'G' )
|
||||
#define TTAG_EBDT FT_MAKE_TAG( 'E', 'B', 'D', 'T' )
|
||||
#define TTAG_EBLC FT_MAKE_TAG( 'E', 'B', 'L', 'C' )
|
||||
#define TTAG_EBSC FT_MAKE_TAG( 'E', 'B', 'S', 'C' )
|
||||
#define TTAG_feat FT_MAKE_TAG( 'f', 'e', 'a', 't' )
|
||||
#define TTAG_FOND FT_MAKE_TAG( 'F', 'O', 'N', 'D' )
|
||||
#define TTAG_fpgm FT_MAKE_TAG( 'f', 'p', 'g', 'm' )
|
||||
#define TTAG_fvar FT_MAKE_TAG( 'f', 'v', 'a', 'r' )
|
||||
#define TTAG_gasp FT_MAKE_TAG( 'g', 'a', 's', 'p' )
|
||||
#define TTAG_GDEF FT_MAKE_TAG( 'G', 'D', 'E', 'F' )
|
||||
#define TTAG_glyf FT_MAKE_TAG( 'g', 'l', 'y', 'f' )
|
||||
#define TTAG_GPOS FT_MAKE_TAG( 'G', 'P', 'O', 'S' )
|
||||
#define TTAG_GSUB FT_MAKE_TAG( 'G', 'S', 'U', 'B' )
|
||||
#define TTAG_gvar FT_MAKE_TAG( 'g', 'v', 'a', 'r' )
|
||||
#define TTAG_HVAR FT_MAKE_TAG( 'H', 'V', 'A', 'R' )
|
||||
#define TTAG_hdmx FT_MAKE_TAG( 'h', 'd', 'm', 'x' )
|
||||
#define TTAG_head FT_MAKE_TAG( 'h', 'e', 'a', 'd' )
|
||||
#define TTAG_hhea FT_MAKE_TAG( 'h', 'h', 'e', 'a' )
|
||||
#define TTAG_hmtx FT_MAKE_TAG( 'h', 'm', 't', 'x' )
|
||||
#define TTAG_JSTF FT_MAKE_TAG( 'J', 'S', 'T', 'F' )
|
||||
#define TTAG_just FT_MAKE_TAG( 'j', 'u', 's', 't' )
|
||||
#define TTAG_kern FT_MAKE_TAG( 'k', 'e', 'r', 'n' )
|
||||
#define TTAG_lcar FT_MAKE_TAG( 'l', 'c', 'a', 'r' )
|
||||
#define TTAG_loca FT_MAKE_TAG( 'l', 'o', 'c', 'a' )
|
||||
#define TTAG_LTSH FT_MAKE_TAG( 'L', 'T', 'S', 'H' )
|
||||
#define TTAG_LWFN FT_MAKE_TAG( 'L', 'W', 'F', 'N' )
|
||||
#define TTAG_MATH FT_MAKE_TAG( 'M', 'A', 'T', 'H' )
|
||||
#define TTAG_maxp FT_MAKE_TAG( 'm', 'a', 'x', 'p' )
|
||||
#define TTAG_META FT_MAKE_TAG( 'M', 'E', 'T', 'A' )
|
||||
#define TTAG_MMFX FT_MAKE_TAG( 'M', 'M', 'F', 'X' )
|
||||
#define TTAG_MMSD FT_MAKE_TAG( 'M', 'M', 'S', 'D' )
|
||||
#define TTAG_mort FT_MAKE_TAG( 'm', 'o', 'r', 't' )
|
||||
#define TTAG_morx FT_MAKE_TAG( 'm', 'o', 'r', 'x' )
|
||||
#define TTAG_MVAR FT_MAKE_TAG( 'M', 'V', 'A', 'R' )
|
||||
#define TTAG_name FT_MAKE_TAG( 'n', 'a', 'm', 'e' )
|
||||
#define TTAG_opbd FT_MAKE_TAG( 'o', 'p', 'b', 'd' )
|
||||
#define TTAG_OS2 FT_MAKE_TAG( 'O', 'S', '/', '2' )
|
||||
#define TTAG_OTTO FT_MAKE_TAG( 'O', 'T', 'T', 'O' )
|
||||
#define TTAG_PCLT FT_MAKE_TAG( 'P', 'C', 'L', 'T' )
|
||||
#define TTAG_POST FT_MAKE_TAG( 'P', 'O', 'S', 'T' )
|
||||
#define TTAG_post FT_MAKE_TAG( 'p', 'o', 's', 't' )
|
||||
#define TTAG_prep FT_MAKE_TAG( 'p', 'r', 'e', 'p' )
|
||||
#define TTAG_prop FT_MAKE_TAG( 'p', 'r', 'o', 'p' )
|
||||
#define TTAG_sbix FT_MAKE_TAG( 's', 'b', 'i', 'x' )
|
||||
#define TTAG_sfnt FT_MAKE_TAG( 's', 'f', 'n', 't' )
|
||||
#define TTAG_SING FT_MAKE_TAG( 'S', 'I', 'N', 'G' )
|
||||
#define TTAG_trak FT_MAKE_TAG( 't', 'r', 'a', 'k' )
|
||||
#define TTAG_true FT_MAKE_TAG( 't', 'r', 'u', 'e' )
|
||||
#define TTAG_ttc FT_MAKE_TAG( 't', 't', 'c', ' ' )
|
||||
#define TTAG_ttcf FT_MAKE_TAG( 't', 't', 'c', 'f' )
|
||||
#define TTAG_TYP1 FT_MAKE_TAG( 'T', 'Y', 'P', '1' )
|
||||
#define TTAG_typ1 FT_MAKE_TAG( 't', 'y', 'p', '1' )
|
||||
#define TTAG_VDMX FT_MAKE_TAG( 'V', 'D', 'M', 'X' )
|
||||
#define TTAG_vhea FT_MAKE_TAG( 'v', 'h', 'e', 'a' )
|
||||
#define TTAG_vmtx FT_MAKE_TAG( 'v', 'm', 't', 'x' )
|
||||
#define TTAG_VVAR FT_MAKE_TAG( 'V', 'V', 'A', 'R' )
|
||||
#define TTAG_wOFF FT_MAKE_TAG( 'w', 'O', 'F', 'F' )
|
||||
|
||||
/* used by "Keyboard.dfont" on legacy Mac OS X */
|
||||
#define TTAG_0xA5kbd FT_MAKE_TAG( 0xA5, 'k', 'b', 'd' )
|
||||
|
||||
/* used by "LastResort.dfont" on legacy Mac OS X */
|
||||
#define TTAG_0xA5lst FT_MAKE_TAG( 0xA5, 'l', 's', 't' )
|
||||
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
#endif /* TTAGS_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,42 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ft2build.h */
|
||||
/* */
|
||||
/* FreeType 2 build and setup macros. */
|
||||
/* */
|
||||
/* Copyright 1996-2018 by */
|
||||
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
||||
/* */
|
||||
/* This file is part of the FreeType project, and may only be used, */
|
||||
/* modified, and distributed under the terms of the FreeType project */
|
||||
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
||||
/* this file you indicate that you have read the license and */
|
||||
/* understand and accept it fully. */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* This is the `entry point' for FreeType header file inclusions. It is */
|
||||
/* the only header file which should be included directly; all other */
|
||||
/* FreeType header files should be accessed with macro names (after */
|
||||
/* including `ft2build.h'). */
|
||||
/* */
|
||||
/* A typical example is */
|
||||
/* */
|
||||
/* #include <ft2build.h> */
|
||||
/* #include FT_FREETYPE_H */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
#ifndef FT2BUILD_H_
|
||||
#define FT2BUILD_H_
|
||||
|
||||
#include <freetype/config/ftheader.h>
|
||||
|
||||
#endif /* FT2BUILD_H_ */
|
||||
|
||||
|
||||
/* END */
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>FreeType</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string>FreeType 2.4.8</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>FreeType</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>2.4.8</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>2.4.8</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,173 @@
|
||||
The source code to this library used with SDL_ttf can be found here:
|
||||
http://www.libsdl.org/projects/SDL_ttf/libs/
|
||||
---
|
||||
|
||||
The FreeType Project LICENSE
|
||||
----------------------------
|
||||
|
||||
2006-Jan-27
|
||||
|
||||
Copyright 1996-2002, 2006 by
|
||||
David Turner, Robert Wilhelm, and Werner Lemberg
|
||||
|
||||
|
||||
|
||||
Introduction
|
||||
============
|
||||
|
||||
The FreeType Project is distributed in several archive packages;
|
||||
some of them may contain, in addition to the FreeType font engine,
|
||||
various tools and contributions which rely on, or relate to, the
|
||||
FreeType Project.
|
||||
|
||||
This license applies to all files found in such packages, and
|
||||
which do not fall under their own explicit license. The license
|
||||
affects thus the FreeType font engine, the test programs,
|
||||
documentation and makefiles, at the very least.
|
||||
|
||||
This license was inspired by the BSD, Artistic, and IJG
|
||||
(Independent JPEG Group) licenses, which all encourage inclusion
|
||||
and use of free software in commercial and freeware products
|
||||
alike. As a consequence, its main points are that:
|
||||
|
||||
o We don't promise that this software works. However, we will be
|
||||
interested in any kind of bug reports. (`as is' distribution)
|
||||
|
||||
o You can use this software for whatever you want, in parts or
|
||||
full form, without having to pay us. (`royalty-free' usage)
|
||||
|
||||
o You may not pretend that you wrote this software. If you use
|
||||
it, or only parts of it, in a program, you must acknowledge
|
||||
somewhere in your documentation that you have used the
|
||||
FreeType code. (`credits')
|
||||
|
||||
We specifically permit and encourage the inclusion of this
|
||||
software, with or without modifications, in commercial products.
|
||||
We disclaim all warranties covering The FreeType Project and
|
||||
assume no liability related to The FreeType Project.
|
||||
|
||||
|
||||
Finally, many people asked us for a preferred form for a
|
||||
credit/disclaimer to use in compliance with this license. We thus
|
||||
encourage you to use the following text:
|
||||
|
||||
"""
|
||||
Portions of this software are copyright © <year> The FreeType
|
||||
Project (www.freetype.org). All rights reserved.
|
||||
"""
|
||||
|
||||
Please replace <year> with the value from the FreeType version you
|
||||
actually use.
|
||||
|
||||
|
||||
Legal Terms
|
||||
===========
|
||||
|
||||
0. Definitions
|
||||
--------------
|
||||
|
||||
Throughout this license, the terms `package', `FreeType Project',
|
||||
and `FreeType archive' refer to the set of files originally
|
||||
distributed by the authors (David Turner, Robert Wilhelm, and
|
||||
Werner Lemberg) as the `FreeType Project', be they named as alpha,
|
||||
beta or final release.
|
||||
|
||||
`You' refers to the licensee, or person using the project, where
|
||||
`using' is a generic term including compiling the project's source
|
||||
code as well as linking it to form a `program' or `executable'.
|
||||
This program is referred to as `a program using the FreeType
|
||||
engine'.
|
||||
|
||||
This license applies to all files distributed in the original
|
||||
FreeType Project, including all source code, binaries and
|
||||
documentation, unless otherwise stated in the file in its
|
||||
original, unmodified form as distributed in the original archive.
|
||||
If you are unsure whether or not a particular file is covered by
|
||||
this license, you must contact us to verify this.
|
||||
|
||||
The FreeType Project is copyright (C) 1996-2000 by David Turner,
|
||||
Robert Wilhelm, and Werner Lemberg. All rights reserved except as
|
||||
specified below.
|
||||
|
||||
1. No Warranty
|
||||
--------------
|
||||
|
||||
THE FREETYPE PROJECT IS PROVIDED `AS IS' WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. IN NO EVENT WILL ANY OF THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
BE LIABLE FOR ANY DAMAGES CAUSED BY THE USE OR THE INABILITY TO
|
||||
USE, OF THE FREETYPE PROJECT.
|
||||
|
||||
2. Redistribution
|
||||
-----------------
|
||||
|
||||
This license grants a worldwide, royalty-free, perpetual and
|
||||
irrevocable right and license to use, execute, perform, compile,
|
||||
display, copy, create derivative works of, distribute and
|
||||
sublicense the FreeType Project (in both source and object code
|
||||
forms) and derivative works thereof for any purpose; and to
|
||||
authorize others to exercise some or all of the rights granted
|
||||
herein, subject to the following conditions:
|
||||
|
||||
o Redistribution of source code must retain this license file
|
||||
(`FTL.TXT') unaltered; any additions, deletions or changes to
|
||||
the original files must be clearly indicated in accompanying
|
||||
documentation. The copyright notices of the unaltered,
|
||||
original files must be preserved in all copies of source
|
||||
files.
|
||||
|
||||
o Redistribution in binary form must provide a disclaimer that
|
||||
states that the software is based in part of the work of the
|
||||
FreeType Team, in the distribution documentation. We also
|
||||
encourage you to put an URL to the FreeType web page in your
|
||||
documentation, though this isn't mandatory.
|
||||
|
||||
These conditions apply to any software derived from or based on
|
||||
the FreeType Project, not just the unmodified files. If you use
|
||||
our work, you must acknowledge us. However, no fee need be paid
|
||||
to us.
|
||||
|
||||
3. Advertising
|
||||
--------------
|
||||
|
||||
Neither the FreeType authors and contributors nor you shall use
|
||||
the name of the other for commercial, advertising, or promotional
|
||||
purposes without specific prior written permission.
|
||||
|
||||
We suggest, but do not require, that you use one or more of the
|
||||
following phrases to refer to this software in your documentation
|
||||
or advertising materials: `FreeType Project', `FreeType Engine',
|
||||
`FreeType library', or `FreeType Distribution'.
|
||||
|
||||
As you have not signed this license, you are not required to
|
||||
accept it. However, as the FreeType Project is copyrighted
|
||||
material, only this license, or another one contracted with the
|
||||
authors, grants you the right to use, distribute, and modify it.
|
||||
Therefore, by using, distributing, or modifying the FreeType
|
||||
Project, you indicate that you understand and accept all the terms
|
||||
of this license.
|
||||
|
||||
4. Contacts
|
||||
-----------
|
||||
|
||||
There are two mailing lists related to FreeType:
|
||||
|
||||
o [email protected]
|
||||
|
||||
Discusses general use and applications of FreeType, as well as
|
||||
future and wanted additions to the library and distribution.
|
||||
If you are looking for support, start in this list if you
|
||||
haven't found anything to help you in the documentation.
|
||||
|
||||
o [email protected]
|
||||
|
||||
Discusses bugs, as well as engine internals, design issues,
|
||||
specific licenses, porting, etc.
|
||||
|
||||
Our home page can be found at
|
||||
|
||||
http://www.freetype.org
|
||||
|
||||
|
||||
--- end of FTL.TXT ---
|
||||
@@ -0,0 +1,500 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>files</key>
|
||||
<dict>
|
||||
<key>Resources/English.lproj/InfoPlist.strings</key>
|
||||
<dict>
|
||||
<key>hash</key>
|
||||
<data>
|
||||
HVTFMg5638sbz7hs64liIWXohnM=
|
||||
</data>
|
||||
<key>optional</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>Resources/Info.plist</key>
|
||||
<data>
|
||||
1FPRdIH76VylC1rjdLR7Ib9yAoY=
|
||||
</data>
|
||||
<key>Resources/LICENSE.freetype.txt</key>
|
||||
<data>
|
||||
CFzqT4LNMTCORxPV3xOqm66oAiE=
|
||||
</data>
|
||||
</dict>
|
||||
<key>files2</key>
|
||||
<dict>
|
||||
<key>Headers/freetype/config/ftconfig.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
ii44OqswYCZ6O0mV6QCSeeWVuaMkyM1jvxqrfz8j9+c=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/config/ftheader.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
ZIac2Y0iUDl8dlOgUE7SULllneCynoxFg6Zb6CgTl0U=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/config/ftmodule.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
Dgadi2klZ5YqXd2DIzPHkV7YqXbKCNLaAXtk4AGraDQ=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/config/ftoption.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
cLtqqTwQOSF/l8qW6XxWknhV1K+ZT4mmMv2/t45whu0=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/config/ftstdlib.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
7/e0zUfA367udzTP+hig27CYl6UzL5VhkDhFfQVonJA=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/freetype.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
+uISfLymGZkItfm2ygWogZ9K3SpANjSl/G75a3235Ds=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ftadvanc.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
N3Ti1qyvARnQvYwEf6FzrzcAbOOgvIOJsABCrWqPRTM=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ftbbox.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
gF7Ga4aLvykJ0vfhq5LDagey+UXMFnzwjgICfEwqZ2k=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ftbdf.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
aJnf99F/B/HSKg6TaI3jfQ0udwzN+InlQcISSzSpdRM=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ftbitmap.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
7AnoE1mGHNF5bMLIPRt0CKMZ5QUU77xk3G4S6xlNZck=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ftbzip2.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
XHkOvZAhM9wsyMFA0ITNGrqzzsxf4Ux7fi3aN586I+M=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ftcache.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
j5gEshUTm2hssVVRarOMc6QlOGn7B833x+PCJ4k/guE=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ftchapters.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
4HmrUDpT5dkppdiu1Uaz/ok1BI+VBZNifNYzqi+eDg8=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ftcid.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
/IMl/nBy+tSpEiT56uk0mFFHwgJTb6DlaHSdT7zn1+Y=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ftdriver.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
bx4DfXGnBYxWlbBkLSOtwylHiNSFhhqzvEwb1OpZtpQ=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/fterrdef.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
G8LZMdG2OIa/PAVZgMnBVjTGDFtIpwjBa5R5DpAw4no=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/fterrors.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
uKfe6Zh5qziNihWlB4z0zxf4ca0GuRSxC8TXA9iXo44=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ftfntfmt.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
hv9Jwwvs2cC3pAkiKIovkwqUjDfy77K7C5OVO+cKHDk=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ftgasp.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
hP8nOIRJQfiv7Ul+rFG83qsYoDeytmB88uTwpBS4q8g=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ftglyph.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
8kmQULsTZAMEtU9XBsG2LA5vonm9xVNY+PKBQzZZzAQ=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ftgxval.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
qcJ2HMYFwDvB98mK1KnPXXPYqhGKWhHTLq5nvSanRsg=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ftgzip.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
T4cjM0y69/j98GOuLdpDHQbs/QEKiXb8ktgmlh6Om3g=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ftimage.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
1NsVTUw62v0nBw3QXS7IvLUpFup94yVcjdBx6tRc6ec=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ftincrem.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
YnjDytEzybejBlqoV7xCBBI8ptd/HT+Nv/wxtCZrMZY=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ftlcdfil.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
JgRBRSSxe/1fypki4av8CifYntpOVC15heRG6ZNocO8=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ftlist.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
P0GFjO3Hu3GbxFSKjKXHer0DkKIRV3UL/T09m9cb3hE=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ftlzw.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
Sp2MQZOJOx2Tk58bCYvbqC3shMbzWR7glJknKhJT5VE=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ftmac.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
MKJAKPBAwhAHUkwylq3C+uiWlu96rBTvU4dd3buCAws=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ftmm.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
qW/nFZKHVt5BzjG9OQdVUO7TpCK1BSvQufrxXOmM68U=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ftmodapi.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
FQAOqPdHcDKU0FmTixf6CyWA7zu629vOTRYB4pdCmN0=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ftmoderr.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
b0NkwkaD+I3TaNC6xa5GEA5309p9LHb/07THyXRivwo=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ftotval.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
i1tVudMs2cuyLiOTJX7IbliBBl9lT7pM2tU3c2z+Zys=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ftoutln.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
fnIqqoWkXFiEPotq+o7wSN1jnrROZLonySBf6Ypwhbs=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ftparams.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
KsIc+RhBt7zaa3/0XcKe8RTnHtyUhET/rxufmSPivGc=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ftpfr.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
8svWMbEW5Zb8FbQO86jcB8wA9lo1LmZ2Yla4l7Qag5M=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ftrender.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
f1Dkxs0msHFJumAnSyuWY7jw4uugZW4xkgwPiNM4whI=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ftsizes.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
L8VaJOH/FNHCqAUAIGOXBS8/e9Ux2NF1i1l4Fey2BTU=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ftsnames.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
L5l/ckLRcykw13cXi2i1+6VXmB+NbAO+qiQLGPoqrxA=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ftstroke.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
8VEOnPE0AIpRbAwWRZWru4ApDVXTBM9i29X7kx4/I9Q=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ftsynth.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
T6ArKW3lj+8axy3kJr2E3bM019R4Cys0JQHTAhDp1bk=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ftsystem.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
KhdFdd7T5vnqi6BG8x36oDzFL6Fvt0mMg/g/BUu3Ddo=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/fttrigon.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
MYzKF2xDzzkmZjud5RxghGPEfzzeXq22puQuuoca+z4=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/fttypes.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
BxrNb/QHOaTm7KHw4sni0mYiUNLXdTHv3QHNUzLn6NQ=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ftwinfnt.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
PaZmX8yotzM/STNOeOV+O3M+lY93iWytoCRdfPDGSAI=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/t1tables.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
rdyBqfN1wCaaH9uKuIgdo33eyv32Dc4jtxoAjyfkb/Q=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/ttnameid.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
fsj4W7TJ8cznJ/qkmNrJUxEz/CxZskpm9gVIB2h1dVw=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/tttables.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
cR9gEaRNfOCraWLZ4GhI69ryrkrzF5ze8FgfecVedh4=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/freetype/tttags.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
/1A7piohdzpWBACeIvNwtc32AvuW30fgCqlSuSualIo=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Headers/ft2build.h</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
7d2Bo9BdTHC7uz/IkAU9Edj9EWtopYhYwD3KtQJMDeU=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Resources/English.lproj/InfoPlist.strings</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
pye1r8MDxlZwdXGVcJXkL7yCWVUL2EBKaPwboOik/Ys=
|
||||
</data>
|
||||
<key>optional</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>Resources/Info.plist</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
LgLWiOAfeKfElgJRbXLL9cgzUidG06AqyWs5IvYZyvg=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Resources/LICENSE.freetype.txt</key>
|
||||
<dict>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
fovJndE7TC9qX3uBKeu1a+/6GIyAwTQSeqtkzn9T0iU=
|
||||
</data>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>rules</key>
|
||||
<dict>
|
||||
<key>^Resources/</key>
|
||||
<true/>
|
||||
<key>^Resources/.*\.lproj/</key>
|
||||
<dict>
|
||||
<key>optional</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>1000</real>
|
||||
</dict>
|
||||
<key>^Resources/.*\.lproj/locversion.plist$</key>
|
||||
<dict>
|
||||
<key>omit</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>1100</real>
|
||||
</dict>
|
||||
<key>^Resources/Base\.lproj/</key>
|
||||
<dict>
|
||||
<key>weight</key>
|
||||
<real>1010</real>
|
||||
</dict>
|
||||
<key>^version.plist$</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>rules2</key>
|
||||
<dict>
|
||||
<key>.*\.dSYM($|/)</key>
|
||||
<dict>
|
||||
<key>weight</key>
|
||||
<real>11</real>
|
||||
</dict>
|
||||
<key>^(.*/)?\.DS_Store$</key>
|
||||
<dict>
|
||||
<key>omit</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>2000</real>
|
||||
</dict>
|
||||
<key>^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/</key>
|
||||
<dict>
|
||||
<key>nested</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>10</real>
|
||||
</dict>
|
||||
<key>^.*</key>
|
||||
<true/>
|
||||
<key>^Info\.plist$</key>
|
||||
<dict>
|
||||
<key>omit</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>20</real>
|
||||
</dict>
|
||||
<key>^PkgInfo$</key>
|
||||
<dict>
|
||||
<key>omit</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>20</real>
|
||||
</dict>
|
||||
<key>^Resources/</key>
|
||||
<dict>
|
||||
<key>weight</key>
|
||||
<real>20</real>
|
||||
</dict>
|
||||
<key>^Resources/.*\.lproj/</key>
|
||||
<dict>
|
||||
<key>optional</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>1000</real>
|
||||
</dict>
|
||||
<key>^Resources/.*\.lproj/locversion.plist$</key>
|
||||
<dict>
|
||||
<key>omit</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>1100</real>
|
||||
</dict>
|
||||
<key>^Resources/Base\.lproj/</key>
|
||||
<dict>
|
||||
<key>weight</key>
|
||||
<real>1010</real>
|
||||
</dict>
|
||||
<key>^[^/]+$</key>
|
||||
<dict>
|
||||
<key>nested</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>10</real>
|
||||
</dict>
|
||||
<key>^embedded\.provisionprofile$</key>
|
||||
<dict>
|
||||
<key>weight</key>
|
||||
<real>20</real>
|
||||
</dict>
|
||||
<key>^version\.plist$</key>
|
||||
<dict>
|
||||
<key>weight</key>
|
||||
<real>20</real>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1 @@
|
||||
A
|
||||
@@ -0,0 +1,294 @@
|
||||
/*
|
||||
SDL_ttf: A companion library to SDL for working with TrueType (tm) fonts
|
||||
Copyright (C) 2001-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/* This library is a wrapper around the excellent FreeType 2.0 library,
|
||||
available at:
|
||||
http://www.freetype.org/
|
||||
*/
|
||||
|
||||
/* Note: In many places, SDL_ttf will say "glyph" when it means "code point."
|
||||
Unicode is hard, we learn as we go, and we apologize for adding to the
|
||||
confusion. */
|
||||
|
||||
#ifndef SDL_TTF_H_
|
||||
#define SDL_TTF_H_
|
||||
|
||||
#include <SDL.h>
|
||||
#include <begin_code.h>
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
|
||||
*/
|
||||
#define SDL_TTF_MAJOR_VERSION 2
|
||||
#define SDL_TTF_MINOR_VERSION 0
|
||||
#define SDL_TTF_PATCHLEVEL 15
|
||||
|
||||
/* This macro can be used to fill a version structure with the compile-time
|
||||
* version of the SDL_ttf library.
|
||||
*/
|
||||
#define SDL_TTF_VERSION(X) \
|
||||
{ \
|
||||
(X)->major = SDL_TTF_MAJOR_VERSION; \
|
||||
(X)->minor = SDL_TTF_MINOR_VERSION; \
|
||||
(X)->patch = SDL_TTF_PATCHLEVEL; \
|
||||
}
|
||||
|
||||
/* Backwards compatibility */
|
||||
#define TTF_MAJOR_VERSION SDL_TTF_MAJOR_VERSION
|
||||
#define TTF_MINOR_VERSION SDL_TTF_MINOR_VERSION
|
||||
#define TTF_PATCHLEVEL SDL_TTF_PATCHLEVEL
|
||||
#define TTF_VERSION(X) SDL_TTF_VERSION(X)
|
||||
|
||||
/**
|
||||
* This is the version number macro for the current SDL_ttf version.
|
||||
*/
|
||||
#define SDL_TTF_COMPILEDVERSION \
|
||||
SDL_VERSIONNUM(SDL_TTF_MAJOR_VERSION, SDL_TTF_MINOR_VERSION, SDL_TTF_PATCHLEVEL)
|
||||
|
||||
/**
|
||||
* This macro will evaluate to true if compiled with SDL_ttf at least X.Y.Z.
|
||||
*/
|
||||
#define SDL_TTF_VERSION_ATLEAST(X, Y, Z) \
|
||||
(SDL_TTF_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
|
||||
|
||||
/* Make sure this is defined (only available in newer SDL versions) */
|
||||
#ifndef SDL_DEPRECATED
|
||||
#define SDL_DEPRECATED
|
||||
#endif
|
||||
|
||||
/* This function gets the version of the dynamically linked SDL_ttf library.
|
||||
it should NOT be used to fill a version structure, instead you should
|
||||
use the SDL_TTF_VERSION() macro.
|
||||
*/
|
||||
extern DECLSPEC const SDL_version * SDLCALL TTF_Linked_Version(void);
|
||||
|
||||
/* ZERO WIDTH NO-BREAKSPACE (Unicode byte order mark) */
|
||||
#define UNICODE_BOM_NATIVE 0xFEFF
|
||||
#define UNICODE_BOM_SWAPPED 0xFFFE
|
||||
|
||||
/* This function tells the library whether UNICODE text is generally
|
||||
byteswapped. A UNICODE BOM character in a string will override
|
||||
this setting for the remainder of that string.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL TTF_ByteSwappedUNICODE(int swapped);
|
||||
|
||||
/* The internal structure containing font information */
|
||||
typedef struct _TTF_Font TTF_Font;
|
||||
|
||||
/* Initialize the TTF engine - returns 0 if successful, -1 on error */
|
||||
extern DECLSPEC int SDLCALL TTF_Init(void);
|
||||
|
||||
/* Open a font file and create a font of the specified point size.
|
||||
* Some .fon fonts will have several sizes embedded in the file, so the
|
||||
* point size becomes the index of choosing which size. If the value
|
||||
* is too high, the last indexed size will be the default. */
|
||||
extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFont(const char *file, int ptsize);
|
||||
extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFontIndex(const char *file, int ptsize, long index);
|
||||
extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFontRW(SDL_RWops *src, int freesrc, int ptsize);
|
||||
extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFontIndexRW(SDL_RWops *src, int freesrc, int ptsize, long index);
|
||||
|
||||
/* Set and retrieve the font style */
|
||||
#define TTF_STYLE_NORMAL 0x00
|
||||
#define TTF_STYLE_BOLD 0x01
|
||||
#define TTF_STYLE_ITALIC 0x02
|
||||
#define TTF_STYLE_UNDERLINE 0x04
|
||||
#define TTF_STYLE_STRIKETHROUGH 0x08
|
||||
extern DECLSPEC int SDLCALL TTF_GetFontStyle(const TTF_Font *font);
|
||||
extern DECLSPEC void SDLCALL TTF_SetFontStyle(TTF_Font *font, int style);
|
||||
extern DECLSPEC int SDLCALL TTF_GetFontOutline(const TTF_Font *font);
|
||||
extern DECLSPEC void SDLCALL TTF_SetFontOutline(TTF_Font *font, int outline);
|
||||
|
||||
/* Set and retrieve FreeType hinter settings */
|
||||
#define TTF_HINTING_NORMAL 0
|
||||
#define TTF_HINTING_LIGHT 1
|
||||
#define TTF_HINTING_MONO 2
|
||||
#define TTF_HINTING_NONE 3
|
||||
extern DECLSPEC int SDLCALL TTF_GetFontHinting(const TTF_Font *font);
|
||||
extern DECLSPEC void SDLCALL TTF_SetFontHinting(TTF_Font *font, int hinting);
|
||||
|
||||
/* Get the total height of the font - usually equal to point size */
|
||||
extern DECLSPEC int SDLCALL TTF_FontHeight(const TTF_Font *font);
|
||||
|
||||
/* Get the offset from the baseline to the top of the font
|
||||
This is a positive value, relative to the baseline.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL TTF_FontAscent(const TTF_Font *font);
|
||||
|
||||
/* Get the offset from the baseline to the bottom of the font
|
||||
This is a negative value, relative to the baseline.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL TTF_FontDescent(const TTF_Font *font);
|
||||
|
||||
/* Get the recommended spacing between lines of text for this font */
|
||||
extern DECLSPEC int SDLCALL TTF_FontLineSkip(const TTF_Font *font);
|
||||
|
||||
/* Get/Set whether or not kerning is allowed for this font */
|
||||
extern DECLSPEC int SDLCALL TTF_GetFontKerning(const TTF_Font *font);
|
||||
extern DECLSPEC void SDLCALL TTF_SetFontKerning(TTF_Font *font, int allowed);
|
||||
|
||||
/* Get the number of faces of the font */
|
||||
extern DECLSPEC long SDLCALL TTF_FontFaces(const TTF_Font *font);
|
||||
|
||||
/* Get the font face attributes, if any */
|
||||
extern DECLSPEC int SDLCALL TTF_FontFaceIsFixedWidth(const TTF_Font *font);
|
||||
extern DECLSPEC char * SDLCALL TTF_FontFaceFamilyName(const TTF_Font *font);
|
||||
extern DECLSPEC char * SDLCALL TTF_FontFaceStyleName(const TTF_Font *font);
|
||||
|
||||
/* Check wether a glyph is provided by the font or not */
|
||||
extern DECLSPEC int SDLCALL TTF_GlyphIsProvided(const TTF_Font *font, Uint16 ch);
|
||||
|
||||
/* Get the metrics (dimensions) of a glyph
|
||||
To understand what these metrics mean, here is a useful link:
|
||||
http://freetype.sourceforge.net/freetype2/docs/tutorial/step2.html
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL TTF_GlyphMetrics(TTF_Font *font, Uint16 ch,
|
||||
int *minx, int *maxx,
|
||||
int *miny, int *maxy, int *advance);
|
||||
|
||||
/* Get the dimensions of a rendered string of text */
|
||||
extern DECLSPEC int SDLCALL TTF_SizeText(TTF_Font *font, const char *text, int *w, int *h);
|
||||
extern DECLSPEC int SDLCALL TTF_SizeUTF8(TTF_Font *font, const char *text, int *w, int *h);
|
||||
extern DECLSPEC int SDLCALL TTF_SizeUNICODE(TTF_Font *font, const Uint16 *text, int *w, int *h);
|
||||
|
||||
/* Create an 8-bit palettized surface and render the given text at
|
||||
fast quality with the given font and color. The 0 pixel is the
|
||||
colorkey, giving a transparent background, and the 1 pixel is set
|
||||
to the text color.
|
||||
This function returns the new surface, or NULL if there was an error.
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Solid(TTF_Font *font,
|
||||
const char *text, SDL_Color fg);
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUTF8_Solid(TTF_Font *font,
|
||||
const char *text, SDL_Color fg);
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUNICODE_Solid(TTF_Font *font,
|
||||
const Uint16 *text, SDL_Color fg);
|
||||
|
||||
/* Create an 8-bit palettized surface and render the given glyph at
|
||||
fast quality with the given font and color. The 0 pixel is the
|
||||
colorkey, giving a transparent background, and the 1 pixel is set
|
||||
to the text color. The glyph is rendered without any padding or
|
||||
centering in the X direction, and aligned normally in the Y direction.
|
||||
This function returns the new surface, or NULL if there was an error.
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderGlyph_Solid(TTF_Font *font,
|
||||
Uint16 ch, SDL_Color fg);
|
||||
|
||||
/* Create an 8-bit palettized surface and render the given text at
|
||||
high quality with the given font and colors. The 0 pixel is background,
|
||||
while other pixels have varying degrees of the foreground color.
|
||||
This function returns the new surface, or NULL if there was an error.
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Shaded(TTF_Font *font,
|
||||
const char *text, SDL_Color fg, SDL_Color bg);
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUTF8_Shaded(TTF_Font *font,
|
||||
const char *text, SDL_Color fg, SDL_Color bg);
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUNICODE_Shaded(TTF_Font *font,
|
||||
const Uint16 *text, SDL_Color fg, SDL_Color bg);
|
||||
|
||||
/* Create an 8-bit palettized surface and render the given glyph at
|
||||
high quality with the given font and colors. The 0 pixel is background,
|
||||
while other pixels have varying degrees of the foreground color.
|
||||
The glyph is rendered without any padding or centering in the X
|
||||
direction, and aligned normally in the Y direction.
|
||||
This function returns the new surface, or NULL if there was an error.
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderGlyph_Shaded(TTF_Font *font,
|
||||
Uint16 ch, SDL_Color fg, SDL_Color bg);
|
||||
|
||||
/* Create a 32-bit ARGB surface and render the given text at high quality,
|
||||
using alpha blending to dither the font with the given color.
|
||||
This function returns the new surface, or NULL if there was an error.
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Blended(TTF_Font *font,
|
||||
const char *text, SDL_Color fg);
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUTF8_Blended(TTF_Font *font,
|
||||
const char *text, SDL_Color fg);
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUNICODE_Blended(TTF_Font *font,
|
||||
const Uint16 *text, SDL_Color fg);
|
||||
|
||||
|
||||
/* Create a 32-bit ARGB surface and render the given text at high quality,
|
||||
using alpha blending to dither the font with the given color.
|
||||
Text is wrapped to multiple lines on line endings and on word boundaries
|
||||
if it extends beyond wrapLength in pixels.
|
||||
This function returns the new surface, or NULL if there was an error.
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Blended_Wrapped(TTF_Font *font,
|
||||
const char *text, SDL_Color fg, Uint32 wrapLength);
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUTF8_Blended_Wrapped(TTF_Font *font,
|
||||
const char *text, SDL_Color fg, Uint32 wrapLength);
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUNICODE_Blended_Wrapped(TTF_Font *font,
|
||||
const Uint16 *text, SDL_Color fg, Uint32 wrapLength);
|
||||
|
||||
/* Create a 32-bit ARGB surface and render the given glyph at high quality,
|
||||
using alpha blending to dither the font with the given color.
|
||||
The glyph is rendered without any padding or centering in the X
|
||||
direction, and aligned normally in the Y direction.
|
||||
This function returns the new surface, or NULL if there was an error.
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderGlyph_Blended(TTF_Font *font,
|
||||
Uint16 ch, SDL_Color fg);
|
||||
|
||||
/* For compatibility with previous versions, here are the old functions */
|
||||
#define TTF_RenderText(font, text, fg, bg) \
|
||||
TTF_RenderText_Shaded(font, text, fg, bg)
|
||||
#define TTF_RenderUTF8(font, text, fg, bg) \
|
||||
TTF_RenderUTF8_Shaded(font, text, fg, bg)
|
||||
#define TTF_RenderUNICODE(font, text, fg, bg) \
|
||||
TTF_RenderUNICODE_Shaded(font, text, fg, bg)
|
||||
|
||||
/* Close an opened font file */
|
||||
extern DECLSPEC void SDLCALL TTF_CloseFont(TTF_Font *font);
|
||||
|
||||
/* De-initialize the TTF engine */
|
||||
extern DECLSPEC void SDLCALL TTF_Quit(void);
|
||||
|
||||
/* Check if the TTF engine is initialized */
|
||||
extern DECLSPEC int SDLCALL TTF_WasInit(void);
|
||||
|
||||
/* Get the kerning size of two glyphs indices */
|
||||
/* DEPRECATED: this function requires FreeType font indexes, not glyphs,
|
||||
by accident, which we don't expose through this API, so it could give
|
||||
wildly incorrect results, especially with non-ASCII values.
|
||||
Going forward, please use TTF_GetFontKerningSizeGlyphs() instead, which
|
||||
does what you probably expected this function to do. */
|
||||
extern DECLSPEC int TTF_GetFontKerningSize(TTF_Font *font, int prev_index, int index) SDL_DEPRECATED;
|
||||
|
||||
/* Get the kerning size of two glyphs */
|
||||
extern DECLSPEC int TTF_GetFontKerningSizeGlyphs(TTF_Font *font, Uint16 previous_ch, Uint16 ch);
|
||||
|
||||
/* We'll use SDL for reporting errors */
|
||||
#define TTF_SetError SDL_SetError
|
||||
#define TTF_GetError SDL_GetError
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include <close_code.h>
|
||||
|
||||
#endif /* SDL_TTF_H_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>BuildMachineOSBuild</key>
|
||||
<string>18C54</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>SDL2_ttf</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.libsdl.SDL2-ttf</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>SDL2_ttf</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>2.0.15</string>
|
||||
<key>CFBundleSupportedPlatforms</key>
|
||||
<array>
|
||||
<string>MacOSX</string>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>2.0.15</string>
|
||||
<key>DTCompiler</key>
|
||||
<string>com.apple.compilers.llvm.clang.1_0</string>
|
||||
<key>DTPlatformBuild</key>
|
||||
<string>10B61</string>
|
||||
<key>DTPlatformVersion</key>
|
||||
<string>GM</string>
|
||||
<key>DTSDKBuild</key>
|
||||
<string>18B71</string>
|
||||
<key>DTSDKName</key>
|
||||
<string>macosx10.14</string>
|
||||
<key>DTXcode</key>
|
||||
<string>1010</string>
|
||||
<key>DTXcodeBuild</key>
|
||||
<string>10B61</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,152 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>files</key>
|
||||
<dict>
|
||||
<key>Resources/Info.plist</key>
|
||||
<data>
|
||||
IfLC5JMCapmKtefZrmJcxZV4NMA=
|
||||
</data>
|
||||
</dict>
|
||||
<key>files2</key>
|
||||
<dict>
|
||||
<key>Frameworks/FreeType.framework</key>
|
||||
<dict>
|
||||
<key>cdhash</key>
|
||||
<data>
|
||||
7QiXe3F/Kkx1E+Qs7nq27ZOleU4=
|
||||
</data>
|
||||
<key>requirement</key>
|
||||
<string>identifier FreeType and anchor apple generic and certificate 1[field.1.2.840.113635.100.6.2.6] /* exists */ and certificate leaf[field.1.2.840.113635.100.6.1.13] /* exists */ and certificate leaf[subject.OU] = "45U78722YL"</string>
|
||||
</dict>
|
||||
<key>Headers/SDL_ttf.h</key>
|
||||
<dict>
|
||||
<key>hash</key>
|
||||
<data>
|
||||
wuhCDit3v14GFg2+LWc+UTKSKsE=
|
||||
</data>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
T1XsXFvOExAvEeSokWuDjAxPzjfUhdYqMQ7oVafG/Ug=
|
||||
</data>
|
||||
</dict>
|
||||
<key>Resources/Info.plist</key>
|
||||
<dict>
|
||||
<key>hash</key>
|
||||
<data>
|
||||
IfLC5JMCapmKtefZrmJcxZV4NMA=
|
||||
</data>
|
||||
<key>hash2</key>
|
||||
<data>
|
||||
/IL1YRtl9s1fvhfRZrQYffaUK0FTRX5NjUZY5ahDouY=
|
||||
</data>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>rules</key>
|
||||
<dict>
|
||||
<key>^Resources/</key>
|
||||
<true/>
|
||||
<key>^Resources/.*\.lproj/</key>
|
||||
<dict>
|
||||
<key>optional</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>1000</real>
|
||||
</dict>
|
||||
<key>^Resources/.*\.lproj/locversion.plist$</key>
|
||||
<dict>
|
||||
<key>omit</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>1100</real>
|
||||
</dict>
|
||||
<key>^Resources/Base\.lproj/</key>
|
||||
<dict>
|
||||
<key>weight</key>
|
||||
<real>1010</real>
|
||||
</dict>
|
||||
<key>^version.plist$</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>rules2</key>
|
||||
<dict>
|
||||
<key>.*\.dSYM($|/)</key>
|
||||
<dict>
|
||||
<key>weight</key>
|
||||
<real>11</real>
|
||||
</dict>
|
||||
<key>^(.*/)?\.DS_Store$</key>
|
||||
<dict>
|
||||
<key>omit</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>2000</real>
|
||||
</dict>
|
||||
<key>^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/</key>
|
||||
<dict>
|
||||
<key>nested</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>10</real>
|
||||
</dict>
|
||||
<key>^.*</key>
|
||||
<true/>
|
||||
<key>^Info\.plist$</key>
|
||||
<dict>
|
||||
<key>omit</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>20</real>
|
||||
</dict>
|
||||
<key>^PkgInfo$</key>
|
||||
<dict>
|
||||
<key>omit</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>20</real>
|
||||
</dict>
|
||||
<key>^Resources/</key>
|
||||
<dict>
|
||||
<key>weight</key>
|
||||
<real>20</real>
|
||||
</dict>
|
||||
<key>^Resources/.*\.lproj/</key>
|
||||
<dict>
|
||||
<key>optional</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>1000</real>
|
||||
</dict>
|
||||
<key>^Resources/.*\.lproj/locversion.plist$</key>
|
||||
<dict>
|
||||
<key>omit</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>1100</real>
|
||||
</dict>
|
||||
<key>^Resources/Base\.lproj/</key>
|
||||
<dict>
|
||||
<key>weight</key>
|
||||
<real>1010</real>
|
||||
</dict>
|
||||
<key>^[^/]+$</key>
|
||||
<dict>
|
||||
<key>nested</key>
|
||||
<true/>
|
||||
<key>weight</key>
|
||||
<real>10</real>
|
||||
</dict>
|
||||
<key>^embedded\.provisionprofile$</key>
|
||||
<dict>
|
||||
<key>weight</key>
|
||||
<real>20</real>
|
||||
</dict>
|
||||
<key>^version\.plist$</key>
|
||||
<dict>
|
||||
<key>weight</key>
|
||||
<real>20</real>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1 @@
|
||||
A
|
||||
@@ -409,6 +409,7 @@ enum AVCodecID {
|
||||
AV_CODEC_ID_DXV,
|
||||
AV_CODEC_ID_SCREENPRESSO,
|
||||
AV_CODEC_ID_RSCC,
|
||||
AV_CODEC_ID_AVS2,
|
||||
|
||||
AV_CODEC_ID_Y41P = 0x8000,
|
||||
AV_CODEC_ID_AVRP,
|
||||
@@ -446,6 +447,11 @@ enum AVCodecID {
|
||||
AV_CODEC_ID_SVG,
|
||||
AV_CODEC_ID_GDV,
|
||||
AV_CODEC_ID_FITS,
|
||||
AV_CODEC_ID_IMM4,
|
||||
AV_CODEC_ID_PROSUMER,
|
||||
AV_CODEC_ID_MWSC,
|
||||
AV_CODEC_ID_WCMV,
|
||||
AV_CODEC_ID_RASC,
|
||||
|
||||
/* various PCM "codecs" */
|
||||
AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
|
||||
@@ -485,6 +491,7 @@ enum AVCodecID {
|
||||
AV_CODEC_ID_PCM_S64BE,
|
||||
AV_CODEC_ID_PCM_F16LE,
|
||||
AV_CODEC_ID_PCM_F24LE,
|
||||
AV_CODEC_ID_PCM_VIDC,
|
||||
|
||||
/* various ADPCM codecs */
|
||||
AV_CODEC_ID_ADPCM_IMA_QT = 0x11000,
|
||||
@@ -1359,6 +1366,12 @@ enum AVPacketSideDataType {
|
||||
*/
|
||||
AV_PKT_DATA_ENCRYPTION_INFO,
|
||||
|
||||
/**
|
||||
* Active Format Description data consisting of a single byte as specified
|
||||
* in ETSI TS 101 154 using AVActiveFormatDescription enum.
|
||||
*/
|
||||
AV_PKT_DATA_AFD,
|
||||
|
||||
/**
|
||||
* The number of side data types.
|
||||
* This is not part of the public API/ABI in the sense that it may
|
||||
@@ -1614,6 +1627,7 @@ typedef struct AVCodecContext {
|
||||
* The allocated memory should be AV_INPUT_BUFFER_PADDING_SIZE bytes larger
|
||||
* than extradata_size to avoid problems if it is read with the bitstream reader.
|
||||
* The bytewise contents of extradata must not depend on the architecture or CPU endianness.
|
||||
* Must be allocated with the av_malloc() family of functions.
|
||||
* - encoding: Set/allocated/freed by libavcodec.
|
||||
* - decoding: Set/allocated/freed by user.
|
||||
*/
|
||||
@@ -5768,6 +5782,7 @@ typedef struct AVBitStreamFilter {
|
||||
int (*init)(AVBSFContext *ctx);
|
||||
int (*filter)(AVBSFContext *ctx, AVPacket *pkt);
|
||||
void (*close)(AVBSFContext *ctx);
|
||||
void (*flush)(AVBSFContext *ctx);
|
||||
} AVBitStreamFilter;
|
||||
|
||||
#if FF_API_OLD_BSF
|
||||
@@ -5894,6 +5909,11 @@ int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt);
|
||||
*/
|
||||
int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt);
|
||||
|
||||
/**
|
||||
* Reset the internal bitstream filter state / flush internal buffers.
|
||||
*/
|
||||
void av_bsf_flush(AVBSFContext *ctx);
|
||||
|
||||
/**
|
||||
* Free a bitstream filter context and everything associated with it; write NULL
|
||||
* into the supplied pointer.
|
||||
|
||||
@@ -85,4 +85,17 @@ typedef struct MediaCodecBuffer AVMediaCodecBuffer;
|
||||
*/
|
||||
int av_mediacodec_release_buffer(AVMediaCodecBuffer *buffer, int render);
|
||||
|
||||
/**
|
||||
* Release a MediaCodec buffer and render it at the given time to the surface
|
||||
* that is associated with the decoder. The timestamp must be within one second
|
||||
* of the current java/lang/System#nanoTime() (which is implemented using
|
||||
* CLOCK_MONOTONIC on Android). See the Android MediaCodec documentation
|
||||
* of android/media/MediaCodec#releaseOutputBuffer(int,long) for more details.
|
||||
*
|
||||
* @param buffer the buffer to render
|
||||
* @param time timestamp in nanoseconds of when to render the buffer
|
||||
* @return 0 on success, < 0 otherwise
|
||||
*/
|
||||
int av_mediacodec_render_buffer_at_time(AVMediaCodecBuffer *buffer, int64_t time);
|
||||
|
||||
#endif /* AVCODEC_MEDIACODEC_H */
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
#include "libavutil/version.h"
|
||||
|
||||
#define LIBAVCODEC_VERSION_MAJOR 58
|
||||
#define LIBAVCODEC_VERSION_MINOR 21
|
||||
#define LIBAVCODEC_VERSION_MICRO 104
|
||||
#define LIBAVCODEC_VERSION_MINOR 35
|
||||
#define LIBAVCODEC_VERSION_MICRO 100
|
||||
|
||||
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
|
||||
LIBAVCODEC_VERSION_MINOR, \
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Assert that floating point opperations can be executed.
|
||||
* Assert that floating point operations can be executed.
|
||||
*
|
||||
* This will av_assert0() that the cpu is not in MMX state on X86
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Automatically generated by version.sh, do not manually edit! */
|
||||
#ifndef AVUTIL_FFVERSION_H
|
||||
#define AVUTIL_FFVERSION_H
|
||||
#define FFMPEG_VERSION "N-91434-gcced03dd66"
|
||||
#define FFMPEG_VERSION "4.1"
|
||||
#endif /* AVUTIL_FFVERSION_H */
|
||||
|
||||
@@ -33,6 +33,8 @@
|
||||
* allocated buffer or map it with mmap() when available.
|
||||
* In case of success set *bufptr to the read or mmapped buffer, and
|
||||
* *size to the size in bytes of the buffer in *bufptr.
|
||||
* Unlike mmap this function succeeds with zero sized files, in this
|
||||
* case *bufptr will be set to NULL and *size will be set to 0.
|
||||
* The returned buffer must be released with av_file_unmap().
|
||||
*
|
||||
* @param log_offset loglevel offset used for logging
|
||||
|
||||
@@ -158,6 +158,14 @@ enum AVFrameSideDataType {
|
||||
*/
|
||||
AV_FRAME_DATA_QP_TABLE_DATA,
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Timecode which conforms to SMPTE ST 12-1. The data is an array of 4 uint32_t
|
||||
* where the first uint32_t describes how many (1-3) of the other timecodes are used.
|
||||
* The timecode format is described in the av_timecode_get_smpte_from_framenum()
|
||||
* function in libavutil/timecode.c.
|
||||
*/
|
||||
AV_FRAME_DATA_S12M_TIMECODE,
|
||||
};
|
||||
|
||||
enum AVActiveFormatDescription {
|
||||
|
||||
@@ -343,7 +343,13 @@ char *av_get_pix_fmt_string(char *buf, int buf_size,
|
||||
* format writes the values corresponding to the palette
|
||||
* component c in data[1] to dst, rather than the palette indexes in
|
||||
* data[0]. The behavior is undefined if the format is not paletted.
|
||||
* @param dst_element_size size of elements in dst array (2 or 4 byte)
|
||||
*/
|
||||
void av_read_image_line2(void *dst, const uint8_t *data[4],
|
||||
const int linesize[4], const AVPixFmtDescriptor *desc,
|
||||
int x, int y, int c, int w, int read_pal_component,
|
||||
int dst_element_size);
|
||||
|
||||
void av_read_image_line(uint16_t *dst, const uint8_t *data[4],
|
||||
const int linesize[4], const AVPixFmtDescriptor *desc,
|
||||
int x, int y, int c, int w, int read_pal_component);
|
||||
@@ -361,7 +367,12 @@ void av_read_image_line(uint16_t *dst, const uint8_t *data[4],
|
||||
* @param y the vertical coordinate of the first pixel to write
|
||||
* @param w the width of the line to write, that is the number of
|
||||
* values to write to the image line
|
||||
* @param src_element_size size of elements in src array (2 or 4 byte)
|
||||
*/
|
||||
void av_write_image_line2(const void *src, uint8_t *data[4],
|
||||
const int linesize[4], const AVPixFmtDescriptor *desc,
|
||||
int x, int y, int c, int w, int src_element_size);
|
||||
|
||||
void av_write_image_line(const uint16_t *src, uint8_t *data[4],
|
||||
const int linesize[4], const AVPixFmtDescriptor *desc,
|
||||
int x, int y, int c, int w);
|
||||
|
||||
@@ -42,6 +42,10 @@
|
||||
* This is stored as BGRA on little-endian CPU architectures and ARGB on
|
||||
* big-endian CPUs.
|
||||
*
|
||||
* @note
|
||||
* If the resolution is not a multiple of the chroma subsampling factor
|
||||
* then the chroma plane resolution must be rounded up.
|
||||
*
|
||||
* @par
|
||||
* When the pixel format is palettized RGB32 (AV_PIX_FMT_PAL8), the palettized
|
||||
* image data is stored in AVFrame.data[0]. The palette is transported in
|
||||
@@ -333,6 +337,9 @@ enum AVPixelFormat {
|
||||
AV_PIX_FMT_GRAY14BE, ///< Y , 14bpp, big-endian
|
||||
AV_PIX_FMT_GRAY14LE, ///< Y , 14bpp, little-endian
|
||||
|
||||
AV_PIX_FMT_GRAYF32BE, ///< IEEE-754 single precision Y, 32bpp, big-endian
|
||||
AV_PIX_FMT_GRAYF32LE, ///< IEEE-754 single precision Y, 32bpp, little-endian
|
||||
|
||||
AV_PIX_FMT_NB ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions
|
||||
};
|
||||
|
||||
@@ -401,6 +408,8 @@ enum AVPixelFormat {
|
||||
#define AV_PIX_FMT_GBRPF32 AV_PIX_FMT_NE(GBRPF32BE, GBRPF32LE)
|
||||
#define AV_PIX_FMT_GBRAPF32 AV_PIX_FMT_NE(GBRAPF32BE, GBRAPF32LE)
|
||||
|
||||
#define AV_PIX_FMT_GRAYF32 AV_PIX_FMT_NE(GRAYF32BE, GRAYF32LE)
|
||||
|
||||
#define AV_PIX_FMT_YUVA420P9 AV_PIX_FMT_NE(YUVA420P9BE , YUVA420P9LE)
|
||||
#define AV_PIX_FMT_YUVA422P9 AV_PIX_FMT_NE(YUVA422P9BE , YUVA422P9LE)
|
||||
#define AV_PIX_FMT_YUVA444P9 AV_PIX_FMT_NE(YUVA444P9BE , YUVA444P9LE)
|
||||
|
||||
@@ -79,8 +79,8 @@
|
||||
*/
|
||||
|
||||
#define LIBAVUTIL_VERSION_MAJOR 56
|
||||
#define LIBAVUTIL_VERSION_MINOR 18
|
||||
#define LIBAVUTIL_VERSION_MICRO 102
|
||||
#define LIBAVUTIL_VERSION_MINOR 22
|
||||
#define LIBAVUTIL_VERSION_MICRO 100
|
||||
|
||||
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
|
||||
LIBAVUTIL_VERSION_MINOR, \
|
||||
|
||||
@@ -0,0 +1,294 @@
|
||||
/*
|
||||
SDL_ttf: A companion library to SDL for working with TrueType (tm) fonts
|
||||
Copyright (C) 2001-2019 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/* This library is a wrapper around the excellent FreeType 2.0 library,
|
||||
available at:
|
||||
http://www.freetype.org/
|
||||
*/
|
||||
|
||||
/* Note: In many places, SDL_ttf will say "glyph" when it means "code point."
|
||||
Unicode is hard, we learn as we go, and we apologize for adding to the
|
||||
confusion. */
|
||||
|
||||
#ifndef SDL_TTF_H_
|
||||
#define SDL_TTF_H_
|
||||
|
||||
#include "SDL.h"
|
||||
#include "begin_code.h"
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
|
||||
*/
|
||||
#define SDL_TTF_MAJOR_VERSION 2
|
||||
#define SDL_TTF_MINOR_VERSION 0
|
||||
#define SDL_TTF_PATCHLEVEL 15
|
||||
|
||||
/* This macro can be used to fill a version structure with the compile-time
|
||||
* version of the SDL_ttf library.
|
||||
*/
|
||||
#define SDL_TTF_VERSION(X) \
|
||||
{ \
|
||||
(X)->major = SDL_TTF_MAJOR_VERSION; \
|
||||
(X)->minor = SDL_TTF_MINOR_VERSION; \
|
||||
(X)->patch = SDL_TTF_PATCHLEVEL; \
|
||||
}
|
||||
|
||||
/* Backwards compatibility */
|
||||
#define TTF_MAJOR_VERSION SDL_TTF_MAJOR_VERSION
|
||||
#define TTF_MINOR_VERSION SDL_TTF_MINOR_VERSION
|
||||
#define TTF_PATCHLEVEL SDL_TTF_PATCHLEVEL
|
||||
#define TTF_VERSION(X) SDL_TTF_VERSION(X)
|
||||
|
||||
/**
|
||||
* This is the version number macro for the current SDL_ttf version.
|
||||
*/
|
||||
#define SDL_TTF_COMPILEDVERSION \
|
||||
SDL_VERSIONNUM(SDL_TTF_MAJOR_VERSION, SDL_TTF_MINOR_VERSION, SDL_TTF_PATCHLEVEL)
|
||||
|
||||
/**
|
||||
* This macro will evaluate to true if compiled with SDL_ttf at least X.Y.Z.
|
||||
*/
|
||||
#define SDL_TTF_VERSION_ATLEAST(X, Y, Z) \
|
||||
(SDL_TTF_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
|
||||
|
||||
/* Make sure this is defined (only available in newer SDL versions) */
|
||||
#ifndef SDL_DEPRECATED
|
||||
#define SDL_DEPRECATED
|
||||
#endif
|
||||
|
||||
/* This function gets the version of the dynamically linked SDL_ttf library.
|
||||
it should NOT be used to fill a version structure, instead you should
|
||||
use the SDL_TTF_VERSION() macro.
|
||||
*/
|
||||
extern DECLSPEC const SDL_version * SDLCALL TTF_Linked_Version(void);
|
||||
|
||||
/* ZERO WIDTH NO-BREAKSPACE (Unicode byte order mark) */
|
||||
#define UNICODE_BOM_NATIVE 0xFEFF
|
||||
#define UNICODE_BOM_SWAPPED 0xFFFE
|
||||
|
||||
/* This function tells the library whether UNICODE text is generally
|
||||
byteswapped. A UNICODE BOM character in a string will override
|
||||
this setting for the remainder of that string.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL TTF_ByteSwappedUNICODE(int swapped);
|
||||
|
||||
/* The internal structure containing font information */
|
||||
typedef struct _TTF_Font TTF_Font;
|
||||
|
||||
/* Initialize the TTF engine - returns 0 if successful, -1 on error */
|
||||
extern DECLSPEC int SDLCALL TTF_Init(void);
|
||||
|
||||
/* Open a font file and create a font of the specified point size.
|
||||
* Some .fon fonts will have several sizes embedded in the file, so the
|
||||
* point size becomes the index of choosing which size. If the value
|
||||
* is too high, the last indexed size will be the default. */
|
||||
extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFont(const char *file, int ptsize);
|
||||
extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFontIndex(const char *file, int ptsize, long index);
|
||||
extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFontRW(SDL_RWops *src, int freesrc, int ptsize);
|
||||
extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFontIndexRW(SDL_RWops *src, int freesrc, int ptsize, long index);
|
||||
|
||||
/* Set and retrieve the font style */
|
||||
#define TTF_STYLE_NORMAL 0x00
|
||||
#define TTF_STYLE_BOLD 0x01
|
||||
#define TTF_STYLE_ITALIC 0x02
|
||||
#define TTF_STYLE_UNDERLINE 0x04
|
||||
#define TTF_STYLE_STRIKETHROUGH 0x08
|
||||
extern DECLSPEC int SDLCALL TTF_GetFontStyle(const TTF_Font *font);
|
||||
extern DECLSPEC void SDLCALL TTF_SetFontStyle(TTF_Font *font, int style);
|
||||
extern DECLSPEC int SDLCALL TTF_GetFontOutline(const TTF_Font *font);
|
||||
extern DECLSPEC void SDLCALL TTF_SetFontOutline(TTF_Font *font, int outline);
|
||||
|
||||
/* Set and retrieve FreeType hinter settings */
|
||||
#define TTF_HINTING_NORMAL 0
|
||||
#define TTF_HINTING_LIGHT 1
|
||||
#define TTF_HINTING_MONO 2
|
||||
#define TTF_HINTING_NONE 3
|
||||
extern DECLSPEC int SDLCALL TTF_GetFontHinting(const TTF_Font *font);
|
||||
extern DECLSPEC void SDLCALL TTF_SetFontHinting(TTF_Font *font, int hinting);
|
||||
|
||||
/* Get the total height of the font - usually equal to point size */
|
||||
extern DECLSPEC int SDLCALL TTF_FontHeight(const TTF_Font *font);
|
||||
|
||||
/* Get the offset from the baseline to the top of the font
|
||||
This is a positive value, relative to the baseline.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL TTF_FontAscent(const TTF_Font *font);
|
||||
|
||||
/* Get the offset from the baseline to the bottom of the font
|
||||
This is a negative value, relative to the baseline.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL TTF_FontDescent(const TTF_Font *font);
|
||||
|
||||
/* Get the recommended spacing between lines of text for this font */
|
||||
extern DECLSPEC int SDLCALL TTF_FontLineSkip(const TTF_Font *font);
|
||||
|
||||
/* Get/Set whether or not kerning is allowed for this font */
|
||||
extern DECLSPEC int SDLCALL TTF_GetFontKerning(const TTF_Font *font);
|
||||
extern DECLSPEC void SDLCALL TTF_SetFontKerning(TTF_Font *font, int allowed);
|
||||
|
||||
/* Get the number of faces of the font */
|
||||
extern DECLSPEC long SDLCALL TTF_FontFaces(const TTF_Font *font);
|
||||
|
||||
/* Get the font face attributes, if any */
|
||||
extern DECLSPEC int SDLCALL TTF_FontFaceIsFixedWidth(const TTF_Font *font);
|
||||
extern DECLSPEC char * SDLCALL TTF_FontFaceFamilyName(const TTF_Font *font);
|
||||
extern DECLSPEC char * SDLCALL TTF_FontFaceStyleName(const TTF_Font *font);
|
||||
|
||||
/* Check wether a glyph is provided by the font or not */
|
||||
extern DECLSPEC int SDLCALL TTF_GlyphIsProvided(const TTF_Font *font, Uint16 ch);
|
||||
|
||||
/* Get the metrics (dimensions) of a glyph
|
||||
To understand what these metrics mean, here is a useful link:
|
||||
http://freetype.sourceforge.net/freetype2/docs/tutorial/step2.html
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL TTF_GlyphMetrics(TTF_Font *font, Uint16 ch,
|
||||
int *minx, int *maxx,
|
||||
int *miny, int *maxy, int *advance);
|
||||
|
||||
/* Get the dimensions of a rendered string of text */
|
||||
extern DECLSPEC int SDLCALL TTF_SizeText(TTF_Font *font, const char *text, int *w, int *h);
|
||||
extern DECLSPEC int SDLCALL TTF_SizeUTF8(TTF_Font *font, const char *text, int *w, int *h);
|
||||
extern DECLSPEC int SDLCALL TTF_SizeUNICODE(TTF_Font *font, const Uint16 *text, int *w, int *h);
|
||||
|
||||
/* Create an 8-bit palettized surface and render the given text at
|
||||
fast quality with the given font and color. The 0 pixel is the
|
||||
colorkey, giving a transparent background, and the 1 pixel is set
|
||||
to the text color.
|
||||
This function returns the new surface, or NULL if there was an error.
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Solid(TTF_Font *font,
|
||||
const char *text, SDL_Color fg);
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUTF8_Solid(TTF_Font *font,
|
||||
const char *text, SDL_Color fg);
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUNICODE_Solid(TTF_Font *font,
|
||||
const Uint16 *text, SDL_Color fg);
|
||||
|
||||
/* Create an 8-bit palettized surface and render the given glyph at
|
||||
fast quality with the given font and color. The 0 pixel is the
|
||||
colorkey, giving a transparent background, and the 1 pixel is set
|
||||
to the text color. The glyph is rendered without any padding or
|
||||
centering in the X direction, and aligned normally in the Y direction.
|
||||
This function returns the new surface, or NULL if there was an error.
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderGlyph_Solid(TTF_Font *font,
|
||||
Uint16 ch, SDL_Color fg);
|
||||
|
||||
/* Create an 8-bit palettized surface and render the given text at
|
||||
high quality with the given font and colors. The 0 pixel is background,
|
||||
while other pixels have varying degrees of the foreground color.
|
||||
This function returns the new surface, or NULL if there was an error.
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Shaded(TTF_Font *font,
|
||||
const char *text, SDL_Color fg, SDL_Color bg);
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUTF8_Shaded(TTF_Font *font,
|
||||
const char *text, SDL_Color fg, SDL_Color bg);
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUNICODE_Shaded(TTF_Font *font,
|
||||
const Uint16 *text, SDL_Color fg, SDL_Color bg);
|
||||
|
||||
/* Create an 8-bit palettized surface and render the given glyph at
|
||||
high quality with the given font and colors. The 0 pixel is background,
|
||||
while other pixels have varying degrees of the foreground color.
|
||||
The glyph is rendered without any padding or centering in the X
|
||||
direction, and aligned normally in the Y direction.
|
||||
This function returns the new surface, or NULL if there was an error.
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderGlyph_Shaded(TTF_Font *font,
|
||||
Uint16 ch, SDL_Color fg, SDL_Color bg);
|
||||
|
||||
/* Create a 32-bit ARGB surface and render the given text at high quality,
|
||||
using alpha blending to dither the font with the given color.
|
||||
This function returns the new surface, or NULL if there was an error.
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Blended(TTF_Font *font,
|
||||
const char *text, SDL_Color fg);
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUTF8_Blended(TTF_Font *font,
|
||||
const char *text, SDL_Color fg);
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUNICODE_Blended(TTF_Font *font,
|
||||
const Uint16 *text, SDL_Color fg);
|
||||
|
||||
|
||||
/* Create a 32-bit ARGB surface and render the given text at high quality,
|
||||
using alpha blending to dither the font with the given color.
|
||||
Text is wrapped to multiple lines on line endings and on word boundaries
|
||||
if it extends beyond wrapLength in pixels.
|
||||
This function returns the new surface, or NULL if there was an error.
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Blended_Wrapped(TTF_Font *font,
|
||||
const char *text, SDL_Color fg, Uint32 wrapLength);
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUTF8_Blended_Wrapped(TTF_Font *font,
|
||||
const char *text, SDL_Color fg, Uint32 wrapLength);
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUNICODE_Blended_Wrapped(TTF_Font *font,
|
||||
const Uint16 *text, SDL_Color fg, Uint32 wrapLength);
|
||||
|
||||
/* Create a 32-bit ARGB surface and render the given glyph at high quality,
|
||||
using alpha blending to dither the font with the given color.
|
||||
The glyph is rendered without any padding or centering in the X
|
||||
direction, and aligned normally in the Y direction.
|
||||
This function returns the new surface, or NULL if there was an error.
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderGlyph_Blended(TTF_Font *font,
|
||||
Uint16 ch, SDL_Color fg);
|
||||
|
||||
/* For compatibility with previous versions, here are the old functions */
|
||||
#define TTF_RenderText(font, text, fg, bg) \
|
||||
TTF_RenderText_Shaded(font, text, fg, bg)
|
||||
#define TTF_RenderUTF8(font, text, fg, bg) \
|
||||
TTF_RenderUTF8_Shaded(font, text, fg, bg)
|
||||
#define TTF_RenderUNICODE(font, text, fg, bg) \
|
||||
TTF_RenderUNICODE_Shaded(font, text, fg, bg)
|
||||
|
||||
/* Close an opened font file */
|
||||
extern DECLSPEC void SDLCALL TTF_CloseFont(TTF_Font *font);
|
||||
|
||||
/* De-initialize the TTF engine */
|
||||
extern DECLSPEC void SDLCALL TTF_Quit(void);
|
||||
|
||||
/* Check if the TTF engine is initialized */
|
||||
extern DECLSPEC int SDLCALL TTF_WasInit(void);
|
||||
|
||||
/* Get the kerning size of two glyphs indices */
|
||||
/* DEPRECATED: this function requires FreeType font indexes, not glyphs,
|
||||
by accident, which we don't expose through this API, so it could give
|
||||
wildly incorrect results, especially with non-ASCII values.
|
||||
Going forward, please use TTF_GetFontKerningSizeGlyphs() instead, which
|
||||
does what you probably expected this function to do. */
|
||||
extern DECLSPEC int TTF_GetFontKerningSize(TTF_Font *font, int prev_index, int index) SDL_DEPRECATED;
|
||||
|
||||
/* Get the kerning size of two glyphs */
|
||||
extern DECLSPEC int TTF_GetFontKerningSizeGlyphs(TTF_Font *font, Uint16 previous_ch, Uint16 ch);
|
||||
|
||||
/* We'll use SDL for reporting errors */
|
||||
#define TTF_SetError SDL_SetError
|
||||
#define TTF_GetError SDL_GetError
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* SDL_TTF_H_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -409,6 +409,7 @@ enum AVCodecID {
|
||||
AV_CODEC_ID_DXV,
|
||||
AV_CODEC_ID_SCREENPRESSO,
|
||||
AV_CODEC_ID_RSCC,
|
||||
AV_CODEC_ID_AVS2,
|
||||
|
||||
AV_CODEC_ID_Y41P = 0x8000,
|
||||
AV_CODEC_ID_AVRP,
|
||||
@@ -446,6 +447,11 @@ enum AVCodecID {
|
||||
AV_CODEC_ID_SVG,
|
||||
AV_CODEC_ID_GDV,
|
||||
AV_CODEC_ID_FITS,
|
||||
AV_CODEC_ID_IMM4,
|
||||
AV_CODEC_ID_PROSUMER,
|
||||
AV_CODEC_ID_MWSC,
|
||||
AV_CODEC_ID_WCMV,
|
||||
AV_CODEC_ID_RASC,
|
||||
|
||||
/* various PCM "codecs" */
|
||||
AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
|
||||
@@ -485,6 +491,7 @@ enum AVCodecID {
|
||||
AV_CODEC_ID_PCM_S64BE,
|
||||
AV_CODEC_ID_PCM_F16LE,
|
||||
AV_CODEC_ID_PCM_F24LE,
|
||||
AV_CODEC_ID_PCM_VIDC,
|
||||
|
||||
/* various ADPCM codecs */
|
||||
AV_CODEC_ID_ADPCM_IMA_QT = 0x11000,
|
||||
@@ -1359,6 +1366,12 @@ enum AVPacketSideDataType {
|
||||
*/
|
||||
AV_PKT_DATA_ENCRYPTION_INFO,
|
||||
|
||||
/**
|
||||
* Active Format Description data consisting of a single byte as specified
|
||||
* in ETSI TS 101 154 using AVActiveFormatDescription enum.
|
||||
*/
|
||||
AV_PKT_DATA_AFD,
|
||||
|
||||
/**
|
||||
* The number of side data types.
|
||||
* This is not part of the public API/ABI in the sense that it may
|
||||
@@ -1614,6 +1627,7 @@ typedef struct AVCodecContext {
|
||||
* The allocated memory should be AV_INPUT_BUFFER_PADDING_SIZE bytes larger
|
||||
* than extradata_size to avoid problems if it is read with the bitstream reader.
|
||||
* The bytewise contents of extradata must not depend on the architecture or CPU endianness.
|
||||
* Must be allocated with the av_malloc() family of functions.
|
||||
* - encoding: Set/allocated/freed by libavcodec.
|
||||
* - decoding: Set/allocated/freed by user.
|
||||
*/
|
||||
@@ -5768,6 +5782,7 @@ typedef struct AVBitStreamFilter {
|
||||
int (*init)(AVBSFContext *ctx);
|
||||
int (*filter)(AVBSFContext *ctx, AVPacket *pkt);
|
||||
void (*close)(AVBSFContext *ctx);
|
||||
void (*flush)(AVBSFContext *ctx);
|
||||
} AVBitStreamFilter;
|
||||
|
||||
#if FF_API_OLD_BSF
|
||||
@@ -5894,6 +5909,11 @@ int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt);
|
||||
*/
|
||||
int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt);
|
||||
|
||||
/**
|
||||
* Reset the internal bitstream filter state / flush internal buffers.
|
||||
*/
|
||||
void av_bsf_flush(AVBSFContext *ctx);
|
||||
|
||||
/**
|
||||
* Free a bitstream filter context and everything associated with it; write NULL
|
||||
* into the supplied pointer.
|
||||
|
||||
@@ -85,4 +85,17 @@ typedef struct MediaCodecBuffer AVMediaCodecBuffer;
|
||||
*/
|
||||
int av_mediacodec_release_buffer(AVMediaCodecBuffer *buffer, int render);
|
||||
|
||||
/**
|
||||
* Release a MediaCodec buffer and render it at the given time to the surface
|
||||
* that is associated with the decoder. The timestamp must be within one second
|
||||
* of the current java/lang/System#nanoTime() (which is implemented using
|
||||
* CLOCK_MONOTONIC on Android). See the Android MediaCodec documentation
|
||||
* of android/media/MediaCodec#releaseOutputBuffer(int,long) for more details.
|
||||
*
|
||||
* @param buffer the buffer to render
|
||||
* @param time timestamp in nanoseconds of when to render the buffer
|
||||
* @return 0 on success, < 0 otherwise
|
||||
*/
|
||||
int av_mediacodec_render_buffer_at_time(AVMediaCodecBuffer *buffer, int64_t time);
|
||||
|
||||
#endif /* AVCODEC_MEDIACODEC_H */
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
#include "libavutil/version.h"
|
||||
|
||||
#define LIBAVCODEC_VERSION_MAJOR 58
|
||||
#define LIBAVCODEC_VERSION_MINOR 21
|
||||
#define LIBAVCODEC_VERSION_MICRO 104
|
||||
#define LIBAVCODEC_VERSION_MINOR 35
|
||||
#define LIBAVCODEC_VERSION_MICRO 100
|
||||
|
||||
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
|
||||
LIBAVCODEC_VERSION_MINOR, \
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Assert that floating point opperations can be executed.
|
||||
* Assert that floating point operations can be executed.
|
||||
*
|
||||
* This will av_assert0() that the cpu is not in MMX state on X86
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* Automatically generated by version.sh, do not manually edit! */
|
||||
#ifndef AVUTIL_FFVERSION_H
|
||||
#define AVUTIL_FFVERSION_H
|
||||
#define FFMPEG_VERSION "N-91434-gcced03dd66"
|
||||
#define FFMPEG_VERSION "4.1"
|
||||
#endif /* AVUTIL_FFVERSION_H */
|
||||
|
||||
@@ -33,6 +33,8 @@
|
||||
* allocated buffer or map it with mmap() when available.
|
||||
* In case of success set *bufptr to the read or mmapped buffer, and
|
||||
* *size to the size in bytes of the buffer in *bufptr.
|
||||
* Unlike mmap this function succeeds with zero sized files, in this
|
||||
* case *bufptr will be set to NULL and *size will be set to 0.
|
||||
* The returned buffer must be released with av_file_unmap().
|
||||
*
|
||||
* @param log_offset loglevel offset used for logging
|
||||
|
||||
@@ -158,6 +158,14 @@ enum AVFrameSideDataType {
|
||||
*/
|
||||
AV_FRAME_DATA_QP_TABLE_DATA,
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Timecode which conforms to SMPTE ST 12-1. The data is an array of 4 uint32_t
|
||||
* where the first uint32_t describes how many (1-3) of the other timecodes are used.
|
||||
* The timecode format is described in the av_timecode_get_smpte_from_framenum()
|
||||
* function in libavutil/timecode.c.
|
||||
*/
|
||||
AV_FRAME_DATA_S12M_TIMECODE,
|
||||
};
|
||||
|
||||
enum AVActiveFormatDescription {
|
||||
|
||||
@@ -343,7 +343,13 @@ char *av_get_pix_fmt_string(char *buf, int buf_size,
|
||||
* format writes the values corresponding to the palette
|
||||
* component c in data[1] to dst, rather than the palette indexes in
|
||||
* data[0]. The behavior is undefined if the format is not paletted.
|
||||
* @param dst_element_size size of elements in dst array (2 or 4 byte)
|
||||
*/
|
||||
void av_read_image_line2(void *dst, const uint8_t *data[4],
|
||||
const int linesize[4], const AVPixFmtDescriptor *desc,
|
||||
int x, int y, int c, int w, int read_pal_component,
|
||||
int dst_element_size);
|
||||
|
||||
void av_read_image_line(uint16_t *dst, const uint8_t *data[4],
|
||||
const int linesize[4], const AVPixFmtDescriptor *desc,
|
||||
int x, int y, int c, int w, int read_pal_component);
|
||||
@@ -361,7 +367,12 @@ void av_read_image_line(uint16_t *dst, const uint8_t *data[4],
|
||||
* @param y the vertical coordinate of the first pixel to write
|
||||
* @param w the width of the line to write, that is the number of
|
||||
* values to write to the image line
|
||||
* @param src_element_size size of elements in src array (2 or 4 byte)
|
||||
*/
|
||||
void av_write_image_line2(const void *src, uint8_t *data[4],
|
||||
const int linesize[4], const AVPixFmtDescriptor *desc,
|
||||
int x, int y, int c, int w, int src_element_size);
|
||||
|
||||
void av_write_image_line(const uint16_t *src, uint8_t *data[4],
|
||||
const int linesize[4], const AVPixFmtDescriptor *desc,
|
||||
int x, int y, int c, int w);
|
||||
|
||||
@@ -42,6 +42,10 @@
|
||||
* This is stored as BGRA on little-endian CPU architectures and ARGB on
|
||||
* big-endian CPUs.
|
||||
*
|
||||
* @note
|
||||
* If the resolution is not a multiple of the chroma subsampling factor
|
||||
* then the chroma plane resolution must be rounded up.
|
||||
*
|
||||
* @par
|
||||
* When the pixel format is palettized RGB32 (AV_PIX_FMT_PAL8), the palettized
|
||||
* image data is stored in AVFrame.data[0]. The palette is transported in
|
||||
@@ -333,6 +337,9 @@ enum AVPixelFormat {
|
||||
AV_PIX_FMT_GRAY14BE, ///< Y , 14bpp, big-endian
|
||||
AV_PIX_FMT_GRAY14LE, ///< Y , 14bpp, little-endian
|
||||
|
||||
AV_PIX_FMT_GRAYF32BE, ///< IEEE-754 single precision Y, 32bpp, big-endian
|
||||
AV_PIX_FMT_GRAYF32LE, ///< IEEE-754 single precision Y, 32bpp, little-endian
|
||||
|
||||
AV_PIX_FMT_NB ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions
|
||||
};
|
||||
|
||||
@@ -401,6 +408,8 @@ enum AVPixelFormat {
|
||||
#define AV_PIX_FMT_GBRPF32 AV_PIX_FMT_NE(GBRPF32BE, GBRPF32LE)
|
||||
#define AV_PIX_FMT_GBRAPF32 AV_PIX_FMT_NE(GBRAPF32BE, GBRAPF32LE)
|
||||
|
||||
#define AV_PIX_FMT_GRAYF32 AV_PIX_FMT_NE(GRAYF32BE, GRAYF32LE)
|
||||
|
||||
#define AV_PIX_FMT_YUVA420P9 AV_PIX_FMT_NE(YUVA420P9BE , YUVA420P9LE)
|
||||
#define AV_PIX_FMT_YUVA422P9 AV_PIX_FMT_NE(YUVA422P9BE , YUVA422P9LE)
|
||||
#define AV_PIX_FMT_YUVA444P9 AV_PIX_FMT_NE(YUVA444P9BE , YUVA444P9LE)
|
||||
|
||||
@@ -79,8 +79,8 @@
|
||||
*/
|
||||
|
||||
#define LIBAVUTIL_VERSION_MAJOR 56
|
||||
#define LIBAVUTIL_VERSION_MINOR 18
|
||||
#define LIBAVUTIL_VERSION_MICRO 102
|
||||
#define LIBAVUTIL_VERSION_MINOR 22
|
||||
#define LIBAVUTIL_VERSION_MICRO 100
|
||||
|
||||
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
|
||||
LIBAVUTIL_VERSION_MINOR, \
|
||||
|
||||
@@ -956,6 +956,7 @@ int ERR_load_ASN1_strings(void);
|
||||
# define ASN1_F_DO_BUF 142
|
||||
# define ASN1_F_DO_TCREATE 222
|
||||
# define ASN1_F_I2D_ASN1_BIO_STREAM 211
|
||||
# define ASN1_F_I2D_ASN1_OBJECT 143
|
||||
# define ASN1_F_I2D_DSA_PUBKEY 161
|
||||
# define ASN1_F_I2D_EC_PUBKEY 181
|
||||
# define ASN1_F_I2D_PRIVATEKEY 163
|
||||
|
||||
@@ -730,26 +730,26 @@ __bio_h__attr__((__format__(__printf__, 3, 0)));
|
||||
|
||||
BIO_METHOD *BIO_meth_new(int type, const char *name);
|
||||
void BIO_meth_free(BIO_METHOD *biom);
|
||||
int (*BIO_meth_get_write(BIO_METHOD *biom)) (BIO *, const char *, int);
|
||||
int (*BIO_meth_get_write(const BIO_METHOD *biom)) (BIO *, const char *, int);
|
||||
int BIO_meth_set_write(BIO_METHOD *biom,
|
||||
int (*write) (BIO *, const char *, int));
|
||||
int (*BIO_meth_get_read(BIO_METHOD *biom)) (BIO *, char *, int);
|
||||
int (*BIO_meth_get_read(const BIO_METHOD *biom)) (BIO *, char *, int);
|
||||
int BIO_meth_set_read(BIO_METHOD *biom,
|
||||
int (*read) (BIO *, char *, int));
|
||||
int (*BIO_meth_get_puts(BIO_METHOD *biom)) (BIO *, const char *);
|
||||
int (*BIO_meth_get_puts(const BIO_METHOD *biom)) (BIO *, const char *);
|
||||
int BIO_meth_set_puts(BIO_METHOD *biom,
|
||||
int (*puts) (BIO *, const char *));
|
||||
int (*BIO_meth_get_gets(BIO_METHOD *biom)) (BIO *, char *, int);
|
||||
int (*BIO_meth_get_gets(const BIO_METHOD *biom)) (BIO *, char *, int);
|
||||
int BIO_meth_set_gets(BIO_METHOD *biom,
|
||||
int (*gets) (BIO *, char *, int));
|
||||
long (*BIO_meth_get_ctrl(BIO_METHOD *biom)) (BIO *, int, long, void *);
|
||||
long (*BIO_meth_get_ctrl(const BIO_METHOD *biom)) (BIO *, int, long, void *);
|
||||
int BIO_meth_set_ctrl(BIO_METHOD *biom,
|
||||
long (*ctrl) (BIO *, int, long, void *));
|
||||
int (*BIO_meth_get_create(BIO_METHOD *bion)) (BIO *);
|
||||
int (*BIO_meth_get_create(const BIO_METHOD *bion)) (BIO *);
|
||||
int BIO_meth_set_create(BIO_METHOD *biom, int (*create) (BIO *));
|
||||
int (*BIO_meth_get_destroy(BIO_METHOD *biom)) (BIO *);
|
||||
int (*BIO_meth_get_destroy(const BIO_METHOD *biom)) (BIO *);
|
||||
int BIO_meth_set_destroy(BIO_METHOD *biom, int (*destroy) (BIO *));
|
||||
long (*BIO_meth_get_callback_ctrl(BIO_METHOD *biom))
|
||||
long (*BIO_meth_get_callback_ctrl(const BIO_METHOD *biom))
|
||||
(BIO *, int, BIO_info_cb *);
|
||||
int BIO_meth_set_callback_ctrl(BIO_METHOD *biom,
|
||||
long (*callback_ctrl) (BIO *, int,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -119,25 +119,76 @@ void *BN_GENCB_get_arg(BN_GENCB *cb);
|
||||
* on the size of the number */
|
||||
|
||||
/*
|
||||
* number of Miller-Rabin iterations for an error rate of less than 2^-80 for
|
||||
* random 'b'-bit input, b >= 100 (taken from table 4.4 in the Handbook of
|
||||
* Applied Cryptography [Menezes, van Oorschot, Vanstone; CRC Press 1996];
|
||||
* original paper: Damgaard, Landrock, Pomerance: Average case error
|
||||
* estimates for the strong probable prime test. -- Math. Comp. 61 (1993)
|
||||
* 177-194)
|
||||
* BN_prime_checks_for_size() returns the number of Miller-Rabin iterations
|
||||
* that will be done for checking that a random number is probably prime. The
|
||||
* error rate for accepting a composite number as prime depends on the size of
|
||||
* the prime |b|. The error rates used are for calculating an RSA key with 2 primes,
|
||||
* and so the level is what you would expect for a key of double the size of the
|
||||
* prime.
|
||||
*
|
||||
* This table is generated using the algorithm of FIPS PUB 186-4
|
||||
* Digital Signature Standard (DSS), section F.1, page 117.
|
||||
* (https://dx.doi.org/10.6028/NIST.FIPS.186-4)
|
||||
*
|
||||
* The following magma script was used to generate the output:
|
||||
* securitybits:=125;
|
||||
* k:=1024;
|
||||
* for t:=1 to 65 do
|
||||
* for M:=3 to Floor(2*Sqrt(k-1)-1) do
|
||||
* S:=0;
|
||||
* // Sum over m
|
||||
* for m:=3 to M do
|
||||
* s:=0;
|
||||
* // Sum over j
|
||||
* for j:=2 to m do
|
||||
* s+:=(RealField(32)!2)^-(j+(k-1)/j);
|
||||
* end for;
|
||||
* S+:=2^(m-(m-1)*t)*s;
|
||||
* end for;
|
||||
* A:=2^(k-2-M*t);
|
||||
* B:=8*(Pi(RealField(32))^2-6)/3*2^(k-2)*S;
|
||||
* pkt:=2.00743*Log(2)*k*2^-k*(A+B);
|
||||
* seclevel:=Floor(-Log(2,pkt));
|
||||
* if seclevel ge securitybits then
|
||||
* printf "k: %5o, security: %o bits (t: %o, M: %o)\n",k,seclevel,t,M;
|
||||
* break;
|
||||
* end if;
|
||||
* end for;
|
||||
* if seclevel ge securitybits then break; end if;
|
||||
* end for;
|
||||
*
|
||||
* It can be run online at:
|
||||
* http://magma.maths.usyd.edu.au/calc
|
||||
*
|
||||
* And will output:
|
||||
* k: 1024, security: 129 bits (t: 6, M: 23)
|
||||
*
|
||||
* k is the number of bits of the prime, securitybits is the level we want to
|
||||
* reach.
|
||||
*
|
||||
* prime length | RSA key size | # MR tests | security level
|
||||
* -------------+--------------|------------+---------------
|
||||
* (b) >= 6394 | >= 12788 | 3 | 256 bit
|
||||
* (b) >= 3747 | >= 7494 | 3 | 192 bit
|
||||
* (b) >= 1345 | >= 2690 | 4 | 128 bit
|
||||
* (b) >= 1080 | >= 2160 | 5 | 128 bit
|
||||
* (b) >= 852 | >= 1704 | 5 | 112 bit
|
||||
* (b) >= 476 | >= 952 | 5 | 80 bit
|
||||
* (b) >= 400 | >= 800 | 6 | 80 bit
|
||||
* (b) >= 347 | >= 694 | 7 | 80 bit
|
||||
* (b) >= 308 | >= 616 | 8 | 80 bit
|
||||
* (b) >= 55 | >= 110 | 27 | 64 bit
|
||||
* (b) >= 6 | >= 12 | 34 | 64 bit
|
||||
*/
|
||||
# define BN_prime_checks_for_size(b) ((b) >= 1300 ? 2 : \
|
||||
(b) >= 850 ? 3 : \
|
||||
(b) >= 650 ? 4 : \
|
||||
(b) >= 550 ? 5 : \
|
||||
(b) >= 450 ? 6 : \
|
||||
(b) >= 400 ? 7 : \
|
||||
(b) >= 350 ? 8 : \
|
||||
(b) >= 300 ? 9 : \
|
||||
(b) >= 250 ? 12 : \
|
||||
(b) >= 200 ? 15 : \
|
||||
(b) >= 150 ? 18 : \
|
||||
/* b >= 100 */ 27)
|
||||
|
||||
# define BN_prime_checks_for_size(b) ((b) >= 3747 ? 3 : \
|
||||
(b) >= 1345 ? 4 : \
|
||||
(b) >= 476 ? 5 : \
|
||||
(b) >= 400 ? 6 : \
|
||||
(b) >= 347 ? 7 : \
|
||||
(b) >= 308 ? 8 : \
|
||||
(b) >= 55 ? 27 : \
|
||||
/* b >= 6 */ 34)
|
||||
|
||||
# define BN_num_bytes(a) ((BN_num_bits(a)+7)/8)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -187,7 +187,7 @@ void DH_meth_free(DH_METHOD *dhm);
|
||||
DH_METHOD *DH_meth_dup(const DH_METHOD *dhm);
|
||||
const char *DH_meth_get0_name(const DH_METHOD *dhm);
|
||||
int DH_meth_set1_name(DH_METHOD *dhm, const char *name);
|
||||
int DH_meth_get_flags(DH_METHOD *dhm);
|
||||
int DH_meth_get_flags(const DH_METHOD *dhm);
|
||||
int DH_meth_set_flags(DH_METHOD *dhm, int flags);
|
||||
void *DH_meth_get0_app_data(const DH_METHOD *dhm);
|
||||
int DH_meth_set0_app_data(DH_METHOD *dhm, void *app_data);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -146,10 +146,12 @@ int DSAparams_print_fp(FILE *fp, const DSA *x);
|
||||
int DSA_print_fp(FILE *bp, const DSA *x, int off);
|
||||
# endif
|
||||
|
||||
# define DSS_prime_checks 50
|
||||
# define DSS_prime_checks 64
|
||||
/*
|
||||
* Primality test according to FIPS PUB 186[-1], Appendix 2.1: 50 rounds of
|
||||
* Rabin-Miller
|
||||
* Primality test according to FIPS PUB 186-4, Appendix C.3. Since we only
|
||||
* have one value here we set the number of checks to 64 which is the 128 bit
|
||||
* security level that is the highest level and valid for creating a 3072 bit
|
||||
* DSA key.
|
||||
*/
|
||||
# define DSA_is_prime(n, callback, cb_arg) \
|
||||
BN_is_prime(n, DSS_prime_checks, callback, NULL, cb_arg)
|
||||
@@ -186,7 +188,7 @@ void DSA_meth_free(DSA_METHOD *dsam);
|
||||
DSA_METHOD *DSA_meth_dup(const DSA_METHOD *dsam);
|
||||
const char *DSA_meth_get0_name(const DSA_METHOD *dsam);
|
||||
int DSA_meth_set1_name(DSA_METHOD *dsam, const char *name);
|
||||
int DSA_meth_get_flags(DSA_METHOD *dsam);
|
||||
int DSA_meth_get_flags(const DSA_METHOD *dsam);
|
||||
int DSA_meth_set_flags(DSA_METHOD *dsam, int flags);
|
||||
void *DSA_meth_get0_app_data(const DSA_METHOD *dsam);
|
||||
int DSA_meth_set0_app_data(DSA_METHOD *dsam, void *app_data);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2002-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -1424,6 +1424,7 @@ int ERR_load_EC_strings(void);
|
||||
# define EC_F_EC_GFP_NIST_FIELD_MUL 200
|
||||
# define EC_F_EC_GFP_NIST_FIELD_SQR 201
|
||||
# define EC_F_EC_GFP_NIST_GROUP_SET_CURVE 202
|
||||
# define EC_F_EC_GFP_SIMPLE_BLIND_COORDINATES 287
|
||||
# define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT 165
|
||||
# define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE 166
|
||||
# define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE 102
|
||||
|
||||
@@ -1351,34 +1351,34 @@ void EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth,
|
||||
const char *type,
|
||||
const char *value));
|
||||
|
||||
void EVP_PKEY_meth_get_init(EVP_PKEY_METHOD *pmeth,
|
||||
void EVP_PKEY_meth_get_init(const EVP_PKEY_METHOD *pmeth,
|
||||
int (**pinit) (EVP_PKEY_CTX *ctx));
|
||||
|
||||
void EVP_PKEY_meth_get_copy(EVP_PKEY_METHOD *pmeth,
|
||||
void EVP_PKEY_meth_get_copy(const EVP_PKEY_METHOD *pmeth,
|
||||
int (**pcopy) (EVP_PKEY_CTX *dst,
|
||||
EVP_PKEY_CTX *src));
|
||||
|
||||
void EVP_PKEY_meth_get_cleanup(EVP_PKEY_METHOD *pmeth,
|
||||
void EVP_PKEY_meth_get_cleanup(const EVP_PKEY_METHOD *pmeth,
|
||||
void (**pcleanup) (EVP_PKEY_CTX *ctx));
|
||||
|
||||
void EVP_PKEY_meth_get_paramgen(EVP_PKEY_METHOD *pmeth,
|
||||
void EVP_PKEY_meth_get_paramgen(const EVP_PKEY_METHOD *pmeth,
|
||||
int (**pparamgen_init) (EVP_PKEY_CTX *ctx),
|
||||
int (**pparamgen) (EVP_PKEY_CTX *ctx,
|
||||
EVP_PKEY *pkey));
|
||||
|
||||
void EVP_PKEY_meth_get_keygen(EVP_PKEY_METHOD *pmeth,
|
||||
void EVP_PKEY_meth_get_keygen(const EVP_PKEY_METHOD *pmeth,
|
||||
int (**pkeygen_init) (EVP_PKEY_CTX *ctx),
|
||||
int (**pkeygen) (EVP_PKEY_CTX *ctx,
|
||||
EVP_PKEY *pkey));
|
||||
|
||||
void EVP_PKEY_meth_get_sign(EVP_PKEY_METHOD *pmeth,
|
||||
void EVP_PKEY_meth_get_sign(const EVP_PKEY_METHOD *pmeth,
|
||||
int (**psign_init) (EVP_PKEY_CTX *ctx),
|
||||
int (**psign) (EVP_PKEY_CTX *ctx,
|
||||
unsigned char *sig, size_t *siglen,
|
||||
const unsigned char *tbs,
|
||||
size_t tbslen));
|
||||
|
||||
void EVP_PKEY_meth_get_verify(EVP_PKEY_METHOD *pmeth,
|
||||
void EVP_PKEY_meth_get_verify(const EVP_PKEY_METHOD *pmeth,
|
||||
int (**pverify_init) (EVP_PKEY_CTX *ctx),
|
||||
int (**pverify) (EVP_PKEY_CTX *ctx,
|
||||
const unsigned char *sig,
|
||||
@@ -1386,7 +1386,7 @@ void EVP_PKEY_meth_get_verify(EVP_PKEY_METHOD *pmeth,
|
||||
const unsigned char *tbs,
|
||||
size_t tbslen));
|
||||
|
||||
void EVP_PKEY_meth_get_verify_recover(EVP_PKEY_METHOD *pmeth,
|
||||
void EVP_PKEY_meth_get_verify_recover(const EVP_PKEY_METHOD *pmeth,
|
||||
int (**pverify_recover_init) (EVP_PKEY_CTX
|
||||
*ctx),
|
||||
int (**pverify_recover) (EVP_PKEY_CTX
|
||||
@@ -1398,7 +1398,7 @@ void EVP_PKEY_meth_get_verify_recover(EVP_PKEY_METHOD *pmeth,
|
||||
char *tbs,
|
||||
size_t tbslen));
|
||||
|
||||
void EVP_PKEY_meth_get_signctx(EVP_PKEY_METHOD *pmeth,
|
||||
void EVP_PKEY_meth_get_signctx(const EVP_PKEY_METHOD *pmeth,
|
||||
int (**psignctx_init) (EVP_PKEY_CTX *ctx,
|
||||
EVP_MD_CTX *mctx),
|
||||
int (**psignctx) (EVP_PKEY_CTX *ctx,
|
||||
@@ -1406,7 +1406,7 @@ void EVP_PKEY_meth_get_signctx(EVP_PKEY_METHOD *pmeth,
|
||||
size_t *siglen,
|
||||
EVP_MD_CTX *mctx));
|
||||
|
||||
void EVP_PKEY_meth_get_verifyctx(EVP_PKEY_METHOD *pmeth,
|
||||
void EVP_PKEY_meth_get_verifyctx(const EVP_PKEY_METHOD *pmeth,
|
||||
int (**pverifyctx_init) (EVP_PKEY_CTX *ctx,
|
||||
EVP_MD_CTX *mctx),
|
||||
int (**pverifyctx) (EVP_PKEY_CTX *ctx,
|
||||
@@ -1414,7 +1414,7 @@ void EVP_PKEY_meth_get_verifyctx(EVP_PKEY_METHOD *pmeth,
|
||||
int siglen,
|
||||
EVP_MD_CTX *mctx));
|
||||
|
||||
void EVP_PKEY_meth_get_encrypt(EVP_PKEY_METHOD *pmeth,
|
||||
void EVP_PKEY_meth_get_encrypt(const EVP_PKEY_METHOD *pmeth,
|
||||
int (**pencrypt_init) (EVP_PKEY_CTX *ctx),
|
||||
int (**pencryptfn) (EVP_PKEY_CTX *ctx,
|
||||
unsigned char *out,
|
||||
@@ -1422,7 +1422,7 @@ void EVP_PKEY_meth_get_encrypt(EVP_PKEY_METHOD *pmeth,
|
||||
const unsigned char *in,
|
||||
size_t inlen));
|
||||
|
||||
void EVP_PKEY_meth_get_decrypt(EVP_PKEY_METHOD *pmeth,
|
||||
void EVP_PKEY_meth_get_decrypt(const EVP_PKEY_METHOD *pmeth,
|
||||
int (**pdecrypt_init) (EVP_PKEY_CTX *ctx),
|
||||
int (**pdecrypt) (EVP_PKEY_CTX *ctx,
|
||||
unsigned char *out,
|
||||
@@ -1430,13 +1430,13 @@ void EVP_PKEY_meth_get_decrypt(EVP_PKEY_METHOD *pmeth,
|
||||
const unsigned char *in,
|
||||
size_t inlen));
|
||||
|
||||
void EVP_PKEY_meth_get_derive(EVP_PKEY_METHOD *pmeth,
|
||||
void EVP_PKEY_meth_get_derive(const EVP_PKEY_METHOD *pmeth,
|
||||
int (**pderive_init) (EVP_PKEY_CTX *ctx),
|
||||
int (**pderive) (EVP_PKEY_CTX *ctx,
|
||||
unsigned char *key,
|
||||
size_t *keylen));
|
||||
|
||||
void EVP_PKEY_meth_get_ctrl(EVP_PKEY_METHOD *pmeth,
|
||||
void EVP_PKEY_meth_get_ctrl(const EVP_PKEY_METHOD *pmeth,
|
||||
int (**pctrl) (EVP_PKEY_CTX *ctx, int type, int p1,
|
||||
void *p2),
|
||||
int (**pctrl_str) (EVP_PKEY_CTX *ctx,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 2000-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -92,7 +92,6 @@ typedef struct ocsp_resp_bytes_st OCSP_RESPBYTES;
|
||||
# define V_OCSP_RESPID_KEY 1
|
||||
|
||||
DEFINE_STACK_OF(OCSP_RESPID)
|
||||
DECLARE_ASN1_FUNCTIONS(OCSP_RESPID)
|
||||
|
||||
typedef struct ocsp_revoked_info_st OCSP_REVOKEDINFO;
|
||||
|
||||
@@ -159,8 +158,6 @@ int OCSP_REQ_CTX_i2d(OCSP_REQ_CTX *rctx, const ASN1_ITEM *it,
|
||||
int OCSP_REQ_CTX_nbio_d2i(OCSP_REQ_CTX *rctx, ASN1_VALUE **pval,
|
||||
const ASN1_ITEM *it);
|
||||
BIO *OCSP_REQ_CTX_get0_mem_bio(OCSP_REQ_CTX *rctx);
|
||||
int OCSP_REQ_CTX_i2d(OCSP_REQ_CTX *rctx, const ASN1_ITEM *it,
|
||||
ASN1_VALUE *val);
|
||||
int OCSP_REQ_CTX_http(OCSP_REQ_CTX *rctx, const char *op, const char *path);
|
||||
int OCSP_REQ_CTX_set1_req(OCSP_REQ_CTX *rctx, OCSP_REQUEST *req);
|
||||
int OCSP_REQ_CTX_add1_header(OCSP_REQ_CTX *rctx,
|
||||
@@ -194,6 +191,8 @@ int OCSP_response_status(OCSP_RESPONSE *resp);
|
||||
OCSP_BASICRESP *OCSP_response_get1_basic(OCSP_RESPONSE *resp);
|
||||
|
||||
const ASN1_OCTET_STRING *OCSP_resp_get0_signature(const OCSP_BASICRESP *bs);
|
||||
const X509_ALGOR *OCSP_resp_get0_tbs_sigalg(const OCSP_BASICRESP *bs);
|
||||
const OCSP_RESPDATA *OCSP_resp_get0_respdata(const OCSP_BASICRESP *bs);
|
||||
int OCSP_resp_get0_signer(OCSP_BASICRESP *bs, X509 **signer,
|
||||
STACK_OF(X509) *extra_certs);
|
||||
|
||||
|
||||
@@ -26,6 +26,9 @@ extern "C" {
|
||||
# define OPENSSL_SYS_WIN64A 1
|
||||
#endif
|
||||
#define OPENSSL_MIN_API 0x10100000L
|
||||
#ifndef OPENSSL_NO_COMP
|
||||
# define OPENSSL_NO_COMP
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_MD2
|
||||
# define OPENSSL_NO_MD2
|
||||
#endif
|
||||
@@ -106,12 +109,18 @@ extern "C" {
|
||||
* still won't see them if the library has been built to disable deprecated
|
||||
* functions.
|
||||
*/
|
||||
#if defined(OPENSSL_NO_DEPRECATED)
|
||||
# define DECLARE_DEPRECATED(f)
|
||||
#elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)
|
||||
# define DECLARE_DEPRECATED(f) f __attribute__ ((deprecated));
|
||||
#else
|
||||
# define DECLARE_DEPRECATED(f) f;
|
||||
#ifndef DECLARE_DEPRECATED
|
||||
# if defined(OPENSSL_NO_DEPRECATED)
|
||||
# define DECLARE_DEPRECATED(f)
|
||||
# else
|
||||
# define DECLARE_DEPRECATED(f) f;
|
||||
# ifdef __GNUC__
|
||||
# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0)
|
||||
# undef DECLARE_DEPRECATED
|
||||
# define DECLARE_DEPRECATED(f) f __attribute__ ((deprecated));
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef OPENSSL_FILE
|
||||
|
||||
@@ -39,11 +39,11 @@ extern "C" {
|
||||
* (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for
|
||||
* major minor fix final patch/beta)
|
||||
*/
|
||||
# define OPENSSL_VERSION_NUMBER 0x10100090L
|
||||
# define OPENSSL_VERSION_NUMBER 0x101000b0L
|
||||
# ifdef OPENSSL_FIPS
|
||||
# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.0i-fips-dev xx XXX xxxx"
|
||||
# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.0k-fips-dev xx XXX xxxx"
|
||||
# else
|
||||
# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.0i-dev xx XXX xxxx"
|
||||
# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.0k-dev xx XXX xxxx"
|
||||
# endif
|
||||
|
||||
/*-
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -374,7 +374,7 @@ void RSA_meth_free(RSA_METHOD *meth);
|
||||
RSA_METHOD *RSA_meth_dup(const RSA_METHOD *meth);
|
||||
const char *RSA_meth_get0_name(const RSA_METHOD *meth);
|
||||
int RSA_meth_set1_name(RSA_METHOD *meth, const char *name);
|
||||
int RSA_meth_get_flags(RSA_METHOD *meth);
|
||||
int RSA_meth_get_flags(const RSA_METHOD *meth);
|
||||
int RSA_meth_set_flags(RSA_METHOD *meth, int flags);
|
||||
void *RSA_meth_get0_app_data(const RSA_METHOD *meth);
|
||||
int RSA_meth_set0_app_data(RSA_METHOD *meth, void *app_data);
|
||||
@@ -407,9 +407,9 @@ int RSA_meth_set_priv_dec(RSA_METHOD *rsa,
|
||||
unsigned char *to, RSA *rsa,
|
||||
int padding));
|
||||
int (*RSA_meth_get_mod_exp(const RSA_METHOD *meth))
|
||||
(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx);
|
||||
(BIGNUM *r0, const BIGNUM *i, RSA *rsa, BN_CTX *ctx);
|
||||
int RSA_meth_set_mod_exp(RSA_METHOD *rsa,
|
||||
int (*mod_exp) (BIGNUM *r0, const BIGNUM *I, RSA *rsa,
|
||||
int (*mod_exp) (BIGNUM *r0, const BIGNUM *i, RSA *rsa,
|
||||
BN_CTX *ctx));
|
||||
int (*RSA_meth_get_bn_mod_exp(const RSA_METHOD *meth))
|
||||
(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||
|
||||
@@ -967,8 +967,8 @@ size_t SSL_get_peer_finished(const SSL *s, void *buf, size_t count);
|
||||
# define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02
|
||||
# define SSL_VERIFY_CLIENT_ONCE 0x04
|
||||
|
||||
# define OpenSSL_add_ssl_algorithms() SSL_library_init()
|
||||
# if OPENSSL_API_COMPAT < 0x10100000L
|
||||
# define OpenSSL_add_ssl_algorithms() SSL_library_init()
|
||||
# define SSLeay_add_ssl_algorithms() SSL_library_init()
|
||||
# endif
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -252,9 +252,15 @@ extern "C" {
|
||||
# define SSL3_CT_FORTEZZA_DMS 20
|
||||
/*
|
||||
* SSL3_CT_NUMBER is used to size arrays and it must be large enough to
|
||||
* contain all of the cert types defined either for SSLv3 and TLSv1.
|
||||
* contain all of the cert types defined for *either* SSLv3 and TLSv1.
|
||||
*/
|
||||
# define SSL3_CT_NUMBER 9
|
||||
# define SSL3_CT_NUMBER 10
|
||||
|
||||
# if defined(TLS_CT_NUMBER)
|
||||
# if TLS_CT_NUMBER != SSL3_CT_NUMBER
|
||||
# error "SSL/TLS CT_NUMBER values do not match"
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# define SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS 0x0001
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1999-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -28,21 +28,6 @@
|
||||
# undef i2d_ECPKPARAMETERS
|
||||
# define i2d_ECPKPARAMETERS i2d_UC_ECPKPARAMETERS
|
||||
|
||||
/*
|
||||
* These functions do not seem to exist! However, I'm paranoid... Original
|
||||
* command in x509v3.h: These functions are being redefined in another
|
||||
* directory, and clash when the linker is case-insensitive, so let's hide
|
||||
* them a little, by giving them an extra 'o' at the beginning of the name...
|
||||
*/
|
||||
# undef X509v3_cleanup_extensions
|
||||
# define X509v3_cleanup_extensions oX509v3_cleanup_extensions
|
||||
# undef X509v3_add_extension
|
||||
# define X509v3_add_extension oX509v3_add_extension
|
||||
# undef X509v3_add_netscape_extensions
|
||||
# define X509v3_add_netscape_extensions oX509v3_add_netscape_extensions
|
||||
# undef X509v3_add_standard_extensions
|
||||
# define X509v3_add_standard_extensions oX509v3_add_standard_extensions
|
||||
|
||||
/* This one clashes with CMS_data_create */
|
||||
# undef cms_Data_create
|
||||
# define cms_Data_create priv_cms_Data_create
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -883,7 +883,13 @@ SSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB,(void (*)(void))cb)
|
||||
* when correcting this number, correct also SSL3_CT_NUMBER in ssl3.h (see
|
||||
* comment there)
|
||||
*/
|
||||
# define TLS_CT_NUMBER 9
|
||||
# define TLS_CT_NUMBER 10
|
||||
|
||||
# if defined(SSL3_CT_NUMBER)
|
||||
# if TLS_CT_NUMBER != SSL3_CT_NUMBER
|
||||
# error "SSL/TLS CT_NUMBER values do not match"
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# define TLS1_FINISH_MAC_LENGTH 12
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
||||
* Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
@@ -397,7 +397,7 @@ int (*X509_LOOKUP_meth_get_new_item(const X509_LOOKUP_METHOD* method))
|
||||
(X509_LOOKUP *ctx);
|
||||
|
||||
int X509_LOOKUP_meth_set_free(X509_LOOKUP_METHOD *method,
|
||||
void (*free) (X509_LOOKUP *ctx));
|
||||
void (*free_fn) (X509_LOOKUP *ctx));
|
||||
void (*X509_LOOKUP_meth_get_free(const X509_LOOKUP_METHOD* method))
|
||||
(X509_LOOKUP *ctx);
|
||||
|
||||
|
||||
@@ -9,11 +9,14 @@ QT -= core gui
|
||||
TARGET = moonlight-common-c
|
||||
TEMPLATE = lib
|
||||
|
||||
# Support debug and release builds from command line for CI
|
||||
CONFIG += debug_and_release
|
||||
# Build a static library
|
||||
CONFIG += staticlib
|
||||
|
||||
# Ensure symbols are always generated
|
||||
CONFIG += force_debug_info
|
||||
# Disable warnings
|
||||
CONFIG += warn_off
|
||||
|
||||
# Include global qmake defs
|
||||
include(../globaldefs.pri)
|
||||
|
||||
win32 {
|
||||
INCLUDEPATH += $$PWD/../libs/windows/include
|
||||
@@ -65,7 +68,6 @@ INCLUDEPATH += \
|
||||
$$RS_DIR \
|
||||
$$ENET_DIR/include \
|
||||
$$COMMON_C_DIR/src
|
||||
CONFIG += warn_off staticlib
|
||||
DEFINES += HAS_SOCKLEN_T
|
||||
|
||||
CONFIG(debug, debug|release) {
|
||||
|
||||
@@ -3,19 +3,22 @@ SUBDIRS = \
|
||||
moonlight-common-c \
|
||||
qmdnsengine \
|
||||
app \
|
||||
soundio \
|
||||
h264bitstream
|
||||
|
||||
# Build the dependencies in parallel before the final app
|
||||
app.depends = qmdnsengine moonlight-common-c soundio h264bitstream
|
||||
win32 {
|
||||
app.depends = qmdnsengine moonlight-common-c h264bitstream
|
||||
win32:!winrt {
|
||||
SUBDIRS += AntiHooking
|
||||
app.depends += AntiHooking
|
||||
}
|
||||
!winrt {
|
||||
SUBDIRS += soundio
|
||||
app.depends += soundio
|
||||
}
|
||||
|
||||
# Support debug and release builds from command line for CI
|
||||
CONFIG += debug_and_release
|
||||
|
||||
# Run our compile tests
|
||||
load(configure)
|
||||
qtCompileTest(SLVideo)
|
||||
qtCompileTest(SL)
|
||||
|
||||
@@ -4,11 +4,17 @@ QT += network
|
||||
TARGET = qmdnsengine
|
||||
TEMPLATE = lib
|
||||
|
||||
# Support debug and release builds from command line for CI
|
||||
CONFIG += debug_and_release
|
||||
# Build a static library
|
||||
CONFIG += staticlib
|
||||
|
||||
# Ensure symbols are always generated
|
||||
CONFIG += force_debug_info
|
||||
# Disable warnings
|
||||
CONFIG += warn_off
|
||||
|
||||
# C++11 is required to build
|
||||
CONFIG += c++11
|
||||
|
||||
# Include global qmake defs
|
||||
include(../globaldefs.pri)
|
||||
|
||||
QMDNSE_DIR = $$PWD/qmdnsengine/src
|
||||
DEFINES += \
|
||||
@@ -66,5 +72,3 @@ SOURCES += \
|
||||
INCLUDEPATH += \
|
||||
$$QMDNSE_DIR/include \
|
||||
$$PWD/qmdnsengine
|
||||
|
||||
CONFIG += warn_off staticlib c++11
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
./configure --extra-cflags="-mmacosx-version-min=10.10" --enable-pic --enable-shared --disable-static --disable-all --enable-avcodec --enable-decoder=h264 --enable-decoder=hevc --enable-hwaccel=h264_videotoolbox --enable-hwaccel=hevc_videotoolbox
|
||||
./configure --extra-cflags="-mmacosx-version-min=10.11" --install-name-dir=@loader_path/../lib --enable-pic --enable-shared --disable-static --disable-all --enable-avcodec --enable-decoder=h264 --enable-decoder=hevc --enable-hwaccel=h264_videotoolbox --enable-hwaccel=hevc_videotoolbox
|
||||
make clean
|
||||
make -j4
|
||||
make -j4
|
||||
codesign -s 45U78722YL libavcodec/libavcodec.dylib
|
||||
codesign -s 45U78722YL libavutil/libavutil.dylib
|
||||
codesign -vv libavcodec/libavcodec.dylib
|
||||
codesign -vv libavutil/libavutil.dylib
|
||||
@@ -0,0 +1,50 @@
|
||||
BUILD_CONFIG="release"
|
||||
|
||||
fail()
|
||||
{
|
||||
echo "$1" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ "$STEAMLINK_SDK_PATH" == "" ]; then
|
||||
fail "You must set STEAMLINK_SDK_PATH to build for Steam Link"
|
||||
fi
|
||||
|
||||
BUILD_ROOT=$PWD/build
|
||||
SOURCE_ROOT=$PWD
|
||||
BUILD_FOLDER=$BUILD_ROOT/build-$BUILD_CONFIG
|
||||
DEPLOY_FOLDER=$BUILD_ROOT/deploy-$BUILD_CONFIG
|
||||
INSTALLER_FOLDER=$BUILD_ROOT/installer-$BUILD_CONFIG
|
||||
VERSION=`cat $SOURCE_ROOT/app/version.txt`
|
||||
|
||||
echo Cleaning output directories
|
||||
rm -rf $BUILD_FOLDER
|
||||
rm -rf $DEPLOY_FOLDER
|
||||
rm -rf $INSTALLER_FOLDER
|
||||
mkdir $BUILD_ROOT
|
||||
mkdir $BUILD_FOLDER
|
||||
mkdir $DEPLOY_FOLDER
|
||||
mkdir $INSTALLER_FOLDER
|
||||
|
||||
echo Initializing Steam Link SDK
|
||||
source $STEAMLINK_SDK_PATH/setenv.sh || fail "SL SDK initialization failed!"
|
||||
|
||||
echo Configuring the project
|
||||
pushd $BUILD_FOLDER
|
||||
qmake $SOURCE_ROOT/moonlight-qt.pro || fail "Qmake failed!"
|
||||
popd
|
||||
|
||||
echo Compiling Moonlight in $BUILD_CONFIG configuration
|
||||
pushd $BUILD_FOLDER
|
||||
make -j$(nproc) $(echo "$BUILD_CONFIG" | tr '[:upper:]' '[:lower:]') || fail "Make failed!"
|
||||
popd
|
||||
|
||||
echo Creating app bundle
|
||||
mkdir -p $DEPLOY_FOLDER/steamlink/apps/moonlight/bin
|
||||
cp $BUILD_FOLDER/app/moonlight $DEPLOY_FOLDER/steamlink/apps/moonlight/bin/ || fail "Binary copy failed!"
|
||||
cp $SOURCE_ROOT/app/deploy/steamlink/* $DEPLOY_FOLDER/steamlink/apps/moonlight/ || fail "Metadata copy failed!"
|
||||
pushd $DEPLOY_FOLDER
|
||||
zip -r $INSTALLER_FOLDER/Moonlight-SteamLink-$VERSION.zip . || fail "Zip failed!"
|
||||
popd
|
||||
|
||||
echo Build completed
|
||||
@@ -0,0 +1,4 @@
|
||||
rem Run from Qt command prompt without changing directories
|
||||
|
||||
del symbols.zip
|
||||
7z a symbols.zip *.pdb -r -xr!Qt5WebEngineCore*
|
||||
@@ -11,10 +11,13 @@ if [ "$BUILD_CONFIG" != "Debug" ] && [ "$BUILD_CONFIG" != "Release" ]; then
|
||||
fail "Invalid build configuration"
|
||||
fi
|
||||
|
||||
[ "$SIGNING_KEY" == "" ] || git diff-index --quiet HEAD -- || fail "Signed release builds must not have unstaged changes!"
|
||||
|
||||
BUILD_ROOT=$PWD/build
|
||||
SOURCE_ROOT=$PWD
|
||||
BUILD_FOLDER=$BUILD_ROOT/build-$BUILD_CONFIG
|
||||
INSTALLER_FOLDER=$BUILD_ROOT/installer-$BUILD_CONFIG
|
||||
VERSION=`cat $SOURCE_ROOT/app/version.txt`
|
||||
|
||||
echo Cleaning output directories
|
||||
rm -rf $BUILD_FOLDER
|
||||
@@ -35,8 +38,8 @@ popd
|
||||
|
||||
echo Saving dSYM file
|
||||
pushd $BUILD_FOLDER
|
||||
dsymutil app/Moonlight.app/Contents/MacOS/Moonlight -o Moonlight.dsym || fail "dSYM creation failed!"
|
||||
cp -R Moonlight.dsym $INSTALLER_FOLDER || fail "dSYM copy failed!"
|
||||
dsymutil app/Moonlight.app/Contents/MacOS/Moonlight -o Moonlight-$VERSION.dsym || fail "dSYM creation failed!"
|
||||
cp -R Moonlight-$VERSION.dsym $INSTALLER_FOLDER || fail "dSYM copy failed!"
|
||||
popd
|
||||
|
||||
echo Copying dylib dependencies
|
||||
@@ -46,9 +49,30 @@ cp $SOURCE_ROOT/libs/mac/lib/*.dylib $BUILD_FOLDER/app/Moonlight.app/Contents/li
|
||||
echo Creating app bundle
|
||||
EXTRA_ARGS=
|
||||
if [ "$BUILD_CONFIG" == "Debug" ]; then EXTRA_ARGS="$EXTRA_ARGS -use-debug-libs"; fi
|
||||
if [ "$SIGNING_KEY" != "" ]; then EXTRA_ARGS="$EXTRA_ARGS -codesign=$SIGNING_KEY"; fi
|
||||
echo Extra deployment arguments: $EXTRA_ARGS
|
||||
macdeployqt $BUILD_FOLDER/app/Moonlight.app $EXTRA_ARGS -qmldir=$SOURCE_ROOT/app/gui -appstore-compliant || fail "macdeployqt failed!"
|
||||
|
||||
if [ "$SIGNING_KEY" != "" ]; then
|
||||
echo Signing app bundle
|
||||
codesign --force --deep --options runtime --timestamp --sign $SIGNING_KEY $BUILD_FOLDER/app/Moonlight.app || fail "Signing failed!"
|
||||
fi
|
||||
|
||||
echo Creating DMG
|
||||
create-dmg $BUILD_FOLDER/app/Moonlight.app $INSTALLER_FOLDER || fail "create-dmg failed!"
|
||||
|
||||
if [ "$NOTARY_USERNAME" != "" ] && [ "$NOTARY_PASSWORD" != "" ]; then
|
||||
echo Uploading to App Notary service
|
||||
xcrun altool -t osx -f $INSTALLER_FOLDER/Moonlight\ $VERSION.dmg --primary-bundle-id com.moonlight-stream.Moonlight --notarize-app --username "$NOTARY_USERNAME" --password "$NOTARY_PASSWORD" --asc-provider $SIGNING_KEY || fail "Notary submission failed"
|
||||
|
||||
echo Waiting 5 minutes for notarization to complete
|
||||
sleep 300
|
||||
|
||||
echo Getting notarization status
|
||||
xcrun altool -t osx --notarization-history 0 --username "$NOTARY_USERNAME" --password "$NOTARY_PASSWORD" --asc-provider $SIGNING_KEY || fail "Unable to fetch notarization history!"
|
||||
|
||||
echo Stapling notary ticket to DMG
|
||||
xcrun stapler staple -v $INSTALLER_FOLDER/Moonlight\ $VERSION.dmg || fail "Notary ticket stapling failed!"
|
||||
fi
|
||||
|
||||
mv $INSTALLER_FOLDER/Moonlight\ $VERSION.dmg $INSTALLER_FOLDER/Moonlight-$VERSION.dmg
|
||||
echo Build successful
|
||||
@@ -17,6 +17,13 @@ if /I "%BUILD_CONFIG%"=="debug" (
|
||||
set BUILD_CONFIG=release
|
||||
set SIGN=1
|
||||
set MUST_DEPLOY_SYMBOLS=1
|
||||
|
||||
rem Fail if there are unstaged changes
|
||||
git diff-index --quiet HEAD --
|
||||
if !ERRORLEVEL! NEQ 0 (
|
||||
echo Signed release builds must not have unstaged changes!
|
||||
exit /b 1
|
||||
)
|
||||
) else (
|
||||
echo Invalid build configuration
|
||||
exit /b 1
|
||||
@@ -43,6 +50,7 @@ set BUILD_FOLDER=%BUILD_ROOT%\build-%ARCH%-%BUILD_CONFIG%
|
||||
set DEPLOY_FOLDER=%BUILD_ROOT%\deploy-%ARCH%-%BUILD_CONFIG%
|
||||
set INSTALLER_FOLDER=%BUILD_ROOT%\installer-%ARCH%-%BUILD_CONFIG%
|
||||
set SYMBOLS_FOLDER=%BUILD_ROOT%\symbols-%ARCH%-%BUILD_CONFIG%
|
||||
set /p VERSION=<%SOURCE_ROOT%\app\version.txt
|
||||
|
||||
echo Cleaning output directories
|
||||
rmdir /s /q %DEPLOY_FOLDER%
|
||||
@@ -74,7 +82,7 @@ for /r "%BUILD_FOLDER%" %%f in (*.pdb) do (
|
||||
)
|
||||
copy %SOURCE_ROOT%\libs\windows\lib\%ARCH%\*.pdb %SYMBOLS_FOLDER%
|
||||
if !ERRORLEVEL! NEQ 0 goto Error
|
||||
7z a %SYMBOLS_FOLDER%\MoonlightDebuggingSymbols.zip %SYMBOLS_FOLDER%\*.pdb
|
||||
7z a %SYMBOLS_FOLDER%\MoonlightDebuggingSymbols-%ARCH%-%VERSION%.zip %SYMBOLS_FOLDER%\*.pdb
|
||||
if !ERRORLEVEL! NEQ 0 goto Error
|
||||
|
||||
if "%ML_SYMBOL_STORE%" NEQ "" (
|
||||
@@ -88,6 +96,17 @@ if "%ML_SYMBOL_STORE%" NEQ "" (
|
||||
)
|
||||
)
|
||||
|
||||
if "%ML_SYMBOL_ARCHIVE%" NEQ "" (
|
||||
echo Copying PDB ZIP to symbol archive: %ML_SYMBOL_ARCHIVE%
|
||||
copy %SYMBOLS_FOLDER%\MoonlightDebuggingSymbols-%ARCH%-%VERSION%.zip %ML_SYMBOL_ARCHIVE%
|
||||
if !ERRORLEVEL! NEQ 0 goto Error
|
||||
) else (
|
||||
if "%MUST_DEPLOY_SYMBOLS%"=="1" (
|
||||
echo "A symbol archive directory must be specified in ML_SYMBOL_ARCHIVE for signed release builds"
|
||||
exit /b 1
|
||||
)
|
||||
)
|
||||
|
||||
echo Copying DLL dependencies
|
||||
copy %SOURCE_ROOT%\libs\windows\lib\%ARCH%\*.dll %DEPLOY_FOLDER%
|
||||
if !ERRORLEVEL! NEQ 0 goto Error
|
||||
@@ -96,12 +115,24 @@ echo Copying AntiHooking.dll
|
||||
copy %BUILD_FOLDER%\AntiHooking\%BUILD_CONFIG%\AntiHooking.dll %DEPLOY_FOLDER%
|
||||
if !ERRORLEVEL! NEQ 0 goto Error
|
||||
|
||||
echo Copying d3dx9_43.dll from DirectX SDK
|
||||
expand "%DXSDK_DIR%\Redist\Jun2010_d3dx9_43_%ARCH%.cab" -F:d3dx9_43.dll %DEPLOY_FOLDER%
|
||||
if !ERRORLEVEL! NEQ 0 goto Error
|
||||
|
||||
echo Copying GC mapping list
|
||||
copy %SOURCE_ROOT%\app\SDL_GameControllerDB\gamecontrollerdb.txt %DEPLOY_FOLDER%
|
||||
if !ERRORLEVEL! NEQ 0 goto Error
|
||||
|
||||
echo Deploying Qt dependencies
|
||||
windeployqt.exe --dir %DEPLOY_FOLDER% --%BUILD_CONFIG% --qmldir %SOURCE_ROOT%\app\gui --no-opengl-sw --no-compiler-runtime %BUILD_FOLDER%\app\%BUILD_CONFIG%\Moonlight.exe
|
||||
windeployqt.exe --dir %DEPLOY_FOLDER% --%BUILD_CONFIG% --qmldir %SOURCE_ROOT%\app\gui --no-opengl-sw --no-compiler-runtime --no-qmltooling %BUILD_FOLDER%\app\%BUILD_CONFIG%\Moonlight.exe
|
||||
if !ERRORLEVEL! NEQ 0 goto Error
|
||||
|
||||
echo Generating QML cache
|
||||
forfiles /p %DEPLOY_FOLDER% /m *.qml /s /c "cmd /c qmlcachegen.exe @path"
|
||||
if !ERRORLEVEL! NEQ 0 goto Error
|
||||
|
||||
echo Deleting original QML files
|
||||
forfiles /p %DEPLOY_FOLDER% /m *.qml /s /c "cmd /c del @path"
|
||||
if !ERRORLEVEL! NEQ 0 goto Error
|
||||
|
||||
echo Harvesting files for WiX
|
||||
@@ -150,6 +181,9 @@ if "%SIGN%"=="1" (
|
||||
if !ERRORLEVEL! NEQ 0 goto Error
|
||||
)
|
||||
|
||||
rem Rename the installer to match the publishing convention
|
||||
ren %INSTALLER_FOLDER%\MoonlightSetup.exe MoonlightSetup-%ARCH%-%VERSION%.exe
|
||||
|
||||
echo Building portable package
|
||||
rem This must be done after WiX harvesting and signing, since the VCRT dlls are MS signed
|
||||
rem and should not be harvested for inclusion in the full installer
|
||||
@@ -157,19 +191,19 @@ copy "%VCToolsRedistDir%%ARCH%\Microsoft.VC141.CRT\*.dll" %DEPLOY_FOLDER%
|
||||
rem This file tells Moonlight that it's a portable installation
|
||||
echo. > %DEPLOY_FOLDER%\portable.dat
|
||||
if !ERRORLEVEL! NEQ 0 goto Error
|
||||
7z a %INSTALLER_FOLDER%\MoonlightPortable.zip %DEPLOY_FOLDER%\*
|
||||
7z a %INSTALLER_FOLDER%\MoonlightPortable-%ARCH%-%VERSION%.zip %DEPLOY_FOLDER%\*
|
||||
if !ERRORLEVEL! NEQ 0 goto Error
|
||||
|
||||
if /i "%APPVEYOR%"=="true" (
|
||||
echo Pushing artifacts
|
||||
appveyor PushArtifact %INSTALLER_FOLDER%\MoonlightSetup.exe -FileName MoonlightSetup-%ARCH%-%BUILD_CONFIG%.exe
|
||||
appveyor PushArtifact %INSTALLER_FOLDER%\MoonlightSetup-%ARCH%-%VERSION%.exe -FileName MoonlightSetup-%ARCH%-%BUILD_CONFIG%.exe
|
||||
if !ERRORLEVEL! NEQ 0 goto Error
|
||||
appveyor PushArtifact %INSTALLER_FOLDER%\MoonlightPortable.zip -FileName MoonlightPortable-%ARCH%-%BUILD_CONFIG%.zip
|
||||
appveyor PushArtifact %INSTALLER_FOLDER%\MoonlightPortable-%ARCH%-%VERSION%.zip -FileName MoonlightPortable-%ARCH%-%BUILD_CONFIG%.zip
|
||||
if !ERRORLEVEL! NEQ 0 goto Error
|
||||
appveyor PushArtifact %SYMBOLS_FOLDER%\MoonlightDebuggingSymbols.zip -FileName MoonlightDebuggingSymbols-%ARCH%-%BUILD_CONFIG%.zip
|
||||
appveyor PushArtifact %SYMBOLS_FOLDER%\MoonlightDebuggingSymbols-%ARCH%-%VERSION%.zip -FileName MoonlightDebuggingSymbols-%ARCH%-%BUILD_CONFIG%.zip
|
||||
)
|
||||
|
||||
echo Build successful!
|
||||
echo Build successful for Moonlight v%VERSION%!
|
||||
exit /b 0
|
||||
|
||||
:Error
|
||||
|
||||
@@ -9,15 +9,15 @@ QT -= core gui
|
||||
TARGET = soundio
|
||||
TEMPLATE = lib
|
||||
|
||||
# Support debug and release builds from command line for CI
|
||||
CONFIG += debug_and_release
|
||||
|
||||
# Ensure symbols are always generated
|
||||
CONFIG += force_debug_info
|
||||
|
||||
# Build a static library
|
||||
CONFIG += staticlib
|
||||
|
||||
# Disable warnings
|
||||
CONFIG += warn_off
|
||||
|
||||
# Include global qmake defs
|
||||
include(../globaldefs.pri)
|
||||
|
||||
# Force MSVC to compile C as C++ for atomic support
|
||||
*-msvc {
|
||||
QMAKE_CFLAGS += /TP
|
||||
@@ -28,9 +28,6 @@ CONFIG += staticlib
|
||||
QMAKE_CFLAGS += -std=gnu99
|
||||
}
|
||||
|
||||
# Disable warnings
|
||||
CONFIG += warn_off
|
||||
|
||||
unix:!macx {
|
||||
CONFIG += link_pkgconfig
|
||||
|
||||
@@ -44,11 +41,6 @@ unix:!macx {
|
||||
}
|
||||
}
|
||||
|
||||
CONFIG(release, debug|release) {
|
||||
# Disable asserts on release builds
|
||||
DEFINES += NDEBUG
|
||||
}
|
||||
|
||||
DEFINES += \
|
||||
SOUNDIO_STATIC_LIBRARY \
|
||||
SOUNDIO_VERSION_MAJOR=1 \
|
||||
|
||||