Sistema de Renderizado de Texto (TTF).
Hemos implementado un sistema para el renderizado de textos mediante fuentes TTF. Para ello utilizamos la librería SDL_TTF. Se ha creado una clase Wrapper (UE::Font) que gestiona una fuente. Está diseñado para poder tener un cache de fuentes de diferentes tamaños. Es posible que hagamos un refactor al AssetManager para convertir las texturas a un Wrapper (más que nada para limpiar el código del AsMng y llevarme la responsabilidad de las texturas a otro sitio.
This commit is contained in:
@@ -1,2 +1,35 @@
|
||||
# UberGame1-Test
|
||||
|
||||
Repositorio principal de UberEngine. Sin mucho más.
|
||||
|
||||
|
||||
## To-Do:
|
||||
|
||||
### General / Arquitectura
|
||||
- Reestructuración completa de la clase Game y del "Entry Point".
|
||||
- Convertir la clase Game a Static completamente.
|
||||
- Unificar todas las inicialziaciones de librerias en una función en UberEngine.
|
||||
- ¿¡Dividir entre la inicialización del propio juego/app y la de los sistemas del motor!?
|
||||
- Revisar la inclusión de librerias en los headers.
|
||||
- ¡DOCUMENTACIÓN DE LA ARQUITECTURA! Quizás comentar un poco lo que hace o se supone que hace cada método. O si alguno es muy complejo, comentar el funcionamiento.
|
||||
- Crear un conjunto de tipos (typedef) de UberEngine para encapsular los vectores de GLM. (Son muy largos: glm::vec<4, int, glm::highpacked> -> UE_Color ó UE_Vec4).
|
||||
- Algún día, tocara revisar los cientos de Warning que hay...
|
||||
|
||||
### Renderer:
|
||||
- Reestructurar la arquitectura de cola de renderizado del Renderer (El sistema de DrawCalls tiene sus problemillas...).
|
||||
-
|
||||
|
||||
### Drawables:
|
||||
- ¿Mover isActive al Drawable e implementarlo a nivel global (en el renderer)?
|
||||
- Métodos para la conversión de coord World-Screen / Screen-World.
|
||||
|
||||
### Fonts / Text rendering / TextBox
|
||||
- Las fuentes no siguen el modelo estandar de Assets. El Asset contiene directamente el objeto, no un documento de datos del objeto.
|
||||
- Revisar el sistema de fuentes de assetManager.
|
||||
- No se cierran (TTF_CloseFont) las fuentes al salir.
|
||||
- Revisar el correcto funcionamiento de los métodos de TextBox.
|
||||
- Investigar formas de cambiar el tamaño al texto (TextBoxs) sin tener que modificar la fuente.
|
||||
|
||||
### Memory Leaks:
|
||||
- AssetManager: Al eliminar una textura, no limpiamos el conjunto de SDL_Rects asociado.
|
||||
- AssetManager: Creo que también hay que limpiar las fonts cargadas....
|
||||
@@ -12,7 +12,7 @@ namespace UE
|
||||
/* All types of Assets that can be loadedand stored by an AssetManager */
|
||||
enum class AssetType
|
||||
{
|
||||
Texture = 0, SpriteSheet, Sound, Other, Unvalid = 15
|
||||
Texture = 0, Font, Sound, Other, Unvalid = 15
|
||||
};
|
||||
|
||||
/* Asset struct. Contains info regarding Assets para ser cargados. */
|
||||
|
||||
@@ -18,10 +18,19 @@ namespace UE
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG_ERROR("SDL_Image Init ERROR.");
|
||||
UE_LOG_ERROR("SDL_Image - Error al inicarse: {0}", IMG_GetError());
|
||||
}
|
||||
|
||||
UE_LOG_INFO("AssetManager Iniciated");
|
||||
if (!TTF_Init()) //Retorna 0 si está correcto.
|
||||
{
|
||||
UE_LOG_INFO("SDL_TTF se ha inicializado correctamente.");
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG_ERROR("SDL_TTF - Error al inicarse: {0}", TTF_GetError());
|
||||
}
|
||||
|
||||
UE_LOG_INFO("AssetManager Iniciado con éxito.");
|
||||
}
|
||||
|
||||
void AssetManager::CleanAssetManager()
|
||||
@@ -32,6 +41,13 @@ namespace UE
|
||||
SDL_DestroyTexture(i->second);
|
||||
}
|
||||
|
||||
//Limpiamos las fuentes.
|
||||
for (auto i = _fonts.begin(); i != _fonts.end(); i++)
|
||||
{
|
||||
//Limpiamos las fuentes.
|
||||
delete i->second;
|
||||
}
|
||||
|
||||
//CPP se debería de encargar de ellos, pero bueno.
|
||||
_assetQueue.clear();
|
||||
_textures.clear();
|
||||
@@ -50,11 +66,13 @@ namespace UE
|
||||
{
|
||||
std::fstream file(filePath.c_str());
|
||||
|
||||
|
||||
|
||||
//Load Asset data from JSON.
|
||||
json jread = json::parse(file);
|
||||
|
||||
json Textures = jread["Textures"];
|
||||
json SpriteSheets = jread["SpriteSheets"];
|
||||
json Fonts = jread["Fonts"];
|
||||
json Sounds = jread["Sounds"];
|
||||
json Others = jread["Others"];
|
||||
|
||||
@@ -65,9 +83,9 @@ namespace UE
|
||||
{
|
||||
_assetQueue.push_back(Textures.at(i));
|
||||
}
|
||||
for (int i = 0; i < SpriteSheets.size(); i++)
|
||||
for (int i = 0; i < Fonts.size(); i++)
|
||||
{
|
||||
_assetQueue.push_back(SpriteSheets.at(i));
|
||||
_assetQueue.push_back(Fonts.at(i));
|
||||
}
|
||||
for (int i = 0; i < Sounds.size(); i++)
|
||||
{
|
||||
@@ -120,6 +138,11 @@ namespace UE
|
||||
LoadTexture(as._name, as._path);
|
||||
break;
|
||||
}
|
||||
case AssetType::Font:
|
||||
{
|
||||
LoadFont(as._name, as._path);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
UE_LOG_WARN("Asset {0}, Type {1} Cannot be loaded from {2}", as._name, as._type, as._path);
|
||||
@@ -176,10 +199,17 @@ namespace UE
|
||||
}
|
||||
|
||||
|
||||
void AssetManager::LoadFont(std::string name, std::string fontPath)
|
||||
{
|
||||
Font* fo = new Font(fontPath);
|
||||
_fonts.insert(std::make_pair(name, fo));
|
||||
|
||||
}
|
||||
|
||||
|
||||
//////////DEBUG//////////
|
||||
|
||||
|
||||
void AssetManager::PrintAssetInfo()
|
||||
{
|
||||
std::cout << "AM - Debug INFO: " << std::endl;
|
||||
|
||||
@@ -11,9 +11,13 @@
|
||||
/*LIB Includes*/
|
||||
#include <SDL_render.h>
|
||||
#include <SDL_image.h>
|
||||
#include <SDL_ttf.h>
|
||||
|
||||
/*UberEngine Includes*/
|
||||
#include "Assets\Asset.h"
|
||||
#include "Assets\Font.h"
|
||||
|
||||
using json = nlohmann::ordered_json;
|
||||
|
||||
|
||||
///
|
||||
@@ -120,6 +124,16 @@ namespace UE
|
||||
inline std::vector<SDL_Rect>* getTexureRects(std::string textureName) { return &_textureRects.at(textureName); }
|
||||
|
||||
|
||||
/*
|
||||
Métodos para manejar las fuentes.
|
||||
*/
|
||||
//Carga una fuente.
|
||||
void LoadFont(std::string name, std::string fontPath);
|
||||
|
||||
inline Font* GetFont(std::string fontName) { return _fonts.at(fontName); }
|
||||
|
||||
|
||||
|
||||
///////DEBUG////////
|
||||
void PrintAssetInfo();
|
||||
///////////////////
|
||||
@@ -142,6 +156,9 @@ namespace UE
|
||||
std::unordered_map<std::string, SDL_Texture*> _textures = {};
|
||||
std::unordered_map<std::string, std::vector<SDL_Rect>> _textureRects = {};
|
||||
|
||||
//Almacen de TTF_Fonts* (Para las fuentes de SDL_TTF).
|
||||
std::unordered_map<std::string, Font*> _fonts = {};
|
||||
|
||||
|
||||
//Necesario para crear las SDL_Texture a partir de SDL_Surface.
|
||||
SDL_Renderer* _mainRenderer = NULL;
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
#include "Font.h"
|
||||
#include "Logging\Logger.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include <json\json.hpp>
|
||||
using json = nlohmann::ordered_json;
|
||||
|
||||
|
||||
|
||||
TTF_Font* UE::Font::GetFont(int size)
|
||||
{
|
||||
TTF_Font* font;
|
||||
|
||||
auto it = _fonts.find(size);
|
||||
if (it == _fonts.end())
|
||||
{
|
||||
//El tamaño pedido no está disponible.
|
||||
//La creamos nueva.
|
||||
font = CreateFontSize(size);
|
||||
return font;
|
||||
}
|
||||
//En caso de estar disponible, lo retornamos.
|
||||
font = it->second;
|
||||
return font;
|
||||
|
||||
}
|
||||
|
||||
void UE::Font::InitFont()
|
||||
{
|
||||
//Cargamos los datos desde el archivo.
|
||||
std::fstream file(_dataPath.c_str());
|
||||
|
||||
json jread = json::parse(file);
|
||||
|
||||
_fontPath = jread["FontPath"].get<std::string>();
|
||||
|
||||
//Obtenemos los tamaños que crear de inicio.
|
||||
std::vector<int> vect = jread["FontSizes"].get<std::vector<int>>();
|
||||
for (auto it : vect)
|
||||
{
|
||||
CreateFontSize(it);
|
||||
}
|
||||
}
|
||||
|
||||
void UE::Font::CleanFont()
|
||||
{
|
||||
//Eliminamos todos los tamaños de las fuentes.
|
||||
for (auto i = _fonts.begin(); i != _fonts.end(); i++)
|
||||
{
|
||||
TTF_CloseFont(i->second);
|
||||
}
|
||||
}
|
||||
|
||||
TTF_Font* UE::Font::CreateFontSize(int size)
|
||||
{
|
||||
//Creamos la fuente del tamaño requerido.
|
||||
TTF_Font* font = TTF_OpenFont(_fontPath.c_str(), size);
|
||||
if (font == nullptr)
|
||||
{
|
||||
UE_LOG_ERROR("No se ha podido crear la fuente: {0} - Size: {1}", _fontPath, size);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//La añadimos al mapa.
|
||||
_fonts.insert(std::make_pair(size, font));
|
||||
|
||||
UE_LOG_TRACE("Font: {0} se ha creado con tamanho: {1}", _fontPath, size);
|
||||
|
||||
return font;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <SDL_ttf.h>
|
||||
|
||||
namespace UE
|
||||
{
|
||||
//Clase que representa una fuente. El objetivo es poder tener múltiples tamaños de esta de forma sencilla.
|
||||
class Font
|
||||
{
|
||||
public:
|
||||
Font(std::string dataPath)
|
||||
: _dataPath(dataPath)
|
||||
{
|
||||
InitFont();
|
||||
}
|
||||
|
||||
~Font()
|
||||
{
|
||||
CleanFont();
|
||||
}
|
||||
|
||||
//Devuelve la fuente del tamaño indicado. En caso de no estar disponible, la carga y la devuelve.
|
||||
TTF_Font* GetFont(int size);
|
||||
|
||||
|
||||
private:
|
||||
void InitFont();
|
||||
|
||||
void CleanFont();
|
||||
|
||||
//Crea la fuente del tamaño deseado y devuelve su ptr.
|
||||
TTF_Font* CreateFontSize(int size);
|
||||
|
||||
|
||||
private:
|
||||
std::string _dataPath = "";
|
||||
|
||||
std::string _fontPath = "";
|
||||
|
||||
//Mapa que contiene un ptr a la fuente con diferentes tamaños.
|
||||
std::unordered_map<int, TTF_Font*> _fonts;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
#include "TextBox.h"
|
||||
|
||||
#include "Logging\Logger.h"
|
||||
#include "Render\Renderer.h"
|
||||
|
||||
void UE::TextBox::SetText(std::string newText)
|
||||
{
|
||||
_text = newText;
|
||||
RenderTextTexture();
|
||||
}
|
||||
|
||||
void UE::TextBox::SetSize(int newSize)
|
||||
{
|
||||
_textSize = newSize;
|
||||
RenderTextTexture();
|
||||
}
|
||||
|
||||
|
||||
void UE::TextBox::SetColor(UE_Color newColor)
|
||||
{
|
||||
_textColor = newColor;
|
||||
RenderTextTexture();
|
||||
}
|
||||
|
||||
void UE::TextBox::SetColor(int r, int g, int b, int a)
|
||||
{
|
||||
UE_Color c = UE_Color(r, g, b, a);
|
||||
_textColor = c;
|
||||
RenderTextTexture();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void UE::TextBox::Draw(Renderer* renderer)
|
||||
{
|
||||
//Si aún no tenemos renderer, lo guardamos y procesamos.
|
||||
if (_sdlRenderer == nullptr)
|
||||
{
|
||||
_sdlRenderer = renderer->GetSDLRenderer();
|
||||
RenderTextTexture();
|
||||
}
|
||||
if (_textTexture == nullptr)
|
||||
{
|
||||
UE_LOG_WARN("El texto: {0} ; No se está renderizando. La textura no existe.", _text);
|
||||
return;
|
||||
}
|
||||
|
||||
//Generamos el SDL_Rect destino.
|
||||
SDL_Rect dest = { _pos.x, _pos.y, _size.x, _size.y };
|
||||
|
||||
renderer->QueueDrawCall(_renderLayer, dest, _textTexture);
|
||||
|
||||
}
|
||||
|
||||
void UE::TextBox::RenderTextTexture()
|
||||
{
|
||||
//No podemos continuar hasta que no tengamos un renderer.
|
||||
if (_sdlRenderer == nullptr) { return; }
|
||||
|
||||
SDL_DestroyTexture(_textTexture);
|
||||
|
||||
//Creamos el SDL_Color a partir del vec4 que contiene el color.
|
||||
SDL_Color color = { _textColor.x,_textColor.y, _textColor.z, _textColor.w };
|
||||
|
||||
//Tomamos la TTF_Font del tamaño que queremos de UE::Font.
|
||||
TTF_Font* fn = _font->GetFont(_textSize);
|
||||
|
||||
SDL_Surface* loader = TTF_RenderText_Solid(fn, _text.c_str(), color);
|
||||
if (loader == NULL)
|
||||
{
|
||||
UE_LOG_ERROR("No se ha podido crear el texto: {0} ; Error: {1}",
|
||||
_text, TTF_GetError());
|
||||
return;
|
||||
}
|
||||
|
||||
_textTexture = SDL_CreateTextureFromSurface(_sdlRenderer, loader);
|
||||
if (_textTexture == NULL)
|
||||
{
|
||||
UE_LOG_ERROR("No se ha podido crear la textura del texto: {0} ; Error: {1}",
|
||||
_text, SDL_GetError());
|
||||
return;
|
||||
}
|
||||
_size.x = loader->w;
|
||||
_size.y = loader->h;
|
||||
|
||||
SDL_FreeSurface(loader);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL_ttf.h>
|
||||
#include <glm\vec4.hpp>
|
||||
|
||||
|
||||
#include "Render\Drawable.h"
|
||||
#include "Render\Transformable.h"
|
||||
|
||||
#include "Assets\Font.h"
|
||||
|
||||
|
||||
namespace UE
|
||||
{
|
||||
|
||||
typedef glm::tvec4<int> UE_Color;
|
||||
|
||||
class TextBox : public Drawable, public Transformable
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
|
||||
|
||||
TextBox(UE::Font* font,
|
||||
std::string text = "Texto por defecto",
|
||||
int textSize = 18,
|
||||
UE_Color textColor = UE_Color(0, 0, 0, 255),
|
||||
int renderLayer = 1,
|
||||
glm::vec2 position = glm::vec2(0, 0))
|
||||
: _font(font), _text(text), _textSize(textSize)
|
||||
{
|
||||
SetColor(textColor);
|
||||
|
||||
SetLayer(renderLayer);
|
||||
SetPosition(position);
|
||||
|
||||
RenderTextTexture();
|
||||
}
|
||||
|
||||
//Se generará una textura y todo eso...
|
||||
void SetText(std::string newText);
|
||||
void SetSize(int newSize);
|
||||
|
||||
void SetColor(UE_Color newColor);
|
||||
void SetColor(int r, int g, int b, int a);
|
||||
|
||||
|
||||
//Implementa el Draw de Drawable.
|
||||
void Draw(Renderer* renderer) override;
|
||||
|
||||
private:
|
||||
void RenderTextTexture();
|
||||
|
||||
|
||||
private:
|
||||
UE::Font* _font = nullptr;
|
||||
std::string _text = "Texto por defecto";
|
||||
int _textSize = 18;
|
||||
UE_Color _textColor;
|
||||
|
||||
SDL_Texture* _textTexture = nullptr;
|
||||
|
||||
//Esto está muy mal hecho, no debería de ser así.
|
||||
//Necesito un renderer para crear la textura del texto, pero no puedo conseguirlo con la arquitectura actual.
|
||||
//No quiero regenerar la textura en cada frame de forma innecesaria...
|
||||
//Por ello, me toca forzar un poco el sistema.
|
||||
SDL_Renderer* _sdlRenderer = nullptr;
|
||||
};
|
||||
}
|
||||
@@ -129,6 +129,11 @@ namespace UE
|
||||
for (int k = 0; k < layer.size(); k++)
|
||||
{
|
||||
DrawCall item = layer.at(k);
|
||||
if (item.fullTexture)
|
||||
{
|
||||
SDL_RenderCopy(main_Renderer, item.tx, NULL, &item.pos_rect);
|
||||
continue;
|
||||
}
|
||||
SDL_RenderCopy(main_Renderer, item.tx, &item.tx_rect, &item.pos_rect);
|
||||
}
|
||||
layer.clear();
|
||||
|
||||
@@ -130,13 +130,24 @@ namespace UE
|
||||
DrawCall(int layer,
|
||||
SDL_Rect position,
|
||||
SDL_Texture* texture,
|
||||
SDL_Rect texture_position = SDL_Rect())
|
||||
SDL_Rect texture_position)
|
||||
|
||||
: layer(layer), tx(texture), tx_rect(texture_position), pos_rect(position)
|
||||
{}
|
||||
|
||||
DrawCall(int layer,
|
||||
SDL_Rect position,
|
||||
SDL_Texture* texture)
|
||||
: layer(layer), tx(texture), pos_rect(position)
|
||||
{
|
||||
tx_rect = SDL_Rect();
|
||||
fullTexture = true;
|
||||
}
|
||||
|
||||
int layer;
|
||||
|
||||
bool fullTexture = false;
|
||||
|
||||
SDL_Texture* tx;
|
||||
SDL_Rect tx_rect;
|
||||
|
||||
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
2.0.18:
|
||||
Ozkan Sezer - Wed Jan 5 14:15:46 PST 2022
|
||||
* Added TTF_GetFreeTypeVersion() and TTF_GetHarfBuzzVersion()
|
||||
Sylvain - Jan 16, 2021
|
||||
* Added support for Signed Distance Field rendering with TTF_SetFontSDF() and TTF_GetFontSDF()
|
||||
David Ludwig - Dec 28, 2019
|
||||
* Added optional DPI-scaling of fonts, with the following new functions:
|
||||
TTF_OpenFontDPI()
|
||||
TTF_OpenFontIndexDPI()
|
||||
TTF_OpenFontDPIRW()
|
||||
TTF_OpenFontIndexDPIRW()
|
||||
TTF_SetFontSizeDPI()
|
||||
Weard Anaether - Dec 2, 2019
|
||||
* Added 32-bit character support with:
|
||||
TTF_RenderGlyph32_Solid()
|
||||
TTF_RenderGlyph32_Shaded()
|
||||
TTF_RenderGlyph32_Blended()
|
||||
TTF_GetFontKerningSizeGlyphs32()
|
||||
Arthur Danskin - Sep 3, 2019
|
||||
* Added 32-bit character support with TTF_GlyphIsProvided32() and TTF_GlyphMetrics32()
|
||||
Sylvain - Apr 5, 2019
|
||||
* Added functions to set direction and script when using Harfbuzz:
|
||||
TTF_SetDirection()
|
||||
TTF_SetScript()
|
||||
Sylvain - Mar 25, 2019
|
||||
* Added extended API for text measurement:
|
||||
TTF_MeasureText()
|
||||
TTF_MeasureUTF8()
|
||||
TTF_MeasureUNICODE()
|
||||
Sylvain - Jan 31, 2019
|
||||
* Added TTF_SetFontSize() to set font size dynamically
|
||||
* Added 'Shaded' and 'Solid' text wrapped functions:
|
||||
TTF_RenderText_Solid_Wrapped()
|
||||
TTF_RenderUTF8_Solid_Wrapped()
|
||||
TTF_RenderUNICODE_Solid_Wrapped()
|
||||
TTF_RenderText_Shaded_Wrapped()
|
||||
TTF_RenderUTF8_Shaded_Wrapped()
|
||||
TTF_RenderUNICODE_Shaded_Wrapped()
|
||||
* Added TTF_HINTING_LIGHT_SUBPIXEL for better results at small text sizes at a performance cost
|
||||
|
||||
2.0.15:
|
||||
Sam Lantinga - Fri Oct 26 13:26:54 PDT 2018
|
||||
* Updated to FreeType version 2.9.1
|
||||
Sam Lantinga - Sun Sep 10 00:18:45 PDT 2017
|
||||
* Text rendering functions now use the alpha component of the text colors
|
||||
Sam Lantinga - Sat Sep 9 22:21:55 PDT 2017
|
||||
* Added support for characters greater than 0xFFFF (e.g. emoji) in the UTF-8 APIs
|
||||
|
||||
2.0.14:
|
||||
Ryan Gordon - Fri Jan 29 12:53:29 PST 2016
|
||||
* Deprecated TTF_GetFontKerningSize() which takes font glyph indices and added TTF_GetFontKerningSizeGlyphs() which takes characters
|
||||
|
||||
2.0.13:
|
||||
Sylvain - Sat Jun 28 11:42:42 2014
|
||||
* Fixed bug rendering text starting with a glyph with negative starting offset
|
||||
beuc - Sun Jun 15 18:27:28 2014
|
||||
* Fixed regression loading non-scalable fonts
|
||||
Sam Lantinga - Sun Jun 15 18:21:04 PDT 2014
|
||||
* TTF_GetFontKerningSize() gets kerning between two characters, not two glyph indices
|
||||
David Ludwig - Sun Apr 13 22:28:26 2014
|
||||
* Added support for building for Windows RT and Windows Phone
|
||||
|
||||
2.0.12:
|
||||
Sam Lantinga - Sat Jun 1 19:11:26 PDT 2013
|
||||
* Updated for SDL 2.0 release
|
||||
|
||||
2.0.11:
|
||||
Sam Lantinga - Sat Dec 31 10:49:42 EST 2011
|
||||
* SDL_ttf is now under the zlib license
|
||||
Peter Kosyh - Mon Feb 28 14:57:03 PST 2011
|
||||
* Improved font glyph caching for non-latin languages
|
||||
Erik Snoek - Wed Jan 12 09:10:15 PST 2011
|
||||
* Added API to get kerning info: TTF_GetFontKerningSize()
|
||||
Sam Lantinga - Mon Jan 10 10:58:34 2011 -0800
|
||||
* Added Android.mk to build on the Android platform
|
||||
|
||||
2.0.10:
|
||||
Adam Strzelecki - Wed Oct 21 21:02:37 PDT 2009
|
||||
* Find the Unicode or symbol character map if it's available in the font
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
SDL_ttf: A companion library to SDL for working with TrueType (tm) fonts
|
||||
Copyright (C) 1997-2022 Sam Lantinga <[email protected]>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
|
||||
This library is a wrapper around the excellent FreeType 2.0 library,
|
||||
available at:
|
||||
http://www.freetype.org/
|
||||
|
||||
This library allows you to use TrueType fonts to render text in SDL
|
||||
applications.
|
||||
|
||||
To make the library, first install the FreeType library, then type
|
||||
'./configure' then 'make' to build the SDL truetype library and the
|
||||
showfont and glfont example applications.
|
||||
|
||||
Be careful when including fonts with your application, as many of them
|
||||
are copyrighted. The Microsoft fonts, for example, are not freely
|
||||
redistributable and even the free "web" fonts they provide are only
|
||||
redistributable in their special executable installer form (May 1998).
|
||||
There are plenty of freeware and shareware fonts available on the Internet
|
||||
though, and may suit your purposes.
|
||||
|
||||
This library is under the zlib license, see the file "COPYING.txt" for details.
|
||||
|
||||
Portions of this software are copyright © 2013 The FreeType Project (www.freetype.org). All rights reserved.
|
||||
|
||||
Enjoy!
|
||||
-Sam Lantinga <[email protected]> (6/20/2001)
|
||||
+387
@@ -0,0 +1,387 @@
|
||||
/*
|
||||
SDL_ttf: A companion library to SDL for working with TrueType (tm) fonts
|
||||
Copyright (C) 2001-2022 Sam Lantinga <[email protected]>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/* This library is a wrapper around the excellent FreeType 2.0 library,
|
||||
available at:
|
||||
http://www.freetype.org/
|
||||
*/
|
||||
|
||||
/* Note: In many places, SDL_ttf will say "glyph" when it means "code point."
|
||||
Unicode is hard, we learn as we go, and we apologize for adding to the
|
||||
confusion. */
|
||||
|
||||
#ifndef SDL_TTF_H_
|
||||
#define SDL_TTF_H_
|
||||
|
||||
#include "SDL.h"
|
||||
#include "begin_code.h"
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
|
||||
*/
|
||||
#define SDL_TTF_MAJOR_VERSION 2
|
||||
#define SDL_TTF_MINOR_VERSION 0
|
||||
#define SDL_TTF_PATCHLEVEL 18
|
||||
|
||||
/* This macro can be used to fill a version structure with the compile-time
|
||||
* version of the SDL_ttf library.
|
||||
*/
|
||||
#define SDL_TTF_VERSION(X) \
|
||||
{ \
|
||||
(X)->major = SDL_TTF_MAJOR_VERSION; \
|
||||
(X)->minor = SDL_TTF_MINOR_VERSION; \
|
||||
(X)->patch = SDL_TTF_PATCHLEVEL; \
|
||||
}
|
||||
|
||||
/* Backwards compatibility */
|
||||
#define TTF_MAJOR_VERSION SDL_TTF_MAJOR_VERSION
|
||||
#define TTF_MINOR_VERSION SDL_TTF_MINOR_VERSION
|
||||
#define TTF_PATCHLEVEL SDL_TTF_PATCHLEVEL
|
||||
#define TTF_VERSION(X) SDL_TTF_VERSION(X)
|
||||
|
||||
/**
|
||||
* This is the version number macro for the current SDL_ttf version.
|
||||
*/
|
||||
#define SDL_TTF_COMPILEDVERSION \
|
||||
SDL_VERSIONNUM(SDL_TTF_MAJOR_VERSION, SDL_TTF_MINOR_VERSION, SDL_TTF_PATCHLEVEL)
|
||||
|
||||
/**
|
||||
* This macro will evaluate to true if compiled with SDL_ttf at least X.Y.Z.
|
||||
*/
|
||||
#define SDL_TTF_VERSION_ATLEAST(X, Y, Z) \
|
||||
(SDL_TTF_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
|
||||
|
||||
/* Make sure this is defined (only available in newer SDL versions) */
|
||||
#ifndef SDL_DEPRECATED
|
||||
#define SDL_DEPRECATED
|
||||
#endif
|
||||
|
||||
/* This function gets the version of the dynamically linked SDL_ttf library.
|
||||
it should NOT be used to fill a version structure, instead you should
|
||||
use the SDL_TTF_VERSION() macro.
|
||||
*/
|
||||
extern DECLSPEC const SDL_version * SDLCALL TTF_Linked_Version(void);
|
||||
|
||||
/* This function stores the version of the FreeType2 library in use.
|
||||
TTF_Init() should be called before calling this function.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL TTF_GetFreeTypeVersion(int *major, int *minor, int *patch);
|
||||
|
||||
/* This function stores the version of the HarfBuzz library in use,
|
||||
or 0 if HarfBuzz is not available.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL TTF_GetHarfBuzzVersion(int *major, int *minor, int *patch);
|
||||
|
||||
/* ZERO WIDTH NO-BREAKSPACE (Unicode byte order mark) */
|
||||
#define UNICODE_BOM_NATIVE 0xFEFF
|
||||
#define UNICODE_BOM_SWAPPED 0xFFFE
|
||||
|
||||
/* This function tells the library whether UNICODE text is generally
|
||||
byteswapped. A UNICODE BOM character in a string will override
|
||||
this setting for the remainder of that string.
|
||||
*/
|
||||
extern DECLSPEC void SDLCALL TTF_ByteSwappedUNICODE(SDL_bool swapped);
|
||||
|
||||
/* The internal structure containing font information */
|
||||
typedef struct _TTF_Font TTF_Font;
|
||||
|
||||
/* Initialize the TTF engine - returns 0 if successful, -1 on error */
|
||||
extern DECLSPEC int SDLCALL TTF_Init(void);
|
||||
|
||||
/* Open a font file and create a font of the specified point size.
|
||||
* Some .fon fonts will have several sizes embedded in the file, so the
|
||||
* point size becomes the index of choosing which size. If the value
|
||||
* is too high, the last indexed size will be the default. */
|
||||
extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFont(const char *file, int ptsize);
|
||||
extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFontIndex(const char *file, int ptsize, long index);
|
||||
/* Open a font file from a SDL_RWops: 'src' must be kept alive for the lifetime of the TTF_Font.
|
||||
* 'freesrc' can be set so that TTF_CloseFont closes the RWops */
|
||||
extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFontRW(SDL_RWops *src, int freesrc, int ptsize);
|
||||
extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFontIndexRW(SDL_RWops *src, int freesrc, int ptsize, long index);
|
||||
|
||||
/* Opens a font using the given horizontal and vertical target resolutions (in DPI).
|
||||
* DPI scaling only applies to scalable fonts (e.g. TrueType). */
|
||||
extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFontDPI(const char *file, int ptsize, unsigned int hdpi, unsigned int vdpi);
|
||||
extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFontIndexDPI(const char *file, int ptsize, long index, unsigned int hdpi, unsigned int vdpi);
|
||||
extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFontDPIRW(SDL_RWops *src, int freesrc, int ptsize, unsigned int hdpi, unsigned int vdpi);
|
||||
extern DECLSPEC TTF_Font * SDLCALL TTF_OpenFontIndexDPIRW(SDL_RWops *src, int freesrc, int ptsize, long index, unsigned int hdpi, unsigned int vdpi);
|
||||
|
||||
/* Set font size dynamically */
|
||||
extern DECLSPEC int SDLCALL TTF_SetFontSize(TTF_Font *font, int ptsize);
|
||||
extern DECLSPEC int SDLCALL TTF_SetFontSizeDPI(TTF_Font *font, int ptsize, unsigned int hdpi, unsigned int vdpi);
|
||||
|
||||
/* Set and retrieve the font style */
|
||||
#define TTF_STYLE_NORMAL 0x00
|
||||
#define TTF_STYLE_BOLD 0x01
|
||||
#define TTF_STYLE_ITALIC 0x02
|
||||
#define TTF_STYLE_UNDERLINE 0x04
|
||||
#define TTF_STYLE_STRIKETHROUGH 0x08
|
||||
extern DECLSPEC int SDLCALL TTF_GetFontStyle(const TTF_Font *font);
|
||||
extern DECLSPEC void SDLCALL TTF_SetFontStyle(TTF_Font *font, int style);
|
||||
extern DECLSPEC int SDLCALL TTF_GetFontOutline(const TTF_Font *font);
|
||||
extern DECLSPEC void SDLCALL TTF_SetFontOutline(TTF_Font *font, int outline);
|
||||
|
||||
/* Set and retrieve FreeType hinter settings */
|
||||
#define TTF_HINTING_NORMAL 0
|
||||
#define TTF_HINTING_LIGHT 1
|
||||
#define TTF_HINTING_MONO 2
|
||||
#define TTF_HINTING_NONE 3
|
||||
#define TTF_HINTING_LIGHT_SUBPIXEL 4
|
||||
extern DECLSPEC int SDLCALL TTF_GetFontHinting(const TTF_Font *font);
|
||||
extern DECLSPEC void SDLCALL TTF_SetFontHinting(TTF_Font *font, int hinting);
|
||||
|
||||
/* Get the total height of the font - usually equal to point size */
|
||||
extern DECLSPEC int SDLCALL TTF_FontHeight(const TTF_Font *font);
|
||||
|
||||
/* Get the offset from the baseline to the top of the font
|
||||
This is a positive value, relative to the baseline.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL TTF_FontAscent(const TTF_Font *font);
|
||||
|
||||
/* Get the offset from the baseline to the bottom of the font
|
||||
This is a negative value, relative to the baseline.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL TTF_FontDescent(const TTF_Font *font);
|
||||
|
||||
/* Get the recommended spacing between lines of text for this font */
|
||||
extern DECLSPEC int SDLCALL TTF_FontLineSkip(const TTF_Font *font);
|
||||
|
||||
/* Get/Set whether or not kerning is allowed for this font */
|
||||
extern DECLSPEC int SDLCALL TTF_GetFontKerning(const TTF_Font *font);
|
||||
extern DECLSPEC void SDLCALL TTF_SetFontKerning(TTF_Font *font, int allowed);
|
||||
|
||||
/* Get the number of faces of the font */
|
||||
extern DECLSPEC long SDLCALL TTF_FontFaces(const TTF_Font *font);
|
||||
|
||||
/* Get the font face attributes, if any */
|
||||
extern DECLSPEC int SDLCALL TTF_FontFaceIsFixedWidth(const TTF_Font *font);
|
||||
extern DECLSPEC char * SDLCALL TTF_FontFaceFamilyName(const TTF_Font *font);
|
||||
extern DECLSPEC char * SDLCALL TTF_FontFaceStyleName(const TTF_Font *font);
|
||||
|
||||
/* Check wether a glyph is provided by the font or not */
|
||||
extern DECLSPEC int SDLCALL TTF_GlyphIsProvided(TTF_Font *font, Uint16 ch);
|
||||
extern DECLSPEC int SDLCALL TTF_GlyphIsProvided32(TTF_Font *font, Uint32 ch);
|
||||
|
||||
/* Get the metrics (dimensions) of a glyph
|
||||
To understand what these metrics mean, here is a useful link:
|
||||
http://freetype.sourceforge.net/freetype2/docs/tutorial/step2.html
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL TTF_GlyphMetrics(TTF_Font *font, Uint16 ch,
|
||||
int *minx, int *maxx,
|
||||
int *miny, int *maxy, int *advance);
|
||||
extern DECLSPEC int SDLCALL TTF_GlyphMetrics32(TTF_Font *font, Uint32 ch,
|
||||
int *minx, int *maxx,
|
||||
int *miny, int *maxy, int *advance);
|
||||
|
||||
/* Get the dimensions of a rendered string of text */
|
||||
extern DECLSPEC int SDLCALL TTF_SizeText(TTF_Font *font, const char *text, int *w, int *h);
|
||||
extern DECLSPEC int SDLCALL TTF_SizeUTF8(TTF_Font *font, const char *text, int *w, int *h);
|
||||
extern DECLSPEC int SDLCALL TTF_SizeUNICODE(TTF_Font *font, const Uint16 *text, int *w, int *h);
|
||||
|
||||
/* Get the measurement string of text without rendering
|
||||
e.g. the number of characters that can be rendered before reaching 'measure_width'
|
||||
|
||||
in:
|
||||
measure_width - in pixels to measure this text
|
||||
out:
|
||||
count - number of characters that can be rendered
|
||||
extent - latest calculated width
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL TTF_MeasureText(TTF_Font *font, const char *text, int measure_width, int *extent, int *count);
|
||||
extern DECLSPEC int SDLCALL TTF_MeasureUTF8(TTF_Font *font, const char *text, int measure_width, int *extent, int *count);
|
||||
extern DECLSPEC int SDLCALL TTF_MeasureUNICODE(TTF_Font *font, const Uint16 *text, int measure_width, int *extent, int *count);
|
||||
|
||||
/* Create an 8-bit palettized surface and render the given text at
|
||||
fast quality with the given font and color. The 0 pixel is the
|
||||
colorkey, giving a transparent background, and the 1 pixel is set
|
||||
to the text color.
|
||||
This function returns the new surface, or NULL if there was an error.
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Solid(TTF_Font *font,
|
||||
const char *text, SDL_Color fg);
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUTF8_Solid(TTF_Font *font,
|
||||
const char *text, SDL_Color fg);
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUNICODE_Solid(TTF_Font *font,
|
||||
const Uint16 *text, SDL_Color fg);
|
||||
|
||||
/* Create an 8-bit palettized surface and render the given text at
|
||||
fast quality with the given font and color. The 0 pixel is the
|
||||
colorkey, giving a transparent background, and the 1 pixel is set
|
||||
to the text color.
|
||||
Text is wrapped to multiple lines on line endings and on word boundaries
|
||||
if it extends beyond wrapLength in pixels.
|
||||
If wrapLength is 0, only wrap on new lines.
|
||||
This function returns the new surface, or NULL if there was an error.
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Solid_Wrapped(TTF_Font *font,
|
||||
const char *text, SDL_Color fg, Uint32 wrapLength);
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUTF8_Solid_Wrapped(TTF_Font *font,
|
||||
const char *text, SDL_Color fg, Uint32 wrapLength);
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUNICODE_Solid_Wrapped(TTF_Font *font,
|
||||
const Uint16 *text, SDL_Color fg, Uint32 wrapLength);
|
||||
|
||||
/* Create an 8-bit palettized surface and render the given glyph at
|
||||
fast quality with the given font and color. The 0 pixel is the
|
||||
colorkey, giving a transparent background, and the 1 pixel is set
|
||||
to the text color. The glyph is rendered without any padding or
|
||||
centering in the X direction, and aligned normally in the Y direction.
|
||||
This function returns the new surface, or NULL if there was an error.
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderGlyph_Solid(TTF_Font *font,
|
||||
Uint16 ch, SDL_Color fg);
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderGlyph32_Solid(TTF_Font *font,
|
||||
Uint32 ch, SDL_Color fg);
|
||||
|
||||
/* Create an 8-bit palettized surface and render the given text at
|
||||
high quality with the given font and colors. The 0 pixel is background,
|
||||
while other pixels have varying degrees of the foreground color.
|
||||
This function returns the new surface, or NULL if there was an error.
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Shaded(TTF_Font *font,
|
||||
const char *text, SDL_Color fg, SDL_Color bg);
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUTF8_Shaded(TTF_Font *font,
|
||||
const char *text, SDL_Color fg, SDL_Color bg);
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUNICODE_Shaded(TTF_Font *font,
|
||||
const Uint16 *text, SDL_Color fg, SDL_Color bg);
|
||||
|
||||
/* Create an 8-bit palettized surface and render the given text at
|
||||
high quality with the given font and colors. The 0 pixel is background,
|
||||
while other pixels have varying degrees of the foreground color.
|
||||
Text is wrapped to multiple lines on line endings and on word boundaries
|
||||
if it extends beyond wrapLength in pixels.
|
||||
If wrapLength is 0, only wrap on new lines.
|
||||
This function returns the new surface, or NULL if there was an error.
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Shaded_Wrapped(TTF_Font *font,
|
||||
const char *text, SDL_Color fg, SDL_Color bg, Uint32 wrapLength);
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUTF8_Shaded_Wrapped(TTF_Font *font,
|
||||
const char *text, SDL_Color fg, SDL_Color bg, Uint32 wrapLength);
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUNICODE_Shaded_Wrapped(TTF_Font *font,
|
||||
const Uint16 *text, SDL_Color fg, SDL_Color bg, Uint32 wrapLength);
|
||||
|
||||
/* Create an 8-bit palettized surface and render the given glyph at
|
||||
high quality with the given font and colors. The 0 pixel is background,
|
||||
while other pixels have varying degrees of the foreground color.
|
||||
The glyph is rendered without any padding or centering in the X
|
||||
direction, and aligned normally in the Y direction.
|
||||
This function returns the new surface, or NULL if there was an error.
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderGlyph_Shaded(TTF_Font *font,
|
||||
Uint16 ch, SDL_Color fg, SDL_Color bg);
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderGlyph32_Shaded(TTF_Font *font,
|
||||
Uint32 ch, SDL_Color fg, SDL_Color bg);
|
||||
|
||||
/* Create a 32-bit ARGB surface and render the given text at high quality,
|
||||
using alpha blending to dither the font with the given color.
|
||||
This function returns the new surface, or NULL if there was an error.
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Blended(TTF_Font *font,
|
||||
const char *text, SDL_Color fg);
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUTF8_Blended(TTF_Font *font,
|
||||
const char *text, SDL_Color fg);
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUNICODE_Blended(TTF_Font *font,
|
||||
const Uint16 *text, SDL_Color fg);
|
||||
|
||||
|
||||
/* Create a 32-bit ARGB surface and render the given text at high quality,
|
||||
using alpha blending to dither the font with the given color.
|
||||
Text is wrapped to multiple lines on line endings and on word boundaries
|
||||
if it extends beyond wrapLength in pixels.
|
||||
If wrapLength is 0, only wrap on new lines.
|
||||
This function returns the new surface, or NULL if there was an error.
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderText_Blended_Wrapped(TTF_Font *font,
|
||||
const char *text, SDL_Color fg, Uint32 wrapLength);
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUTF8_Blended_Wrapped(TTF_Font *font,
|
||||
const char *text, SDL_Color fg, Uint32 wrapLength);
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderUNICODE_Blended_Wrapped(TTF_Font *font,
|
||||
const Uint16 *text, SDL_Color fg, Uint32 wrapLength);
|
||||
|
||||
/* Create a 32-bit ARGB surface and render the given glyph at high quality,
|
||||
using alpha blending to dither the font with the given color.
|
||||
The glyph is rendered without any padding or centering in the X
|
||||
direction, and aligned normally in the Y direction.
|
||||
This function returns the new surface, or NULL if there was an error.
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderGlyph_Blended(TTF_Font *font,
|
||||
Uint16 ch, SDL_Color fg);
|
||||
extern DECLSPEC SDL_Surface * SDLCALL TTF_RenderGlyph32_Blended(TTF_Font *font,
|
||||
Uint32 ch, SDL_Color fg);
|
||||
|
||||
/* For compatibility with previous versions, here are the old functions */
|
||||
#define TTF_RenderText(font, text, fg, bg) \
|
||||
TTF_RenderText_Shaded(font, text, fg, bg)
|
||||
#define TTF_RenderUTF8(font, text, fg, bg) \
|
||||
TTF_RenderUTF8_Shaded(font, text, fg, bg)
|
||||
#define TTF_RenderUNICODE(font, text, fg, bg) \
|
||||
TTF_RenderUNICODE_Shaded(font, text, fg, bg)
|
||||
|
||||
/* Set Direction and Script to be used for text shaping.
|
||||
- direction is of type hb_direction_t
|
||||
- script is of type hb_script_t
|
||||
|
||||
This functions returns always 0, or -1 if SDL_ttf is not compiled with HarfBuzz
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL TTF_SetDirection(int direction); /* hb_direction_t */
|
||||
extern DECLSPEC int SDLCALL TTF_SetScript(int script); /* hb_script_t */
|
||||
|
||||
/* Close an opened font file */
|
||||
extern DECLSPEC void SDLCALL TTF_CloseFont(TTF_Font *font);
|
||||
|
||||
/* De-initialize the TTF engine */
|
||||
extern DECLSPEC void SDLCALL TTF_Quit(void);
|
||||
|
||||
/* Check if the TTF engine is initialized */
|
||||
extern DECLSPEC int SDLCALL TTF_WasInit(void);
|
||||
|
||||
/* Get the kerning size of two glyphs indices */
|
||||
/* DEPRECATED: this function requires FreeType font indexes, not glyphs,
|
||||
by accident, which we don't expose through this API, so it could give
|
||||
wildly incorrect results, especially with non-ASCII values.
|
||||
Going forward, please use TTF_GetFontKerningSizeGlyphs() instead, which
|
||||
does what you probably expected this function to do. */
|
||||
extern DECLSPEC int TTF_GetFontKerningSize(TTF_Font *font, int prev_index, int index) SDL_DEPRECATED;
|
||||
|
||||
/* Get the kerning size of two glyphs */
|
||||
extern DECLSPEC int TTF_GetFontKerningSizeGlyphs(TTF_Font *font, Uint16 previous_ch, Uint16 ch);
|
||||
extern DECLSPEC int TTF_GetFontKerningSizeGlyphs32(TTF_Font *font, Uint32 previous_ch, Uint32 ch);
|
||||
|
||||
/* Enable Signed Distance Field rendering (with the Blended APIs) */
|
||||
extern DECLSPEC int TTF_SetFontSDF(TTF_Font *font, SDL_bool on_off);
|
||||
extern DECLSPEC SDL_bool TTF_GetFontSDF(const TTF_Font *font);
|
||||
|
||||
/* We'll use SDL for reporting errors */
|
||||
#define TTF_SetError SDL_SetError
|
||||
#define TTF_GetError SDL_GetError
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#include "close_code.h"
|
||||
|
||||
#endif /* SDL_TTF_H_ */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -0,0 +1,173 @@
|
||||
The source code to this library used with SDL_ttf can be found here:
|
||||
https://github.com/libsdl-org/SDL_ttf/tree/main/external
|
||||
---
|
||||
|
||||
The FreeType Project LICENSE
|
||||
----------------------------
|
||||
|
||||
2006-Jan-27
|
||||
|
||||
Copyright 1996-2002, 2006 by
|
||||
David Turner, Robert Wilhelm, and Werner Lemberg
|
||||
|
||||
|
||||
|
||||
Introduction
|
||||
============
|
||||
|
||||
The FreeType Project is distributed in several archive packages;
|
||||
some of them may contain, in addition to the FreeType font engine,
|
||||
various tools and contributions which rely on, or relate to, the
|
||||
FreeType Project.
|
||||
|
||||
This license applies to all files found in such packages, and
|
||||
which do not fall under their own explicit license. The license
|
||||
affects thus the FreeType font engine, the test programs,
|
||||
documentation and makefiles, at the very least.
|
||||
|
||||
This license was inspired by the BSD, Artistic, and IJG
|
||||
(Independent JPEG Group) licenses, which all encourage inclusion
|
||||
and use of free software in commercial and freeware products
|
||||
alike. As a consequence, its main points are that:
|
||||
|
||||
o We don't promise that this software works. However, we will be
|
||||
interested in any kind of bug reports. (`as is' distribution)
|
||||
|
||||
o You can use this software for whatever you want, in parts or
|
||||
full form, without having to pay us. (`royalty-free' usage)
|
||||
|
||||
o You may not pretend that you wrote this software. If you use
|
||||
it, or only parts of it, in a program, you must acknowledge
|
||||
somewhere in your documentation that you have used the
|
||||
FreeType code. (`credits')
|
||||
|
||||
We specifically permit and encourage the inclusion of this
|
||||
software, with or without modifications, in commercial products.
|
||||
We disclaim all warranties covering The FreeType Project and
|
||||
assume no liability related to The FreeType Project.
|
||||
|
||||
|
||||
Finally, many people asked us for a preferred form for a
|
||||
credit/disclaimer to use in compliance with this license. We thus
|
||||
encourage you to use the following text:
|
||||
|
||||
"""
|
||||
Portions of this software are copyright © <year> The FreeType
|
||||
Project (www.freetype.org). All rights reserved.
|
||||
"""
|
||||
|
||||
Please replace <year> with the value from the FreeType version you
|
||||
actually use.
|
||||
|
||||
|
||||
Legal Terms
|
||||
===========
|
||||
|
||||
0. Definitions
|
||||
--------------
|
||||
|
||||
Throughout this license, the terms `package', `FreeType Project',
|
||||
and `FreeType archive' refer to the set of files originally
|
||||
distributed by the authors (David Turner, Robert Wilhelm, and
|
||||
Werner Lemberg) as the `FreeType Project', be they named as alpha,
|
||||
beta or final release.
|
||||
|
||||
`You' refers to the licensee, or person using the project, where
|
||||
`using' is a generic term including compiling the project's source
|
||||
code as well as linking it to form a `program' or `executable'.
|
||||
This program is referred to as `a program using the FreeType
|
||||
engine'.
|
||||
|
||||
This license applies to all files distributed in the original
|
||||
FreeType Project, including all source code, binaries and
|
||||
documentation, unless otherwise stated in the file in its
|
||||
original, unmodified form as distributed in the original archive.
|
||||
If you are unsure whether or not a particular file is covered by
|
||||
this license, you must contact us to verify this.
|
||||
|
||||
The FreeType Project is copyright (C) 1996-2000 by David Turner,
|
||||
Robert Wilhelm, and Werner Lemberg. All rights reserved except as
|
||||
specified below.
|
||||
|
||||
1. No Warranty
|
||||
--------------
|
||||
|
||||
THE FREETYPE PROJECT IS PROVIDED `AS IS' WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. IN NO EVENT WILL ANY OF THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
BE LIABLE FOR ANY DAMAGES CAUSED BY THE USE OR THE INABILITY TO
|
||||
USE, OF THE FREETYPE PROJECT.
|
||||
|
||||
2. Redistribution
|
||||
-----------------
|
||||
|
||||
This license grants a worldwide, royalty-free, perpetual and
|
||||
irrevocable right and license to use, execute, perform, compile,
|
||||
display, copy, create derivative works of, distribute and
|
||||
sublicense the FreeType Project (in both source and object code
|
||||
forms) and derivative works thereof for any purpose; and to
|
||||
authorize others to exercise some or all of the rights granted
|
||||
herein, subject to the following conditions:
|
||||
|
||||
o Redistribution of source code must retain this license file
|
||||
(`FTL.TXT') unaltered; any additions, deletions or changes to
|
||||
the original files must be clearly indicated in accompanying
|
||||
documentation. The copyright notices of the unaltered,
|
||||
original files must be preserved in all copies of source
|
||||
files.
|
||||
|
||||
o Redistribution in binary form must provide a disclaimer that
|
||||
states that the software is based in part of the work of the
|
||||
FreeType Team, in the distribution documentation. We also
|
||||
encourage you to put an URL to the FreeType web page in your
|
||||
documentation, though this isn't mandatory.
|
||||
|
||||
These conditions apply to any software derived from or based on
|
||||
the FreeType Project, not just the unmodified files. If you use
|
||||
our work, you must acknowledge us. However, no fee need be paid
|
||||
to us.
|
||||
|
||||
3. Advertising
|
||||
--------------
|
||||
|
||||
Neither the FreeType authors and contributors nor you shall use
|
||||
the name of the other for commercial, advertising, or promotional
|
||||
purposes without specific prior written permission.
|
||||
|
||||
We suggest, but do not require, that you use one or more of the
|
||||
following phrases to refer to this software in your documentation
|
||||
or advertising materials: `FreeType Project', `FreeType Engine',
|
||||
`FreeType library', or `FreeType Distribution'.
|
||||
|
||||
As you have not signed this license, you are not required to
|
||||
accept it. However, as the FreeType Project is copyrighted
|
||||
material, only this license, or another one contracted with the
|
||||
authors, grants you the right to use, distribute, and modify it.
|
||||
Therefore, by using, distributing, or modifying the FreeType
|
||||
Project, you indicate that you understand and accept all the terms
|
||||
of this license.
|
||||
|
||||
4. Contacts
|
||||
-----------
|
||||
|
||||
There are two mailing lists related to FreeType:
|
||||
|
||||
o [email protected]
|
||||
|
||||
Discusses general use and applications of FreeType, as well as
|
||||
future and wanted additions to the library and distribution.
|
||||
If you are looking for support, start in this list if you
|
||||
haven't found anything to help you in the documentation.
|
||||
|
||||
o [email protected]
|
||||
|
||||
Discusses bugs, as well as engine internals, design issues,
|
||||
specific licenses, porting, etc.
|
||||
|
||||
Our home page can be found at
|
||||
|
||||
https://www.freetype.org
|
||||
|
||||
|
||||
--- end of FTL.TXT ---
|
||||
@@ -0,0 +1,38 @@
|
||||
HarfBuzz is licensed under the so-called "Old MIT" license. Details follow.
|
||||
For parts of HarfBuzz that are licensed under different licenses see individual
|
||||
files names COPYING in subdirectories where applicable.
|
||||
|
||||
Copyright © 2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020 Google, Inc.
|
||||
Copyright © 2018,2019,2020 Ebrahim Byagowi
|
||||
Copyright © 2019,2020 Facebook, Inc.
|
||||
Copyright © 2012 Mozilla Foundation
|
||||
Copyright © 2011 Codethink Limited
|
||||
Copyright © 2008,2010 Nokia Corporation and/or its subsidiary(-ies)
|
||||
Copyright © 2009 Keith Stribley
|
||||
Copyright © 2009 Martin Hosken and SIL International
|
||||
Copyright © 2007 Chris Wilson
|
||||
Copyright © 2006 Behdad Esfahbod
|
||||
Copyright © 2005 David Turner
|
||||
Copyright © 2004,2007,2008,2009,2010 Red Hat, Inc.
|
||||
Copyright © 1998-2004 David Turner and Werner Lemberg
|
||||
|
||||
For full copyright notices consult the individual files in the package.
|
||||
|
||||
|
||||
Permission is hereby granted, without written agreement and without
|
||||
license or royalty fees, to use, copy, modify, and distribute this
|
||||
software and its documentation for any purpose, provided that the
|
||||
above copyright notice and the following two paragraphs appear in
|
||||
all copies of this software.
|
||||
|
||||
IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
|
||||
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
|
||||
ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
|
||||
IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGE.
|
||||
|
||||
THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
|
||||
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
||||
ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
|
||||
PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
||||
@@ -0,0 +1,31 @@
|
||||
The source code to this library used with SDL_ttf can be found here:
|
||||
https://github.com/libsdl-org/SDL_ttf/tree/main/external
|
||||
---
|
||||
|
||||
Copyright notice:
|
||||
|
||||
(C) 1995-2010 Jean-loup Gailly and Mark Adler
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jean-loup Gailly Mark Adler
|
||||
[email protected] [email protected]
|
||||
|
||||
If you use the zlib library in a product, we would appreciate *not* receiving
|
||||
lengthy legal documents to sign. The sources are provided for free but without
|
||||
warranty of any kind. The library has been entirely written by Jean-loup
|
||||
Gailly and Mark Adler; it does not include third-party code.
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -4,15 +4,18 @@
|
||||
#include "Scene\Scene.h"
|
||||
#include "Render\Renderer.h"
|
||||
#include "Assets\AssetManager.h"
|
||||
#include "Drawables\Sprite.h"
|
||||
#include "Logging\Logger.h"
|
||||
|
||||
#include "Drawables\Sprite.h"
|
||||
#include "Drawables\TextBox.h"
|
||||
|
||||
#include "Time\Time.h"
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <SDL.h>
|
||||
#include <SDL_ttf.h>
|
||||
|
||||
#include <ImGui\imgui.h>
|
||||
|
||||
@@ -40,6 +43,14 @@ public:
|
||||
sprites.push_back(sp2);
|
||||
sprites.push_back(bg);
|
||||
|
||||
UE::Font* OP_Regular = as->GetFont("OpenSans_Regular");
|
||||
//TTF_Font* OP_Bold = as->GetFont("OpenSans_Bold");
|
||||
|
||||
UE::TextBox text1(OP_Regular);
|
||||
//UE::TextBox text2(OP_Bold, "Otro texto");
|
||||
|
||||
texts.push_back(text1);
|
||||
//texts.push_back(text2);
|
||||
}
|
||||
|
||||
void SceneUpdate() override
|
||||
@@ -73,6 +84,10 @@ public:
|
||||
renderer->Render(sp);
|
||||
}
|
||||
}
|
||||
for (UE::TextBox& text : texts)
|
||||
{
|
||||
renderer->Render(text);
|
||||
}
|
||||
|
||||
ImguiRender();
|
||||
}
|
||||
@@ -95,7 +110,10 @@ public:
|
||||
break;
|
||||
}
|
||||
case SDLK_F2:
|
||||
{
|
||||
debugGUI = !debugGUI;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -187,6 +205,20 @@ private:
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
||||
ImGui::InputText("Text", textBuffer, 32);
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Set text"))
|
||||
{
|
||||
texts.at(0).SetText(textBuffer);
|
||||
}
|
||||
ImGui::InputInt("Text Size", &textSize);
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Set Size"))
|
||||
{
|
||||
texts.at(0).SetSize(textSize);
|
||||
}
|
||||
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
@@ -204,6 +236,7 @@ private:
|
||||
private:
|
||||
|
||||
std::vector<UE::Sprite> sprites;
|
||||
std::vector<UE::TextBox> texts;
|
||||
|
||||
//ImGui:
|
||||
bool _windowOpen = true;
|
||||
@@ -215,4 +248,6 @@ private:
|
||||
bool rendererGUI = false;
|
||||
bool sceneMngGUI = false;
|
||||
|
||||
char textBuffer[32] = {};
|
||||
int textSize = 12;
|
||||
};
|
||||
+5
-2
@@ -40,13 +40,14 @@ project (""..GameName.."")
|
||||
-- "UberEngine/vendor/json", --Header-Only
|
||||
"UberEngine/vendor/SDL/include",
|
||||
"UberEngine/vendor/SDL2_image/include",
|
||||
"UberEngine/vendor/SDL2_ttf/include",
|
||||
"UberEngine/vendor/spdlog/include",
|
||||
"UberEngine/vendor",
|
||||
"UberEngine/src"
|
||||
|
||||
}
|
||||
libdirs { "UberEngine/vendor/SDL/lib/x64", "UberEngine/vendor/SDL2_image/lib/x64" }
|
||||
links { "opengl32.lib", "SDL2.lib", "SDL2main.lib", "SDL2_image.lib" }
|
||||
libdirs { "UberEngine/vendor/SDL/lib/x64", "UberEngine/vendor/SDL2_image/lib/x64", "UberEngine/vendor/SDL2_ttf/lib/x64" }
|
||||
links { "opengl32.lib", "SDL2.lib", "SDL2main.lib", "SDL2_image.lib", "SDL2_ttf.lib" }
|
||||
|
||||
filter "system:windows"
|
||||
cppdialect "C++17"
|
||||
@@ -63,6 +64,7 @@ project (""..GameName.."")
|
||||
{
|
||||
"xcopy UberEngine\\vendor\\SDL\\lib\\x64\\*.dll bin\\Debug\\ /y /f",
|
||||
"xcopy UberEngine\\vendor\\SDL2_image\\lib\\x64\\*.dll bin\\Debug\\ /y /f",
|
||||
"xcopy UberEngine\\vendor\\SDL2_ttf\\lib\\x64\\*.dll bin\\Debug\\ /y /f",
|
||||
"xcopy resources\\ bin\\Debug\\resources\\ /e /y /f"
|
||||
}
|
||||
|
||||
@@ -77,5 +79,6 @@ project (""..GameName.."")
|
||||
{
|
||||
"xcopy UberEngine\\vendor\\SDL\\lib\\x64\\*.dll bin\\Release\\ /y /f",
|
||||
"xcopy UberEngine\\vendor\\SDL2_image\\lib\\x64\\*.dll bin\\Release\\ /y /f",
|
||||
"xcopy UberEngine\\vendor\\SDL2_ttf\\lib\\x64\\*.dll bin\\Release\\ /y /f",
|
||||
"xcopy resources\\ bin\\Release\\resources\\ /e /y /f"
|
||||
}
|
||||
@@ -26,6 +26,16 @@
|
||||
"Type": 0
|
||||
}
|
||||
],
|
||||
"SpriteSheets": [
|
||||
"Fonts": [
|
||||
{
|
||||
"name": "OpenSans_Regular",
|
||||
"Path": "resources/AssetsData/FontsData/OpenSansFont.json",
|
||||
"Type": 1
|
||||
},
|
||||
{
|
||||
"name": "OpenSans_Bold",
|
||||
"Path": "resources/AssetsData/FontsData/OpenSansFont.json",
|
||||
"Type": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"FontPath": "resources/Fonts/OpenSans-Regular.ttf",
|
||||
"FontSizes": [12, 18, 24]
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,100 @@
|
||||
Open Sans Variable Font
|
||||
=======================
|
||||
|
||||
This download contains Open Sans as both variable fonts and static fonts.
|
||||
|
||||
Open Sans is a variable font with these axes:
|
||||
wdth
|
||||
wght
|
||||
|
||||
This means all the styles are contained in these files:
|
||||
OpenSans-VariableFont_wdth,wght.ttf
|
||||
OpenSans-Italic-VariableFont_wdth,wght.ttf
|
||||
|
||||
If your app fully supports variable fonts, you can now pick intermediate styles
|
||||
that aren’t available as static fonts. Not all apps support variable fonts, and
|
||||
in those cases you can use the static font files for Open Sans:
|
||||
static/OpenSans_Condensed/OpenSans_Condensed-Light.ttf
|
||||
static/OpenSans_Condensed/OpenSans_Condensed-Regular.ttf
|
||||
static/OpenSans_Condensed/OpenSans_Condensed-Medium.ttf
|
||||
static/OpenSans_Condensed/OpenSans_Condensed-SemiBold.ttf
|
||||
static/OpenSans_Condensed/OpenSans_Condensed-Bold.ttf
|
||||
static/OpenSans_Condensed/OpenSans_Condensed-ExtraBold.ttf
|
||||
static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-Light.ttf
|
||||
static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-Regular.ttf
|
||||
static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-Medium.ttf
|
||||
static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-SemiBold.ttf
|
||||
static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-Bold.ttf
|
||||
static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-ExtraBold.ttf
|
||||
static/OpenSans/OpenSans-Light.ttf
|
||||
static/OpenSans/OpenSans-Regular.ttf
|
||||
static/OpenSans/OpenSans-Medium.ttf
|
||||
static/OpenSans/OpenSans-SemiBold.ttf
|
||||
static/OpenSans/OpenSans-Bold.ttf
|
||||
static/OpenSans/OpenSans-ExtraBold.ttf
|
||||
static/OpenSans_Condensed/OpenSans_Condensed-LightItalic.ttf
|
||||
static/OpenSans_Condensed/OpenSans_Condensed-Italic.ttf
|
||||
static/OpenSans_Condensed/OpenSans_Condensed-MediumItalic.ttf
|
||||
static/OpenSans_Condensed/OpenSans_Condensed-SemiBoldItalic.ttf
|
||||
static/OpenSans_Condensed/OpenSans_Condensed-BoldItalic.ttf
|
||||
static/OpenSans_Condensed/OpenSans_Condensed-ExtraBoldItalic.ttf
|
||||
static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-LightItalic.ttf
|
||||
static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-Italic.ttf
|
||||
static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-MediumItalic.ttf
|
||||
static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-SemiBoldItalic.ttf
|
||||
static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-BoldItalic.ttf
|
||||
static/OpenSans_SemiCondensed/OpenSans_SemiCondensed-ExtraBoldItalic.ttf
|
||||
static/OpenSans/OpenSans-LightItalic.ttf
|
||||
static/OpenSans/OpenSans-Italic.ttf
|
||||
static/OpenSans/OpenSans-MediumItalic.ttf
|
||||
static/OpenSans/OpenSans-SemiBoldItalic.ttf
|
||||
static/OpenSans/OpenSans-BoldItalic.ttf
|
||||
static/OpenSans/OpenSans-ExtraBoldItalic.ttf
|
||||
|
||||
Get started
|
||||
-----------
|
||||
|
||||
1. Install the font files you want to use
|
||||
|
||||
2. Use your app's font picker to view the font family and all the
|
||||
available styles
|
||||
|
||||
Learn more about variable fonts
|
||||
-------------------------------
|
||||
|
||||
https://developers.google.com/web/fundamentals/design-and-ux/typography/variable-fonts
|
||||
https://variablefonts.typenetwork.com
|
||||
https://medium.com/variable-fonts
|
||||
|
||||
In desktop apps
|
||||
|
||||
https://theblog.adobe.com/can-variable-fonts-illustrator-cc
|
||||
https://helpx.adobe.com/nz/photoshop/using/fonts.html#variable_fonts
|
||||
|
||||
Online
|
||||
|
||||
https://developers.google.com/fonts/docs/getting_started
|
||||
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Fonts/Variable_Fonts_Guide
|
||||
https://developer.microsoft.com/en-us/microsoft-edge/testdrive/demos/variable-fonts
|
||||
|
||||
Installing fonts
|
||||
|
||||
MacOS: https://support.apple.com/en-us/HT201749
|
||||
Linux: https://www.google.com/search?q=how+to+install+a+font+on+gnu%2Blinux
|
||||
Windows: https://support.microsoft.com/en-us/help/314960/how-to-install-or-remove-a-font-in-windows
|
||||
|
||||
Android Apps
|
||||
|
||||
https://developers.google.com/fonts/docs/android
|
||||
https://developer.android.com/guide/topics/ui/look-and-feel/downloadable-fonts
|
||||
|
||||
License
|
||||
-------
|
||||
Please read the full license text (LICENSE.txt) to understand the permissions,
|
||||
restrictions and requirements for usage, redistribution, and modification.
|
||||
|
||||
You can use them freely in your products & projects - print or digital,
|
||||
commercial or otherwise.
|
||||
|
||||
This isn't legal advice, please consider consulting a lawyer and see the full
|
||||
license for all details.
|
||||
Reference in New Issue
Block a user