From 40773d41fa7898e7f03b0de011a9740061ade0aa Mon Sep 17 00:00:00 2001 From: Amlal Date: Mon, 24 Feb 2025 09:07:56 +0100 Subject: Add LibFont and LibLocale, port structs that I made for app-kit to LibCF too. Signed-off-by: Amlal --- dev/Kernel/NetworkKit/MAC.h | 4 +++- dev/Usr/LibCF/Core.cc | 48 ++++++++++++++++++++++++++++++++++++++ dev/Usr/LibCF/Core.h | 57 ++++++++++++++++++++++++++++++++++++++++++++- dev/Usr/LibFont/.keep | 0 dev/Usr/LibFont/Font.h | 55 +++++++++++++++++++++++++++++++++++++++++++ dev/Usr/LibLocale/.keep | 0 6 files changed, 162 insertions(+), 2 deletions(-) create mode 100644 dev/Usr/LibCF/Core.cc create mode 100644 dev/Usr/LibFont/.keep create mode 100644 dev/Usr/LibFont/Font.h create mode 100644 dev/Usr/LibLocale/.keep (limited to 'dev') diff --git a/dev/Kernel/NetworkKit/MAC.h b/dev/Kernel/NetworkKit/MAC.h index f9be61a0..4ea05b70 100644 --- a/dev/Kernel/NetworkKit/MAC.h +++ b/dev/Kernel/NetworkKit/MAC.h @@ -10,6 +10,8 @@ #include #include +#define kMACAddrLen (12) + namespace NeOS { class MacAddressGetter; @@ -23,7 +25,7 @@ namespace NeOS public: KString& AsString(); - Array& AsBytes(); + Array& AsBytes(); }; } // namespace NeOS diff --git a/dev/Usr/LibCF/Core.cc b/dev/Usr/LibCF/Core.cc new file mode 100644 index 00000000..28306c56 --- /dev/null +++ b/dev/Usr/LibCF/Core.cc @@ -0,0 +1,48 @@ +/* ------------------------------------------- + + Copyright (C) 2024 Amlal El Mahrouss, all rights reserved + +------------------------------------------- */ + +#include + +LibCF::CFRect::operator bool() +{ + return width > 0 && height > 0; +} + +/***********************************************************************************/ +/// @brief returns true if size matches. +/***********************************************************************************/ +BOOL LibCF::CFRect::sizeMatches(LibCF::CFRect& rect) noexcept +{ + return rect.height == height && rect.width == width; +} + +/***********************************************************************************/ +/// @brief returns true if position matches. +/***********************************************************************************/ +BOOL LibCF::CFRect::positionMatches(LibCF::CFRect& rect) noexcept +{ + return rect.y == y && rect.x == x; +} + +/***********************************************************************************/ +/// @brief Check if point is within the current MLPoint. +/// @param point the current point to check. +/// @retval true if point is within this point. +/// @retval the validations have failed, false otherwise true. +/***********************************************************************************/ +BOOL LibCF::CFPoint::isWithin(LibCF::CFPoint& withinOf) +{ + return x_1 >= withinOf.x_1 && x_2 <= (withinOf.x_2) && + y_1 >= withinOf.y_1 && y_2 <= (withinOf.y_2); +} + +/***********************************************************************************/ +/// @brief if Point object is correctly set up. +/***********************************************************************************/ +LibCF::CFPoint::operator bool() +{ + return x_1 > x_2 && y_1 > y_2; +} \ No newline at end of file diff --git a/dev/Usr/LibCF/Core.h b/dev/Usr/LibCF/Core.h index 7aaa001d..acebe996 100644 --- a/dev/Usr/LibCF/Core.h +++ b/dev/Usr/LibCF/Core.h @@ -15,5 +15,60 @@ namespace LibCF class CFGUID; class CFProperty; class CFObject; - class CFRef; /// TODO: Ref->CFRef + class CFRef; + class CFFont; + struct CFPoint; + struct CFRect; + struct CFColor; + +#ifndef __LP64__ + typedef SInt32 CFInteger; + typedef float CFReal; +#else + typedef SInt64 CFInteger; + typedef double CFReal; +#endif + + typedef SInt32 CFInteger32; + typedef SInt64 CFInteger64; + + typedef char CFChar8; + typedef char16_t CFChar16; + + struct CFPoint + { + CFInteger64 x_1{0UL}; + CFInteger64 y_1{0UL}; + + CFInteger64 x_2{0UL}; + CFInteger64 y_2{0UL}; + CFReal ang{0UL}; + + operator bool(); + + /// @brief Check if point is within the current CFPoint. + /// @param point the current point to check. + /// @retval true if point is within this point. + /// @retval validations failed. + bool isWithin(CFPoint& point); + }; + + struct CFColor final + { + CFInteger64 r, g, b, a{0}; + }; + + struct CFRect final + { + CFInteger64 x{0UL}; + CFInteger64 y{0UL}; + + CFInteger64 width{0UL}; + CFInteger64 height{0UL}; + + operator bool(); + + BOOL sizeMatches(CFRect& rect) noexcept; + BOOL positionMatches(CFRect& rect) noexcept; + }; } // namespace LibCF \ No newline at end of file diff --git a/dev/Usr/LibFont/.keep b/dev/Usr/LibFont/.keep new file mode 100644 index 00000000..e69de29b diff --git a/dev/Usr/LibFont/Font.h b/dev/Usr/LibFont/Font.h new file mode 100644 index 00000000..710dbd3a --- /dev/null +++ b/dev/Usr/LibFont/Font.h @@ -0,0 +1,55 @@ +/** + * + * Copyright (c) 2024 Amlal El Mahrouss + * + */ + +#pragma once + +#include + +#define kCFFontExt ".ttf" + +/// @file Font.h +/// @brief Font parsing using a NeOS True Font. + +namespace LibCF +{ + class CFFont; + + class CFFont + { + public: + explicit CFFont() = default; + virtual ~CFFont() = default; + + protected: + CFRect m_size{}; + CFRect* m_glyphs{nullptr}; + CFInteger32 m_glyphs_cnt{0}; + BOOL m_bold{NO}; + BOOL m_italic{NO}; + + CFFont(const CFFont& fnt) = delete; + CFFont& operator=(const CFFont& fnt) = delete; + + virtual BOOL render_(CFPoint pos, CFChar16 character, CFColor color) = 0; + + virtual void dispose_() + { + m_bold = NO; + m_italic = NO; + + m_size.height = 0; + m_size.width = 0; + + m_glyphs_cnt = 0; + + delete[] m_glyphs; + m_glyphs = nullptr; + + m_size.x = 0; + m_size.y = 0; + } + }; +} // namespace LibCF \ No newline at end of file diff --git a/dev/Usr/LibLocale/.keep b/dev/Usr/LibLocale/.keep new file mode 100644 index 00000000..e69de29b -- cgit v1.2.3