New upstream version 26.0.0+dfsg1
This commit is contained in:
parent
8e020cdacb
commit
240080891f
837 changed files with 41275 additions and 9196 deletions
|
|
@ -77,6 +77,7 @@ target_link_libraries(text-freetype2
|
|||
libobs
|
||||
${text-freetype2_PLATFORM_DEPS}
|
||||
${FREETYPE_LIBRARIES})
|
||||
set_target_properties(text-freetype2 PROPERTIES FOLDER "plugins")
|
||||
|
||||
if(NOT WIN32)
|
||||
if(FONTCONFIG_FOUND)
|
||||
|
|
|
|||
|
|
@ -10,4 +10,5 @@ DropShadow="ظل"
|
|||
ReadFromFile="قراءة من ملف"
|
||||
CustomWidth="عرض نص مخصص"
|
||||
WordWrap="التفاف الكلمة"
|
||||
Antialiasing="تمكين التنعيم"
|
||||
|
||||
|
|
|
|||
9
plugins/text-freetype2/data/locale/ba-RU.ini
Normal file
9
plugins/text-freetype2/data/locale/ba-RU.ini
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
TextFreetype2="Текст (FreeType 2)"
|
||||
Font="Хәреф"
|
||||
Text="Текст"
|
||||
TextFile="Текст файлы (UTF-8 or UTF-16)"
|
||||
TextFileFilter="Текст файлдары (*.txt);;"
|
||||
Color1="Төҫ 1"
|
||||
Color2="Төҫ 2"
|
||||
DropShadow="Күләгә"
|
||||
|
||||
|
|
@ -12,4 +12,5 @@ DropShadow="Ombra"
|
|||
ReadFromFile="Llegeix del fitxer"
|
||||
CustomWidth="Amplada de text personalitzada"
|
||||
WordWrap="Ajustament de línia"
|
||||
Antialiasing="Activa l'antialiàsing"
|
||||
|
||||
|
|
|
|||
|
|
@ -12,4 +12,5 @@ DropShadow="Vrhat stín"
|
|||
ReadFromFile="Číst ze souboru"
|
||||
CustomWidth="Vlastní šířka textu"
|
||||
WordWrap="Zalamování řádků"
|
||||
Antialiasing="Povolit Antialiasing"
|
||||
|
||||
|
|
|
|||
|
|
@ -12,4 +12,5 @@ DropShadow="Drop Shadow"
|
|||
ReadFromFile="Læs fra fil"
|
||||
CustomWidth="Tilpasset tekstbredde"
|
||||
WordWrap="Tekstombrydning"
|
||||
Antialiasing="Aktivér udjævning (antialiasing)"
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ Font="Schriftart"
|
|||
Text="Text"
|
||||
TextFile="Textdatei (UTF‐8 oder UTF‐16)"
|
||||
TextFileFilter="Textdateien (*.txt);;"
|
||||
ChatLogMode="Chatprotokollmodus"
|
||||
ChatLogLines="Chatprotokollzeilen"
|
||||
ChatLogMode="Chatlogmodus"
|
||||
ChatLogLines="Chatlogzeilen"
|
||||
Color1="Farbe 1"
|
||||
Color2="Farbe 2"
|
||||
Outline="Umrandung"
|
||||
|
|
@ -12,4 +12,5 @@ DropShadow="Schlagschatten"
|
|||
ReadFromFile="Aus Datei lesen"
|
||||
CustomWidth="Benutzerdefinierte Textbreite"
|
||||
WordWrap="Zeilenumbruch"
|
||||
Antialiasing="Antialiasing aktivieren"
|
||||
|
||||
|
|
|
|||
16
plugins/text-freetype2/data/locale/en-GB.ini
Normal file
16
plugins/text-freetype2/data/locale/en-GB.ini
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
TextFreetype2="Text (FreeType 2)"
|
||||
Font="Font"
|
||||
Text="Text"
|
||||
TextFile="Text File (UTF-8 or UTF-16)"
|
||||
TextFileFilter="Text Files (*.txt);;"
|
||||
ChatLogMode="Chat log mode"
|
||||
ChatLogLines="Chat log lines"
|
||||
Color1="Colour 1"
|
||||
Color2="Colour 2"
|
||||
Outline="Outline"
|
||||
DropShadow="Drop Shadow"
|
||||
ReadFromFile="Read from file"
|
||||
CustomWidth="Custom text width"
|
||||
WordWrap="Word Wrap"
|
||||
Antialiasing="Enable Antialiasing"
|
||||
|
||||
|
|
@ -12,3 +12,4 @@ DropShadow="Drop Shadow"
|
|||
ReadFromFile="Read from file"
|
||||
CustomWidth="Custom text width"
|
||||
WordWrap="Word Wrap"
|
||||
Antialiasing="Enable Antialiasing"
|
||||
|
|
|
|||
|
|
@ -12,4 +12,5 @@ DropShadow="Texto sombreado"
|
|||
ReadFromFile="Leer desde archivo"
|
||||
CustomWidth="Ancho de texto personalizado"
|
||||
WordWrap="Ajuste de línea"
|
||||
Antialiasing="Habilitar Antialiasing"
|
||||
|
||||
|
|
|
|||
|
|
@ -12,4 +12,5 @@ DropShadow="Varjo"
|
|||
ReadFromFile="Lue tiedostosta"
|
||||
CustomWidth="Mukautettu tekstin pituus"
|
||||
WordWrap="Sido"
|
||||
Antialiasing="Ota reunanpehmennys käyttöön"
|
||||
|
||||
|
|
|
|||
|
|
@ -12,4 +12,5 @@ DropShadow="Ombre portée"
|
|||
ReadFromFile="Lire depuis le fichier"
|
||||
CustomWidth="Largeur du texte personnalisée"
|
||||
WordWrap="Retour à la ligne automatique"
|
||||
Antialiasing="Activer le lissage de la police"
|
||||
|
||||
|
|
|
|||
|
|
@ -12,4 +12,5 @@ DropShadow="Texto sombreado"
|
|||
ReadFromFile="Ler a partir dun ficheiro"
|
||||
CustomWidth="Personalizar a largura do texto"
|
||||
WordWrap="Axuste de liña"
|
||||
Antialiasing="Activar o suavizado"
|
||||
|
||||
|
|
|
|||
|
|
@ -12,4 +12,5 @@ DropShadow="Vetett árnyék"
|
|||
ReadFromFile="Fájlból olvasás"
|
||||
CustomWidth="Egyedi szövegszélesség"
|
||||
WordWrap="Sortörés"
|
||||
Antialiasing="Élsimítás bekapcsolása"
|
||||
|
||||
|
|
|
|||
16
plugins/text-freetype2/data/locale/id-ID.ini
Normal file
16
plugins/text-freetype2/data/locale/id-ID.ini
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
TextFreetype2="Teks (FreeType 2)"
|
||||
Font="Font"
|
||||
Text="Teks"
|
||||
TextFile="File Teks (UTF-8 atau UTF-16)"
|
||||
TextFileFilter="File Teks (*.txt);;"
|
||||
ChatLogMode="Mode log chat"
|
||||
ChatLogLines="Baris log chat"
|
||||
Color1="Warna 1"
|
||||
Color2="Warna 2"
|
||||
Outline="Kerangka"
|
||||
DropShadow="Bayangan Jatuh"
|
||||
ReadFromFile="Baca dari file"
|
||||
CustomWidth="Lebar teks kustom"
|
||||
WordWrap="Atur Kata"
|
||||
Antialiasing="Aktifkan Antialiasing"
|
||||
|
||||
|
|
@ -12,4 +12,5 @@ DropShadow="Ombreggiatura del testo"
|
|||
ReadFromFile="Leggi da file"
|
||||
CustomWidth="Larghezza del testo personalizzata"
|
||||
WordWrap="A capo automatico"
|
||||
Antialiasing="Abilita Antialiasing"
|
||||
|
||||
|
|
|
|||
|
|
@ -12,4 +12,5 @@ DropShadow="影をつける"
|
|||
ReadFromFile="ファイルからの読み取り"
|
||||
CustomWidth="カスタムテキスト幅"
|
||||
WordWrap="折り返し表示"
|
||||
Antialiasing="アンチエイリアスを有効にする"
|
||||
|
||||
|
|
|
|||
|
|
@ -12,4 +12,5 @@ DropShadow="დაჩრდილვა"
|
|||
ReadFromFile="ფაილიდან წაკითხვა"
|
||||
CustomWidth="ტექსტის მითითებული სიგანე"
|
||||
WordWrap="სიტყვების გადატანა"
|
||||
Antialiasing="დაკბილვის არიდება"
|
||||
|
||||
|
|
|
|||
|
|
@ -12,4 +12,5 @@ DropShadow="그림자 삽입"
|
|||
ReadFromFile="파일에서 읽기"
|
||||
CustomWidth="임의 텍스트 너비"
|
||||
WordWrap="자동 줄 바꿈"
|
||||
Antialiasing="Antialiasing 사용"
|
||||
|
||||
|
|
|
|||
|
|
@ -12,4 +12,5 @@ DropShadow="Slagschaduw"
|
|||
ReadFromFile="Lees uit bestand"
|
||||
CustomWidth="Aangepaste tekstbreedte"
|
||||
WordWrap="Word Wrap"
|
||||
Antialiasing="Anti-aliasing inschakelen"
|
||||
|
||||
|
|
|
|||
|
|
@ -12,4 +12,5 @@ DropShadow="Cień"
|
|||
ReadFromFile="Czytaj z pliku"
|
||||
CustomWidth="Własna szerokość tekstu"
|
||||
WordWrap="Zawijanie wierszy"
|
||||
Antialiasing="Włącz antyaliasing"
|
||||
|
||||
|
|
|
|||
|
|
@ -12,4 +12,5 @@ DropShadow="Sombra"
|
|||
ReadFromFile="Ler de arquivo"
|
||||
CustomWidth="Largura do texto personalizada"
|
||||
WordWrap="Quebra de Linha"
|
||||
Antialiasing="Ativar Anti-Aliasing"
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ Font="Font"
|
|||
Text="Text"
|
||||
TextFile="Fișier text (UTF-8 sau UTF-16)"
|
||||
TextFileFilter="Fișiere text (*.txt);;"
|
||||
ChatLogMode="Mod jurnal chat"
|
||||
ChatLogLines="Linii jurnal chat"
|
||||
Color1="Culoarea 1"
|
||||
Color2="Culoarea 2"
|
||||
Outline="Contur"
|
||||
|
|
@ -10,4 +12,5 @@ DropShadow="Umbrire"
|
|||
ReadFromFile="Citește din fișier"
|
||||
CustomWidth="Lățime de text personalizată"
|
||||
WordWrap="Încadrare pentru cuvinte"
|
||||
Antialiasing="Activează antialiasing"
|
||||
|
||||
|
|
|
|||
|
|
@ -12,4 +12,5 @@ DropShadow="Тень"
|
|||
ReadFromFile="Чтение из файла"
|
||||
CustomWidth="Пользовательская ширина текста"
|
||||
WordWrap="Перенос слов"
|
||||
Antialiasing="Включить сглаживание"
|
||||
|
||||
|
|
|
|||
|
|
@ -12,4 +12,5 @@ DropShadow="Tieň"
|
|||
ReadFromFile="Čítať zo súboru"
|
||||
CustomWidth="Vlastná šírka textu"
|
||||
WordWrap="Zalamovanie textu"
|
||||
Antialiasing="Povoliť vyhladenie hrán"
|
||||
|
||||
|
|
|
|||
|
|
@ -12,4 +12,5 @@ DropShadow="Odajaj senco"
|
|||
ReadFromFile="Preberi iz datoteke"
|
||||
CustomWidth="Širina besedila po meri"
|
||||
WordWrap="Prelomi besedilo"
|
||||
Antialiasing="Omogoči glajenje robov"
|
||||
|
||||
|
|
|
|||
|
|
@ -12,4 +12,5 @@ DropShadow="Skugga"
|
|||
ReadFromFile="Läsa från fil"
|
||||
CustomWidth="Anpassad textbredd"
|
||||
WordWrap="Radbrytning"
|
||||
Antialiasing="Aktivera kantutjämning"
|
||||
|
||||
|
|
|
|||
10
plugins/text-freetype2/data/locale/ta-IN.ini
Normal file
10
plugins/text-freetype2/data/locale/ta-IN.ini
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
TextFreetype2="உரை (FreeType 2)"
|
||||
Font="எழுத்துரு"
|
||||
Text="உரை"
|
||||
TextFile="உரை கோப்பு (UTF-8 அல்லது UTF-16)"
|
||||
TextFileFilter="உரை கோப்புகள் (*.txt);;"
|
||||
Color1="வண்ணம் 1"
|
||||
Color2="வண்ணம் 2"
|
||||
ReadFromFile="கோப்பிலிருந்துப் படி"
|
||||
CustomWidth="தனிப்பயன் உரை அகலம்"
|
||||
|
||||
|
|
@ -12,4 +12,5 @@ DropShadow="Alt Gölge"
|
|||
ReadFromFile="Dosyadan oku"
|
||||
CustomWidth="Özel metin genişliği"
|
||||
WordWrap="Sözcük Kaydırma"
|
||||
Antialiasing="Yumuşatmayı Etkinleştir"
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ Color1="Колір 1"
|
|||
Color2="Колір 2"
|
||||
Outline="Контур"
|
||||
DropShadow="Тінь"
|
||||
ReadFromFile="Текст з файлу"
|
||||
ReadFromFile="Читати з файлу"
|
||||
CustomWidth="Фіксована ширина тексту"
|
||||
WordWrap="Перенос слів"
|
||||
WordWrap="Перенос по словах"
|
||||
Antialiasing="Увімкнути згладжування"
|
||||
|
||||
|
|
|
|||
|
|
@ -10,4 +10,5 @@ DropShadow="Đổ bóng"
|
|||
ReadFromFile="Đọc từ tệp"
|
||||
CustomWidth="Tùy chỉnh độ rộng ký tự"
|
||||
WordWrap="Bọc từ"
|
||||
Antialiasing="Bật khử răng cưa"
|
||||
|
||||
|
|
|
|||
|
|
@ -12,4 +12,5 @@ DropShadow="阴影"
|
|||
ReadFromFile="从文件读取"
|
||||
CustomWidth="自定义文本宽度"
|
||||
WordWrap="自动换行"
|
||||
Antialiasing="启用抗锯齿"
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ Text="文字"
|
|||
TextFile="文字檔案 (UTF-8 或 UTF-16)"
|
||||
TextFileFilter="文字檔案 (*.txt);;"
|
||||
ChatLogMode="聊天記錄模式"
|
||||
ChatLogLines="聊天記錄行"
|
||||
ChatLogLines="聊天記錄列"
|
||||
Color1="顏色 1"
|
||||
Color2="顏色 2"
|
||||
Outline="外框"
|
||||
|
|
@ -12,4 +12,5 @@ DropShadow="陰影效果"
|
|||
ReadFromFile="從檔案讀取"
|
||||
CustomWidth="自定文字寬度"
|
||||
WordWrap="自動換行"
|
||||
Antialiasing="啟用反鋸齒"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/******************************************************************************
|
||||
/******************************************************************************
|
||||
Copyright (C) 2014 by Nibbles
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -125,14 +125,14 @@ static uint32_t ft2_source_get_width(void *data)
|
|||
{
|
||||
struct ft2_source *srcdata = data;
|
||||
|
||||
return srcdata->cx;
|
||||
return srcdata->cx + srcdata->outline_width;
|
||||
}
|
||||
|
||||
static uint32_t ft2_source_get_height(void *data)
|
||||
{
|
||||
struct ft2_source *srcdata = data;
|
||||
|
||||
return srcdata->cy;
|
||||
return srcdata->cy + srcdata->outline_width;
|
||||
}
|
||||
|
||||
static obs_properties_t *ft2_source_properties(void *unused)
|
||||
|
|
@ -156,6 +156,9 @@ static obs_properties_t *ft2_source_properties(void *unused)
|
|||
obs_properties_add_bool(props, "from_file",
|
||||
obs_module_text("ReadFromFile"));
|
||||
|
||||
obs_properties_add_bool(props, "antialiasing",
|
||||
obs_module_text("Antialiasing"));
|
||||
|
||||
obs_properties_add_bool(props, "log_mode",
|
||||
obs_module_text("ChatLogMode"));
|
||||
|
||||
|
|
@ -322,8 +325,16 @@ static void ft2_source_update(void *data, obs_data_t *settings)
|
|||
if (!font_obj)
|
||||
return;
|
||||
|
||||
srcdata->outline_width = 0;
|
||||
|
||||
srcdata->drop_shadow = obs_data_get_bool(settings, "drop_shadow");
|
||||
srcdata->outline_text = obs_data_get_bool(settings, "outline");
|
||||
|
||||
if (srcdata->outline_text && srcdata->drop_shadow)
|
||||
srcdata->outline_width = 6;
|
||||
else if (srcdata->outline_text || srcdata->drop_shadow)
|
||||
srcdata->outline_width = 4;
|
||||
|
||||
word_wrap = obs_data_get_bool(settings, "word_wrap");
|
||||
|
||||
color[0] = (uint32_t)obs_data_get_int(settings, "color1");
|
||||
|
|
@ -365,6 +376,8 @@ static void ft2_source_update(void *data, obs_data_t *settings)
|
|||
if (ft2_lib == NULL)
|
||||
goto error;
|
||||
|
||||
const size_t texbuf_size = (size_t)texbuf_w * (size_t)texbuf_h;
|
||||
|
||||
if (srcdata->draw_effect == NULL) {
|
||||
char *effect_file = NULL;
|
||||
char *error_string = NULL;
|
||||
|
|
@ -386,6 +399,16 @@ static void ft2_source_update(void *data, obs_data_t *settings)
|
|||
if (srcdata->font_size != font_size || srcdata->from_file != from_file)
|
||||
vbuf_needs_update = true;
|
||||
|
||||
const bool new_aa_setting = obs_data_get_bool(settings, "antialiasing");
|
||||
const bool aa_changed = srcdata->antialiasing != new_aa_setting;
|
||||
if (aa_changed) {
|
||||
srcdata->antialiasing = new_aa_setting;
|
||||
if (srcdata->texbuf != NULL) {
|
||||
memset(srcdata->texbuf, 0, texbuf_size);
|
||||
}
|
||||
cache_standard_glyphs(srcdata);
|
||||
}
|
||||
|
||||
srcdata->file_load_failed = false;
|
||||
srcdata->from_file = from_file;
|
||||
|
||||
|
|
@ -422,7 +445,7 @@ static void ft2_source_update(void *data, obs_data_t *settings)
|
|||
bfree(srcdata->texbuf);
|
||||
srcdata->texbuf = NULL;
|
||||
}
|
||||
srcdata->texbuf = bzalloc(texbuf_w * texbuf_h);
|
||||
srcdata->texbuf = bzalloc(texbuf_size);
|
||||
|
||||
if (srcdata->font_face)
|
||||
cache_standard_glyphs(srcdata);
|
||||
|
|
@ -505,6 +528,8 @@ static void *ft2_source_create(obs_data_t *settings, obs_source_t *source,
|
|||
obs_data_set_default_int(font_obj, "size", font_size);
|
||||
obs_data_set_default_obj(settings, "font", font_obj);
|
||||
|
||||
obs_data_set_default_bool(settings, "antialiasing", true);
|
||||
|
||||
obs_data_set_default_int(settings, "log_lines", 6);
|
||||
|
||||
obs_data_set_default_int(settings, "color1", 0xFFFFFFFF);
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ struct ft2_source {
|
|||
|
||||
bool file_load_failed;
|
||||
bool from_file;
|
||||
bool antialiasing;
|
||||
char *text_file;
|
||||
wchar_t *text;
|
||||
time_t m_timestamp;
|
||||
|
|
@ -44,6 +45,7 @@ struct ft2_source {
|
|||
uint64_t last_checked;
|
||||
|
||||
uint32_t cx, cy, max_h, custom_width;
|
||||
uint32_t outline_width;
|
||||
uint32_t texbuf_x, texbuf_y;
|
||||
uint32_t color[2];
|
||||
uint32_t *colorbuf;
|
||||
|
|
|
|||
|
|
@ -162,8 +162,14 @@ void fill_vertex_buffer(struct ft2_source *srcdata)
|
|||
|
||||
uint32_t dx = 0, dy = srcdata->max_h, max_y = dy;
|
||||
uint32_t cur_glyph = 0;
|
||||
uint32_t offset = 0;
|
||||
size_t len = wcslen(srcdata->text);
|
||||
|
||||
if (srcdata->outline_text) {
|
||||
offset = 2;
|
||||
dx = offset;
|
||||
}
|
||||
|
||||
if (srcdata->colorbuf != NULL) {
|
||||
bfree(srcdata->colorbuf);
|
||||
srcdata->colorbuf = NULL;
|
||||
|
|
@ -178,7 +184,7 @@ void fill_vertex_buffer(struct ft2_source *srcdata)
|
|||
add_linebreak:;
|
||||
if (srcdata->text[i] != L'\n')
|
||||
goto draw_glyph;
|
||||
dx = 0;
|
||||
dx = offset;
|
||||
i++;
|
||||
dy += srcdata->max_h + 4;
|
||||
if (i == wcslen(srcdata->text))
|
||||
|
|
@ -199,7 +205,7 @@ void fill_vertex_buffer(struct ft2_source *srcdata)
|
|||
goto skip_custom_width;
|
||||
|
||||
if (dx + src_glyph->xadv > srcdata->custom_width) {
|
||||
dx = 0;
|
||||
dx = offset;
|
||||
dy += srcdata->max_h + 4;
|
||||
}
|
||||
|
||||
|
|
@ -240,39 +246,110 @@ void cache_standard_glyphs(struct ft2_source *srcdata)
|
|||
L"!@#$%^&*()-_=+,<.>/?\\|[]{}`~ \'\"\0");
|
||||
}
|
||||
|
||||
#define glyph_pos x + (y * slot->bitmap.pitch)
|
||||
#define buf_pos (dx + x) + ((dy + y) * texbuf_w)
|
||||
FT_Render_Mode get_render_mode(struct ft2_source *srcdata)
|
||||
{
|
||||
return srcdata->antialiasing ? FT_RENDER_MODE_NORMAL
|
||||
: FT_RENDER_MODE_MONO;
|
||||
}
|
||||
|
||||
void load_glyph(struct ft2_source *srcdata, const FT_UInt glyph_index,
|
||||
const FT_Render_Mode render_mode)
|
||||
{
|
||||
const FT_Int32 load_mode = render_mode == FT_RENDER_MODE_MONO
|
||||
? FT_LOAD_TARGET_MONO
|
||||
: FT_LOAD_DEFAULT;
|
||||
FT_Load_Glyph(srcdata->font_face, glyph_index, load_mode);
|
||||
}
|
||||
|
||||
struct glyph_info *init_glyph(FT_GlyphSlot slot, const uint32_t dx,
|
||||
const uint32_t dy, const uint32_t g_w,
|
||||
const uint32_t g_h)
|
||||
{
|
||||
struct glyph_info *glyph = bzalloc(sizeof(struct glyph_info));
|
||||
glyph->u = (float)dx / (float)texbuf_w;
|
||||
glyph->u2 = (float)(dx + g_w) / (float)texbuf_w;
|
||||
glyph->v = (float)dy / (float)texbuf_h;
|
||||
glyph->v2 = (float)(dy + g_h) / (float)texbuf_h;
|
||||
glyph->w = g_w;
|
||||
glyph->h = g_h;
|
||||
glyph->yoff = slot->bitmap_top;
|
||||
glyph->xoff = slot->bitmap_left;
|
||||
glyph->xadv = slot->advance.x >> 6;
|
||||
|
||||
return glyph;
|
||||
}
|
||||
|
||||
uint8_t get_pixel_value(const unsigned char *buf_row,
|
||||
FT_Render_Mode render_mode, const uint32_t x)
|
||||
{
|
||||
if (render_mode == FT_RENDER_MODE_NORMAL) {
|
||||
return buf_row[x];
|
||||
}
|
||||
|
||||
const uint32_t byte_index = x / 8;
|
||||
const uint8_t bit_index = x % 8;
|
||||
const bool pixel_set = (buf_row[byte_index] >> (7 - bit_index)) & 1;
|
||||
return pixel_set ? 255 : 0;
|
||||
}
|
||||
|
||||
void rasterize(struct ft2_source *srcdata, FT_GlyphSlot slot,
|
||||
const FT_Render_Mode render_mode, const uint32_t dx,
|
||||
const uint32_t dy)
|
||||
{
|
||||
/**
|
||||
* The pitch's absolute value is the number of bytes taken by one bitmap
|
||||
* row, including padding.
|
||||
*
|
||||
* Source: https://www.freetype.org/freetype2/docs/reference/ft2-basic_types.html
|
||||
*/
|
||||
const int pitch = abs(slot->bitmap.pitch);
|
||||
|
||||
for (uint32_t y = 0; y < slot->bitmap.rows; y++) {
|
||||
const uint32_t row_start = y * pitch;
|
||||
const uint32_t row = (dy + y) * texbuf_w;
|
||||
|
||||
for (uint32_t x = 0; x < slot->bitmap.width; x++) {
|
||||
const uint32_t row_pixel_position = dx + x;
|
||||
const uint8_t pixel_value =
|
||||
get_pixel_value(&slot->bitmap.buffer[row_start],
|
||||
render_mode, x);
|
||||
srcdata->texbuf[row_pixel_position + row] = pixel_value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cache_glyphs(struct ft2_source *srcdata, wchar_t *cache_glyphs)
|
||||
{
|
||||
FT_GlyphSlot slot;
|
||||
FT_UInt glyph_index = 0;
|
||||
|
||||
if (!srcdata->font_face || !cache_glyphs)
|
||||
return;
|
||||
|
||||
slot = srcdata->font_face->glyph;
|
||||
FT_GlyphSlot slot = srcdata->font_face->glyph;
|
||||
|
||||
uint32_t dx = srcdata->texbuf_x, dy = srcdata->texbuf_y;
|
||||
uint32_t dx = srcdata->texbuf_x;
|
||||
uint32_t dy = srcdata->texbuf_y;
|
||||
|
||||
int32_t cached_glyphs = 0;
|
||||
size_t len = wcslen(cache_glyphs);
|
||||
const size_t len = wcslen(cache_glyphs);
|
||||
|
||||
const FT_Render_Mode render_mode = get_render_mode(srcdata);
|
||||
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
glyph_index =
|
||||
const FT_UInt glyph_index =
|
||||
FT_Get_Char_Index(srcdata->font_face, cache_glyphs[i]);
|
||||
|
||||
if (src_glyph != NULL)
|
||||
goto skip_glyph;
|
||||
if (src_glyph != NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FT_Load_Glyph(srcdata->font_face, glyph_index, FT_LOAD_DEFAULT);
|
||||
FT_Render_Glyph(slot, FT_RENDER_MODE_NORMAL);
|
||||
load_glyph(srcdata, glyph_index, render_mode);
|
||||
FT_Render_Glyph(slot, render_mode);
|
||||
|
||||
uint32_t g_w = slot->bitmap.width;
|
||||
uint32_t g_h = slot->bitmap.rows;
|
||||
const uint32_t g_w = slot->bitmap.width;
|
||||
const uint32_t g_h = slot->bitmap.rows;
|
||||
|
||||
if (srcdata->max_h < g_h)
|
||||
if (srcdata->max_h < g_h) {
|
||||
srcdata->max_h = g_h;
|
||||
}
|
||||
|
||||
if (dx + g_w >= texbuf_w) {
|
||||
dx = 0;
|
||||
|
|
@ -285,22 +362,8 @@ void cache_glyphs(struct ft2_source *srcdata, wchar_t *cache_glyphs)
|
|||
break;
|
||||
}
|
||||
|
||||
src_glyph = bzalloc(sizeof(struct glyph_info));
|
||||
src_glyph->u = (float)dx / (float)texbuf_w;
|
||||
src_glyph->u2 = (float)(dx + g_w) / (float)texbuf_w;
|
||||
src_glyph->v = (float)dy / (float)texbuf_h;
|
||||
src_glyph->v2 = (float)(dy + g_h) / (float)texbuf_h;
|
||||
src_glyph->w = g_w;
|
||||
src_glyph->h = g_h;
|
||||
src_glyph->yoff = slot->bitmap_top;
|
||||
src_glyph->xoff = slot->bitmap_left;
|
||||
src_glyph->xadv = slot->advance.x >> 6;
|
||||
|
||||
for (uint32_t y = 0; y < g_h; y++) {
|
||||
for (uint32_t x = 0; x < g_w; x++)
|
||||
srcdata->texbuf[buf_pos] =
|
||||
slot->bitmap.buffer[glyph_pos];
|
||||
}
|
||||
src_glyph = init_glyph(slot, dx, dy, g_w, g_h);
|
||||
rasterize(srcdata, slot, render_mode, dx, dy);
|
||||
|
||||
dx += (g_w + 1);
|
||||
if (dx >= texbuf_w) {
|
||||
|
|
@ -309,7 +372,6 @@ void cache_glyphs(struct ft2_source *srcdata, wchar_t *cache_glyphs)
|
|||
}
|
||||
|
||||
cached_glyphs++;
|
||||
skip_glyph:;
|
||||
}
|
||||
|
||||
srcdata->texbuf_x = dx;
|
||||
|
|
@ -320,8 +382,7 @@ void cache_glyphs(struct ft2_source *srcdata, wchar_t *cache_glyphs)
|
|||
obs_enter_graphics();
|
||||
|
||||
if (srcdata->tex != NULL) {
|
||||
gs_texture_t *tmp_texture = NULL;
|
||||
tmp_texture = srcdata->tex;
|
||||
gs_texture_t *tmp_texture = srcdata->tex;
|
||||
srcdata->tex = NULL;
|
||||
gs_texture_destroy(tmp_texture);
|
||||
}
|
||||
|
|
@ -497,18 +558,18 @@ void read_from_end(struct ft2_source *srcdata, const char *filename)
|
|||
|
||||
uint32_t get_ft2_text_width(wchar_t *text, struct ft2_source *srcdata)
|
||||
{
|
||||
FT_GlyphSlot slot = srcdata->font_face->glyph;
|
||||
FT_UInt glyph_index = 0;
|
||||
uint32_t w = 0, max_w = 0;
|
||||
size_t len;
|
||||
|
||||
if (!text)
|
||||
if (!text) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
len = wcslen(text);
|
||||
FT_GlyphSlot slot = srcdata->font_face->glyph;
|
||||
uint32_t w = 0, max_w = 0;
|
||||
const size_t len = wcslen(text);
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
glyph_index = FT_Get_Char_Index(srcdata->font_face, text[i]);
|
||||
FT_Load_Glyph(srcdata->font_face, glyph_index, FT_LOAD_DEFAULT);
|
||||
const FT_UInt glyph_index =
|
||||
FT_Get_Char_Index(srcdata->font_face, text[i]);
|
||||
|
||||
load_glyph(srcdata, glyph_index, get_render_mode(srcdata));
|
||||
|
||||
if (text[i] == L'\n')
|
||||
w = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue