forked from metin-server/m2dev-client-src
FreeType: TextBar boldness fix
This commit is contained in:
@@ -94,7 +94,16 @@ void CBlockTexture::Render(int ix, int iy)
|
||||
STATEMANAGER.SetTexture(0, m_lpd3dTexture);
|
||||
STATEMANAGER.SetTexture(1, NULL);
|
||||
STATEMANAGER.SetFVF(D3DFVF_XYZ|D3DFVF_TEX1|D3DFVF_DIFFUSE);
|
||||
|
||||
STATEMANAGER.SaveRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
|
||||
STATEMANAGER.SaveRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
STATEMANAGER.SaveRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
||||
|
||||
STATEMANAGER.DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 4, 0, 2);
|
||||
|
||||
STATEMANAGER.RestoreRenderState(D3DRS_DESTBLEND);
|
||||
STATEMANAGER.RestoreRenderState(D3DRS_SRCBLEND);
|
||||
STATEMANAGER.RestoreRenderState(D3DRS_ALPHABLENDENABLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,10 +150,7 @@ void CBlockTexture::InvalidateRect(const RECT & c_rsrcRect)
|
||||
{
|
||||
for (int i = 0; i < iclipWidth; ++i)
|
||||
{
|
||||
if (pdwSrc[i])
|
||||
pdwDst[i] = pdwSrc[i] | 0xff000000;
|
||||
else
|
||||
pdwDst[i] = 0;
|
||||
pdwDst[i] = pdwSrc[i];
|
||||
}
|
||||
pdwDst += dwDstWidth;
|
||||
pdwSrc += dwSrcWidth;
|
||||
|
||||
@@ -62,8 +62,11 @@ bool CFontManager::Initialize()
|
||||
|
||||
// Common Latin fonts
|
||||
m_fontPathMap["arial"] = "arial.ttf";
|
||||
m_fontPathMap["arial bold"] = "arialbd.ttf";
|
||||
m_fontPathMap["tahoma"] = "tahoma.ttf";
|
||||
m_fontPathMap["tahoma bold"] = "tahomabd.ttf";
|
||||
m_fontPathMap["verdana"] = "verdana.ttf";
|
||||
m_fontPathMap["verdana bold"] = "verdanab.ttf";
|
||||
m_fontPathMap["times new roman"] = "times.ttf";
|
||||
m_fontPathMap["courier new"] = "cour.ttf";
|
||||
m_fontPathMap["segoe ui"] = "segoeui.ttf";
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <utf8.h>
|
||||
|
||||
#include <ft2build.h>
|
||||
#include FT_BITMAP_H
|
||||
#include FT_FREETYPE_H
|
||||
|
||||
#include <cmath>
|
||||
|
||||
@@ -22,8 +22,17 @@ static struct STextBarGammaLUT {
|
||||
|
||||
void CTextBar::__SetFont(int fontSize, bool isBold)
|
||||
{
|
||||
// Create a per-instance FT_Face (this instance owns it)
|
||||
m_ftFace = CFontManager::Instance().CreateFace("Tahoma");
|
||||
// Load bold font variant if available, otherwise fall back to regular
|
||||
if (isBold)
|
||||
{
|
||||
m_ftFace = CFontManager::Instance().CreateFace("Tahoma Bold");
|
||||
if (!m_ftFace)
|
||||
m_ftFace = CFontManager::Instance().CreateFace("Tahoma");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ftFace = CFontManager::Instance().CreateFace("Tahoma");
|
||||
}
|
||||
if (!m_ftFace)
|
||||
return;
|
||||
|
||||
@@ -109,11 +118,6 @@ void CTextBar::TextOut(int ix, int iy, const char * c_szText)
|
||||
continue;
|
||||
|
||||
FT_GlyphSlot slot = m_ftFace->glyph;
|
||||
|
||||
// Apply synthetic bold (32 = 0.5px embolden; 64 = 1px was too aggressive)
|
||||
if (m_isBold && slot->bitmap.buffer)
|
||||
FT_Bitmap_Embolden(CFontManager::Instance().GetLibrary(), &slot->bitmap, 32, 0);
|
||||
|
||||
FT_Bitmap& bitmap = slot->bitmap;
|
||||
|
||||
int bmpX = penX + slot->bitmap_left;
|
||||
|
||||
@@ -38,7 +38,7 @@ PyObject* grpCreateBigTextBar(PyObject* poSelf, PyObject* poArgs)
|
||||
if (!PyTuple_GetInteger(poArgs, 2, &iFontSize))
|
||||
return Py_BuildException();
|
||||
|
||||
CTextBar * pTextBar = new CTextBar(iFontSize, true);
|
||||
CTextBar * pTextBar = new CTextBar(iFontSize, false);
|
||||
if (!pTextBar->Create(iWidth, iHeight))
|
||||
{
|
||||
delete pTextBar;
|
||||
|
||||
Reference in New Issue
Block a user