GSdx: Add Default OSD Font Resource (#3605)

GSdx: Add Roboto font to resources and make it the default for the OSD
This commit is contained in:
JC 2020-09-01 08:50:09 -07:00 committed by GitHub
parent 6a4e93db3c
commit 23248b5293
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 84 additions and 9 deletions

View File

@ -94,6 +94,9 @@ bool GSdxApp::LoadResource(int id, std::vector<char>& buff, const char* type)
case IDR_TFX_CL:
path = "/GSdx/res/tfx.cl";
break;
case IDR_FONT_ROBOTO:
path = "/GSdx/res/fonts-roboto/Roboto-Regular.ttf";
break;
default:
printf("LoadResource not implemented for id %d\n", id);
return false;
@ -359,9 +362,9 @@ void GSdxApp::Init()
m_default_configuration["NTSC_Saturation"] = "1";
m_default_configuration["ocldev"] = "";
#ifdef _WIN32
m_default_configuration["osd_fontname"] = "C:\\Windows\\Fonts\\tahoma.ttf";
m_default_configuration["osd_fontname"] = "C:\\Windows\\Fonts\\my_favorite_font_e_g_tahoma.ttf";
#else
m_default_configuration["osd_fontname"] = "/usr/share/fonts/truetype/freefont/FreeSerif.ttf";
m_default_configuration["osd_fontname"] = "/usr/share/fonts/truetype/my_favorite_font_e_g_DejaVu Sans.ttf";
#endif
m_default_configuration["osd_color_r"] = "0";
m_default_configuration["osd_color_g"] = "160";

View File

@ -94,6 +94,8 @@ IDR_TFX_VGS_GLSL RCDATA "res\\glsl\\tfx_vgs.glsl";
IDR_TFX_FS_GLSL RCDATA "res\\glsl\\tfx_fs.glsl";
IDR_FONT_ROBOTO RCDATA "res\\fonts-roboto\\Roboto-Regular.ttf";
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap

View File

@ -22,16 +22,24 @@
#include "stdafx.h"
#include "GSdx.h"
#include "GSOsdManager.h"
#ifdef _WIN32
#include "resource.h"
#endif
void GSOsdManager::LoadFont() {
FT_Error error = FT_New_Face(m_library, theApp.GetConfigS("osd_fontname").c_str(), 0, &m_face);
if (error) {
m_face = NULL;
fprintf(stderr, "Failed to init the freetype face\n");
if(error == FT_Err_Unknown_File_Format)
fprintf(stderr, "\tFreetype unknown file format\n");
return;
FT_Error error_load_res = 1;
if(theApp.LoadResource(IDR_FONT_ROBOTO, resource_data_buffer))
error_load_res = FT_New_Memory_Face(m_library, (const FT_Byte*)resource_data_buffer.data(), resource_data_buffer.size(), 0, &m_face);
if (error_load_res) {
m_face = NULL;
fprintf(stderr, "Failed to init freetype face from external and internal resource\n");
if(error == FT_Err_Unknown_File_Format)
fprintf(stderr, "\tFreetype unknown file format for external file\n");
return;
}
}
LoadSize();

View File

@ -95,4 +95,8 @@ class GSOsdManager {
GSVector2i m_real_size;
size_t Size();
size_t GeneratePrimitives(GSVertexPT1* dst, size_t count);
private:
std::vector<char> resource_data_buffer;
};

View File

@ -98,5 +98,7 @@ enum {
IDR_TFX_VGS_GLSL,
IDR_TFX_FS_GLSL,
IDR_TFX_CL,
// fonts
IDR_FONT_ROBOTO,
};
#endif

Binary file not shown.

View File

@ -0,0 +1,52 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Roboto
Upstream-Contact: https://github.com/google/roboto/issues
Source: git clone https://github.com/google/roboto
Comment: Tarball created from git clone using this command:
git archive HEAD --format=tar
Files: *
Copyright: 2015, Google Inc.
License: Apache-2.0
Files: hinted/*
out/*
scripts/lib/*
src/v2/*
scripts/render.sh
scripts/build-v2.py
scripts/run_exhaustive_tests.py
scripts/coverage_test.py
scripts/touchup_for_web.py
scripts/temporary_touchups.py
scripts/run_web_tests.py
scripts/touchup_for_android.py
scripts/roboto_data.py
scripts/force_yminmax.py
scripts/run_general_tests.py
Copyright: 2015, Google Inc.
License: Apache-2.0
Files: scripts/subset_for_web.py
third_party/fontcrunch/*
Copyright: 2014, Google Inc.
License: Apache-2.0
Files: third_party/spiro/*
Copyright: 2007, Raph Levien
License: GPL-2+
Files: debian/*
Copyright: 2015, Vasudev Kamath <vasudev@copyninja.info>
2015, Jonas Smedegaard <dr@jones.dk>
License: GPL-3+
License: Apache-2.0
License-Reference: /usr/share/common-licenses/Apache-2.0
License: GPL-2+
License-Reference: /usr/share/common-licenses/GPL-2
License: GPL-3+
License-Reference: /usr/share/common-licenses/GPL-3

View File

@ -30,4 +30,7 @@
<gresource prefix="/GSdx/res/">
<file>tfx.cl</file>
</gresource>
<gresource prefix="/GSdx/res/">
<file>fonts-roboto/Roboto-Regular.ttf</file>
</gresource>
</gresources>

View File

@ -155,13 +155,14 @@
#define IDR_COMMON_GLSL 10015
#define IDR_TFX_VGS_GLSL 10016
#define IDR_TFX_FS_GLSL 10017
#define IDR_FONT_ROBOTO 10018
#define IDC_STATIC -1
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 10018
#define _APS_NEXT_RESOURCE_VALUE 10019
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 2194
#define _APS_NEXT_SYMED_VALUE 5000