update client visuals, performance and diagnostics
This commit is contained in:
1 parent
361892bf0b
commit
875bab0310
155 files changed
+40855
-421
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 182 KiB |
@@ -0,0 +1,2 @@
|
||||
#include <windows.h>
|
||||
101 ICON "assets\\window.ico"
|
||||
@@ -148,6 +148,14 @@
|
||||
<EnableUAC>false</EnableUAC>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="client.rc" />
|
||||
<Image Include="assets\window.ico" />
|
||||
<ClInclude Include="window_branding.h" />
|
||||
<ClInclude Include="game\qol_events.h" />
|
||||
<ClInclude Include="modules\qol_state.h" />
|
||||
<ClInclude Include="modules\qol_modules.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\vendor\imgui\backends\imgui_impl_dx11.cpp" />
|
||||
<ClCompile Include="..\vendor\imgui\backends\imgui_impl_win32.cpp" />
|
||||
@@ -205,12 +213,14 @@
|
||||
<ClInclude Include="modules\trade_io.h" />
|
||||
<ClInclude Include="modules\trade_profile.h" />
|
||||
<ClInclude Include="gui\notifications.h" />
|
||||
<ClInclude Include="gui\startup_intro.h" />
|
||||
<ClInclude Include="modules\module.h" />
|
||||
<ClInclude Include="modules\module_manager.h" />
|
||||
<ClInclude Include="modules\optimizations.h" />
|
||||
<ClInclude Include="modules\setting.h" />
|
||||
<ClInclude Include="modules\watermark.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(ProjectDir)..\vendor\freetype\freetype.props" />
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
|
||||
@@ -125,6 +125,10 @@ namespace config {
|
||||
state.enabled = loaded->second.enabled; state.key = loaded->second.key;
|
||||
state.x = loaded->second.x; state.y = loaded->second.y;
|
||||
for (auto& entry : loaded->second.settings) state.settings[entry.first] = entry.second;
|
||||
if(m->name()=="atmosphere")for(const auto& alias:{std::pair<const char*,const char*>{"screen rain","rain density"},{"screen snow","snow density"}}) {
|
||||
auto old=loaded->second.settings.find(alias.first);
|
||||
if(old!=loaded->second.settings.end() && !loaded->second.settings.count(alias.second))state.settings[alias.second]=old->second;
|
||||
}
|
||||
}
|
||||
m->set_toggle_key(state.key); m->hud_pos = ImVec2(state.x, state.y); m->ui.binding = false;
|
||||
for (auto& s : m->settings()) {
|
||||
|
||||
+24
-2
@@ -7,8 +7,27 @@
|
||||
|
||||
namespace game {
|
||||
|
||||
// messages show up in the Visual Studio output window, or in Sysinternals DebugView
|
||||
inline void log(const std::string& msg) { OutputDebugStringA(("[amnesia] " + msg + "\n").c_str()); }
|
||||
inline std::wstring debug_log_path;
|
||||
inline void initialize_debug_log(HMODULE module) {
|
||||
#ifdef _DEBUG
|
||||
wchar_t path[32768]{};
|
||||
if(!GetModuleFileNameW(module,path,32768))return;
|
||||
debug_log_path=path;
|
||||
const auto slash=debug_log_path.find_last_of(L"\\/");
|
||||
if(slash==std::wstring::npos){debug_log_path.clear();return;}
|
||||
debug_log_path.resize(slash+1);debug_log_path+=L"startup-debug.log";
|
||||
HANDLE file=CreateFileW(debug_log_path.c_str(),GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,nullptr,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,nullptr);
|
||||
if(file!=INVALID_HANDLE_VALUE)CloseHandle(file);
|
||||
#endif
|
||||
}
|
||||
// Debug builds also leave a flushed startup trace beside the DLL.
|
||||
inline void log(const std::string& msg) {
|
||||
const auto text="[amnesia] "+msg+"\n";
|
||||
OutputDebugStringA(text.c_str());
|
||||
if(debug_log_path.empty())return;
|
||||
HANDLE file=CreateFileW(debug_log_path.c_str(),FILE_APPEND_DATA,FILE_SHARE_READ|FILE_SHARE_WRITE,nullptr,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,nullptr);
|
||||
if(file!=INVALID_HANDLE_VALUE){DWORD written=0;WriteFile(file,text.data(),DWORD(text.size()),&written,nullptr);CloseHandle(file);}
|
||||
}
|
||||
|
||||
class game_hook {
|
||||
public:
|
||||
@@ -17,7 +36,10 @@ namespace game {
|
||||
bool require_unique = false) {
|
||||
if (!signature || !*signature) { log(std::string(name) + ": no signature set"); return false; }
|
||||
|
||||
log(std::string(name)+": scanning");
|
||||
const auto started=GetTickCount64();
|
||||
uint8_t* addr = sigscan::find(signature, require_unique);
|
||||
log(std::string(name)+": scan completed in "+std::to_string(GetTickCount64()-started)+" ms");
|
||||
if (!addr) { log(std::string(name) + ": signature missing or ambiguous (game updated?)"); return false; }
|
||||
|
||||
if (MH_CreateHook(addr, detour, original) != MH_OK) { log(std::string(name) + ": MH_CreateHook failed"); return false; }
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
#include "world.h"
|
||||
#include "../gui/notifications.h"
|
||||
#include <deque>
|
||||
#include <map>
|
||||
|
||||
namespace inventory_tools {
|
||||
struct panel {std::string group;std::vector<world::item> items;};
|
||||
struct snapshot {uintptr_t controller=0;uint64_t stamp=0;std::string hover;bool cursor=false,busy=false;world::item held;std::vector<panel> panels;};
|
||||
enum class action {steal,dump,sort,stop};
|
||||
struct request {uintptr_t controller;action operation;std::string group;};
|
||||
struct request {uintptr_t controller;action operation;std::string group;std::string filter;};
|
||||
inline std::atomic<bool> enabled{false},include_hotbar{false};
|
||||
inline std::atomic<int> delay{75};
|
||||
inline std::atomic<uint64_t> epoch{0};
|
||||
@@ -24,9 +25,9 @@ namespace inventory_tools {
|
||||
inline game::game_hook tick_hook;
|
||||
inline snapshot latest(){std::lock_guard lock(mutex);return published;}
|
||||
inline bool fresh(snapshot const& state){return state.controller && GetTickCount64()-state.stamp<150;}
|
||||
inline void queue(action operation,std::string group="") {
|
||||
inline void queue(action operation,std::string group="",std::string filter="",uintptr_t owner=0) {
|
||||
std::lock_guard lock(mutex);
|
||||
if(fresh(published) && requests.size()<4)requests.push_back({published.controller,operation,std::move(group)});
|
||||
if(fresh(published) && (!owner || owner==published.controller) && requests.size()<4)requests.push_back({published.controller,operation,std::move(group),std::move(filter)});
|
||||
}
|
||||
inline void reset(){++epoch;std::lock_guard lock(mutex);requests.clear();published={};}
|
||||
inline bool playing_ui() {
|
||||
@@ -62,6 +63,15 @@ namespace inventory_tools {
|
||||
__try{fn(controller,group,slot);return true;}__except(EXCEPTION_EXECUTE_HANDLER){return false;}
|
||||
}
|
||||
inline const panel* find(snapshot const& state,std::string const& group){for(auto const& panel:state.panels)if(panel.group==group)return &panel;return nullptr;}
|
||||
inline std::vector<world::item> choices(snapshot const& state,action operation,bool hotbar) {
|
||||
std::map<std::string,int> totals;
|
||||
for(auto const& panel:state.panels) {
|
||||
const bool source=operation==action::steal ? panel.group=="container_items" :
|
||||
panel.group=="inventory_items" || (hotbar && panel.group=="hotbar_items");
|
||||
if(source)for(auto const& item:panel.items)if(item.count>0 && !item.name.empty())totals[item.name]+=item.count;
|
||||
}
|
||||
std::vector<world::item> result;for(auto& entry:totals)result.push_back({entry.first,entry.second});return result;
|
||||
}
|
||||
inline int next_minimum(std::vector<world::item> const& items,int index) {
|
||||
int best=-1;
|
||||
for(int i=index;i<int(items.size());++i)if(!items[i].name.empty() && (best<0 || items[i].name<items[best].name))best=i;
|
||||
@@ -88,7 +98,7 @@ namespace inventory_tools {
|
||||
return state;
|
||||
}
|
||||
struct engine {
|
||||
uintptr_t controller=0;action operation=action::stop;std::string group;int index=0;
|
||||
uintptr_t controller=0;action operation=action::stop;std::string group,filter;int index=0;
|
||||
uint64_t due=0,wait_stamp=0;bool hotbar=false,awaiting=false;
|
||||
std::string wait_group,wait_name;int wait_slot=0,wait_count=0;
|
||||
enum class phase {idle,pickup,swap,putback,recover};
|
||||
@@ -97,8 +107,8 @@ namespace inventory_tools {
|
||||
static bool same(world::item const& a,world::item const& b){return a.name==b.name && a.count==b.count;}
|
||||
enum class stop_reason {none,completed,focus,controller,cursor,timeout,action_failed,requested,disabled};
|
||||
stop_reason last_stop=stop_reason::none;
|
||||
void cancel(stop_reason reason=stop_reason::completed){if(active())last_stop=reason;sort_phase=phase::idle;controller=0;operation=action::stop;group.clear();index=0;awaiting=false;}
|
||||
void start(request const& request){last_stop=stop_reason::none;sort_phase=phase::idle;controller=request.controller;operation=request.operation;group=request.group;index=0;due=0;hotbar=false;awaiting=false;}
|
||||
void cancel(stop_reason reason=stop_reason::completed){if(active())last_stop=reason;sort_phase=phase::idle;controller=0;operation=action::stop;group.clear();filter.clear();index=0;awaiting=false;}
|
||||
void start(request const& request){last_stop=stop_reason::none;sort_phase=phase::idle;controller=request.controller;operation=request.operation;group=request.group;filter=request.filter;index=0;due=0;hotbar=false;awaiting=false;}
|
||||
bool active() const{return controller && operation!=action::stop;}
|
||||
void step(snapshot const& state,uint64_t now,bool eligible=playing_ui()) {
|
||||
if(!active())return;
|
||||
@@ -149,7 +159,7 @@ namespace inventory_tools {
|
||||
if(operation==action::dump && !hotbar && include_hotbar){hotbar=true;index=0;return;}
|
||||
cancel();return;
|
||||
}
|
||||
const int slot=index++;const auto& item=source->items[slot];if(item.name.empty())return;
|
||||
const int slot=index++;const auto& item=source->items[slot];if(item.name.empty() || (!filter.empty() && item.name!=filter))return;
|
||||
auto_place(controller,item.count,&group,slot);
|
||||
awaiting=true;wait_group=group;wait_slot=slot;wait_count=item.count;wait_name=item.name;wait_stamp=now;
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
#pragma once
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <dxgi.h>
|
||||
#include <string>
|
||||
|
||||
namespace performance {
|
||||
inline std::atomic<bool> particles{false}, uncapped_present{false};
|
||||
inline std::atomic<int> keep{50}, burst_limit{200}, hud_hz{0};
|
||||
inline std::atomic<bool> protect_combat{true};
|
||||
inline std::atomic<uint64_t> sequence{0}, budget_state{0}, suppressed{0};
|
||||
inline void reset() {
|
||||
particles=false;uncapped_present=false;hud_hz=0;
|
||||
sequence=0;budget_state=0;suppressed=0;
|
||||
}
|
||||
// Timestamp and count share one CAS, so emitters on different threads cannot
|
||||
// reset a new window's count or exceed the budget during a rollover race.
|
||||
inline bool over_budget(uint64_t now,int cap) {
|
||||
if(cap<=0)return false;
|
||||
const uint64_t bucket=now/100+1;
|
||||
auto state=budget_state.load(std::memory_order_relaxed);
|
||||
for(;;) {
|
||||
const uint64_t stamp=state>>20;
|
||||
const uint64_t count=stamp==bucket ? state&0xfffff : 0;
|
||||
if(stamp>bucket)return true;
|
||||
if(count>=uint64_t(cap))return true;
|
||||
const auto next=(bucket<<20)|(count+1);
|
||||
if(budget_state.compare_exchange_weak(state,next,std::memory_order_relaxed))return false;
|
||||
}
|
||||
}
|
||||
inline bool suppress(int category,bool named,uint64_t now) {
|
||||
if(!particles.load(std::memory_order_relaxed) || !named || (category==2 && protect_combat))return false;
|
||||
const int density=std::clamp(keep.load(std::memory_order_relaxed),0,100);
|
||||
if(density<100 && int((sequence.fetch_add(1,std::memory_order_relaxed)*37)%100)>=density)return true;
|
||||
return over_budget(now,burst_limit.load(std::memory_order_relaxed));
|
||||
}
|
||||
inline UINT present_sync(UINT native,UINT flags) {
|
||||
return uncapped_present.load(std::memory_order_relaxed) && !(flags&DXGI_PRESENT_TEST) ? 0 : native;
|
||||
}
|
||||
struct adaptive_density {
|
||||
double seconds=0;unsigned frames=0;int current=50;
|
||||
void reset(int maximum){seconds=0;frames=0;current=maximum;}
|
||||
int update(double dt,int target,int maximum) {
|
||||
current=std::clamp(current,0,maximum);
|
||||
if(!std::isfinite(dt) || dt<=0)return current;
|
||||
seconds+=dt;++frames;
|
||||
if(seconds<.5)return current;
|
||||
const double fps=frames/seconds;
|
||||
if(fps<target*.9)current=(std::max)(0,current-10);
|
||||
else if(fps>target*1.1)current=(std::min)(maximum,current+5);
|
||||
seconds=0;frames=0;return current;
|
||||
}
|
||||
};
|
||||
struct refresh_gate {
|
||||
uint64_t stamp=0,owner=0;uint32_t entity=0;unsigned features=0;bool valid=false;
|
||||
bool due(uint64_t time,uint64_t world,uint32_t player,unsigned flags,int hz) {
|
||||
const bool refresh=hz<=0 || !valid || world!=owner || player!=entity || flags!=features ||
|
||||
time<stamp || time-stamp>=uint64_t((1000+(std::max)(1,hz)-1)/(std::max)(1,hz));
|
||||
if(refresh){stamp=time;owner=world;entity=player;features=flags;valid=true;}
|
||||
return refresh;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
#pragma once
|
||||
#include <deque>
|
||||
#include "world.h"
|
||||
#include "performance.h"
|
||||
|
||||
namespace qol_events {
|
||||
// Verified 26.52: named particle-definition lookup returns shared_ptr data
|
||||
// through RDX and takes a HashedString (hash + native string) in R8.
|
||||
inline constexpr const char* particle_signature=
|
||||
"55 41 57 41 56 41 54 56 57 53 48 83 EC 40 48 8D 6C 24 40 48 C7 45 F8 FE FF FF FF "
|
||||
"4C 89 C7 48 89 D6 48 89 CB 4C 8D 71 40 4C 89 F1 E8 ?? ?? ?? ?? 85 C0";
|
||||
// SoundInstance::update(float). Position +0x100, positional flag +0x11c,
|
||||
// event name +0x20 and FMOD channel +0x88 are verified against native setup.
|
||||
inline constexpr const char* sound_signature=
|
||||
"55 41 57 41 56 41 55 41 54 56 57 53 48 81 EC A8 00 00 00 48 8D AC 24 80 00 00 00 "
|
||||
"44 0F 29 45 10 0F 29 7D 00 0F 29 75 F0 48 C7 45 E8 FE FF FF FF 0F 28 F1 48 89 CE 48 8D B9 B0 00 00 00";
|
||||
inline constexpr const char* short_sound_signature=
|
||||
"55 56 57 53 48 83 EC 68 48 8D 6C 24 60 48 C7 45 00 FE FF FF FF 48 89 CE 8B 81 CC 00 00 00 "
|
||||
"83 F8 01 0F 84 ?? ?? ?? ?? 85 C0 0F 85 ?? ?? ?? ?? 48 89 F1 E8 ?? ?? ?? ?? 83 F8 02";
|
||||
inline game::game_hook particle_hook,sound_hook,short_sound_hook;
|
||||
inline bool particle_attempted=false,sound_attempted=false,particle_ready=false,sound_ready=false;
|
||||
inline std::atomic<bool> particles_enabled{false},sounds_enabled{false};
|
||||
inline std::atomic<int> density{50};
|
||||
inline std::atomic<uint64_t> particles_seen{0},particles_suppressed{0},sounds_seen{0};
|
||||
// Categories: portal, weather, combat, smoke/flame, potion, other.
|
||||
inline std::atomic<unsigned> particle_categories{0x3f},sequence{0};
|
||||
inline int particle_category(const std::string& name) {
|
||||
auto has=[&](const char* s){return name.find(s)!=std::string::npos;};
|
||||
if(has("portal"))return 0;
|
||||
if(has("rain") || has("snow") || has("splash") || has("weather"))return 1;
|
||||
if(has("crit") || has("hit") || has("damage") || has("attack") || has("explosion"))return 2;
|
||||
if(has("smoke") || has("flame") || has("fire") || has("lava"))return 3;
|
||||
if(has("spell") || has("effect") || has("mobspell") || has("potion"))return 4;
|
||||
return 5;
|
||||
}
|
||||
inline bool suppress_particle(const std::string& name) {
|
||||
if(name.empty() || !(particle_categories.load()&(1u<<particle_category(name))))return false;
|
||||
const int keep=std::clamp(density.load(),0,100);
|
||||
// Deterministic sampling, with no shared game RNG state.
|
||||
return int((uint64_t(sequence.fetch_add(1))*37)%100)>=keep;
|
||||
}
|
||||
using particle_fn=uintptr_t(__fastcall*)(uintptr_t,uintptr_t,uintptr_t);
|
||||
inline particle_fn original_particle=nullptr;
|
||||
inline uintptr_t __fastcall particle_detour(uintptr_t cache,uintptr_t output,uintptr_t identifier) {
|
||||
if(particles_enabled || performance::particles) {
|
||||
const auto name=world::string(identifier+8,128);
|
||||
++particles_seen;
|
||||
const bool filtered=particles_enabled && suppress_particle(name);
|
||||
if(filtered || (performance::particles && performance::suppress(particle_category(name),!name.empty(),GetTickCount64()))) {
|
||||
// A missing definition is a supported native path: createEmitter
|
||||
// checks for null, returns an invalid handle, and cleans its args.
|
||||
const std::array<uintptr_t,2> empty{};
|
||||
if(world::write(output,empty)){++particles_suppressed;if(!filtered)++performance::suppressed;return output;}
|
||||
}
|
||||
}
|
||||
return original_particle(cache,output,identifier);
|
||||
}
|
||||
struct sound {std::string name;world::vec3 position;uint64_t stamp=0,world_id=0;};
|
||||
inline std::mutex sound_mutex;
|
||||
inline std::deque<sound> pending;
|
||||
inline void record(sound event) {
|
||||
if(event.name.empty() || !world::finite(event.position))return;
|
||||
++sounds_seen;std::lock_guard lock(sound_mutex);if(pending.size()>=64)pending.pop_front();pending.push_back(std::move(event));
|
||||
}
|
||||
using sound_fn=void(__fastcall*)(uintptr_t,float);
|
||||
inline sound_fn original_sound=nullptr;
|
||||
inline sound_fn original_short_sound=nullptr;
|
||||
inline void record_instance(uintptr_t self,size_t position_offset) {
|
||||
world::vec3 pos{};if(!world::read(self+position_offset,pos) || !world::finite(pos))return;
|
||||
const auto frame=world::latest();if(!world::fresh(*frame))return;
|
||||
record({world::string(self+0x20,96),pos,GetTickCount64(),frame->world_id});
|
||||
}
|
||||
inline void __fastcall sound_detour(uintptr_t self,float dt) {
|
||||
const bool observe=sounds_enabled.load();
|
||||
const auto before=observe ? world::get<uintptr_t>(self+0x88) : 0;
|
||||
const int state=observe ? world::get<int>(self+0xa8) : 0;
|
||||
original_sound(self,dt);
|
||||
if(!observe || !sounds_enabled || world::get<uint8_t>(self+0x11c)!=1)return;
|
||||
const auto channel=world::get<uintptr_t>(self+0x88);
|
||||
if(channel && world::get<int>(self+0xa8)==3 && (channel!=before || state!=3))record_instance(self,0x100);
|
||||
}
|
||||
inline void __fastcall short_sound_detour(uintptr_t self,float dt) {
|
||||
const bool observe=sounds_enabled.load();
|
||||
const auto before=observe ? world::get<uintptr_t>(self+0x88) : 0;
|
||||
const int state=observe ? world::get<int>(self+0xcc) : 0;
|
||||
original_short_sound(self,dt);
|
||||
if(!observe || !sounds_enabled || world::get<uint8_t>(self+0xbc)!=1)return;
|
||||
const auto channel=world::get<uintptr_t>(self+0x88);
|
||||
if(channel && world::get<int>(self+0xcc)==1 && (channel!=before || state!=1))record_instance(self,0xa8);
|
||||
}
|
||||
inline bool initialize_particles() {
|
||||
if(particle_attempted)return particle_ready;particle_attempted=true;
|
||||
particle_ready=particle_hook.install("named particle filter",particle_signature,reinterpret_cast<void*>(&particle_detour),reinterpret_cast<void**>(&original_particle),true)
|
||||
&& particle_hook.set_enabled(true);return particle_ready;
|
||||
}
|
||||
inline bool initialize_sounds() {
|
||||
if(sound_attempted)return sound_ready;sound_attempted=true;
|
||||
const bool continuous=sound_hook.install("positional sound events",sound_signature,reinterpret_cast<void*>(&sound_detour),reinterpret_cast<void**>(&original_sound),true)
|
||||
&& sound_hook.set_enabled(true);
|
||||
const bool short_events=short_sound_hook.install("short positional sound events",short_sound_signature,reinterpret_cast<void*>(&short_sound_detour),reinterpret_cast<void**>(&original_short_sound),true)
|
||||
&& short_sound_hook.set_enabled(true);
|
||||
sound_ready=continuous && short_events;return sound_ready;
|
||||
}
|
||||
}
|
||||
+29
-32
@@ -2,19 +2,21 @@
|
||||
#include <windows.h>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <vector>
|
||||
|
||||
namespace sigscan {
|
||||
|
||||
struct pattern {
|
||||
std::vector<uint8_t> bytes;
|
||||
std::vector<bool> mask; // true = this byte must match
|
||||
std::vector<uint8_t> mask; // 1 = this byte must match; no vector<bool> proxy in Debug
|
||||
size_t anchor_offset=0,anchor_size=0;
|
||||
};
|
||||
|
||||
// IDA-style: "48 8B ?? ?? 89 5C"
|
||||
inline bool parse(const char* ida, pattern& out) {
|
||||
out.bytes.clear();
|
||||
out.mask.clear();
|
||||
out.mask.clear();out.anchor_offset=out.anchor_size=0;
|
||||
|
||||
for (const char* p = ida; *p;) {
|
||||
if (*p == ' ') { ++p; continue; }
|
||||
@@ -35,44 +37,39 @@ namespace sigscan {
|
||||
p += 2;
|
||||
}
|
||||
}
|
||||
size_t start=0,length=0;
|
||||
for(size_t i=0;i<out.mask.size();++i) {
|
||||
if(out.mask[i]){if(length==0)start=i;++length;if(length>out.anchor_size){out.anchor_offset=start;out.anchor_size=length;}}
|
||||
else length=0;
|
||||
}
|
||||
return !out.bytes.empty();
|
||||
}
|
||||
|
||||
inline uint8_t* scan_range(uint8_t* begin, uint8_t* end, const pattern& pat) {
|
||||
const size_t n = pat.bytes.size();
|
||||
if ((size_t)(end - begin) < n) return nullptr;
|
||||
uint8_t* last = end - n;
|
||||
for (uint8_t* p = begin; p <= last; ++p) {
|
||||
size_t i = 0;
|
||||
while (i < n && (!pat.mask[i] || p[i] == pat.bytes[i])) ++i;
|
||||
if (i == n) return p;
|
||||
const size_t n=pat.bytes.size();
|
||||
if(!begin || !end || end<begin || n==0 || pat.mask.size()!=n || size_t(end-begin)<n)return nullptr;
|
||||
if(pat.anchor_size==0)return begin; // an all-wildcard signature
|
||||
const auto* bytes=pat.bytes.data();const auto* mask=pat.mask.data();
|
||||
const size_t offset=pat.anchor_offset,length=pat.anchor_size;
|
||||
uint8_t* cursor=begin+offset;uint8_t* last=end-n+offset;
|
||||
// The CRT searches bytes with optimized native code even when this DLL
|
||||
// is /Od. Only candidate anchors enter the wildcard comparison loop.
|
||||
while(cursor<=last) {
|
||||
auto* hit=static_cast<uint8_t*>(memchr(cursor,bytes[offset],size_t(last-cursor)+1));
|
||||
if(!hit)return nullptr;
|
||||
if(memcmp(hit,bytes+offset,length)==0) {
|
||||
auto* candidate=hit-offset;size_t i=0;
|
||||
while(i<n && (!mask[i] || candidate[i]==bytes[i]))++i;
|
||||
if(i==n)return candidate;
|
||||
}
|
||||
cursor=hit+1;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
inline size_t count_matches(
|
||||
uint8_t* begin,
|
||||
uint8_t* end,
|
||||
const pattern& pat)
|
||||
{
|
||||
size_t count = 0;
|
||||
const size_t n = pat.bytes.size();
|
||||
|
||||
if (n == 0 || end < begin ||
|
||||
static_cast<size_t>(end - begin) < n)
|
||||
return 0;
|
||||
|
||||
for (uint8_t* p = begin; p <= end - n; ++p) {
|
||||
size_t i = 0;
|
||||
|
||||
while (i < n &&
|
||||
(!pat.mask[i] || p[i] == pat.bytes[i]))
|
||||
++i;
|
||||
|
||||
if (i == n)
|
||||
++count;
|
||||
}
|
||||
|
||||
inline size_t count_matches(uint8_t* begin,uint8_t* end,const pattern& pat) {
|
||||
size_t count=0;
|
||||
while(auto* hit=scan_range(begin,end,pat)){++count;begin=hit+1;}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
+113
-11
@@ -8,6 +8,7 @@
|
||||
#include <intrin.h>
|
||||
#include "world_math.h"
|
||||
#include "hook.h"
|
||||
#include "performance.h"
|
||||
#include "../input.h"
|
||||
|
||||
// Verified 1.26.5203.0 read-only ECS access. Do not instantiate an external
|
||||
@@ -86,7 +87,14 @@ namespace world {
|
||||
for(size_t i=0;i<value.size;++i) {char c;if(!read(bytes+i,c) || !c) return {};out+=c;}
|
||||
return out;
|
||||
}
|
||||
struct item {std::string name;int count=0;};
|
||||
struct enchantment {int id=0,level=0;};
|
||||
struct item {
|
||||
std::string name;int count=0;
|
||||
int damage=0,max_damage=0,attack_bonus=0;
|
||||
bool durability_known=false,attack_known=false;
|
||||
std::vector<enchantment> enchantments;
|
||||
};
|
||||
struct effect {int id=0,ticks=0,amplifier=0;};
|
||||
struct actor {
|
||||
uint32_t id=0;std::string name;vec3 position{},feet{},head{},velocity{};
|
||||
float health=0,max_health=0;bool health_known=false;
|
||||
@@ -97,6 +105,7 @@ namespace world {
|
||||
uint64_t stamp=0,world_id=0;actor local,target;
|
||||
std::vector<actor> players;
|
||||
std::vector<std::string> online_players;bool roster_known=false,xp_known=false;int xp_level=0;float xp_progress=0;
|
||||
int dimension=-1;bool effects_known=false;std::vector<effect> effects;
|
||||
vec3 block{},camera{};float matrix[16]{},fov_x=1,fov_y=1;
|
||||
};
|
||||
inline std::shared_ptr<const frame> published=std::make_shared<frame>();
|
||||
@@ -104,6 +113,7 @@ namespace world {
|
||||
inline std::atomic<uintptr_t> client{0};
|
||||
inline std::atomic<DWORD> render_thread{0};
|
||||
inline std::atomic<bool> collect_players{false},collect_roster{false},collect_xp{false};
|
||||
inline std::atomic<int> collect_item_details{0},collect_effects{0},extra_xp_readers{0};
|
||||
inline std::atomic<int> time_override{-1};
|
||||
inline bool ready=false,camera_ready=false,time_ready=false,name_ready=false,fog_ready=false;
|
||||
inline std::atomic<bool> fog_enabled{false};
|
||||
@@ -112,18 +122,71 @@ namespace world {
|
||||
inline std::shared_ptr<const std::string> alias=std::make_shared<const std::string>("Player");
|
||||
inline std::atomic<uintptr_t> local_actor{0};
|
||||
inline thread_local bool rendering=false;
|
||||
inline void (*after_world)()=nullptr;
|
||||
inline std::atomic<void(*)()> after_world{nullptr};
|
||||
inline std::shared_ptr<const frame> latest() {std::lock_guard<std::mutex> lock(frame_mutex);return published;}
|
||||
inline void publish(frame value) {auto next=std::make_shared<frame>(std::move(value));std::lock_guard<std::mutex> lock(frame_mutex);published=std::move(next);}
|
||||
inline std::shared_ptr<const std::string> current_alias() {std::lock_guard<std::mutex> lock(alias_mutex);return alias;}
|
||||
inline void set_alias(std::string name) {auto next=std::make_shared<const std::string>(std::move(name));std::lock_guard<std::mutex> lock(alias_mutex);alias=std::move(next);}
|
||||
inline bool fresh(const frame& value) {return value.valid && GetTickCount64()-value.stamp<500;}
|
||||
inline item read_item(uintptr_t stack) {
|
||||
inline int tag_type(uintptr_t tag) {
|
||||
const auto getter=get<uintptr_t>(get<uintptr_t>(tag)+5*8);
|
||||
std::array<uint8_t,3> code{};
|
||||
return read(getter,code) && code[0]==0xb0 && code[2]==0xc3 && code[1]<=12 ? code[1] : -1;
|
||||
}
|
||||
inline uintptr_t find_tag(uintptr_t compound,const char* key) {
|
||||
if(tag_type(compound)!=10)return 0;
|
||||
const auto head=get<uintptr_t>(compound+8);const auto count=get<size_t>(compound+16);
|
||||
if(!head || count>128)return 0;
|
||||
auto node=get<uintptr_t>(head+8);
|
||||
for(size_t i=0;i<count && node && node!=head;++i) {
|
||||
const auto name=string(node+32);if(name==key)return node+64;
|
||||
if(name.empty())return 0;
|
||||
node=get<uintptr_t>(node+(name<key ? 16 : 0));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
inline void read_item_details(uintptr_t stack,uintptr_t type,item& value) {
|
||||
const auto maximum=get<uintptr_t>(get<uintptr_t>(type)+36*8);
|
||||
const std::array<uint8_t,8> max_getter{0x0f,0xb7,0x81,0x50,0x01,0x00,0x00,0xc3};
|
||||
const auto compound=get<uintptr_t>(stack+16);
|
||||
if(get<std::array<uint8_t,8>>(maximum)==max_getter) {
|
||||
value.max_damage=get<uint16_t>(type+0x150);
|
||||
const auto damage=find_tag(compound,"Damage");
|
||||
const bool tags_valid=!compound || tag_type(compound)==10 && get<uintptr_t>(compound+8) && get<size_t>(compound+16)<=128;
|
||||
if(value.max_damage>0 && tags_valid && (!damage || tag_type(damage)==3)) {
|
||||
value.damage=damage ? get<int>(damage+8) : 0;
|
||||
value.durability_known=value.damage>=0 && value.damage<=value.max_damage;
|
||||
}
|
||||
}
|
||||
const auto attack=get<uintptr_t>(get<uintptr_t>(type)+37*8);
|
||||
std::array<uint8_t,7> getter{};
|
||||
if(read(attack,getter) && getter[0]==0x8b && getter[1]==0x81 && getter[6]==0xc3) {
|
||||
uint32_t offset=0;memcpy(&offset,getter.data()+2,4);
|
||||
if(offset==0x218 || offset==0x228) {
|
||||
value.attack_bonus=get<int>(type+offset);
|
||||
value.attack_known=value.attack_bonus>=0 && value.attack_bonus<=2048;
|
||||
}
|
||||
}
|
||||
const auto ench=find_tag(compound,"ench");
|
||||
if(ench && tag_type(ench)==9) {
|
||||
const auto first=get<uintptr_t>(ench+8),last=get<uintptr_t>(ench+16);
|
||||
if(first && last>=first && last-first<=8*64 && (last-first)%8==0)
|
||||
for(auto at=first;at<last;at+=8) {
|
||||
const auto entry=get<uintptr_t>(at),id=find_tag(entry,"id"),level=find_tag(entry,"lvl");
|
||||
if(tag_type(id)==2 && tag_type(level)==2) {
|
||||
enchantment e{get<int16_t>(id+8),get<int16_t>(level+8)};
|
||||
if(e.id>=0 && e.id<=255 && e.level>0 && e.level<=32767)value.enchantments.push_back(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
inline item read_item(uintptr_t stack,bool details=false) {
|
||||
item value;if(!stack) return value;
|
||||
const auto counter=get<uintptr_t>(stack+8),type=get<uintptr_t>(counter);
|
||||
if(!type) return value;
|
||||
value.name=string(type+0xd8);value.count=get<uint8_t>(stack+0x22);
|
||||
if(!value.count) value.name.clear();return value;
|
||||
if(!value.count) value.name.clear();else if(details && !value.name.empty())read_item_details(stack,type,value);
|
||||
return value;
|
||||
}
|
||||
inline uintptr_t inventory_item(uintptr_t container,int slot) {
|
||||
const auto first=get<uintptr_t>(container+0x1a0),end=get<uintptr_t>(container+0x1a8);
|
||||
@@ -138,7 +201,7 @@ namespace world {
|
||||
if(!first || selected<0 || selected>8 || get<uint8_t>(inventory+0xb0) || last<first || last-first>152*256 || size_t(selected)>=(last-first)/152) return 0;
|
||||
return first+152*selected;
|
||||
}
|
||||
inline bool read_actor(uintptr_t registry,uint32_t id,actor& value,bool equipment=true) {
|
||||
inline bool read_actor(uintptr_t registry,uint32_t id,actor& value,bool equipment=true,bool details=false,bool metadata=true) {
|
||||
auto state=component(registry,id,"StateVectorComponent");
|
||||
if(!state || !read(state,value.position) || !finite(value.position)) return false;
|
||||
value.id=id;read(state+24,value.velocity);
|
||||
@@ -150,6 +213,7 @@ namespace world {
|
||||
value.head={(min.x+max.x)*.5f,max.y+.3f,(min.z+max.z)*.5f};
|
||||
}
|
||||
else value.head={value.position.x,value.position.y+.3f,value.position.z};
|
||||
if(!metadata)return true;
|
||||
const auto sync=component(registry,id,"SynchedActorDataComponent");
|
||||
const auto items=get<uintptr_t>(sync),end=get<uintptr_t>(sync+8);
|
||||
if(items && end>=items+5*8 && end-items<8192) value.name=clean_name(string(get<uintptr_t>(items+4*8)+16));
|
||||
@@ -164,11 +228,11 @@ namespace world {
|
||||
}
|
||||
if(equipment) {
|
||||
auto equip=component(registry,id,"ActorEquipmentComponent");auto armor=get<uintptr_t>(equip+8);
|
||||
for(int i=0;i<4;++i) value.armor[i]=read_item(inventory_item(armor,i));
|
||||
for(int i=0;i<4;++i) value.armor[i]=read_item(inventory_item(armor,i),details);
|
||||
// The player's selected stack is accessed through its actual
|
||||
// inventory reference rather than through item-renderer copies.
|
||||
const auto owner=get<uintptr_t>(component(registry,id,"ActorOwnerComponent"));
|
||||
value.held=read_item(carried_item(owner));
|
||||
value.held=read_item(carried_item(owner),details);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -204,13 +268,35 @@ namespace world {
|
||||
if(!std::isfinite(l) || l<0 || l>24791 || l!=std::floor(l) || !std::isfinite(p) || p<0 || p>1)return false;
|
||||
level=int(l);progress=p;return true;
|
||||
}
|
||||
inline bool read_effects(uintptr_t effects,std::vector<effect>& result) {
|
||||
if(!effects)return false;
|
||||
const auto first=get<uintptr_t>(effects),last=get<uintptr_t>(effects+8);
|
||||
if(!first && !last){result.clear();return true;}
|
||||
if(!first || last<first || last-first>144*128 || (last-first)%144)return false;
|
||||
std::vector<effect> found;
|
||||
for(auto at=first;at<last;at+=144) {
|
||||
effect e;if(!read(at,e.id) || !read(at+4,e.ticks) || !read(at+0x20,e.amplifier))return false;
|
||||
if(e.id==0)continue; // inactive slots remain in the indexed vector
|
||||
if(e.id<1 || e.id>127 || e.amplifier<0 || e.amplifier>255 || e.ticks< -1)return false;
|
||||
if(e.ticks)found.push_back(e);
|
||||
}
|
||||
result=std::move(found);return true;
|
||||
}
|
||||
inline void capture(uintptr_t ci) {
|
||||
static performance::refresh_gate refresh;
|
||||
static frame cached;
|
||||
frame out;out.stamp=GetTickCount64();
|
||||
const auto registry_owner=get<uintptr_t>(ci+0x248),registry=registry_owner+0x30;
|
||||
const auto entity=get<uint32_t>(ci+0x258);out.world_id=registry_owner;
|
||||
const unsigned features=(collect_item_details>0 ? 1u : 0u)|(collect_roster ? 2u : 0u)|
|
||||
((collect_xp || extra_xp_readers>0) ? 4u : 0u)|(collect_effects>0 ? 8u : 0u);
|
||||
const bool details_due=refresh.due(out.stamp,registry_owner,entity,features,performance::hud_hz.load());
|
||||
if(!details_due)out.local=cached.local;
|
||||
local_actor=get<uintptr_t>(component(registry,entity,"ActorOwnerComponent"));
|
||||
const auto renderer=get<uintptr_t>(ci+0x1c0),camera=get<uintptr_t>(renderer+0x468);
|
||||
if(!registry_owner || !camera || !read_actor(registry,entity,out.local) || !read(camera+0x660,out.camera) || !read(ci+0x420,out.matrix)) {input::in_world=false;publish(std::move(out));return;}
|
||||
if(!registry_owner || !camera || !read_actor(registry,entity,out.local,details_due,collect_item_details>0,details_due) || !read(camera+0x660,out.camera) || !read(ci+0x420,out.matrix)) {refresh.valid=false;input::in_world=false;publish(std::move(out));return;}
|
||||
const auto dimension=component(registry,entity,"DimensionTypeComponent");
|
||||
if(dimension) {const int id=get<int>(dimension);if(id>=0 && id<=2)out.dimension=id;}
|
||||
out.fov_x=get<float>(camera+0xf58);out.fov_y=get<float>(camera+0xf6c);
|
||||
out.valid=finite(out.camera) && std::isfinite(out.fov_x) && std::isfinite(out.fov_y) && out.fov_x>0 && out.fov_y>0;
|
||||
const auto controller=get<uintptr_t>(component(registry,entity,"HitResultComponent"));
|
||||
@@ -235,8 +321,20 @@ namespace world {
|
||||
actor other;if(read_actor(registry,id,other,false) && distance(other.position,out.local.position)<=128 && !other.name.empty()) out.players.push_back(std::move(other));
|
||||
}
|
||||
}
|
||||
if(out.valid && collect_roster)out.roster_known=read_roster(registry,out.online_players);
|
||||
if(out.valid && collect_xp)out.xp_known=read_xp_values(component(registry,entity,"AttributesComponent"),out.xp_level,out.xp_progress);
|
||||
if(!details_due) {
|
||||
out.online_players=cached.online_players;out.roster_known=cached.roster_known;
|
||||
out.xp_known=cached.xp_known;out.xp_level=cached.xp_level;out.xp_progress=cached.xp_progress;
|
||||
out.effects_known=cached.effects_known;out.effects=cached.effects;
|
||||
}
|
||||
if(details_due && out.valid && collect_roster)out.roster_known=read_roster(registry,out.online_players);
|
||||
if(details_due && out.valid && (collect_xp || extra_xp_readers>0))out.xp_known=read_xp_values(component(registry,entity,"AttributesComponent"),out.xp_level,out.xp_progress);
|
||||
if(details_due && out.valid && collect_effects>0)out.effects_known=read_effects(component(registry,entity,"MobEffectsComponent"),out.effects);
|
||||
if(details_due) {
|
||||
cached.local=out.local;cached.online_players=out.online_players;cached.roster_known=out.roster_known;
|
||||
cached.xp_known=out.xp_known;cached.xp_level=out.xp_level;cached.xp_progress=out.xp_progress;
|
||||
cached.effects_known=out.effects_known;cached.effects=out.effects;
|
||||
}
|
||||
if(!out.valid)refresh.valid=false;
|
||||
input::in_world=out.valid;
|
||||
publish(std::move(out));
|
||||
}
|
||||
@@ -338,7 +436,7 @@ namespace world {
|
||||
inline int64_t __fastcall level_detour(uintptr_t self,void* context,int64_t parameters) {
|
||||
render_thread=GetCurrentThreadId();sync_player_look(client.load());const bool previous=rendering;rendering=true;
|
||||
const auto result=original_level(self,context,parameters);
|
||||
capture(client.load());if(after_world) after_world();rendering=previous;return result;
|
||||
capture(client.load());if(auto callback=after_world.load())callback();rendering=previous;return result;
|
||||
}
|
||||
struct active_context {uintptr_t owner,registry;uint32_t entity;uint8_t padding[4];bool valid;uint8_t tail[7];};
|
||||
inline uintptr_t active_camera(uintptr_t ci) {
|
||||
@@ -394,18 +492,22 @@ namespace world {
|
||||
}
|
||||
inline void initialize() {
|
||||
bool update_ok=update_hook.install("client world context",client_update_signature,reinterpret_cast<void*>(&update_detour),reinterpret_cast<void**>(&original_update),true);
|
||||
game::log("world render: scanning");
|
||||
auto call=sigscan::find("E8 ?? ?? ?? ?? 45 31 E4 48 83 BE A8 01 00 00 00",true);
|
||||
if(call) {
|
||||
level_target=sigscan::resolve_rip(call,1,5);
|
||||
if(MH_CreateHook(level_target,&level_detour,reinterpret_cast<void**>(&original_level))!=MH_OK) level_target=nullptr;
|
||||
}
|
||||
game::log("world render: enabling hooks");
|
||||
ready=update_ok && level_target && update_hook.set_enabled(true) && MH_EnableHook(level_target)==MH_OK;
|
||||
game::log("active camera: scanning");
|
||||
auto active=sigscan::find(active_camera_signature,true);
|
||||
if(active) {
|
||||
DWORD64 image_base=0;
|
||||
auto function=RtlLookupFunctionEntry(reinterpret_cast<DWORD64>(active),&image_base,nullptr);
|
||||
if(function) get_camera=reinterpret_cast<active_fn>(image_base+function->BeginAddress);
|
||||
}
|
||||
game::log("active camera: scan completed");
|
||||
camera_ready=get_camera && camera_hook.install("camera matrices",camera_matrix_signature,reinterpret_cast<void*>(&camera_detour),reinterpret_cast<void**>(&original_camera),true) && camera_hook.set_enabled(true);
|
||||
perspective_ready=perspective_hook.install("view perspective",perspective_signature,reinterpret_cast<void*>(&perspective_detour),reinterpret_cast<void**>(&original_perspective),true) && perspective_hook.set_enabled(true);
|
||||
input::freelook_supported=camera_ready && perspective_ready;
|
||||
|
||||
+62
-6
@@ -13,6 +13,16 @@ namespace world_filter {
|
||||
inline std::atomic<bool> enabled{false};
|
||||
inline std::atomic<uint32_t> tint{0xffffffff};
|
||||
inline std::atomic<float> brightness{1};
|
||||
struct grading {
|
||||
float exposure=0,contrast=1,saturation=1;
|
||||
uint32_t shadows=0x00ffffff,highlights=0x00ffffff;
|
||||
float vignette=0,bloom=0,threshold=.7f,aberration=0;
|
||||
float grain=0,rain=0,snow=0,speed=1;
|
||||
};
|
||||
inline std::mutex grading_mutex;
|
||||
inline grading current;
|
||||
inline void configure(grading value) {std::lock_guard lock(grading_mutex);current=value;}
|
||||
inline grading configuration() {std::lock_guard lock(grading_mutex);return current;}
|
||||
inline ComPtr<ID3D11VertexShader> vs;
|
||||
inline ComPtr<ID3D11PixelShader> ps;
|
||||
inline ComPtr<ID3D11SamplerState> sampler;
|
||||
@@ -24,13 +34,51 @@ namespace world_filter {
|
||||
inline ID3D11Device* owner=nullptr;
|
||||
inline bool initialize(ID3D11Device* device) {
|
||||
if(owner==device && vs && ps && constants && sampler && raster && depth) return true;
|
||||
if(owner!=device){copy.Reset();view.Reset();}
|
||||
owner=device;
|
||||
const char* source=R"(
|
||||
Texture2D image:register(t0);SamplerState sampleImage:register(s0);
|
||||
cbuffer settings:register(b0){float4 color;float4 light;}
|
||||
cbuffer settings:register(b0){float4 color;float4 light;float4 shadows;float4 highlights;float4 lens;float4 fx;float4 viewport;}
|
||||
struct Vertex{float4 position:SV_POSITION;float2 uv:TEXCOORD0;};
|
||||
Vertex vertex(uint id:SV_VertexID){Vertex v;v.uv=float2((id<<1)&2,id&2);v.position=float4(v.uv*float2(2,-2)+float2(-1,1),0,1);return v;}
|
||||
float4 pixel(Vertex v):SV_TARGET{float4 c=image.Sample(sampleImage,v.uv);c.rgb*=lerp(float3(1,1,1),color.rgb,color.a)*light.x;return c;}
|
||||
float hash(float2 p){return frac(sin(dot(p,float2(127.1,311.7)))*43758.5453);}
|
||||
float3 bright(float2 uv){float3 c=image.Sample(sampleImage,uv).rgb;return c*saturate((max(c.r,max(c.g,c.b))-lens.z)/max(.01,1-lens.z));}
|
||||
float4 pixel(Vertex v):SV_TARGET {
|
||||
float2 uv=v.uv;float4 original=image.Sample(sampleImage,uv);float3 c=original.rgb;
|
||||
if(lens.w>0) {
|
||||
float2 delta=(uv-.5)*viewport.xy*lens.w*2;
|
||||
c.r=image.Sample(sampleImage,uv+delta).r;c.b=image.Sample(sampleImage,uv-delta).b;
|
||||
}
|
||||
if(lens.y>0) {
|
||||
float2 step=viewport.xy*5;
|
||||
float3 glow=bright(uv)*.2;
|
||||
glow+=(bright(uv+float2(step.x,0))+bright(uv-float2(step.x,0))+bright(uv+float2(0,step.y))+bright(uv-float2(0,step.y)))*.12;
|
||||
glow+=(bright(uv+step)+bright(uv-step)+bright(uv+float2(step.x,-step.y))+bright(uv+float2(-step.x,step.y)))*.08;
|
||||
c+=glow*lens.y;
|
||||
}
|
||||
c*=lerp(float3(1,1,1),color.rgb,color.a)*light.x*exp2(light.y);
|
||||
float luma=dot(c,float3(.2126,.7152,.0722));c=lerp(luma.xxx,c,light.w);
|
||||
float low=1-smoothstep(.1,.65,luma),high=smoothstep(.35,.9,luma);
|
||||
c=lerp(c,c*shadows.rgb*1.7,shadows.a*low);
|
||||
c=lerp(c,c*highlights.rgb*1.7,highlights.a*high);
|
||||
c=(c-.5)*light.z+.5;
|
||||
float2 center=(uv-.5)*float2(viewport.z,1);
|
||||
c*=1-lens.x*smoothstep(.15,.8,length(center));
|
||||
if(fx.x>0)c+=(hash(floor(uv/viewport.xy)+floor(fx.w*24))-.5)*fx.x*.12;
|
||||
if(fx.y>0) {
|
||||
float2 grid=float2(uv.x*90+uv.y*24,uv.y*14+fx.w*5);
|
||||
float2 cell=floor(grid),local=frac(grid);float seed=hash(cell);
|
||||
float streak=(1-smoothstep(.015,.055,abs(local.x-.5)))*smoothstep(.05,.2,local.y)*(1-smoothstep(.6,1,local.y));
|
||||
c+=float3(.5,.65,.8)*streak*step(seed,fx.y)*.4;
|
||||
}
|
||||
if(fx.z>0) {
|
||||
float2 grid=float2(uv.x*55+sin(fx.w*.5+uv.y*7),uv.y*32+fx.w*.7);
|
||||
float2 cell=floor(grid),local=frac(grid)-.5;float seed=hash(cell);
|
||||
float flake=1-smoothstep(.015,.07,length(local*float2(viewport.z,1)));
|
||||
c=lerp(c,float3(.9,.95,1),flake*step(seed,fx.z)*.8);
|
||||
}
|
||||
return float4(saturate(c),original.a);
|
||||
}
|
||||
)";
|
||||
ComPtr<ID3DBlob> vertex,pixel,error;
|
||||
if(FAILED(D3DCompile(source,strlen(source),nullptr,nullptr,nullptr,"vertex","vs_4_0",0,0,&vertex,&error)) ||
|
||||
@@ -40,7 +88,7 @@ namespace world_filter {
|
||||
D3D11_SAMPLER_DESC sd{};sd.Filter=D3D11_FILTER_MIN_MAG_MIP_LINEAR;sd.AddressU=sd.AddressV=sd.AddressW=D3D11_TEXTURE_ADDRESS_CLAMP;sd.MaxLOD=D3D11_FLOAT32_MAX;
|
||||
D3D11_RASTERIZER_DESC rs{};rs.FillMode=D3D11_FILL_SOLID;rs.CullMode=D3D11_CULL_NONE;rs.DepthClipEnable=true;
|
||||
D3D11_DEPTH_STENCIL_DESC ds{};ds.DepthFunc=D3D11_COMPARISON_ALWAYS;
|
||||
D3D11_BUFFER_DESC bd{};bd.ByteWidth=32;bd.Usage=D3D11_USAGE_DEFAULT;bd.BindFlags=D3D11_BIND_CONSTANT_BUFFER;
|
||||
D3D11_BUFFER_DESC bd{};bd.ByteWidth=112;bd.Usage=D3D11_USAGE_DEFAULT;bd.BindFlags=D3D11_BIND_CONSTANT_BUFFER;
|
||||
return SUCCEEDED(device->CreateSamplerState(&sd,&sampler)) && SUCCEEDED(device->CreateRasterizerState(&rs,&raster)) &&
|
||||
SUCCEEDED(device->CreateDepthStencilState(&ds,&depth)) && SUCCEEDED(device->CreateBuffer(&bd,nullptr,&constants));
|
||||
}
|
||||
@@ -76,8 +124,16 @@ namespace world_filter {
|
||||
context->PSGetShaderResources(0,1,&old_srv);context->PSGetSamplers(0,1,&old_sampler);
|
||||
context->IAGetInputLayout(&layout);context->IAGetPrimitiveTopology(&topology);context->RSGetState(&old_rs);context->RSGetViewports(&count,ports);
|
||||
context->OMGetDepthStencilState(&old_depth,&stencil);context->OMGetBlendState(&blend,factor,&mask);
|
||||
const auto color=tint.load();float data[8]={float(color&255)/255,float((color>>8)&255)/255,float((color>>16)&255)/255,float(color>>24)/255,
|
||||
brightness.load(),0,0,0};context->UpdateSubresource(constants.Get(),0,nullptr,data,0,0);
|
||||
const auto color=tint.load();const auto grade=configuration();
|
||||
auto channel=[](uint32_t value,int shift){return float((value>>shift)&255)/255;};
|
||||
float data[28]={channel(color,0),channel(color,8),channel(color,16),channel(color,24),
|
||||
brightness.load(),grade.exposure,grade.contrast,grade.saturation,
|
||||
channel(grade.shadows,0),channel(grade.shadows,8),channel(grade.shadows,16),channel(grade.shadows,24),
|
||||
channel(grade.highlights,0),channel(grade.highlights,8),channel(grade.highlights,16),channel(grade.highlights,24),
|
||||
grade.vignette,grade.bloom,grade.threshold,grade.aberration,
|
||||
grade.grain,grade.rain,grade.snow,float(fmod(GetTickCount64()/1000.0,4096.0))*grade.speed,
|
||||
1.f/desc.Width,1.f/desc.Height,float(desc.Width)/desc.Height,0};
|
||||
context->UpdateSubresource(constants.Get(),0,nullptr,data,0,0);
|
||||
ID3D11Buffer* cb=constants.Get();ID3D11ShaderResourceView* srv=view.Get();ID3D11SamplerState* sm=sampler.Get();
|
||||
D3D11_VIEWPORT port{0,0,float(desc.Width),float(desc.Height),0,1};
|
||||
context->OMSetRenderTargets(1,&target,nullptr);context->OMSetDepthStencilState(depth.Get(),0);context->OMSetBlendState(nullptr,nullptr,0xffffffff);
|
||||
@@ -95,5 +151,5 @@ namespace world_filter {
|
||||
for(int stage=0;stage<5;++stage) for(UINT i=0;i<class_count[stage];++i) if(classes[stage][i]) classes[stage][i]->Release();
|
||||
for(auto* rt:targets) if(rt) rt->Release();return true;
|
||||
}
|
||||
inline void shutdown() {enabled=false;vs.Reset();ps.Reset();sampler.Reset();raster.Reset();depth.Reset();constants.Reset();copy.Reset();view.Reset();owner=nullptr;}
|
||||
inline void shutdown() {enabled=false;configure({});vs.Reset();ps.Reset();sampler.Reset();raster.Reset();depth.Reset();constants.Reset();copy.Reset();view.Reset();owner=nullptr;}
|
||||
}
|
||||
@@ -0,0 +1,305 @@
|
||||
#pragma once
|
||||
#include <d3d11_1.h>
|
||||
#include <d3dcompiler.h>
|
||||
#include <wrl/client.h>
|
||||
#include <mutex>
|
||||
#include <unordered_map>
|
||||
#include "world.h"
|
||||
#pragma comment(lib,"d3dcompiler.lib")
|
||||
|
||||
extern "C" {
|
||||
__declspec(dllexport) inline volatile LONG amnesia_weather_status=0;
|
||||
__declspec(dllexport) inline volatile LONG amnesia_weather_draws=0;
|
||||
__declspec(dllexport) inline volatile LONG amnesia_weather_callbacks=0;
|
||||
__declspec(dllexport) inline volatile LONG amnesia_weather_blocked=0;
|
||||
}
|
||||
namespace world_weather {
|
||||
using Microsoft::WRL::ComPtr;
|
||||
struct settings {float rain=0,snow=0,speed=1,radius=24,wind=.3f;uint32_t rain_color=0x99e6cfa6,snow_color=0xddfff5e6;};
|
||||
inline std::mutex mutex;
|
||||
inline settings configuration;
|
||||
inline std::atomic<bool> enabled{false};
|
||||
inline std::atomic<ID3D11DeviceContext*> draw_context{nullptr};
|
||||
inline std::atomic<DWORD> draw_thread{0};
|
||||
inline void configure(settings value){std::lock_guard lock(mutex);configuration=value;enabled=value.rain>0 || value.snow>0;}
|
||||
struct projection {float a=0,b=0;};
|
||||
// Recognize only a real perspective matrix matching the captured camera.
|
||||
// No guessed near/far planes or arbitrary mapping to the native depth buffer.
|
||||
inline bool find_projection(const float* data,size_t size,float x,float y,projection& out) {
|
||||
for(size_t i=0;i+16<=size;i+=4) {
|
||||
const float* m=data+i;
|
||||
if(!std::isfinite(m[0]) || !std::isfinite(m[5]) || std::abs(m[0]-x)>(std::max)(.005f,std::abs(x)*.015f) ||
|
||||
std::abs(std::abs(m[5])-y)>(std::max)(.005f,std::abs(y)*.015f) || std::abs(m[15])>.00001f)continue;
|
||||
if(std::abs(m[1])+std::abs(m[4])+std::abs(m[3])+std::abs(m[7])+std::abs(m[12])+std::abs(m[13])>.01f)continue;
|
||||
float b=0;
|
||||
if(std::abs(m[11]+1)<.0001f)b=m[14];
|
||||
else if(std::abs(m[14]+1)<.0001f)b=m[11];
|
||||
else continue;
|
||||
const float a=m[10];
|
||||
if(!std::isfinite(a) || !std::isfinite(b) || std::abs(b)<.001f || std::abs(b)>4)continue;
|
||||
if((b<0 && a>=-1.01f && a<=-.99f) || (b>0 && a>=-.01f && a<=.01f)){out={a,b};return true;}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
inline ComPtr<ID3D11VertexShader> vs;
|
||||
inline ComPtr<ID3D11PixelShader> ps;
|
||||
inline ComPtr<ID3D11Buffer> constants;
|
||||
inline ComPtr<ID3D11BlendState> blend;
|
||||
inline ComPtr<ID3D11RasterizerState> raster;
|
||||
inline ComPtr<ID3D11DepthStencilState> depth,reverse_depth;
|
||||
|
||||
inline ID3D11Device* owner=nullptr;
|
||||
inline uint64_t next_probe=0;
|
||||
inline projection cached_projection;
|
||||
inline float cached_x=0,cached_y=0;
|
||||
inline uintptr_t cached_buffer=0;
|
||||
inline bool initialize(ID3D11Device* device) {
|
||||
if(owner==device && vs && ps && constants && blend && raster && depth && reverse_depth)return true;
|
||||
owner=device;
|
||||
const char* source=R"(
|
||||
cbuffer Weather:register(b0){float4 row0,row1,row2,cameraTime,projection,grid,tint,motion,dimensions;}
|
||||
struct Vertex{float4 pos:SV_POSITION;float2 uv:TEXCOORD0;float alpha:TEXCOORD1;};
|
||||
float hash(float3 p){return frac(sin(dot(p,float3(127.1,311.7,74.7)))*43758.5453);}
|
||||
Vertex vertex(uint vertex:SV_VertexID,uint id:SV_InstanceID) {
|
||||
const float2 corners[6]={float2(-1,-1),float2(-1,1),float2(1,1),float2(-1,-1),float2(1,1),float2(1,-1)};
|
||||
float2 corner=corners[vertex];uint side=(uint)dimensions.z;
|
||||
float3 cell=float3(int(id%side)-int(side/2),int(id/(side*side))-4,int((id/side)%side)-int(side/2))+grid.xyz;
|
||||
float seed=hash(cell),phase=frac(hash(cell+7)-cameraTime.w*motion.y*(motion.x<.5 ? 9:1.1)/4);
|
||||
float3 p=float3((cell.x+hash(cell+2))*grid.w,(cell.y+phase)*4,(cell.z+hash(cell+3))*grid.w);
|
||||
p.x+=sin(cameraTime.w*.35+seed*6.28)*motion.z;
|
||||
float3 relative=p-cameraTime.xyz;
|
||||
float3 eye=float3(dot(row0.xyz,relative)+row0.w,dot(row1.xyz,relative)+row1.w,dot(row2.xyz,relative)+row2.w);
|
||||
float size=motion.x<.5 ? .015 : .035+seed*.035;
|
||||
if(motion.x<.5)eye+=float3(row0.y,row1.y,row2.y)*corner.y*.4+float3(size*corner.x,0,0);
|
||||
else eye.xy+=corner*size;
|
||||
float d=-eye.z;Vertex v;
|
||||
v.pos=float4(eye.x*projection.x,eye.y*projection.y,projection.z*eye.z+projection.w,d);
|
||||
v.uv=corner;float radius=length(relative.xz);
|
||||
v.alpha=smoothstep(0,.15,phase)*(1-smoothstep(.85,1,phase))*(1-smoothstep(dimensions.w*.65,dimensions.w,radius));
|
||||
if(seed>motion.w || d<.05){v.pos=float4(2,2,1,1);v.alpha=0;}
|
||||
return v;
|
||||
}
|
||||
float4 pixel(Vertex v):SV_TARGET {
|
||||
float shape;
|
||||
if(motion.x<.5)shape=(1-smoothstep(.2,1,abs(v.uv.x)))*(1-smoothstep(.65,1,abs(v.uv.y)));
|
||||
else {
|
||||
float2 p=v.uv;float r=length(p);
|
||||
float angle=atan2(p.y,p.x);float arms=pow(abs(cos(angle*3)),10);
|
||||
shape=(1-smoothstep(.1,.4,r))*.75+arms*(1-smoothstep(.2,.95,r))*.6;
|
||||
}
|
||||
float alpha=saturate(shape*v.alpha*tint.a);clip(alpha-.01);return float4(tint.rgb,alpha);
|
||||
}
|
||||
)";
|
||||
ComPtr<ID3DBlob> v,p,error;
|
||||
if(FAILED(D3DCompile(source,strlen(source),nullptr,nullptr,nullptr,"vertex","vs_4_0",0,0,&v,&error)) ||
|
||||
FAILED(D3DCompile(source,strlen(source),nullptr,nullptr,nullptr,"pixel","ps_4_0",0,0,&p,&error)))return false;
|
||||
if(FAILED(device->CreateVertexShader(v->GetBufferPointer(),v->GetBufferSize(),nullptr,&vs)) ||
|
||||
FAILED(device->CreatePixelShader(p->GetBufferPointer(),p->GetBufferSize(),nullptr,&ps)))return false;
|
||||
D3D11_BUFFER_DESC cb{};cb.ByteWidth=144;cb.Usage=D3D11_USAGE_DEFAULT;cb.BindFlags=D3D11_BIND_CONSTANT_BUFFER;
|
||||
D3D11_BLEND_DESC bs{};auto& target=bs.RenderTarget[0];target.BlendEnable=true;target.SrcBlend=D3D11_BLEND_SRC_ALPHA;
|
||||
target.DestBlend=D3D11_BLEND_INV_SRC_ALPHA;target.BlendOp=D3D11_BLEND_OP_ADD;target.SrcBlendAlpha=D3D11_BLEND_ONE;
|
||||
target.DestBlendAlpha=D3D11_BLEND_INV_SRC_ALPHA;target.BlendOpAlpha=D3D11_BLEND_OP_ADD;target.RenderTargetWriteMask=15;
|
||||
D3D11_RASTERIZER_DESC rs{};rs.FillMode=D3D11_FILL_SOLID;rs.CullMode=D3D11_CULL_NONE;rs.DepthClipEnable=true;
|
||||
D3D11_DEPTH_STENCIL_DESC ds{};ds.DepthEnable=true;ds.DepthWriteMask=D3D11_DEPTH_WRITE_MASK_ZERO;ds.DepthFunc=D3D11_COMPARISON_LESS_EQUAL;
|
||||
if(FAILED(device->CreateDepthStencilState(&ds,&depth)))return false;
|
||||
ds.DepthFunc=D3D11_COMPARISON_GREATER_EQUAL;if(FAILED(device->CreateDepthStencilState(&ds,&reverse_depth)))return false;
|
||||
return SUCCEEDED(device->CreateBuffer(&cb,nullptr,&constants)) && SUCCEEDED(device->CreateBlendState(&bs,&blend)) &&
|
||||
SUCCEEDED(device->CreateRasterizerState(&rs,&raster));
|
||||
}
|
||||
inline std::mutex projection_mutex;
|
||||
inline std::atomic<float> expected_x{1},expected_y{1};
|
||||
inline uint64_t projection_stamp=0;
|
||||
inline std::atomic<int> projection_source{0};
|
||||
struct mapped_buffer {const void* data=nullptr;size_t bytes=0;uintptr_t identity=0;};
|
||||
inline std::mutex mapped_mutex;
|
||||
inline std::unordered_map<ID3D11Resource*,mapped_buffer> mapped;
|
||||
inline bool hooks_ready=false;
|
||||
inline std::vector<void*> hooks;
|
||||
using map_fn=HRESULT(STDMETHODCALLTYPE*)(ID3D11DeviceContext*,ID3D11Resource*,UINT,D3D11_MAP,UINT,D3D11_MAPPED_SUBRESOURCE*);
|
||||
using unmap_fn=void(STDMETHODCALLTYPE*)(ID3D11DeviceContext*,ID3D11Resource*,UINT);
|
||||
using update_fn=void(STDMETHODCALLTYPE*)(ID3D11DeviceContext*,ID3D11Resource*,UINT,const D3D11_BOX*,const void*,UINT,UINT);
|
||||
using targets_fn=void(STDMETHODCALLTYPE*)(ID3D11DeviceContext*,UINT,ID3D11RenderTargetView*const*,ID3D11DepthStencilView*);
|
||||
inline targets_fn original_targets=nullptr;
|
||||
using targets_uav_fn=void(STDMETHODCALLTYPE*)(ID3D11DeviceContext*,UINT,ID3D11RenderTargetView*const*,ID3D11DepthStencilView*,UINT,UINT,ID3D11UnorderedAccessView*const*,const UINT*);
|
||||
inline targets_uav_fn original_targets_uav=nullptr;
|
||||
inline std::atomic<void(*)(ID3D11DeviceContext*)> before_target_change{nullptr};
|
||||
inline map_fn original_map=nullptr;inline unmap_fn original_unmap=nullptr;inline update_fn original_update=nullptr;
|
||||
using update1_fn=void(STDMETHODCALLTYPE*)(ID3D11DeviceContext1*,ID3D11Resource*,UINT,const D3D11_BOX*,const void*,UINT,UINT,UINT);
|
||||
inline update1_fn original_update1=nullptr;
|
||||
inline mapped_buffer describe(ID3D11Resource* resource,const void* data) {
|
||||
if(!enabled || !resource || !data)return {};
|
||||
ComPtr<ID3D11Buffer> buffer;if(FAILED(resource->QueryInterface(IID_PPV_ARGS(&buffer))) || buffer.Get()==constants.Get())return {};
|
||||
{std::lock_guard lock(projection_mutex);if(cached_buffer && cached_buffer!=reinterpret_cast<uintptr_t>(buffer.Get()) && GetTickCount64()-projection_stamp<2000)return {};}
|
||||
D3D11_BUFFER_DESC desc{};buffer->GetDesc(&desc);
|
||||
if(!(desc.BindFlags&D3D11_BIND_CONSTANT_BUFFER) || desc.ByteWidth<64 || desc.ByteWidth>65536)return {};
|
||||
return {data,desc.ByteWidth,reinterpret_cast<uintptr_t>(buffer.Get())};
|
||||
}
|
||||
inline void observe(mapped_buffer value) {
|
||||
if(!value.data)return;
|
||||
projection p;const float x=expected_x.load(),y=expected_y.load();
|
||||
if(!find_projection(static_cast<const float*>(value.data),value.bytes/4,x,y,p))return;
|
||||
std::lock_guard lock(projection_mutex);cached_projection=p;cached_x=x;cached_y=y;cached_buffer=value.identity;projection_stamp=GetTickCount64();projection_source=1;
|
||||
}
|
||||
inline HRESULT STDMETHODCALLTYPE map_detour(ID3D11DeviceContext* context,ID3D11Resource* resource,UINT sub,D3D11_MAP type,UINT flags,D3D11_MAPPED_SUBRESOURCE* result) {
|
||||
const auto status=original_map(context,resource,sub,type,flags,result);
|
||||
if(SUCCEEDED(status) && result && sub==0 && type!=D3D11_MAP_READ) {
|
||||
auto buffer=describe(resource,result->pData);if(buffer.data){std::lock_guard lock(mapped_mutex);if(mapped.size()<64)mapped[resource]=buffer;}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
inline void STDMETHODCALLTYPE unmap_detour(ID3D11DeviceContext* context,ID3D11Resource* resource,UINT sub) {
|
||||
mapped_buffer value;
|
||||
if(sub==0){std::lock_guard lock(mapped_mutex);auto found=mapped.find(resource);if(found!=mapped.end()){value=found->second;mapped.erase(found);}}
|
||||
if(enabled)observe(value);original_unmap(context,resource,sub);
|
||||
}
|
||||
inline void STDMETHODCALLTYPE update_detour(ID3D11DeviceContext* context,ID3D11Resource* resource,UINT sub,const D3D11_BOX* box,const void* data,UINT row,UINT depth) {
|
||||
if(sub==0 && !box)observe(describe(resource,data));original_update(context,resource,sub,box,data,row,depth);
|
||||
}
|
||||
inline void STDMETHODCALLTYPE update1_detour(ID3D11DeviceContext1* context,ID3D11Resource* resource,UINT sub,const D3D11_BOX* box,const void* data,UINT row,UINT depth,UINT flags) {
|
||||
if(sub==0) {auto buffer=describe(resource,data);if(box){if(box->right>box->left && box->right-box->left<=buffer.bytes)buffer.bytes=box->right-box->left;else buffer={};}observe(buffer);}original_update1(context,resource,sub,box,data,row,depth,flags);
|
||||
}
|
||||
inline void target_boundary(ID3D11DeviceContext* context,ID3D11DepthStencilView* depth) {
|
||||
if(context!=draw_context.load() || GetCurrentThreadId()!=draw_thread.load())return;
|
||||
if(enabled)if(auto callback=before_target_change.load()) {
|
||||
static thread_local bool entered=false;
|
||||
if(!entered) {
|
||||
ComPtr<ID3D11DepthStencilView> previous;context->OMGetRenderTargets(0,nullptr,&previous);
|
||||
if(previous && previous.Get()!=depth){entered=true;callback(context);entered=false;}
|
||||
}
|
||||
}
|
||||
}
|
||||
inline void STDMETHODCALLTYPE targets_detour(ID3D11DeviceContext* context,UINT count,ID3D11RenderTargetView*const* targets,ID3D11DepthStencilView* depth) {
|
||||
target_boundary(context,depth);original_targets(context,count,targets,depth);
|
||||
}
|
||||
inline void STDMETHODCALLTYPE targets_uav_detour(ID3D11DeviceContext* context,UINT count,ID3D11RenderTargetView*const* targets,ID3D11DepthStencilView* depth,UINT start,UINT num,ID3D11UnorderedAccessView*const* uavs,const UINT* counters) {
|
||||
if(count!=D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL)target_boundary(context,depth);
|
||||
original_targets_uav(context,count,targets,depth,start,num,uavs,counters);
|
||||
}
|
||||
inline bool install(ID3D11DeviceContext* context) {
|
||||
if(hooks_ready)return true;
|
||||
auto** table=*reinterpret_cast<void***>(context);
|
||||
ComPtr<ID3D11DeviceContext1> extended;if(FAILED(context->QueryInterface(IID_PPV_ARGS(&extended))))return false;
|
||||
auto** table1=*reinterpret_cast<void***>(extended.Get());
|
||||
void* targets[]={table[14],table[15],table[48],table1[116],table[33],table[34]};
|
||||
void* detours[]={reinterpret_cast<void*>(&map_detour),reinterpret_cast<void*>(&unmap_detour),reinterpret_cast<void*>(&update_detour),reinterpret_cast<void*>(&update1_detour),reinterpret_cast<void*>(&targets_detour),reinterpret_cast<void*>(&targets_uav_detour)};
|
||||
void** originals[]={reinterpret_cast<void**>(&original_map),reinterpret_cast<void**>(&original_unmap),reinterpret_cast<void**>(&original_update),reinterpret_cast<void**>(&original_update1),reinterpret_cast<void**>(&original_targets),reinterpret_cast<void**>(&original_targets_uav)};
|
||||
for(int i=0;i<6;++i) {
|
||||
if(MH_CreateHook(targets[i],detours[i],originals[i])!=MH_OK){for(auto* hook:hooks)MH_RemoveHook(hook);hooks.clear();return false;}
|
||||
hooks.push_back(targets[i]);
|
||||
}
|
||||
for(auto* hook:hooks)if(MH_EnableHook(hook)!=MH_OK){for(auto* other:hooks){MH_DisableHook(other);MH_RemoveHook(other);}hooks.clear();return false;}
|
||||
hooks_ready=true;return true;
|
||||
}
|
||||
inline uintptr_t camera_matrix_address=0;
|
||||
inline uint64_t camera_owner=0,next_camera_scan=0;
|
||||
inline bool camera_projection(const world::frame& frame) {
|
||||
const auto ci=world::client.load();if(!ci || !frame.valid)return false;
|
||||
auto accept=[&](uintptr_t at,const float* data,size_t floats) {
|
||||
projection p;
|
||||
if(!find_projection(data,floats,frame.fov_x,frame.fov_y,p))return false;
|
||||
// This build's GPU projection was recovered from the crash dump.
|
||||
// Reject OpenGL/depth-range variants that happen to have the same FOV.
|
||||
int source=2;
|
||||
if(std::abs(p.b+.05f)<.00001f){p.a=(p.a-1)*.5f;p.b*=.5f;source=3;}
|
||||
if(std::abs(p.b+.025f)>.000005f)return false;
|
||||
std::lock_guard lock(projection_mutex);cached_projection=p;cached_x=frame.fov_x;cached_y=frame.fov_y;
|
||||
cached_buffer=1;projection_stamp=GetTickCount64();projection_source=source;camera_matrix_address=at;return true;
|
||||
};
|
||||
if(camera_owner!=frame.world_id){camera_owner=frame.world_id;camera_matrix_address=0;next_camera_scan=0;}
|
||||
std::array<float,16> matrix{};
|
||||
if(camera_matrix_address && world::read(camera_matrix_address,matrix) && accept(camera_matrix_address,matrix.data(),16))return true;
|
||||
const auto now=GetTickCount64();if(now<next_camera_scan)return false;next_camera_scan=now+1000;
|
||||
const auto renderer=world::get<uintptr_t>(ci+0x1c0),camera=world::get<uintptr_t>(renderer+0x468);
|
||||
if(camera && world::read(camera+0xf58,matrix) && accept(camera+0xf58,matrix.data(),16))return true;
|
||||
const auto active=world::active_camera(ci);
|
||||
const std::pair<uintptr_t,size_t> ranges[]={{camera,0x1100},{ci+0x300,0x700},{active,0x300}};
|
||||
for(auto range:ranges)if(range.first)for(size_t offset=0;offset+64<=range.second;offset+=4) {
|
||||
const auto at=range.first+offset;
|
||||
if(world::read(at,matrix) && accept(at,matrix.data(),16))return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
inline bool discover(ID3D11Device*,ID3D11DeviceContext* context,const world::frame& frame,projection& result) {
|
||||
expected_x=frame.fov_x;expected_y=frame.fov_y;
|
||||
{std::lock_guard lock(projection_mutex);if(cached_buffer==1 && GetTickCount64()-projection_stamp<2000 && std::abs(cached_x-frame.fov_x)<.0001f && std::abs(cached_y-frame.fov_y)<.0001f){result=cached_projection;return true;}}
|
||||
ID3D11Buffer* buffers[14]{};context->VSGetConstantBuffers(0,14,buffers);
|
||||
bool found=false;
|
||||
{std::lock_guard lock(projection_mutex);
|
||||
if(cached_buffer && GetTickCount64()-projection_stamp<2000 && std::abs(cached_x-frame.fov_x)<.0001f && std::abs(cached_y-frame.fov_y)<.0001f)
|
||||
for(auto* buffer:buffers)if(reinterpret_cast<uintptr_t>(buffer)==cached_buffer){result=cached_projection;found=true;break;}
|
||||
}
|
||||
for(auto* buffer:buffers)if(buffer)buffer->Release();return found;
|
||||
}
|
||||
struct pipeline_guard {
|
||||
ID3D11DeviceContext* context;ComPtr<ID3D11DeviceContext1> extended;
|
||||
ComPtr<ID3D11VertexShader> vs;ComPtr<ID3D11PixelShader> ps;ComPtr<ID3D11GeometryShader> gs;
|
||||
ComPtr<ID3D11HullShader> hs;ComPtr<ID3D11DomainShader> ds;
|
||||
ComPtr<ID3D11Buffer> vs_cb,ps_cb;UINT vf=0,vc=0,pf=0,pc=0;
|
||||
ComPtr<ID3D11BlendState> blend;ComPtr<ID3D11DepthStencilState> depth;ComPtr<ID3D11RasterizerState> raster;
|
||||
ComPtr<ID3D11InputLayout> layout;D3D11_PRIMITIVE_TOPOLOGY topology{};
|
||||
ID3D11ClassInstance* classes[5][256]{};UINT counts[5]={256,256,256,256,256};
|
||||
UINT stencil=0,mask=0,num_viewports=16;float factor[4]{};D3D11_VIEWPORT viewports[16]{};
|
||||
pipeline_guard(ID3D11DeviceContext* ctx):context(ctx) {
|
||||
context->QueryInterface(IID_PPV_ARGS(&extended));
|
||||
context->VSGetShader(&vs,classes[0],&counts[0]);context->PSGetShader(&ps,classes[1],&counts[1]);context->GSGetShader(&gs,classes[2],&counts[2]);
|
||||
context->HSGetShader(&hs,classes[3],&counts[3]);context->DSGetShader(&ds,classes[4],&counts[4]);
|
||||
if(extended){extended->VSGetConstantBuffers1(0,1,&vs_cb,&vf,&vc);extended->PSGetConstantBuffers1(0,1,&ps_cb,&pf,&pc);}
|
||||
else {context->VSGetConstantBuffers(0,1,&vs_cb);context->PSGetConstantBuffers(0,1,&ps_cb);}
|
||||
context->OMGetBlendState(&blend,factor,&mask);context->OMGetDepthStencilState(&depth,&stencil);
|
||||
context->RSGetState(&raster);context->RSGetViewports(&num_viewports,viewports);context->IAGetInputLayout(&layout);context->IAGetPrimitiveTopology(&topology);
|
||||
}
|
||||
~pipeline_guard() {
|
||||
context->VSSetShader(vs.Get(),classes[0],counts[0]);context->PSSetShader(ps.Get(),classes[1],counts[1]);context->GSSetShader(gs.Get(),classes[2],counts[2]);
|
||||
context->HSSetShader(hs.Get(),classes[3],counts[3]);context->DSSetShader(ds.Get(),classes[4],counts[4]);
|
||||
ID3D11Buffer* v=vs_cb.Get();ID3D11Buffer* p=ps_cb.Get();
|
||||
if(extended){extended->VSSetConstantBuffers1(0,1,&v,&vf,&vc);extended->PSSetConstantBuffers1(0,1,&p,&pf,&pc);}
|
||||
else {context->VSSetConstantBuffers(0,1,&v);context->PSSetConstantBuffers(0,1,&p);}
|
||||
context->OMSetBlendState(blend.Get(),factor,mask);context->OMSetDepthStencilState(depth.Get(),stencil);
|
||||
context->RSSetState(raster.Get());context->RSSetViewports(num_viewports,viewports);context->IASetInputLayout(layout.Get());context->IASetPrimitiveTopology(topology);
|
||||
for(int stage=0;stage<5;++stage)for(UINT i=0;i<counts[stage];++i)if(classes[stage][i])classes[stage][i]->Release();
|
||||
}
|
||||
};
|
||||
inline bool draw(ID3D11Device* device,ID3D11DeviceContext* context,const world::frame& frame,ID3D11RenderTargetView* target,ID3D11DepthStencilView* dsv,D3D11_VIEWPORT viewport,projection native,settings options,double time) {
|
||||
if(!target || !dsv || !frame.valid || !initialize(device))return false;
|
||||
pipeline_guard saved(context);
|
||||
context->IASetInputLayout(nullptr);context->GSSetShader(nullptr,nullptr,0);context->HSSetShader(nullptr,nullptr,0);context->DSSetShader(nullptr,nullptr,0);
|
||||
context->OMSetDepthStencilState(native.b<0 ? depth.Get():reverse_depth.Get(),0);
|
||||
context->OMSetBlendState(blend.Get(),nullptr,0xffffffff);context->RSSetState(raster.Get());context->RSSetViewports(1,&viewport);
|
||||
context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);context->VSSetShader(vs.Get(),nullptr,0);context->PSSetShader(ps.Get(),nullptr,0);
|
||||
ID3D11Buffer* cb=constants.Get();context->VSSetConstantBuffers(0,1,&cb);context->PSSetConstantBuffers(0,1,&cb);
|
||||
const float spacing=options.radius*2/17;
|
||||
for(int type=0;type<2;++type) {
|
||||
const float density=type==0 ? options.rain:options.snow;if(density<=0)continue;
|
||||
const auto color=type==0 ? options.rain_color:options.snow_color;
|
||||
float data[36];memcpy(data,frame.matrix,12*sizeof(float));
|
||||
const float rest[24]={frame.camera.x,frame.camera.y,frame.camera.z,float(fmod(time,4096.0)),frame.fov_x,frame.fov_y,native.a,native.b,
|
||||
floorf(frame.camera.x/spacing),floorf(frame.camera.y/4),floorf(frame.camera.z/spacing),spacing,
|
||||
float(color&255)/255,float((color>>8)&255)/255,float((color>>16)&255)/255,float(color>>24)/255,
|
||||
float(type),options.speed,options.wind,density,viewport.Width,viewport.Height,17,options.radius};
|
||||
memcpy(data+12,rest,sizeof(rest));context->UpdateSubresource(constants.Get(),0,nullptr,data,0,0);context->DrawInstanced(6,17*17*8,0,0);
|
||||
}
|
||||
InterlockedIncrement(&amnesia_weather_draws);return true;
|
||||
}
|
||||
inline void render(ID3D11Device* device,ID3D11DeviceContext* context,const world::frame& frame) {
|
||||
if(!enabled)return;
|
||||
ID3D11RenderTargetView* bound[8]{};ComPtr<ID3D11DepthStencilView> dsv;context->OMGetRenderTargets(8,bound,&dsv);
|
||||
ComPtr<ID3D11RenderTargetView> target;target.Attach(bound[0]);int colors=target ? 1:0;
|
||||
for(int i=1;i<8;++i)if(bound[i]){++colors;bound[i]->Release();}
|
||||
if(!target || !dsv || colors!=1){amnesia_weather_status=1;return;}
|
||||
D3D11_RENDER_TARGET_VIEW_DESC color_desc{};target->GetDesc(&color_desc);
|
||||
const auto format=color_desc.Format;
|
||||
if(format!=DXGI_FORMAT_R8G8B8A8_UNORM && format!=DXGI_FORMAT_R8G8B8A8_UNORM_SRGB &&
|
||||
format!=DXGI_FORMAT_B8G8R8A8_UNORM && format!=DXGI_FORMAT_B8G8R8A8_UNORM_SRGB &&
|
||||
format!=DXGI_FORMAT_R16G16B16A16_FLOAT && format!=DXGI_FORMAT_R11G11B10_FLOAT){amnesia_weather_status=2;return;}
|
||||
UINT count=1;D3D11_VIEWPORT viewport{};context->RSGetViewports(&count,&viewport);
|
||||
if(!count || viewport.Width<64 || viewport.Height<64 || std::abs(viewport.Width/viewport.Height-frame.fov_y/frame.fov_x)>.05f){amnesia_weather_status=2;return;}
|
||||
ComPtr<ID3D11Resource> resource;target->GetResource(&resource);ComPtr<ID3D11Texture2D> color_texture;
|
||||
if(FAILED(resource.As(&color_texture))){amnesia_weather_status=2;return;}
|
||||
D3D11_TEXTURE2D_DESC dimensions{};color_texture->GetDesc(&dimensions);
|
||||
if(std::abs(viewport.Width-dimensions.Width)>1 || std::abs(viewport.Height-dimensions.Height)>1 || viewport.TopLeftX!=0 || viewport.TopLeftY!=0){amnesia_weather_status=2;return;}
|
||||
projection native;if(!discover(device,context,frame,native)){amnesia_weather_status=3;return;}
|
||||
settings options;{std::lock_guard lock(mutex);options=configuration;}
|
||||
amnesia_weather_status=draw(device,context,frame,target.Get(),dsv.Get(),viewport,native,options,GetTickCount64()/1000.0) ? 4:5;
|
||||
}
|
||||
inline void shutdown(){enabled=false;vs.Reset();ps.Reset();constants.Reset();blend.Reset();raster.Reset();depth.Reset();reverse_depth.Reset();owner=nullptr;cached_buffer=0;next_probe=0;projection_stamp=0;camera_matrix_address=0;camera_owner=0;next_camera_scan=0;{std::lock_guard lock(mapped_mutex);mapped.clear();}}
|
||||
}
|
||||
+124
-107
@@ -7,6 +7,7 @@
|
||||
#include "fonts.h"
|
||||
#include "theme.h"
|
||||
#include "widgets.h"
|
||||
#include "indent_section.h"
|
||||
#include "../input.h"
|
||||
#include "../modules/module_manager.h"
|
||||
#include "../config/profiles.h"
|
||||
@@ -32,6 +33,7 @@ inline std::string key_name(int vk) {
|
||||
|
||||
class clickgui {
|
||||
public:
|
||||
void open() { set_open(true); }
|
||||
// after ImGui::CreateContext(), before the backends are initialized
|
||||
void init() {
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
@@ -51,11 +53,14 @@ public:
|
||||
menu_key_was_down_ = menu_down;
|
||||
|
||||
const bool esc_down = is_key_down(VK_ESCAPE);
|
||||
if (esc_down && !esc_was_down_ && g_menu_open && !any_binding()) set_open(false);
|
||||
if (esc_down && !esc_was_down_ && g_menu_open && !any_binding()) {
|
||||
if (editing_hud_) editing_hud_ = false;
|
||||
else set_open(false);
|
||||
}
|
||||
esc_was_down_ = esc_down;
|
||||
|
||||
update_menu_cursor();
|
||||
open_t_ = theme::approach(open_t_, g_menu_open ? 1.f : 0.f, ImGui::GetIO().DeltaTime * 14.f);
|
||||
open_t_ = std::clamp(open_t_+(g_menu_open ? 1.f : -1.f)*ImGui::GetIO().DeltaTime*6.5f,0.f,1.f);
|
||||
}
|
||||
|
||||
// dim + wordmark; call BEFORE modules().render() so the HUD stays above the dimming
|
||||
@@ -69,7 +74,7 @@ public:
|
||||
dl->AddRectFilled(ImVec2(0.f, 0.f), io.DisplaySize,
|
||||
theme::u32(theme::with_alpha(theme::bg(), k_backdrop_alpha * a)));
|
||||
|
||||
if(g_menu_open && hud_editor::options.snap && hud_editor::options.show_grid) {
|
||||
if(g_menu_open && editing_hud_ && hud_editor::options.snap && hud_editor::options.show_grid) {
|
||||
const float spacing=float(std::clamp(hud_editor::options.grid_size,4,64));
|
||||
const auto color=theme::u32(theme::with_alpha(theme::line(),.22f*a));
|
||||
for(float x=0;x<io.DisplaySize.x;x+=spacing)dl->AddLine({x,0},{x,io.DisplaySize.y},color);
|
||||
@@ -89,29 +94,42 @@ public:
|
||||
ImVec2(28.f, io.DisplaySize.y - 30.f),
|
||||
theme::u32(theme::with_alpha(theme::dim(), a)), "amnesia / v0.0.1");
|
||||
|
||||
const char* hint = "right click a module for settings | drag hud elements to move them | right shift or esc to close";
|
||||
const char* hint = editing_hud_
|
||||
? "drag hud elements to move them | shift to bypass grid | esc to return"
|
||||
: "right click a module for settings | right shift or esc to close";
|
||||
const ImVec2 hs = fonts::text_size(fonts::body, fonts::k_body_size, hint);
|
||||
dl->AddText(fonts::body, fonts::k_body_size,
|
||||
ImVec2(floorf(io.DisplaySize.x - hs.x - 28.f), io.DisplaySize.y - 32.f),
|
||||
theme::u32(theme::with_alpha(theme::muted(), a)), hint);
|
||||
}
|
||||
|
||||
// the panels and the HUD drag editor
|
||||
// Separate module and HUD editing screens share the same compact controls.
|
||||
void draw() {
|
||||
if (open_t_ <= 0.01f) return;
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, open_t_);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(12.f, 8.f));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(8.f, 3.f));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(6.f, 3.f));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemInnerSpacing, ImVec2(6.f, 3.f));
|
||||
|
||||
draw_profiles();
|
||||
float x = 40.f;
|
||||
for (category cat : k_categories) {
|
||||
if (!has_modules(cat)) continue;
|
||||
draw_panel(cat, x);
|
||||
x += k_panel_w + 20.f;
|
||||
if (editing_hud_) {
|
||||
draw_hud_editor();
|
||||
draw_editor_toolbar();
|
||||
} else {
|
||||
draw_navigation();
|
||||
// The navigation button can change screens in this frame.
|
||||
if (!editing_hud_) {
|
||||
float x = 40.f;
|
||||
for (category cat : k_categories) {
|
||||
if (!has_modules(cat)) continue;
|
||||
draw_panel(cat, x);
|
||||
x += k_panel_w + 12.f;
|
||||
}
|
||||
}
|
||||
}
|
||||
draw_hud_editor();
|
||||
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::PopStyleVar(5);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -123,46 +141,58 @@ private:
|
||||
float open_t_ = 0.f;
|
||||
bool menu_key_was_down_ = false;
|
||||
bool esc_was_down_ = false;
|
||||
bool editing_hud_ = false;
|
||||
char profile_name_[49]{};
|
||||
hud_editor::drag hud_drag_;
|
||||
// An organizer entry, separate from toggleable gameplay modules and their
|
||||
// saved settings. Autosaving remains active even while this card is closed.
|
||||
class module profile_entry_{"profiles", "Switch, save and manage client profiles.", category::utility};
|
||||
|
||||
void draw_profiles() {
|
||||
void draw_navigation() {
|
||||
ImGui::SetNextWindowPos(ImVec2(40.f, 56.f), ImGuiCond_Always);
|
||||
ImGui::SetNextWindowSize(ImVec2(850.f, 0.f), ImGuiCond_Always);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(8.f, 4.f));
|
||||
ImGui::SetNextWindowSize(ImVec2(0.f, 0.f), ImGuiCond_Always);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(8.f, 3.f));
|
||||
auto flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove |
|
||||
ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_AlwaysAutoResize;
|
||||
if (!g_menu_open) flags |= ImGuiWindowFlags_NoInputs;
|
||||
if (ImGui::Begin("##profiles", nullptr, flags)) {
|
||||
ImGui::AlignTextToFramePadding(); ImGui::TextUnformatted("profile"); ImGui::SameLine();
|
||||
ImGui::SetNextItemWidth(200.f);
|
||||
if (ImGui::BeginCombo("##active", profiles().active().c_str())) {
|
||||
if (ImGui::Begin("##navigation", nullptr, flags)) {
|
||||
if(ImGui::Button("hud editor")) {
|
||||
editing_hud_ = true;
|
||||
for (auto& m : modules().all()) {
|
||||
m->ui.binding = false;
|
||||
for (auto& s : m->settings()) s.binding = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui::End(); ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
void draw_profile_controls(float w) {
|
||||
ImGui::TextUnformatted("active profile");
|
||||
ImGui::SetNextItemWidth(w);
|
||||
if (widgets::begin_combo("##active", profiles().active().c_str(),w)) {
|
||||
if (ImGui::IsWindowAppearing()) profiles().refresh();
|
||||
const auto choices = profiles().names();
|
||||
for (const auto& name : choices) {
|
||||
const bool selected = name == profiles().active();
|
||||
if (ImGui::Selectable(name.c_str(), selected)) profiles().switch_to(name);
|
||||
if (widgets::selectable(name.c_str(), selected)) profiles().switch_to(name);
|
||||
if (selected) ImGui::SetItemDefaultFocus();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
ImGui::SameLine(); if (ImGui::Button("save now")) profiles().save();
|
||||
ImGui::SameLine(); if (ImGui::Button("manage profiles")) { profiles().refresh(); ImGui::OpenPopup("manage profiles"); }
|
||||
ImGui::SameLine();
|
||||
if (widgets::button("##save_profile", "save now", false, w, 22.f)) profiles().save();
|
||||
if (widgets::button("##manage_profiles", "manage profiles", false, w, 22.f)) { profiles().refresh(); ImGui::OpenPopup("manage profiles"); }
|
||||
ImGui::PushTextWrapPos(ImGui::GetCursorPosX() + w);
|
||||
ImGui::TextColored(profiles().blocked() ? theme::accent() : theme::muted(), "%s",
|
||||
profiles().blocked() ? "autosave paused: file error" : profiles().dirty() ? "autosaving..." : "autosave on / saved");
|
||||
ImGui::SameLine();if(ImGui::Button("hud editor"))ImGui::OpenPopup("hud editor");
|
||||
if(ImGui::BeginPopup("hud editor")) {
|
||||
widgets::checkbox("snap to grid",&hud_editor::options.snap,220);
|
||||
widgets::checkbox("show grid",&hud_editor::options.show_grid,220);
|
||||
ImGui::TextUnformatted("grid size (px)");ImGui::SetNextItemWidth(220);
|
||||
ImGui::SliderInt("##grid size",&hud_editor::options.grid_size,4,64);
|
||||
ImGui::TextColored(theme::muted(),"hold Shift while dragging for free movement");
|
||||
ImGui::EndPopup();
|
||||
if (!profiles().last_error().empty()) {
|
||||
ImGui::TextColored(theme::accent(), "%s", profiles().last_error().c_str());
|
||||
}
|
||||
ImGui::PopTextWrapPos();
|
||||
if (ImGui::BeginPopup("manage profiles")) {
|
||||
ImGui::TextUnformatted("New profiles copy your current settings.");
|
||||
ImGui::TextUnformatted("Names: letters, numbers, spaces, _ or -");
|
||||
ImGui::SetNextItemWidth(310.f); ImGui::InputText("name", profile_name_, sizeof(profile_name_));
|
||||
ImGui::SetNextItemWidth(310.f); widgets::input_text("name", profile_name_, sizeof(profile_name_),310.f);
|
||||
if (ImGui::Button("create & use")) { if (profiles().create(profile_name_)) profile_name_[0] = 0; }
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("rename current")) { if (profiles().rename(profile_name_)) profile_name_[0] = 0; }
|
||||
@@ -181,8 +211,23 @@ private:
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
}
|
||||
|
||||
void draw_editor_toolbar() {
|
||||
ImGui::SetNextWindowPos(ImVec2(40.f, 56.f), ImGuiCond_Always);
|
||||
ImGui::SetNextWindowSize(ImVec2(0.f, 0.f), ImGuiCond_Always);
|
||||
auto flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize |
|
||||
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_AlwaysAutoResize;
|
||||
if (!g_menu_open) flags |= ImGuiWindowFlags_NoInputs;
|
||||
if (ImGui::Begin("##hud_editor_toolbar", nullptr, flags)) {
|
||||
if (ImGui::Button("back to modules")) editing_hud_ = false;
|
||||
ImGui::SameLine(); ImGui::AlignTextToFramePadding(); ImGui::TextUnformatted("hud editor");
|
||||
ImGui::SameLine(0.f, 18.f); ImGui::Checkbox("snap to grid", &hud_editor::options.snap);
|
||||
ImGui::SameLine(); ImGui::Checkbox("show grid", &hud_editor::options.show_grid);
|
||||
ImGui::SameLine(); ImGui::SetNextItemWidth(130.f);
|
||||
widgets::slider_track("grid (px)", &hud_editor::options.grid_size, 4, 64,130.f,"%d");
|
||||
}
|
||||
ImGui::End(); ImGui::PopStyleVar();
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
static const char* category_title(category c) {
|
||||
@@ -200,6 +245,7 @@ private:
|
||||
update_menu_cursor();
|
||||
|
||||
if (open) {
|
||||
editing_hud_ = false;
|
||||
input::release_cursor();
|
||||
}
|
||||
else {
|
||||
@@ -255,61 +301,58 @@ private:
|
||||
fonts::push_font(fonts::heading, fonts::k_heading_size);
|
||||
ImGui::TextUnformatted(category_title(cat));
|
||||
ImGui::PopFont();
|
||||
ImGui::Dummy(ImVec2(0.f, 4.f));
|
||||
ImGui::Dummy(ImVec2(0.f, 1.f));
|
||||
|
||||
if (cat == category::utility) draw_module(profile_entry_, true);
|
||||
for (auto& m : modules().all())
|
||||
if (m->cat() == cat) draw_module(*m);
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void draw_tooltip(const module& m) {
|
||||
void draw_tooltip(const module& m, bool organizer = false) {
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(14.f, 12.f));
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::TextUnformatted(m.description().c_str());
|
||||
ImGui::TextColored(theme::muted(), "click to toggle | right click for settings");
|
||||
ImGui::TextColored(theme::muted(), "%s", organizer ? "click or right click to expand" : "click to toggle | right click for settings");
|
||||
ImGui::EndTooltip();
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
void draw_module(module& m) {
|
||||
void draw_module(module& m, bool organizer = false) {
|
||||
ImGui::PushID(&m);
|
||||
|
||||
ImDrawList* dl = ImGui::GetWindowDrawList();
|
||||
const float w = ImGui::GetContentRegionAvail().x;
|
||||
const float h = 38.f;
|
||||
const float h = 26.f;
|
||||
const ImVec2 p = ImGui::GetCursorScreenPos();
|
||||
const ImVec2 q(p.x + w, p.y + h);
|
||||
|
||||
ImGui::InvisibleButton("##row", ImVec2(w, h));
|
||||
const bool hovered = ImGui::IsItemHovered();
|
||||
const bool active = ImGui::IsItemActive();
|
||||
if (ImGui::IsItemClicked(ImGuiMouseButton_Left)) m.toggle();
|
||||
if (ImGui::IsItemClicked(ImGuiMouseButton_Left)) {
|
||||
if (organizer) m.ui.expanded = !m.ui.expanded;
|
||||
else m.toggle();
|
||||
}
|
||||
if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) {
|
||||
m.ui.expanded = !m.ui.expanded;
|
||||
m.ui.binding = false;
|
||||
}
|
||||
if (hovered) draw_tooltip(m);
|
||||
if (hovered) draw_tooltip(m, organizer);
|
||||
|
||||
const float dt = ImGui::GetIO().DeltaTime;
|
||||
m.ui.hover_t = theme::approach(m.ui.hover_t, hovered ? 1.f : 0.f, dt * 16.f);
|
||||
m.ui.enable_t = theme::approach(m.ui.enable_t, m.enabled() ? 1.f : 0.f, dt * 12.f);
|
||||
m.ui.expand_t = theme::approach(m.ui.expand_t, m.ui.expanded ? 1.f : 0.f, dt * 12.f);
|
||||
m.ui.enable_t = theme::approach(m.ui.enable_t, (organizer ? m.ui.expanded : m.enabled()) ? 1.f : 0.f, dt * 12.f);
|
||||
m.ui.expand_t = widgets::expand_step(m.ui.expand_t, m.ui.expanded, dt);
|
||||
|
||||
// off = secondary button, on = Primary (Accent fill, dark text)
|
||||
const ImVec4 fill_off = theme::mix(theme::raised(), theme::hover(), m.ui.hover_t);
|
||||
const ImVec4 fill_on = theme::shade(theme::accent(), 1.f + 0.10f * m.ui.hover_t);
|
||||
ImVec4 fill = theme::mix(fill_off, fill_on, m.ui.enable_t);
|
||||
ImVec4 border = theme::mix(theme::line(), theme::accent(), m.ui.hover_t);
|
||||
ImVec4 text_col = theme::mix(theme::fg(), theme::bg(), m.ui.enable_t);
|
||||
if (active) { fill.w *= 0.7f; border.w *= 0.7f; text_col.w *= 0.7f; }
|
||||
ImVec4 text_col = theme::mix(theme::muted(), theme::fg(), m.ui.enable_t);
|
||||
|
||||
dl->AddRectFilled(p, q, theme::u32(fill), theme::k_radius_button);
|
||||
dl->AddRect(p, q, theme::u32(border), theme::k_radius_button, 0, 1.f);
|
||||
theme::control(dl,p,q,organizer ? m.ui.expanded : m.enabled(),hovered,active);
|
||||
|
||||
const ImVec2 ts = fonts::text_size(fonts::semibold, fonts::k_body_size, m.name().c_str());
|
||||
dl->AddText(fonts::semibold, fonts::k_body_size,
|
||||
ImVec2(floorf(p.x + 16.f), floorf(p.y + (h - ts.y) * 0.5f)),
|
||||
ImVec2(floorf(p.x + 10.f), floorf(p.y + (h - ts.y) * 0.5f)),
|
||||
theme::u32(text_col), m.name().c_str());
|
||||
|
||||
if (m.toggle_key()) { // keycap chip on the right
|
||||
@@ -318,59 +361,31 @@ private:
|
||||
const float cw = ks.x + 14.f, ch = 20.f;
|
||||
const ImVec2 c0(q.x - 12.f - cw, p.y + (h - ch) * 0.5f);
|
||||
const ImVec2 c1(c0.x + cw, c0.y + ch);
|
||||
dl->AddRectFilled(c0, c1, theme::u32(theme::with_alpha(theme::bg(), 0.55f)), 6.f);
|
||||
dl->AddText(fonts::label, fonts::k_label_size,
|
||||
ImVec2(floorf(c0.x + 7.f), floorf(c0.y + (ch - ks.y) * 0.5f)),
|
||||
theme::u32(theme::muted()), k.c_str());
|
||||
theme::u32(theme::fg()), k.c_str());
|
||||
}
|
||||
|
||||
if (m.ui.expand_t > 0.01f) {
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * m.ui.expand_t);
|
||||
draw_settings(m, w);
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::Dummy(ImVec2(0.f, 2.f));
|
||||
if (m.ui.expand_t > 0.f) {
|
||||
widgets::indent_section(w,q.y,m.ui.expand_t,m.ui.settings_height,
|
||||
m.ui.expanded && m.ui.expand_t>=.99f,[&](float inner_w) {
|
||||
if (organizer) draw_profile_controls(inner_w);
|
||||
else {
|
||||
draw_bind(m,inner_w);
|
||||
for (auto& s:m.settings()) if (!s.hidden) draw_setting(s,inner_w);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
// settings live in an inset card (Bg fill, Line border), drawn behind the widgets
|
||||
void draw_settings(module& m, float w) {
|
||||
ImDrawList* dl = ImGui::GetWindowDrawList();
|
||||
const ImVec2 start = ImGui::GetCursorScreenPos();
|
||||
const float pad = 12.f;
|
||||
const float inner_w = w - pad * 2.f;
|
||||
|
||||
dl->ChannelsSplit(2);
|
||||
dl->ChannelsSetCurrent(1);
|
||||
|
||||
ImGui::BeginGroup();
|
||||
ImGui::Dummy(ImVec2(w, 2.f));
|
||||
ImGui::Indent(pad);
|
||||
|
||||
draw_bind(m, inner_w);
|
||||
for (auto& s : m.settings()) draw_setting(s, inner_w);
|
||||
|
||||
ImGui::Unindent(pad);
|
||||
ImGui::Dummy(ImVec2(0.f, 2.f));
|
||||
ImGui::EndGroup();
|
||||
|
||||
const ImVec2 gmin = ImGui::GetItemRectMin();
|
||||
const ImVec2 gmax = ImGui::GetItemRectMax();
|
||||
|
||||
dl->ChannelsSetCurrent(0);
|
||||
const ImVec2 a(start.x, gmin.y), b(start.x + w, gmax.y);
|
||||
dl->AddRectFilled(a, b, theme::u32(theme::bg()), theme::k_radius_button);
|
||||
dl->AddRect(a, b, theme::u32(theme::line()), theme::k_radius_button, 0, 1.f);
|
||||
dl->ChannelsMerge();
|
||||
}
|
||||
|
||||
void draw_bind(module& m, float w) {
|
||||
ImGui::TextUnformatted("bind");
|
||||
const std::string text = m.ui.binding ? std::string("press a key...") : key_name(m.toggle_key());
|
||||
if (widgets::button("##bind", text.c_str(), false, w)) m.ui.binding = !m.ui.binding;
|
||||
if (widgets::keybind("##bind", text.c_str(), m.ui.binding, w)) m.ui.binding = !m.ui.binding;
|
||||
|
||||
if (m.ui.binding) {
|
||||
if (m.ui.binding && !(ImGui::GetCurrentContext()->CurrentItemFlags & ImGuiItemFlags_Disabled)) {
|
||||
for (int vk = 0x08; vk < 0xFF; ++vk) { // starts above the mouse buttons
|
||||
if (is_key_down(vk)) {
|
||||
m.set_toggle_key(vk == VK_ESCAPE ? 0 : vk); // Esc clears the bind
|
||||
@@ -388,17 +403,17 @@ private:
|
||||
case setting_type::text: {
|
||||
char value[257]{}; strncpy_s(value, s.text_value.c_str(), _TRUNCATE);
|
||||
ImGui::TextUnformatted(s.name.c_str()); ImGui::SetNextItemWidth(w);
|
||||
if (ImGui::InputText("##text", value, (std::min)(sizeof(value), size_t(s.int_max + 1)))) s.text_value = value;
|
||||
if (widgets::input_text("##text", value, (std::min)(sizeof(value), size_t(s.int_max + 1)),w)) s.text_value = value;
|
||||
break;
|
||||
}
|
||||
case setting_type::action:
|
||||
if (widgets::button("##action", s.name.c_str(), false, w) && s.action) s.action();
|
||||
if (widgets::button("##action", s.name.c_str(), false, w, 22.f) && s.action) s.action();
|
||||
break;
|
||||
case setting_type::keybind: {
|
||||
ImGui::TextUnformatted(s.name.c_str());
|
||||
const std::string text = s.binding ? "press a key..." : key_name(s.int_value);
|
||||
if (widgets::button("##key", text.c_str(), false, w)) s.binding = !s.binding;
|
||||
if (s.binding) {
|
||||
if (widgets::keybind("##key", text.c_str(), s.binding, w)) s.binding = !s.binding;
|
||||
if (s.binding && !(ImGui::GetCurrentContext()->CurrentItemFlags & ImGuiItemFlags_Disabled)) {
|
||||
for (int vk = 0x08; vk < 0xFF; ++vk) {
|
||||
if (is_key_down(vk)) {
|
||||
// Keep modifiers specific so synthetic input and real input can be separated.
|
||||
@@ -412,27 +427,29 @@ private:
|
||||
break;
|
||||
}
|
||||
case setting_type::toggle:
|
||||
widgets::checkbox(s.name.c_str(), &s.bool_value, w);
|
||||
widgets::checkbox(s.name.c_str(), &s.bool_value, w, 20.f);
|
||||
break;
|
||||
|
||||
case setting_type::slider_float:
|
||||
ImGui::TextUnformatted(s.name.c_str());
|
||||
ImGui::SetNextItemWidth(w);
|
||||
ImGui::SliderFloat("##v", &s.float_value, s.float_min, s.float_max, "%.2f");
|
||||
widgets::slider_float(s.name.c_str(), &s.float_value, s.float_min, s.float_max,w);
|
||||
break;
|
||||
|
||||
case setting_type::slider_int:
|
||||
ImGui::TextUnformatted(s.name.c_str());
|
||||
ImGui::SetNextItemWidth(w);
|
||||
ImGui::SliderInt("##v", &s.int_value, s.int_min, s.int_max, "%d");
|
||||
widgets::slider_int(s.name.c_str(), &s.int_value, s.int_min, s.int_max,w);
|
||||
break;
|
||||
|
||||
case setting_type::mode:
|
||||
if (!s.modes.empty()) {
|
||||
if (s.int_value < 0 || s.int_value >= (int)s.modes.size()) s.int_value = 0;
|
||||
ImGui::TextUnformatted(s.name.c_str());
|
||||
if (widgets::button("##mode", s.modes[s.int_value].c_str(), false, w))
|
||||
s.int_value = (s.int_value + 1) % (int)s.modes.size();
|
||||
// Compact dropdown height shared with action buttons.
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding,{8.f,(22.f-ImGui::GetFontSize())*.5f});
|
||||
if(widgets::begin_combo("##mode",s.modes[s.int_value].c_str(),w)) {
|
||||
for(int i=0;i<int(s.modes.size());++i)
|
||||
if(widgets::selectable(s.modes[i].c_str(),s.int_value==i))s.int_value=i;
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -490,7 +507,7 @@ private:
|
||||
const ImVec4 col = (hovered || active) ? theme::focus() : theme::hover();
|
||||
ImGui::GetForegroundDrawList()->AddRect(
|
||||
m.hud_pos, ImVec2(m.hud_pos.x + size.x, m.hud_pos.y + size.y),
|
||||
theme::u32(col), 10.f, 0, 1.5f);
|
||||
theme::u32(col), 0.f, 0, 1.5f);
|
||||
}
|
||||
ImGui::End();
|
||||
ImGui::PopStyleVar(2);
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
#pragma once
|
||||
#include <windows.h>
|
||||
#include <psapi.h>
|
||||
#include <dxgi1_4.h>
|
||||
#include <array>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include "hud_editor.h"
|
||||
#include "hud_card.h"
|
||||
#include "../config/profiles.h"
|
||||
#include "../game/world.h"
|
||||
#include "../game/world_weather.h"
|
||||
#include "../game/world_filter.h"
|
||||
#include "../game/inventory_tools.h"
|
||||
#include "../game/qol_events.h"
|
||||
#include "../game/media.h"
|
||||
#pragma comment(lib,"psapi.lib")
|
||||
|
||||
// Included by main.cc only in Debug builds. Diagnostics never enable a reader
|
||||
// or hook, and use the same published snapshots as the ordinary HUD modules.
|
||||
namespace debug_metrics {
|
||||
inline double seconds() {
|
||||
static const double frequency=[] {LARGE_INTEGER value;QueryPerformanceFrequency(&value);return double(value.QuadPart);}();
|
||||
LARGE_INTEGER value;QueryPerformanceCounter(&value);return double(value.QuadPart)/frequency;
|
||||
}
|
||||
struct frame_history {
|
||||
std::array<float,240> values{};
|
||||
size_t count=0,next=0;
|
||||
void push(float ms) {if(!std::isfinite(ms)||ms<=0)return;values[next]=ms;next=(next+1)%values.size();count=(std::min)(count+1,values.size());}
|
||||
struct summary {float mean=0,min=0,max=0,p95=0,low=0;};
|
||||
summary summarize() const {
|
||||
if(!count)return {};
|
||||
auto sorted=values;std::sort(sorted.begin(),sorted.begin()+count);
|
||||
double total=0;for(size_t i=0;i<count;++i)total+=sorted[i];
|
||||
const size_t tail=(std::max)(size_t(1),(count+99)/100);
|
||||
double slow=0;for(size_t i=count-tail;i<count;++i)slow+=sorted[i];
|
||||
return {float(total/count),sorted[0],sorted[count-1],sorted[(count*95+99)/100-1],float(1000.*tail/slow)};
|
||||
}
|
||||
};
|
||||
struct row {std::string label,value;bool heading=false;};
|
||||
struct layout {
|
||||
ImVec2 pos{},size{};int columns=1,rows=0;
|
||||
float column_width=300,row_height=14,font_size=11,header=0,padding=0;
|
||||
};
|
||||
inline layout arrange(ImVec2 screen,size_t count,int grid) {
|
||||
layout out;
|
||||
const float step=float(std::clamp(grid,4,64));
|
||||
if(screen.x<=0 || screen.y<=0 || !count)return out;
|
||||
const float margin=(std::min)(step,(std::min)(screen.x,screen.y)*.05f);
|
||||
const float width=(std::max)(1.f,screen.x-margin*2),height=(std::max)(1.f,screen.y-margin*2);
|
||||
const int capacity=(std::max)(1,int((height-out.header-out.padding)/out.row_height));
|
||||
out.columns=std::clamp(int((count+capacity-1)/capacity),1,(std::max)(1,int(width/260)));
|
||||
out.rows=int((count+out.columns-1)/out.columns);
|
||||
out.column_width=(std::min)(std::ceil(300.f/step)*step,std::floor(width/out.columns/step)*step);
|
||||
out.column_width=(std::max)(1.f,out.column_width);
|
||||
const float scale=(std::min)(1.f,(std::min)(out.column_width/260.f,height/(out.header+out.padding+out.rows*out.row_height)));
|
||||
out.row_height*=scale;out.font_size*=scale;out.header*=scale;out.padding*=scale;
|
||||
out.size={out.column_width*out.columns,(std::min)(height,std::ceil((out.header+out.padding+out.rows*out.row_height)/step)*step)};
|
||||
out.pos={std::floor((screen.x-margin-out.size.x)/step)*step,std::floor(margin/step)*step};
|
||||
out.pos.x=(std::max)(0.f,out.pos.x);out.pos.y=(std::max)(0.f,out.pos.y);
|
||||
return out;
|
||||
}
|
||||
struct dashboard {
|
||||
frame_history history;
|
||||
frame_history::summary timing;
|
||||
std::vector<row> rows;
|
||||
double sampled=-1,started=seconds(),client_ms=0,module_ms=0,present_ms=0,overlay_ms=0,startup_ms=0;
|
||||
uint64_t cpu_stamp=0,wall_stamp=0;
|
||||
float cpu=0;bool cpu_known=false,memory_known=false,gpu_known=false;
|
||||
PROCESS_MEMORY_COUNTERS_EX memory{};DWORD handles=0;
|
||||
Microsoft::WRL::ComPtr<IDXGIAdapter3> adapter;
|
||||
bool adapter_attempted=false;
|
||||
DXGI_QUERY_VIDEO_MEMORY_INFO video{};
|
||||
std::string gpu="unavailable";
|
||||
static uint64_t ticks(FILETIME t){return (uint64_t(t.dwHighDateTime)<<32)|t.dwLowDateTime;}
|
||||
void heading(const char* label){rows.push_back({label,"",true});}
|
||||
template<class... Args> void add(const char* label,const char* format,Args... args) {
|
||||
char value[256]{};snprintf(value,sizeof(value),format,args...);rows.push_back({label,value,false});
|
||||
}
|
||||
void flag(const char* label,bool value){add(label,"%s",value ? "yes" : "no");}
|
||||
void sample(ID3D11Device* device) {
|
||||
const auto now=seconds();if(sampled>=0 && now-sampled<.5)return;sampled=now;
|
||||
timing=history.summarize();rows.clear();
|
||||
FILETIME creation{},exit{},kernel{},user{},wall{};GetSystemTimeAsFileTime(&wall);
|
||||
if(GetProcessTimes(GetCurrentProcess(),&creation,&exit,&kernel,&user)) {
|
||||
const auto cpu_now=ticks(kernel)+ticks(user),wall_now=ticks(wall);
|
||||
if(wall_stamp && wall_now>wall_stamp && cpu_now>=cpu_stamp) {
|
||||
cpu=float(100.*double(cpu_now-cpu_stamp)/double(wall_now-wall_stamp)/(std::max)(1ul,GetActiveProcessorCount(ALL_PROCESSOR_GROUPS)));cpu_known=true;
|
||||
}
|
||||
cpu_stamp=cpu_now;wall_stamp=wall_now;
|
||||
}
|
||||
memory.cb=sizeof(memory);memory_known=GetProcessMemoryInfo(GetCurrentProcess(),reinterpret_cast<PROCESS_MEMORY_COUNTERS*>(&memory),sizeof(memory))!=FALSE;
|
||||
GetProcessHandleCount(GetCurrentProcess(),&handles);
|
||||
if(device && !adapter_attempted) {
|
||||
adapter_attempted=true;Microsoft::WRL::ComPtr<IDXGIDevice> dxgi;Microsoft::WRL::ComPtr<IDXGIAdapter> base;
|
||||
if(SUCCEEDED(device->QueryInterface(IID_PPV_ARGS(&dxgi))) && SUCCEEDED(dxgi->GetAdapter(&base))) {
|
||||
base.As(&adapter);DXGI_ADAPTER_DESC desc{};
|
||||
if(SUCCEEDED(base->GetDesc(&desc))){char name[256]{};WideCharToMultiByte(CP_UTF8,0,desc.Description,-1,name,sizeof(name),nullptr,nullptr);gpu=name;}
|
||||
}
|
||||
}
|
||||
gpu_known=adapter && SUCCEEDED(adapter->QueryVideoMemoryInfo(0,DXGI_MEMORY_SEGMENT_GROUP_LOCAL,&video));
|
||||
const auto scene=world::latest();
|
||||
const bool fresh=world::fresh(*scene);
|
||||
size_t active=0,huds=0;for(const auto& module:modules().all()){active+=module->enabled();huds+=module->enabled()&&module->is_hud();}
|
||||
heading("client");
|
||||
add("uptime / startup","%.0f s / %.0f ms",now-started,startup_ms);
|
||||
add("modules / huds","%zu of %zu / %zu",active,modules().all().size(),huds);
|
||||
add("profile","%s",profiles().ready() ? profiles().active().c_str() : "loading");
|
||||
const bool hooks[]={world::ready,world::camera_ready,world::perspective_ready,world::time_ready,
|
||||
world::name_ready,world::fog_ready,inventory_tools::ready,input::mouse_gate_ready.load()};
|
||||
unsigned ready=0;for(bool hook:hooks)ready+=hook;
|
||||
add("core hooks","%u / 8",ready);
|
||||
if(fresh)add("world snapshot","%llu ms old",GetTickCount64()-scene->stamp);
|
||||
else add("world snapshot","%s",scene->valid ? "stale" : "no world");
|
||||
add("nearby / online","%zu / %s",scene->players.size(),scene->roster_known ? std::to_string(scene->online_players.size()).c_str() : "unknown");
|
||||
heading("process / memory");
|
||||
if(cpu_known)add("process cpu","%.1f%%",cpu);else add("process cpu","sampling");
|
||||
if(memory_known)add("ram / private","%.0f / %.0f mib",memory.WorkingSetSize/1048576.,memory.PrivateUsage/1048576.);
|
||||
else add("process memory","unavailable");
|
||||
if(gpu_known)add("gpu usage / budget","%.0f / %.0f mib",video.CurrentUsage/1048576.,video.Budget/1048576.);
|
||||
else add("gpu memory","unavailable");
|
||||
heading("rendering / events");
|
||||
add("weather state / draws","%ld / %ld",InterlockedCompareExchange(&amnesia_weather_status,0,0),InterlockedCompareExchange(&amnesia_weather_draws,0,0));
|
||||
add("particles seen / cut","%llu / %llu",qol_events::particles_seen.load(),qol_events::particles_suppressed.load());
|
||||
add("sound events","%llu",qol_events::sounds_seen.load());
|
||||
add("blocked clicks / wheel","%llu / %llu",input::blocked_mouse_buttons.load(),input::blocked_mouse_wheels.load());
|
||||
add("metadata refresh","%d hz (0 = native)",performance::hud_hz.load());
|
||||
flag("uncapped present",performance::uncapped_present.load());
|
||||
}
|
||||
void draw(ID3D11Device* device) {
|
||||
const auto begin=seconds();const auto& io=ImGui::GetIO();history.push(io.DeltaTime*1000);sample(device);
|
||||
std::vector<row> live;
|
||||
auto add=[&](const char* label,const char* format,auto... args){char value[128]{};snprintf(value,sizeof(value),format,args...);live.push_back({label,value,false});};
|
||||
live.push_back({"frame timing / 240-frame window","",true});
|
||||
add("fps / 1%% low","%.0f / %.0f",io.Framerate,timing.low);
|
||||
add("frame / mean","%.2f / %.2f ms",io.DeltaTime*1000,timing.mean);
|
||||
add("frame min / max","%.2f / %.2f ms",timing.min,timing.max);add("frame p95","%.2f ms",timing.p95);
|
||||
add("client / modules","%.2f / %.2f ms",client_ms,module_ms);add("present call / wait","%.2f ms",present_ms);add("diagnostics cost","%.2f ms",overlay_ms);
|
||||
add("imgui vertices / indices","%d / %d",io.MetricsRenderVertices,io.MetricsRenderIndices);
|
||||
add("display","%.0f x %.0f",io.DisplaySize.x,io.DisplaySize.y);
|
||||
live.insert(live.end(),rows.begin(),rows.end());
|
||||
const auto box=arrange(io.DisplaySize,live.size(),hud_editor::options.grid_size);
|
||||
if(box.size.x<=0 || box.size.y<=0)return;
|
||||
auto* draw=ImGui::GetForegroundDrawList();
|
||||
draw->PushClipRect(box.pos,{box.pos.x+box.size.x,box.pos.y+box.size.y},true);
|
||||
// Text and its existing font shadow only; leave gameplay visible.
|
||||
auto* font=fonts::label ? fonts::label : ImGui::GetFont();
|
||||
for(int column=0;column<box.columns;++column) {
|
||||
const float x=box.pos.x+column*box.column_width;
|
||||
|
||||
for(int index=0;index<box.rows;++index) {
|
||||
const size_t at=size_t(column*box.rows+index);if(at>=live.size())break;
|
||||
const auto& line=live[at];const float y=box.pos.y+box.header+index*box.row_height;
|
||||
const float left=x+box.padding,right=x+box.column_width-box.padding;
|
||||
if(line.heading) {
|
||||
draw->AddText(font,box.font_size,{left,y},theme::u32(theme::accent()),line.label.c_str());
|
||||
}else {
|
||||
const auto extent=font->CalcTextSizeA(box.font_size,FLT_MAX,0,line.value.c_str());
|
||||
const float value_x=(std::max)(left+(right-left)*.48f,right-extent.x);
|
||||
const float label_right=(std::min)(left+(right-left)*.56f,value_x-8);
|
||||
draw->PushClipRect({left,y},{label_right,y+box.row_height},true);
|
||||
draw->AddText(font,box.font_size,{left,y},theme::u32(theme::muted()),line.label.c_str());draw->PopClipRect();
|
||||
draw->PushClipRect({value_x,y},{right,y+box.row_height},true);
|
||||
draw->AddText(font,box.font_size,{value_x,y},theme::u32(theme::fg()),line.value.c_str());draw->PopClipRect();
|
||||
}
|
||||
}
|
||||
}
|
||||
draw->PopClipRect();overlay_ms=(seconds()-begin)*1000;
|
||||
}
|
||||
};
|
||||
inline dashboard state;
|
||||
}
|
||||
+30
-12
@@ -2,6 +2,7 @@
|
||||
#include <windows.h>
|
||||
#include <string>
|
||||
#include "imgui.h"
|
||||
#include "misc/freetype/imgui_freetype.h"
|
||||
|
||||
// optional fallback if the Segoe UI files can't be found
|
||||
#if __has_include("../font_data.h")
|
||||
@@ -14,14 +15,24 @@ int amnesia_fallback_font_size();
|
||||
|
||||
namespace fonts {
|
||||
|
||||
inline constexpr float k_body_size = 14.f; // launcher base font size
|
||||
inline constexpr float k_label_size = 11.f; // the small uppercase labels
|
||||
inline constexpr float k_heading_size = 20.f;
|
||||
inline constexpr float k_body_size = 13.f; // reference menu Verdana size
|
||||
inline constexpr float k_label_size = 11.f; // compact secondary labels
|
||||
inline constexpr float k_heading_size = 13.f;
|
||||
|
||||
inline ImFont* body = nullptr; // Segoe UI
|
||||
inline ImFont* semibold = nullptr; // Segoe UI Semibold (buttons, module names)
|
||||
inline ImFont* label = nullptr; // Segoe UI Bold
|
||||
inline ImFont* heading = nullptr; // Segoe UI Semibold, larger
|
||||
inline ImFont* body = nullptr; // Verdana, matching the reference menu
|
||||
inline ImFont* semibold = nullptr;
|
||||
inline ImFont* label = nullptr;
|
||||
inline ImFont* heading = nullptr;
|
||||
inline ImFont* media = nullptr; // original glyphs for song/artist metadata
|
||||
|
||||
inline void lowercase_display(ImFont* font) {
|
||||
// Render capitals with their lowercase glyph, including matching advance
|
||||
// widths for layout, wrapping and text-input caret placement. Keep source
|
||||
// strings intact: module/profile identifiers and external data retain case.
|
||||
// Apply before any glyphs are baked, at every font weight and size.
|
||||
for (ImWchar upper = 'A'; upper <= 'Z'; ++upper)
|
||||
font->AddRemapCodepoint(upper, upper + ('a' - 'A'));
|
||||
}
|
||||
|
||||
// PushFont changed signature in ImGui 1.92 (fonts became size-flexible)
|
||||
inline void push_font(ImFont* font, float size) {
|
||||
@@ -51,11 +62,13 @@ namespace fonts {
|
||||
inline ImFont* load_one(ImGuiIO& io, const char* file, float size) {
|
||||
std::string path;
|
||||
if (windows_font_path(file, path)) {
|
||||
if (ImFont* f = io.Fonts->AddFontFromFileTTF(path.c_str(), size)) return f;
|
||||
ImFontConfig config;config.PixelSnapH=true;
|
||||
if (ImFont* f = io.Fonts->AddFontFromFileTTF(path.c_str(), size,&config)) return f;
|
||||
}
|
||||
#if AMNESIA_HAS_FONT
|
||||
ImFontConfig cfg;
|
||||
cfg.FontDataOwnedByAtlas = false;
|
||||
cfg.PixelSnapH = true;
|
||||
return io.Fonts->AddFontFromMemoryTTF((void*)amnesia_fallback_font(), amnesia_fallback_font_size(), size, &cfg);
|
||||
#else
|
||||
return io.Fonts->AddFontDefault();
|
||||
@@ -65,10 +78,15 @@ namespace fonts {
|
||||
// after ImGui::CreateContext(), before the backends are initialized
|
||||
inline void load() {
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
body = load_one(io, "segoeui.ttf", k_body_size);
|
||||
semibold = load_one(io, "seguisb.ttf", k_body_size);
|
||||
label = load_one(io, "segoeuib.ttf", k_label_size);
|
||||
heading = load_one(io, "seguisb.ttf", k_heading_size);
|
||||
io.Fonts->SetFontLoader(ImGuiFreeType::GetFontLoader());
|
||||
// Strong mono-grid hinting with native Verdana hints; keep grayscale antialiasing.
|
||||
io.Fonts->FontLoaderFlags = ImGuiFreeTypeLoaderFlags_NoAutoHint | ImGuiFreeTypeLoaderFlags_MonoHinting;
|
||||
body = load_one(io, "verdana.ttf", k_body_size);
|
||||
semibold = load_one(io, "verdana.ttf", k_body_size);
|
||||
label = load_one(io, "verdana.ttf", k_label_size);
|
||||
heading = load_one(io, "verdana.ttf", k_heading_size);
|
||||
for (ImFont* font : {body, semibold, label, heading}) lowercase_display(font);
|
||||
media = load_one(io, "verdana.ttf", k_body_size);
|
||||
io.FontDefault = body;
|
||||
}
|
||||
|
||||
|
||||
+19
-14
@@ -1,34 +1,39 @@
|
||||
#pragma once
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include "fonts.h"
|
||||
#include "theme.h"
|
||||
|
||||
namespace hud_card {
|
||||
inline constexpr float pad_x = 12.f, pad_y = 7.f, gap = 6.f;
|
||||
inline ImVec2 size(const char* label, const char* value, float scale, const char* reserve = "") {
|
||||
const auto a = fonts::text_size(fonts::body, fonts::k_body_size, label);
|
||||
const auto b = fonts::text_size(fonts::semibold, fonts::k_body_size, value);
|
||||
const auto c = fonts::text_size(fonts::semibold, fonts::k_body_size, reserve);
|
||||
return ImVec2((pad_x * 2 + a.x + (a.x > 0 ? gap : 0) + (std::max)(b.x, c.x)) * scale,
|
||||
(pad_y * 2 + (std::max)(a.y, b.y)) * scale);
|
||||
const float font_size=fonts::k_body_size*scale;
|
||||
const auto a = fonts::text_size(fonts::body, font_size, label);
|
||||
const auto b = fonts::text_size(fonts::semibold, font_size, value);
|
||||
const auto c = fonts::text_size(fonts::semibold, font_size, reserve);
|
||||
const float spacing=a.x>0 && (b.x>0 || c.x>0) ? gap*scale : 0.f;
|
||||
return ImVec2(pad_x*2*scale+a.x+spacing+(std::max)(b.x,c.x),
|
||||
pad_y*2*scale+(std::max)(a.y,b.y));
|
||||
}
|
||||
inline float rows_height(int count, float line_height=fonts::k_body_size, float stride=20.f) {
|
||||
return pad_y*2+(std::max)(0,count-1)*stride+line_height;
|
||||
}
|
||||
inline void background(ImDrawList* draw, ImVec2 pos, ImVec2 size, float scale, bool enabled, float alpha = 1.f) {
|
||||
if (!enabled) return;
|
||||
const ImVec2 end(pos.x + size.x, pos.y + size.y);
|
||||
draw->AddRectFilled(pos, end, theme::u32(theme::with_alpha(theme::surface(), .85f * alpha)), 10.f * scale);
|
||||
draw->AddRect(pos, end, theme::u32(theme::with_alpha(theme::line(), alpha)), 10.f * scale, 0, scale);
|
||||
theme::panel(draw,pos,end,alpha);
|
||||
}
|
||||
inline void text(ImDrawList* draw, ImFont* font, float scale, ImVec2 pos, ImU32 color, const char* value, bool card) {
|
||||
if (!card) draw->AddText(font, fonts::k_body_size * scale, ImVec2(pos.x + scale, pos.y + scale),
|
||||
theme::u32(theme::with_alpha(theme::bg(), .7f)), value);
|
||||
draw->AddText(font, fonts::k_body_size * scale, pos, color, value);
|
||||
color=theme::display_color(color);
|
||||
draw->AddText(font, fonts::k_body_size * scale, {std::floor(pos.x),std::floor(pos.y)}, color, value);
|
||||
}
|
||||
inline void draw(ImVec2 pos, const char* label, const char* value, float scale, bool card, ImU32 color, const char* reserve = "") {
|
||||
auto* draw = ImGui::GetBackgroundDrawList(); const auto bounds = size(label, value, scale, reserve);
|
||||
background(draw, pos, bounds, scale, card);
|
||||
const auto a = fonts::text_size(fonts::body, fonts::k_body_size, label);
|
||||
const float y = pos.y + pad_y * scale;
|
||||
text(draw, fonts::body, scale, ImVec2(pos.x + pad_x * scale, y), theme::u32(theme::muted()), label, card);
|
||||
text(draw, fonts::semibold, scale, ImVec2(pos.x + (pad_x + a.x + (a.x > 0 ? gap : 0)) * scale, y), color, value, card);
|
||||
const auto a = fonts::text_size(fonts::body, fonts::k_body_size*scale, label);
|
||||
const auto b = fonts::text_size(fonts::semibold, fonts::k_body_size*scale, value);
|
||||
const float y = pos.y+(bounds.y-b.y)*.5f;
|
||||
text(draw, fonts::body, scale, ImVec2(pos.x+pad_x*scale,pos.y+(bounds.y-a.y)*.5f),theme::u32(theme::muted()),label,card);
|
||||
text(draw, fonts::semibold, scale, ImVec2(pos.x+bounds.x-pad_x*scale-b.x,y),color,value,card);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include "imgui.h"
|
||||
#include "imgui_internal.h"
|
||||
#include "theme.h"
|
||||
|
||||
namespace widgets {
|
||||
inline float expand_step(float value, bool open, float dt) {
|
||||
return theme::approach(value, open ? 1.f : 0.f, 1.f-std::exp(-14.f*(std::max)(0.f,dt)));
|
||||
}
|
||||
|
||||
// Measure controls at their natural height, but reserve/clip only the revealed part.
|
||||
// Keep everything in the category window so its scrolling and widget IDs stay intact.
|
||||
template<class Render>
|
||||
void indent_section(float width, float anchor_y, float amount, float& content_height, bool interactive, Render render) {
|
||||
const auto start=ImGui::GetCursorScreenPos();
|
||||
auto* window=ImGui::GetCurrentWindow();
|
||||
const auto old_max=window->DC.CursorMaxPos, old_ideal=window->DC.IdealMaxPos;
|
||||
const float reveal=content_height*amount;
|
||||
ImGui::PushClipRect(start,{start.x+width,start.y+reveal},true);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_Alpha,ImGui::GetStyle().Alpha*amount);
|
||||
if (!interactive) ImGui::BeginDisabled();
|
||||
ImGui::BeginGroup();
|
||||
ImGui::Indent(14.f);
|
||||
render((std::max)(1.f,width-14.f));
|
||||
ImGui::Unindent(14.f);
|
||||
ImGui::EndGroup();
|
||||
content_height=ImGui::GetItemRectSize().y;
|
||||
if (!interactive) ImGui::EndDisabled();
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::PopClipRect();
|
||||
const float height=content_height*amount;
|
||||
window->DrawList->AddLine({start.x+6.f,anchor_y},{start.x+6.f,start.y+height},
|
||||
theme::u32(theme::with_alpha(theme::hex(0x141414),amount)),3.f);
|
||||
// Discard the full measurement's scroll extent, then submit the animated bounds.
|
||||
window->DC.CursorMaxPos=old_max;
|
||||
window->DC.IdealMaxPos=old_ideal;
|
||||
ImGui::SetCursorScreenPos(start);
|
||||
ImGui::Dummy({width,height});
|
||||
}
|
||||
}
|
||||
+58
-24
@@ -16,20 +16,23 @@ namespace notifications {
|
||||
kind type=kind::info;
|
||||
double born=0,duration=3;
|
||||
float progress=-1,y=-1;
|
||||
bool dismissed=false;
|
||||
};
|
||||
inline std::deque<toast> items;
|
||||
inline std::mutex mutex;
|
||||
inline void dismiss(const std::string& key) {
|
||||
std::lock_guard lock(mutex);
|
||||
for(auto& item:items) if(item.key==key) item.duration=(std::max)(0.001,now()-item.born);
|
||||
for(auto& item:items) if(item.key==key && !item.dismissed) {
|
||||
item.duration=(std::max)(0.001,now()-item.born);item.dismissed=true;
|
||||
}
|
||||
}
|
||||
inline void push(std::string title,std::string body,kind type=kind::info,double duration=3,
|
||||
std::string key={},float progress=-1) {
|
||||
std::lock_guard lock(mutex);
|
||||
if(!key.empty()) for(auto& item:items) if(item.key==key) {
|
||||
const bool changed=item.title!=title || item.type!=type || item.duration!=duration;
|
||||
const bool changed=item.dismissed || item.title!=title || item.type!=type || item.duration!=duration;
|
||||
item.title=std::move(title);item.body=std::move(body);item.type=type;
|
||||
item.duration=duration;item.progress=progress;if(changed) item.born=now();return;
|
||||
item.duration=duration;item.progress=progress;item.dismissed=false;if(changed) item.born=now();return;
|
||||
}
|
||||
if(items.size()>=6) {
|
||||
auto removable=std::find_if(items.begin(),items.end(),[](const toast& t){return t.duration>0;});
|
||||
@@ -38,34 +41,65 @@ namespace notifications {
|
||||
items.push_back({std::move(key),std::move(title),std::move(body),type,now(),duration,progress,-1});
|
||||
}
|
||||
inline float entrance(float t) {t=std::clamp(t,0.f,1.f);return 1-(1-t)*(1-t);}
|
||||
inline constexpr float slide_duration=.5f;
|
||||
struct animation {float slide,alpha,remaining;};
|
||||
inline animation animate(const toast& item,double time) {
|
||||
const float age=float((std::max)(0.0,time-item.born));
|
||||
const float out=item.duration>0 ? entrance((age-float(item.duration))/slide_duration) : 0;
|
||||
const float in=entrance(age/slide_duration);
|
||||
return {(std::max)(1-in,out),1-out,
|
||||
item.duration>0 ? std::clamp(1-age/float(item.duration),0.f,1.f) : 1.f};
|
||||
}
|
||||
// The reference uses one compact message, rather than a title/icon/body card.
|
||||
inline std::string message(const toast& item) {
|
||||
if(item.title.empty())return item.body;
|
||||
if(item.body.empty())return item.title;
|
||||
return item.title + ": " + item.body;
|
||||
}
|
||||
inline void draw() {
|
||||
std::lock_guard lock(mutex);const double time=now();
|
||||
for(auto it=items.begin();it!=items.end();) {
|
||||
if(it->duration>0 && time-it->born>it->duration+.2)it=items.erase(it);else ++it;
|
||||
if(it->duration>0 && time-it->born>it->duration+slide_duration)it=items.erase(it);else ++it;
|
||||
}
|
||||
const auto& io=ImGui::GetIO();auto* draw=ImGui::GetForegroundDrawList();
|
||||
const float width=std::clamp(io.DisplaySize.x-24.f,140.f,300.f);float y=16;int shown=0;
|
||||
for(auto it=items.rbegin();it!=items.rend() && shown<3;++it,++shown) {
|
||||
auto& item=*it;const float age=float(time-item.born),in=std::clamp(age/.18f,0.f,1.f);
|
||||
const float out=item.duration>0 ? std::clamp((age-float(item.duration))/.2f,0.f,1.f) : 0;
|
||||
const float alpha=entrance(in)*(1-out);
|
||||
if(item.y<0)item.y=y;item.y+=(y-item.y)*(1-std::exp(-16.f*io.DeltaTime));
|
||||
const float x=io.DisplaySize.x-width-16+(1-entrance(in)+out)*8;
|
||||
fonts::push_font(fonts::body,fonts::k_body_size);
|
||||
const auto body=ImGui::CalcTextSize(item.body.c_str(),nullptr,false,width-24);ImGui::PopFont();
|
||||
const float height=28+(item.body.empty() ? 0 : body.y+5)+(item.progress>=0 ? 8 : 0);
|
||||
if(io.DisplaySize.x<=30 || io.DisplaySize.y<=12)return;
|
||||
fonts::push_font(fonts::body,fonts::k_body_size);
|
||||
const float max_width=(std::min)(480.f,io.DisplaySize.x-10.f);
|
||||
float y=5;
|
||||
for(auto& item:items) {
|
||||
const auto motion=animate(item,time);
|
||||
const float age=float(time-item.born),alpha=motion.alpha;
|
||||
const std::string text=message(item);
|
||||
const float width=std::clamp(ImGui::CalcTextSize(text.c_str()).x+16.f,20.f,max_width);
|
||||
const float wrap=width-16.f;
|
||||
const auto size=ImGui::CalcTextSize(text.c_str(),nullptr,false,wrap);
|
||||
const float height=size.y+12.f;
|
||||
if(item.y<0)item.y=y;
|
||||
item.y+=(y-item.y)*(1-std::exp(-12.f*io.DeltaTime));
|
||||
// Preserve the reference's 400px travel; allow wider messages to clear the edge.
|
||||
const float x=5-motion.slide*(std::max)(400.f,width+5.f);
|
||||
auto color=[&](ImVec4 c){c.w*=alpha;return ImGui::ColorConvertFloat4ToU32(c);};
|
||||
draw->AddRectFilled({x,item.y},{x+width,item.y+height},color(theme::with_alpha(theme::surface(),.85f)),10);
|
||||
draw->AddRect({x,item.y},{x+width,item.y+height},color(theme::line()),10);
|
||||
draw->PushClipRect({x+12,item.y},{x+width-12,item.y+height},true);
|
||||
draw->AddText(fonts::semibold,fonts::k_body_size,{x+12,item.y+7},color(item.type==kind::error ? theme::danger() : theme::fg()),item.title.c_str());
|
||||
if(!item.body.empty())draw->AddText(fonts::body,fonts::k_body_size,{x+12,item.y+26},color(theme::muted()),item.body.c_str(),nullptr,width-24);
|
||||
if(item.progress>=0) {
|
||||
const float p=std::isfinite(item.progress) ? std::clamp(item.progress,0.f,1.f) : 0;
|
||||
draw->AddRectFilled({x+12,item.y+height-7},{x+width-12,item.y+height-4},color(theme::line()),2);
|
||||
draw->AddRectFilled({x+12,item.y+height-7},{x+12+(width-24)*p,item.y+height-4},color(theme::accent()),2);
|
||||
theme::panel(draw,{x,item.y},{x+width,item.y+height},alpha,false);
|
||||
draw->AddRectFilled({x+2,item.y+2},{x+4,item.y+height-2},color(theme::accent()));
|
||||
draw->AddLine({x+4,item.y+2},{x+4,item.y+height-2},color(theme::hex(0x000000,.4f)));
|
||||
draw->PushClipRect({x+7,item.y+2},{x+width-2,item.y+height-2},true);
|
||||
draw->AddText(fonts::body,fonts::k_body_size,{x+8,item.y+6},color(theme::fg()),text.c_str(),nullptr,wrap);
|
||||
draw->PopClipRect();
|
||||
const ImVec2 bar0(x+6,item.y+height-4),bar1(x+width-2,item.y+height-2);
|
||||
if(item.progress>=0 || item.duration>0) {
|
||||
const float fraction=item.progress>=0 ? (std::isfinite(item.progress) ? std::clamp(item.progress,0.f,1.f) : 0.f) : motion.remaining;
|
||||
theme::bar(draw,bar0,bar1,fraction,theme::accent(),alpha);
|
||||
}
|
||||
draw->PopClipRect();y+=height+8;
|
||||
if(item.type==kind::warning || item.type==kind::error) {
|
||||
// Reference warning line: two-second bounce with a half-second blink.
|
||||
const float segment=(std::min)(20.f,bar1.x-bar0.x);
|
||||
const float offset=(.5f+.5f*std::sin(age*3.14159265f))*(bar1.x-bar0.x-segment);
|
||||
const float pulse=.5f+.5f*std::sin(age*12.5663706f);
|
||||
const auto tint=item.type==kind::error ? theme::danger() : theme::accent();
|
||||
draw->AddRect({bar0.x+offset,bar0.y},{bar0.x+offset+segment,bar1.y},color(theme::with_alpha(tint,pulse)));
|
||||
}
|
||||
y+=height+2.f;
|
||||
}
|
||||
ImGui::PopFont();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
#pragma once
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <atomic>
|
||||
#include <array>
|
||||
#include <cstdio>
|
||||
#include <d3d11.h>
|
||||
#include <wrl/client.h>
|
||||
#include "fonts.h"
|
||||
#include "theme.h"
|
||||
|
||||
namespace startup_intro {
|
||||
inline constexpr float duration=2.8f;
|
||||
inline constexpr float hold_age=1.85f;
|
||||
inline float unit(float value){return std::clamp(value,0.f,1.f);}
|
||||
inline float ease(float value){value=unit(value);return 1.f-std::pow(1.f-value,3.f);}
|
||||
inline float smooth(float value){value=unit(value);return value*value*(3.f-2.f*value);}
|
||||
inline ImU32 ink(ImVec4 color,float alpha){color.w*=unit(alpha);return ImGui::ColorConvertFloat4ToU32(color);}
|
||||
|
||||
enum class stage {hooks,modules,input,profile,hud,ready};
|
||||
inline std::atomic<stage> loading_stage{stage::hooks};
|
||||
inline std::atomic<unsigned> modules_done{0},modules_total{0};
|
||||
inline float completion(stage phase,unsigned done,unsigned total) {
|
||||
switch(phase) {
|
||||
case stage::hooks:return .05f;
|
||||
case stage::modules:return .35f+.4f*(total ? unit(float(done)/total) : 0);
|
||||
case stage::input:return .75f;
|
||||
case stage::profile:return .85f;
|
||||
case stage::hud:return .95f;
|
||||
case stage::ready:return 1.f;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
inline const char* stage_name(stage phase) {
|
||||
switch(phase) {
|
||||
case stage::hooks:return "loading hooks";
|
||||
case stage::modules:return "loading modules";
|
||||
case stage::input:return "setting up input";
|
||||
case stage::profile:return "loading profile";
|
||||
case stage::hud:return "preparing hud";
|
||||
case stage::ready:return "ready";
|
||||
}
|
||||
return "loading";
|
||||
}
|
||||
inline Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> texture;
|
||||
inline void initialize_texture(ID3D11Device* device) {
|
||||
if(!device || texture)return;
|
||||
// Small repeatable woven/grain tile; generated once and shared by every
|
||||
// frame. No image decoding or per-pixel CPU work during the animation.
|
||||
std::array<unsigned,128*128> pixels{};
|
||||
unsigned seed=0x416d6e65;
|
||||
for(unsigned y=0;y<128;++y)for(unsigned x=0;x<128;++x) {
|
||||
seed^=seed<<13;seed^=seed>>17;seed^=seed<<5;
|
||||
const unsigned weave=((x/2+y/2)&1) ? 9 : 0;
|
||||
pixels[y*128+x]=IM_COL32(160,160,160,9+(seed&31)+weave);
|
||||
}
|
||||
D3D11_TEXTURE2D_DESC desc{};desc.Width=desc.Height=128;desc.MipLevels=desc.ArraySize=1;
|
||||
desc.Format=DXGI_FORMAT_R8G8B8A8_UNORM;desc.SampleDesc.Count=1;
|
||||
desc.Usage=D3D11_USAGE_IMMUTABLE;desc.BindFlags=D3D11_BIND_SHADER_RESOURCE;
|
||||
D3D11_SUBRESOURCE_DATA data{pixels.data(),128*4,0};
|
||||
Microsoft::WRL::ComPtr<ID3D11Texture2D> image;
|
||||
if(SUCCEEDED(device->CreateTexture2D(&desc,&data,&image)))
|
||||
device->CreateShaderResourceView(image.Get(),nullptr,&texture);
|
||||
}
|
||||
|
||||
struct playback {
|
||||
double previous=-1;
|
||||
float age=0;
|
||||
bool finished=false;
|
||||
float step(double now,bool ready,bool skip_requested=false) {
|
||||
if(finished)return -1;
|
||||
const double delta=previous<0 ? 0 : (std::max)(0.0,now-previous);
|
||||
previous=now;
|
||||
// Start immediately, but keep the fully assembled mark on an opaque
|
||||
// field until hooks, profile activation and a module frame are ready.
|
||||
if(skip_requested)age=(std::max)(age,hold_age);
|
||||
age+=float(delta>.25 ? 1.0/60.0 : delta);
|
||||
if(!ready)age=(std::min)(age,hold_age);
|
||||
if(age>=duration){finished=true;return -1;}
|
||||
return age;
|
||||
}
|
||||
};
|
||||
inline playback animation;
|
||||
|
||||
inline void render(float age,ImVec2 screen,float progress=0,const char* status="loading hooks",double motion=0) {
|
||||
if(age<0 || age>=duration || screen.x<1 || screen.y<1)return;
|
||||
auto* draw=ImGui::GetForegroundDrawList();
|
||||
const float scale=std::clamp((std::min)(screen.x/900.f,screen.y/650.f),.35f,1.35f);
|
||||
const float enter=smooth(age/.18f),exit=smooth((age-2.12f)/.68f);
|
||||
const float alpha=enter*(1-smooth((age-2.02f)/.4f));
|
||||
const ImVec2 center{screen.x*.5f,screen.y*.5f};
|
||||
|
||||
// The opaque field clears only after loading has completed.
|
||||
const float edge=-screen.y*.2f+exit*(screen.x+screen.y*.4f);
|
||||
const float top=std::clamp(edge+screen.y*.12f,0.f,screen.x);
|
||||
const float bottom=std::clamp(edge-screen.y*.12f,0.f,screen.x);
|
||||
const ImVec2 field[]={{top,0},{screen.x,0},screen,{bottom,screen.y}};
|
||||
if(exit<=0)draw->AddRectFilled({0,0},screen,ink(theme::bg(),1.f));
|
||||
else draw->AddConvexPolyFilled(field,4,ink(theme::bg(),1.f));
|
||||
const float grain=1-smooth((age-1.95f)/.17f);
|
||||
if(texture && grain>0) {
|
||||
draw->PushClipRect({0,0},screen,true);
|
||||
const float drift=float(std::fmod(motion*4,128.0));
|
||||
for(float y=-128+drift;y<screen.y;y+=128)
|
||||
for(float x=-128+drift*.5f;x<screen.x;x+=128)
|
||||
draw->AddImage(reinterpret_cast<ImTextureID>(texture.Get()),{x,y},{x+128,y+128},{0,0},{1,1},ink({1,1,1,1},grain*.22f));
|
||||
draw->PopClipRect();
|
||||
}
|
||||
if(exit>0 && exit<1)
|
||||
draw->AddLine({edge+screen.y*.12f,0},{edge-screen.y*.12f,screen.y},ink(theme::accent(),(1-exit)*.5f),scale);
|
||||
|
||||
ImFont* face=fonts::heading ? fonts::heading : ImGui::GetFont();
|
||||
const float title_size=51*scale;
|
||||
const auto title=fonts::text_size(face,title_size,"amnesia");
|
||||
const float logo_h=70*scale,logo_w=logo_h*174/199,gap=23*scale;
|
||||
const float width=logo_w+gap+title.x;
|
||||
const float left=center.x-width*.5f;
|
||||
const ImVec2 origin{left,center.y-logo_h*.5f-6*scale};
|
||||
|
||||
// Short, precise face movements lock the familiar cube into place.
|
||||
const float assemble=ease((age-.14f)/.48f);
|
||||
auto pt=[&](float x,float y,float dx,float dy) {
|
||||
return ImVec2{origin.x+(x-43)*logo_h/199+dx*(1-assemble)*scale,
|
||||
origin.y+(y-36)*logo_h/199+dy*(1-assemble)*scale};
|
||||
};
|
||||
const ImVec2 cap[]={pt(130,36,0,-18),pt(217,86,0,-18),pt(130,137,0,-18),pt(43,86,0,-18)};
|
||||
const ImVec2 lhs[]={pt(43,86,-16,9),pt(130,137,-16,9),pt(130,235,-16,9),pt(43,184,-16,9)};
|
||||
const ImVec2 rhs[]={pt(130,137,16,9),pt(217,86,16,9),pt(217,184,16,9),pt(130,235,16,9)};
|
||||
const float mark=alpha*smooth((age-.12f)/.3f);
|
||||
draw->AddConvexPolyFilled(cap,4,ink(theme::accent(),mark));
|
||||
draw->AddConvexPolyFilled(lhs,4,ink(theme::dim(),mark));
|
||||
draw->AddConvexPolyFilled(rhs,4,ink(theme::line(),mark));
|
||||
|
||||
// The whole word slides out from behind the cube through a fixed mask.
|
||||
// Keep the normal letter spacing used by the rest of the client.
|
||||
const float reveal=ease((age-.4f)/.6f);
|
||||
const float text_x=left+logo_w+gap;
|
||||
draw->PushClipRect({text_x,center.y-logo_h},{text_x+title.x*reveal+1,center.y+logo_h},true);
|
||||
draw->AddText(face,title_size,{text_x-(1-reveal)*24*scale,center.y-title.y*.5f-6*scale},ink(theme::fg(),alpha*reveal),"amnesia");
|
||||
draw->PopClipRect();
|
||||
|
||||
// Stage completion comes from actual loader checkpoints, not intro age.
|
||||
const float bar_alpha=alpha*smooth((age-.55f)/.3f);
|
||||
const float y=center.y+logo_h*.5f+13*scale;
|
||||
theme::bar(draw,{left,y},{left+width,y+5*scale},progress,theme::accent(),bar_alpha);
|
||||
ImFont* body=fonts::body ? fonts::body : ImGui::GetFont();
|
||||
draw->AddText(body,11*scale,{left,y+12*scale},ink(theme::muted(),bar_alpha),status);
|
||||
char percent[8];snprintf(percent,sizeof(percent),"%d%%",int(unit(progress)*100+.5f));
|
||||
const auto size=fonts::text_size(body,11*scale,percent);
|
||||
draw->AddText(body,11*scale,{left+width-size.x,y+12*scale},ink(theme::muted(),bar_alpha),percent);
|
||||
}
|
||||
|
||||
inline void draw(bool ready,bool skip_requested=false) {
|
||||
const float age=animation.step(ImGui::GetTime(),ready,skip_requested);
|
||||
const auto phase=loading_stage.load();
|
||||
if(age>=0)render(age,ImGui::GetIO().DisplaySize,
|
||||
completion(phase,modules_done.load(),modules_total.load()),stage_name(phase),ImGui::GetTime());
|
||||
}
|
||||
}
|
||||
+71
-24
@@ -4,11 +4,10 @@
|
||||
|
||||
namespace theme {
|
||||
|
||||
// radii straight from App.xaml
|
||||
inline constexpr float k_radius_card = 20.f;
|
||||
inline constexpr float k_radius_button = 12.f;
|
||||
inline constexpr float k_radius_input = 10.f;
|
||||
inline constexpr float k_radius_check = 6.f;
|
||||
inline constexpr float k_radius_card = 0.f;
|
||||
inline constexpr float k_radius_button = 0.f;
|
||||
inline constexpr float k_radius_input = 0.f;
|
||||
inline constexpr float k_radius_check = 0.f;
|
||||
|
||||
inline float clampf(float v, float lo, float hi) { return v < lo ? lo : (v > hi ? hi : v); }
|
||||
|
||||
@@ -39,18 +38,51 @@ namespace theme {
|
||||
return (v - target < 0.001f && target - v < 0.001f) ? target : v;
|
||||
}
|
||||
|
||||
// ---- names mirror App.xaml ----
|
||||
inline ImVec4 bg() { return hex(0x17141c); } // Bg
|
||||
inline ImVec4 surface() { return hex(0x2b2632); } // Surface
|
||||
inline ImVec4 raised() { return hex(0x38313c); } // Raised
|
||||
inline ImVec4 fg() { return hex(0xc9b5af); } // Fg
|
||||
inline ImVec4 muted() { return hex(0x8372a0); } // Muted
|
||||
inline ImVec4 dim() { return hex(0x625577); } // Dim
|
||||
inline ImVec4 accent() { return hex(0x8c79a5); } // Accent
|
||||
inline ImVec4 hover() { return hex(0x74608e); } // Hover
|
||||
inline ImVec4 line() { return hex(0x433a4f); } // Line
|
||||
inline ImVec4 focus() { return hex(0xd5c7eb); } // keyboard-focus ring
|
||||
inline ImVec4 danger() { return hex(0xbc9ba1); } // error text
|
||||
// Reference menu: neutral charcoal, black edging, white text and #7a459c.
|
||||
inline ImVec4 bg() { return hex(0x212121); }
|
||||
inline ImVec4 surface() { return hex(0x2b2b2b); }
|
||||
inline ImVec4 raised() { return hex(0x1e1e1e); }
|
||||
inline ImVec4 fg() { return hex(0xffffff); }
|
||||
inline ImVec4 muted() { return hex(0xa0a0a0); }
|
||||
inline ImVec4 dim() { return hex(0x787878); }
|
||||
inline ImVec4 accent() { return hex(0x7a459c); }
|
||||
inline ImVec4 hover() { return hex(0x282828); }
|
||||
inline ImVec4 line() { return hex(0x000000); }
|
||||
inline ImVec4 focus() { return hex(0xffffff); }
|
||||
inline ImVec4 danger() { return hex(0xdf6868); }
|
||||
inline ImU32 display_color(ImU32 color) {
|
||||
const auto rgb=color&~IM_COL32_A_MASK;
|
||||
ImU32 replacement=rgb;
|
||||
if(rgb==(IM_COL32(201,181,175,255)&~IM_COL32_A_MASK))replacement=IM_COL32(255,255,255,0);
|
||||
else if(rgb==(IM_COL32(140,121,165,255)&~IM_COL32_A_MASK))replacement=IM_COL32(122,69,156,0);
|
||||
return replacement|(color&IM_COL32_A_MASK);
|
||||
}
|
||||
|
||||
inline void gradient(ImDrawList* draw,ImVec2 p,ImVec2 q,ImVec4 top,ImVec4 bottom,float alpha=1.f) {
|
||||
top.w*=alpha;bottom.w*=alpha;
|
||||
draw->AddRectFilledMultiColor(p,q,u32(top),u32(top),u32(bottom),u32(bottom));
|
||||
}
|
||||
inline void panel(ImDrawList* draw,ImVec2 p,ImVec2 q,float alpha=1.f,bool accent_strip=true) {
|
||||
gradient(draw,p,q,surface(),hex(0x1c1c1c),alpha);
|
||||
if(accent_strip && q.y-p.y>8) {
|
||||
draw->AddRectFilled({p.x+1,p.y+1},{q.x-1,p.y+3},u32(with_alpha(accent(),alpha)));
|
||||
draw->AddRectFilled({p.x+1,p.y+3},{q.x-1,p.y+4},u32(with_alpha(shade(accent(),.5f),alpha)));
|
||||
}
|
||||
draw->AddRect({p.x+1,p.y+1},{q.x-1,q.y-1},u32(with_alpha(line(),alpha)));
|
||||
}
|
||||
inline void control(ImDrawList* draw,ImVec2 p,ImVec2 q,bool selected=false,bool hovered=false,bool held=false,float alpha=1.f) {
|
||||
const auto top=selected ? hex(0x464646) : held ? hex(0x2d2d2d) : hovered ? hex(0x282828) : hex(0x1e1e1e);
|
||||
const auto bottom=selected ? hex(0x282828) : held ? hex(0x232323) : hovered ? hex(0x1c1c1c) : hex(0x161616);
|
||||
gradient(draw,p,q,top,bottom,alpha);
|
||||
draw->AddRect(p,q,u32(with_alpha(line(),alpha)));
|
||||
}
|
||||
inline void bar(ImDrawList* draw,ImVec2 p,ImVec2 q,float fraction,ImVec4 tint,float alpha=1.f) {
|
||||
gradient(draw,p,q,hex(0x232323),hex(0x2c2c2c),alpha);
|
||||
fraction=std::isfinite(fraction) ? clampf(fraction,0.f,1.f) : 0;
|
||||
if(fraction>0)gradient(draw,p,{p.x+(q.x-p.x)*fraction,q.y},tint,shade(tint,.5f),alpha);
|
||||
draw->AddLine({p.x+1,p.y+1},{q.x-1,p.y+1},u32(with_alpha(hex(0x2e2e2e),alpha)));
|
||||
draw->AddRect(p,q,u32(with_alpha(hex(0x0c0c0c),alpha)));
|
||||
}
|
||||
|
||||
// the isometric cube from the launcher's login screen; returns its width
|
||||
inline float draw_logo(ImDrawList* dl, ImVec2 pos, float height, float alpha = 1.f) {
|
||||
@@ -84,9 +116,9 @@ namespace theme {
|
||||
s.FrameBorderSize = 1.f;
|
||||
|
||||
s.WindowPadding = ImVec2(18.f, 18.f);
|
||||
s.FramePadding = ImVec2(12.f, 8.f);
|
||||
s.ItemSpacing = ImVec2(8.f, 8.f);
|
||||
s.ItemInnerSpacing = ImVec2(8.f, 6.f);
|
||||
s.FramePadding = ImVec2(8.f, 3.f);
|
||||
s.ItemSpacing = ImVec2(6.f, 3.f);
|
||||
s.ItemInnerSpacing = ImVec2(6.f, 3.f);
|
||||
s.GrabMinSize = 16.f;
|
||||
s.ScrollbarSize = 10.f;
|
||||
|
||||
@@ -94,11 +126,12 @@ namespace theme {
|
||||
s.AntiAliasedFill = true;
|
||||
|
||||
ImVec4* c = s.Colors;
|
||||
for(int i=0;i<ImGuiCol_COUNT;++i)c[i]=raised();
|
||||
const ImVec4 clear(0.f, 0.f, 0.f, 0.f);
|
||||
|
||||
c[ImGuiCol_Text] = fg();
|
||||
c[ImGuiCol_TextDisabled] = dim();
|
||||
c[ImGuiCol_WindowBg] = with_alpha(surface(), 0.97f);
|
||||
c[ImGuiCol_WindowBg] = bg();
|
||||
c[ImGuiCol_ChildBg] = clear;
|
||||
c[ImGuiCol_PopupBg] = surface();
|
||||
c[ImGuiCol_Border] = line();
|
||||
@@ -125,10 +158,24 @@ namespace theme {
|
||||
c[ImGuiCol_ButtonHovered] = hover();
|
||||
c[ImGuiCol_ButtonActive] = hover();
|
||||
|
||||
c[ImGuiCol_Header] = hover();
|
||||
c[ImGuiCol_HeaderHovered] = accent();
|
||||
c[ImGuiCol_Header] = shade(accent(),.5f);
|
||||
c[ImGuiCol_HeaderHovered] = hover();
|
||||
c[ImGuiCol_HeaderActive] = accent();
|
||||
c[ImGuiCol_Separator] = line();
|
||||
c[ImGuiCol_SeparatorHovered]=muted();c[ImGuiCol_SeparatorActive]=accent();
|
||||
c[ImGuiCol_MenuBarBg]=bg();c[ImGuiCol_CheckboxSelectedBg]=accent();
|
||||
c[ImGuiCol_InputTextCursor]=fg();c[ImGuiCol_TextSelectedBg]=with_alpha(accent(),.6f);
|
||||
c[ImGuiCol_ResizeGrip]=dim();c[ImGuiCol_ResizeGripHovered]=muted();c[ImGuiCol_ResizeGripActive]=accent();
|
||||
c[ImGuiCol_Tab]=raised();c[ImGuiCol_TabSelected]=hex(0x464646);c[ImGuiCol_TabHovered]=hover();
|
||||
c[ImGuiCol_TabSelectedOverline]=accent();c[ImGuiCol_TabDimmedSelectedOverline]=shade(accent(),.5f);
|
||||
c[ImGuiCol_PlotLines]=fg();c[ImGuiCol_PlotLinesHovered]=accent();
|
||||
c[ImGuiCol_PlotHistogram]=accent();c[ImGuiCol_PlotHistogramHovered]=fg();
|
||||
c[ImGuiCol_TableHeaderBg]=surface();c[ImGuiCol_TableBorderStrong]=line();c[ImGuiCol_TableBorderLight]=raised();
|
||||
c[ImGuiCol_TableRowBg]=clear;c[ImGuiCol_TableRowBgAlt]=with_alpha(fg(),.025f);
|
||||
c[ImGuiCol_TextLink]=accent();c[ImGuiCol_TreeLines]=dim();
|
||||
c[ImGuiCol_DragDropTarget]=accent();c[ImGuiCol_DragDropTargetBg]=with_alpha(accent(),.15f);
|
||||
c[ImGuiCol_UnsavedMarker]=accent();c[ImGuiCol_NavCursor]=fg();c[ImGuiCol_NavWindowingHighlight]=muted();
|
||||
c[ImGuiCol_NavWindowingDimBg]=with_alpha(line(),.45f);c[ImGuiCol_ModalWindowDimBg]=with_alpha(line(),.6f);
|
||||
}
|
||||
|
||||
} // namespace theme
|
||||
} // namespace theme
|
||||
+112
-46
@@ -1,41 +1,32 @@
|
||||
#pragma once
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
#include <type_traits>
|
||||
#include "imgui.h"
|
||||
#include "fonts.h"
|
||||
#include "theme.h"
|
||||
|
||||
namespace widgets {
|
||||
|
||||
inline constexpr float k_button_height = 36.f;
|
||||
inline constexpr float k_button_height = 26.f;
|
||||
|
||||
// the launcher's Button: Raised fill + Line border, hover -> Hover fill + Accent border,
|
||||
// pressed -> 70% opacity. primary = Accent fill with dark text. width 0 = fill the row.
|
||||
inline bool button(const char* id, const char* text, bool primary = false, float width = 0.f) {
|
||||
// Reference tab/button gradients fitted to the client's existing row bounds.
|
||||
inline bool button(const char* id, const char* text, bool primary = false, float width = 0.f, float height = k_button_height) {
|
||||
ImDrawList* dl = ImGui::GetWindowDrawList();
|
||||
const ImVec2 p = ImGui::GetCursorScreenPos();
|
||||
const float w = width > 0.f ? width : ImGui::GetContentRegionAvail().x;
|
||||
const float h = k_button_height;
|
||||
const float h = height;
|
||||
|
||||
ImGui::PushID(id);
|
||||
const bool clicked = ImGui::InvisibleButton("##b", ImVec2(w, h));
|
||||
const bool hovered = ImGui::IsItemHovered();
|
||||
const bool held = ImGui::IsItemActive();
|
||||
const ImGuiID key = ImGui::GetID("##hover_t");
|
||||
ImGui::PopID();
|
||||
|
||||
ImGuiStorage* st = ImGui::GetStateStorage();
|
||||
const float t = theme::approach(st->GetFloat(key, 0.f), hovered ? 1.f : 0.f,
|
||||
ImGui::GetIO().DeltaTime * 16.f);
|
||||
st->SetFloat(key, t);
|
||||
|
||||
ImVec4 fill = theme::mix(primary ? theme::accent() : theme::raised(), theme::hover(), t);
|
||||
ImVec4 border = theme::mix(theme::line(), theme::accent(), t);
|
||||
ImVec4 text_col = primary ? theme::bg() : theme::fg();
|
||||
if (held) { fill.w *= 0.7f; border.w *= 0.7f; text_col.w *= 0.7f; }
|
||||
ImVec4 text_col = primary || hovered ? theme::fg() : theme::muted();
|
||||
|
||||
const ImVec2 q(p.x + w, p.y + h);
|
||||
dl->AddRectFilled(p, q, theme::u32(fill), theme::k_radius_button);
|
||||
dl->AddRect(p, q, theme::u32(border), theme::k_radius_button, 0, 1.f);
|
||||
theme::control(dl,p,q,primary,hovered,held);
|
||||
|
||||
const ImVec2 ts = fonts::text_size(fonts::semibold, fonts::k_body_size, text);
|
||||
dl->AddText(fonts::semibold, fonts::k_body_size,
|
||||
@@ -44,51 +35,126 @@ namespace widgets {
|
||||
return clicked;
|
||||
}
|
||||
|
||||
// the launcher's CheckBox: 20px box, radius 6, Bg fill + Line border; checked -> Hover fill + tick
|
||||
inline bool checkbox(const char* label, bool* value, float width = 0.f) {
|
||||
// The original hitbox and label position surround a text-height checkbox.
|
||||
inline bool checkbox(const char* label, bool* value, float width = 0.f, float height = 22.f) {
|
||||
ImDrawList* dl = ImGui::GetWindowDrawList();
|
||||
const ImVec2 p = ImGui::GetCursorScreenPos();
|
||||
const float w = width > 0.f ? width : ImGui::GetContentRegionAvail().x;
|
||||
const float box = 20.f;
|
||||
const float h = 28.f;
|
||||
const float box = fonts::k_body_size + 6.f;
|
||||
const float h = height;
|
||||
|
||||
ImGui::PushID(label);
|
||||
const bool pressed = ImGui::InvisibleButton("##c", ImVec2(w, h));
|
||||
const bool hovered = ImGui::IsItemHovered();
|
||||
const ImGuiID hover_key = ImGui::GetID("##hover_t");
|
||||
const ImGuiID on_key = ImGui::GetID("##on_t");
|
||||
ImGui::PopID();
|
||||
|
||||
if (pressed) *value = !*value;
|
||||
|
||||
ImGuiStorage* st = ImGui::GetStateStorage();
|
||||
const float dt = ImGui::GetIO().DeltaTime;
|
||||
const float hover_t = theme::approach(st->GetFloat(hover_key, 0.f), hovered ? 1.f : 0.f, dt * 16.f);
|
||||
const float on_t = theme::approach(st->GetFloat(on_key, *value ? 1.f : 0.f), *value ? 1.f : 0.f, dt * 14.f);
|
||||
st->SetFloat(hover_key, hover_t);
|
||||
st->SetFloat(on_key, on_t);
|
||||
|
||||
const ImVec2 b0(p.x, p.y + (h - box) * 0.5f);
|
||||
const ImVec2 b1(b0.x + box, b0.y + box);
|
||||
const ImVec4 fill = theme::mix(theme::bg(), theme::hover(), on_t);
|
||||
const ImVec4 border = theme::mix(theme::line(), theme::accent(), hover_t > on_t ? hover_t : on_t);
|
||||
dl->AddRectFilled(b0, b1, theme::u32(fill), theme::k_radius_check);
|
||||
dl->AddRect(b0, b1, theme::u32(border), theme::k_radius_check, 0, 1.f);
|
||||
|
||||
if (on_t > 0.01f) { // vector tick, so we don't depend on the font having a check glyph
|
||||
const ImU32 tick = theme::u32(theme::with_alpha(theme::fg(), on_t));
|
||||
const ImVec2 a(b0.x + box * 0.27f, b0.y + box * 0.53f);
|
||||
const ImVec2 b(b0.x + box * 0.43f, b0.y + box * 0.69f);
|
||||
const ImVec2 c(b0.x + box * 0.74f, b0.y + box * 0.33f);
|
||||
dl->AddLine(a, b, tick, 2.f);
|
||||
dl->AddLine(b, c, tick, 2.f);
|
||||
}
|
||||
const float visual_box=fonts::k_body_size;
|
||||
const ImVec2 b0(p.x, p.y + (h - visual_box) * 0.5f);
|
||||
const ImVec2 b1(b0.x + visual_box, b0.y + visual_box);
|
||||
const auto top=*value ? theme::accent() : theme::hex(hovered ? 0x282828 : 0x1e1e1e);
|
||||
const auto bottom=*value ? theme::shade(theme::accent(),.5f) : theme::hex(hovered ? 0x3a3a3a : 0x303030);
|
||||
theme::gradient(dl,b0,b1,top,bottom);
|
||||
dl->AddRect(b0,b1,theme::u32(theme::line()));
|
||||
|
||||
const ImVec2 ts = fonts::text_size(fonts::body, fonts::k_body_size, label);
|
||||
dl->AddText(fonts::body, fonts::k_body_size,
|
||||
ImVec2(floorf(b1.x + 10.f), floorf(p.y + (h - ts.y) * 0.5f)),
|
||||
ImVec2(floorf(p.x + box + 8.f), floorf(p.y + (h - ts.y) * 0.5f)),
|
||||
theme::u32(theme::fg()), label);
|
||||
return pressed;
|
||||
}
|
||||
|
||||
} // namespace widgets
|
||||
inline void transparent_frame() {
|
||||
for(auto color:{ImGuiCol_FrameBg,ImGuiCol_FrameBgHovered,ImGuiCol_FrameBgActive,
|
||||
ImGuiCol_SliderGrab,ImGuiCol_SliderGrabActive})ImGui::PushStyleColor(color,{0,0,0,0});
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize,0.f);
|
||||
}
|
||||
inline void end_transparent_frame(){ImGui::PopStyleVar();ImGui::PopStyleColor(5);}
|
||||
|
||||
inline bool input_text(const char* id,char* value,size_t capacity,float width=0) {
|
||||
auto* draw=ImGui::GetWindowDrawList();const auto p=ImGui::GetCursorScreenPos();
|
||||
const float w=width>0 ? width : ImGui::CalcItemWidth();
|
||||
const ImVec2 q{p.x+w,p.y+ImGui::GetFrameHeight()};
|
||||
theme::gradient(draw,p,q,theme::hex(0x232323),theme::hex(0x2c2c2c));
|
||||
transparent_frame();ImGui::SetNextItemWidth(w);
|
||||
const bool changed=ImGui::InputText(id,value,capacity);
|
||||
end_transparent_frame();
|
||||
draw->AddLine({p.x+1,p.y+1},{q.x-1,p.y+1},theme::u32(theme::hex(0x2e2e2e)));
|
||||
draw->AddRect(p,q,theme::u32(theme::hex(0x0c0c0c)));
|
||||
return changed;
|
||||
}
|
||||
|
||||
inline bool begin_combo(const char* id,const char* preview,float width=0) {
|
||||
auto* draw=ImGui::GetWindowDrawList();const auto p=ImGui::GetCursorScreenPos();
|
||||
const float w=width>0 ? width : ImGui::CalcItemWidth();
|
||||
const ImVec2 q{p.x+w,p.y+ImGui::GetFrameHeight()};
|
||||
theme::gradient(draw,p,q,theme::hex(0x232323),theme::hex(0x2c2c2c));
|
||||
transparent_frame();ImGui::SetNextItemWidth(w);
|
||||
const bool open=ImGui::BeginCombo(id,nullptr,ImGuiComboFlags_NoArrowButton);
|
||||
end_transparent_frame();
|
||||
draw->AddLine({p.x+1,p.y+1},{q.x-1,p.y+1},theme::u32(theme::hex(0x2e2e2e)));
|
||||
draw->AddRect(p,q,theme::u32(theme::hex(0x0c0c0c)));
|
||||
draw->PushClipRect({p.x+5,p.y},{q.x-20,q.y},true);
|
||||
draw->AddText({p.x+5,p.y+ImGui::GetStyle().FramePadding.y},theme::u32(theme::fg()),preview);
|
||||
draw->PopClipRect();
|
||||
draw->AddText({q.x-13,p.y+ImGui::GetStyle().FramePadding.y},theme::u32(open ? theme::accent() : theme::fg()),open ? "-" : "+");
|
||||
return open;
|
||||
}
|
||||
inline bool selectable(const char* label,bool selected) {
|
||||
const auto p=ImGui::GetCursorScreenPos();
|
||||
if(selected)theme::gradient(ImGui::GetWindowDrawList(),p,{p.x+ImGui::GetContentRegionAvail().x,p.y+ImGui::GetTextLineHeight()},theme::accent(),theme::shade(theme::accent(),.5f));
|
||||
ImGui::PushStyleColor(ImGuiCol_Header,{0,0,0,0});
|
||||
const bool clicked=ImGui::Selectable(label,selected);
|
||||
ImGui::PopStyleColor();return clicked;
|
||||
}
|
||||
|
||||
// Preserve the existing label/control rows and native keyboard/Ctrl-click
|
||||
// slider editing, while rendering the reference's filled gradient track.
|
||||
inline bool text_button(const char* text) {
|
||||
const auto p=ImGui::GetCursorScreenPos();const auto size=ImGui::CalcTextSize(text);
|
||||
const bool pressed=ImGui::InvisibleButton(text,size);
|
||||
ImGui::GetWindowDrawList()->AddText(p,theme::u32(ImGui::IsItemHovered() ? theme::accent() : theme::fg()),text);
|
||||
return pressed;
|
||||
}
|
||||
inline bool keybind(const char* id,const char* text,bool listening,float width) {
|
||||
const auto p=ImGui::GetCursorScreenPos();const bool clicked=ImGui::InvisibleButton(id,{width,22});
|
||||
const auto size=fonts::text_size(fonts::body,fonts::k_body_size,text);
|
||||
ImGui::GetWindowDrawList()->AddText(fonts::body,fonts::k_body_size,
|
||||
{p.x+(width-size.x)*.5f,p.y+(22-size.y)*.5f},theme::u32(listening ? theme::accent() : theme::fg()),text);
|
||||
return clicked;
|
||||
}
|
||||
template<class T> inline bool slider_track(const char* id,T* value,T minimum,T maximum,float width,const char* format) {
|
||||
ImGui::SetNextItemWidth(width);bool changed=false;
|
||||
auto* draw=ImGui::GetWindowDrawList();ImDrawListSplitter layers;layers.Split(draw,2);layers.SetCurrentChannel(draw,1);
|
||||
const auto frame_p=ImGui::GetCursorScreenPos();const float inset=(std::max)(0.f,(ImGui::GetFrameHeight()-12.f)*.5f);
|
||||
const ImVec2 p{frame_p.x,frame_p.y+inset},q{p.x+width,p.y+12.f};
|
||||
transparent_frame();
|
||||
if constexpr(std::is_same_v<T,int>)changed=ImGui::SliderInt(id,value,minimum,maximum,format);
|
||||
else changed=ImGui::SliderFloat(id,value,minimum,maximum,format);
|
||||
end_transparent_frame();layers.SetCurrentChannel(draw,0);
|
||||
const float fraction=maximum>minimum ? float(*value-minimum)/float(maximum-minimum) : 0;
|
||||
theme::bar(draw,p,q,fraction,theme::accent());layers.Merge(draw);
|
||||
return changed;
|
||||
}
|
||||
template<class T> inline bool slider(const char* label,T* value,T minimum,T maximum,float width,const char* format,T step) {
|
||||
ImGui::PushID(label);bool changed=false;
|
||||
const auto origin=ImGui::GetCursorScreenPos();
|
||||
ImGui::TextUnformatted(label);const auto next=ImGui::GetCursorScreenPos();
|
||||
ImGui::SetCursorScreenPos({origin.x+width-29,origin.y});
|
||||
if(text_button("-")){*value=std::clamp(T(*value-step),minimum,maximum);changed=true;}
|
||||
ImGui::SameLine(0,3);
|
||||
if(text_button("+")){*value=std::clamp(T(*value+step),minimum,maximum);changed=true;}
|
||||
ImGui::SetCursorScreenPos(next);
|
||||
changed|=slider_track("##value",value,minimum,maximum,width,format);
|
||||
ImGui::PopID();return changed;
|
||||
}
|
||||
inline bool slider_float(const char* label,float* value,float minimum,float maximum,float width) {
|
||||
const float range=maximum-minimum;
|
||||
return slider(label,value,minimum,maximum,width,"%.2f",range<=2 ? .01f : range<=20 ? .1f : 1.f);
|
||||
}
|
||||
inline bool slider_int(const char* label,int* value,int minimum,int maximum,float width) {
|
||||
return slider(label,value,minimum,maximum,width,"%d",1);
|
||||
}
|
||||
} // namespace widgets
|
||||
+54
@@ -2,9 +2,12 @@
|
||||
#include <windows.h>
|
||||
#include <atomic>
|
||||
#include <array>
|
||||
#include <mutex>
|
||||
#include "game/hook.h"
|
||||
#include "MinHook.h"
|
||||
#include "imgui.h"
|
||||
#include "imgui_impl_win32.h"
|
||||
#include "window_branding.h"
|
||||
|
||||
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
@@ -12,6 +15,47 @@ inline std::atomic<bool> g_menu_open{ false };
|
||||
|
||||
namespace input {
|
||||
|
||||
// The platform can enqueue mouse events independently of our subclassed
|
||||
// window procedure. Gate the native queue as well as Win32 messages.
|
||||
inline constexpr const char* mouse_feed_signature =
|
||||
"41 57 41 56 41 55 41 54 56 57 55 53 48 83 EC 48 44 89 CF 44 89 C3 89 D5 48 89 CE "
|
||||
"44 0F B7 A4 24 C0 00 00 00 44 0F B7 AC 24 B8 00 00 00 44 0F B7 BC 24 B0 00 00 00";
|
||||
using mouse_feed_fn = void(__fastcall*)(void*,char,char,short,short,short,short,char);
|
||||
inline game::game_hook mouse_feed_hook;
|
||||
inline mouse_feed_fn original_mouse_feed = nullptr;
|
||||
inline std::mutex mouse_feed_mutex;
|
||||
inline void* mouse_device = nullptr;
|
||||
inline short mouse_x = 0, mouse_y = 0;
|
||||
inline std::atomic<bool> mouse_gate_ready{false};
|
||||
inline std::atomic<uint64_t> blocked_mouse_buttons{0},blocked_mouse_wheels{0},blocked_mouse_moves{0};
|
||||
inline constexpr UINT release_mouse_message = WM_APP + 0x5a3;
|
||||
inline constexpr WPARAM release_mouse_tag = 0x414d494e;
|
||||
|
||||
inline bool mouse_release(char button, char state) {
|
||||
return state == 0 && (button == 1 || button == 2 || button == 3 || button == 5 || button == 6);
|
||||
}
|
||||
inline void release_native_mouse() {
|
||||
std::lock_guard<std::mutex> lock(mouse_feed_mutex);
|
||||
if (!g_menu_open || !mouse_device || !original_mouse_feed) return;
|
||||
// Use the native release path on the window/input thread. It clears
|
||||
// cached buttons and queues releases for actions already held in-game.
|
||||
for (char button : {char(1),char(2),char(3),char(5),char(6)})
|
||||
original_mouse_feed(mouse_device,button,0,mouse_x,mouse_y,0,0,0);
|
||||
}
|
||||
inline void __fastcall mouse_feed_detour(void* device,char button,char state,
|
||||
short x,short y,short dx,short dy,char scrolling) {
|
||||
std::lock_guard<std::mutex> lock(mouse_feed_mutex);
|
||||
mouse_device = device;
|
||||
mouse_x = x; mouse_y = y;
|
||||
if (g_menu_open && !mouse_release(button,state)) {
|
||||
if (button == 0) ++blocked_mouse_moves;
|
||||
else if (button == 4) ++blocked_mouse_wheels;
|
||||
else ++blocked_mouse_buttons;
|
||||
return;
|
||||
}
|
||||
original_mouse_feed(device,button,state,x,y,dx,dy,scrolling);
|
||||
}
|
||||
|
||||
inline constexpr ULONG_PTR sprint_input_tag = 0x414d535052494e54ull;
|
||||
inline std::array<std::atomic<bool>, 256> physical_keys{};
|
||||
inline std::atomic<uint64_t> activity_sequence{0};
|
||||
@@ -100,6 +144,7 @@ namespace input {
|
||||
GetClipCursor(&saved_clip);
|
||||
wanted_set = false;
|
||||
if (o_clip_cursor) o_clip_cursor(nullptr); else ClipCursor(nullptr);
|
||||
if (hooked_window) PostMessageW(hooked_window,release_mouse_message,release_mouse_tag,0);
|
||||
}
|
||||
|
||||
inline void restore_cursor() {
|
||||
@@ -149,6 +194,11 @@ namespace input {
|
||||
WPARAM wp,
|
||||
LPARAM lp
|
||||
) {
|
||||
if (msg == release_mouse_message && wp == release_mouse_tag && lp == 0) {
|
||||
release_native_mouse();
|
||||
return 0;
|
||||
}
|
||||
if(window_branding::handle_message(hwnd,msg,wp,lp))return 0;
|
||||
if(msg==WM_KILLFOCUS)if(auto handler=focus_lost_handler.load())handler();
|
||||
observe_message(hwnd, msg, wp, lp);
|
||||
if(auto handler=inventory_handler.load();handler && handler(hwnd,msg,wp,lp))return 0;
|
||||
@@ -187,6 +237,10 @@ namespace input {
|
||||
physical_keys[vk].store((GetAsyncKeyState(vk) & 0x8000) != 0, std::memory_order_relaxed);
|
||||
o_wnd_proc = (WNDPROC)SetWindowLongPtrW(hwnd, GWLP_WNDPROC, (LONG_PTR)wnd_proc);
|
||||
|
||||
mouse_gate_ready = mouse_feed_hook.install("menu mouse input",mouse_feed_signature,
|
||||
reinterpret_cast<void*>(&mouse_feed_detour),reinterpret_cast<void**>(&original_mouse_feed),true)
|
||||
&& mouse_feed_hook.set_enabled(true);
|
||||
|
||||
if (MH_CreateHookApiEx(L"user32", "SetCursorPos", (LPVOID)&hk_set_cursor_pos,
|
||||
(LPVOID*)&o_set_cursor_pos, &set_cursor_target) == MH_OK)
|
||||
MH_EnableHook(set_cursor_target);
|
||||
|
||||
+218
-56
@@ -2,12 +2,14 @@
|
||||
#include <d3d11.h>
|
||||
#include <dxgi.h>
|
||||
#include <atomic>
|
||||
#include <functional>
|
||||
#include "MinHook.h"
|
||||
#include "imgui.h"
|
||||
#include "imgui_impl_dx11.h"
|
||||
#include "imgui_impl_win32.h"
|
||||
|
||||
#include "input.h"
|
||||
#include "window_branding.h"
|
||||
#include "gui/clickgui.h"
|
||||
#include "modules/module_manager.h"
|
||||
#include "modules/fps_counter.h"
|
||||
@@ -29,7 +31,12 @@
|
||||
#include "modules/cps_counter.h"
|
||||
#include "modules/clock.h"
|
||||
#include "modules/world_modules.h"
|
||||
#include "modules/qol_modules.h"
|
||||
#include "gui/notifications.h"
|
||||
#include "gui/startup_intro.h"
|
||||
#ifdef _DEBUG
|
||||
#include "gui/debug_metrics.h"
|
||||
#endif
|
||||
|
||||
#pragma comment(lib, "d3d11.lib")
|
||||
#pragma comment(lib, "dxgi.lib")
|
||||
@@ -40,11 +47,50 @@ static present_fn o_present = nullptr;
|
||||
static bool g_init = false;
|
||||
static ID3D11Device* g_device = nullptr;
|
||||
static ID3D11DeviceContext* g_ctx = nullptr;
|
||||
static std::atomic<DWORD> g_present_thread{0};
|
||||
static HMODULE g_module = nullptr;
|
||||
static std::atomic<bool> g_unloading{ false };
|
||||
static std::atomic<bool> g_client_ready{false};
|
||||
static std::atomic<HANDLE> g_start_client{nullptr};
|
||||
static HANDLE g_loader_thread=nullptr;
|
||||
static bool g_runtime_ready=false,g_startup_menu_requested=false,g_load_requested=false;
|
||||
|
||||
static void report_world_weather() {
|
||||
if(!world_weather::enabled)return;
|
||||
static ULONGLONG previous=0;const auto now=GetTickCount64();if(now-previous<1000)return;previous=now;
|
||||
wchar_t path[32768]{};if(!GetModuleFileNameW(g_module,path,32768))return;
|
||||
std::wstring file=path;const auto slash=file.find_last_of(L"\\/");if(slash==std::wstring::npos)return;
|
||||
file.resize(slash+1);file+=L"world-weather-status.txt";
|
||||
char text[256]{};const int length=snprintf(text,sizeof(text),"stamp=%llu status=%ld draws=%ld callbacks=%ld blocked=%ld uploads=%d projection=%d\n",
|
||||
now,amnesia_weather_status,amnesia_weather_draws,amnesia_weather_callbacks,amnesia_weather_blocked,world_weather::hooks_ready ? 1:0,world_weather::projection_source.load());
|
||||
HANDLE output=CreateFileW(file.c_str(),GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,nullptr,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,nullptr);
|
||||
if(output!=INVALID_HANDLE_VALUE){DWORD written=0;WriteFile(output,text,length,&written,nullptr);CloseHandle(output);}
|
||||
}
|
||||
|
||||
static std::atomic<uint64_t> g_weather_frame{1};
|
||||
static uint64_t g_last_weather_frame=0;
|
||||
static void render_world_weather_gpu(ID3D11DeviceContext* context) {
|
||||
if(!world_weather::enabled || g_unloading || !g_init || context!=g_ctx || GetCurrentThreadId()!=g_present_thread.load())return;
|
||||
if(g_last_weather_frame==g_weather_frame.load() || g_menu_open || !is_game_focused())return;
|
||||
CURSORINFO cursor{sizeof(cursor)};if(!GetCursorInfo(&cursor) || cursor.flags&CURSOR_SHOWING)return;
|
||||
const auto scene=world::latest();if(!world::fresh(*scene))return;
|
||||
const auto before=amnesia_weather_draws;world_weather::render(g_device,g_ctx,*scene);
|
||||
if(amnesia_weather_draws!=before)g_last_weather_frame=g_weather_frame.load();
|
||||
}
|
||||
static void render_world_weather() {
|
||||
if(!world_weather::enabled)return;
|
||||
InterlockedIncrement(&amnesia_weather_callbacks);
|
||||
// World capture may run on the simulation thread; only publish CPU inputs here.
|
||||
const auto scene=world::latest();if(world::fresh(*scene)){world_weather::expected_x=scene->fov_x;world_weather::expected_y=scene->fov_y;world_weather::camera_projection(*scene);}
|
||||
}
|
||||
|
||||
HRESULT __stdcall hk_present(IDXGISwapChain* sc, UINT sync, UINT flags) {
|
||||
if (g_unloading) return o_present(sc, sync, flags);
|
||||
#ifdef _DEBUG
|
||||
const auto debug_frame_begin=debug_metrics::seconds();
|
||||
#endif
|
||||
g_present_thread=GetCurrentThreadId();
|
||||
bool drew_loading_screen=false;
|
||||
|
||||
if (!g_init) {
|
||||
// if the game isn't running D3D11 this fails, and we just skip drawing
|
||||
@@ -52,7 +98,6 @@ HRESULT __stdcall hk_present(IDXGISwapChain* sc, UINT sync, UINT flags) {
|
||||
return o_present(sc, sync, flags);
|
||||
|
||||
g_device->GetImmediateContext(&g_ctx);
|
||||
media_art::device=g_device;
|
||||
|
||||
DXGI_SWAP_CHAIN_DESC desc;
|
||||
sc->GetDesc(&desc);
|
||||
@@ -62,10 +107,16 @@ HRESULT __stdcall hk_present(IDXGISwapChain* sc, UINT sync, UINT flags) {
|
||||
gui().init(); // fonts + theme, must run before the backends init
|
||||
ImGui_ImplWin32_Init(desc.OutputWindow);
|
||||
ImGui_ImplDX11_Init(g_device, g_ctx);
|
||||
input::install(desc.OutputWindow); // window proc + cursor hooks
|
||||
startup_intro::initialize_texture(g_device);
|
||||
g_init = true;
|
||||
}
|
||||
|
||||
world_weather::draw_context=g_ctx;world_weather::draw_thread=GetCurrentThreadId();
|
||||
if(world_weather::enabled && !world_weather::hooks_ready)world_weather::install(g_ctx);
|
||||
|
||||
report_world_weather();
|
||||
render_world_weather_gpu(g_ctx);
|
||||
|
||||
// grab the backbuffer fresh each frame so window resizes just work
|
||||
ID3D11Texture2D* backbuffer = nullptr;
|
||||
ID3D11RenderTargetView* rtv = nullptr;
|
||||
@@ -76,36 +127,97 @@ HRESULT __stdcall hk_present(IDXGISwapChain* sc, UINT sync, UINT flags) {
|
||||
}
|
||||
|
||||
if (rtv) {
|
||||
const auto scene=world::latest();
|
||||
if(!world::fresh(*scene)) input::in_world=false;
|
||||
CURSORINFO cursor{sizeof(cursor)};
|
||||
if(world::fresh(*scene) && GetCursorInfo(&cursor) && !(cursor.flags&CURSOR_SHOWING) && world_filter::enabled) {
|
||||
static bool filter_warning=false;
|
||||
const bool applied=world_filter::apply(g_device,g_ctx,rtv);
|
||||
if(!applied && !filter_warning) notifications::push("World tint unavailable","This render target does not support the world color filter. Fog color remains available.",notifications::kind::warning,5,"world_filter");
|
||||
filter_warning=!applied;
|
||||
// Keep rendering the loading screen while the worker builds the client.
|
||||
// Do not access the registry until it has been completely constructed.
|
||||
const bool client_ready=g_client_ready.load(std::memory_order_acquire);
|
||||
if(client_ready && !g_runtime_ready) {
|
||||
startup_intro::loading_stage=startup_intro::stage::input;
|
||||
input::install(g_game_window);
|
||||
window_branding::install(g_game_window,g_module);
|
||||
media_art::device=g_device;
|
||||
g_runtime_ready=true;
|
||||
}
|
||||
if(g_runtime_ready)window_branding::tick();
|
||||
if(client_ready) {
|
||||
const auto scene=world::latest();
|
||||
if(!world::fresh(*scene)) input::in_world=false;
|
||||
CURSORINFO cursor{sizeof(cursor)};
|
||||
if(!g_menu_open && world::fresh(*scene) && GetCursorInfo(&cursor) && !(cursor.flags&CURSOR_SHOWING) && world_filter::enabled) {
|
||||
static bool filter_warning=false;
|
||||
const bool applied=world_filter::apply(g_device,g_ctx,rtv);
|
||||
if(!applied && !filter_warning) notifications::push("World visuals unavailable","This render target does not support the world effects pass. Fog color remains available.",notifications::kind::warning,5,"world_filter");
|
||||
filter_warning=!applied;
|
||||
}
|
||||
}
|
||||
ImGui_ImplDX11_NewFrame();
|
||||
ImGui_ImplWin32_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
if (!profiles().ready()) profiles().initialize(modules());
|
||||
|
||||
gui().update(); // menu key, esc, animations
|
||||
if (!g_menu_open) modules().update_keys(); // toggle keys are ignored while the menu is open
|
||||
gui().draw_backdrop();
|
||||
modules().render();
|
||||
gui().draw();
|
||||
profiles().tick(notifications::now());
|
||||
notifications::draw();
|
||||
const bool loading=!startup_intro::animation.finished;
|
||||
if(loading && is_key_down(VK_RSHIFT))g_startup_menu_requested=true;
|
||||
if(client_ready) {
|
||||
if (!profiles().ready()) {
|
||||
startup_intro::loading_stage=startup_intro::stage::profile;
|
||||
profiles().initialize(modules());
|
||||
startup_intro::loading_stage=startup_intro::stage::hud;
|
||||
}
|
||||
if(!loading) {
|
||||
gui().update(); // menu key, esc, animations
|
||||
if(g_startup_menu_requested) {
|
||||
gui().open();
|
||||
g_startup_menu_requested=false;
|
||||
}
|
||||
if (!g_menu_open) modules().update_keys();
|
||||
gui().draw_backdrop();
|
||||
}
|
||||
// Warm HUD and GPU resources behind the opaque intro before reveal.
|
||||
#ifdef _DEBUG
|
||||
const auto debug_modules_begin=debug_metrics::seconds();
|
||||
#endif
|
||||
modules().render();
|
||||
#ifdef _DEBUG
|
||||
debug_metrics::state.module_ms=(debug_metrics::seconds()-debug_modules_begin)*1000;
|
||||
#endif
|
||||
if(loading)startup_intro::loading_stage=startup_intro::stage::ready;
|
||||
if(!loading)gui().draw();
|
||||
profiles().tick(notifications::now());
|
||||
if(!loading)notifications::draw();
|
||||
}
|
||||
if(loading) {
|
||||
startup_intro::draw(client_ready && g_runtime_ready && profiles().ready(),g_startup_menu_requested);
|
||||
drew_loading_screen=!startup_intro::animation.finished;
|
||||
if(startup_intro::animation.finished) {
|
||||
// Startup notices should receive their full lifetime once visible.
|
||||
std::lock_guard lock(notifications::mutex);
|
||||
const auto time=notifications::now();
|
||||
for(auto& item:notifications::items)if(!item.dismissed)item.born=time;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
if(client_ready && !loading)debug_metrics::state.draw(g_device);
|
||||
#endif
|
||||
ImGui::Render();
|
||||
g_ctx->OMSetRenderTargets(1, &rtv, nullptr);
|
||||
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
|
||||
rtv->Release();
|
||||
}
|
||||
|
||||
const HRESULT result = o_present(sc, sync, flags);
|
||||
if (g_init && !g_unloading) modules().frame_end();
|
||||
#ifdef _DEBUG
|
||||
const auto debug_present_begin=debug_metrics::seconds();
|
||||
debug_metrics::state.client_ms=(debug_present_begin-debug_frame_begin)*1000;
|
||||
#endif
|
||||
const HRESULT result = o_present(sc, performance::present_sync(sync,flags), flags);
|
||||
#ifdef _DEBUG
|
||||
debug_metrics::state.present_ms=(debug_metrics::seconds()-debug_present_begin)*1000;
|
||||
#endif
|
||||
++g_weather_frame;
|
||||
// Put an opaque loading frame on screen before expensive setup begins.
|
||||
// Loading and animation then run together, with the reveal gated on readiness.
|
||||
if(!g_unloading && drew_loading_screen && SUCCEEDED(result) && !g_load_requested) {
|
||||
g_load_requested=true;
|
||||
SetEvent(g_start_client);
|
||||
}
|
||||
if (g_runtime_ready && startup_intro::animation.finished && !g_unloading) modules().frame_end();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -142,57 +254,107 @@ static void* get_present_address() {
|
||||
}
|
||||
|
||||
DWORD WINAPI main_thread(LPVOID) {
|
||||
game::initialize_debug_log(g_module);
|
||||
game::log("startup: installing present");
|
||||
MH_Initialize();
|
||||
world::initialize();
|
||||
|
||||
modules().add<fps_counter>()->set_enabled(true);
|
||||
modules().add<keystrokes>()->set_enabled(true);
|
||||
modules().add<watermark>()->set_enabled(true);
|
||||
modules().add<crosshair>(); // off until you turn it on in the menu
|
||||
modules().add<optimizations>();
|
||||
modules().add<macro>();
|
||||
modules().add<fullbright>(); // scans for its signature here; can take a couple of seconds
|
||||
modules().add<fov_changer>();
|
||||
modules().add<zoom>();
|
||||
modules().add<glint_changer>();
|
||||
modules().add<music_player>();
|
||||
modules().add<inventory_tools_module>();
|
||||
modules().add<anti_afk>();
|
||||
modules().add<tab_list>();
|
||||
modules().add<xp_progress_hud>();
|
||||
modules().add<viewmodel>();
|
||||
modules().add<toggle_sprint>();
|
||||
modules().add<cps_counter>();
|
||||
modules().add<clock_hud>();
|
||||
modules().add<block_outlines>();
|
||||
modules().add<atmosphere>();
|
||||
modules().add<armor_hud>();
|
||||
modules().add<name_changer>();
|
||||
modules().add<better_nametags>();
|
||||
modules().add<target_hud>();
|
||||
modules().add<client_time>();
|
||||
modules().add<freelook>();
|
||||
modules().add<coordinates_hud>();
|
||||
|
||||
g_start_client=CreateEventW(nullptr,TRUE,FALSE,nullptr);
|
||||
if(!g_start_client)return 1;
|
||||
void* present = get_present_address();
|
||||
if (!present) { MessageBoxA(nullptr, "couldn't find Present!", "amnesia", MB_OK); return 1; }
|
||||
if (!present) { MessageBoxA(nullptr, "couldn't find present!", "amnesia", MB_OK); return 1; }
|
||||
if(MH_CreateHook(present,&hk_present,reinterpret_cast<void**>(&o_present))!=MH_OK ||
|
||||
MH_EnableHook(present)!=MH_OK)return 1;
|
||||
|
||||
MH_CreateHook(present, &hk_present, (void**)&o_present);
|
||||
MH_EnableHook(present);
|
||||
// This worker sleeps without occupying the render thread. Unloading wakes
|
||||
// it as well, allowing injection to be cancelled before modules exist.
|
||||
// The first presented loading frame releases it, rather than the intro's end.
|
||||
if(!g_unloading)WaitForSingleObject(g_start_client.load(),INFINITE);
|
||||
if(g_unloading)return 0;
|
||||
game::log("startup: loading world hooks");
|
||||
world::initialize();
|
||||
game::log("startup: loading modules");
|
||||
|
||||
waypoints_module* waypoint_module=nullptr;
|
||||
const std::function<void()> module_steps[]={
|
||||
[&] { modules().add<fps_counter>()->set_enabled(true); },
|
||||
[&] { modules().add<keystrokes>()->set_enabled(true); },
|
||||
[&] { modules().add<watermark>()->set_enabled(true); },
|
||||
[&] { modules().add<crosshair>(); },
|
||||
[&] { modules().add<optimizations>(); },
|
||||
[&] { modules().add<macro>(); },
|
||||
[&] { modules().add<fullbright>(); },
|
||||
[&] { modules().add<fov_changer>(); },
|
||||
[&] { modules().add<zoom>(); },
|
||||
[&] { modules().add<glint_changer>(); },
|
||||
[&] { modules().add<music_player>(); },
|
||||
[&] { modules().add<inventory_tools_module>(); },
|
||||
[&] { modules().add<anti_afk>(); },
|
||||
[&] { modules().add<tab_list>(); },
|
||||
[&] { modules().add<xp_progress_hud>(); },
|
||||
[&] { modules().add<viewmodel>(); },
|
||||
[&] { modules().add<toggle_sprint>(); },
|
||||
[&] { modules().add<cps_counter>(); },
|
||||
[&] { modules().add<clock_hud>(); },
|
||||
[&] { modules().add<block_outlines>(); },
|
||||
[&] { modules().add<atmosphere>(); },
|
||||
[&] { modules().add<armor_hud>(); },
|
||||
[&] { modules().add<name_changer>(); },
|
||||
[&] { modules().add<better_nametags>(); },
|
||||
[&] { modules().add<target_hud>(); },
|
||||
[&] { modules().add<client_time>(); },
|
||||
[&] { modules().add<freelook>(); },
|
||||
[&] { modules().add<coordinates_hud>(); },
|
||||
[&] { waypoint_module=modules().add<waypoints_module>(); },
|
||||
[&] { modules().add<compass_hud>(*waypoint_module); },
|
||||
[&] { modules().add<session_stats>(); },
|
||||
[&] { modules().add<durability_alerts>(); },
|
||||
[&] { modules().add<tool_info>(); },
|
||||
[&] { modules().add<status_effects_hud>(); },
|
||||
[&] { modules().add<particle_controls>(); },
|
||||
[&] { modules().add<sound_indicators>(); },
|
||||
};
|
||||
startup_intro::modules_total=unsigned(sizeof(module_steps)/sizeof(module_steps[0]));
|
||||
startup_intro::loading_stage=startup_intro::stage::modules;
|
||||
for(const auto& load:module_steps) {
|
||||
if(g_unloading)return 0;
|
||||
load();
|
||||
++startup_intro::modules_done;
|
||||
}
|
||||
|
||||
if(!g_unloading){
|
||||
world::after_world=&render_world_weather;world_weather::before_target_change=&render_world_weather_gpu;
|
||||
#ifdef _DEBUG
|
||||
debug_metrics::state.startup_ms=(debug_metrics::seconds()-debug_metrics::state.started)*1000;
|
||||
#endif
|
||||
game::log("startup: modules ready");g_client_ready.store(true,std::memory_order_release);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) DWORD WINAPI unload(LPVOID) {
|
||||
g_unloading = true; // hk_present stops drawing and just forwards
|
||||
if(g_start_client)SetEvent(g_start_client);
|
||||
// Never remove hooks or free module state while the loader is installing
|
||||
// them. It can also be waiting for an intro that has not finished yet.
|
||||
if(g_loader_thread) {
|
||||
WaitForSingleObject(g_loader_thread,INFINITE);
|
||||
CloseHandle(g_loader_thread);g_loader_thread=nullptr;
|
||||
}
|
||||
MH_DisableHook(MH_ALL_HOOKS); // Present + cursor hooks
|
||||
window_branding::shutdown(); // restore while our window message handler is still installed
|
||||
input::uninstall(); // restores the game's window proc (and the cursor if the menu was open)
|
||||
Sleep(300); // let any in-flight Present / window messages finish
|
||||
if(auto event=g_start_client.exchange(nullptr))CloseHandle(event);
|
||||
|
||||
profiles().shutdown(); // save enabled states before clear() disables them
|
||||
modules().clear();
|
||||
media::shutdown();
|
||||
media_art::device=nullptr;
|
||||
world::after_world=nullptr;world_weather::before_target_change=nullptr;world_weather::shutdown();
|
||||
world_filter::shutdown();
|
||||
#ifdef _DEBUG
|
||||
debug_metrics::state.adapter.Reset();
|
||||
#endif
|
||||
startup_intro::texture.Reset();
|
||||
|
||||
if (g_init) {
|
||||
ImGui_ImplDX11_Shutdown();
|
||||
@@ -211,7 +373,7 @@ BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, LPVOID) {
|
||||
if (reason == DLL_PROCESS_ATTACH) {
|
||||
g_module = hmod;
|
||||
DisableThreadLibraryCalls(hmod);
|
||||
CreateThread(nullptr, 0, main_thread, nullptr, 0, nullptr);
|
||||
g_loader_thread=CreateThread(nullptr, 0, main_thread, nullptr, 0, nullptr);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@@ -17,48 +17,114 @@ public:
|
||||
if(!inventory_tools::ready){set_enabled(false);notifications::push("Inventory tools unavailable","The container hooks could not be verified.",notifications::kind::warning);return;}
|
||||
inventory_tools::enabled=true;input::inventory_handler=&handle_input;
|
||||
}
|
||||
void on_disable() override {inventory_tools::enabled=false;input::inventory_handler=nullptr;left_owned_=false;middle_owned_=false;inventory_tools::reset();}
|
||||
void on_disable() override {inventory_tools::enabled=false;input::inventory_handler=nullptr;left_owned_=false;middle_owned_=false;right_owned_=false;{std::lock_guard lock(button_mutex_);picker_={};}inventory_tools::reset();}
|
||||
void on_render() override {
|
||||
inventory_tools::delay=delay_->int_value;inventory_tools::include_hotbar=hotbar_->bool_value;
|
||||
button_enabled_=buttons_->bool_value;middle_enabled_=middle_->bool_value;
|
||||
const auto state=inventory_tools::latest();if(!inventory_tools::fresh(state) || !inventory_tools::playing_ui())return;
|
||||
if(!buttons_->bool_value)return;
|
||||
const auto state=inventory_tools::latest();
|
||||
if(!inventory_tools::fresh(state) || !inventory_tools::playing_ui() || !buttons_->bool_value) {
|
||||
std::lock_guard lock(button_mutex_);picker_={};return;
|
||||
}
|
||||
const auto size=ImGui::GetIO().DisplaySize;
|
||||
const ImVec2 pos{std::clamp(size.x*x_->float_value-156.f,0.f,(std::max)(0.f,size.x-312.f)),std::clamp(size.y*y_->float_value,0.f,(std::max)(0.f,size.y-32.f))};
|
||||
const ImVec2 pos{std::clamp(size.x*x_->float_value-156.f,0.f,(std::max)(0.f,size.x-312.f)),std::clamp(size.y*y_->float_value,0.f,(std::max)(0.f,size.y-28.f))};
|
||||
{std::lock_guard lock(button_mutex_);button_pos_=pos;button_stamp_=GetTickCount64();}
|
||||
auto* draw=ImGui::GetForegroundDrawList();
|
||||
const bool chest=inventory_tools::find(state,"container_items")!=nullptr;
|
||||
const char* labels[]={"steal","dump",state.busy ? "stop" : "sort"};
|
||||
for(int i=0;i<3;++i) {
|
||||
const ImVec2 at{pos.x+i*104.f,pos.y};
|
||||
hud_card::background(draw,at,{100,30},1,true);
|
||||
hud_card::background(draw,at,{100,26},1,true);
|
||||
const auto color=theme::u32(i<2 && !chest || state.cursor ? theme::muted() : theme::fg());
|
||||
const auto text=fonts::text_size(fonts::semibold,fonts::k_body_size,labels[i]);
|
||||
hud_card::text(draw,fonts::semibold,1,{at.x+(100-text.x)/2,at.y+7},color,labels[i],true);
|
||||
hud_card::text(draw,fonts::semibold,1,{at.x+(100-text.x)/2,at.y+(26-text.y)/2},color,labels[i],true);
|
||||
}
|
||||
draw_picker(state,pos);
|
||||
}
|
||||
private:
|
||||
setting *buttons_,*middle_,*hotbar_,*delay_,*x_,*y_;
|
||||
static inline inventory_tools_module* instance_=nullptr;
|
||||
inline static std::mutex button_mutex_;inline static ImVec2 button_pos_;inline static uint64_t button_stamp_=0;
|
||||
inline static std::atomic<bool> left_owned_{false},middle_owned_{false};
|
||||
inline static std::atomic<bool> left_owned_{false},middle_owned_{false},right_owned_{false};
|
||||
struct picker_state {
|
||||
uintptr_t controller=0;inventory_tools::action operation=inventory_tools::action::steal;
|
||||
int scroll=0,visible=0;ImVec2 pos{},size{};uint64_t stamp=0;std::vector<world::item> items;
|
||||
};
|
||||
inline static picker_state picker_;
|
||||
void draw_picker(inventory_tools::snapshot const& state,ImVec2 buttons) {
|
||||
std::lock_guard lock(button_mutex_);
|
||||
if(!picker_.controller)return;
|
||||
if(picker_.controller!=state.controller || state.cursor || !inventory_tools::find(state,"container_items")){picker_={};return;}
|
||||
picker_.items=inventory_tools::choices(state,picker_.operation,hotbar_->bool_value);
|
||||
const auto screen=ImGui::GetIO().DisplaySize;
|
||||
picker_.visible=(std::min)(int(picker_.items.size()),(std::min)(10,(std::max)(1,int((screen.y-64)/22))));
|
||||
picker_.scroll=std::clamp(picker_.scroll,0,(std::max)(0,int(picker_.items.size())-picker_.visible));
|
||||
picker_.size={264.f,48.f+22.f*(std::max)(1,picker_.visible)};
|
||||
const float x=buttons.x+(picker_.operation==inventory_tools::action::dump ? 104.f : 0.f);
|
||||
const float y=buttons.y+32+picker_.size.y<=screen.y ? buttons.y+32 : buttons.y-picker_.size.y-6;
|
||||
picker_.pos={std::clamp(x,0.f,(std::max)(0.f,screen.x-picker_.size.x)),std::clamp(y,0.f,(std::max)(0.f,screen.y-picker_.size.y))};
|
||||
picker_.stamp=GetTickCount64();const auto p=picker_.pos;auto* draw=ImGui::GetForegroundDrawList();
|
||||
theme::panel(draw,p,{p.x+picker_.size.x,p.y+picker_.size.y});
|
||||
hud_card::text(draw,fonts::semibold,1,{p.x+12,p.y+7},theme::u32(theme::fg()),picker_.operation==inventory_tools::action::steal ? "steal item" : "dump item",true);
|
||||
const auto mouse=ImGui::GetIO().MousePos;
|
||||
if(picker_.items.empty())hud_card::text(draw,fonts::body,1,{p.x+12,p.y+31},theme::u32(theme::muted()),"no items available",true);
|
||||
for(int row=0;row<picker_.visible;++row) {
|
||||
const auto& item=picker_.items[picker_.scroll+row];const float y=p.y+28+row*22;
|
||||
if(mouse.x>=p.x && mouse.x<p.x+picker_.size.x && mouse.y>=y && mouse.y<y+22)
|
||||
theme::control(draw,{p.x+4,y},{p.x+picker_.size.x-4,y+21},false,true);
|
||||
const auto name=world::item_label(item.name),count=std::to_string(item.count);
|
||||
draw->PushClipRect({p.x+12,y},{p.x+picker_.size.x-58,y+22},true);
|
||||
hud_card::text(draw,fonts::body,1,{p.x+12,y+5},theme::u32(theme::fg()),name.c_str(),true);draw->PopClipRect();
|
||||
const auto width=fonts::text_size(fonts::body,fonts::k_body_size,count.c_str()).x;
|
||||
hud_card::text(draw,fonts::body,1,{p.x+picker_.size.x-12-width,y+5},theme::u32(theme::muted()),count.c_str(),true);
|
||||
}
|
||||
const char* hint=int(picker_.items.size())>picker_.visible ? "all matching stacks / wheel to scroll" : "transfers all matching stacks";
|
||||
hud_card::text(draw,fonts::body,.8f,{p.x+12,p.y+picker_.size.y-16},theme::u32(theme::muted()),hint,true);
|
||||
}
|
||||
inline static std::atomic<bool> button_enabled_{true},middle_enabled_{true};
|
||||
static bool handle_input(HWND,UINT message,WPARAM,LPARAM param) {
|
||||
static bool handle_input(HWND,UINT message,WPARAM wp,LPARAM param) {
|
||||
if(message==WM_LBUTTONUP && left_owned_){left_owned_=false;return true;}
|
||||
if(message==WM_RBUTTONUP && right_owned_){right_owned_=false;return true;}
|
||||
if(message==WM_MBUTTONUP && middle_owned_){middle_owned_=false;return true;}
|
||||
if(!instance_ || !inventory_tools::playing_ui())return false;
|
||||
const auto state=inventory_tools::latest();if(!inventory_tools::fresh(state))return false;
|
||||
if((message==WM_MBUTTONDOWN || message==WM_MBUTTONDBLCLK) && middle_enabled_ && inventory_tools::find(state,state.hover) && state.hover!="hotbar_items") {
|
||||
inventory_tools::queue(inventory_tools::action::sort);middle_owned_=true;return true;
|
||||
}
|
||||
if(message!=WM_LBUTTONDOWN && message!=WM_LBUTTONDBLCLK)return false;
|
||||
if(!button_enabled_){if(state.busy)inventory_tools::queue(inventory_tools::action::stop);return false;}
|
||||
ImVec2 pos;uint64_t stamp;{std::lock_guard lock(button_mutex_);pos=button_pos_;stamp=button_stamp_;}
|
||||
const int x=short(LOWORD(param)),y=short(HIWORD(param));
|
||||
if(GetTickCount64()-stamp>150 || x<pos.x || x>=pos.x+312 || y<pos.y || y>=pos.y+30) {
|
||||
if(state.busy)inventory_tools::queue(inventory_tools::action::stop);return false;
|
||||
const bool left=message==WM_LBUTTONDOWN || message==WM_LBUTTONDBLCLK;
|
||||
const bool right=message==WM_RBUTTONDOWN || message==WM_RBUTTONDBLCLK;
|
||||
std::lock_guard lock(button_mutex_);
|
||||
if(picker_.controller && (picker_.controller!=state.controller || !button_enabled_))picker_={};
|
||||
if(picker_.controller && (message==WM_KEYDOWN || message==WM_SYSKEYDOWN) && wp==VK_ESCAPE){picker_={};return true;}
|
||||
if(picker_.controller && message==WM_MOUSEWHEEL) {
|
||||
const int steps=short(HIWORD(wp))/WHEEL_DELTA;
|
||||
picker_.scroll=std::clamp(picker_.scroll-steps,0,(std::max)(0,int(picker_.items.size())-picker_.visible));return true;
|
||||
}
|
||||
const int button=int((x-pos.x)/104);left_owned_=true;
|
||||
if(!left && !right)return false;
|
||||
if(!button_enabled_){if(state.busy)inventory_tools::queue(inventory_tools::action::stop);return false;}
|
||||
const int x=short(LOWORD(param)),y=short(HIWORD(param));const auto pos=button_pos_;
|
||||
const bool button_hit=GetTickCount64()-button_stamp_<=150 && x>=pos.x && x<pos.x+308 && y>=pos.y && y<pos.y+26 && int(x-pos.x)%104<100;
|
||||
if(picker_.controller) {
|
||||
const auto p=picker_.pos;
|
||||
if(left && GetTickCount64()-picker_.stamp<=150 && x>=p.x && x<p.x+picker_.size.x && y>=p.y+28 && y<p.y+28+picker_.visible*22) {
|
||||
const int selected=picker_.scroll+int((y-p.y-28)/22);
|
||||
if(!state.cursor)inventory_tools::queue(picker_.operation,"",picker_.items[selected].name,picker_.controller);
|
||||
picker_={};left_owned_=true;return true;
|
||||
}
|
||||
picker_={};
|
||||
if(!right || !button_hit){if(left)left_owned_=true;else right_owned_=true;return true;}
|
||||
}
|
||||
if(!button_hit){if(left && state.busy)inventory_tools::queue(inventory_tools::action::stop);return false;}
|
||||
const int button=int((x-pos.x)/104);
|
||||
if(right) {
|
||||
if(button==2)return false;
|
||||
right_owned_=true;
|
||||
if(!state.cursor && inventory_tools::find(state,"container_items")) {
|
||||
if(state.busy)inventory_tools::queue(inventory_tools::action::stop);
|
||||
picker_.controller=state.controller;picker_.operation=button==0 ? inventory_tools::action::steal : inventory_tools::action::dump;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
left_owned_=true;
|
||||
if(!state.cursor) {
|
||||
if(button==2)inventory_tools::queue(state.busy ? inventory_tools::action::stop : inventory_tools::action::sort,
|
||||
inventory_tools::find(state,"container_items") ? "container_items" : "inventory_items");
|
||||
|
||||
@@ -54,20 +54,17 @@ private:
|
||||
press_t_[i] = theme::approach(press_t_[i], is_key_down(vk) ? 1.f : 0.f, dt * 20.f);
|
||||
const float t = press_t_[i];
|
||||
|
||||
const ImVec4 pressed(pressed_->color[0], pressed_->color[1], pressed_->color[2], pressed_->color[3]);
|
||||
const ImVec4 fill = theme::mix(theme::with_alpha(theme::raised(), 0.85f), pressed, t);
|
||||
const ImVec4 border = theme::mix(theme::line(), theme::accent(), t);
|
||||
const ImVec4 text = theme::mix(ImVec4(color_->color[0], color_->color[1], color_->color[2], color_->color[3]), theme::bg(), t);
|
||||
const float r = 6.f * scale_->float_value;
|
||||
const auto pressed=ImGui::ColorConvertU32ToFloat4(theme::display_color(setting_color(*pressed_)));
|
||||
const auto text=ImGui::ColorConvertU32ToFloat4(theme::display_color(setting_color(*color_)));
|
||||
|
||||
const ImVec2 a(x, y), b(x + w, y + h);
|
||||
dl->AddRectFilled(a, b, theme::u32(fill), r);
|
||||
dl->AddRect(a, b, theme::u32(border), r, 0, 1.f);
|
||||
theme::gradient(dl,a,b,theme::mix(theme::raised(),pressed,t),theme::mix(theme::hex(0x303030),theme::shade(pressed,.5f),t));
|
||||
dl->AddRect(a,b,theme::u32(theme::line()));
|
||||
|
||||
const float scale = size_->float_value / 40.f * scale_->float_value;
|
||||
const ImVec2 ts = fonts::text_size(fonts::semibold, fonts::k_body_size, label);
|
||||
const ImVec2 ts = fonts::text_size(fonts::semibold, fonts::k_body_size * scale, label);
|
||||
dl->AddText(fonts::semibold, fonts::k_body_size * scale,
|
||||
ImVec2(floorf(x + (w - ts.x * scale) * 0.5f), floorf(y + (h - ts.y * scale) * 0.5f)),
|
||||
ImVec2(floorf(x + (w - ts.x) * 0.5f), floorf(y + (h - ts.y) * 0.5f)),
|
||||
theme::u32(text), label);
|
||||
}
|
||||
};
|
||||
@@ -138,6 +138,7 @@ public:
|
||||
bool expanded = false;
|
||||
bool binding = false;
|
||||
float hover_t = 0.f, enable_t = 0.f, expand_t = 0.f;
|
||||
float settings_height = 0.f;
|
||||
} ui;
|
||||
|
||||
private:
|
||||
|
||||
+34
-18
@@ -32,7 +32,7 @@ public:
|
||||
catch(...) {set_enabled(false);}
|
||||
}
|
||||
void on_disable() override {media::system().stop();image_.Reset();uploaded_.reset();}
|
||||
ImVec2 hud_size() const override {return {width_->float_value*scale_->float_value,(controls_->bool_value ? 116.f : 80.f)*scale_->float_value};}
|
||||
ImVec2 hud_size() const override {return {width_->float_value*scale_->float_value,(76.f+(progress_->bool_value ? 12.f : 0.f)+(controls_->bool_value ? 30.f : 0.f))*scale_->float_value};}
|
||||
ImVec2 hud_drag_size() const override {return {hud_size().x,76*scale_->float_value};}
|
||||
void on_render() override {
|
||||
media::system().prefer(player_->text_value);const auto state=media::system().latest();
|
||||
@@ -44,41 +44,57 @@ public:
|
||||
const auto p=[&](float x,float y){return ImVec2(hud_pos.x+x*s,hud_pos.y+y*s);};
|
||||
auto* draw=ImGui::GetBackgroundDrawList();hud_card::background(draw,hud_pos,hud_size(),s,background_->bool_value);
|
||||
const auto color=setting_color(*color_);const auto muted=theme::u32(theme::muted());
|
||||
const float left=art_->bool_value ? 76.f : 12.f;
|
||||
const float left=art_->bool_value ? 80.f : 12.f;
|
||||
ImFont* face=fonts::media ? fonts::media : fonts::body;
|
||||
auto text=[&](float size,ImVec2 at,ImU32 ink,const char* value) {
|
||||
draw->AddText(face,size*s,{std::floor(at.x),std::floor(at.y)},theme::display_color(ink),value);
|
||||
};
|
||||
if(art_->bool_value) {
|
||||
upload(state.available ? state.art : nullptr);
|
||||
draw->AddRectFilled(p(12,8),p(64,60),theme::u32(theme::line()),6*s);
|
||||
if(image_)draw->AddImageRounded((ImTextureID)(uintptr_t)image_.Get(),p(12,8),p(64,60),{0,0},{1,1},IM_COL32_WHITE,6*s);
|
||||
else {draw->AddCircle(p(38,34),15*s,muted,24,2*s);draw->AddCircleFilled(p(38,34),3*s,color);}
|
||||
draw->AddRectFilled(p(12,10),p(68,66),theme::u32(theme::line()));
|
||||
if(image_) {
|
||||
// Spotify's Windows thumbnail frames a 234px square cover in a
|
||||
// 300px image, with side padding and its branding underneath.
|
||||
// Crop only the displayed UVs; other players keep their full art.
|
||||
const bool spotify=_stricmp(state.app.c_str(),"Spotify.exe")==0;
|
||||
const ImVec2 uv_min=spotify ? ImVec2(33.f/300.f,0) : ImVec2(0,0);
|
||||
const ImVec2 uv_max=spotify ? ImVec2(267.f/300.f,234.f/300.f) : ImVec2(1,1);
|
||||
draw->AddImage((ImTextureID)(uintptr_t)image_.Get(),p(12,10),p(68,66),uv_min,uv_max,IM_COL32_WHITE);
|
||||
}
|
||||
else {draw->AddCircle(p(40,38),15*s,muted,24,2*s);draw->AddCircleFilled(p(40,38),3*s,color);}
|
||||
} else {image_.Reset();uploaded_.reset();}
|
||||
draw->PushClipRect(p(left,0),p(w-12,64),true);
|
||||
hud_card::text(draw,fonts::semibold,s,p(left,8),color,state.available ? state.title.c_str() : "music",background_->bool_value);
|
||||
draw->PushClipRect(p(left,10),p(w-12,66),true);
|
||||
text(13,p(left,15),color,state.available ? state.title.c_str() : "music");
|
||||
const auto detail=state.available ? (state.artist.empty() ? state.app : state.artist) : state.message;
|
||||
hud_card::text(draw,fonts::body,s*.85f,p(left,29),muted,detail.c_str(),background_->bool_value);
|
||||
hud_card::text(draw,fonts::body,s*.7f,p(left,47),muted,state.available ? (state.playing ? "playing" : "paused") : "Open a player that supports Windows media controls",background_->bool_value);
|
||||
text(11,p(left,33),muted,detail.c_str());
|
||||
text(11,p(left,49),muted,state.available ? (state.playing ? "playing" : "paused") : "Open a player that supports Windows media controls");
|
||||
draw->PopClipRect();
|
||||
if(progress_->bool_value && state.available && state.duration>0) {
|
||||
const double elapsed=state.playing && state.stamp ? double(GetTickCount64()-state.stamp)/1000*state.rate : 0;
|
||||
const float fraction=float(std::clamp((state.position+elapsed)/state.duration,0.,1.));
|
||||
draw->AddRectFilled(p(12,68),p(w-12,71),theme::u32(theme::line()),2*s);
|
||||
if(fraction>0)draw->AddRectFilled(p(12,68),p(12+(w-24)*fraction,71),color,2*s);
|
||||
theme::bar(draw,p(12,74),p(w-12,78),fraction,ImGui::ColorConvertU32ToFloat4(theme::display_color(color)));
|
||||
}
|
||||
if(controls_->bool_value) {
|
||||
// Buttons become interactive only while the client menu releases the cursor.
|
||||
ImGui::SetNextWindowPos(p(12,81));ImGui::SetNextWindowSize({(w-24)*s,29*s});
|
||||
const float controls_y=progress_->bool_value ? 86.f : 74.f;
|
||||
ImGui::SetNextWindowPos(p(12,controls_y));ImGui::SetNextWindowSize({(w-24)*s,22*s});
|
||||
fonts::push_font(face,fonts::k_body_size*s);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding,{0,0});
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing,{4*s,0});
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding,{0,0});ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize,0);
|
||||
auto flags=ImGuiWindowFlags_NoDecoration|ImGuiWindowFlags_NoBackground|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoNav;
|
||||
auto flags=ImGuiWindowFlags_NoDecoration|ImGuiWindowFlags_NoBackground|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoNav|ImGuiWindowFlags_NoScrollbar|ImGuiWindowFlags_NoScrollWithMouse;
|
||||
if(!g_menu_open)flags|=ImGuiWindowFlags_NoInputs;
|
||||
if(ImGui::Begin("##music_controls",nullptr,flags)) {
|
||||
const std::string controls_id="##music_controls_"+std::to_string(reinterpret_cast<uintptr_t>(this));
|
||||
if(ImGui::Begin(controls_id.c_str(),nullptr,flags)) {
|
||||
const float button=(w-32)/3*s;
|
||||
ImGui::BeginDisabled(!g_menu_open || !state.available || !state.previous);
|
||||
if(ImGui::Button("previous",{button,26*s}))media::system().send(media::command::previous);ImGui::EndDisabled();ImGui::SameLine(0,4*s);
|
||||
if(ImGui::Button("previous",{button,22*s}))media::system().send(media::command::previous);ImGui::EndDisabled();ImGui::SameLine(0,4*s);
|
||||
ImGui::BeginDisabled(!g_menu_open || !state.available || !state.pause);
|
||||
if(ImGui::Button(state.playing ? "pause" : "play",{button,26*s}))media::system().send(media::command::pause);ImGui::EndDisabled();ImGui::SameLine(0,4*s);
|
||||
if(ImGui::Button(state.playing ? "pause" : "play",{button,22*s}))media::system().send(media::command::pause);ImGui::EndDisabled();ImGui::SameLine(0,4*s);
|
||||
ImGui::BeginDisabled(!g_menu_open || !state.available || !state.next);
|
||||
if(ImGui::Button("next",{button,26*s}))media::system().send(media::command::next);ImGui::EndDisabled();
|
||||
if(ImGui::Button("next",{button,22*s}))media::system().send(media::command::next);ImGui::EndDisabled();
|
||||
}
|
||||
ImGui::End();ImGui::PopStyleVar(2);
|
||||
ImGui::End();ImGui::PopStyleVar(4);ImGui::PopFont();
|
||||
}
|
||||
}
|
||||
private:
|
||||
|
||||
@@ -2,24 +2,39 @@
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
#include "module.h"
|
||||
#include "../game/qol_events.h"
|
||||
#include "../gui/notifications.h"
|
||||
|
||||
#pragma comment(lib, "winmm.lib")
|
||||
|
||||
class optimizations : public module {
|
||||
public:
|
||||
optimizations()
|
||||
: module("Optimizations", "Frame limiter and Windows tweaks for smoother, cooler gameplay.",
|
||||
: module("Optimizations", "Adaptive native particles, lighter HUD reads, presentation and frame pacing.",
|
||||
category::utility) {
|
||||
fps_limit_ = &add_int("FPS Limit (0 = off)", 0, 0, 360);
|
||||
bg_limit_ = &add_int("Background FPS (0 = off)", 15, 0, 60);
|
||||
priority_ = &add_toggle("High Priority", true);
|
||||
timer_ = &add_toggle("Precise Timer", true);
|
||||
throttle_ = &add_toggle("No Power Throttling", true);
|
||||
particles_=&add_toggle("reduce native particles",true);
|
||||
density_=&add_int("maximum particles kept (%)",50,0,100);
|
||||
adaptive_=&add_toggle("adaptive particle density",true);
|
||||
target_=&add_int("adaptive target fps",120,30,360);
|
||||
burst_=&add_int("particle budget per 100ms (0 = off)",200,0,2000);
|
||||
combat_=&add_toggle("preserve combat particles",true);
|
||||
reads_=&add_int("hud data refresh hz (0 = every frame)",30,0,120);
|
||||
vsync_=&add_toggle("disable present vsync",false);
|
||||
}
|
||||
|
||||
void on_enable() override { next_frame_ = 0.0; }
|
||||
void on_enable() override {
|
||||
next_frame_=last_sample_=0;density_control_.reset(density_->int_value);particle_warning_=false;
|
||||
update_game_controls();
|
||||
}
|
||||
void on_render() override {update_game_controls();}
|
||||
|
||||
void on_disable() override {
|
||||
performance::reset();
|
||||
if (priority_on_) apply_priority(false);
|
||||
if (timer_on_) apply_timer(false);
|
||||
if (throttle_on_) apply_throttling(false);
|
||||
@@ -29,6 +44,13 @@ public:
|
||||
if (priority_->bool_value != priority_on_) apply_priority(priority_->bool_value);
|
||||
if (timer_->bool_value != timer_on_) apply_timer(timer_->bool_value);
|
||||
if (throttle_->bool_value != throttle_on_) apply_throttling(throttle_->bool_value);
|
||||
const double time=now();
|
||||
if(adaptive_->bool_value && particles_->bool_value && is_game_focused() && !g_menu_open) {
|
||||
int target=target_->int_value;
|
||||
if(fps_limit_->int_value>0)target=(std::min)(target,fps_limit_->int_value);
|
||||
if(last_sample_>0)performance::keep=density_control_.update(time-last_sample_,target,density_->int_value);
|
||||
last_sample_=time;
|
||||
} else {last_sample_=0;density_control_.reset(density_->int_value);}
|
||||
limit_frame();
|
||||
}
|
||||
|
||||
@@ -39,6 +61,22 @@ private:
|
||||
setting* timer_ = nullptr;
|
||||
setting* throttle_ = nullptr;
|
||||
|
||||
setting *particles_,*density_,*adaptive_,*target_,*burst_,*combat_,*reads_,*vsync_;
|
||||
performance::adaptive_density density_control_;
|
||||
double last_sample_=0;
|
||||
bool particle_warning_=false;
|
||||
void update_game_controls() {
|
||||
performance::uncapped_present=vsync_->bool_value;
|
||||
performance::hud_hz=reads_->int_value;
|
||||
if(particles_->bool_value && !qol_events::initialize_particles()) {
|
||||
if(!particle_warning_)notifications::push("particle optimization unavailable","the native particle hook could not be verified; other optimizations remain active",notifications::kind::warning);
|
||||
particle_warning_=true;
|
||||
}
|
||||
performance::keep=adaptive_->bool_value ? (std::min)(density_control_.current,density_->int_value) : density_->int_value;
|
||||
performance::burst_limit=burst_->int_value;performance::protect_combat=combat_->bool_value;
|
||||
performance::particles=particles_->bool_value && qol_events::particle_ready;
|
||||
}
|
||||
|
||||
bool priority_on_ = false, timer_on_ = false, throttle_on_ = false;
|
||||
DWORD original_priority_ = 0;
|
||||
bool priority_saved_ = false;
|
||||
|
||||
@@ -0,0 +1,317 @@
|
||||
#pragma once
|
||||
#include <map>
|
||||
#include "world_modules.h"
|
||||
#include "qol_state.h"
|
||||
#include "../game/qol_events.h"
|
||||
|
||||
class rows_hud : public text_hud {
|
||||
public:
|
||||
rows_hud(const char* name,const char* description):text_hud(name,description){}
|
||||
ImVec2 hud_size() const override {return {width_*scale_->float_value,hud_card::rows_height(rows_)*scale_->float_value};}
|
||||
protected:
|
||||
float width_=230;int rows_=1;
|
||||
void draw_rows(const std::vector<std::pair<std::string,std::string>>& rows) {
|
||||
rows_=int(rows.size());width_=200;
|
||||
for(const auto& r:rows)width_=(std::max)(width_,hud_card::size(r.first.c_str(),r.second.c_str(),scale_->float_value).x/scale_->float_value);
|
||||
const float s=scale_->float_value;auto* dl=ImGui::GetBackgroundDrawList();
|
||||
hud_card::background(dl,hud_pos,hud_size(),s,background_->bool_value);
|
||||
for(int i=0;i<rows_;++i)draw_hud_row({hud_pos.x+12*s,hud_pos.y+(7+20*i)*s},(width_-24)*s,
|
||||
rows[i].first.c_str(),rows[i].second,s,setting_color(*color_),background_->bool_value);
|
||||
}
|
||||
};
|
||||
|
||||
class waypoints_module : public module {
|
||||
public:
|
||||
waypoints_module():module("waypoints","saved locations and your latest death; groups separate worlds/servers",category::visual) {
|
||||
group_=&add_text("world/server group","my world",32);name_=&add_text("new waypoint name","home",32);
|
||||
key_=&add_key("save location key",VK_F8);death_=&add_toggle("death marker",true);
|
||||
distance_=&add_toggle("show distance",true);coordinates_=&add_toggle("show coordinates",false);
|
||||
range_=&add_float("maximum distance",10000,32,30000);scale_=&add_float("marker scale",1,.7f,2);
|
||||
const auto tint=theme::accent();color_=&add_color("marker color",tint.x,tint.y,tint.z);
|
||||
selected_=&add_int("selected waypoint slot",1,1,16);
|
||||
add_action("save current location",[this]{save_location();});
|
||||
add_action("rename selected",[this]{qol::waypoint p;auto* slot=slots_[selected_->int_value-1];if(qol::decode(slot->text_value,p)){p.name=world::clean_name(name_->text_value).substr(0,32);if(!p.name.empty())slot->text_value=qol::encode(p);}});
|
||||
add_action("delete selected",[this]{slots_[selected_->int_value-1]->text_value.clear();});
|
||||
add_action("clear death marker",[this]{death_slot_->text_value.clear();});
|
||||
for(int i=0;i<16;++i){slots_[i]=&add_text("saved waypoint "+std::to_string(i+1),"",240);slots_[i]->hidden=true;}
|
||||
death_slot_=&add_text("saved death marker","",240);death_slot_->hidden=true;
|
||||
}
|
||||
bool consumes_key(int key) const override {return enabled() && key==key_->int_value;}
|
||||
void on_enable() override {require_world(*this);tracking_.reset();}
|
||||
void on_disable() override {tracking_.reset();was_down_=false;}
|
||||
std::vector<qol::waypoint> points(const world::frame& frame) const {
|
||||
std::vector<qol::waypoint> result;qol::waypoint p;
|
||||
for(auto* slot:slots_)if(qol::decode(slot->text_value,p) && p.group==group_->text_value && p.dimension==frame.dimension)result.push_back(p);
|
||||
if(death_->bool_value && qol::decode(death_slot_->text_value,p) && p.group==group_->text_value && p.dimension==frame.dimension)result.push_back(p);
|
||||
return result;
|
||||
}
|
||||
void on_render() override {
|
||||
const auto f=world::latest();const bool down=is_key_down(key_->int_value);
|
||||
if(!g_menu_open && down && !was_down_)save_location();was_down_=down;
|
||||
const auto before=tracking_.position;
|
||||
if(tracking_.update(*f,notifications::now()) && death_->bool_value && f->dimension>=0) {
|
||||
qol::waypoint p{"last death",group_->text_value,before,f->dimension,true};death_slot_->text_value=qol::encode(p);
|
||||
notifications::push("Death marker saved","Your last location is marked.",notifications::kind::info,4,"death_marker");
|
||||
}
|
||||
if(!world::fresh(*f) || g_menu_open || !input::in_world)return;
|
||||
CURSORINFO cursor{sizeof(cursor)};if(GetCursorInfo(&cursor) && (cursor.flags&CURSOR_SHOWING))return;
|
||||
for(const auto& p:points(*f)) {
|
||||
const float meters=world::distance(f->local.feet,p.position);if(meters>range_->float_value)continue;
|
||||
ImVec2 pos;if(!project_world(*f,{p.position.x,p.position.y+1.5f,p.position.z},pos))continue;
|
||||
char value[100];std::string info;
|
||||
if(distance_->bool_value){snprintf(value,sizeof(value),"%.0fm",meters);info=value;}
|
||||
if(coordinates_->bool_value){snprintf(value,sizeof(value),"%.0f %.0f %.0f",p.position.x,p.position.y,p.position.z);if(!info.empty())info+=" | ";info+=value;}
|
||||
const auto size=hud_card::size(p.name.c_str(),info.c_str(),scale_->float_value);
|
||||
hud_card::draw({pos.x-size.x/2,pos.y-size.y},p.name.c_str(),info.c_str(),scale_->float_value,true,
|
||||
p.death ? theme::u32(theme::danger()) : setting_color(*color_));
|
||||
}
|
||||
}
|
||||
private:
|
||||
setting *group_,*name_,*key_,*death_,*distance_,*coordinates_,*range_,*scale_,*color_,*selected_,*death_slot_;
|
||||
std::array<setting*,16> slots_{};qol::session tracking_;bool was_down_=false;
|
||||
void save_location() {
|
||||
const auto f=world::latest();
|
||||
if(!world::fresh(*f) || f->dimension<0){notifications::push("Waypoint unavailable","Enter a world first.",notifications::kind::warning);return;}
|
||||
const auto name=world::clean_name(name_->text_value).substr(0,32);if(name.empty())return;
|
||||
for(int i=0;i<16;++i)if(slots_[i]->text_value.empty()) {
|
||||
slots_[i]->text_value=qol::encode({name,group_->text_value,f->local.feet,f->dimension,false});selected_->int_value=i+1;
|
||||
notifications::push("Waypoint saved",name+" / slot "+std::to_string(i+1),notifications::kind::success);return;
|
||||
}
|
||||
notifications::push("Waypoint slots full","Delete a saved slot to make room.",notifications::kind::warning);
|
||||
}
|
||||
};
|
||||
|
||||
class compass_hud : public text_hud {
|
||||
public:
|
||||
explicit compass_hud(waypoints_module& waypoints):text_hud("compass","camera heading and saved waypoint directions"),waypoints_(waypoints) {
|
||||
hud_pos={340,12};width_=&add_float("width",320,180,600);fov_=&add_float("visible degrees",120,60,240);
|
||||
points_=&add_toggle("waypoint markers",true);degrees_=&add_toggle("heading degrees",true);
|
||||
}
|
||||
void on_enable() override {require_world(*this);}
|
||||
ImVec2 hud_size() const override {return {width_->float_value*scale_->float_value,58*scale_->float_value};}
|
||||
void on_render() override {
|
||||
const auto f=world::latest();if(!g_menu_open && !world::fresh(*f))return;
|
||||
const float heading=world::fresh(*f) ? qol::heading(*f) : 0,s=scale_->float_value,w=width_->float_value;
|
||||
auto* dl=ImGui::GetBackgroundDrawList();hud_card::background(dl,hud_pos,hud_size(),s,background_->bool_value);
|
||||
dl->PushClipRect({hud_pos.x+8*s,hud_pos.y},{hud_pos.x+(w-8)*s,hud_pos.y+58*s},true);
|
||||
auto x_at=[&](float angle){return hud_pos.x+(w*.5f+qol::wrap(angle-heading)/fov_->float_value*(w-24))*s;};
|
||||
const char* directions[]={"S","SW","W","NW","N","NE","E","SE"};
|
||||
for(int i=0;i<24;++i) {
|
||||
const float angle=i*15.f;if(std::abs(qol::wrap(angle-heading))>fov_->float_value*.5f)continue;
|
||||
const float x=x_at(angle);dl->AddLine({x,hud_pos.y+25*s},{x,hud_pos.y+(i%3==0 ? 32 : 29)*s},theme::u32(theme::dim()),s);
|
||||
if(i%3==0) {
|
||||
const auto* text=directions[(i/3+8)%8];const float tw=fonts::text_size(fonts::semibold,fonts::k_body_size*s,text).x;
|
||||
hud_card::text(dl,fonts::semibold,s,{x-tw/2,hud_pos.y+7*s},setting_color(*color_),text,background_->bool_value);
|
||||
}
|
||||
}
|
||||
dl->AddTriangleFilled({hud_pos.x+w*.5f*s,hud_pos.y+35*s},{hud_pos.x+(w*.5f-3)*s,hud_pos.y+40*s},{hud_pos.x+(w*.5f+3)*s,hud_pos.y+40*s},theme::u32(theme::accent()));
|
||||
if(degrees_->bool_value){char value[24];snprintf(value,sizeof(value),"%.0f",std::fmod(heading+360,360.f));hud_card::text(dl,fonts::body,s,{hud_pos.x+12*s,hud_pos.y+38*s},theme::u32(theme::muted()),value,background_->bool_value);}
|
||||
if(points_->bool_value)for(const auto& p:waypoints_.points(*f)) {
|
||||
const float angle=qol::bearing(f->local.feet,p.position);if(std::abs(qol::wrap(angle-heading))>fov_->float_value*.5f)continue;
|
||||
const float x=x_at(angle);dl->AddCircleFilled({x,hud_pos.y+34*s},2.5f*s,p.death ? theme::u32(theme::danger()) : theme::u32(theme::accent()));
|
||||
const std::string label=p.name.substr(0,12);const float tw=fonts::text_size(fonts::body,fonts::k_body_size*s,label.c_str()).x;
|
||||
hud_card::text(dl,fonts::body,s,{x-tw/2,hud_pos.y+39*s},setting_color(*color_),label.c_str(),background_->bool_value);
|
||||
}
|
||||
dl->PopClipRect();
|
||||
}
|
||||
private:waypoints_module& waypoints_;setting *width_,*fov_,*points_,*degrees_;
|
||||
};
|
||||
|
||||
class session_stats : public rows_hud {
|
||||
public:
|
||||
session_stats():rows_hud("session stats","playtime, distance, deaths and XP earned since enabling") {
|
||||
hud_pos={10,510};time_=&add_toggle("playtime",true);distance_=&add_toggle("distance traveled",true);
|
||||
deaths_=&add_toggle("deaths",true);xp_=&add_toggle("XP gained",true);horizontal_=&add_toggle("horizontal distance only",true);
|
||||
add_action("reset session",[this]{state_.reset();});
|
||||
}
|
||||
void on_enable() override {if(require_world(*this)){++world::extra_xp_readers;reading_=true;state_.reset();}}
|
||||
void on_disable() override {if(reading_){--world::extra_xp_readers;reading_=false;}state_.last_time=-1;state_.sampled=false;}
|
||||
void on_render() override {
|
||||
const auto f=world::latest();state_.update(*f,notifications::now(),horizontal_->bool_value);
|
||||
if(!g_menu_open && !world::fresh(*f))return;
|
||||
std::vector<std::pair<std::string,std::string>> rows;
|
||||
if(time_->bool_value)rows.emplace_back("playtime",qol::clock_text(int(state_.seconds)));
|
||||
if(distance_->bool_value){char value[32];snprintf(value,sizeof(value),state_.distance>=1000 ? "%.2f km" : "%.0f m",state_.distance>=1000 ? state_.distance/1000 : state_.distance);rows.emplace_back("distance",value);}
|
||||
if(deaths_->bool_value)rows.emplace_back("deaths",std::to_string(state_.deaths));
|
||||
if(xp_->bool_value)rows.emplace_back("XP gained",f->xp_known || g_menu_open ? std::to_string(int(std::floor(state_.xp+.01))) : "unavailable");
|
||||
if(rows.empty())rows.emplace_back("session","all counters hidden");draw_rows(rows);
|
||||
}
|
||||
private:setting *time_,*distance_,*deaths_,*xp_,*horizontal_;qol::session state_;bool reading_=false;
|
||||
};
|
||||
|
||||
class durability_alerts : public module {
|
||||
public:
|
||||
durability_alerts():module("durability alerts","warns before your held tool or equipped armor breaks",category::utility) {
|
||||
threshold_=&add_float("warn below percent",15,1,50);held_=&add_toggle("held item",true);armor_=&add_toggle("armor",true);
|
||||
cooldown_=&add_float("repeat after seconds (0 = once)",60,0,300);duration_=&add_float("notification duration",5,1,15);
|
||||
}
|
||||
void on_enable() override {if(require_world(*this)){++world::collect_item_details;reading_=true;}}
|
||||
void on_disable() override {if(reading_){--world::collect_item_details;reading_=false;}warned_={};}
|
||||
void on_render() override {
|
||||
const auto f=world::latest();if(!world::fresh(*f))return;
|
||||
check(0,f->local.held,held_->bool_value);
|
||||
for(int i=0;i<4;++i)check(i+1,f->local.armor[i],armor_->bool_value);
|
||||
}
|
||||
private:
|
||||
struct warning {std::string name;double time=-1;int damage=0;};std::array<warning,5> warned_{};
|
||||
setting *threshold_,*held_,*armor_,*cooldown_,*duration_;
|
||||
bool reading_=false;
|
||||
void check(int slot,const world::item& item,bool show) {
|
||||
auto& old=warned_[slot];
|
||||
if(!show || !item.durability_known || item.name.empty() || item.max_damage<=0){old={};return;}
|
||||
const float percent=100.f*(item.max_damage-item.damage)/item.max_damage;
|
||||
if(old.name!=item.name || item.damage<old.damage || percent>threshold_->float_value+5)old={item.name,-1,item.damage};
|
||||
old.damage=item.damage;
|
||||
if(percent>threshold_->float_value)return;
|
||||
const double now=notifications::now();
|
||||
if(old.time>=0 && (cooldown_->float_value<=0 || now-old.time<cooldown_->float_value))return;
|
||||
char text[160];snprintf(text,sizeof(text),"%s: %d uses left (%.0f%%)",world::item_label(item.name).c_str(),item.max_damage-item.damage,percent);
|
||||
notifications::push("Low durability",text,notifications::kind::warning,duration_->float_value,"durability_"+std::to_string(slot));
|
||||
old.name=item.name;old.time=now;
|
||||
}
|
||||
};
|
||||
|
||||
inline std::string enchantment_label(int id) {
|
||||
static const char* names[]={"protection","fire protection","feather falling","blast protection","projectile protection","thorns","respiration","depth strider","aqua affinity",
|
||||
"sharpness","smite","bane of arthropods","knockback","fire aspect","looting","efficiency","silk touch","unbreaking","fortune","power","punch","flame","infinity",
|
||||
"luck of the sea","lure","frost walker","mending","binding curse","vanishing curse","impaling","riptide","loyalty","channeling","multishot","piercing","quick charge",
|
||||
"soul speed","swift sneak","wind burst","density","breach","lunge"};
|
||||
return id>=0 && id<int(std::size(names)) ? names[id] : "enchantment "+std::to_string(id);
|
||||
}
|
||||
class tool_info : public rows_hud {
|
||||
public:
|
||||
tool_info():rows_hud("tool info","held item durability, enchantments and base attack bonus") {
|
||||
hud_pos={600,365};durability_=&add_toggle("durability",true);enchants_=&add_toggle("enchantments",true);
|
||||
attack_=&add_toggle("attack bonus",true);hide_=&add_toggle("hide empty hand",true);
|
||||
}
|
||||
void on_enable() override {if(require_world(*this)){++world::collect_item_details;reading_=true;}}
|
||||
void on_disable() override {if(reading_){--world::collect_item_details;reading_=false;}}
|
||||
void on_render() override {
|
||||
const auto f=world::latest();if(!g_menu_open && !world::fresh(*f))return;
|
||||
auto item=f->local.held;
|
||||
if(g_menu_open && item.name.empty()){item.name="diamond_pickaxe";item.max_damage=1561;item.damage=275;item.durability_known=true;item.enchantments={{15,4},{17,3}};item.attack_known=true;item.attack_bonus=5;}
|
||||
if(item.name.empty() && hide_->bool_value && !g_menu_open)return;
|
||||
std::vector<std::pair<std::string,std::string>> rows{{"held item",world::item_label(item.name)}};
|
||||
if(durability_->bool_value && item.max_damage>0){char value[64];snprintf(value,sizeof(value),"%d / %d (%.0f%%)",item.max_damage-item.damage,item.max_damage,100.f*(item.max_damage-item.damage)/item.max_damage);rows.emplace_back("durability",item.durability_known ? value : "unavailable");}
|
||||
if(attack_->bool_value && item.attack_known)rows.emplace_back("base attack bonus","+"+std::to_string(item.attack_bonus));
|
||||
if(enchants_->bool_value)for(const auto& e:item.enchantments)rows.emplace_back(enchantment_label(e.id),std::to_string(e.level));
|
||||
draw_rows(rows);
|
||||
}
|
||||
private:setting *durability_,*enchants_,*attack_,*hide_;bool reading_=false;
|
||||
};
|
||||
|
||||
class status_effects_hud : public text_hud {
|
||||
public:
|
||||
status_effects_hud():text_hud("status effects","active effects with strength, timers and expiry warnings") {
|
||||
hud_pos={600,150};width_=&add_float("width",240,180,400);bars_=&add_toggle("timer bars",true);
|
||||
flash_=&add_toggle("flash near expiry",true);expiry_=&add_float("expiry warning seconds",5,1,30);
|
||||
hide_=&add_toggle("hide when empty",true);rows_=&add_int("maximum effects",8,1,16);
|
||||
}
|
||||
void on_enable() override {if(require_world(*this)){++world::collect_effects;reading_=true;}}
|
||||
void on_disable() override {if(reading_){--world::collect_effects;reading_=false;}maximum_.clear();}
|
||||
ImVec2 hud_size() const override {return {width_->float_value*scale_->float_value,hud_card::rows_height(shown_,bars_->bool_value ? 28.f : 24.f,38.f)*scale_->float_value};}
|
||||
void on_render() override {
|
||||
const auto f=world::latest();if(!g_menu_open && !world::fresh(*f))return;
|
||||
auto effects=f->effects;if(g_menu_open && effects.empty())effects={{1,1800,1},{16,150,0}};
|
||||
if(effects.empty() && hide_->bool_value && !g_menu_open){maximum_.clear();return;}
|
||||
if(last_world_!=f->world_id){maximum_.clear();last_world_=f->world_id;}
|
||||
std::map<int,int> next;
|
||||
for(const auto& e:effects)next[e.id]=(std::max)(maximum_[e.id],e.ticks);
|
||||
maximum_=std::move(next);
|
||||
std::sort(effects.begin(),effects.end(),[](const auto& a,const auto& b){return (a.ticks<0 ? INT_MAX : a.ticks)<(b.ticks<0 ? INT_MAX : b.ticks);});
|
||||
shown_=(std::max)(1,(std::min)(int(effects.size()),rows_->int_value));const float s=scale_->float_value,w=width_->float_value;
|
||||
auto* dl=ImGui::GetBackgroundDrawList();hud_card::background(dl,hud_pos,hud_size(),s,background_->bool_value);
|
||||
dl->PushClipRect(hud_pos,{hud_pos.x+w*s,hud_pos.y+hud_size().y},true);
|
||||
if(effects.empty())hud_card::text(dl,fonts::body,s,{hud_pos.x+12*s,hud_pos.y+15*s},theme::u32(theme::muted()),f->effects_known ? "no active effects" : "effects unavailable",background_->bool_value);
|
||||
for(int i=0;i<int(effects.size()) && i<shown_;++i) {
|
||||
const auto& e=effects[i];const float y=hud_pos.y+(7+i*38)*s;
|
||||
const bool expiring=e.ticks>=0 && e.ticks<=expiry_->float_value*20;
|
||||
const float pulse=flash_->bool_value && expiring ? .6f+.4f*std::sin(float(ImGui::GetTime())*8) : 1;
|
||||
const auto tint=expiring ? theme::danger() : theme::accent();
|
||||
dl->AddCircleFilled({hud_pos.x+22*s,y+12*s},10*s,theme::u32(theme::with_alpha(tint,.2f*pulse)));
|
||||
// Small potion bottle, drawn with the same muted palette as the HUD.
|
||||
dl->AddRect({hud_pos.x+18*s,y+7*s},{hud_pos.x+26*s,y+18*s},theme::u32(theme::with_alpha(tint,pulse)),2*s);
|
||||
dl->AddRectFilled({hud_pos.x+19*s,y+12*s},{hud_pos.x+25*s,y+17*s},theme::u32(theme::with_alpha(tint,.6f*pulse)),s);
|
||||
dl->AddRectFilled({hud_pos.x+20*s,y+4*s},{hud_pos.x+24*s,y+8*s},theme::u32(theme::with_alpha(tint,pulse)),s);
|
||||
const std::string name=std::string(qol::effect_name(e.id))+" "+std::to_string(e.amplifier+1);
|
||||
const std::string time=e.ticks<0 ? "infinite" : qol::clock_text((e.ticks+19)/20);
|
||||
const float tw=fonts::text_size(fonts::body,fonts::k_body_size*s,time.c_str()).x/s;
|
||||
dl->PushClipRect({hud_pos.x+40*s,y},{hud_pos.x+(w-tw-20)*s,y+19*s},true);
|
||||
hud_card::text(dl,fonts::semibold,s,{hud_pos.x+40*s,y+1*s},setting_color(*color_),name.c_str(),background_->bool_value);dl->PopClipRect();
|
||||
hud_card::text(dl,fonts::body,s,{hud_pos.x+(w-tw-12)*s,y+1*s},theme::u32(theme::muted()),time.c_str(),background_->bool_value);
|
||||
if(bars_->bool_value) {
|
||||
const float p=e.ticks<0 ? 1.f : float(e.ticks)/(std::max)(1,maximum_[e.id]);
|
||||
const ImVec2 a{hud_pos.x+40*s,y+25*s},b{hud_pos.x+(w-12)*s,y+28*s};
|
||||
theme::bar(dl,a,b,p,theme::with_alpha(tint,pulse));
|
||||
}
|
||||
}
|
||||
dl->PopClipRect();
|
||||
}
|
||||
private:setting *width_,*bars_,*flash_,*expiry_,*hide_,*rows_;int shown_=2;uint64_t last_world_=0;std::map<int,int> maximum_;bool reading_=false;
|
||||
};
|
||||
|
||||
class particle_controls : public module {
|
||||
public:
|
||||
particle_controls():module("particle controls","reduces supported named particles; existing emitters expire normally",category::visual) {
|
||||
density_=&add_int("particles kept (%)",50,0,100);
|
||||
const char* names[]={"portal","weather and splashes","combat","smoke and fire","potion effects","other particles"};
|
||||
for(int i=0;i<6;++i)categories_[i]=&add_toggle(names[i],i<5);
|
||||
}
|
||||
void on_enable() override {if(require_world(*this,qol_events::initialize_particles()))update();}
|
||||
void on_disable() override {qol_events::particles_enabled=false;}
|
||||
void on_render() override {update();}
|
||||
private:
|
||||
setting* density_;std::array<setting*,6> categories_{};
|
||||
void update() {
|
||||
unsigned mask=0;for(int i=0;i<6;++i)if(categories_[i]->bool_value)mask|=1u<<i;
|
||||
qol_events::particle_categories=mask;qol_events::density=density_->int_value;qol_events::particles_enabled=true;
|
||||
}
|
||||
};
|
||||
|
||||
class sound_indicators : public rows_hud {
|
||||
public:
|
||||
sound_indicators():rows_hud("sound indicators","directions for supported positional sounds; does not change audio") {
|
||||
hud_pos={600,510};lifetime_=&add_float("lifetime (seconds)",3,.5f,10);range_=&add_float("maximum distance",48,4,128);
|
||||
footsteps_=&add_toggle("footsteps",true);combat_=&add_toggle("combat",true);ambient_=&add_toggle("ambient",true);
|
||||
other_=&add_toggle("other sounds",true);filter_=&add_text("name contains (blank = all)","",64);
|
||||
nearby_=&add_toggle("hide sounds within 2 blocks",true);limit_=&add_int("maximum indicators",5,1,10);
|
||||
}
|
||||
void on_enable() override {if(require_world(*this,qol_events::initialize_sounds()))qol_events::sounds_enabled=true;}
|
||||
void on_disable() override {qol_events::sounds_enabled=false;events_.clear();std::lock_guard lock(qol_events::sound_mutex);qol_events::pending.clear();}
|
||||
void on_render() override {
|
||||
const auto f=world::latest();const auto now=GetTickCount64();
|
||||
std::deque<qol_events::sound> incoming;{std::lock_guard lock(qol_events::sound_mutex);incoming.swap(qol_events::pending);}
|
||||
if(!world::fresh(*f)){events_.clear();if(!g_menu_open)return;}
|
||||
for(auto& e:incoming) {
|
||||
if(e.world_id!=f->world_id || !allowed(e.name))continue;
|
||||
const float distance=world::distance(f->local.position,e.position);
|
||||
if(distance>range_->float_value || nearby_->bool_value && distance<2)continue;
|
||||
auto old=std::find_if(events_.begin(),events_.end(),[&](const auto& v){return v.name==e.name && world::distance(v.position,e.position)<3;});
|
||||
if(old!=events_.end())events_.erase(old);events_.push_front(std::move(e));
|
||||
while(events_.size()>16)events_.pop_back();
|
||||
}
|
||||
events_.erase(std::remove_if(events_.begin(),events_.end(),[&](const auto& e){return e.world_id!=f->world_id || now-e.stamp>lifetime_->float_value*1000 || !allowed(e.name);}),events_.end());
|
||||
std::vector<std::pair<std::string,std::string>> rows;
|
||||
for(const auto& e:events_) {
|
||||
if(rows.size()>=size_t(limit_->int_value))break;
|
||||
const float meters=world::distance(f->local.position,e.position);if(meters>range_->float_value)continue;
|
||||
const float angle=qol::wrap(qol::bearing(f->local.position,e.position)-qol::heading(*f));
|
||||
const char* direction=std::abs(angle)<30 ? "ahead" : std::abs(angle)>150 ? "behind" : angle<0 ? "left" : "right";
|
||||
char value[64];snprintf(value,sizeof(value),"%s / %.0fm",direction,meters);
|
||||
std::string name=e.name;std::replace(name.begin(),name.end(),'.',' ');std::replace(name.begin(),name.end(),'_',' ');
|
||||
rows.emplace_back(name,value);
|
||||
}
|
||||
if(rows.empty()){if(!g_menu_open)return;rows={{"zombie ambient","left / 12m"},{"player footsteps","behind / 8m"}};}
|
||||
draw_rows(rows);
|
||||
}
|
||||
private:
|
||||
setting *lifetime_,*range_,*footsteps_,*combat_,*ambient_,*other_,*filter_,*nearby_,*limit_;
|
||||
std::deque<qol_events::sound> events_;
|
||||
bool allowed(const std::string& name) const {
|
||||
if(!filter_->text_value.empty() && name.find(filter_->text_value)==std::string::npos)return false;
|
||||
if(name.find("step")!=std::string::npos)return footsteps_->bool_value;
|
||||
for(const char* s:{"hurt","attack","hit","explode","shoot","bow"})if(name.find(s)!=std::string::npos)return combat_->bool_value;
|
||||
for(const char* s:{"ambient","weather","rain","music"})if(name.find(s)!=std::string::npos)return ambient_->bool_value;
|
||||
return other_->bool_value;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,71 @@
|
||||
#pragma once
|
||||
#include <iomanip>
|
||||
#include <locale>
|
||||
#include <sstream>
|
||||
#include "../game/world.h"
|
||||
|
||||
namespace qol {
|
||||
inline float wrap(float angle) {return std::remainder(angle,360.f);}
|
||||
inline float bearing(world::vec3 from,world::vec3 to) {return std::atan2(from.x-to.x,to.z-from.z)*180.f/3.14159265f;}
|
||||
inline float heading(const world::frame& frame) {return std::atan2(frame.matrix[8],-frame.matrix[10])*180.f/3.14159265f;}
|
||||
inline std::string clock_text(int seconds) {
|
||||
seconds=(std::max)(0,seconds);char text[32];
|
||||
if(seconds>=3600)snprintf(text,sizeof(text),"%d:%02d:%02d",seconds/3600,seconds/60%60,seconds%60);
|
||||
else snprintf(text,sizeof(text),"%d:%02d",seconds/60,seconds%60);
|
||||
return text;
|
||||
}
|
||||
struct waypoint {std::string name,group;world::vec3 position;int dimension=0;bool death=false;};
|
||||
inline std::string encode(const waypoint& point) {
|
||||
std::ostringstream out;out.imbue(std::locale::classic());
|
||||
out<<std::quoted(point.name)<<' '<<std::quoted(point.group)<<' '<<point.dimension<<' '
|
||||
<<std::setprecision(9)<<point.position.x<<' '<<point.position.y<<' '<<point.position.z<<' '<<point.death;
|
||||
return out.str();
|
||||
}
|
||||
inline bool decode(const std::string& text,waypoint& result) {
|
||||
std::istringstream in(text);in.imbue(std::locale::classic());waypoint point;int death;
|
||||
if(!(in>>std::quoted(point.name)>>std::quoted(point.group)>>point.dimension>>point.position.x>>point.position.y>>point.position.z>>death))return false;
|
||||
in>>std::ws;if(!in.eof() || point.name.empty() || point.name.size()>32 || point.group.size()>32 ||
|
||||
point.dimension<0 || point.dimension>2 || death<0 || death>1 || !world::finite(point.position) ||
|
||||
std::abs(point.position.x)>3e7f || std::abs(point.position.y)>4096 || std::abs(point.position.z)>3e7f)return false;
|
||||
point.death=death!=0;result=std::move(point);return true;
|
||||
}
|
||||
inline double total_xp(int level,float progress) {
|
||||
const double l=level;
|
||||
return (level<=16 ? l*l+6*l : level<=31 ? 2.5*l*l-40.5*l+360 : 4.5*l*l-162.5*l+2220)
|
||||
+progress*(level<16 ? 2*l+7 : level<31 ? 5*l-38 : 9*l-158);
|
||||
}
|
||||
struct session {
|
||||
double seconds=0,distance=0,xp=0,last_time=-1,last_xp=0;int deaths=0;
|
||||
uint64_t world_id=0;uint32_t actor_id=0;int dimension=-1;bool sampled=false,alive=false,xp_sampled=false;world::vec3 position{};
|
||||
void reset(){*this={};}
|
||||
bool update(const world::frame& f,double time,bool horizontal=true) {
|
||||
if(!world::fresh(f)){sampled=false;xp_sampled=false;last_time=time;return false;}
|
||||
if(world_id!=f.world_id || dimension!=f.dimension || actor_id!=f.local.id) {
|
||||
world_id=f.world_id;dimension=f.dimension;actor_id=f.local.id;sampled=false;xp_sampled=false;alive=false;
|
||||
}
|
||||
const double dt=last_time<0 ? 0 : time-last_time;last_time=time;
|
||||
if(sampled && dt>0 && dt<1) {
|
||||
seconds+=dt;auto a=position,b=f.local.feet;if(horizontal)a.y=b.y=0;
|
||||
const float moved=world::distance(a,b);if(moved<16)distance+=moved;
|
||||
}
|
||||
const bool dead=f.local.health_known && f.local.health<=0;
|
||||
const bool died=sampled && alive && dead;
|
||||
if(died)++deaths;
|
||||
if(f.local.health_known)alive=!dead;
|
||||
if(f.xp_known) {
|
||||
const double value=total_xp(f.xp_level,f.xp_progress);
|
||||
if(xp_sampled && value>last_xp)xp+=value-last_xp;
|
||||
last_xp=value;xp_sampled=true;
|
||||
} else xp_sampled=false;
|
||||
position=f.local.feet;sampled=true;return died;
|
||||
}
|
||||
};
|
||||
inline const char* effect_name(int id) {
|
||||
static const char* names[]={"", "speed","slowness","haste","mining fatigue","strength","instant health","instant damage",
|
||||
"jump boost","nausea","regeneration","resistance","fire resistance","water breathing","invisibility","blindness",
|
||||
"night vision","hunger","weakness","poison","wither","health boost","absorption","saturation","levitation",
|
||||
"fatal poison","conduit power","slow falling","bad omen","village hero","darkness","trial omen","raid omen",
|
||||
"wind charged","weaving","oozing","infested","breath of the nautilus"};
|
||||
return id>0 && id<int(std::size(names)) ? names[id] : "unknown effect";
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ public:
|
||||
}
|
||||
void on_enable() override {if(require_world(*this))world::collect_xp=true;}
|
||||
void on_disable() override {world::collect_xp=false;}
|
||||
ImVec2 hud_size() const override {return {width_->float_value*scale_->float_value,(bar_->bool_value ? 54.f : 34.f)*scale_->float_value};}
|
||||
ImVec2 hud_size() const override {return {width_->float_value*scale_->float_value,height_*scale_->float_value};}
|
||||
void on_render() override {
|
||||
auto frame=world::latest();if(!g_menu_open && (!world::fresh(*frame) || !frame->xp_known))return;
|
||||
const int level=frame->xp_known ? frame->xp_level : 28;const float progress=frame->xp_known ? frame->xp_progress : .3f;
|
||||
@@ -23,17 +23,21 @@ public:
|
||||
if(percent_->bool_value){snprintf(value,sizeof(value)," %.1f%%",progress*100);text+=value;}
|
||||
if(remaining_->bool_value){snprintf(value,sizeof(value)," %d XP to go",xp_math::remaining(level,progress));text+=value;}
|
||||
const float scale=scale_->float_value;auto* draw=ImGui::GetBackgroundDrawList();
|
||||
fonts::push_font(fonts::semibold,fonts::k_body_size*scale);
|
||||
const auto text_size=ImGui::CalcTextSize(text.c_str(),nullptr,false,(width_->float_value-24)*scale);
|
||||
ImGui::PopFont();
|
||||
height_=14+text_size.y/scale+(bar_->bool_value ? 16.f : 0.f);
|
||||
hud_card::background(draw,hud_pos,hud_size(),scale,background_->bool_value);
|
||||
draw->PushClipRect(hud_pos,{hud_pos.x+hud_size().x,hud_pos.y+hud_size().y},true);
|
||||
hud_card::text(draw,fonts::semibold,scale,{hud_pos.x+12*scale,hud_pos.y+9*scale},setting_color(*color_),text.c_str(),background_->bool_value);
|
||||
draw->AddText(fonts::semibold,fonts::k_body_size*scale,{std::floor(hud_pos.x+12*scale),std::floor(hud_pos.y+7*scale)},
|
||||
theme::display_color(setting_color(*color_)),text.c_str(),nullptr,(width_->float_value-24)*scale);
|
||||
if(bar_->bool_value) {
|
||||
const ImVec2 p{hud_pos.x+12*scale,hud_pos.y+36*scale},q{hud_pos.x+(width_->float_value-12)*scale,p.y+5*scale};
|
||||
draw->AddRectFilled(p,q,theme::u32(theme::line()),2*scale);
|
||||
draw->AddRectFilled(p,{p.x+(q.x-p.x)*progress,q.y},setting_color(*color_),2*scale);
|
||||
const ImVec2 p{hud_pos.x+12*scale,hud_pos.y+18*scale+text_size.y},q{hud_pos.x+(width_->float_value-12)*scale,p.y+5*scale};
|
||||
theme::bar(draw,p,q,progress,ImGui::ColorConvertU32ToFloat4(theme::display_color(setting_color(*color_))));
|
||||
}
|
||||
draw->PopClipRect();
|
||||
}
|
||||
private:setting *width_,*percent_,*remaining_,*bar_;
|
||||
private:setting *width_,*percent_,*remaining_,*bar_;float height_=43;
|
||||
};
|
||||
|
||||
class tab_list : public text_hud {
|
||||
@@ -59,7 +63,7 @@ public:
|
||||
const bool known=frame->roster_known || g_menu_open;
|
||||
const int rows=rows_->int_value,count=int(names.size()),columns=(std::max)(1,(count+rows-1)/rows);
|
||||
const float scale=scale_->float_value,width=width_->float_value;
|
||||
bounds_={columns*width*scale,(38.f+20.f*(std::max)(1,(std::min)(rows,count)))*scale};
|
||||
bounds_={columns*width*scale,(32.f+hud_card::rows_height((std::max)(1,(std::min)(rows,count)))-7.f)*scale};
|
||||
auto* draw=ImGui::GetBackgroundDrawList();hud_card::background(draw,hud_pos,bounds_,scale,background_->bool_value);
|
||||
draw->PushClipRect(hud_pos,{hud_pos.x+bounds_.x,hud_pos.y+bounds_.y},true);
|
||||
std::string title=known ? "online "+std::to_string(frame->roster_known ? count : 0) : "player list unavailable";
|
||||
|
||||
@@ -11,6 +11,7 @@ struct setting {
|
||||
|
||||
bool bool_value = false;
|
||||
bool binding = false;
|
||||
bool hidden = false; // persisted module data, excluded from the settings panel
|
||||
std::function<void()> action;
|
||||
std::string text_value;
|
||||
float float_value = 0.f, float_min = 0.f, float_max = 1.f;
|
||||
|
||||
+96
-20
@@ -3,6 +3,7 @@
|
||||
#include "text_hud.h"
|
||||
#include "../game/world.h"
|
||||
#include "../game/world_filter.h"
|
||||
#include "../game/world_weather.h"
|
||||
#include "../gui/notifications.h"
|
||||
|
||||
inline bool require_world(module& m,bool available=world::ready) {
|
||||
@@ -16,10 +17,12 @@ inline bool project_world(const world::frame& frame,world::vec3 p,ImVec2& out) {
|
||||
}
|
||||
inline void draw_hud_row(ImVec2 pos,float width,const char* label,const std::string& value,float scale,ImU32 color,bool background) {
|
||||
auto* draw=ImGui::GetBackgroundDrawList();
|
||||
const auto label_size=fonts::text_size(fonts::body,fonts::k_body_size,label);
|
||||
const auto text_size=fonts::text_size(fonts::semibold,fonts::k_body_size,value.c_str());
|
||||
const auto label_size=fonts::text_size(fonts::body,fonts::k_body_size*scale,label);
|
||||
const auto text_size=fonts::text_size(fonts::semibold,fonts::k_body_size*scale,value.c_str());
|
||||
hud_card::text(draw,fonts::body,scale,pos,theme::u32(theme::muted()),label,background);
|
||||
hud_card::text(draw,fonts::semibold,scale,ImVec2((std::max)(pos.x+(label_size.x+6)*scale,pos.x+width-text_size.x*scale),pos.y),color,value.c_str(),background);
|
||||
draw->PushClipRect({pos.x+label_size.x+6*scale,pos.y},{pos.x+width,pos.y+fonts::k_body_size*scale+2},true);
|
||||
hud_card::text(draw,fonts::semibold,scale,ImVec2((std::max)(pos.x+label_size.x+6*scale,pos.x+width-text_size.x),pos.y),color,value.c_str(),background);
|
||||
draw->PopClipRect();
|
||||
}
|
||||
|
||||
class block_outlines : public module {
|
||||
@@ -59,21 +62,94 @@ private:setting *color_,*outline_,*width_;world::vec3 block_{};uint64_t last_hit
|
||||
|
||||
class atmosphere : public module {
|
||||
public:
|
||||
atmosphere():module("atmosphere","custom fog, world tint and darkness without changing the time",category::visual) {
|
||||
atmosphere():module("atmosphere","fog, animated palettes, cinematic grading, bloom and cosmetic weather",category::visual) {
|
||||
preset_=&add_mode("look preset",{"neon dusk","vaporwave","frost","ember","golden hour","noir","dreamscape"});
|
||||
add_action("apply selected look",[this]{apply_preset(preset_->int_value);});
|
||||
fog_=&add_toggle("custom fog color",true);fog_color_=&add_color("fog color",.4f,.6f,.9f,.65f);
|
||||
tint_=&add_color("world color",1,1,1,1);
|
||||
night_=&add_toggle("night mode",false);darkness_=&add_float("night darkness",.45f,.05f,.9f);
|
||||
add_action("reset atmosphere",[this]{fog_color_->color[0]=.4f;fog_color_->color[1]=.6f;fog_color_->color[2]=.9f;fog_color_->color[3]=.65f;for(auto& v:tint_->color)v=1;night_->bool_value=false;});
|
||||
exposure_=&add_float("exposure",0,-1.5f,1.5f);contrast_=&add_float("contrast",1,.5f,1.8f);
|
||||
saturation_=&add_float("saturation",1,0,2.5f);
|
||||
shadows_=&add_color("shadow tone",.35f,.2f,.65f,0);highlights_=&add_color("highlight tone",1,.65f,.8f,0);
|
||||
bloom_=&add_float("bloom",0,0,1.5f);threshold_=&add_float("bloom threshold",.7f,.35f,.95f);
|
||||
vignette_=&add_float("vignette",0,0,.8f);aberration_=&add_float("chromatic offset (px)",0,0,5);
|
||||
grain_=&add_float("film grain",0,0,1);
|
||||
animation_=&add_mode("palette animation",{"off","two color","rainbow"});
|
||||
palette_a_=&add_color("palette a",.9f,.35f,.75f,.3f);palette_b_=&add_color("palette b",.25f,.7f,1,.3f);
|
||||
speed_=&add_float("palette cycles per minute",3,.5f,20);
|
||||
animated_fog_=&add_toggle("animate fog too",true);
|
||||
renderer_=&add_mode("weather renderer",{"world particles","screen overlay"});
|
||||
rain_=&add_float("rain density",0,0,1);snow_=&add_float("snow density",0,0,1);
|
||||
rain_color_=&add_color("rain color",.65f,.8f,1,.6f);snow_color_=&add_color("snow color",.9f,.96f,1,.85f);
|
||||
radius_=&add_float("weather radius (blocks)",24,8,48);wind_=&add_float("weather wind",.3f,0,3);
|
||||
weather_speed_=&add_float("weather speed",1,.2f,3);
|
||||
add_action("reset atmosphere",[this]{reset();});
|
||||
}
|
||||
void on_enable() override {if(require_world(*this,world::ready && world::fog_ready)) update();}
|
||||
void on_disable() override {world::fog_enabled=false;world_filter::enabled=false;}
|
||||
void on_disable() override {world::fog_enabled=false;world_filter::enabled=false;world_filter::configure({});world_weather::configure({});}
|
||||
void on_render() override {update();}
|
||||
private:
|
||||
setting *fog_,*fog_color_,*tint_,*night_,*darkness_;
|
||||
setting *preset_,*fog_,*fog_color_,*tint_,*night_,*darkness_,*exposure_,*contrast_,*saturation_,*shadows_,*highlights_;
|
||||
setting *renderer_,*radius_,*wind_,*rain_color_,*snow_color_;
|
||||
bool weather_notice_=false;double weather_since_=0;
|
||||
setting *bloom_,*threshold_,*vignette_,*aberration_,*grain_,*animation_,*palette_a_,*palette_b_,*speed_,*animated_fog_,*rain_,*snow_,*weather_speed_;
|
||||
static void color(setting* s,unsigned rgb,float alpha) {
|
||||
s->color[0]=float((rgb>>16)&255)/255;s->color[1]=float((rgb>>8)&255)/255;s->color[2]=float(rgb&255)/255;s->color[3]=alpha;
|
||||
}
|
||||
void reset() {
|
||||
color(fog_color_,0x6699e6,.65f);color(tint_,0xffffff,1);fog_->bool_value=true;night_->bool_value=false;
|
||||
darkness_->float_value=.45f;exposure_->float_value=0;contrast_->float_value=saturation_->float_value=1;
|
||||
shadows_->color[3]=highlights_->color[3]=0;
|
||||
bloom_->float_value=vignette_->float_value=aberration_->float_value=grain_->float_value=rain_->float_value=snow_->float_value=0;
|
||||
renderer_->int_value=0;radius_->float_value=24;wind_->float_value=.3f;
|
||||
color(rain_color_,0xa6ccff,.6f);color(snow_color_,0xe6f5ff,.85f);
|
||||
threshold_->float_value=.7f;animation_->int_value=0;speed_->float_value=3;weather_speed_->float_value=1;
|
||||
animated_fog_->bool_value=true;color(palette_a_,0xe659bf,.3f);color(palette_b_,0x40b3ff,.3f);
|
||||
}
|
||||
void apply_preset(int index) {
|
||||
reset();vignette_->float_value=.23f;bloom_->float_value=.3f;exposure_->float_value=.15f;contrast_->float_value=1.1f;
|
||||
switch(index) {
|
||||
case 0:color(fog_color_,0x422c75,.8f);color(tint_,0xe1b7ff,.3f);color(shadows_,0x4520a0,.25f);color(highlights_,0xff8ac5,.18f);saturation_->float_value=1.35f;break;
|
||||
case 1:color(fog_color_,0xbf68b0,.7f);color(tint_,0xb8efff,.22f);color(shadows_,0x4d36a4,.25f);color(highlights_,0xff87cb,.2f);saturation_->float_value=1.35f;animation_->int_value=1;break;
|
||||
case 2:color(fog_color_,0x86aac4,.7f);color(tint_,0xbfe7ff,.25f);color(shadows_,0x3676b8,.22f);saturation_->float_value=.85f;snow_->float_value=.35f;break;
|
||||
case 3:color(fog_color_,0x713921,.75f);color(tint_,0xffd3a0,.25f);color(shadows_,0x59235f,.22f);color(highlights_,0xffb35c,.3f);saturation_->float_value=1.3f;grain_->float_value=.08f;break;
|
||||
case 4:color(fog_color_,0xd5a374,.55f);color(tint_,0xffe9c2,.2f);color(shadows_,0x6c7395,.15f);color(highlights_,0xffd08b,.25f);bloom_->float_value=.4f;break;
|
||||
case 5:color(fog_color_,0x747b86,.5f);saturation_->float_value=0;contrast_->float_value=1.25f;grain_->float_value=.15f;rain_->float_value=.45f;bloom_->float_value=.1f;break;
|
||||
case 6:color(fog_color_,0xaa99c8,.6f);color(tint_,0xffe0f5,.2f);color(shadows_,0x7975c9,.15f);color(highlights_,0xffc3d7,.18f);contrast_->float_value=.9f;bloom_->float_value=.55f;break;
|
||||
}
|
||||
}
|
||||
void update() {
|
||||
world::fog_color=setting_color(*fog_color_);world::fog_enabled=fog_->bool_value;
|
||||
world_filter::tint=setting_color(*tint_);world_filter::brightness=night_->bool_value ? 1-darkness_->float_value : 1;
|
||||
world_filter::enabled=night_->bool_value || tint_->color[0]!=1 || tint_->color[1]!=1 || tint_->color[2]!=1;
|
||||
ImVec4 tint=ImGui::ColorConvertU32ToFloat4(setting_color(*tint_));
|
||||
ImVec4 fog=ImGui::ColorConvertU32ToFloat4(setting_color(*fog_color_));
|
||||
if(animation_->int_value) {
|
||||
const float phase=float(std::fmod(ImGui::GetTime()*speed_->float_value/60,1.0));
|
||||
ImVec4 animated;
|
||||
if(animation_->int_value==1) {
|
||||
const float t=.5f-.5f*std::cos(phase*6.2831853f);
|
||||
animated=theme::mix(ImGui::ColorConvertU32ToFloat4(setting_color(*palette_a_)),ImGui::ColorConvertU32ToFloat4(setting_color(*palette_b_)),t);
|
||||
} else {ImGui::ColorConvertHSVtoRGB(phase,.55f,1,animated.x,animated.y,animated.z);animated.w=palette_a_->color[3];}
|
||||
tint=animated;
|
||||
if(animated_fog_->bool_value){fog.x=animated.x;fog.y=animated.y;fog.z=animated.z;}
|
||||
}
|
||||
world::fog_color=ImGui::ColorConvertFloat4ToU32(fog);world::fog_enabled=fog_->bool_value;
|
||||
world_filter::tint=ImGui::ColorConvertFloat4ToU32(tint);world_filter::brightness=night_->bool_value ? 1-darkness_->float_value : 1;
|
||||
world_filter::grading g;
|
||||
g.exposure=exposure_->float_value;g.contrast=contrast_->float_value;g.saturation=saturation_->float_value;
|
||||
g.shadows=setting_color(*shadows_);g.highlights=setting_color(*highlights_);
|
||||
g.vignette=vignette_->float_value;g.bloom=bloom_->float_value;g.threshold=threshold_->float_value;g.aberration=aberration_->float_value;
|
||||
g.grain=grain_->float_value;g.rain=renderer_->int_value==1 ? rain_->float_value:0;g.snow=renderer_->int_value==1 ? snow_->float_value:0;g.speed=weather_speed_->float_value;
|
||||
world_weather::settings weather;
|
||||
weather.rain=renderer_->int_value==0 ? rain_->float_value:0;weather.snow=renderer_->int_value==0 ? snow_->float_value:0;
|
||||
weather.radius=radius_->float_value;weather.speed=weather_speed_->float_value;weather.wind=wind_->float_value;
|
||||
weather.rain_color=setting_color(*rain_color_);weather.snow_color=setting_color(*snow_color_);
|
||||
if(!world_weather::enabled && (weather.rain>0 || weather.snow>0)){weather_since_=ImGui::GetTime();weather_notice_=false;}
|
||||
world_weather::configure(weather);
|
||||
if(world_weather::enabled && !weather_notice_ && ImGui::GetTime()-weather_since_>5 && amnesia_weather_status!=4) {
|
||||
notifications::push("world weather waiting","a matching world depth and projection pass has not been found",notifications::kind::warning,5,"world_weather");weather_notice_=true;
|
||||
}
|
||||
world_filter::configure(g);
|
||||
world_filter::enabled=night_->bool_value || tint.x!=1 || tint.y!=1 || tint.z!=1 || g.exposure!=0 || g.contrast!=1 || g.saturation!=1 ||
|
||||
shadows_->color[3]>0 || highlights_->color[3]>0 || g.vignette>0 || g.bloom>0 || g.aberration>0 || g.grain>0 || g.rain>0 || g.snow>0;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -83,7 +159,7 @@ public:
|
||||
hud_pos={10,365};compact_=&add_toggle("compact",false);hide_empty_=&add_toggle("hide empty slots",false);
|
||||
}
|
||||
void on_enable() override {require_world(*this);}
|
||||
ImVec2 hud_size() const override {return {width_*scale_->float_value,(14+rows_*20.f)*scale_->float_value};}
|
||||
ImVec2 hud_size() const override {return {width_*scale_->float_value,hud_card::rows_height(rows_)*scale_->float_value};}
|
||||
void on_render() override {
|
||||
auto frame=world::latest();if(!world::fresh(*frame) && !g_menu_open) return;
|
||||
const char* labels[] = {"head","chest","legs","feet"};
|
||||
@@ -97,7 +173,7 @@ public:
|
||||
rows.emplace_back(labels[i],std::move(name));
|
||||
}
|
||||
rows_=int(rows.size());width_=140;
|
||||
for(auto& row:rows) width_=(std::max)(width_,hud_card::size(row.first.c_str(),row.second.c_str(),1).x+8);
|
||||
for(auto& row:rows) width_=(std::max)(width_,hud_card::size(row.first.c_str(),row.second.c_str(),scale_->float_value).x/scale_->float_value);
|
||||
if(rows.empty()) return;
|
||||
const float scale=scale_->float_value;auto* draw=ImGui::GetBackgroundDrawList();
|
||||
hud_card::background(draw,hud_pos,hud_size(),scale,background_->bool_value);
|
||||
@@ -170,16 +246,16 @@ public:
|
||||
opacity_=theme::approach(opacity_,show ? 1.f : 0.f,ImGui::GetIO().DeltaTime*10);
|
||||
if(opacity_<.01f) return;
|
||||
const std::string name=preview ? "target preview" : target_.name.empty() ? "player" : target_.name;
|
||||
width_=(std::max)(240.f,fonts::text_size(fonts::semibold,fonts::k_body_size,name.c_str()).x+76);
|
||||
width_=(std::max)(240.f,fonts::text_size(fonts::semibold,fonts::k_body_size*scale_->float_value,name.c_str()).x/scale_->float_value+76);
|
||||
const float s=scale_->float_value;auto* draw=ImGui::GetBackgroundDrawList();
|
||||
const auto rgba=[&](int r,int g,int b,float alpha=1.f){return IM_COL32(r,g,b,int(255*alpha*opacity_));};
|
||||
const auto point=[&](float x,float y){return ImVec2(hud_pos.x+x*s,hud_pos.y+y*s);};
|
||||
hud_card::background(draw,hud_pos,hud_size(),s,background_->bool_value,opacity_);
|
||||
const ImU32 color=ImGui::ColorConvertFloat4ToU32({color_->color[0],color_->color[1],color_->color[2],color_->color[3]*opacity_});
|
||||
// Neutral head placeholder: no skin pixels are available in the actor snapshot.
|
||||
draw->AddRectFilled(point(10,10),point(46,46),rgba(12,13,15),6*s);
|
||||
draw->AddRectFilled(point(19,16),point(37,32),rgba(48,50,54),2*s);
|
||||
draw->AddRectFilled(point(16,33),point(40,44),rgba(35,37,41),3*s);
|
||||
draw->AddRectFilled(point(10,10),point(46,46),rgba(12,12,12));
|
||||
draw->AddRectFilled(point(19,16),point(37,32),rgba(48,48,48));
|
||||
draw->AddRectFilled(point(16,33),point(40,44),rgba(35,35,35));
|
||||
draw->AddRectFilled(point(22,23),point(25,26),rgba(16,17,19));
|
||||
draw->AddRectFilled(point(31,23),point(34,26),rgba(16,17,19));
|
||||
hud_card::text(draw,fonts::semibold,s,point(56,8),color,name.c_str(),background_->bool_value);
|
||||
@@ -188,16 +264,16 @@ public:
|
||||
const float fraction=known ? std::clamp(target_.health/target_.max_health,0.f,1.f) : 0;
|
||||
char percentage[24];if(known)snprintf(percentage,sizeof(percentage),"%.0f%%",fraction*100);
|
||||
else snprintf(percentage,sizeof(percentage),"--%%");
|
||||
const float percentage_width=fonts::text_size(fonts::semibold,fonts::k_body_size,percentage).x*.7f;
|
||||
const float percentage_width=fonts::text_size(fonts::semibold,fonts::k_body_size*s*.7f,percentage).x/s;
|
||||
hud_card::text(draw,fonts::semibold,s*.7f,point(width_-12-percentage_width,27),color,percentage,background_->bool_value);
|
||||
if(bar_->bool_value) {
|
||||
draw->AddRectFilled(point(56,40),point(width_-12,44),rgba(30,31,34),2*s);
|
||||
if(known && fraction>0) draw->AddRectFilled(point(56,40),point(56+(width_-68)*fraction,44),color,2*s);
|
||||
theme::bar(draw,point(56,40),point(width_-12,44),known ? fraction : 0,
|
||||
ImGui::ColorConvertU32ToFloat4(theme::display_color(color)));
|
||||
}
|
||||
char health[96];if(known)snprintf(health,sizeof(health),"%.0f / %.0f hp | %.1fm",target_.health,target_.max_health,distance_);
|
||||
else if(preview)snprintf(health,sizeof(health),"health unknown | preview");
|
||||
else snprintf(health,sizeof(health),"health unknown | %.1fm",distance_);
|
||||
hud_card::text(draw,fonts::body,s*.8f,point(56,49),rgba(195,197,202),health,background_->bool_value);
|
||||
hud_card::text(draw,fonts::body,s*.8f,point(56,49),theme::u32(theme::with_alpha(theme::muted(),opacity_)),health,background_->bool_value);
|
||||
if(equipment_->bool_value) {
|
||||
const char* labels[]={"weapon","head","chest","legs","feet"};
|
||||
for(int i=0;i<5;++i) {
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
#pragma once
|
||||
#include <windows.h>
|
||||
#include <appmodel.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <atomic>
|
||||
|
||||
namespace window_branding {
|
||||
inline constexpr int icon_resource=101;
|
||||
inline HWND window=nullptr;
|
||||
inline HICON icon_small=nullptr,icon_large=nullptr,original_small=nullptr,original_large=nullptr;
|
||||
inline std::wstring original_title,title;
|
||||
inline std::atomic<ULONGLONG> next_check{0};
|
||||
inline std::atomic<HWND> target{nullptr};
|
||||
inline std::atomic<HMODULE> resource_module{nullptr};
|
||||
inline std::atomic<bool> active{false},queued{false};
|
||||
inline constexpr UINT update_message=WM_APP+0x5a1,restore_message=WM_APP+0x5a2;
|
||||
inline constexpr WPARAM message_tag=0x414d4e;
|
||||
|
||||
inline std::wstring display_version(const PACKAGE_VERSION& version) {
|
||||
// Bedrock encodes its patch and package revision together in Build.
|
||||
if(version.Major==1 && version.Minor>=26)
|
||||
return std::to_wstring(version.Minor)+L"."+std::to_wstring(version.Build/100);
|
||||
return std::to_wstring(version.Major)+L"."+std::to_wstring(version.Minor)+L"."+std::to_wstring(version.Build/100);
|
||||
}
|
||||
inline std::wstring game_version() {
|
||||
UINT32 size=0;
|
||||
if(GetCurrentPackageId(&size,nullptr)!=ERROR_INSUFFICIENT_BUFFER || size>65536)return {};
|
||||
std::vector<BYTE> data(size);
|
||||
if(GetCurrentPackageId(&size,data.data())!=ERROR_SUCCESS)return {};
|
||||
return display_version(reinterpret_cast<const PACKAGE_ID*>(data.data())->version);
|
||||
}
|
||||
inline std::wstring window_title(HWND hwnd) {
|
||||
std::wstring text(GetWindowTextLengthW(hwnd)+1,L'\0');
|
||||
text.resize(GetWindowTextW(hwnd,text.data(),static_cast<int>(text.size())));
|
||||
return text;
|
||||
}
|
||||
inline void apply() {
|
||||
if(!window || !IsWindow(window))return;
|
||||
if(window_title(window)!=title)SetWindowTextW(window,title.c_str());
|
||||
if(icon_small && reinterpret_cast<HICON>(SendMessageW(window,WM_GETICON,ICON_SMALL,0))!=icon_small)
|
||||
SendMessageW(window,WM_SETICON,ICON_SMALL,reinterpret_cast<LPARAM>(icon_small));
|
||||
if(icon_large && reinterpret_cast<HICON>(SendMessageW(window,WM_GETICON,ICON_BIG,0))!=icon_large)
|
||||
SendMessageW(window,WM_SETICON,ICON_BIG,reinterpret_cast<LPARAM>(icon_large));
|
||||
}
|
||||
// These helpers run only inside the window's own message handler. Calling
|
||||
// GetWindowText/SendMessage from Present can deadlock against a UI thread
|
||||
// that is waiting for rendering to complete.
|
||||
inline void initialize_on_window_thread(HWND hwnd,HMODULE module) {
|
||||
HWND root=GetAncestor(hwnd,GA_ROOT);
|
||||
if(root && GetWindowThreadProcessId(root,nullptr)==GetCurrentThreadId())hwnd=root;
|
||||
window=hwnd;original_title=window_title(hwnd);
|
||||
original_small=reinterpret_cast<HICON>(SendMessageW(hwnd,WM_GETICON,ICON_SMALL,0));
|
||||
original_large=reinterpret_cast<HICON>(SendMessageW(hwnd,WM_GETICON,ICON_BIG,0));
|
||||
const auto version=game_version();
|
||||
title=L"amnesia // minecraft"+(version.empty() ? std::wstring{} : L" "+version);
|
||||
icon_small=static_cast<HICON>(LoadImageW(module,MAKEINTRESOURCEW(icon_resource),IMAGE_ICON,
|
||||
GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),0));
|
||||
icon_large=static_cast<HICON>(LoadImageW(module,MAKEINTRESOURCEW(icon_resource),IMAGE_ICON,
|
||||
GetSystemMetrics(SM_CXICON),GetSystemMetrics(SM_CYICON),0));
|
||||
apply();
|
||||
}
|
||||
inline void restore_on_window_thread() {
|
||||
if(window && IsWindow(window)) {
|
||||
SetWindowTextW(window,original_title.c_str());
|
||||
SendMessageW(window,WM_SETICON,ICON_SMALL,reinterpret_cast<LPARAM>(original_small));
|
||||
SendMessageW(window,WM_SETICON,ICON_BIG,reinterpret_cast<LPARAM>(original_large));
|
||||
}
|
||||
if(icon_small)DestroyIcon(icon_small);
|
||||
if(icon_large)DestroyIcon(icon_large);
|
||||
window=nullptr;icon_small=icon_large=original_small=original_large=nullptr;
|
||||
original_title.clear();title.clear();
|
||||
}
|
||||
inline bool handle_message(HWND hwnd,UINT message,WPARAM wp,LPARAM lp) {
|
||||
if((message!=update_message && message!=restore_message) || wp!=message_tag || lp!=0)return false;
|
||||
if(message==restore_message) {restore_on_window_thread();return true;}
|
||||
queued=false;
|
||||
if(!active || hwnd!=target.load())return true;
|
||||
if(!window)initialize_on_window_thread(hwnd,resource_module.load());else apply();
|
||||
return true;
|
||||
}
|
||||
inline void schedule() {
|
||||
if(!active || queued.exchange(true))return;
|
||||
if(!PostMessageW(target.load(),update_message,message_tag,0))queued=false;
|
||||
}
|
||||
inline void install(HWND hwnd,HMODULE module) {
|
||||
if(!IsWindow(hwnd) || active.exchange(true))return;
|
||||
resource_module=module;target=hwnd;next_check=GetTickCount64()+1000;
|
||||
schedule();
|
||||
}
|
||||
inline void tick() {
|
||||
const auto time=GetTickCount64();
|
||||
if(active && time>=next_check.load()) {next_check=time+1000;schedule();}
|
||||
}
|
||||
inline void shutdown() {
|
||||
active=false;HWND hwnd=target.exchange(nullptr);queued=false;next_check=0;
|
||||
if(!hwnd || !IsWindow(hwnd))return;
|
||||
if(GetWindowThreadProcessId(hwnd,nullptr)==GetCurrentThreadId())restore_on_window_thread();
|
||||
else {
|
||||
DWORD_PTR result=0;
|
||||
// Unload is allowed a bounded wait, never a render-thread wait.
|
||||
// On timeout retain the icons: the window may still reference them.
|
||||
SendMessageTimeoutW(hwnd,restore_message,message_tag,0,SMTO_ABORTIFHUNG|SMTO_BLOCK,1000,&result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
# In-game optimizations
|
||||
|
||||
Enable the existing optimizations module in Utility. New settings autosave in
|
||||
existing profiles; the module is not force-enabled in the user's profile.
|
||||
|
||||
- Reduce native particles: filters the verified named particle lookup before
|
||||
emitter creation, with the existing supported empty-definition return path.
|
||||
- Maximum particles kept: default 50%. Adaptive density lowers this in 10-point
|
||||
steps when measured FPS falls below 90% of the target and restores it in
|
||||
5-point steps above 110%. Measurement windows are at least half a second.
|
||||
Foreground FPS caps lower the effective target. Menus/background suspend
|
||||
adaptation. It reduces future emitters; existing emitters expire normally.
|
||||
- Particle budget: default 200 accepted non-combat lookups per 100ms. Set 0 for
|
||||
unlimited. A packed timestamp/count CAS makes the budget safe across threads.
|
||||
- Preserve combat particles: defaults on; the separate Particle Controls module
|
||||
can still suppress categories selected there. Both modules compose.
|
||||
- HUD data refresh: defaults to 30Hz for local equipment, health/name metadata,
|
||||
roster, XP and effects. Geometry, velocity, camera matrices, targeting and
|
||||
nametag player positions are still sampled every rendered world frame. Cache
|
||||
refreshes immediately on world/player/reader changes or an invalid frame.
|
||||
Set 0 to restore per-frame metadata reads. These settings do not change game
|
||||
simulation, inventory actions, packets or tick rates.
|
||||
- Disable present vsync: optional, defaults off. Sends SyncInterval=0 through the
|
||||
existing D3D11 Present hook, preserving TEST calls and all native flags. It
|
||||
does not force tearing flags, overwrite game options, or bypass other FPS
|
||||
limits. Presentation behavior depends on the game's swapchain/Windows.
|
||||
|
||||
Disabling the module restores full-rate reads, native sync and particle behavior
|
||||
independently of Particle Controls. No speculative game offsets are introduced.
|
||||
The original Windows scheduling controls/frame caps remain available.
|
||||
|
||||
Validation covers native particle forwarding/empty returns, combat exceptions,
|
||||
filter composition, deterministic density, concurrent burst ceilings/rollovers,
|
||||
adaptive recovery, refresh invalidation and native Present flags. Full FPS gains
|
||||
need an in-game comparison in the same scene; none are claimed from unit tests.
|
||||
@@ -0,0 +1,85 @@
|
||||
# Quality-of-life modules
|
||||
|
||||
All eight additions start disabled. HUDs use the existing FPS card style, font,
|
||||
background/color/scale controls, draggable editor, and grid snapping. Settings and
|
||||
saved waypoint records use profile autosave.
|
||||
|
||||
- **Waypoints:** F8 (rebindable) or "save current location" adds a named location.
|
||||
Sixteen slots can be renamed or deleted. The newest death gets a separate slot.
|
||||
Choose a **world/server group** for each world you use; group selection is manual.
|
||||
Locations filter by group and actual dimension. Marker distance, coordinates,
|
||||
range, color, and scale are configurable. Saved data is hidden from the settings
|
||||
panel but included in profile snapshots. Death recording requires the module
|
||||
enabled and a captured alive-to-zero-health transition.
|
||||
- **Compass:** camera-relative direction ticks, heading degrees, width, visible
|
||||
angle, and optional waypoint/death markers. Works with the freelook camera.
|
||||
- **Session stats:** time spent in a world while enabled, horizontal/3D distance,
|
||||
deaths, and positive XP gains. Reset action starts a new session. World or
|
||||
dimension changes reset measurement baselines; teleports and long frame gaps do
|
||||
not add traveled distance. Counters are session-only, not lifetime statistics.
|
||||
- **Durability alerts:** held item/armor selection, percent threshold, notification
|
||||
duration, and repeat interval (zero = once). Repairing or changing items rearms
|
||||
alerts. Damage comes from the native `Damage` NBT IntTag, not stack auxiliary data.
|
||||
- **Tool info:** held item, remaining/max durability and percent, enchantments with
|
||||
levels, and verified native **base attack bonus**. This is the item's bonus,
|
||||
not a prediction including enchantments, player attributes, or armor mitigation.
|
||||
- **Status effects:** potion bottle symbols, names/strength, timers, optional bars,
|
||||
adjustable expiry flashing, empty-state hiding, width, and row limit. Infinite
|
||||
effects display "infinite". Bars use the longest duration observed while enabled.
|
||||
- **Particle controls:** percentage of supported named particle requests to keep,
|
||||
with portal/weather/combat/smoke-fire/potion/other category switches. Unchecked
|
||||
categories retain normal behavior. The hook filters definition lookup before
|
||||
emitter creation; existing emitters finish naturally. Legacy unnamed particles
|
||||
and effects that reuse a definition without another lookup are not covered.
|
||||
- **Sound indicators:** native positional SoundInstance start events, names,
|
||||
direction and distance. Configure lifetime, range, row count, footsteps/combat/
|
||||
ambient/other filters, optional name substring, and nearby-sound hiding. Audio
|
||||
is forwarded unchanged. UI/non-positional sounds and other native audio-instance
|
||||
implementations are not displayed. Indicators show events already started by
|
||||
the client, not arbitrary nearby entities.
|
||||
|
||||
## Native verification (26.52 / package 1.26.5203.0)
|
||||
|
||||
Read-only live checks confirmed Speed I's effect ID, decreasing ticks, and zero
|
||||
amplifier. MobEffectsComponent contains indexed 144-byte instances; ID +0, duration
|
||||
+4, amplifier +0x20. Inactive slots have ID zero. DimensionTypeComponent is a bounded
|
||||
0/1/2 integer. Native getters still go through the verified sparse ECS access.
|
||||
|
||||
The held realm diamond axe reported Damage 546 / max 1561 (1015 remaining), with
|
||||
Unbreaking III, Sharpness V, Efficiency IV, and Mending I. CompoundTag uses a bounded
|
||||
native map; ListTag contains pointers to compound entries with ShortTag `id`/`lvl`.
|
||||
Tag type getters and the exact max-damage getter are checked before reading. The
|
||||
attack getter must be a verified read-only integer leaf at +0x218 or +0x228.
|
||||
|
||||
All three hook patterns have exactly one match in the captured executable:
|
||||
particle definition lookup RVA 0x21529c0, continuous SoundInstance update RVA
|
||||
0xb3a4890, and short SoundInstance update RVA 0xb3a9ec0.
|
||||
Particle input is HashedString (native string +8), return is a shared-pointer pair.
|
||||
The emitter's null-definition path returns an invalid handle and cleans its owned
|
||||
arguments normally. Filtering does not skip an owning emitter wrapper destructor.
|
||||
Sound name +0x20, position +0x100, positional flag +0x11c and channel +0x88 were
|
||||
verified against native FMOD setup and live sound objects.
|
||||
Short instances share name +0x20 and channel +0x88, with position +0xa8,
|
||||
positional flag +0xbc and playback state +0xcc. Live portal and horse sounds
|
||||
confirmed these fields. Both start paths are observed; repeated updates to an
|
||||
already-playing channel do not add events.
|
||||
|
||||
## Tests and remaining live checks
|
||||
|
||||
The integration suite covers native-shaped item tags/getter validation, malformed
|
||||
NBT/vector bounds, effect duration/amplifier bounds, waypoint serialization,
|
||||
dimension filtering/actions, death latching, teleport rejection, session XP math,
|
||||
particle sampling, null-handle/pass-through behavior, audio forwarding and start
|
||||
deduplication, reader lifetime across toggles, and actual finite HUD geometry.
|
||||
|
||||
In-game interaction still needs verification after loading the rebuilt client:
|
||||
new HUD appearance, saving/reloading waypoint profiles, death-marker capture,
|
||||
audible world sound indicators, and visible reduction of supported particles.
|
||||
The first live build received hundreds of particle requests and suppressed them
|
||||
at the selected density. That check exposed the missing short-sound update path,
|
||||
which is now included and covered by the forwarding/deduplication test.
|
||||
|
||||
The reloaded build subsequently received 32 native sound events and 973 particle
|
||||
requests, with 593 particle requests suppressed at the active settings. Minecraft
|
||||
remained responsive. This confirms live event delivery and filtering; the HUD
|
||||
appearance and remaining interactions above still require visual verification.
|
||||
@@ -1,5 +1,31 @@
|
||||
# FOV Changer verification
|
||||
|
||||
## Debug startup scanning
|
||||
|
||||
Debug builds also show a read-only diagnostics dashboard after the intro. It
|
||||
anchors to the top-right HUD grid, flows into columns to fit the display and
|
||||
uses the current client fonts and text shadows with no background or border.
|
||||
The compact readout reports rolling frame statistics,
|
||||
client/module/Present elapsed times, process CPU and memory, adapter-local memory,
|
||||
aggregate core hook readiness, world snapshot age, input counters, weather,
|
||||
particles and profiles. Process CPU is normalized across logical processors;
|
||||
process and GPU memory are for Minecraft as a whole, not just the client DLL.
|
||||
Present elapsed time includes waiting. Slow counters refresh at 2 Hz; frame
|
||||
timing stays live. Inactive readers remain inactive. Release builds exclude it.
|
||||
`debug_metrics_tests.h` verifies statistics, grid alignment and screen bounds at
|
||||
multiple resolutions/grid sizes, sampling cadence and passive reader behavior.
|
||||
|
||||
Signature searches use the longest literal run as an anchor, then verify all
|
||||
wildcards at each candidate. This avoids checked `vector<bool>` access at every
|
||||
executable byte in unoptimized Debug builds. Unique-match rejection is retained.
|
||||
`sigscan_tests.h` compares 3,000 generated patterns against an independent matcher
|
||||
and checks wildcard-only patterns, overlapping matches and guard-page boundaries.
|
||||
The existing integration tests still check missing and ambiguous executable matches.
|
||||
|
||||
Debug builds write `startup-debug.log` beside `client.dll`, including named scans,
|
||||
scan durations and the transition from world hooks to modules. If startup still
|
||||
stalls in-game, inspect the last entry before assuming the remaining issue is a scan.
|
||||
|
||||
## World modules and HUD style
|
||||
|
||||
See [WORLD_MODULES.md](WORLD_MODULES.md) for the new modules, verified interfaces,
|
||||
@@ -139,3 +165,24 @@ The Debug and Release client DLLs build successfully, and the isolated integrati
|
||||
test passes. Visual behavior inside Minecraft still requires the in-game check.
|
||||
Future game updates may require a new signature; a missing or ambiguous match
|
||||
leaves the module unavailable.
|
||||
# Window branding
|
||||
|
||||
The client applies `amnesia // minecraft {version}` to the game window when its
|
||||
renderer initializes. The version comes from the running app's package identity;
|
||||
package `1.26.5203.0` displays as `26.52`. Without a package identity the title
|
||||
omits the version. Both window icon sizes use the embedded `src/assets/window.ico`.
|
||||
Branding is checked once per second and the saved title and icon handles are
|
||||
restored on unload. The injector's source icon is only copied, never modified.
|
||||
Render callbacks only post branding requests. Title/icon reads and writes run
|
||||
on the window thread through the input message handler, avoiding a synchronous
|
||||
render-to-window wait. Unload requests restoration before removing that handler,
|
||||
with a one-second timeout if the window thread is unavailable.
|
||||
|
||||
The integration suite uses a real hidden Win32 window to verify embedded icon
|
||||
loading, branding reapplication, repeated install/unload, and restoration of the
|
||||
original title and icons. Minecraft's title bar and task-switcher appearance still
|
||||
need an in-game check after loading the rebuilt DLL.
|
||||
The regression test schedules branding from another thread while the UI thread
|
||||
does not process messages, then verifies application when messages resume and
|
||||
restoration from a separate unload thread. It also covers unload before the first
|
||||
posted branding request has run.
|
||||
@@ -0,0 +1,54 @@
|
||||
# Reference menu style
|
||||
|
||||
Style source: `D:/projects/menus/bitchbot/src/main.cpp` (read only).
|
||||
Its UI uses FreeType-rasterized Verdana, white/gray text with four one-pixel black shadows,
|
||||
square charcoal gradients, black inset borders, and accent #7a459c with a
|
||||
half-brightness secondary stripe. Checkboxes use a solid gradient selection;
|
||||
sliders use filled gradient tracks, centered values and +/- label controls;
|
||||
combos use +/- indicators and accent selections; key binds use plain text.
|
||||
|
||||
The client retains its panel/category layout, HUD positions,
|
||||
editor navigation, lowercase display and existing profile/module identifiers.
|
||||
The mini player uses a separate, case-preserving Verdana face for external
|
||||
song/artist/player metadata; other client text keeps the lowercase display.
|
||||
Body and category text use the reference's 13px Verdana, with 11px secondary
|
||||
labels. The font atlas uses FreeType with native mono hinting (grayscale antialiasing retained) and horizontal pixel
|
||||
snapping, including the embedded fallback font. The backend is shared by the
|
||||
DLL, integration tests and offscreen preview.
|
||||
HUD text is measured at its actual rendered size, including non-integer
|
||||
scales. Row cards balance top/bottom padding, values share right edges, and
|
||||
mini-player art, text, progress and controls share consistent insets/gaps.
|
||||
|
||||
Module rows are 26px; action buttons, binds and combos are 22px;
|
||||
toggle rows are 20px. Native controls use 3px vertical padding.
|
||||
Existing user colors remain stored; legacy default HUD text/accent colors are
|
||||
adapted at display time, without rewriting profiles or other custom colors.
|
||||
|
||||
Notifications follow `D:/projects/asm_notifications`: compact messages at the
|
||||
top left, text-sized cards, 2px stack gaps, half-second eased horizontal slides
|
||||
and exit fades, smoothed stack movement, blinking/bouncing warning lines.
|
||||
Client timer and live-task progress bars remain available. Backgrounds, borders
|
||||
and the accent use the shared menu theme; errors use its error color.
|
||||
|
||||
Module settings use the reference indent group: a 3px dark vertical guide
|
||||
and 14px indentation. Expansion and collapse animate the reserved height and
|
||||
clip the settings, with frame-rate-independent easing. Controls remain disabled
|
||||
until the reveal finishes; the category owns scrolling.
|
||||
|
||||
Shared styling covers ClickGUI, profile dialogs, HUD editor, HUD cards, world
|
||||
nametags, target/armor/tool/effect/session HUDs, keystrokes, inventory buttons
|
||||
and picker, media art frames/controls, notifications and the startup screen.
|
||||
Gameplay rendering colors (crosshair, particles, glint, fog, block outlines)
|
||||
remain module settings rather than being replaced by the UI theme.
|
||||
|
||||
Small local ImGui rendering changes apply shadows, native control gradients,
|
||||
native checkbox fills, popup/window gradients and accent borders consistently.
|
||||
They do not change widget input handling or window layout. Keep these changes
|
||||
when updating the vendored ImGui revision.
|
||||
|
||||
Verification: actual checkbox/slider clicks, slider value bounds, stable row
|
||||
positions, nested draw-list splitting, open dropdown/style-stack balancing,
|
||||
finite HUD geometry, native font glyph/layout checks and the full integration
|
||||
suite. An offscreen D3D11/WARP preview uses the actual ClickGUI and widgets
|
||||
with sample modules (`client/build/style-preview.png`). Final visual behavior
|
||||
in Minecraft requires reloading the rebuilt DLL.
|
||||
@@ -56,9 +56,13 @@ the visible-cursor guard is enabled, window resizing, pixel-read failure, or mou
|
||||
input failure. A held left mouse button is released on cancellation; failed releases
|
||||
retain ownership for retry and prevent another run from starting.
|
||||
|
||||
Notifications appear at the upper right, with sliding/fading cards, reflow, shadows,
|
||||
colored status icons, a spinner while running, and progress/lifetime bars. Trading
|
||||
Notifications appear at the upper right, with half-second eased slides, fading
|
||||
exits, smooth stack reflow, and info/success/warning/error icons in muted colors.
|
||||
Rounded cards, borders, and fonts match the click GUI. Timed cards have shrinking
|
||||
lifetime bars; warnings add a pulsing icon and a moving bar indicator. Trading
|
||||
updates one persistent card rather than creating a toast for every attempt. The
|
||||
live bar shows trade progress without restarting the entry animation. Repeated
|
||||
dismissal requests do not postpone expiry. The
|
||||
renderer remains active after Macro is disabled so final stop messages can finish.
|
||||
|
||||
## Verification
|
||||
|
||||
+31
-2
@@ -187,8 +187,22 @@ only. In-game verification of the rebuilt DLL still requires loading it.
|
||||
|
||||
## HUD editor grid snapping
|
||||
|
||||
The clickgui's top bar has a `hud editor` popup with snap/grid toggles and a
|
||||
4-64 pixel grid size (default 10). Hold Shift while dragging to bypass snapping.
|
||||
Mouse input is gated both in the subclassed window procedure and in Bedrock's
|
||||
native MouseDevice feed queue (verified unique signature, current RVA 0x361ad0).
|
||||
While the menu is open, native motion, button presses, and wheel packets are
|
||||
discarded; actual button releases still pass. Opening the menu posts a tagged
|
||||
message to the game's window thread that queues releases for cached mouse
|
||||
buttons at the last mouse position. It does not synthesize clicks or wheel input.
|
||||
Closing the menu restores unmodified native event forwarding. Automated tests
|
||||
cover forwarding arguments, blocked event types, release handling and reopening;
|
||||
the final in-game click/scroll check remains necessary after reloading the DLL.
|
||||
|
||||
The clickgui's top bar has a `hud editor` button that opens a separate editing
|
||||
screen. Category panels and profile controls are hidden there; its toolbar has
|
||||
snap/grid toggles, a 4-64 pixel grid size (default 10), and `back to modules`.
|
||||
Escape returns to the module screen; Right Shift closes the menu. Each new menu
|
||||
opening starts on modules. Grid lines and HUD drag handles appear only in the
|
||||
editor. Hold Shift while dragging to bypass snapping.
|
||||
Only dragged HUD elements snap; opening the editor leaves existing layouts alone.
|
||||
Mouse displacement is measured from the original grab point, rather than rounding
|
||||
each frame's delta, so slow dragging does not get stuck between grid cells.
|
||||
@@ -332,3 +346,18 @@ orbit deltas; reads of the restored player baseline do not reset that reference.
|
||||
A regression checks that a repeated target contributes zero camera movement,
|
||||
then a new target contributes only its incremental pitch/yaw change. This fixes
|
||||
the observed continuous orbit after stopping the mouse.
|
||||
|
||||
## Steal/dump item picker
|
||||
|
||||
Right-clicking steal or dump opens a compact item list from the current source
|
||||
slots. Counts aggregate all matching native item IDs; choosing a row transfers
|
||||
all stacks of that exact ID. Dump choices include hotbar only when the existing
|
||||
include-hotbar setting is enabled. Left-click continues to transfer everything.
|
||||
The list scrolls with the mouse wheel, closes with Escape/outside clicks, and
|
||||
consumes its mouse buttons so selecting a row cannot pick up a container item.
|
||||
Closing/changing containers, disabling buttons/module or opening the clickgui
|
||||
clears the picker. Requests carry a copied filter and expected controller identity;
|
||||
no stale picker selection can attach to a newly opened container. Engine tests
|
||||
cover duplicate stacks, missing IDs, exact apple/golden-apple distinction, dump
|
||||
filtering, hotbar choices and filter reset. In-game picker interaction remains to
|
||||
be checked after loading the rebuilt DLL.
|
||||
@@ -0,0 +1,56 @@
|
||||
# Atmosphere world visuals
|
||||
|
||||
Visual -> atmosphere keeps the existing module ID, fog/world colors and night
|
||||
mode. New settings autosave in the existing profile system.
|
||||
|
||||
Choose a look preset, press apply selected look, then enable atmosphere:
|
||||
- neon dusk: purple fog, rich saturation, violet shadows and pink highlights
|
||||
- vaporwave: cycling pink/cyan palette, colored fog and soft bloom
|
||||
- frost: pale blue grading, desaturation and cosmetic snow
|
||||
- ember: warm highlights, purple shadows, amber fog and subtle grain
|
||||
- golden hour: warm light, cooler shadows and brighter bloom
|
||||
- noir: monochrome contrast, grain and cosmetic rain
|
||||
- dreamscape: soft contrast, pastel fog and bloom
|
||||
|
||||
Applying a preset updates ordinary settings. All values remain editable; presets
|
||||
are not reapplied each frame. Reset restores neutral grading and the original
|
||||
fog defaults. Disabling restores native fog and disables the GPU effects pass.
|
||||
|
||||
Controls: exposure, contrast, saturation, shadow/highlight RGB + blend alpha,
|
||||
world tint + alpha, fog RGB + alpha, night darkness, bloom/threshold, vignette,
|
||||
chromatic offset, grain, two-color/rainbow palette animation and speed, optional
|
||||
animated fog, rain/snow density and weather speed, weather renderer, radius, wind and colors.
|
||||
|
||||
The postprocess is a single D3D11 fullscreen pass. Bloom samples bright neighbors
|
||||
only when enabled; chromatic offset adds samples only when enabled. Effects run
|
||||
in active gameplay with the cursor hidden and ClickGUI closed. Client HUD/GUI
|
||||
are drawn afterward. This screen-space pass includes Minecraft's own already
|
||||
rendered UI; screen-overlay rain/snow remain available as a fallback. The default world
|
||||
renderer draws custom camera-projected particles at world locations using
|
||||
instanced streak/flake shaders and the native depth buffer with depth writes
|
||||
disabled. It recognizes standard/reversed perspective matrices matching the
|
||||
current FOV; if depth/projection cannot be verified, it skips drawing and
|
||||
reports a waiting notification. Projection coefficients are read from the native camera matrix and normalized
|
||||
from its OpenGL depth range to D3D11. FOV, matrix shape and the near plane are
|
||||
validated against the live 26.52 GPU projection recovered during diagnosis.
|
||||
CPU-side constant-buffer uploads remain an alternate observation path (Map/Unmap, UpdateSubresource and UpdateSubresource1); no GPU-buffer
|
||||
copy/readback is used. World weather explicitly restores all changed D3D11 state
|
||||
and leaves native targets/UAV bindings untouched. It never swaps or clears
|
||||
the game context and only draws on the Present thread. Precipitation does not
|
||||
yet check block columns for roofs and can spawn inside covered areas. Neither
|
||||
renderer changes real weather. Native fog uses the existing verified dimension fog hook.
|
||||
No fake world-time changes, packets or server-state writes are introduced.
|
||||
|
||||
Verification uses actual WARP shader execution and pixel readback for neutral
|
||||
legacy tint/darkness, grayscale, vignette and split tones, all seven presets,
|
||||
animated-palette changes and reset/disable. Existing tests cover fog isolation
|
||||
and full D3D11 render-state restoration. A synthetic scene contact sheet renders
|
||||
the real GPU pass; it is a shader preview, not a screenshot of Minecraft.
|
||||
|
||||
Live validation on 26.52: status 4 with an increasing draw count and projection
|
||||
source 3 confirms the graphics boundary is drawing with the converted native
|
||||
camera projection. The earlier graphics readback/context-state path was removed
|
||||
after an NVIDIA-driver crash. Both the WARP and hardware tests now exercise
|
||||
explicit state preservation, standard/reversed depth occlusion, camera motion
|
||||
and projection conversion. Final particle appearance requires the user's visual
|
||||
confirmation; draw counters alone do not establish visual quality.
|
||||
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
#include "../src/gui/debug_metrics.h"
|
||||
|
||||
inline void test_debug_metrics() {
|
||||
using namespace debug_metrics;
|
||||
frame_history history;
|
||||
assert(history.summarize().mean==0);
|
||||
history.push(0);history.push(-1);history.push(std::numeric_limits<float>::infinity());
|
||||
assert(history.count==0);
|
||||
for(int i=0;i<239;++i)history.push(10);
|
||||
history.push(100);
|
||||
auto stats=history.summarize();
|
||||
assert(stats.min==10 && stats.max==100 && stats.p95==10);
|
||||
assert(std::fabs(stats.mean-10.375f)<.001f);
|
||||
assert(std::fabs(stats.low-25.f)<.001f); // slowest 3 of 240 frames
|
||||
history.push(20);assert(history.count==240 && history.next==1);
|
||||
|
||||
for(ImVec2 screen: {ImVec2{1920,1080},ImVec2{1280,720},ImVec2{800,600},ImVec2{320,240}})
|
||||
for(int grid: {4,10,24,64})for(size_t count:{size_t(1),size_t(90),size_t(140)}) {
|
||||
const auto box=arrange(screen,count,grid);
|
||||
assert(box.columns*box.rows>=int(count));
|
||||
assert(box.pos.x>=0 && box.pos.y>=0 && box.pos.x+box.size.x<=screen.x && box.pos.y+box.size.y<=screen.y);
|
||||
assert(std::fabs(std::remainder(box.pos.x,float(grid)))<.01f && std::fabs(std::remainder(box.pos.y,float(grid)))<.01f);
|
||||
assert(box.header+box.rows*box.row_height+box.padding<=box.size.y+.01f);
|
||||
}
|
||||
// Reading diagnostics must not activate native hooks or a media worker.
|
||||
const auto particles=performance::particles.load();const auto weather=world_weather::enabled.load();auto* media_before=media::instance;
|
||||
dashboard metrics;metrics.sample(nullptr);
|
||||
assert(!metrics.rows.empty() && particles==performance::particles && weather==world_weather::enabled && media_before==media::instance);
|
||||
assert(std::any_of(metrics.rows.begin(),metrics.rows.end(),[](const row& r){return r.label=="profile";}));
|
||||
metrics.rows.push_back({"sample sentinel","",false});metrics.sample(nullptr);
|
||||
assert(metrics.rows.back().label=="sample sentinel"); // expensive sampling is capped at 2 Hz
|
||||
std::cout<<"PASS: Debug metrics frame statistics, responsive grid layout, bounded sampling and passive readers\n";
|
||||
}
|
||||
@@ -12,6 +12,12 @@
|
||||
#include "../src/modules/trade_profile.h"
|
||||
#include "../src/gui/notifications.h"
|
||||
#include "../src/input.h"
|
||||
#include "window_branding_tests.h"
|
||||
#include "menu_input_tests.h"
|
||||
#include "lowercase_font_tests.h"
|
||||
#include "startup_intro_tests.h"
|
||||
#include "style_widget_tests.h"
|
||||
#include "sigscan_tests.h"
|
||||
#pragma section(".fvtest", read, execute)
|
||||
#pragma comment(linker, "/SECTION:.fvtest,ER")
|
||||
__declspec(allocate(".fvtest")) unsigned char fixture[] = {0x56, 0x57, 0x53, 0x48, 0x83, 0xec, 0x60, 0x44, 0x0f, 0x29, 0x44, 0x24, 0x50, 0x0f, 0x29, 0x7c, 0x24, 0x40, 0x0f, 0x29, 0x74, 0x24, 0x30, 0x44, 0x89, 0xc3, 0x0f, 0x28, 0xf1, 0x48, 0x89, 0xce, 0x45, 0x84, 0xc0, 0x0f, 0x84, 0x23, 0x00, 0x00, 0x00, 0x48, 0x8b, 0x86, 0x88, 0x11, 0x00, 0x00, 0x48, 0x8b, 0x88, 0xf8, 0x03, 0x00, 0x00, 0x48, 0x8b, 0x01, 0x48, 0x8b, 0x80, 0xd8, 0x00, 0x00, 0x00, 0x48, 0x8d, 0x54, 0x24, 0x28, 0x41, 0xb8, 0x2f, 0x00, 0x00, 0x00, 0xf3, 0x0f, 0x10, 0x05, 0x18, 0x00, 0x00, 0x00, 0x0f, 0x28, 0x74, 0x24, 0x30, 0x0f, 0x28, 0x7c, 0x24, 0x40, 0x44, 0x0f, 0x28, 0x44, 0x24, 0x50, 0x48, 0x83, 0xc4, 0x60, 0x5b, 0x5f, 0x5e, 0xc3, 0x00, 0x00, 0x8c, 0x42};
|
||||
@@ -271,6 +277,24 @@ static void test_crosshair_render() {
|
||||
cross.set_enabled(false);draw_native();assert(native_crosshair_draws==3+i);
|
||||
}
|
||||
notifications::items.clear();
|
||||
// Entry/exit match the reference's half-second eased slide; timers count down.
|
||||
notifications::toast timed;timed.born=10;timed.duration=3;
|
||||
auto motion=notifications::animate(timed,10);
|
||||
assert(motion.slide==1 && motion.alpha==1 && motion.remaining==1);
|
||||
motion=notifications::animate(timed,10.25);
|
||||
assert(close_float(motion.slide,.25f));
|
||||
motion=notifications::animate(timed,11.5);
|
||||
assert(motion.slide==0 && close_float(motion.remaining,.5f));
|
||||
motion=notifications::animate(timed,13.25);
|
||||
assert(close_float(motion.slide,.75f) && close_float(motion.alpha,.25f) && motion.remaining==0);
|
||||
motion=notifications::animate(timed,13.5);
|
||||
assert(motion.slide==1 && motion.alpha==0);
|
||||
timed.title="macro";timed.body="running";
|
||||
assert(notifications::message(timed)=="macro: running");
|
||||
timed.title.clear();assert(notifications::message(timed)=="running");
|
||||
timed.body.clear();assert(notifications::message(timed).empty());
|
||||
timed.duration=0;motion=notifications::animate(timed,100);
|
||||
assert(motion.slide==0 && motion.alpha==1);
|
||||
notifications::push("Trading","1 / 500 trade attempts",notifications::kind::info,0,"trade",0.1f);
|
||||
notifications::push("Trading","2 / 500 trade attempts",notifications::kind::info,0,"trade",0.2f);
|
||||
assert(notifications::items.size()==1 && notifications::items[0].progress==0.2f);
|
||||
@@ -281,9 +305,32 @@ static void test_crosshair_render() {
|
||||
assert(ImGui::GetForegroundDrawList()->VtxBuffer.Size>0);
|
||||
for(const auto& vertex:ImGui::GetForegroundDrawList()->VtxBuffer) assert(std::isfinite(vertex.pos.x) && std::isfinite(vertex.pos.y));
|
||||
ImGui::Render();
|
||||
assert(close_float(notifications::items.front().y,5.f));
|
||||
assert(notifications::items[1].y>notifications::items[0].y);
|
||||
assert(notifications::items[2].y>notifications::items[1].y);
|
||||
notifications::dismiss("trade");assert(notifications::items[0].duration>0);
|
||||
const double dismissed_duration=notifications::items[0].duration;
|
||||
notifications::dismiss("trade");assert(notifications::items[0].duration==dismissed_duration);
|
||||
for(auto& item:notifications::items) item.born-=20;
|
||||
ImGui::NewFrame();notifications::draw();assert(notifications::items.empty());ImGui::Render();
|
||||
// All four types, wrapped text, and keyed progress updates render without restarting entry.
|
||||
notifications::push("Working","A long notification body that should wrap across more than one line in the card.",notifications::kind::info,0,"live",.3f);
|
||||
const double live_born=notifications::items[0].born;
|
||||
notifications::push("Working","Updated progress",notifications::kind::info,0,"live",.7f);
|
||||
assert(notifications::items[0].born==live_born);
|
||||
notifications::dismiss("live");
|
||||
notifications::push("Working","Resumed",notifications::kind::info,0,"live",.8f);
|
||||
assert(!notifications::items[0].dismissed && notifications::items[0].duration==0);
|
||||
for(auto type:{notifications::kind::info,notifications::kind::success,notifications::kind::warning,notifications::kind::error}) {
|
||||
notifications::items.clear();
|
||||
notifications::push("Status","Multiple lines\nwith a timer",type,3);
|
||||
notifications::items[0].born-=1;
|
||||
ImGui::NewFrame();notifications::draw();ImGui::Render();
|
||||
assert(ImGui::GetDrawData()->TotalVtxCount>0);
|
||||
for(const auto& vertex:ImGui::GetForegroundDrawList()->VtxBuffer)
|
||||
assert(std::isfinite(vertex.pos.x) && std::isfinite(vertex.pos.y));
|
||||
}
|
||||
notifications::items.clear();
|
||||
ImGui::DestroyContext();
|
||||
}
|
||||
|
||||
@@ -344,8 +391,20 @@ static void write_code(unsigned char* target, const unsigned char* bytes, size_t
|
||||
#include "anti_afk_tests.h"
|
||||
#include "server_hud_tests.h"
|
||||
#include "hud_grid_tests.h"
|
||||
#include "qol_tests.h"
|
||||
#include "performance_tests.h"
|
||||
#include "world_weather_tests.h"
|
||||
#include "debug_metrics_tests.h"
|
||||
|
||||
int main() {
|
||||
test_debug_metrics();
|
||||
test_sigscan_ranges();
|
||||
test_lowercase_fonts();
|
||||
test_startup_intro();
|
||||
test_style_widgets();
|
||||
menu_input_test::run();
|
||||
test_window_branding();
|
||||
test_qol_readers();test_qol_state();test_qol_event_forwarding();test_qol_modules();test_performance();test_world_weather();test_world_weather(D3D_DRIVER_TYPE_HARDWARE);
|
||||
test_profiles();
|
||||
test_world_math_and_hooks();
|
||||
test_world_filter();
|
||||
|
||||
@@ -9,11 +9,14 @@
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<PropertyGroup><OutDir>$(ProjectDir)..\build\tests\</OutDir><IntDir>$(OutDir)obj\</IntDir></PropertyGroup>
|
||||
<ItemDefinitionGroup>
|
||||
<ResourceCompile><AdditionalIncludeDirectories>$(ProjectDir)..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories></ResourceCompile>
|
||||
<ClCompile><LanguageStandard>stdcpp17</LanguageStandard><WarningLevel>Level3</WarningLevel><UndefinePreprocessorDefinitions>NDEBUG</UndefinePreprocessorDefinitions><AdditionalIncludeDirectories>$(ProjectDir)..\vendor\minhook\include;$(ProjectDir)..\vendor\imgui;$(ProjectDir)..\vendor\imgui\backends</AdditionalIncludeDirectories></ClCompile>
|
||||
<Link><AdditionalDependencies>user32.lib;%(AdditionalDependencies)</AdditionalDependencies></Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="..\src\client.rc" />
|
||||
<ClCompile Include="fov_changer_test.cc" />
|
||||
<ClCompile Include="..\src\font_data.cc" />
|
||||
<ClCompile Include="..\vendor\imgui\imgui.cpp" />
|
||||
<ClCompile Include="..\vendor\imgui\imgui_draw.cpp" />
|
||||
<ClCompile Include="..\vendor\imgui\imgui_tables.cpp" />
|
||||
@@ -23,5 +26,6 @@
|
||||
<ClCompile Include="..\vendor\minhook\src\trampoline.c" />
|
||||
<ClCompile Include="..\vendor\minhook\src\hde\hde64.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(ProjectDir)..\vendor\freetype\freetype.props" />
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
</Project>
|
||||
@@ -85,6 +85,26 @@ inline void test_inventory_tools() {
|
||||
stock={{"apple",3}};state.panels[2].items=stock;worker.step(state,11200,true);
|
||||
state.panels[2].items=stock;worker.step(state,11300,true);
|
||||
assert(!worker.active() && cursor.count==0 && transferred_groups==std::vector<std::string>({"inventory_items","hotbar_items"}));include_hotbar=false;
|
||||
// Filtered transfers use exact native item IDs and retain unrelated stacks.
|
||||
stock={{"arrow",10},{"golden_apple",4},{"arrow",5},{"apple",3}};cursor={};
|
||||
state.panels={{"container_items",stock},{"inventory_items",stock}};state.cursor=false;
|
||||
transfers=0;transferred_groups.clear();worker.start({owner,action::steal,"","arrow"});
|
||||
for(int i=0;i<12 && worker.active();++i){state.panels[0].items=stock;worker.step(state,16000+i*100,true);}
|
||||
assert(!worker.active() && transfers==2 && stock[0].count==0 && stock[2].count==0 && stock[1].count==4 && stock[3].count==3);
|
||||
transfers=0;worker.start({owner,action::steal,"","diamond"});
|
||||
for(int i=0;i<12 && worker.active();++i){state.panels[0].items=stock;worker.step(state,18000+i*100,true);}
|
||||
assert(!worker.active() && transfers==0 && stock[1].count==4);
|
||||
stock={{"apple",3},{"golden_apple",4}};state.panels[1].items=stock;transfers=0;
|
||||
worker.start({owner,action::dump,"","apple"});
|
||||
for(int i=0;i<8 && worker.active();++i){state.panels[1].items=stock;worker.step(state,20000+i*100,true);}
|
||||
assert(transfers==1 && stock[0].count==0 && stock[1].count==4);
|
||||
snapshot picker_fixture;picker_fixture.panels={{"container_items",{{"arrow",10},{"arrow",5},{"apple",3}}},
|
||||
{"inventory_items",{{"stone",64}}},{"hotbar_items",{{"arrow",20},{"stone",6}}}};
|
||||
auto menu=choices(picker_fixture,action::steal,false);
|
||||
assert(menu.size()==2 && menu[0].name=="apple" && menu[1].name=="arrow" && menu[1].count==15);
|
||||
menu=choices(picker_fixture,action::dump,false);assert(menu.size()==1 && menu[0].name=="stone" && menu[0].count==64);
|
||||
menu=choices(picker_fixture,action::dump,true);assert(menu.size()==2 && menu[0].name=="arrow" && menu[1].count==70);
|
||||
worker.start({owner,action::dump,"","apple"});worker.cancel();assert(worker.filter.empty());
|
||||
assert(next_minimum({},0)==-1);
|
||||
// Additional controllers must not cancel an operation owned by a fresh chest.
|
||||
auto old_tick=original_tick;auto old_current=current;auto old_published=latest();const bool old_enabled=enabled;
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
#include "../src/gui/fonts.h"
|
||||
#include "../src/gui/hud_card.h"
|
||||
|
||||
inline void test_lowercase_fonts() {
|
||||
ImGui::CreateContext();
|
||||
fonts::load();
|
||||
auto& io=ImGui::GetIO();
|
||||
assert(io.Fonts->FontLoader==ImGuiFreeType::GetFontLoader());
|
||||
io.DisplaySize={1280,720};io.DeltaTime=.016f;
|
||||
io.BackendFlags|=ImGuiBackendFlags_RendererHasTextures;
|
||||
ImGui::NewFrame();
|
||||
for(ImFont* font : {fonts::body,fonts::semibold,fonts::label,fonts::heading}) {
|
||||
for(float size : {11.f,13.f,14.f,20.f,35.f}) {
|
||||
auto* baked=font->GetFontBaked(size);
|
||||
for(ImWchar upper='A';upper<='Z';++upper) {
|
||||
// Loading the second glyph can grow/reallocate the glyph array.
|
||||
const auto* glyph=baked->FindGlyphNoFallback(upper);
|
||||
assert(glyph);
|
||||
const ImFontGlyph capital=*glyph;
|
||||
const auto* lower=baked->FindGlyphNoFallback(upper+('a'-'A'));
|
||||
assert(lower && capital.AdvanceX==lower->AdvanceX);
|
||||
assert(capital.X0==lower->X0 && capital.X1==lower->X1 && capital.Y0==lower->Y0 && capital.Y1==lower->Y1);
|
||||
}
|
||||
const auto a=font->CalcTextSizeA(size,FLT_MAX,0,"Macro / Shift / FPS");
|
||||
const auto b=font->CalcTextSizeA(size,FLT_MAX,0,"macro / shift / fps");
|
||||
assert(a.x==b.x && a.y==b.y);
|
||||
}
|
||||
}
|
||||
assert(fonts::media && fonts::media!=fonts::body);
|
||||
auto* media_baked=fonts::media->GetFontBaked(13.f);
|
||||
const ImFontGlyph capital=*media_baked->FindGlyphNoFallback('A');
|
||||
const ImFontGlyph lower=*media_baked->FindGlyphNoFallback('a');
|
||||
assert(capital.U0!=lower.U0 || capital.V0!=lower.V0);
|
||||
// Exercise the real hinted fonts at non-integer HUD scales; glyphs and their
|
||||
// shadows must fit the card sized by the same font, rather than scaled metrics.
|
||||
for(float scale:{.7f,1.f,1.35f,2.5f}) {
|
||||
const ImVec2 pos{40,40};const auto bounds=hud_card::size("fps","144",scale,"999");
|
||||
auto* draw=ImGui::GetBackgroundDrawList();const int begin=draw->VtxBuffer.Size;
|
||||
hud_card::draw(pos,"fps","144",scale,true,IM_COL32_WHITE,"999");
|
||||
for(int i=begin;i<draw->VtxBuffer.Size;++i) {
|
||||
const auto p=draw->VtxBuffer[i].pos;
|
||||
assert(p.x>=pos.x-2 && p.x<=pos.x+bounds.x+2);
|
||||
assert(p.y>=pos.y-2 && p.y<=pos.y+bounds.y+2);
|
||||
}
|
||||
}
|
||||
ImGui::EndFrame();ImGui::DestroyContext();
|
||||
fonts::body=fonts::semibold=fonts::label=fonts::heading=fonts::media=nullptr;
|
||||
std::cout<<"PASS: lowercase glyphs and matching layout at all client font weights and sizes\n";
|
||||
}
|
||||
@@ -42,7 +42,10 @@ inline void test_media_and_glint() {
|
||||
state.duration=240;state.position=60;state.stamp=GetTickCount64();player.draw(state);
|
||||
Microsoft::WRL::ComPtr<ID3D11Device> art_device;Microsoft::WRL::ComPtr<ID3D11DeviceContext> art_context;D3D_FEATURE_LEVEL art_level;
|
||||
assert(SUCCEEDED(D3D11CreateDevice(nullptr,D3D_DRIVER_TYPE_WARP,nullptr,0,nullptr,0,D3D11_SDK_VERSION,&art_device,&art_level,&art_context)));
|
||||
media_art::device=art_device.Get();state.art=cover;player.draw(state);media_art::device=nullptr;
|
||||
media_art::device=art_device.Get();state.art=cover;player.draw(state);
|
||||
state.app="Spotify.exe";player.draw(state);
|
||||
state.app="SPOTIFY.EXE";player.draw(state);
|
||||
state.app="test player";player.draw(state);media_art::device=nullptr;
|
||||
g_menu_open=true;player.draw(state);g_menu_open=false;
|
||||
assert(player.hud_drag_size().y<player.hud_size().y);
|
||||
ImGui::Render();assert(ImGui::GetDrawData()->TotalVtxCount>100);
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include "../src/input.h"
|
||||
|
||||
namespace menu_input_test {
|
||||
struct event {void* device;char button,state;short x,y,dx,dy;char scrolling;};
|
||||
inline std::vector<event> received;
|
||||
inline void __fastcall receive(void* device,char button,char state,short x,short y,short dx,short dy,char scrolling) {
|
||||
received.push_back({device,button,state,x,y,dx,dy,scrolling});
|
||||
}
|
||||
inline void run() {
|
||||
const auto saved = input::original_mouse_feed;
|
||||
const auto device = input::mouse_device;
|
||||
const auto x = input::mouse_x, y = input::mouse_y;
|
||||
const bool open = g_menu_open;
|
||||
const auto buttons=input::blocked_mouse_buttons.load(), wheels=input::blocked_mouse_wheels.load(), moves=input::blocked_mouse_moves.load();
|
||||
input::original_mouse_feed=receive; received.clear();
|
||||
auto* fake = reinterpret_cast<void*>(0x1234);
|
||||
g_menu_open=false;
|
||||
input::mouse_feed_detour(fake,1,1,100,200,3,4,7);
|
||||
assert(received.size()==1 && received[0].device==fake && received[0].button==1 && received[0].state==1);
|
||||
assert(received[0].x==100 && received[0].y==200 && received[0].dx==3 && received[0].dy==4 && received[0].scrolling==7);
|
||||
g_menu_open=true;
|
||||
input::release_native_mouse();
|
||||
assert(received.size()==6);
|
||||
for(size_t i=1;i<received.size();++i) {
|
||||
assert(input::mouse_release(received[i].button,received[i].state));
|
||||
assert(received[i].x==100 && received[i].y==200 && received[i].dx==0 && received[i].dy==0);
|
||||
}
|
||||
const auto count=received.size();
|
||||
for(char button : {char(0),char(1),char(2),char(3),char(4),char(5),char(6)})
|
||||
input::mouse_feed_detour(fake,button,1,110,210,5,6,0);
|
||||
input::mouse_feed_detour(fake,4,0,110,210,0,0,0); // Zero wheel state isn't a button release.
|
||||
assert(received.size()==count);
|
||||
assert(input::blocked_mouse_buttons==buttons+5 && input::blocked_mouse_wheels==wheels+2 && input::blocked_mouse_moves==moves+1);
|
||||
for(char button : {char(1),char(2),char(3),char(5),char(6)})
|
||||
input::mouse_feed_detour(fake,button,0,110,210,0,0,0);
|
||||
assert(received.size()==count+5);
|
||||
g_menu_open=false;
|
||||
input::release_native_mouse();
|
||||
assert(received.size()==count+5);
|
||||
input::mouse_feed_detour(fake,4,-120,120,220,0,0,1);
|
||||
assert(received.size()==count+6 && received.back().state==-120 && received.back().scrolling==1);
|
||||
input::original_mouse_feed=saved;input::mouse_device=device;input::mouse_x=x;input::mouse_y=y;g_menu_open=open;
|
||||
input::blocked_mouse_buttons=buttons;input::blocked_mouse_wheels=wheels;input::blocked_mouse_moves=moves;
|
||||
std::cout<<"PASS: native menu mouse gate blocks clicks, wheel and motion; releases held buttons and resumes unchanged input\n";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
#include <thread>
|
||||
#include "../src/game/performance.h"
|
||||
inline void test_performance() {
|
||||
performance::reset();
|
||||
assert(performance::present_sync(1,0)==1);
|
||||
performance::uncapped_present=true;
|
||||
assert(performance::present_sync(1,0)==0 && performance::present_sync(3,DXGI_PRESENT_TEST)==3);
|
||||
performance::particles=true;performance::keep=50;performance::burst_limit=0;
|
||||
int dropped=0;for(int i=0;i<100;++i)dropped+=performance::suppress(0,true,1000);
|
||||
assert(dropped==50);
|
||||
performance::keep=0;
|
||||
assert(!performance::suppress(2,true,1000) && !performance::suppress(0,false,1000));
|
||||
performance::keep=100;performance::burst_limit=10;
|
||||
int allowed=0;for(int i=0;i<100;++i)allowed+=!performance::suppress(0,true,1000);
|
||||
assert(allowed==10 && !performance::suppress(0,true,1100));
|
||||
performance::budget_state=0;
|
||||
std::atomic<int> total{0};std::vector<std::thread> workers;
|
||||
for(int i=0;i<8;++i)workers.emplace_back([&]{for(int n=0;n<1000;++n)if(!performance::over_budget(2000,317))++total;});
|
||||
for(auto& thread:workers)thread.join();assert(total==317);
|
||||
assert(!performance::over_budget(2100,317));
|
||||
// An older thread must not reset the next window's budget.
|
||||
const auto newer=performance::budget_state.load();assert(performance::over_budget(2000,317));
|
||||
assert(performance::budget_state==newer);
|
||||
performance::adaptive_density adaptive;adaptive.reset(50);
|
||||
for(int i=0;i<40;++i)adaptive.update(1./30,120,50);
|
||||
assert(adaptive.current<50);
|
||||
for(int i=0;i<960;++i)adaptive.update(1./240,120,50);
|
||||
assert(adaptive.current==50);
|
||||
const int saved=adaptive.current;adaptive.update(std::nan(""),120,50);assert(adaptive.current==saved);
|
||||
performance::refresh_gate refresh;
|
||||
assert(refresh.due(1000,1,1,0,30));assert(!refresh.due(1016,1,1,0,30));assert(refresh.due(1034,1,1,0,30));
|
||||
assert(refresh.due(1035,2,1,0,30));assert(refresh.due(1036,2,2,0,30));assert(refresh.due(1037,2,2,1,30));
|
||||
assert(refresh.due(1038,2,2,1,0));refresh.valid=false;assert(refresh.due(1039,2,2,1,30));
|
||||
performance::reset();assert(!performance::particles && !performance::uncapped_present && performance::hud_hz==0);
|
||||
std::cout<<"PASS: adaptive native particles, concurrent burst budgets, composed filters, HUD refresh invalidation and reversible Present sync\n";
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
#pragma once
|
||||
#include "../src/modules/qol_modules.h"
|
||||
#include "../src/config/profiles.h"
|
||||
|
||||
inline void test_qol_readers() {
|
||||
auto put=[](void* p,size_t offset,auto value){memcpy(static_cast<unsigned char*>(p)+offset,&value,sizeof(value));};
|
||||
unsigned char type2[]{0xb0,2,0xc3},type3[]{0xb0,3,0xc3},type9[]{0xb0,9,0xc3},type10[]{0xb0,10,0xc3};
|
||||
uintptr_t vt2[6]{},vt3[6]{},vt9[6]{},vt10[6]{};
|
||||
vt2[5]=uintptr_t(type2);vt3[5]=uintptr_t(type3);vt9[5]=uintptr_t(type9);vt10[5]=uintptr_t(type10);
|
||||
struct node {uintptr_t left=0,parent=0,right=0;uint64_t flags=0;std::string key;unsigned char value[96]{};};
|
||||
static_assert(offsetof(node,key)==32 && offsetof(node,value)==64);
|
||||
struct compound {uintptr_t vt=0,head=0;size_t count=0;};
|
||||
node head,damage,ench,ench_head,id,lvl;
|
||||
compound tags{uintptr_t(vt10),uintptr_t(&head),2},enchantment{uintptr_t(vt10),uintptr_t(&ench_head),2};
|
||||
head.parent=uintptr_t(&damage);damage.key="Damage";damage.left=uintptr_t(&head);damage.right=uintptr_t(&ench);
|
||||
ench.key="ench";ench.left=ench.right=uintptr_t(&head);
|
||||
put(damage.value,0,uintptr_t(vt3));put(damage.value,8,275);
|
||||
ench_head.parent=uintptr_t(&id);id.key="id";id.left=uintptr_t(&ench_head);id.right=uintptr_t(&lvl);
|
||||
lvl.key="lvl";lvl.left=lvl.right=uintptr_t(&ench_head);
|
||||
put(id.value,0,uintptr_t(vt2));put(id.value,8,int16_t(17));put(lvl.value,0,uintptr_t(vt2));put(lvl.value,8,int16_t(3));
|
||||
uintptr_t entry=uintptr_t(&enchantment);put(ench.value,0,uintptr_t(vt9));put(ench.value,8,uintptr_t(&entry));put(ench.value,16,uintptr_t(&entry+1));
|
||||
unsigned char item[0x240]{},stack[152]{},max_getter[]{0x0f,0xb7,0x81,0x50,1,0,0,0xc3},attack_getter[]{0x8b,0x81,0x28,2,0,0,0xc3};
|
||||
uintptr_t item_vt[38]{},counter=uintptr_t(item);item_vt[36]=uintptr_t(max_getter);item_vt[37]=uintptr_t(attack_getter);
|
||||
put(item,0,uintptr_t(item_vt));put(item,0x150,uint16_t(1561));put(item,0x228,5);
|
||||
const char* name="diamond_pickaxe";memcpy(item+0xd8,name,strlen(name));put(item,0xe8,uint64_t(strlen(name)));put(item,0xf0,uint64_t(15));
|
||||
put(stack,8,uintptr_t(&counter));put(stack,16,uintptr_t(&tags));put(stack,0x22,uint8_t(1));
|
||||
auto value=world::read_item(uintptr_t(stack),true);
|
||||
assert(value.name==name && value.durability_known && value.damage==275 && value.max_damage==1561);
|
||||
assert(value.attack_known && value.attack_bonus==5 && value.enchantments.size()==1 && value.enchantments[0].id==17 && value.enchantments[0].level==3);
|
||||
put(damage.value,8,1600);assert(!world::read_item(uintptr_t(stack),true).durability_known);put(damage.value,8,275);
|
||||
tags.count=129;assert(!world::read_item(uintptr_t(stack),true).durability_known);tags.count=2;
|
||||
put(ench.value,16,uintptr_t(&entry)+513);assert(world::read_item(uintptr_t(stack),true).enchantments.empty());
|
||||
assert(!world::read_item(uintptr_t(stack),false).durability_known);
|
||||
unsigned char effect_data[144*3]{};uintptr_t effects[]{uintptr_t(effect_data),uintptr_t(effect_data+sizeof(effect_data)),uintptr_t(effect_data+sizeof(effect_data))};
|
||||
put(effect_data,144,1);put(effect_data,144+4,1200);put(effect_data,144+0x10,14);put(effect_data,144+0x20,0);
|
||||
put(effect_data,288,19);put(effect_data,288+4,60);put(effect_data,288+0x20,1);
|
||||
std::vector<world::effect> active;assert(world::read_effects(uintptr_t(effects),active) && active.size()==2 && active[0].amplifier==0 && active[1].ticks==60);
|
||||
put(effect_data,144+4,-1);assert(world::read_effects(uintptr_t(effects),active) && active[0].ticks==-1);
|
||||
put(effect_data,144+0x20,256);assert(!world::read_effects(uintptr_t(effects),active));
|
||||
effects[1]++;assert(!world::read_effects(uintptr_t(effects),active));
|
||||
std::cout<<"PASS: native item Damage/enchantment tags, verified durability/attack getters and indexed effect timers\n";
|
||||
}
|
||||
|
||||
inline void test_qol_state() {
|
||||
qol::waypoint p{"home \"base\"","realm",{123,64,-256},0,false},restored;
|
||||
assert(qol::decode(qol::encode(p),restored) && restored.name==p.name && restored.position.z==-256);
|
||||
assert(!qol::decode("broken",restored));p.position.x=std::numeric_limits<float>::infinity();assert(!qol::decode(qol::encode(p),restored));
|
||||
assert(qol::bearing({},{0,0,10})==0 && std::abs(qol::bearing({},{10,0,0})+90)<.01f);
|
||||
world::frame f;f.valid=true;f.stamp=GetTickCount64();f.world_id=1;f.local.health_known=true;f.local.health=20;
|
||||
f.xp_known=true;f.xp_level=1;f.xp_progress=0;
|
||||
qol::session stats;assert(!stats.update(f,1));f.local.feet={3,0,4};f.xp_progress=.5f;
|
||||
stats.update(f,1.5);assert(std::abs(stats.distance-5)<.01 && stats.seconds==.5 && stats.xp==4.5);
|
||||
f.local.feet={1000,0,0};stats.update(f,1.6);assert(std::abs(stats.distance-5)<.01);
|
||||
f.local.health=0;assert(stats.update(f,1.7) && stats.deaths==1);assert(!stats.update(f,1.8) && stats.deaths==1);
|
||||
f.local.health=20;stats.update(f,1.9);f.local.health=0;assert(stats.update(f,2) && stats.deaths==2);
|
||||
f.world_id=2;stats.update(f,2.1);assert(stats.deaths==2);
|
||||
const double previous_xp=stats.xp;f.local.id=2;f.xp_level=100;stats.update(f,2.2);assert(stats.xp==previous_xp);
|
||||
assert(qol::total_xp(16,0)==352 && qol::total_xp(17,0)==394 && qol::total_xp(31,0)==1507 && qol::total_xp(32,0)==1628);
|
||||
assert(qol::clock_text(65)=="1:05" && qol::clock_text(3661)=="1:01:01");
|
||||
module_manager manager;auto* points=manager.add<waypoints_module>();const auto defaults=config::capture(manager);
|
||||
const auto saved=qol::encode({"realm home","my world",{10,64,20},0,false});
|
||||
for(auto& setting:points->settings())if(setting.name=="saved waypoint 1")setting.text_value=saved;
|
||||
config::snapshot loaded;assert(config::decode(config::encode(config::capture(manager)),loaded));
|
||||
for(auto& setting:points->settings())if(setting.name=="saved waypoint 1")setting.text_value.clear();
|
||||
config::apply(manager,defaults,loaded);
|
||||
for(auto& setting:points->settings())if(setting.name=="saved waypoint 1")assert(setting.hidden && setting.text_value==saved);
|
||||
qol_events::particle_categories=1;qol_events::density=0;assert(qol_events::suppress_particle("minecraft:portal_directional"));
|
||||
assert(!qol_events::suppress_particle("minecraft:critical_hit_emitter"));
|
||||
qol_events::particle_categories=0x3f;qol_events::density=50;qol_events::sequence=0;int dropped=0;
|
||||
for(int i=0;i<100;++i)dropped+=qol_events::suppress_particle("minecraft:rain_splash");assert(dropped==50);
|
||||
qol_events::density=100;assert(!qol_events::suppress_particle("minecraft:portal_directional"));
|
||||
std::cout<<"PASS: waypoint round-trip, bearings, death latching, teleport rejection, session XP and particle sampling\n";
|
||||
}
|
||||
|
||||
inline setting& qol_setting(module& m,const char* name) {
|
||||
for(auto& s:m.settings())if(s.name==name)return s;
|
||||
assert(false);return m.settings().front();
|
||||
}
|
||||
inline void test_qol_event_forwarding() {
|
||||
auto put=[](void* p,size_t offset,auto value){memcpy(static_cast<unsigned char*>(p)+offset,&value,sizeof(value));};
|
||||
const auto old_sound=qol_events::original_sound,old_short=qol_events::original_short_sound;const auto old_particle=qol_events::original_particle;
|
||||
world::frame f;f.valid=true;f.stamp=GetTickCount64();f.world_id=17;world::publish(f);
|
||||
unsigned char object[0x128]{};const char* name="zombie.hurt";
|
||||
memcpy(object+0x20,name,strlen(name));put(object,0x30,uint64_t(strlen(name)));put(object,0x38,uint64_t(15));
|
||||
put(object,0x100,world::vec3{12,64,20});put(object,0x11c,uint8_t(1));
|
||||
qol_events::original_sound=+[](uintptr_t self,float dt) {
|
||||
assert(dt==.125f);world::write(self+0x88,uintptr_t(12345));world::write(self+0xa8,3);
|
||||
};
|
||||
qol_events::sounds_enabled=true;qol_events::pending.clear();
|
||||
qol_events::sound_detour(uintptr_t(object),.125f);
|
||||
assert(qol_events::pending.size()==1 && qol_events::pending[0].name==name && qol_events::pending[0].position.x==12);
|
||||
qol_events::sound_detour(uintptr_t(object),.125f);assert(qol_events::pending.size()==1);
|
||||
put(object,0x88,uintptr_t(0));put(object,0x11c,uint8_t(0));qol_events::sound_detour(uintptr_t(object),.125f);assert(qol_events::pending.size()==1);
|
||||
qol_events::pending.clear();put(object,0x88,uintptr_t(0));put(object,0xbc,uint8_t(1));put(object,0xa8,world::vec3{5,64,8});
|
||||
qol_events::original_short_sound=+[](uintptr_t self,float dt) {
|
||||
assert(dt==.125f);world::write(self+0x88,uintptr_t(23456));world::write(self+0xcc,1);
|
||||
};
|
||||
qol_events::short_sound_detour(uintptr_t(object),.125f);assert(qol_events::pending.size()==1 && qol_events::pending[0].position.x==5);
|
||||
qol_events::short_sound_detour(uintptr_t(object),.125f);assert(qol_events::pending.size()==1);
|
||||
qol_events::sounds_enabled=false;qol_events::pending.clear();
|
||||
struct hashed {uint64_t hash=0;std::string text;};hashed particle;particle.text="minecraft:portal_directional";
|
||||
uintptr_t output[]{111,222};
|
||||
qol_events::original_particle=+[](uintptr_t cache,uintptr_t out,uintptr_t id) {
|
||||
assert(cache==123 && id);world::write(out,std::array<uintptr_t,2>{11,22});return out;
|
||||
};
|
||||
qol_events::particles_enabled=true;qol_events::particle_categories=1;qol_events::density=0;
|
||||
assert(qol_events::particle_detour(123,uintptr_t(output),uintptr_t(&particle))==uintptr_t(output) && output[0]==0 && output[1]==0);
|
||||
qol_events::particles_enabled=false;qol_events::particle_detour(123,uintptr_t(output),uintptr_t(&particle));assert(output[0]==11 && output[1]==22);
|
||||
performance::particles=true;performance::keep=0;
|
||||
qol_events::particle_detour(123,uintptr_t(output),uintptr_t(&particle));assert(output[0]==0 && output[1]==0);
|
||||
particle.text="minecraft:critical_hit_emitter";performance::protect_combat=true;
|
||||
qol_events::particle_detour(123,uintptr_t(output),uintptr_t(&particle));assert(output[0]==11 && output[1]==22);
|
||||
// Independent Particle Controls still applies its own selected categories.
|
||||
qol_events::particles_enabled=true;qol_events::particle_categories=1u<<2;qol_events::density=0;
|
||||
qol_events::particle_detour(123,uintptr_t(output),uintptr_t(&particle));assert(output[0]==0 && output[1]==0);
|
||||
qol_events::particles_enabled=false;performance::reset();
|
||||
qol_events::original_sound=old_sound;qol_events::original_short_sound=old_short;qol_events::original_particle=old_particle;world::publish({});
|
||||
std::cout<<"PASS: native sound forwarding/start deduplication and particle empty-handle/pass-through paths\n";
|
||||
}
|
||||
inline void test_qol_modules() {
|
||||
ImGui::CreateContext();auto& io=ImGui::GetIO();io.DisplaySize={1280,900};io.DeltaTime=.016f;
|
||||
io.Fonts->AddFontDefault();unsigned char* pixels;int w,h;io.Fonts->GetTexDataAsRGBA32(&pixels,&w,&h);
|
||||
world::frame f;f.valid=true;f.stamp=GetTickCount64();f.world_id=1;f.dimension=0;f.local.feet={10,64,20};f.local.health_known=true;f.local.health=20;
|
||||
f.matrix[0]=f.matrix[5]=f.matrix[15]=1;f.matrix[10]=-1;f.xp_known=true;f.xp_level=28;f.xp_progress=.3f;
|
||||
f.effects_known=true;f.effects={{1,1200,0},{19,80,1}};
|
||||
f.local.held.name="diamond_axe";f.local.held.damage=1500;f.local.held.max_damage=1561;f.local.held.durability_known=true;f.local.held.enchantments={{17,3},{26,1}};
|
||||
world::publish(f);const bool was_ready=world::ready;world::ready=true;
|
||||
waypoints_module points;compass_hud compass(points);session_stats stats;durability_alerts alerts;tool_info tool;status_effects_hud effects;sound_indicators sounds;
|
||||
points.set_enabled(true);tool.set_enabled(true);alerts.set_enabled(true);effects.set_enabled(true);stats.set_enabled(true);
|
||||
assert(world::collect_item_details==2 && world::collect_effects==1 && world::extra_xp_readers==1);
|
||||
qol_setting(points,"save current location").action();assert(points.points(f).size()==1);
|
||||
f.dimension=1;assert(points.points(f).empty());f.dimension=0;
|
||||
g_menu_open=true;ImGui::NewFrame();
|
||||
module* hud_modules[]{&points,&compass,&stats,&alerts,&tool,&effects,&sounds};
|
||||
for(module* m:hud_modules)m->on_render();
|
||||
const auto notification_count=notifications::items.size();alerts.on_render();assert(notifications::items.size()==notification_count);
|
||||
ImGui::Render();auto* data=ImGui::GetDrawData();assert(data->TotalVtxCount>100);
|
||||
for(int i=0;i<data->CmdListsCount;++i)for(const auto& v:data->CmdLists[i]->VtxBuffer)assert(std::isfinite(v.pos.x) && std::isfinite(v.pos.y));
|
||||
points.set_enabled(false);tool.set_enabled(false);alerts.set_enabled(false);effects.set_enabled(false);stats.set_enabled(false);
|
||||
assert(world::collect_item_details==0 && world::collect_effects==0 && world::extra_xp_readers==0);
|
||||
world::ready=was_ready;g_menu_open=false;world::publish({});notifications::items.clear();ImGui::DestroyContext();
|
||||
std::cout<<"PASS: new HUD geometry, waypoint actions/dimension filtering, alerts and shared-reader lifetime\n";
|
||||
}
|
||||
@@ -31,7 +31,7 @@ inline void test_server_hud() {
|
||||
ImGui::NewFrame();g_menu_open=true;
|
||||
world::frame frame;frame.valid=true;frame.stamp=GetTickCount64();frame.xp_known=true;frame.xp_level=28;frame.xp_progress=.3f;frame.roster_known=true;
|
||||
for(int i=0;i<25;++i)frame.online_players.push_back("player "+std::to_string(i));world::publish(frame);
|
||||
tab_list list;xp_progress_hud xp;list.on_render();xp.on_render();assert(list.hud_size().x==360 && xp.hud_size().y==54);
|
||||
tab_list list;xp_progress_hud xp;list.on_render();xp.on_render();assert(list.hud_size().x==360 && xp.hud_size().y==43);
|
||||
world::publish({});list.on_render();xp.on_render();list.on_disable();xp.on_disable();
|
||||
assert(!world::collect_roster && !world::collect_xp);
|
||||
ImGui::Render();auto* data=ImGui::GetDrawData();assert(data->TotalVtxCount>100);
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
#include "../src/game/sigscan.h"
|
||||
|
||||
inline void test_sigscan_ranges() {
|
||||
// Compare optimized matching to a simple independent matcher, including
|
||||
// leading/trailing wildcards, repeated anchors and overlapping matches.
|
||||
unsigned state=0x5812;
|
||||
auto random=[&] {state=state*1664525u+1013904223u;return state;};
|
||||
unsigned char data[128];
|
||||
sigscan::pattern pattern;
|
||||
for(unsigned trial=0;trial<3000;++trial) {
|
||||
const size_t size=1+random()%sizeof(data),length=1+random()%24;
|
||||
for(size_t i=0;i<size;++i)data[i]=static_cast<unsigned char>((random()>>16)%4);
|
||||
std::string text;
|
||||
for(size_t i=0;i<length;++i) {
|
||||
if((random()>>16)%3==0)text+="?? ";
|
||||
else {text+="0";text+=char('0'+(random()>>16)%4);text+=' ';}
|
||||
}
|
||||
assert(sigscan::parse(text.c_str(),pattern));
|
||||
size_t expected=0;unsigned char* first=nullptr;
|
||||
if(length<=size)for(size_t at=0;at<=size-length;++at) {
|
||||
bool match=true;
|
||||
for(size_t i=0;i<length;++i)if(pattern.mask[i] && data[at+i]!=pattern.bytes[i]){match=false;break;}
|
||||
if(match){++expected;if(!first)first=data+at;}
|
||||
}
|
||||
assert(sigscan::scan_range(data,data+size,pattern)==first);
|
||||
assert(sigscan::count_matches(data,data+size,pattern)==expected);
|
||||
}
|
||||
assert(sigscan::parse("?? ??",pattern));
|
||||
assert(sigscan::count_matches(data,data+4,pattern)==3);
|
||||
assert(sigscan::scan_range(data,data,pattern)==nullptr);
|
||||
assert(sigscan::scan_range(nullptr,nullptr,pattern)==nullptr);
|
||||
assert(!sigscan::parse("",pattern));
|
||||
assert(!sigscan::parse("4",pattern));
|
||||
assert(!sigscan::parse("ZZ",pattern));
|
||||
|
||||
// A last-position anchor must never read into the following guard page.
|
||||
SYSTEM_INFO info{};GetSystemInfo(&info);
|
||||
auto* pages=static_cast<unsigned char*>(VirtualAlloc(nullptr,info.dwPageSize*2,MEM_RESERVE|MEM_COMMIT,PAGE_READWRITE));
|
||||
assert(pages);DWORD old=0;
|
||||
assert(VirtualProtect(pages+info.dwPageSize,info.dwPageSize,PAGE_NOACCESS,&old));
|
||||
auto* end=pages+info.dwPageSize;
|
||||
end[-4]=0x11;end[-3]=0x22;end[-2]=0x33;end[-1]=0x44;
|
||||
assert(sigscan::parse("?? 22 33 44",pattern));
|
||||
assert(sigscan::scan_range(end-4,end,pattern)==end-4);
|
||||
assert(sigscan::scan_range(end-3,end,pattern)==nullptr);
|
||||
assert(sigscan::parse("?? 22 33 45",pattern));
|
||||
assert(sigscan::scan_range(end-4,end,pattern)==nullptr);
|
||||
assert(VirtualFree(pages,0,MEM_RELEASE));
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
#pragma once
|
||||
#include "../src/gui/startup_intro.h"
|
||||
|
||||
inline void test_startup_intro() {
|
||||
using startup_intro::stage;
|
||||
float progress=startup_intro::completion(stage::hooks,0,0);
|
||||
for(unsigned i=0;i<=36;++i) {
|
||||
const float next=startup_intro::completion(stage::modules,i,36);
|
||||
assert(next>=progress && next<1);progress=next;
|
||||
}
|
||||
for(auto phase:{stage::input,stage::profile,stage::hud,stage::ready}) {
|
||||
const float next=startup_intro::completion(phase,36,36);
|
||||
assert(next>=progress && next<=1);progress=next;
|
||||
}
|
||||
assert(progress==1 && startup_intro::completion(stage::modules,100,36)==.75f);
|
||||
assert(startup_intro::completion(stage::modules,0,0)==.35f);
|
||||
|
||||
using startup_intro::playback;
|
||||
playback clock;
|
||||
assert(clock.step(0,false)==0); // No startup delay.
|
||||
for(int i=1;i<=600;++i) {
|
||||
const auto age=clock.step(i/60.0,false);
|
||||
assert(age>=0 && age<=startup_intro::hold_age && !clock.finished);
|
||||
}
|
||||
assert(clock.age==startup_intro::hold_age);
|
||||
double now=10;
|
||||
assert(clock.step(now+=.1,true)>startup_intro::hold_age);
|
||||
for(int i=0;i<200;++i)clock.step(now+=1.0/60,true);
|
||||
assert(clock.finished && clock.step(now+1,true)<0);
|
||||
|
||||
playback startup_stall;
|
||||
startup_stall.step(0,true);
|
||||
const float before=startup_stall.step(.1,true);
|
||||
assert(startup_stall.step(8,true)<before+.02f); // Stall doesn't skip animation.
|
||||
playback skipped;
|
||||
assert(skipped.step(0,false,true)==startup_intro::hold_age && !skipped.finished);
|
||||
assert(skipped.step(20,false,true)==startup_intro::hold_age && !skipped.finished);
|
||||
now=20;
|
||||
for(int i=0;i<100;++i)skipped.step(now+=1.0/60,true,true);
|
||||
assert(skipped.finished); // Skip cannot bypass the readiness gate.
|
||||
|
||||
ImGui::CreateContext();auto& io=ImGui::GetIO();
|
||||
io.DisplaySize={1280,720};io.DeltaTime=.016f;
|
||||
io.Fonts->AddFontDefault();unsigned char* pixels;int width,height;
|
||||
io.Fonts->GetTexDataAsRGBA32(&pixels,&width,&height);
|
||||
Microsoft::WRL::ComPtr<ID3D11Device> device;
|
||||
assert(SUCCEEDED(D3D11CreateDevice(nullptr,D3D_DRIVER_TYPE_WARP,nullptr,0,nullptr,0,
|
||||
D3D11_SDK_VERSION,&device,nullptr,nullptr)));
|
||||
startup_intro::initialize_texture(device.Get());assert(startup_intro::texture);
|
||||
for(ImVec2 screen : {ImVec2{320,240},ImVec2{1280,720},ImVec2{3440,1440}}) {
|
||||
io.DisplaySize=screen;
|
||||
for(float age : {-1.f,0.f,.15f,.5f,1.25f,2.3f,2.7f,2.8f,5.f}) {
|
||||
ImGui::NewFrame();startup_intro::render(age,screen,.5f,"loading modules",age);ImGui::Render();
|
||||
auto* data=ImGui::GetDrawData();
|
||||
if(age<0 || age>=startup_intro::duration)assert(data->TotalVtxCount==0);
|
||||
else assert(data->TotalVtxCount>0);
|
||||
if(age==0) {
|
||||
// The first frame already covers gameplay with opaque pixels.
|
||||
const auto* list=data->CmdLists[0];
|
||||
for(int i=0;i<4;++i)assert((list->VtxBuffer[i].col>>IM_COL32_A_SHIFT)==255);
|
||||
}
|
||||
assert(data->TotalVtxCount<8000);
|
||||
for(int i=0;i<data->CmdListsCount;++i)
|
||||
for(const auto& vertex:data->CmdLists[i]->VtxBuffer)
|
||||
assert(std::isfinite(vertex.pos.x) && std::isfinite(vertex.pos.y));
|
||||
}
|
||||
}
|
||||
ImVec2 texture_position[2];
|
||||
for(int i=0;i<2;++i) {
|
||||
ImGui::NewFrame();startup_intro::render(startup_intro::hold_age,io.DisplaySize,.5f,"loading modules",double(i));ImGui::Render();
|
||||
texture_position[i]=ImGui::GetDrawData()->CmdLists[0]->VtxBuffer[4].pos;
|
||||
}
|
||||
assert(texture_position[0].x!=texture_position[1].x || texture_position[0].y!=texture_position[1].y);
|
||||
startup_intro::texture.Reset();
|
||||
ImGui::DestroyContext();
|
||||
std::cout<<"PASS: opaque readiness-gated intro, real loading-stage progress, GPU grain texture/motion and responsive geometry\n";
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
#pragma once
|
||||
#include "../src/gui/widgets.h"
|
||||
#include "../src/gui/indent_section.h"
|
||||
#include "imgui_internal.h"
|
||||
|
||||
inline void test_style_widgets() {
|
||||
ImGui::CreateContext();auto& io=ImGui::GetIO();io.IniFilename=nullptr;
|
||||
io.DisplaySize={800,600};io.DeltaTime=1.f/60;io.ConfigInputTrickleEventQueue=false;
|
||||
io.Fonts->AddFontDefault();unsigned char* pixels;int width,height;io.Fonts->GetTexDataAsRGBA32(&pixels,&width,&height);
|
||||
theme::apply();
|
||||
bool checked=false,open=false;int integer=25,selected=0;float number=.5f;
|
||||
char text[32]="amnesia";ImVec2 check_pos{},slider_pos{},combo_pos{};
|
||||
auto frame=[&](ImVec2 mouse,bool down) {
|
||||
io.AddMousePosEvent(mouse.x,mouse.y);io.AddMouseButtonEvent(0,down);
|
||||
ImGui::NewFrame();ImGui::SetNextWindowPos({20,20});ImGui::SetNextWindowSize({400,520});
|
||||
ImGui::Begin("style controls",nullptr,ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_NoMove);
|
||||
auto* draw=ImGui::GetWindowDrawList();draw->ChannelsSplit(2);draw->ChannelsSetCurrent(1);
|
||||
check_pos=ImGui::GetCursorScreenPos();widgets::checkbox("toggle",&checked,260,24);
|
||||
widgets::slider_int("integer",&integer,0,100,260);slider_pos=ImGui::GetItemRectMin();
|
||||
widgets::slider_float("float",&number,0,1,260);
|
||||
widgets::input_text("##text",text,sizeof(text),260);
|
||||
combo_pos=ImGui::GetCursorScreenPos();open=widgets::begin_combo("##mode",selected ? "second" : "first",260);
|
||||
if(open) {
|
||||
if(widgets::selectable("first",selected==0))selected=0;
|
||||
if(widgets::selectable("second",selected==1))selected=1;
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
widgets::button("action","apply",false,260,26);
|
||||
draw->ChannelsMerge();ImGui::End();
|
||||
assert(GImGui->ColorStack.empty() && GImGui->StyleVarStack.empty());
|
||||
ImGui::Render();
|
||||
for(int i=0;i<ImGui::GetDrawData()->CmdListsCount;++i)
|
||||
for(const auto& v:ImGui::GetDrawData()->CmdLists[i]->VtxBuffer)
|
||||
assert(std::isfinite(v.pos.x) && std::isfinite(v.pos.y));
|
||||
};
|
||||
frame({-100,-100},false);
|
||||
const auto initial_check=check_pos,initial_slider=slider_pos,initial_combo=combo_pos;
|
||||
frame({check_pos.x+7,check_pos.y+10},false);frame({check_pos.x+7,check_pos.y+10},true);frame({check_pos.x+7,check_pos.y+10},false);
|
||||
assert(checked);
|
||||
frame({slider_pos.x+200,slider_pos.y+10},false);frame({slider_pos.x+200,slider_pos.y+10},true);frame({slider_pos.x+200,slider_pos.y+10},false);
|
||||
assert(integer>65 && integer<90 && number==.5f && std::string(text)=="amnesia");
|
||||
assert(check_pos.x==initial_check.x && check_pos.y==initial_check.y);
|
||||
assert(slider_pos.x==initial_slider.x && slider_pos.y==initial_slider.y);
|
||||
assert(combo_pos.x==initial_combo.x && combo_pos.y==initial_combo.y);
|
||||
frame({combo_pos.x+100,combo_pos.y+10},false);frame({combo_pos.x+100,combo_pos.y+10},true);frame({combo_pos.x+100,combo_pos.y+10},false);
|
||||
assert(open);
|
||||
// The settings reveal must move following rows, preserve scrolling bounds,
|
||||
// and prevent partially revealed controls from accepting clicks.
|
||||
float measured=0;bool activated=false;
|
||||
auto reveal_frame=[&](float amount,ImVec2 mouse,bool down) {
|
||||
io.AddMousePosEvent(mouse.x,mouse.y);io.AddMouseButtonEvent(0,down);
|
||||
ImGui::NewFrame();ImGui::SetNextWindowPos({20,20});ImGui::SetNextWindowSize({400,520});
|
||||
ImGui::Begin("reveal",nullptr,ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_NoMove);
|
||||
const auto start=ImGui::GetCursorScreenPos();
|
||||
widgets::indent_section(260,start.y,amount,measured,amount==1,[&](float w) {
|
||||
ImGui::TextUnformatted("settings");
|
||||
activated|=widgets::button("hidden action","apply",false,w,22);
|
||||
});
|
||||
const float occupied=ImGui::GetItemRectSize().y;
|
||||
assert(std::abs(occupied-measured*amount)<.01f);
|
||||
assert(ImGui::GetCurrentWindow()->DC.CursorMaxPos.y<=start.y+occupied+.01f);
|
||||
const float below=ImGui::GetCursorScreenPos().y;
|
||||
ImGui::Button("next module",{260,26});ImGui::End();
|
||||
assert(GImGui->ColorStack.empty() && GImGui->StyleVarStack.empty() && GImGui->GroupStack.empty());
|
||||
ImGui::Render();return below;
|
||||
};
|
||||
const float full=reveal_frame(1,{-100,-100},false);
|
||||
const float half=reveal_frame(.5f,{-100,-100},false);
|
||||
const float closed=reveal_frame(0,{-100,-100},false);
|
||||
assert(full>half && half>closed);
|
||||
// A click at the lower action's full-size location cannot fire while sliding.
|
||||
reveal_frame(.5f,{80,full-13},false);reveal_frame(.5f,{80,full-13},true);reveal_frame(.5f,{80,full-13},false);
|
||||
assert(!activated);
|
||||
float a=0,b=0;
|
||||
for(int i=0;i<12;++i)a=widgets::expand_step(a,true,1.f/60);
|
||||
for(int i=0;i<24;++i)b=widgets::expand_step(b,true,1.f/120);
|
||||
assert(std::abs(a-b)<.00001f && a>0 && a<1);
|
||||
assert(widgets::expand_step(a,false,1.f/60)<a);
|
||||
ImGui::DestroyContext();
|
||||
std::cout<<"PASS: styled checkbox/slider interaction, stable row layout, nested draw layers and balanced dropdown style stacks\n";
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
#pragma once
|
||||
#include "../src/window_branding.h"
|
||||
#include <future>
|
||||
|
||||
inline LRESULT CALLBACK branding_test_proc(HWND hwnd,UINT msg,WPARAM wp,LPARAM lp) {
|
||||
if(window_branding::handle_message(hwnd,msg,wp,lp))return 0;
|
||||
return DefWindowProcW(hwnd,msg,wp,lp);
|
||||
}
|
||||
inline void pump_branding_messages() {
|
||||
MSG message{};
|
||||
while(PeekMessageW(&message,nullptr,0,0,PM_REMOVE))DispatchMessageW(&message);
|
||||
}
|
||||
|
||||
inline void test_window_branding() {
|
||||
PACKAGE_VERSION version{};version.Major=1;version.Minor=26;version.Build=5203;
|
||||
assert(window_branding::display_version(version)==L"26.52");
|
||||
version.Minor=21;version.Build=11401;
|
||||
assert(window_branding::display_version(version)==L"1.21.114");
|
||||
const auto module=GetModuleHandleW(nullptr);
|
||||
WNDCLASSW wc{};wc.hInstance=module;wc.lpfnWndProc=branding_test_proc;wc.lpszClassName=L"AmnesiaBrandingTest";
|
||||
assert(RegisterClassW(&wc));
|
||||
HWND hwnd=CreateWindowExW(0,wc.lpszClassName,L"Original Minecraft title",WS_OVERLAPPEDWINDOW,
|
||||
0,0,300,200,nullptr,nullptr,module,nullptr);
|
||||
assert(hwnd);
|
||||
auto original_small=LoadIcon(nullptr,IDI_WARNING),original_large=LoadIcon(nullptr,IDI_ERROR);
|
||||
SendMessageW(hwnd,WM_SETICON,ICON_SMALL,reinterpret_cast<LPARAM>(original_small));
|
||||
SendMessageW(hwnd,WM_SETICON,ICON_BIG,reinterpret_cast<LPARAM>(original_large));
|
||||
for(int i=0;i<2;++i) {
|
||||
// Simulate Present running while the UI thread cannot pump messages.
|
||||
// Scheduling must finish without waiting for any UI response.
|
||||
auto render=std::async(std::launch::async,[=] {
|
||||
window_branding::install(hwnd,module);
|
||||
window_branding::next_check=0;window_branding::tick();
|
||||
});
|
||||
assert(render.wait_for(std::chrono::milliseconds(500))==std::future_status::ready);
|
||||
render.get();assert(!window_branding::window);
|
||||
pump_branding_messages();
|
||||
assert(window_branding::icon_small && window_branding::icon_large);
|
||||
assert(window_branding::window_title(hwnd).find(L"amnesia // minecraft")==0);
|
||||
assert(reinterpret_cast<HICON>(SendMessageW(hwnd,WM_GETICON,ICON_SMALL,0))==window_branding::icon_small);
|
||||
SetWindowTextW(hwnd,L"Game changed title");
|
||||
SendMessageW(hwnd,WM_SETICON,ICON_BIG,0);
|
||||
window_branding::next_check=0;window_branding::tick();
|
||||
pump_branding_messages();
|
||||
assert(window_branding::window_title(hwnd)==window_branding::title);
|
||||
assert(reinterpret_cast<HICON>(SendMessageW(hwnd,WM_GETICON,ICON_BIG,0))==window_branding::icon_large);
|
||||
auto unload=std::async(std::launch::async,[] {window_branding::shutdown();});
|
||||
const auto deadline=GetTickCount64()+2000;
|
||||
while(unload.wait_for(std::chrono::milliseconds(0))!=std::future_status::ready && GetTickCount64()<deadline) {
|
||||
pump_branding_messages();Sleep(1);
|
||||
}
|
||||
assert(unload.wait_for(std::chrono::milliseconds(0))==std::future_status::ready);unload.get();
|
||||
assert(window_branding::window_title(hwnd)==L"Original Minecraft title");
|
||||
assert(reinterpret_cast<HICON>(SendMessageW(hwnd,WM_GETICON,ICON_SMALL,0))==original_small);
|
||||
assert(reinterpret_cast<HICON>(SendMessageW(hwnd,WM_GETICON,ICON_BIG,0))==original_large);
|
||||
assert(!window_branding::window && !window_branding::icon_small && !window_branding::icon_large);
|
||||
}
|
||||
// An unload before the first posted update must not brand the window later.
|
||||
window_branding::install(hwnd,module);window_branding::shutdown();pump_branding_messages();
|
||||
assert(window_branding::window_title(hwnd)==L"Original Minecraft title" && !window_branding::window);
|
||||
DestroyWindow(hwnd);window_branding::shutdown();UnregisterClassW(wc.lpszClassName,module);
|
||||
std::cout<<"PASS: asynchronous window branding without a pumping UI thread, embedded icons and unload restoration\n";
|
||||
}
|
||||
+33
-2
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#include <set>
|
||||
#include "../src/modules/world_modules.h"
|
||||
#include "../src/modules/fps_counter.h"
|
||||
#include "../src/modules/keystrokes.h"
|
||||
@@ -106,8 +107,38 @@ inline void test_world_filter() {
|
||||
D3D11_MAPPED_SUBRESOURCE mapped{};assert(SUCCEEDED(context->Map(staging.Get(),0,D3D11_MAP_READ,0,&mapped)));
|
||||
auto* pixel=static_cast<unsigned char*>(mapped.pData)+16*mapped.RowPitch+16*4;
|
||||
assert(std::abs(int(pixel[0])-128)<=1 && std::abs(int(pixel[1])-64)<=1 && std::abs(int(pixel[2])-32)<=1 && pixel[3]==255);
|
||||
context->Unmap(staging.Get(),0);enabled=false;assert(!apply(device.Get(),context.Get(),rt));shutdown();
|
||||
std::cout<<"PASS: actual D3D11 color/darkness shader and render-state restoration (WARP)\n";
|
||||
context->Unmap(staging.Get(),0);
|
||||
auto read_pixel=[&](int x,int y) {
|
||||
context->CopyResource(staging.Get(),output.Get());
|
||||
D3D11_MAPPED_SUBRESOURCE data{};assert(SUCCEEDED(context->Map(staging.Get(),0,D3D11_MAP_READ,0,&data)));
|
||||
const auto* p=static_cast<unsigned char*>(data.pData)+y*data.RowPitch+x*4;
|
||||
const std::array<int,3> result{p[0],p[1],p[2]};context->Unmap(staging.Get(),0);return result;
|
||||
};
|
||||
tint=IM_COL32_WHITE;brightness=1;
|
||||
grading grade;grade.saturation=0;configure(grade);
|
||||
const float blue[4]={.2f,.4f,.8f,1};context->ClearRenderTargetView(rt,blue);assert(apply(device.Get(),context.Get(),rt));
|
||||
const auto gray=read_pixel(16,16);assert(std::abs(gray[0]-gray[1])<=1 && std::abs(gray[1]-gray[2])<=1);
|
||||
grade={};grade.vignette=.8f;configure(grade);context->ClearRenderTargetView(rt,white);assert(apply(device.Get(),context.Get(),rt));
|
||||
assert(read_pixel(16,16)[0]>read_pixel(0,0)[0]+30);
|
||||
grade={};grade.shadows=IM_COL32(255,0,0,255);grade.highlights=IM_COL32(255,0,0,255);configure(grade);
|
||||
context->ClearRenderTargetView(rt,blue);assert(apply(device.Get(),context.Get(),rt));const auto toned=read_pixel(16,16);assert(toned[0]>51 && toned[2]<204);
|
||||
ImGui::CreateContext();atmosphere looks;
|
||||
auto setting=[&](const char* name)->struct setting& {for(auto& s:looks.settings())if(s.name==name)return s;assert(false);return looks.settings().front();};
|
||||
std::set<std::array<int,3>> results;
|
||||
for(int preset=0;preset<7;++preset) {
|
||||
setting("look preset").int_value=preset;setting("apply selected look").action();looks.on_render();
|
||||
assert(enabled && world::fog_enabled);
|
||||
context->ClearRenderTargetView(rt,blue);assert(apply(device.Get(),context.Get(),rt));results.insert(read_pixel(16,16));
|
||||
D3D11_PRIMITIVE_TOPOLOGY restored_topology;context->IAGetPrimitiveTopology(&restored_topology);
|
||||
assert(restored_topology==D3D11_PRIMITIVE_TOPOLOGY_LINELIST);
|
||||
}
|
||||
assert(results.size()>=5);
|
||||
setting("palette animation").int_value=1;looks.on_render();const auto first=tint.load();
|
||||
GImGui->Time+=5;looks.on_render();assert(tint!=first);
|
||||
setting("reset atmosphere").action();looks.on_render();assert(!enabled && configuration().bloom==0 && configuration().contrast==1);
|
||||
looks.on_disable();assert(!world::fog_enabled);ImGui::DestroyContext();
|
||||
enabled=false;assert(!apply(device.Get(),context.Get(),rt));shutdown();
|
||||
std::cout<<"PASS: actual D3D11 grading, vignette, split tones, seven presets, palette animation/reset and render-state restoration (WARP)\n";
|
||||
}
|
||||
|
||||
inline void test_world_huds() {
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
#pragma once
|
||||
#include "../src/game/world_weather.h"
|
||||
inline void test_world_weather(D3D_DRIVER_TYPE driver=D3D_DRIVER_TYPE_WARP) {
|
||||
using namespace world_weather;
|
||||
float matrix[16]{};matrix[0]=matrix[5]=1;matrix[10]=-1.001f;matrix[11]=-1;matrix[14]=-.1f;
|
||||
projection found;assert(find_projection(matrix,16,1,1,found) && found.b<0);
|
||||
assert(!find_projection(matrix,16,2,1,found));matrix[15]=1;assert(!find_projection(matrix,16,1,1,found));
|
||||
matrix[15]=0;matrix[10]=0;matrix[14]=.1f;assert(find_projection(matrix,16,1,1,found) && found.b>0);
|
||||
matrix[10]=-1.001f;matrix[14]=-.1f;
|
||||
ComPtr<ID3D11Device> device;ComPtr<ID3D11DeviceContext> context;
|
||||
const D3D_FEATURE_LEVEL levels[]={D3D_FEATURE_LEVEL_12_1,D3D_FEATURE_LEVEL_12_0,D3D_FEATURE_LEVEL_11_1,D3D_FEATURE_LEVEL_11_0};
|
||||
assert(SUCCEEDED(D3D11CreateDevice(nullptr,driver,nullptr,0,levels,4,D3D11_SDK_VERSION,&device,nullptr,&context)));
|
||||
D3D11_TEXTURE2D_DESC td{};td.Width=td.Height=256;td.MipLevels=td.ArraySize=1;td.SampleDesc.Count=1;
|
||||
td.Format=DXGI_FORMAT_R8G8B8A8_UNORM;td.BindFlags=D3D11_BIND_RENDER_TARGET;
|
||||
ComPtr<ID3D11Texture2D> image;ComPtr<ID3D11RenderTargetView> target;
|
||||
assert(SUCCEEDED(device->CreateTexture2D(&td,nullptr,&image)));assert(SUCCEEDED(device->CreateRenderTargetView(image.Get(),nullptr,&target)));
|
||||
td.Format=DXGI_FORMAT_D32_FLOAT;td.BindFlags=D3D11_BIND_DEPTH_STENCIL;
|
||||
ComPtr<ID3D11Texture2D> depth_texture;ComPtr<ID3D11DepthStencilView> dsv;
|
||||
assert(SUCCEEDED(device->CreateTexture2D(&td,nullptr,&depth_texture)));assert(SUCCEEDED(device->CreateDepthStencilView(depth_texture.Get(),nullptr,&dsv)));
|
||||
td.Format=DXGI_FORMAT_R8G8B8A8_UNORM;td.BindFlags=0;td.Usage=D3D11_USAGE_STAGING;td.CPUAccessFlags=D3D11_CPU_ACCESS_READ;
|
||||
ComPtr<ID3D11Texture2D> staging;assert(SUCCEEDED(device->CreateTexture2D(&td,nullptr,&staging)));
|
||||
ID3D11RenderTargetView* rt=target.Get();context->OMSetRenderTargets(1,&rt,dsv.Get());
|
||||
D3D11_VIEWPORT viewport{0,0,256,256,0,1};context->RSSetViewports(1,&viewport);
|
||||
context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_LINELIST);
|
||||
D3D11_BUFFER_DESC bd{};bd.ByteWidth=64;bd.BindFlags=D3D11_BIND_CONSTANT_BUFFER;D3D11_SUBRESOURCE_DATA initial{matrix,0,0};
|
||||
ComPtr<ID3D11Buffer> native_cb;assert(SUCCEEDED(device->CreateBuffer(&bd,&initial,&native_cb)));
|
||||
ID3D11Buffer* cb=native_cb.Get();context->VSSetConstantBuffers(0,1,&cb);
|
||||
world::frame scene;scene.valid=true;scene.fov_x=scene.fov_y=1;scene.matrix[0]=scene.matrix[5]=scene.matrix[10]=scene.matrix[15]=1;
|
||||
enabled=true;expected_x=expected_y=1;
|
||||
observe({matrix,sizeof(matrix),reinterpret_cast<uintptr_t>(native_cb.Get())});
|
||||
assert(discover(device.Get(),context.Get(),scene,found) && found.b<0);
|
||||
settings options;options.snow=1;options.radius=8;options.snow_color=IM_COL32(255,0,0,255);
|
||||
auto render=[&](float clear_depth,projection p,float camera_x) {
|
||||
const float black[4]{0,0,0,1};context->ClearRenderTargetView(rt,black);context->ClearDepthStencilView(dsv.Get(),D3D11_CLEAR_DEPTH,clear_depth,0);
|
||||
scene.camera.x=camera_x;assert(draw(device.Get(),context.Get(),scene,rt,dsv.Get(),viewport,p,options,3.5));
|
||||
D3D11_PRIMITIVE_TOPOLOGY topology;context->IAGetPrimitiveTopology(&topology);assert(topology==D3D11_PRIMITIVE_TOPOLOGY_LINELIST);
|
||||
ComPtr<ID3D11RenderTargetView> restored;ComPtr<ID3D11DepthStencilView> restored_depth;context->OMGetRenderTargets(1,&restored,&restored_depth);
|
||||
assert(restored.Get()==rt && restored_depth.Get()==dsv.Get());
|
||||
ComPtr<ID3D11Buffer> restored_cb;context->VSGetConstantBuffers(0,1,&restored_cb);assert(restored_cb.Get()==native_cb.Get());
|
||||
context->CopyResource(staging.Get(),image.Get());D3D11_MAPPED_SUBRESOURCE map{};assert(SUCCEEDED(context->Map(staging.Get(),0,D3D11_MAP_READ,0,&map)));
|
||||
uint64_t sum=0,hash=0;for(int y=0;y<256;++y)for(int x=0;x<256;++x) {auto* pixel=static_cast<unsigned char*>(map.pData)+y*map.RowPitch+x*4;sum+=pixel[0];hash=hash*31+pixel[0];}
|
||||
context->Unmap(staging.Get(),0);return std::make_pair(sum,hash);
|
||||
};
|
||||
const auto visible=render(1,{-1.001f,-.1f},0);assert(visible.first>0);
|
||||
assert(render(0,{-1.001f,-.1f},0).first==0);
|
||||
assert(render(1,{-1.001f,-.1f},.5f).second!=visible.second);
|
||||
assert(render(0,{0,.1f},0).first>0);assert(render(1,{0,.1f},0).first==0);
|
||||
options.snow=0;options.rain=1;options.rain_color=IM_COL32(255,0,0,255);assert(render(1,{-1.001f,-.1f},0).first>0);
|
||||
// Read the actual camera-layout projection path without any GPU staging copy.
|
||||
alignas(16) unsigned char client_data[0x800]{},renderer_data[0x500]{},camera_data[0x1100]{};
|
||||
const auto old_client=world::client.load();world::client=reinterpret_cast<uintptr_t>(client_data);
|
||||
const uintptr_t renderer_pointer=reinterpret_cast<uintptr_t>(renderer_data),camera_pointer=reinterpret_cast<uintptr_t>(camera_data);
|
||||
memcpy(client_data+0x1c0,&renderer_pointer,sizeof(renderer_pointer));memcpy(renderer_data+0x468,&camera_pointer,sizeof(camera_pointer));
|
||||
float camera_projection_data[16]{};memcpy(camera_projection_data,matrix,sizeof(matrix));camera_projection_data[14]=-.025f;
|
||||
memcpy(camera_data+0xf58,camera_projection_data,sizeof(camera_projection_data));
|
||||
assert(camera_projection(scene));assert(discover(device.Get(),context.Get(),scene,found) && std::abs(found.b+.025f)<.000001f);
|
||||
camera_projection_data[14]=-.05f;camera_projection_data[10]=-1.002f;memcpy(camera_data+0xf58,camera_projection_data,sizeof(camera_projection_data));
|
||||
assert(camera_projection(scene));assert(discover(device.Get(),context.Get(),scene,found) && std::abs(found.a+1.001f)<.00001f && std::abs(found.b+.025f)<.000001f);
|
||||
world::client=old_client;
|
||||
// Run both upload observers against the real adapter without staging readback.
|
||||
original_update=+[](ID3D11DeviceContext* c,ID3D11Resource* r,UINT sub,const D3D11_BOX* box,const void* data,UINT row,UINT depth){c->UpdateSubresource(r,sub,box,data,row,depth);};
|
||||
cached_buffer=0;enabled=true;update_detour(context.Get(),native_cb.Get(),0,nullptr,matrix,0,0);
|
||||
assert(discover(device.Get(),context.Get(),scene,found));
|
||||
draw_context=context.Get();draw_thread=GetCurrentThreadId();
|
||||
static int boundaries=0;boundaries=0;
|
||||
before_target_change=+[](ID3D11DeviceContext* c){ComPtr<ID3D11DepthStencilView> d;c->OMGetRenderTargets(0,nullptr,&d);assert(d);++boundaries;};
|
||||
target_boundary(context.Get(),dsv.Get());assert(boundaries==0);
|
||||
target_boundary(context.Get(),nullptr);assert(boundaries==1);
|
||||
before_target_change=nullptr;
|
||||
shutdown();assert(!enabled && !vs);
|
||||
std::cout<<"PASS: world-space rain/snow shaders, native projection matching, standard/reverse depth occlusion, camera parallax and complete pipeline restoration (GPU)\n";
|
||||
}
|
||||
Vendored
+169
@@ -0,0 +1,169 @@
|
||||
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 freetype@nongnu.org
|
||||
|
||||
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 freetype-devel@nongnu.org
|
||||
|
||||
Discusses bugs, as well as engine internals, design issues,
|
||||
specific licenses, porting, etc.
|
||||
|
||||
Our home page can be found at
|
||||
|
||||
https://www.freetype.org
|
||||
|
||||
|
||||
--- end of FTL.TXT ---
|
||||
Vendored
+39
@@ -0,0 +1,39 @@
|
||||
|
||||
The FreeType 2 font engine is copyrighted work and cannot be used
|
||||
legally without a software license. In order to make this project
|
||||
usable to a vast majority of developers, we distribute it under two
|
||||
mutually exclusive open-source licenses.
|
||||
|
||||
This means that *you* must choose *one* of the two licenses described
|
||||
below, then obey all its terms and conditions when using FreeType 2 in
|
||||
any of your projects or products.
|
||||
|
||||
- The FreeType License, found in the file `FTL.TXT', which is similar
|
||||
to the original BSD license *with* an advertising clause that forces
|
||||
you to explicitly cite the FreeType project in your product's
|
||||
documentation. All details are in the license file. This license
|
||||
is suited to products which don't use the GNU General Public
|
||||
License.
|
||||
|
||||
Note that this license is compatible to the GNU General Public
|
||||
License version 3, but not version 2.
|
||||
|
||||
- The GNU General Public License version 2, found in `GPLv2.TXT' (any
|
||||
later version can be used also), for programs which already use the
|
||||
GPL. Note that the FTL is incompatible with GPLv2 due to its
|
||||
advertisement clause.
|
||||
|
||||
The contributed BDF and PCF drivers come with a license similar to that
|
||||
of the X Window System. It is compatible to the above two licenses (see
|
||||
file src/bdf/README and src/pcf/README). The same holds for the files
|
||||
`fthash.c' and `fthash.h'; their code was part of the BDF driver in
|
||||
earlier FreeType versions.
|
||||
|
||||
The gzip module uses the zlib license (see src/gzip/zlib.h) which too is
|
||||
compatible to the above two licenses.
|
||||
|
||||
The MD5 checksum support (only used for debugging in development builds)
|
||||
is in the public domain.
|
||||
|
||||
|
||||
--- end of LICENSE.TXT ---
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
# FreeType dependency
|
||||
|
||||
Headers and static x64 library copied from the user's reference project:
|
||||
`D:/projects/menus/bitchbot/src/vendor/freetype`.
|
||||
The source project remains unchanged. This copy makes client builds independent
|
||||
of that external directory. The header set identifies itself as 2.9.1.
|
||||
|
||||
FreeType is linked into the client; no additional runtime DLL is required.
|
||||
`freetype.props` enables ImGui's FreeType loader in the DLL, tests and preview.
|
||||
The archive's C runtime references resolve against each target's existing CRT.
|
||||
Only missing debug symbols in the precompiled archive are suppressed.
|
||||
|
||||
This software uses the FreeType project (https://freetype.org), distributed
|
||||
under the FreeType License in FTL.TXT. Copyright 1996-2018 David Turner,
|
||||
Robert Wilhelm, and Werner Lemberg. See LICENSE.TXT for upstream licensing.
|
||||
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>IMGUI_ENABLE_FREETYPE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<!-- Reference archive is static C code; resolve its CRT calls against the host runtime. -->
|
||||
<IgnoreSpecificDefaultLibraries>LIBCMT;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||
<AdditionalOptions>/ignore:4099 %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalDependencies>$(MSBuildThisFileDirectory)lib\freetype.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup><ClCompile Include="$(MSBuildThisFileDirectory)..\imgui\misc\freetype\imgui_freetype.cpp" /></ItemGroup>
|
||||
</Project>
|
||||
+571
@@ -0,0 +1,571 @@
|
||||
/***************************************************************************/
|
||||
/* */
|
||||
/* ftconfig.h */
|
||||
/* */
|
||||
/* ANSI-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. */
|
||||
/* */
|
||||
/* This ANSI version should stay in `include/config/'. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
#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. */
|
||||
/* */
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/* 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
|
||||
|
||||
|
||||
/* 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
|
||||
|
||||
|
||||
/* 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 == ( 32 / FT_CHAR_BIT )
|
||||
|
||||
typedef signed int FT_Int32;
|
||||
typedef unsigned int FT_UInt32;
|
||||
|
||||
#elif FT_SIZEOF_LONG == ( 32 / FT_CHAR_BIT )
|
||||
|
||||
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 >= ( 32 / FT_CHAR_BIT )
|
||||
|
||||
typedef int FT_Fast;
|
||||
typedef unsigned int FT_UFast;
|
||||
|
||||
#elif FT_SIZEOF_LONG >= ( 32 / FT_CHAR_BIT )
|
||||
|
||||
typedef long FT_Fast;
|
||||
typedef unsigned long FT_UFast;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* determine whether we have a 64-bit int type for platforms without */
|
||||
/* Autoconf */
|
||||
#if FT_SIZEOF_LONG == ( 64 / FT_CHAR_BIT )
|
||||
|
||||
/* FT_LONG64 must be defined if a 64-bit type is available */
|
||||
#define FT_LONG64
|
||||
#define FT_INT64 long
|
||||
#define FT_UINT64 unsigned long
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* 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 == (64 / FT_CHAR_BIT) */
|
||||
|
||||
#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 */
|
||||
+804
@@ -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,32 @@
|
||||
/*
|
||||
* This file registers the FreeType modules compiled into the library.
|
||||
*
|
||||
* If you use GNU make, this file IS NOT USED! Instead, it is created in
|
||||
* the objects directory (normally `<topdir>/objs/') based on information
|
||||
* from `<topdir>/modules.cfg'.
|
||||
*
|
||||
* Please read `docs/INSTALL.ANY' and `docs/CUSTOMIZE' how to compile
|
||||
* FreeType without GNU make.
|
||||
*
|
||||
*/
|
||||
|
||||
FT_USE_MODULE( FT_Module_Class, autofit_module_class )
|
||||
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_Module_Class, psaux_module_class )
|
||||
FT_USE_MODULE( FT_Module_Class, psnames_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_Module_Class, sfnt_module_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_Driver_ClassRec, bdf_driver_class )
|
||||
|
||||
/* EOF */
|
||||
+977
@@ -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. */
|
||||
/* */
|
||||
/* #define 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. */
|
||||
/* */
|
||||
/* #define 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 <steven.f.chu@gmail.com> */
|
||||
/* */
|
||||
/* [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 */
|
||||
+175
@@ -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 */
|
||||
+4657
File diff suppressed because it is too large.
Load diff
+187
@@ -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 */
|
||||
+101
@@ -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: */
|
||||
+210
@@ -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 */
|
||||
+240
@@ -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 */
|
||||
+102
@@ -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 */
|
||||
+1042
File diff suppressed because it is too large.
Load diff
+139
@@ -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 */
|
||||
/* */
|
||||
/***************************************************************************/
|
||||
+168
@@ -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 */
|
||||
+1225
File diff suppressed because it is too large.
Load diff
+280
@@ -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 */
|
||||
+226
@@ -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 */
|
||||
+95
@@ -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 */
|
||||
+142
@@ -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 */
|
||||
+614
@@ -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: */
|
||||
+357
@@ -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 */
|
||||
+151
@@ -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 */
|
||||
+1205
File diff suppressed because it is too large.
Load diff
+343
@@ -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 */
|
||||
+309
@@ -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 */
|
||||
+276
@@ -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 */
|
||||
+99
@@ -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 */
|
||||
+275
@@ -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 */
|
||||
+638
@@ -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 */
|
||||
+711
@@ -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 */
|
||||
+194
@@ -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 */
|
||||
+204
@@ -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 */
|
||||
+582
@@ -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: */
|
||||
+205
@@ -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 */
|
||||
+172
@@ -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 */
|
||||
+233
@@ -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 */
|
||||
+159
@@ -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 */
|
||||
+253
@@ -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 */
|
||||
+785
@@ -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: */
|
||||
Loaded 100 of 155 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user